var a = new Image(); a.src = "images/MsgBg.png";
var b = new Image(); b.src = "images/blank.png";
var OverlayZIndex = 10000;
function ShowMessageOnOverlay(m) {
    EnableOverlay();
    $("#Overlay").append($("<div></div>").attr("id", "OverlayMessage").css({
        left: ($(document).width() - 430) / 2 + "px",
        top: ($(window).height() - 139) / 2 + "px",
        zIndex: OverlayZIndex + 1,
        backgroundColor: "Transparent",
        backgroundRepeat: "repeat-x",
        border: "solid 1px #777",
        fontSize: "30px",
        paddingTop: "50px",
        paddingBottom: "50px",
        paddingLeft: "100px",
        paddingRight: "100px",
        color: "White"
    }).html(m));
    if ($.browser.version == "6.0")
        $("#OverlayMessage").css({position:"absolute", filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/MsgBg.png,sizingmethod=scale)" });
    else
        $("#OverlayMessage").css({position:"fixed", backgroundImage: "url(images/MsgBg.png)" });
};


function EnableOverlay() {
    if ($("#Overlay").length > 0) return;
    if (typeof (theForm) == "undefined") theForm = document.forms[0];
    if (typeof (theForm) == "undefined") theForm = document.form1;
    $(theForm).prepend($("<div></div>").attr("id", "Overlay").css({
        position: "absolute",
        left: $(document).width() / 2 + "px",
        top: $(window).height() / 2 - 20 + "px",
        zIndex: OverlayZIndex,
        width: "0px",
        height: "0px"
    }).animate({
        left: "0px",
        top: "0px",
        width: "100%",
        height: $(document).height() + "px"
    }));
    
    if ($.browser.version == "6.0")
        $("#Overlay").css({ filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/blank.png,sizingmethod=scale)" });
    else
        $("#Overlay").css({ backgroundImage: "url(images/blank.png)" });
        
    OverlayZIndex += 2;
}

function DisableOverlay() {
    $("#Overlay").animate({
        left: $(document).width() / 2 + "px",
        top: $(window).height() / 2 - 20 + "px",
        width: "0px",
        height: "0px"
    }, 100, function() {
        $(this).remove();
    });
    OverlayZIndex -= 2;
}

function ShowWait(){
	setTimeout(function(){
		DisableOverlay();
	},3000);
	ShowMessageOnOverlay('Please wait...');
}
