﻿/// <reference path="jQuery/jquery-1.4.1-vsdoc.js" />

//-----------------------------------------------------------------------------

function showLoadingScreen() {
    $(function () {
        //Element to dim the screen.
        var grayOut = $("<div>&nbsp;</div>").attr("id", "grayOut_Dyn");
        grayOut.css({
            background: "#000",
            left: "0px",
            top: "0px",
            zIndex: 999,
            position: "absolute",
            opacity: 0,
            height: "100%",
            width: "100%"
        });

        //Dialog element.
        var dialog = $("<div>Loading Content, <br />Please wait...<br /><br /></div>").attr("id", "dialog_Dyn");
        dialog.css({
            fontWeight: "bold",
            fontFamily: "verdana,helvetica",
            textAlign: "center",
            marginLeft: "-175px",
            padding: "15px",
            backgroundColor: "#FFF",
            width: "350px",
            position: "absolute",
            top: "40%",
            left: "50%",
            zIndex: 999,
            opacity: 0
        });

        //Loading bar element.
        var loadingBar = $("<div></div>").attr("id", "loadingBar_Dyn");
        loadingBar.progressbar({
            value: 100
        });
        loadingBar.css({
            margin: "auto auto",
            height: "18px",
            width: "95%",
            position: "relative",
            zIndex: 999
        });
        loadingBar.find("div").css("backgroundImage", "url(_Images/pbar-ani.gif)");

        //Append elements together.
        dialog.append(loadingBar);

        $("body").css("overflow", "hidden");
        $("body").append(grayOut);
        $("#grayOut_Dyn").fadeTo("normal", .8, function () {
            $("body").append(dialog);
            $("#dialog_Dyn").fadeTo("normal", 1);
        });
    });
}

//-----------------------------------------------------------------------------

function hideLoadingScreen() {
    //Unlock scroll bars.
    $("body").css("overflow", "auto");

    //Fade out the elements.
    $("#dialog_Dyn").hide("fast", function () {
        $("#grayOut_Dyn").fadeTo("slow", 0, function () {
            //Remove all of the dynamically created elements from the page.
            $("#grayOut_Dyn").remove();
            $("#loadingBar_Dyn").remove();
            $("#dialog_Dyn").remove();
        });
    });
}

//-----------------------------------------------------------------------------
