// JavaScript Document POPUP sub-window script
//@auth Duncan Mountford

//0=off 1=on
var popupStatus = 0;

function loadPopup()
{
	
		$("#backgroundPopup").css({ "opacity" : "0.7"});
	    $("#backgroundPopup").fadeIn("slow");
	    $("#popupContact").fadeIn("slow");	
	
}


function disablePopup()
{
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
}

function centerPopup()
{
    //data for centering
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#popupContact").height();
    var popupWidth = $("#popupContact").width();

    //centering
    $("#popupContact").css({"position": "absolute","top": windowHeight/2-popupHeight/2,"left": windowWidth/2-popupWidth/2});

//IE6 Hack
    $("#backgroundPopup").css({"height": windowHeight});

}

$(document).ready(function()
{
	//Load Popup
	$("#tempConstruction").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction2").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction3").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction4").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction5").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction6").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction7").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction8").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction9").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction10").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction11").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction12").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction13").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction14").click(function(){ centerPopup(); loadPopup();});
	$("#tempConstruction15").click(function(){ centerPopup(); loadPopup();});
	//Close Popup
	$("#popupContactClose").click(function(){ disablePopup();});
	//escape key press
	$(document).keypress(function(e){ 
	    if(e.keyCode==27 && popupStatus==1)
	       { disablePopup(); }
		   })
						   
});
