function FindElement(sId) {
	var o = null;
	if (document.getElementById)
		o = document.getElementById(sId);
	if (!o && document.all)
		o = document.all[sId];
	if (!o && document.layers)
		o = document.layers[sId];
	return o;
}
function ToggleBody(sId, b) {
	if (document.getElementById) {
		var oTable = document.getElementById(sId);
		if (oTable) {
			var oABody = oTable.getElementsByTagName("tbody");
			if (oABody && oABody.length > 0)
				oABody[0].style.display = (oABody[0].style.display == "none") ? "block" : "none";
		}
	}
}
function OpenMailPopup(sUrl) {
	window.open(sUrl, "kk", "width=600,height=720,scrollbars=1,menubar=0"); 
	return false
}
function ToggleShade(b, c) {
	if (document.getElementById) {
		var oShade = document.getElementById("pageShade");
		var oShadeWnd = document.getElementById("pageShadeWindow");
		var oShadeCnt = document.getElementById("pageShadeContent");
		if (oShade && oShadeWnd && oShadeCnt) {
			oShade.style.display = (b) ? "block" : "none";
			oShadeWnd.style.display = (b) ? "block" : "none";
			oShadeCnt.innerHTML = (b) ? ((c) ? c : "<strong>Odota hetki...</strong><br/><img src=\"/images/loading_bar.gif\" class=\"loading\" alt=\"\"/>") : "";
		}
	}
}
function ShowImagePopup(oImg) {
	var oShade = document.getElementById("pageShade");
	var oShadeWnd = document.getElementById("pageShadeWindow");
	var oShadeCnt = document.getElementById("pageShadeContent");
	var oImgFrm = document.getElementById("popupImageFrame");
	if (oShade && oShadeWnd && oShadeCnt && oImgFrm) {
		oShade.style.display = "block";
		oShadeWnd.style.display = "block";
		oShadeCnt.style.display = "block"
		oImgFrm.style.width     = (oImg.width + 8) + "px";
		oImgFrm.style.top       = "-" + (oImg.height / 2) + "px";
		oImgFrm.style.left      = "-" + (oImg.width / 2) + "px";
	}
}
function InitImagePopup(s, i, a, sA) {
	var oShade    = document.getElementById("pageShade");
	var oShadeWnd = document.getElementById("pageShadeWindow");
	var oShadeCnt = document.getElementById("pageShadeContent");
	if (oShade && oShadeWnd && oShadeCnt) {
		oShadeCnt.style.display = "none";
		oShadeCnt.innerHTML = "<div id=\"popupImageFrame\" class=\"popupImageFrame\">" +
							  "<span class=\"imageTitle\">" + ((a) ? a[i][1] : "&nbsp;") + "</span>" +
							  "<a href=\"#\" onclick=\"ToggleShade(false, null); return false;\" class=\"popupImageLink\">" +
							  "<img src=\"" + s + "\" onload=\"ShowImagePopup(this);\" alt=\"Sulje kuva\" class=\"popupImage\" /></a><div class=\"galleryPager\">" +
							  ((a && i > 0) ? "<a href=\"#\" onclick=\"return InitImagePopup('" + a[i - 1][0] + "', " + (i - 1) + ", " + sA + ", '" + sA + "');\"><img src=\"http://www.isannointiliitto.fi/images/galleryPrev.gif\" alt=\"Edellinen\" class=\"galleryPrev\"/></a>" : "<img src=\"http://www.isannointiliitto.fi/images/galleryPrevD.gif\" alt=\"\" class=\"galleryPrev\"/>") +
							  ((a) ? "<span class=\"galleryPage\">" + (i + 1) + "/" + a.length + "</span>" : "") +
							  ((a && i < a.length - 1) ? "<a href=\"#\" onclick=\"return InitImagePopup('" + a[i + 1][0] + "', " + (i + 1) + ", " + sA + ", '" + sA + "');\"><img src=\"http://www.isannointiliitto.fi/images/galleryNext.gif\" alt=\"Seuraava\" class=\"galleryNext\"/></a>" : "<img src=\"http://www.isannointiliitto.fi/images/galleryNextD.gif\" alt=\"\" class=\"galleryNext\"/>") +
							  "</div><div class=\"popupImageClose\" onclick=\"ToggleShade(false, null); return false;\">X</div>" + 
							  "</div>";
		return false;
	}
	return true;
}
