﻿var popupStatus = 0;
function loadPopup()
{
    if(popupStatus==0)
    {
        $("#MainDiv").hide();
		$("#backgroundPopup").css({ "opacity": "0.7" });
		$("#backgroundPopup").fadeIn("slow");
		$("#BannerMainDiv").fadeIn("slow");
		popupStatus = 1;
	}
}
function disablePopup()
{
	if(popupStatus==1)
	{
	    $("#MainDiv").show();
		$("#backgroundPopup").fadeOut("slow");
		$("#BannerMainDiv").fadeOut("slow");
		popupStatus = 0;
	}
}

function centerPopup()
{
    var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#BannerMainDiv").height();
	var popupWidth = $("#BannerMainDiv").width();
	$("#BannerMainDiv").css({ "position": "absolute", "top": windowHeight/2-popupHeight/2,"left": windowWidth/2-popupWidth/2 });
	$("#backgroundPopup").css({"height": windowHeight});
}

function Load()
{
    $("#popupContactClose").click(function(){disablePopup();});
	$(document).keypress(function(e)
	{
		if(e.keyCode==27 && popupStatus==1)
		{
			disablePopup();
		}
	});

    centerPopup();
	loadPopup();
	setTimeout("disablePopup();",20000);  
}

window.onload=Load ;
