function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName('a');
 for (var i=0; i<anchors.length; i++) 
 {
   var anchor = anchors[i];
   if ( anchor.getAttribute('href') )
   {
     if ( right(anchor.getAttribute('href'), 4) == '.pdf') 
     {
       anchor.setAttribute('target','_blank') ;
     }
   }
 } 
}
function right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
window.onload = externalLinks;
