function astrack_click() 
{
	urchinTracker('/asclick');
}


//BEGIN Specific for firefox (to handle mouse position check when we leave the page)
var px;
var py;

function astrack_getmouse(e)
{
	px=e.pageX;
	py=e.clientY;
}

function astrack_findy(obj)
{
	var y = 0;
	while (obj) 
	{
		y += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return(y);
}

function astrack_findx(obj) 
{
	var x = 0;
	while (obj)
	{
		x += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return(x);
}

function astrack_pageexit(e) 
{
	ad = document.getElementsByTagName("iframe");
	for (i=0; i<ad.length; i++) 
	{
		var adLeft = astrack_findx(ad[i]);
		var adTop = astrack_findy(ad[i]);
		var inFrameX = (px > (adLeft - 10) && px < (parseInt(adLeft) + parseInt(ad[i].width) + 15));
		var inFrameY = (py > (adTop - 10) && py < (parseInt(adTop) + parseInt(ad[i].height) + 10));
		
		if (inFrameY && inFrameX) 
		{
			astrack_click();
		}
	}
}
//END Specific for firefox 


function astrack_init()
{
	if (document.all)   //ie: onfocus function called when ad is clicked
	{
		var el = document.getElementsByTagName("iframe");
		for(var i = 0; i < el.length; i++) 
		{
			if(el[i].src.indexOf('googlesyndication.com') > -1)
				el[i].onfocus = astrack_click;
		}
	} 
	else 				// firefox: check mouse position when page is unloaded
	{
		window.addEventListener('beforeunload', astrack_pageexit, false);
		window.addEventListener('mousemove', astrack_getmouse, true);
	}
}


// Add onLoad handler, for all browsers (prevents having to manually modify it for each page)
if(typeof window.addEventListener != 'undefined')
{
	window.addEventListener('load', astrack_init, false);	//For gecko, safari, konqueror and standard
}
else if(typeof document.addEventListener != 'undefined')
{
	document.addEventListener('load', astrack_init, false);	//For opera 7
}
else if(typeof window.attachEvent != 'undefined')
{
	window.attachEvent('onload', astrack_init);				//For win/ie
}
else														//For older browsers (mac/ie5 ...)
{
	if(typeof window.onload == 'function')	//If there's an existing onload function
	{
		var existing_onload = onload;			//Store it
		window.onload = function()				//Then add new onload handler
		{
			existing_onload();					//Call existing onload function
			astrack_init();						//Call astrack_init onload function
		};
	}
	else									//Setup onload function
	{
		window.onload = astrack_init;
	}
}