// Events Management
////////////////////////////////////////////////////////////////////////
function addEvent(elm, evType, fn, useCapture){
	if(elm.addEventListener){
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}else if (elm.attachEvent){
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}else{
		elm['on' + evType] = fn;
	}
}
function getEvent()
{
	if(window.event) {
		return this.window.event;
	}else{
		return getEvent.caller.arguments[0];
	}
}


// Find rel="external" popups
// Nabbed from: http://www.thefutureoftheweb.com/blog/submit-a-form-in-ie-with-enter
////////////////////////////////////////////////////////////////////////
function findPopUps()
{
	var popups = document.getElementsByTagName("a");
	for (i=0;i<popups.length;i++)
	{
		if (popups[i].rel.indexOf("external")!=-1)
		{
			// attach popup behaviour
			popups[i].target = '_blank';
			//popups[i].onclick = doPopUp;
			// add info to title attribute to alert fact that it's a pop-up window
			popups[i].title = popups[i].title + " [Opens in new window]";
		}
		else if (popups[i].rel.indexOf("home page")!=-1)
		{
			// attach popup behaviour
			popups[i].target = '_top';
		}
	}
}


// Setup Events
////////////////////////////////////////////////////////////////////////
addEvent(window, 'load', findPopUps, false);