(function($){

$(function(){

    var protocol = document.location.protocol;
    var host = document.location.toString().replace(protocol, '').replace('//','');
    if (host.indexOf("/") != -1) {
        host = host.substr(0, host.indexOf("/"));
    }
    $("a").each(function(){
        var hh = $(this).attr("href");
        if( hh.indexOf(protocol) != -1 && ( hh.indexOf(host)==-1 )){
            $(this).addClass("external");
        }
    });
});

})(jQuery);