//UML sitewide javascript file
//
//@author Kareem Abu-Zahra
//@version 0.1
//@date January, 22, 2008


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;}
}

addEvent(window, 'load', addLinkTracker, false);

function addLinkTracker()
{
    if (!document.getElementsByTagName) return false;
    
    
    linksElement = document.getElementById('enewsLink')

    addEvent(linksElement, 'mousedown', recordClick, true);
}


function recordClick(e)
{

 	url = document.location.href;


	var xhr;
	try
	{
		xhr = new XMLHttpRequest();
	} catch (error)
	{
		try
		{
			xhr = new ActiveXObject('Microsoft.XMLHTTP');
		} catch (error)
		{
			xhr = null;
		}
	}
	
	if (xhr != null)
	{
		xhr.open('GET', 'http://www.uml.edu/linkcatcher/count2.asp', true);

		xhr.onreadystatechange = function()
		{
			if (xhr.readyState == 4)
			{
				if (xhr.status == 200 || xhr.status == 304)
				{
				    //silent fail
					//alert("Error: " + xhr.status);
				}
		    } else {
		    }
		};
		xhr.send(null);
	}	
}



