// 0 means disabled; 1 means enabled;
var popupStatus = 0;
function loadPopup(dv) {
	//loads popup only if it is disabled
	$("#popupBox .container").hide();
	$("#popupBox ." + dv).show();
	$("#popupBox ." + dv + " .content").show();
	if(popupStatus==0) {
		$("#backgroundPopup").css({
			"opacity": "0.5"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupBox").fadeIn("slow");
		popupStatus = 1;
	}
}

function disablePopup() {
	//disables popup only if it is enabled
	if(popupStatus==1) {
		$("#backgroundPopup").fadeOut("slow");
		$("#popupBox").fadeOut("slow",function(){
			$("#popupBox .loading").hide();
		});
		popupStatus = 0;
	}
}

function centerPopup() {
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var windowYOffset = document.documentElement.scrollTop;
	var popupHeight = $("#popupBox").height();
	var popupWidth = $("#popupBox").width();
	//centering
	$("#popupBox").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2+windowYOffset-100,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	$("#backgroundPopup").css({
		"height": windowHeight
	});
}