﻿function getpos()
{
	var IE = document.all?true:false;
	if (!IE) document.captureEvents(Event.MOUSEMOVE)
	document.onmousemove = getMouseXY;
	var tempX = 0;
	var tempY = 0;
	function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
	tempX = event.clientX + document.body.scrollLeft;
	tempY = event.clientY + document.body.scrollTop;
	}
	else {  // grab the x-y pos.s if browser is NS
	tempX = e.pageX;
	tempY = e.pageY;
	}  
	
	var viewporth = getvp();
	var half = (viewporth / 2);
	
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  
	document.getElementById('maindiv').style.marginLeft = "-"+(tempX*4)+"px";
	document.getElementById('maindiv').style.marginTop = "-"+(tempY*3)+"px";
	
	//document.body.style.marginLeft = tempX+"px";
	//document.body.style.marginTop = tempY+"px";
	return true;
	}
}

function getvp()
{
	 var viewportwidth;
	 var viewportheight;
	 
	 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 
	 if (typeof window.innerWidth != 'undefined')
	 {
		  viewportwidth = window.innerWidth,
		  viewportheight = window.innerHeight
	 }
	 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	
	 else if (typeof document.documentElement != 'undefined'
		 && typeof document.documentElement.clientWidth !=
		 'undefined' && document.documentElement.clientWidth != 0)
	 {
		   viewportwidth = document.documentElement.clientWidth,
		   viewportheight = document.documentElement.clientHeight
	 }
	 
	 // older versions of IE
	 
	 else
	 {
		   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		   viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }
	 
	 // Set start position
	 var startx = viewportwidth / 2;
	 var starty = viewportheight / 2;
	 document.getElementById('maindiv').style.marginLeft = startx+"px";
	 document.getElementById('maindiv').style.marginTop = starty+"px";
	 
	 return viewportheight;
	//-->

}

