﻿//0 means disabled; 
//1 means enabled;
var popupStatus = 0;

function loadPopup(){
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupDialog").fadeIn("slow");
		popupStatus = 1;
	}
}

function disablePopup(){
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupDialog").fadeOut("slow");
		popupStatus = 0;
	}
}

function centerPopup(){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupDialog").height();
	var popupWidth = $("#popupDialog").width();

	$("#popupDialog").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});

	$("#backgroundPopup").css({
	    "height": windowHeight
	});
}

var popupExpiredStatus = 0;

function loadExpiredPopup() {
	if (popupExpiredStatus == 0) {
		$("#backgroundExpiredPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundExpiredPopup").fadeIn("slow");
		$("#popupExpiredDialog").fadeIn("slow");
		popupExpiredStatus = 1;
	}
}

function disableExpiredPopup() {
	if (popupExpiredStatus == 1) {
		$("#backgroundExpiredPopup").fadeOut("slow");
		$("#popupExpiredDialog").fadeOut("slow");
		popupExpiredStatus = 0;
	}
}

function centerExpiredPopup() {
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupExpiredDialog").height();
	var popupWidth = $("#popupExpiredDialog").width();

	$("#popupExpiredDialog").css({
		"position": "absolute",
		"top": windowHeight / 2 - popupHeight / 2,
		"left": windowWidth / 2 - popupWidth / 2
	});

	$("#backgroundExpiredPopup").css({
		"height": windowHeight
	});
}
