﻿function ShowLoading(loadingMessage) {
    if (!loadingMessage) { loadingMessage = "Loading..." };
	if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
		$("body","html").css({height: "100%", width: "100%"});
		$("html").css("overflow","hidden");
		if (document.getElementById("LD_HideSelect") === null) {//iframe to hide select elements in ie6
			$("body").append("<iframe id='LD_HideSelect'></iframe><div id='LD_overlay'></div><div id='LD_window'></div>");
		}
	}else{//all others
		if(document.getElementById("LD_overlay") === null){
			$("body").append("<div id='LD_overlay'></div><div id='LD_window'></div>");
		}
	}

	if(tb_detectMacXFF()){
		$("#LD_overlay").addClass("LD_overlayMacFFBGHack");//use png overlay so hide flash
	}else{
		$("#LD_overlay").addClass("LD_overlayBG");//use background and opacity
	}

    imgLoader = new Image();// preload image
    imgLoader.src = '/images/pm_sys/loader_wheel.gif';

    $("body").append('<div id="ModalLoadingWindow" class="modal"><h4>'+loadingMessage+'</h4><div class="progress_meter"><img src="'+imgLoader.src+'" /></div><p>Please do not close or refresh your browser window.</p></div>');//add loader to the page

    $('#ModalLoadingWindow').show(); //show loader
    document.location.href = '#site'; // move to top of screen so the user sees the box
}

function RemoveLoading() {
 	$('#LD_overlay,#ModalLoadingWindow').trigger("unload").unbind().remove();
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
	return false;
}

function tb_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}

function ShowHourGlass(show) {
    if (show) {
        $('*').addClass('hourglass');
    }
    else {
        $('*').removeClass("hourglass");
    }
}     
