﻿var returnMessage = new String;
var redir = new String;
var isTracing = false;
var traceWindow = null;

$(document).ready(function () {
    $("#maskContent").fadeOut(350);
    $("#mask").fadeOut(450);
    $("a:not([target='_blank'])").bind("click", function () {
        $("#maskContent").fadeIn(350);
        $("#mask").fadeTo(450, 0.4);
    });

    $("#toolCmd").bind("click", function () {
        if ($("#ctl00_Tool_Connection:hidden").length > 0) {
            $("#ctl00_Tool_Connection:hidden").show(150);
        } else {
            $("#ctl00_Tool_Connection:visible").hide(150);
        }
    });
    //alert($("body").height() + "\n" + $("html").height()); // + "\n" + $(document).height() + "\n" + $(window).height());

    if ($("#SectionDataScroller").length > 0) {
        var offset = $("#SectionDataScroller").offset();
        var h = $("html").height() - offset.top - 50;
        $("#SectionDataScroller").css("height", h + "px");
        $("body, html").css("overflow", "hidden");
    };

    if ($("#SectionDataScroller2").length > 0) {
        var offset = $("#SectionDataScroller2").offset();
        var h = $("html").height() - offset.top - 50;
        $("#SectionDataScroller2").css("height", h + "px");
        $("body, html").css("overflow", "hidden");
    };

    $("tr.Header a").bind("click", function () {
        var cUrl = "../inc/controles/pref.aspx"
        cUrl += "?p=" + encodeURI(window.location.href);
        cUrl += "&c=" + encodeURI($(this).attr("href"));
        $.ajax({
            url: cUrl,
            success: function (data) { }
        });
    });

    if (isTracing) {
        traceWindow = window.open("../trace.axd", "traceWindow")
    }
});


function Init() {
            
    if (returnMessage=="CloseAndRefresh")
        {window.opener.document.forms(0).submit()
            //var url = window.opener.location
            //window.opener.location=url
            window.close()
        }
            
    if (returnMessage.indexOf("CloseandRedirect")>-1)
        {window.opener.location=returnMessage.substring(returnMessage.indexOf(":")+1)
        window.close()
        }
                
    if (returnMessage.indexOf("Eval")>-1)
        {
        eval("window.opener." & returnMessage.substring(returnMessage.indexOf(":")+1))
        window.close()
        }
                
    if (redir != "")
        {
        window.open(redir,"_blank")
        }
             
}


function openPopup(url) 
            {
            window.open(url,"_blank","height=550,width=550,status=yes,toolbar=no,menubar=no,location=no,resizable=yes")
            }
            
            
window.setInterval('Reconnect()', 18000)

function Reconnect()
            {           
            var img = new Image(1,1);
            img.src = '../Reconnect.aspx';                
            }

