function adsense_click() {
	top.window.focus();
	ProductWiki.Web.BasePage.PWPage.TrackGoogleAdsenseClick();
	urchinTracker('/productpage/clickthrus/adsense');
}

function sdc(pid) {
	top.window.focus();
	ProductWiki.Web.BasePage.PWPage.TrackShoppingDotComClick(pid);
	urchinTracker('/productpage/clickthrus/sdc');
}

function init_adsense() {
	if (document.all) {  //ie
		var el = document.getElementsByTagName("iframe");
		for(var i = 0; i < el.length; i++) {
			if(el[i].src.indexOf('googlesyndication.com') > -1) {

				el[i].onfocus =  adsense_click;
			}
		}
	} 
	else {   // firefox
		window.addEventListener('beforeunload', doPageExit, false);
		window.addEventListener('mousemove', getMouse, true);
	}
}


//for firefox
var px;
var py;

function getMouse(e) {
	px=e.pageX;
	py=e.clientY;
}

function findY(obj) {
	var y = 0;
	while (obj) {
		y += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return(y);
}

function findX(obj) {
	var x = 0;
	while (obj) {
		x += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return(x);
}

function doPageExit(e) {
	ad = document.getElementsByTagName("iframe");
	for (i=0; i<ad.length; i++) {
		var adLeft = findX(ad[i]);
		var adTop = 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) {
			adsense_click();
		}
	}
}
//end for firefox