
$(document).ready(
	function() {
		$(document).pngFix(); 
	}
);


var pausePopup = 0;

function showInCenter(ident) {

	editwin = document.getElementById(ident);

	setToCenter(editwin);

	editwin.style.visibility = "visible";

}

function showNearMouse(ident, event) {

	editwin = document.getElementById(ident);

	setNearMouse(editwin, event);

	editwin.style.visibility = "visible";

}

function hidediv(ident) {

	document.getElementById(ident).style.visibility = "hidden";

}

function setToCenter(obj) {

	var isIE = (String(typeof(document.all)) != "undefined");

	var body_width = isIE ? document.body.parentNode.offsetWidth : window.innerWidth;

	var body_height = isIE ? document.body.parentNode.offsetHeight : window.innerHeight;

	var bwidth  = obj.clientWidth;

	var bheight = obj.clientHeight;

	var left = document.body.parentNode.scrollLeft + (body_width - bwidth)/2;

	var top  = document.body.parentNode.scrollTop + (body_height - bheight)/2;

	obj.style.left = left + "px";

	obj.style.top  = top + "px";

}

function setNearMouse(obj, e) {

	var isIE = (String(typeof(document.all)) != "undefined");

	var body_width = isIE ? document.body.parentNode.offsetWidth : window.innerWidth;

	var body_height = isIE ? document.body.parentNode.offsetHeight : window.innerHeight;

	var width = obj.clientWidth;

	var height = obj.clientHeight;

	var left = (isIE ? event.clientX : e.clientX) + 5;

	var top  = (isIE ? event.clientY : e.clientY) + 5;

	

	if ((left + width) > body_width) {

		var left = left - width -10;

	}

	if ((top + height) > body_height) {

		var top = top - height - 10;

	}

	obj.style.left = document.body.parentNode.scrollLeft + left + "px";

	obj.style.top  = document.body.parentNode.scrollTop + top + "px";

}

function showPopUpText(titleobj) {

	var textobj = titleobj.firstChild;

	textobj.style.display = "block";
	
	titleobj.style.zIndex = 150;
	
	textobj.style.zIndex = 150;
	
	pausePopup = false;

}

function hidePopUpText(titleobj) {
	
	if (!pausePopup)
	{
		var textobj = titleobj.firstChild;
	
		textobj.style.display = "none";
		
		titleobj.style.zIndex = 1;
	
		textobj.style.zIndex = 1;
	}
}

function showCoords(obj, e) {
	var isIE = (String(typeof(document.all)) != "undefined");
	var left = (isIE ? event.clientX : e.clientX);
	var top  = (isIE ? event.clientY : e.clientY);
	var corner = findPos(obj);
	alert((left - 150) + "\n" + (top - 114) + "\n");
}

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    return [curleft,curtop];
}

function freezePopup() {
	pausePopup = true;
}
