function RedirectToExpire(res) {
    ReopenLogon(res);
/*
    var destination = "/Account/Expires/"; var version = navigator.appVersion; if (destination !== "") {
        if (version.indexOf("MSIE") >= -1)
        { window.location.href = destination; }
        else { window.open(destination, target == "_self"); } 
    }
    */
}
$(function () {
  /*  setInterval(KeepSessionAlive, 60000);*/
});

function KeepSessionAlive() {
    if (window.location.pathname != "/") {
        issessionend();
    }

}
function ReopenLogon(res) {
    $("div#logonmodalcontainer").html("<img alt='Loading' src='../../Content/images/ajax-loader.gif' />");
    if (res && res != "") {
        $("div#logonmodalcontainer").load('/Account/ModalLogon/?reason=' + encodeURI(res));
    } else {
        $("div#logonmodalcontainer").load('/Account/ModalLogon/');
    }
        lndialog.dialog('option', 'title', 'Enter Login and Password');
        lndialog.dialog('option', 'buttons', { "Close": function () { $("div#logonmodalcontainer").html(""); lndialog.dialog('close'); }, "Login": function () {beginLogin(); } });
        lndialog.dialog('open');     
}
function beginLogin() {
    if (findElement('mlusername') && findElement('mlpassword')) {
        lform = $("#modallogontbl").serialize();
        $.post("/Account/ModalLogonRequest/", { username: encodeURI($("#modallogontbl #mlusername").val()), password: encodeURI($("#modallogontbl #mlpassword").val()) }, function (data) {
            if (data === 'true') {
                lndialog.dialog("close");
            } else {
                $("#modallogontbl #mlpassword").val("");
               $("#modallogontbl #mlpassword").css("border", "1px solid red");
            }
        });
    }
}   
function RedirectToAction(C, A) {
    if (C != null && A != null) {
        var destination = "/" + C + "/" + A + "/"; var version = navigator.appVersion; if (destination !== "") {
            if (version.indexOf("MSIE") >= -1)
            { window.location.href = destination; }
            else { window.open(destination, target == "_self"); } 
        } 
    } 
}
function RedirectTo(destination) {
    var version = navigator.appVersion; if (destination !== "") {
        if (version.indexOf("MSIE") >= -1)
        { window.location.href = destination; }
        else { window.open(destination, target == "_self"); } 
    } 
}
function RedirectToNew(destination) { if (destination != "") { window.open(destination); } }
var lndialog;
function setlogonmodalcontainer() { lndialog = $("#logonmodalcontainer").dialog({ modal: true, autoOpen: false, closeOnEscape: true }); }
function openlogonmodalcontainer(C, A) {
    var E = ""; if (C == "" && A == "") { E = "true"; }
    var view = "<span style='color:Red;' id='logonerror'></span>" + "<form action='/Account/Login' id='logonform' method='post' name='logonform'>" + "<div>" + "<table>" + "<tr>" + "<td>Login:</td>" + "<td>" + "<input id='username' name='username' type='text' value='' />" + "</td>" + "</tr>" + "<tr>" + "<td>Password :</td>" + "<td>" + "<input id='password' name='password' type='password'/>" + "</td>" + "</tr>" + "<tr>" + "<td></td>" + "<!--td><input id='rememberMe' name='rememberMe' type='checkbox' value='true' /><input name='rememberMe' type='hidden' value='false' /> Remember me?</td-->" + "<input id='C' name='C' type='hidden' value='" + C + "' />" + "<input id='A' name='A' type='hidden' value='" + A + "' />" + "<input id='E' name='E' type='hidden' value='" + E + "' />" + "</tr>" + "<tr>" + "<td></td>" + "<td>" + "<input type='submit'  value='Login' />" + "</td>" + "</tr>" + "</table>" + "</div>" + "</form>"; try { $("div#logonmodalcontainer").html(view); $("#logonmodalcontainer").dialog('option', 'title', 'Enter Login and Password'); $("#logonmodalcontainer").dialog('open'); return false; } catch (Err) { alert(Err); return false; } 
}
function openlogonmodalcontainerifneeded(auth, C, A) {
    if (auth == "False" || auth == "false") { openlogonmodalcontainer(C, A); return false; }
    else { clearlogonmodalcontainer(); return true; } 
}
function clearlogonmodalcontainer() { $("div#logonmodalcontainer").text(""); }
function issessionend() { $.getJSON("/Account/IsSessionEnd", null, function (data) { if (data == "true") { RedirectToExpire("expire"); } }); }
jQuery(document).ready(function() {
    setlogonmodalcontainer(); shortcut.add("F1", function() {
        var txt; if (document) {
            if (document.title != null) { txt = document.title; }
            if (document.location != null) { txt += "\n " + document.location; } 
        }
        var destination = "/Help/Help?text=" + encodeURI(txt); window.open(destination, "HELP", "width=1024,height=768,top=0,left=0,scrollbars=1,resizable=1,toolbar=0,menubar=0,status=0,statusbar=0"); document.onhelp = returnFalse; window.onhelp = returnFalse; return false;
    }, { 'type': 'keydown', 'propagate': false, 'target': document });
}); function returnFalse() { return false; }
function findElement(id) { if (document.getElementById) { return document.getElementById(id); } else if (document.all) { return document.all[id]; } else if (document.layers) { return document.layers[id]; } else { return null; } }; function includeScript(include, filename) { if (include === true) { if (jQuery.browser.safari) { jQuery.ajax({ url: filename, dataType: 'script', async: false, cache: true }); } else { IncludeJavaScript(filename); } } }; function IncludeJavaScript(jsFile)
{ var oHead = document.getElementsByTagName('head')[0]; var oScript = document.createElement('script'); oScript.type = 'text/javascript'; oScript.charset = 'utf-8'; oScript.src = jsFile; oHead.appendChild(oScript); }; var ektrdxhrs = new Array(); function abortallhgrs() {
    var tmpektrdxhrs = ektrdxhrs; var xhrid = 0; $.each(tmpektrdxhrs, function(i) {
        if (null !== this) { this.abort(); openviewiscomplete = true; }
        xhrid++;
    }); tmpektrdxhrs = null; ektrdxhrs = null; ektrdxhrs = new Array();
}




