/*
	Translation script
	
	requires:		an element names 'popup', with element names
					'errMsg' to which it changes it's content
	can use:
	what is does: 	displays a popup message
	notes:
	
*/

function messageDlg(message,align,reference,type) {
	if(!type) type = "alert";
	switch (type) {
		case "tooltip" :
			itemRef = document.getElementById(reference);
			popupDiv = document.getElementById("popup");
			document.getElementById("errMsg").innerHTML = message;
			popupDiv.style.left = findPosX(itemRef) + itemRef.offsetWidth + "px";
			popupDiv.style.top = (findPosY(itemRef) - (popupDiv.offsetHeight /2 ) + (itemRef.offsetHeight / 2)) + "px";						
			popupDiv.style.visibility = "visible";
			break;
		case "alert" :
			window.status = message;
			alert(message);
			break;
	}
}
function clearMessageDlg () {
	document.getElementById("popup").style.visibility = "hidden";
	window.status = "";
}

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;
}
