﻿var pageHeight;
var pageWidth;
var mykid;
var myImg;

function showCurtain()
{
	pageHeight = (document.height != undefined) ? document.height : document.body.offsetHeight;
	pageWidth = (document.width != undefined) ? document.width : document.body.offsetWidth;

	if (document.documentElement.clientHeight > pageHeight)
		pageHeight = document.documentElement.clientHeight;
	
	if (window.innerHeight)
		pageHeight = (window.innerHeight > pageHeight ? window.innerHeight : pageHeight);

	var curtain_div = document.getElementById('divCurtain');
	curtain_div.style.height = (Math.ceil(pageHeight)) + "px";
	curtain_div.style.width = Math.ceil(pageWidth) + "px";
	curtain_div.style.display = "block";
}

function hideCurtain()
{
	if (mykid)
	{
		mykid.style.display = "none";
	}
	document.getElementById('divCurtain').style.display = "none";
}

function showPopup(name, imgName)
{
	var scrollOffset = document.all ? ((document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body).scrollTop : pageYOffset;

    var imgElement = document.getElementById(imgName);
	mykid = document.getElementById(name);
	mykid.style.position = "absolute";
	mykid.style.display = "block";
	mykid.style.top = (200 + scrollOffset) + "px";
	mykid.style.left = (Math.ceil(pageWidth)/2 - parseInt(imgElement.width)/2) + "px";
	mykid.style.zIndex = "1000";
}

function showPic( src, width, height )
{
    var childImg = document.getElementById('curtainImg');
    childImg.src = src;
    childImg.height = height;
    childImg.width = width;
    
    showCurtain();
    showPopup('divCurtainChild', 'curtainImg');
}