// JavaScript Document

function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
  if (elm.addEventListener){
	elm.addEventListener(evType, fn, useCapture);
	return true;
  } else if (elm.attachEvent){
	var r = elm.attachEvent("on"+evType, fn);
	return r;
  } else {
	alert("Handler could not be removed");
  }
} 
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.setAttribute("target","_blank");
 }
}

addEvent(window, "load", externalLinks);

/*
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";
			anchor.title = (anchor.title != "") ? anchor.title+" (opens in a new window)" : "opens in a new window";
			anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
		}
	}
}

window.onload = externalLinks;

function externalLinks()
{
	if (document.getElementsByTagName)
	{
		var objAnchors = document.getElementsByTagName("a");
		for (var iCounter=0; iCounter<objAnchors.length; iCounter++)
		{
			if (objAnchors[iCounter].getAttribute("href") && objAnchors[iCounter].getAttribute("rel") == "external")
			{
				objAnchors[iCounter].onclick = function(event)
				{
					return launchWindow(this, event);
				}
				objAnchors[iCounter].onkeypress = function(event)
				{
					return launchWindow(this, event);
				}
			}
		}
	}
}
		
function launchWindow(objAnchor, objEvent)
{
	var iKeyCode;
	
	if (objEvent && objEvent.type == ‘keypress’)
	{
		if (objEvent.keyCode)
			iKeyCode = objEvent.keyCode;
		else if (objEvent.which)
			iKeyCode = objEvent.which;
	
		if (iKeyCode != 13 && iKeyCode != 32)
			return true;
	}
	return !window.open(objAnchor);
}
*/