﻿
var __escToAdmin = {
    msgA: "'Are you sure you want to leave this page\nand enter the Admin Section?'",
    msgB: "A Popup blocker might have blocked the new window.\nDo you want to open the Admin in this window?",
    simpleMode: false,
    targetPage: ""
};

document.onkeyup = JumpToAdmin;

function JumpToAdmin(e) {
    var KeyID = (window.event) ? event.keyCode : e.keyCode;
    if (KeyID == 27) {
        var nn;
        if (e) {
            nn = e.target.nodeName;
        } else {
            nn = window.event.srcElement.nodeName;
        }
        if (nn != "INPUT" && nn != "TEXTAREA") {
            if (__escToAdmin.simpleMode) {
                if (confirm(__escToAdmin.msgA)) {
                    var nuWin = window.open("/admin/" + __escToAdmin.targetPage);
                    if (nuWin == null) {
                        if (confirm(__escToAdmin.msgB))
                            location.href = "/admin/" + __escToAdmin.targetPage;
                    }
                }
            } else {
                jConfirm(__escToAdmin.msgA, 'Jump to Admin', function(r) {
                    if (r) {
                        var nuWin = window.open("/admin/" + __escToAdmin.targetPage);
                        if (nuWin == null) {
                            jConfirm(__escToAdmin.msgB, 'Popup Blocked', function(r) {
                                if (r) location.href = "/admin/" + __escToAdmin.targetPage;
                            });

                        }

                    }
                });
            }
        }
    }
}

