// clickreg stuff by adam@1k.dk

function xmlhttpPost(strURL,strRequest)
{
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest)
	{
	    self.xmlHttpReq = new XMLHttpRequest();
	}
	// Internet Exploder
	else if (window.ActiveXObject)
	{
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL+strRequest, false); // false bestemmer noget med om requests skal streame eller lukke.. slå det op og læs.
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function()
	{
		if (self.xmlHttpReq.readyState == 4)
		{
		// option for returning result
		// updatepage(self.xmlHttpReq.responseText);
		}
	}
	// for adding allot of data via a function
	// self.xmlHttpReq.send(getquerystring());
	self.xmlHttpReq.send('w='+escape(strRequest));
}

function updatepage(str){
	document.getElementById("result").innerHTML = str;
}

// main cord red function
function doSomething(e)
{
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	bodyX = document.body.clientWidth;
	bodyY = document.body.clientHeight;
	strCords = '&cx=' + posx + '&cy=' + posy + '&bx=' + bodyX + '&by=' + bodyY;
	strUrl = '/d/1k/static/clickreg.php?mode=log';
	xmlhttpPost(strUrl,strCords);
}

document.onclick = doSomething;

