/* This script provides a replacement for the target="_blank"
   feature for links, which was removed from the (X)HTML Strict
   specs */

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") &&
        anchor.getAttribute("rel") == "external")
      anchor.target = "_blank";
  }

  /* For forms, we can't do a target="_blank" anymore, either.
     This section of the function makes a form go to a new
     window by default. */
  var forms = document.getElementsByTagName("form");
  for (var i = 0; i < forms.length; i++) {
   var form = forms[i];
   if (form.getAttribute("action").substring(0, 4) == "http")
     form.target = "_blank";
  }
}

window.onload = externalLinks;
