﻿/* 
* PRAKUL GARG (v-prgarg)
* 11th Aug 2011
* Common functions to handle ModalWait Window are defined.
* 1. Define ShowModalWaitWindow
* 2. Define HideModalWaitWindow
*/
   

    //var ShowModalWindow = false;

var ShowModalWaitWindow = function (e) {

    var $scrollingElement = $('.DialogWindow');
    var $maskElement = $('#mask');
    var $loadingImageElement = $("imgLoading");

    //Cancel the link behavior
    //e.preventDefault();

    //    ShowModalWindow = true;

    //Get the A tag
    //var id = $(this).attr('href');
    //var id = "#ImageDialog";

    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    //Set heigth and width to mask to fill up the whole screen
    $maskElement.css({ 'width': maskWidth, 'height': maskHeight });

    //$maskElement.

    //transition effect		
    $maskElement.fadeIn(100);
    $maskElement.fadeTo("slow", 0.5);

    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();

    //Set the popup window to center
    $scrollingElement.css('top', ((winH / 2) - $scrollingElement.height() - 50) + $(window).scrollTop());
    $scrollingElement.css('left', ((winW - $scrollingElement.width()) / 2) + $(window).scrollLeft());

    $scrollingElement.css({'visibility':'visible'});

    //transition effect
    $scrollingElement.fadeIn(100);
    $scrollingElement.fadeTo("slow", 0.9);
    //$(id).show();

    var src = $("imgLoading").attr("src");
    $("imgLoading").attr("src", src);

    return true;
};

var HideModalWaitWindow = function () {
    //    ShowModalWindow = false;
    $('#mask').hide();
    $('.DialogWindow').hide();
};

var headTag = '<head>'
//+ '<link href="../Content/master.css" rel="stylesheet" type="text/css" />'
//+ '<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>'
//+ '<script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>    '
//+ '<script src="Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>'
//+ '<script src="Scripts/LoadingModalWindow.js" type="text/javascript"></script>'
                + '<script type="text/javascript">'
                + ' function DoSomething() {'
                + ' alert("hi, how r u");'
                + ' alert(document.getElementById("imgLoading").src);'
//                + ' $(document).ready(ShowModalWaitWindow);'
//                + ' $(document).ready(function() { alert("inside ready function"); });'
                + '}'
                + '</script>'
                + '</head>';

var htmlTag = '<html><body style="background-color: #D0D0D0;">'
        + '<div id="boxes" style="width=100%; height=100%">'
        + '<!-- Loading message box --> '
        + '     <div id="ImageDialog" style="position: absolute;left: 30%;top: 30%;width: 350px; height: 150px; visibility: visible;'
        +  'text-align: center;font-family: Calibri;color: black;z-index: 9999; background-color: #FDE0B0; border-color:White; border-style:solid;'
        +  'border-width:thick;>'
        + '         <img id="imgLoading" style="width:35px; height:35px; margin-top:35px;" src="http://localhost:1703/DevPortal/Content/loading.gif" alt="Loading..." runat="server" />'
        + '        <p style="font-size:18px; font-weight:bold;">Request is being processed, please wait.</p>'
        + '    </div>'
        + '</div>'    
        + '<!-- Mask to cover the whole screen -->'
       // + '<div id="mask"></div>'
        + '</body></html>';
 
