var needToReload = 0;

function show_popup() {

	try {
		eraseLittleCalendar();
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			$("body","html").css({height: "100%", width: "100%"});
			$("html").css("overflow","hidden");
			if (document.getElementById("popHideSelect") === null) {//iframe to hide select elements in ie6
				$("body").append("<iframe id='popHideSelect'></iframe><div id='popShadow'></div><div id='popContainer'></div>");
				$("#popShadow").click(hide_popup);
			}
		}else{//all others
			if(document.getElementById("popShadow") === null){
				$("body").append("<div id='popShadow'></div><div id='popContainer'></div>");
				$("#popShadow").click(hide_popup);
			}
		}
		
		if(tb_detectMacXFF()){
			$("#popShadow").addClass("popShadowMacFFBGHack");//use png overlay so hide flash
		}else{
			$("#popShadow").addClass("popShadowBG");//use background and opacity
		}
		
		$("body").append("<div id='popLoader'><img src='images/loadingAnimation.gif' /></div>");//add loader to the page
		$('#popLoader').show();//show loader
		
		
		
		var pageWidth = window.innerWidth || self.innerWidth || (document.documentElement&&document.documentElement.clientWidth) || document.body.clientWidth;
		var pageHeight = window.innerHeight || self.innerHeight || (document.documentElement&&document.documentElement.clientHeight) || document.body.clientHeight;
		$("#popContainer").css({height:pageHeight-20+"px"});
		$("#popContainer").css({marginLeft: '-' + parseInt((620 / 2),10) + 'px', width: 620 + 'px'});
			if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
				$("#popContainer").css({marginTop: '-' + parseInt(((pageHeight-20) / 2),10) + 'px'});
			}
			else {

			}

		if(navigator.appName=="Microsoft Internet Explorer" && navigator.userAgent.indexOf("MSIE 6.0")!=-1) {
			
		} else {
			
			document.getElementById("helptip_container").style.position="fixed";
			document.getElementById("helptipBackground").style.position="fixed";
			
		}
				
	} catch(e) {
		
	}
}

function hide_popup() {
	eraseLittleCalendar();
	$("#popContainer").fadeOut("fast",function(){$('#popContainer,#popShadow,#popHideSelect').trigger("unload").unbind().remove();});
	$("#popLoader").remove();
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
	var popMyContainer = $(".popMyContainer");
	for(var i=0;i<popMyContainer.length;i++) {
		popMyContainer[i].style.display="none"
	}
	if(navigator.appName=="Microsoft Internet Explorer" && navigator.userAgent.indexOf("MSIE 6.0")!=-1) {
			
	} else {
		document.getElementById("helptip_container").style.position="absolute";	
		document.getElementById("helptipBackground").style.position="absolute";	
	}
	if(needToReload==1) {
		window.location = window.location;
	}
}

function tb_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}

function resetPopup() {
	document.getElementById("popContainer").style.display = "block";
	document.getElementById("popContainer").style.width = "auto";
	document.getElementById("popContainer").style.height = "auto";
	document.getElementById("popContainer").style.marginLeft = "-" + document.getElementById("popContainer").offsetWidth/2 + "px";
	if(!navigator.appName=="Microsoft Internet Explorer" || navigator.userAgent.indexOf("MSIE 6.0")==-1) {
		document.getElementById("popContainer").style.marginTop = "-" + document.getElementById("popContainer").offsetHeight/2 + "px";
	}
}

