﻿var exclude = 1;
var agt = navigator.userAgent.toLowerCase();
var win = 0; var mac = 0; var lin = 1;
if (agt.indexOf('win') != -1) { win = 1; lin = 0; }
if (agt.indexOf('mac') != -1) { mac = 1; lin = 0; }
var lnx = 0; if (lin) { lnx = 1; }
var ice = 0;
var ie = 0; var ie4 = 0; var ie5 = 0; var ie6 = 0; var ie7 = 0; var com = 0; var dcm;
var op5 = 0; var op6 = 0; var op7 = 0;
var ns4 = 0; var ns6 = 0; var ns7 = 0; var mz7 = 0; var kde = 0; var saf = 0;
if (typeof navigator.vendor != "undefined" && navigator.vendor == "KDE") {
    var thisKDE = agt;
    var splitKDE = thisKDE.split("konqueror/");
    var aKDE = splitKDE[1].split("; ");
    var KDEn = parseFloat(aKDE[0]);
    if (KDEn >= 2.2) {
        kde = 1;
        ns6 = 1;
        exclude = 0;
    }
}
else if (agt.indexOf('webtv') != -1) { exclude = 1; }
else if (typeof window.opera != "undefined") {
    exclude = 0;
    if (/opera[\/ ][5]/.test(agt)) { op5 = 1; }
    if (/opera[\/ ][6]/.test(agt)) { op6 = 1; }
    if (/opera[\/ ][7-9]/.test(agt)) { op7 = 1; }
}
else if (typeof document.all != "undefined" && !kde) {
    exclude = 0;
    ie = 1;
    if (document.documentElement && typeof document.documentElement.style.maxHeight != "undefined") {
        ie7 = 1;
    }
    else if (typeof document.getElementById != "undefined") {
        ie5 = 1;
        if (agt.indexOf("msie 6") != -1) {
            ie6 = 1;
            dcm = document.compatMode;
            if (dcm != "BackCompat") { com = 1; }
        }
    }
    else { ie4 = 1; }
}
else if (typeof document.getElementById != "undefined") {
    exclude = 0;
    if (agt.indexOf("netscape/6") != -1 || agt.indexOf("netscape6") != -1) { ns6 = 1; }
    else if (agt.indexOf("netscape/7") != -1 || agt.indexOf("netscape7") != -1) { ns6 = 1; ns7 = 1; }
    else if (agt.indexOf("gecko") != -1) { ns6 = 1; mz7 = 1; }
    if (agt.indexOf("safari") != -1 || (typeof document.childNodes != "undefined" && typeof document.all == "undefined" && typeof navigator.taintEnabled == "undefined")) { mz7 = 0; ns6 = 1; saf = 1; }
}
else if ((agt.indexOf('mozilla') != -1) && (parseInt(navigator.appVersion) >= 4)) {
    exclude = 0;
    ns4 = 1;
    if (typeof navigator.mimeTypes['*'] == "undefined") {
        exclude = 1;
        ns4 = 0;
    }
}
if (agt.indexOf('escape') != -1) { exclude = 1; ns4 = 0; }
if (typeof navigator.__ice_version != "undefined") { exclude = 1; ie4 = 0; }

/* Gets the window position for IE and Firefox, at least */
function windowLeft() { return typeof window.screenLeft != 'undefined' ? window.screenLeft : typeof window.screenX != 'undefined' ? window.screenX : 0; }
function windowTop() { return typeof window.screenTop != 'undefined' ? window.screenTop : typeof window.screenY != 'undefined' ? window.screenY : 0; }
function getTopForPopup(windowHeight) {
    var top;

    if (windowHeight) {
        top = (screen.height / 2 - windowHeight / 2);
        if (document.body.offsetHeight == windowHeight) {
            top += 50;
            if (Math.abs(windowTop() - top) < 50) {
                top += 50;
            }
        }
    }
    else
        top = 50;
    return top;
}

function getLeftForPopup(windowWidth) {
    var left;

    if (windowWidth) {
        left = (screen.width / 2 - windowWidth / 2);
        if (document.body.offsetWidth == windowWidth) {
            left += 50;
            if (Math.abs(windowLeft() - left) < 50) {
                left += 50;
            }
        }
    }
    else
        left = 100;

    return left;
}

function popUp(url, width, height, menubar, name, top, left) {
    var strName;
    if (!top) {
        top = getTopForPopup(height);
    }
    if (!left) {
        left = getLeftForPopup(width);
    }
    if (name) strName = name; else strName = "popup"
    if (menubar) {
        var winObj = window.open(url, strName, 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=no,resizable=yes,copyhistory=yes,left=' + left + ',top=' + top + ',width=' + width + ',height=' + height);
        winObj.focus();
    }
    else {
        var winObj = window.open(url, strName, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,left=' + left + ',top=' + top + ',width=' + width + ',height=' + height);
        winObj.focus();
    }
}

function popUpDrilldown(url, name, width, height) {
    if (width == null)
        width = 1000;
    if (height == null)
        height = 600;
    popUp(url, width, height, false, name);
}

function popUpPrintPage(url, name, width, height) {
    if (width == null)
        width = 750;
    if (height == null)
        height = 600;
    var top = getTopForPopup(height);
    var left = getLeftForPopup(width);
    if (name) strName = name; else strName = "popup"
    var winObj = window.open(url, strName, 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,left=' + left + ',top=' + top + ',width=' + width + ',height=' + height);
    winObj.focus();
}

function popUpDrilldownMini(url, name, width, height) {
    if (width == null)
        width = 600;
    if (height == null)
        height = 400;
    popUp(url, width, height, false, name);
}


function popUpConfirmation(url, name) {
    popUp(url, 360, 240, false, name);
}

function popUpLookup(url, hiddenName) {
    var retVal = false;
    var returnId = "";
    returnId = window.showModalDialog(url, '', 'dialogHeight:400px;dialogWidth:500px');
    if (returnId != "" && returnId != undefined) {
        var hiddenField = document.getElementById(hiddenName);
        hiddenField.value = returnId;
        retVal = true;
    }
    return (retVal);
}