
//  Javascript function ExternalLinks()
//
//  This script is a work around for the fact that the W3C has
//  deprecated the target attribute from the "a" tag.
//  This is a pain since target="_blank" is useful for opening
//  up new windows and since javascript pop-up windows are
//  often disabled by ad-blocking measures and since it disrupts
//  referers.
//
//  If this script is linked from between the "head" and "/head" tags
//  then any "a" tag with a rel="external" attribute in it will
//  open the link in a new window.  If javascript is not present
//  or disabled or getElementByTagName is not supported by
//  the browser then the link will open in the same old window.

//  This works via DOM technology which used javascript to edit
//  put in the target="_blank" dynamically.  Oddly enough target
//  while deprecated from (X)HTML is still part of the DOM standard.
//  Go figure. The reason is the W3C's insistance that (X)HTML not
//  have having anything besides content.
//
//  This script is modified from a web article by Kevin Yank located at
//
//  www.sitepoint.com/article/1041

function ExternalLinks()
{ 
   if (!document.getElementsByTagName)
       return; // If not supported abort function
	 re=/external/;  // regular expression
   var anchors = document.getElementsByTagName("a"); // Find all "a" tags
   for (var i=0; i < anchors.length; i++) // Loop through "a"tags
   {
       var anchor = anchors[i]; 
			 var attr = anchor.getAttribute("rel");
       if ( anchor.getAttribute("href") &&     // If href attribute is present
            (attr=="external" ||
						 re.test(attr) )  )                // and rel="external" is present
           anchor.target = "_blank";           // then create a target="_blank"
   } // end of for loop
} // end function
