// incredibly funky onload add-event scripting, for all browsers

		 if(typeof window.addEventListener != 'undefined')
		 {
		 	window.addEventListener('load', adsense_init, false);	//.. gecko, safari, konqueror and standard
		 }
		 else if(typeof document.addEventListener != 'undefined')
		 {
		 	//.. opera 7
		 	document.addEventListener('load', adsense_init, false);
		 }
		 else if(typeof window.attachEvent != 'undefined')
		 {
		 	//.. win/ie
		 	window.attachEvent('onload', adsense_init);
		 }

		 //** remove this condition to degrade older browsers
		 else
		 {
		 	//.. mac/ie5 and anything else that gets this far

		 	//if there's an existing onload function
		 	if(typeof window.onload == 'function')
		 	{
		 		//store it
		 		var existing = onload;

		 		//add new onload handler
		 		window.onload = function()
		 		{
		 			//call existing onload function
		 			existing();

		 			//call adsense_init onload function
		 			adsense_init();
		 		};
		 	}
		 	else
		 	{
		 		//setup onload function
		 		window.onload = adsense_init;
		 	}
		 }


function adsense_init () {

	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) {
				adUnit = i+1;
				browser = "IE";
				adunitsize = el[i].width + "x" + el[i].height;
				el[i].onfocus = trackAdsense;
			}
		}
	
	} else {   // firefox
	
		window.addEventListener('beforeunload', doPageExit, false);
		window.addEventListener('mousemove', getMouse, true);
	
	}
		
}

//for firefox
var px;
var py;
var adUnit = "";
var browser = "";
var adunitsize = "";

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) {
			adUnit = i+1;
			browser = "Firefox";
			adunitsize = ad[i].width + "x" + ad[i].height;
			trackAdsense();
		
		}
	}

}

//end for firefox
function ct_getURLvar( url, varName )
{
	var match = url.match( new RegExp("[&?]"+escape(varName)+"=(.+?)(&|$)" ) );

	if ( match != null )
		return match[1];
	else
		return '';
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function setCookie (name, value, expires, path) {
var valu;

if(!(valu = getCookie("click"))) 

var waw;
waw=valu+1;

      document.cookie = name + "=" + waw +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "");
}


function trackAdsense() {

	setCookie ("click", 1, "Mon, 26-May-2008 00:00:00 GMT", "/");

	var path = 'http://detkam.e-papa.ru/pepper/data.php';

	// can't use encodeURIComponent everywhere. escape() should work for this scenario
	path += "?from_title="+encodeURIComponent(document.title);
	path += "&from="+encodeURIComponent(self.location);
	path += "&unit="+encodeURIComponent(adUnit);
	path += "&browser="+escape(browser);
	path += "&adunitsize="+escape(adunitsize);
	

	var data = false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	try { data = new ActiveXObject("Msxml2.XMLHTTP"); } 
	catch (e) { try { data = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { data = false; } }
	@end @*/
	if (!data && typeof XMLHttpRequest!='undefined') data = new XMLHttpRequest();
	if (data) data.open("GET", path, false); data.send(null);

}