var mousePos
document.onmousemove = mouseMove;

function mouseMove(ev){
	ev = ev || window.event;
	eventObj = ev;
	mousePos = mouseCoords(eventObj);
}

function mouseCoords(ev){
	var xpos, ypos;
	xpos = ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft;
	ypos = ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop;
	if(!xpos && !ypos){
		xpos = ev.screenX + document.documentElement.scrollLeft;
		ypos = ev.screenY + document.documentElement.scrollTop;
	}
	return new Array(xpos, ypos);
}


var time_ctr = 1;
var dv;
var divWidth = 0;
var divHeight = 0;
var animationLength = 10;
function show_div(div,w,h){
	var divObject = document.getElementById(div);
	divObject.style.display = "block";
	divObject.style.left=mousePos[0]+10+'px';
	divObject.style.top=mousePos[1]+10+'px';
	divWidth = w;
	divHeight = h;
	divObject.style.width=(divWidth/animationLength)+'px';
	divObject.style.height=(divHeight/animationLength)+'px';
	dv = divObject;
	window.setTimeout("animateOpen()", 20);
}
	
function animateOpen(){
	time_ctr++;
	dv.style.width=((divWidth/animationLength)*time_ctr)+'px';
	dv.style.height=((divHeight/animationLength)*time_ctr)+'px';
	if(time_ctr!=animationLength){
		window.setTimeout("animateOpen()", 20);
	} else {
		time_ctr = 1;
	}
}
	
var time_ctr2 = animationLength-1;

function hide_div(div){
	var divObject = document.getElementById(div);
	dv = divObject;
	window.setTimeout("animateClose()", 5000);
}
	
function animateClose(){
	time_ctr2--;
	if(time_ctr2>0){
		dv.style.width=((divWidth/animationLength)*time_ctr2)+'px';
		dv.style.height=((divHeight/animationLength)*time_ctr2)+'px';
		window.setTimeout("animateClose()", 20);
	} else {
		dv.style.display = "none";
		time_ctr2 = animationLength-1;
	}
}

function hide_div_now(div){
	var divObject = document.getElementById(div);
	dv = divObject;
	window.setTimeout("animateClose()", 20);
}
