﻿// JavaScript Document
jQuery(document).ready(function ()
{

    window.SiteSecurity = "/SiteSecurity/";


    // Create a place to put custom content and append it to the body.
    var dlgdiv = document.createElement("div");
    document.body.appendChild(dlgdiv);
    dlgdiv.id = "DLGCONTENT";


    // Load our dialog and lightbox html.
    jQuery("#DLGCONTENT").load("/SiteSecurity/html/dialog.htm");


    var closedialogtimer = 0;
    var AllowDialogToCloseLightbox = false;

    window.OpenInfoDialog = function (text, timer, uselightbox)
    {

        //if (jQuery("#overlay").length > 0) jQuery("#lightbox").get(0).style.zIndex = 91;
        jQuery("#INFO_DIALOG_TEXT").html(text); //.get(0).innerHTML = text;
        jQuery("#INFO_DIALOG").get(0).style.left = ((jQuery(document).width() - jQuery("#INFO_DIALOG").width()) / 2) + "px";
        jQuery("#INFO_DIALOG").fadeIn("Slow"); //.appear({ duration: 0.5 });

        if (uselightbox)
        {
            LightboxOn();
            AllowDialogToCloseLightbox = true;
        }

        if (timer)
        {
            closedialogtimer = setTimeout(CloseInfoDialog, timer);
        }
    }

    window.CloseInfoDialog = function ()
    {
        if (closedialogtimer > 0)
        {
            clearTimeout(closedialogtimer)
            closedialogtimer = 0;
        }
        jQuery("#INFO_DIALOG").fadeOut("slow");
        if (AllowDialogToCloseLightbox)
        {
            LightboxOff();
            AllowDialogToCloseLightbox = false;
        }
    }

    function LightboxOn()
    {
        jQuery(window).resize(resizeLightbox);
        jQuery(window).scroll(resizeLightbox); //jQuery(window).resize
        resizeLightbox();
        jQuery("#SysLIGHTBOX").fadeTo("slow", .4); //appear({from:0, to:0.4, duration: 0.5});
    }

    function resizeLightbox()
    {
        jQuery("#SysLIGHTBOX").get(0).style.top = jQuery(window).scrollTop() + "px";
        jQuery("#SysLIGHTBOX").get(0).style.left = jQuery(window).scrollLeft() + "px";
        jQuery("#SysLIGHTBOX").get(0).style.height = jQuery(window).height() + "px";
        jQuery("#SysLIGHTBOX").get(0).style.width = jQuery(window).width() + "px";

    }

    function LightboxOff()
    {
        jQuery("#SysLIGHTBOX").fadeOut("Slow")
        jQuery(window).unbind('resize');
        jQuery(window).unbind('scroll');
    }

});
