var xmouse = 0, ymouse = 0, xicon = 0, yicon = 0;
var moveimg = null;
function mouseMove (e) {
	if(window.event) e = window.event;
	xmouse = e.clientX + scrollLeft();
	ymouse = e.clientY + scrollTop();
}
function moveImage () {
	var len = Math.sqrt(Math.pow(xmouse - xicon, 2) +
		Math.pow(ymouse - yicon, 2));
	var len2 = len / 2;
	if(len2 >= 8) {
		xicon = Math.round(len2/len * (xmouse - xicon)
			+ xicon);
		yicon = Math.round(len2/len * (ymouse - yicon)
			+ yicon);
		moveimg.style.left = xicon + "px";
		moveimg.style.top  = yicon + "px";
	}
	setTimeout("moveImage();", 100);
}
function moveImageInit() {
	moveimg = document.createElement("IMG");
	moveimg.src = imagefile;
	moveimg.style.position = "absolute";
	document.body.appendChild(moveimg);
	
	document.onmousemove = mouseMove;
	
	moveImage();
}
if(document.getElementById) window.onload = moveImageInit;

function scrollTop () {
	if(window.pageYOffset)
		return window.pageYOffset;
	if(document.compatMode == "CSS1Compat")
		return document.documentElement.scrollTop;
	if(document.body.scrollTop)
		return document.body.scrollTop;
	return 0;
}
function scrollLeft () {
	if(window.pageXOffset)
		return window.pageXOffset;
	if(document.compatMode == "CSS1Compat")
		return document.documentElement.scrollLeft;
	if(document.body.scrollLeft)
		return document.body.scrollLeft;
	return 0;
}
