var asAdBoxes = new Array();

var curFrame = -1; // used to track which AdBox the mouse is over

function doMouseOverAdBlock(n)
{
	curFrame = n;
	//alert(curFrame);
}

function doMouseOutAdBlock(n)
{
	curFrame = -1;
	//alert(curFrame);
}

function logASClick()
 { 
	//alert('hello');
    var theURL=""+ escape(window.status.substring(6)) ;
	if(curFrame > -1)
	{
		var format=findItem('format',asAdBoxes[curFrame].src);
		var channel=findItem('channel',asAdBoxes[curFrame].src);
	}
	var thispage = escape(document.URL);
    var img = new Image();
    var title=escape(document.location);
    img.src = 'http://www.sensestats.com/logclicks.php?ref=' + escape(document.referrer) + '&src=' + thispage + '&url=' +theURL +'&title=' + title+ '&format=' + format +'&channel='+channel+'&cid='+sscid+'&adb='+curFrame ; 
}  

function logASClick2(frameno)
 { 
	 curFrame = frameno;

	//alert('hello');
    var theURL=""+ escape(window.status.substring(6)) ;
	if(curFrame > -1)
	{
		var format=findItem('format',asAdBoxes[curFrame].src);
		var channel=findItem('channel',asAdBoxes[curFrame].src);
	}
	var thispage = escape(document.URL);
    var img = new Image();
    var title=escape(document.location);
    img.src = 'http://www.sensestats.com/logclicks.php?ref=' + escape(document.referrer) + '&src=' + thispage + '&url=' +theURL +'&title=' + title+ '&format=' + format +'&channel='+channel+'&cid='+sscid+'&adb='+curFrame ; 
}  
 
function findItem(item, source)
{
   var start=source.indexOf(item);
   if (start == -1)
		return "";
   var source2=source.substring(start);
   var end=source2.indexOf("&");
   var source3=source2.substring(0,end);
   var retval=source3.substring(item.length+1);
   return retval;
} 
 
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 getASBoxes()
{
	var adboxes;

	if(document.getElementsByTagName) {
		adboxes = document.body.getElementsByTagName("IFRAME");
	} else if (document.body.all) {
		adboxes = document.body.all.tags("IFRAME");
	} else {
		adboxes = Array();
	}

	 return adboxes;
}
 
function addASBoxEvents()
{
	for (var i = 0; i < asAdBoxes.length; i++) 
	 { 
	   if(asAdBoxes[i].src.indexOf('googlesyndication.com') > -1) 
	   { 
			//addEvent(asAdBoxes[i], 'focus', logASClick, false);

			eval("addEvent(asAdBoxes[i], 'focus', function(e){logASClick2("+i+")}, false);");

			eval("addEvent(asAdBoxes[i], 'mouseover', function(e){doMouseOverAdBlock("+i+")}, false);");
	   } 
	 } 
}


asAdBoxes = getASBoxes();

addASBoxEvents();










