﻿var maxWidth = 566;
var maxHeight = 626;
var popupContainerDiv = null;
var screenShade = null;

function doPopup(popupId,lang)
{
    //shadeScreen
    shadeScreen(true, 49);
    
    //create new div
    createNewDiv(maxWidth, maxHeight, (document.documentElement.scrollWidth / 2) - (maxWidth / 2), 170);
    
    //set the content
    var ajaxURL = site + "Ajax/PopupHandler.ashx?popupId=" + popupId + "&lang=" + lang;
    xmlHttp = GetXmlHttpObject();
    AJAXtargetId = popupContainerDiv;
    DoAJAXGet(ajaxURL, xmlHttp, AJAXSetRefInnerHTML);
}

function createNewDiv(width,height,left,top){
    var div = document.createElement('DIV');
	document.body.appendChild(div);
	div.style.left = left + 'px';
    div.style.top = top + 'px';
    div.style.width = width + 'px';	
    div.style.height = height + 'px';
    div.style.margin = '13px';
    div.style.zIndex = 50;
    div.style.position = 'absolute';
    div.style.border = 'none';//'1px solid black';
    div.style.backgroundImage = 'url(./Resources/Images/PopupBg.gif)';
    popupContainerDiv = div;
}
function shadeScreen(active, zindex)
{
    if (active){
        if (!screenShade){
            screenShade = document.createElement('DIV');
	        document.body.appendChild(screenShade);        	
            screenShade.style.position = 'absolute';
	        screenShade.style.left = '0px';
            screenShade.style.top = '0px';
            screenShade.height = document.documentElement.scrollHeight;
            screenShade.width = document.documentElement.scrollWidth;
            screenShade.style.height = eval(document.documentElement.scrollHeight) * 1.4 + 'px';
            screenShade.style.width = document.documentElement.scrollWidth + 'px';
            setCSS(screenShade,'modalBackground');
        }        
        screenShade.style.zIndex = zindex;
        screenShade.style.display = '';
    } else {
        if (screenShade)  screenShade.style.display = 'none';
    }
}