var theIMG;
var marginTop = 200;
var paddingTop = 300;

function getObj(name) {
	if (document.getElementById) {
		if (document.getElementById(name))
			return document.getElementById(name);
	} else if (document.all) {
		if (document.all[name])
			return document.all[name];
	} else if (document.layers) {
		if (document.layers[name])
			return document.layers[name];
	}
}

function moveIMG(original, from, to, mouse_add) {
	var allLength = to-original;
	var alreadyWent = from-original;
	
	var percentWent = alreadyWent / allLength;
	if (percentWent > 1) { return 0; }
	var speed = Math.cos(percentWent) * 12;
	
	
	theIMG.style.top = from+'px';
	if(mouse_add == 1){
		theIMG.style.left = (mouseX+10)+'px';
	}
	if (from <= to)
		temp = setTimeout('moveIMG('+original+', '+(from+speed)+', '+to+', '+mouse_add+')', 10);
}

function getPos() {
	var pos = 0;
	if (window.innerHeight) {
		pos = window.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		pos = document.documentElement.scrollTop;
	} else if (document.body) {
		pos = document.body.scrollTop;
	}
	return pos;
}

/*function findeL(obj){
	var lPos = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			lPos += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		lPos += obj.x;
		return lPos;
}
	
function findeO(obj){
	var oPos = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			oPos += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		oPos += obj.y;
	return oPos;
} */

function showIMG(id, mouse_add){
	theIMG = getObj(id);
	test = getObj('selected_data');
	pos = getPos();
	theIMG.style.top = mouseY + 'px';
	theIMG.style.left = mouseX + 'px';
	theIMG.style.display='block';
	//var to = pos+paddingTop;
	//if (to < marginTop) to = marginTop;
	//moveIMG(pos-400, pos-400, to,mouse_add);
}

function hideIMG(){
	theIMG.style.display='none';
}