function showHideElementById(id) {
	if (document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "";
	} else {
		document.getElementById(id).style.display = "none";
	}
}

function setElementPositionByOtherTopRight(element1, element2) {
	element1.style.top = eval(findPosTopLeft(element2)[0] - element1.clientHeight) + "px";
	element1.style.left = eval(findPosTopLeft(element2)[1] - element1.clientWidth + element2.clientWidth) + "px";
}

function setElementPositionByOtherBottom(element1, element2) {
	element1.style.top = findPosBottom(element2)[0] + "px";
	element1.style.left = findPosBottom(element2)[1] + "px";
}

function setElementPositionByOtherBottomWithId(element1Id, element2Id) {
	document.getElementById(element1Id).style.top = findPosBottom(document.getElementById(element2Id))[0] + "px";
	document.getElementById(element1Id).style.left = findPosBottom(document.getElementById(element2Id))[1] + "px";
}

function setElementPositionByOtherLeft(element1, element2) {
	element1.style.top = findPosLeft(element2)[0] + "px";
	element1.style.left = findPosLeft(element2)[1] + "px";
}


function showHideByOtherBottomWithId(element1Id, element2Id) {
	document.getElementById(element2Id).style.top = eval(findPosBottom(document.getElementById(element1Id))[0] + 7) + "px";
	document.getElementById(element2Id).style.left = findPosBottom(document.getElementById(element1Id))[1] + "px";
	
	showHideElementById(element2Id);
}

function setLang( lang ) {
	location.href = 'changeLang.php?lang=' + lang;
}

function setElementPositionScreenCenter(elementId)
	{
	/*
		var element = document.getElementById(elementId);
		
		element.style.left = "0 px"
		element.style.top = "0 px"
		
		var elementHeight = eval(element.offsetHeight);
		var elementWidth = eval(element.offsetWidth);
		
		alert(elementHeight + "---" + elementWidth);
		
		element.style.left = eval((screen.width / 2) - (elementWidth / 2)) + "px";
		element.style.top = eval((screen.height / 2) - (elementHeight / 2)) + "px";
		
		alert(element.style.left + "---" + element.style.top);
		
		*/
		
		//var screenXmid,screenYmid;

		//screenXmid=parseInt(document.body.clientWidth/2);
		//screenYmid=parseInt(document.body.clientHeight/2);
		
		//alert(screenXmid + "---" + screenYmid);
		
		//var divId=document.getElementById(elementId);
		
		//var divXmid= parseInt(divId.offsetWidth/2);
		//var divYmid=parseInt(divId.offsetHeight/2);
		
		//divId.style.left= screenXmid - divXmid;
		//divId.style.top= screenYmid - divYmid;
		
		var element = document.getElementById(elementId);
		element.style.height = document.body.clientHeight + "px";
		element.style.width = document.body.clientWidth + "px";
		
		//alert(divXmid + "---" + divYmid);
		
		
	}

function findPosTopLeft(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = curtop + obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curtop, curleft];
}

function findPosBottom(obj) {
	var curleft = curtop = 0;
	curtop = obj.clientHeight + 3;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = curtop + obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curtop, curleft];
}

function findPosLeft(obj) {
	var curleft = curtop = 0;
	curleft = obj.clientWidth + 3;
	if (obj.offsetParent) {
		curleft = curleft + obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curtop, curleft];
}

function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else {
		if (obj.x) {
			curleft += obj.x;
		}
	}
	return curleft;
}
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else {
		if (obj.y) {
			curtop += obj.y;
		}
	}
	return curtop;
}

function showImage(imageUrl) {
	
	//background
	var backgroundHeight = document.getElementById("bodyCell").clientHeight;
	var backgroundWidth = document.getElementById("bodyCell").clientWidth;
	var backgroundTop = findPosY(document.getElementById("bodyCell"));
	var backgroundLeft = findPosX(document.getElementById("bodyCell"));
	
	
	//pleaseWaitBackgroundDiv
	document.getElementById("imageBackgroundDiv").style.height = eval(backgroundHeight) + "px";
	document.getElementById("imageBackgroundDiv").style.width = eval(backgroundWidth) + "px";
	document.getElementById("imageBackgroundDiv").style.top = eval(backgroundTop) + "px";
	document.getElementById("imageBackgroundDiv").style.left = eval(backgroundLeft) + "px";
	document.getElementById("imageBackgroundDiv").style.visibility = "visible";
	
	document.getElementById("selectedImage").src = imageUrl;
	
	
	
	//document.getElementById("selectedImage").style.border = "1px solid #444444";
	
	//Reflection.add(document.getElementById('selectedImage'), { height: 0.2, opacity: 0.5});
	
	//alert(document.getElementById('selectedImage').height);
	
	//document
	var documentHeight = document.body.clientHeight;
	var documentWidth = document.body.clientWidth;
	//var documentHeight = 0;
	//var documentWidth = 0;
	
	//pleaseWaitDiv
	document.getElementById("selectedImage").style.top = eval((documentHeight / 2) - (document.getElementById("selectedImage").clientHeight / 2)) + "px";
	document.getElementById("selectedImage").style.left = eval((documentWidth / 2) - (document.getElementById("selectedImage").clientWidth / 2)) + "px";
	document.getElementById("selectedImage").style.top = eval((backgroundHeight / 2) - (document.getElementById("selectedImage").clientHeight / 2)) + "px";
	document.getElementById("selectedImage").style.left = eval((backgroundWidth / 2) - (document.getElementById("selectedImage").clientWidth / 2))+ "px";
	//document.getElementById("selectedImage").style.top = documentHeight + "px";
	//document.getElementById("selectedImage").style.left = documentWidth + "px";
	//document.getElementById("selectedImage").style.visibility = "visible";
}

function getKeycode(e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	return keycode;
}
