function loadPopup(){
	if(popupStatus==0){
		document.getElementById("backgroundPopup").style.opacity = "0.7";
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}
function disablePopup(){
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}
function centerPopup(){
	var windowWidth = document.body.clientWidth;
	var windowHeight = document.body.clientHeight;
	var popupHeight = document.getElementById("popupContact").style.height;
	var popupWidth = document.getElementById("popupContact").style.width;

	document.getElementById("popupContact").style.position = "absolute";
	document.getElementById("backgroundPopup").style.display = 'block';
	document.getElementById("backgroundPopup").style.height = 850+"px";
	document.getElementById("backgroundPopup").style.width = windowWidth+"px";
	
	var x = (windowWidth / 2) - 400;
	document.getElementById("popupContact").style.top = 40+"px";
	document.getElementById("popupContact").style.left = x+"px";
}

function dispPopup(){
	centerPopup();
	loadPopup();
				
	$("#popupClose").click(function(){
		disablePopup();
	});
	$("#backgroundPopup").click(function(){
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
}

function donotdisplay()
{
	setCookie('popwindow', 1, 31, '/');
	disablePopup();
}

function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + getExpiryDate(expires) : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getExpiryDate(nodays) {
	var UTCstring;

	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();

	return UTCstring;
}

