var cX = 0; var cY = 0; var rX = 0; var rY = 0;

function UpdateCursorPosition(e){ 
	cX = e.pageX; cY = e.pageY;
}

function UpdateCursorPositionDocAll(e){ 
	cX = event.clientX; cY = event.clientY;
}

if(document.all) { 
	document.onmousemove = UpdateCursorPositionDocAll; 
}else{
	document.onmousemove = UpdateCursorPosition;
}

function AssignPosition(d) {
	if(self.pageYOffset) {
		rX = self.pageXOffset;
		rY = self.pageYOffset;
	}else if(document.documentElement && document.documentElement.scrollTop){
		rX = document.documentElement.scrollLeft;
		rY = document.documentElement.scrollTop;
	}else if(document.body){
		rX = document.body.scrollLeft;
		rY = document.body.scrollTop;
	}

	if(document.all) {
		cX += rX;
		cY += rY;
	}

	d.style.left = (cX+10) + "px";
	d.style.top = (cY+10) + "px";
}

function HideContent(d) {
	if(d.length < 1) { return; }
	//document.getElementById(d).style.display = "none";
	$("#"+d).fadeOut("fast");
}

function ShowContent(d) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	AssignPosition(dd);
	$("#"+d).fadeIn("fast");
	//dd.style.display = "block";
}

function displayDiv(divTag, dwidth, dheight){
	var A = document.getElementById(divTag);
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		var C = window.innerWidth;
		var D = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		var C = document.documentElement.clientWidth;
		var D = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		var C = document.body.clientWidth;
		var D = document.body.clientHeight;
	}

	//must display block first to have clientWidth and clientHeight
	//A.style.display = "block";

	//var elementWidth = A.clientWidth;
	//var elementHeight = A.clientHeight;
	
	var elementWidth = dwidth;
	var elementHeight = dheight;
	
	A.style.top = String(Math.round((D-elementHeight)/2))+"px";
	A.style.left = String(Math.round((C-elementWidth)/2))+"px";
	
	$("#"+divTag).fadeIn("slow");
}

function hideDiv(divTag){
	$("#"+divTag).fadeOut("slow");
}
