var state = new Array();

$(document).ready(function() {
	$("body").append('<div id="bgPopup"></div>');
});

function loadPopup(popupID) {
	if(state[popupID]==0) {
		hideAnimatedLogo();
		$("#bgPopup").css({ "opacity":"0.7"});
		$("#bgPopup").fadeIn("slow");
		$(popupID).fadeIn("slow");
		state[popupID] = 1;
	}
}

function hidePopup(popupID) {
	if(state[popupID]==1) {
		$("#bgPopup").fadeOut("slow");
		$(popupID).fadeOut("slow");
		setTimeout('showAnimatedLogo()',1000);
		state[popupID] = 0;
	}
}

function centerPopup(popupID) {
	var winWidth = document.documentElement.clientWidth;
	var winHeight = document.documentElement.clientHeight;
	var scrolledHeight = $("html").scrollTop();
	var popupHeight = $(popupID).height();
	var popupWidth = $(popupID).width();
	var top = (winHeight/2)-(popupHeight/2);
	if(top < 0) {
		top = top * -1;
	}
	top += scrolledHeight;
	$(popupID).css({"position":"absolute","top": top,"left":(winWidth/2)-(popupWidth/2)});
	$("#bgPopup").css({"height":winHeight});
}

function hideAnimatedLogo() {
	$("#animatedlogo").hide();
	$("#nonanimatedlogo").show();
}

function showAnimatedLogo() {
	$("#nonanimatedlogo").hide();
	$("#animatedlogo").show();
}
