﻿var HR = new (function () {
    this.LiveDoctor = new (function () {
        this.Common = new (function () {

            this.ShowBackground = function () {
                showBackground();
            }

            this.HideBackground = function () {
                hideBackground();
            }

            this.ShowError = function () {
                $("#failureMessageWindow").show();
            }

            this.UpdateTargetId = function (context, panel) {

                // the HTML output of the partial view
                var html = context.get_data();

                if (html.match(new RegExp("id=\"" + panel.attr('id') + "\""))) {

                    // use jQuery to update the placeholder.   
                    $(panel).attr("innerHTML", html);

                    // return false to prevent the automatic update of the placeholder
                    return false;
                }
            }

            function showBackground() {

                var windowHeight = window.clientHeight ? window.innerHeight : document.documentElement.clientHeight
                    ? document.documentElement.clientHeight : document.body.clientHeight;
                var windowWidth = window.clientWidth ? window.innerWidth : document.documentElement.clientWidth
                    ? document.documentElement.clientWidth : document.body.clientWidth;

                var shadow = document.createElement("div");

                shadow.id = "shadowBackground";

                shadow.style.zIndex = 100;
                shadow.style.backgroundColor = "#000000";
                shadow.style.position = "absolute";
                shadow.style.filter = "alpha(opacity=40)";
                shadow.style.opacity = 0.4;

                $("body").append(shadow);

                shadow.style.left = 0;
                shadow.style.top = shadow.scrollTop;
                shadow.style.width = "100%";
                shadow.style.height = "100%";
                shadow.style.overflow = "hidden";
            }

            function hideBackground() {

                $("#shadowBackground").remove();

                //opera hack to force redraw of whole window
                if (window.opera) {
                    $(document.body).css("background-color", "#FFFFFE");
                    setTimeout(function () {
                        $(document.body).css("background-color", "#FFFFFF");
                    }, 1);
                }
            }

        });
    });
});

