function targetBlank(){
    if(document.getElementsByTagName){
        var as = document.getElementsByTagName("a");
        for(var i = 0; i < as.length; i++){

            var hostname = as[i].href.replace(/http(s)?\:\/\//, "");
            hostname = hostname.replace(/\/.*/, "");

            if(hostname != window.location.hostname || as[i].href.match(/\/ad\.php\?/) || as[i].href.match(/\/ldir\.php\?/) || as[i].href.match(/\.pdf/)){
                if(!as[i].target){
                    as[i].target = "_blank";
                    continue;
                }
            }
		}
    }
}
