var DontAutoCloseOverlay = false;
function OverlayShow( oElementToShow ) {//function called when the user clicks on a thickbox link
	
	try {
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			$("body","html").css({height: "100%", width: "100%"});
			$("html").css("overflow","hidden");
		}
		
		if(document.getElementById("OVRL_overlay") === null){
			$("body").append("<div id='OVRL_overlay'></div>");
			$("#OVRL_overlay").click( function() { if(!DontAutoCloseOverlay) OverlayHide(oElementToShow); else if(ConfirmCloseOverlay()) OverlayHide(oElementToShow); } );
		}
		
		if(OVRL_detectMacXFF()){
			$("#OVRL_overlay").addClass("OVRL_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			$("#OVRL_overlay").addClass("OVRL_overlayBG");//use background and opacity
		}
		
		$("#OVRL_overlay").css('opacity', 0);
		
		$("#OVRL_overlay").fadeTo('fast', 0.5);
		
		
		oElementToShow.fadeIn('fast');

		document.onkeyup = function(e){ 	
			if (e == null) { // ie
				keycode = event.keyCode;
			} else { // mozilla
				keycode = e.which;
			}
			if(keycode == 27){ // close
				if(!DontAutoCloseOverlay) OverlayHide(oElementToShow); else if(ConfirmCloseOverlay()) OverlayHide(oElementToShow);
			}	
		};
		
	} catch(e) {
		//nothing here
	}
}

function OverlayHide(oElementToShow) {
	oElementToShow.fadeOut('fast');
	$("#OVRL_overlay").fadeOut('fast', function() {$(this).unbind().remove()});
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
  
	document.onkeydown = "";
	document.onkeyup = "";
	
	return false;
}


function OVRL_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}


