function openEventEdit(url, nimi) {
	var handle = window.open(url, nimi, "width=850,height=545,resizable=0,menubar=0,toolbar=0,status=0,location=0,titlebar=0");
	if (!handle.opener)
		handle.opener = self;
	childHandle = handle;
	handle.focus();
	return false;
}
var g_oImgDiv = null;
var g_oImgDivSdw = null;
var g_bImgDrag = false;
var g_iMPX = 0;
var g_iMPY = 0;
function GetElements() {
	if (document.getElementById) {
		g_oImgDiv = document.getElementById("imgDiv");
		g_oImgDivSdw = document.getElementById("imgDivSdw");
	} else if (document.all) {
		g_oImgDiv = document.all["imgDiv"];
		g_oImgDivSdw = document.all["imgDivSdw"];
	}
}
function PositionImage(o) {
	if (g_oImgDiv) {
		var iWindowWidth = -1;
		var iTop = 60;
		if (window.outerWidth)
			iWindowWidth = window.outerWidth;
		else
			iWindowWidth = document.body.clientWidth;
		if (document.body && (document.body.scrollLeft || document.body.scrollTop))
			iTop += document.body.scrollTop;
		else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
			iTop += document.documentElement.scrollTop;
		g_oImgDiv.style.display = "block";
		g_oImgDiv.style.top = iTop + "px";
		g_oImgDiv.style.left = Math.round((iWindowWidth / 2) - (o.width / 2)) + "px";
		PositionShadow();
	}
	g_bImgDrag = false;
}
function PositionShadow() {
	if (g_oImgDiv && g_oImgDivSdw) {
		var iTop = parseInt(g_oImgDiv.style.top) + 5;
		var iLeft = parseInt(g_oImgDiv.style.left) + 5;
		var iWidth = g_oImgDiv.offsetWidth;
		var iHeight = g_oImgDiv.offsetHeight;
		if (iWidth > 0 && iHeight > 0) {
			g_oImgDivSdw.style.display = "block";
			g_oImgDivSdw.style.top = iTop + "px";
			g_oImgDivSdw.style.left = iLeft + "px";
			g_oImgDivSdw.style.width = iWidth + "px";
			g_oImgDivSdw.style.height = iHeight + "px";
		}
	}
}
function StartImageDrag() {
	g_iMPX = 0;
	g_iMPY = 0;
	g_bImgDrag = true;
}
function DragImage(e) {
	if (g_oImgDiv && g_bImgDrag) {
		var iX = parseInt(g_oImgDiv.style.left);
		var iY = parseInt(g_oImgDiv.style.top);
		var iMX = (e) ? e.clientX : event.clientX;
		var iMY = (e) ? e.clientY : event.clientY;
		if (g_iMPX > 0 || g_iMPY > 0) {
			g_oImgDiv.style.left = (iX + (iMX - g_iMPX)) + "px";
			g_oImgDiv.style.top = (iY + (iMY - g_iMPY)) + "px";
			PositionShadow();
		}
		g_iMPX = iMX;
		g_iMPY = iMY;
		return false;
	}
}
function ShowImage(sImgUrl, sAlt) {
	GetElements();
	if (g_oImgDiv) {
		g_oImgDiv.style.display = "none";
		g_oImgDiv.innerHTML = "<div class=\"title\" onmousedown=\"StartImageDrag();\" onmouseup=\"g_bImgDrag=false;\"><div class=\"titleCnt\">" + sAlt + "</div><div onClick=\"HideImage();\" class=\"close\" title=\"Sulje kuva\"></div></div><div class=\"image\"><img src=\"" + sImgUrl + "\" onload=\"if(PositionImage) PositionImage(this)\" onClick=\"return HideImage();\" alt=\"" + sAlt + "\"/></div>";
	}
	return false;
}
function HideImage() {
	GetElements();
	if (g_oImgDiv)
		g_oImgDiv.style.display = "none";
	if (g_oImgDivSdw)
		g_oImgDivSdw.style.display = "none";
	g_bImgDrag = false;
	return false;
}
document.onmousemove = DragImage;
document.onmouseup = new Function("g_bImgDrag=false");