/**
 * Add target="_blank" to external links
 */

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("target") &&
       anchor.getAttribute("href") &&
       anchor.getAttribute("href").slice(0, 4) == "http" &&
       anchor.getAttribute("href").split('.')[1] != "seligson")
     anchor.target = "_blank";
 }
}

// this is to preserve any onload functions set by other scripts
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(externalLinks);
