// JavaScript Document
function externalLinks() {
  //we need getElementsByTagName for this to work
  if (!document.getElementsByTagName) return;
 
  //get all the anchors within the document
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) { //loop through all the anchors
    var anchor = anchors[i];
   
    //check to make sure that we have a href, so its a real hyperlink
    //and make sure that we have a ref and its set to external
    if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
   
      //assign the dynamic function to the onclick event.
      anchor.onclick = function(x) {
        //store the variable so that we can actually use it within each function
        var p = x;
        return function() {
          var w = window.open(p); //try and open up a new window with the url
          if(!w) { //check to see if the window opened
            //let the user know that a window didnt open
            alert("Die Sicherheitseinstellungen ihres Computers haben vielleicht verhindert, daß diese Seite angezeigt wird.");
          }
         
          //return false to make sure the browser doesnt navigate away in the current window also
          return false;
        }
      }(anchor.getAttribute("href")); //pass through the href for this anchor
    }
  }
}

//make sure we only set everything up on load
//after the DOM has been inited
window.onload = externalLinks;
