function PopUpHandler() {
this.popupStatus = 0;
this.bgColor = "";

var me = this;

this.SetBackgroundColor = function(bgColor)
{
	me.bgColor = bgColor;
}

this.SetContent = function(p_title, p_content) {
	GetBlock("popupTitle").innerHTML = p_title;
	var content = GetBlock("popupContent");
	while (content.hasChildNodes()) {
		content.removeChild(content.firstChild);
	}
	AddTag(p_content, content);
	GetBlock("popupHolder").style.backgroundColor = me.bgColor;
	me.bgColor = "";
}

this.SetSize = function(p_width, p_height) {
	GetBlock("popupHolder").style.width = p_width + "px";
	GetBlock("popupHolder").style.height = p_height + "px";
}

this.ShowPopup = function() {
	if(me.popupStatus == 0) {
		var arrIDsToHide = ["idBannerBottom", "idBannerSuperTop", "idBannerTop", "idBannerRight"];
		for(var i=0; i<arrIDsToHide.length; i++)
		{
			var div = GetBlock(arrIDsToHide[i]);
			if(div && div.style)
				div.style.visibility = 'hidden';
		}

		$("#backgroundPopup").css({
			"opacity": "0.5"
		});
		$("#backgroundPopup").fadeIn("fast");
		$("#popupHolder").fadeIn("fast");
		me.popupStatus = 1;
	}
}

this.HidePopup = function() {
	if(me.popupStatus == 1) {
		$("#backgroundPopup").fadeOut("fast");
		$("#popupHolder").fadeOut("fast");
		me.popupStatus = 0;

		var arrIDsToShow = ["idBannerBottom", "idBannerSuperTop", "idBannerTop", "idBannerRight"];
		for(var i=0; i<arrIDsToShow.length; i++)
		{
			var div = GetBlock(arrIDsToShow[i]);
			if(div && div.style)
				div.style.visibility = 'visible';
		}
	}
}

this.CenterPopup = function() {
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupHolder").height();
	var popupWidth = $("#popupHolder").width();
	$("#popupHolder").css({
		"position": "absolute",
		"top": windowHeight / 2 - popupHeight / 2 + $(window).scrollTop(),
		"left": windowWidth / 2 - popupWidth / 2 + $(window).scrollLeft()
	});
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
}

this.Init = function() {
	$("#popupHolderClose").click(function(){
		me.HidePopup();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && me.popupStatus==1){
			me.HidePopup();
		}
	});
}

me.Init();

}
