/**
 * @author Aaron Romine
 * This method simply iterates all the anchor tags in the page
 * and checks to see if they point to an external URL.  If so
 * then it changes the target to "_new".
 */
function fixExternalLinks(){
    var location = window.location.host, //location to look for in the href
        prefix = "://", //Prefix
        tagName = "A", //node name
        target = "_new", //new target for the a links
        nodes; //Nodes to iterate
    if(document.getElementsByTagName){
		nodes = document.getElementsByTagName(tagName); //DOM support
	}
	else if(document.all && document.all.tags){
		nodes = document.all.tags(tagName); //IE 4 support
	}
	else if(document.links){
		nodes = document.links; //Netscape 4 support
	}
	if(nodes && nodes.length){
	    for(var i = 0, len = nodes.length; i<len; i++){
	       //If the node has an href and it is an external link, and the link isn't our domain change its target.
	       if(nodes[i].href && nodes[i].href.indexOf(prefix)>0 && nodes[i].href.indexOf(prefix+location)<0){
	           nodes[i].target = target; //change the target if the link has an href, and contains the location string
	       }
	    }
	}
}
//Add the hooks to the window's load.
if (window.addEventListener){ //DOM method for binding an event 
     window.addEventListener("load", fixExternalLinks, false);
}
else if (window.attachEvent){ //IE exclusive method for binding an event version 4-7
    window.attachEvent("onload", fixExternalLinks);
}
else {
	if(window.onload){
		window.onload += ";fixExternalLinks();" //Hopefully NN4, IE3
	}
	else	{
		window.onload = "fixExternalLinks();";
	}
}