﻿var version4 = (navigator.appVersion.charAt(0) == "4");
var popupHandle, popupHandle2, popupHandle3, popupHandle4, popupHandle5, popupHandle6, popupHandleR, popupHandleR2;

function closePopup() {
    if (popupHandle != null && !popupHandle.closed) popupHandle.close();
}

function displayPopup(url, name, height, width) {

    var properties = "menubar = 0,toolbar = 0, location = 0, scrollbars=1, resizable=0, height = " + height;
    properties = properties + ", width=" + width;

    var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;

    if (navigator.appName == "Microsoft Internet Explorer") {
        screenY = window.screen.availHeight;
        screenX = window.screen.availWidth;
    }
    else {
        screenY = window.outerHeight;
        screenX = window.outerWidth;
    }

    leftvar = (screenX - width) / 2;
    rightvar = (screenY - height) / 2;
    if (navigator.appName == "Microsoft Internet Explorer") {
        leftprop = leftvar;
        topprop = rightvar;
    }
    else {
        leftprop = (leftvar - pageXOffset);
        topprop = (rightvar - pageYOffset);
    }

    properties = properties + ", left = " + leftprop;
    properties = properties + ", top = " + topprop;

    closePopup();
    popupHandle = open(url, name, properties);
}

function closePopup2() {
    if (popupHandle2 != null && !popupHandle2.closed) popupHandle2.close();
}

function displayPopup2(url, name, height, width) {

    var properties = "menubar = 0,toolbar = 0, location = 0, scrollbars=1, resizable=0, height = " + height;
    properties = properties + ", width=" + width;

    var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;

    if (navigator.appName == "Microsoft Internet Explorer") {
        screenY = window.screen.availHeight;
        screenX = window.screen.availWidth;
    }
    else {
        screenY = window.outerHeight;
        screenX = window.outerWidth;
    }

    leftvar = (screenX - width) / 2;
    rightvar = (screenY - height) / 2;
    if (navigator.appName == "Microsoft Internet Explorer") {
        leftprop = leftvar;
        topprop = rightvar;
    }
    else {
        leftprop = (leftvar - pageXOffset);
        topprop = (rightvar - pageYOffset);
    }

    properties = properties + ", left = " + leftprop;
    properties = properties + ", top = " + topprop;

    closePopup2();
    popupHandle2 = open(url, name, properties);
}

function closePopup3() {
    if (popupHandle3 != null && !popupHandle3.closed) popupHandle3.close();
}

function displayPopup3(url, name, height, width) {

    var properties = "menubar = 0,toolbar = 0, location = 0, scrollbars=1, resizable=0, height = " + height;
    properties = properties + ", width=" + width;

    var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;

    if (navigator.appName == "Microsoft Internet Explorer") {
        screenY = window.screen.availHeight;
        screenX = window.screen.availWidth;
    }
    else {
        screenY = window.outerHeight;
        screenX = window.outerWidth;
    }

    leftvar = (screenX - width) / 2;
    rightvar = (screenY - height) / 2;
    if (navigator.appName == "Microsoft Internet Explorer") {
        leftprop = leftvar;
        topprop = rightvar;
    }
    else {
        leftprop = (leftvar - pageXOffset);
        topprop = (rightvar - pageYOffset);
    }

    properties = properties + ", left = " + leftprop;
    properties = properties + ", top = " + topprop;

    closePopup3();
    popupHandle3 = open(url, name, properties);
}

function closePopup4() {
    if (popupHandle4 != null && !popupHandle4.closed) popupHandle4.close();
}

function displayPopup4(url, name, height, width) {

    var properties = "menubar = 0,toolbar = 0, location = 0, scrollbars=1, resizable=0, height = " + height;
    properties = properties + ", width=" + width;

    var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;

    if (navigator.appName == "Microsoft Internet Explorer") {
        screenY = window.screen.availHeight;
        screenX = window.screen.availWidth;
    }
    else {
        screenY = window.outerHeight;
        screenX = window.outerWidth;
    }

    leftvar = (screenX - width) / 2;
    rightvar = (screenY - height) / 2;
    if (navigator.appName == "Microsoft Internet Explorer") {
        leftprop = leftvar;
        topprop = rightvar;
    }
    else {
        leftprop = (leftvar - pageXOffset);
        topprop = (rightvar - pageYOffset);
    }

    properties = properties + ", left = " + leftprop;
    properties = properties + ", top = " + topprop;

    closePopup4();
    popupHandle4 = open(url, name, properties);
}

function closePopup5() {
    if (popupHandle5 != null && !popupHandle5.closed) popupHandle5.close();
}

function displayPopup5(url, name, height, width) {

    var properties = "menubar = 0,toolbar = 0, location = 0, scrollbars=1, resizable=0, height = " + height;
    properties = properties + ", width=" + width;

    var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;

    if (navigator.appName == "Microsoft Internet Explorer") {
        screenY = window.screen.availHeight;
        screenX = window.screen.availWidth;
    }
    else {
        screenY = window.outerHeight;
        screenX = window.outerWidth;
    }

    leftvar = (screenX - width) / 2;
    rightvar = (screenY - height) / 2;
    if (navigator.appName == "Microsoft Internet Explorer") {
        leftprop = leftvar;
        topprop = rightvar;
    }
    else {
        leftprop = (leftvar - pageXOffset);
        topprop = (rightvar - pageYOffset);
    }

    properties = properties + ", left = " + leftprop;
    properties = properties + ", top = " + topprop;

    closePopup5();
    popupHandle5 = open(url, name, properties);
}

function closePopup6() {
    if (popupHandle6 != null && !popupHandle6.closed) popupHandle6.close();
}

function displayPopup6(url, name, height, width) {

    var properties = "menubar = 0,toolbar = 0, location = 0, scrollbars=1, resizable=0, height = " + height;
    properties = properties + ", width=" + width;

    var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;

    if (navigator.appName == "Microsoft Internet Explorer") {
        screenY = window.screen.availHeight;
        screenX = window.screen.availWidth;
    }
    else {
        screenY = window.outerHeight;
        screenX = window.outerWidth;
    }

    leftvar = (screenX - width) / 2;
    rightvar = (screenY - height) / 2;
    if (navigator.appName == "Microsoft Internet Explorer") {
        leftprop = leftvar;
        topprop = rightvar;
    }
    else {
        leftprop = (leftvar - pageXOffset);
        topprop = (rightvar - pageYOffset);
    }

    properties = properties + ", left = " + leftprop;
    properties = properties + ", top = " + topprop;

    closePopup6();
    popupHandle6 = open(url, name, properties);
}

function closePopupR() {
    if (popupHandleR != null && !popupHandleR.closed) popupHandleR.close();
}

function displayPopupResizable(url, name, height, width) {

    var properties = "menubar = 0,toolbar = 0, location = 0, scrollbars=1, resizable=1, height = " + height;
    properties = properties + ", width=" + width;

    var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;

    if (navigator.appName == "Microsoft Internet Explorer") {
        screenY = window.screen.availHeight;
        screenX = window.screen.availWidth;
    }
    else {
        screenY = window.outerHeight;
        screenX = window.outerWidth;
    }

    leftvar = (screenX - width) / 2;
    rightvar = (screenY - height) / 2;
    if (navigator.appName == "Microsoft Internet Explorer") {
        leftprop = leftvar;
        topprop = rightvar;
    }
    else {
        leftprop = (leftvar - pageXOffset);
        topprop = (rightvar - pageYOffset);
    }

    properties = properties + ", left = " + leftprop;
    properties = properties + ", top = " + topprop;

    closePopupR();
    popupHandleR = open(url, name, properties);
}

function closePopupR2() {
    if (popupHandleR2 != null && !popupHandleR2.closed) popupHandleR2.close();
}

function displayPopupResizable2(url, name, height, width) {

    var properties = "menubar = 0,toolbar = 0, location = 0, scrollbars=1, resizable=1, height = " + height;
    properties = properties + ", width=" + width;

    var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;

    if (navigator.appName == "Microsoft Internet Explorer") {
        screenY = window.screen.availHeight;
        screenX = window.screen.availWidth;
    }
    else {
        screenY = window.outerHeight;
        screenX = window.outerWidth;
    }

    leftvar = (screenX - width) / 2;
    rightvar = (screenY - height) / 2;
    if (navigator.appName == "Microsoft Internet Explorer") {
        leftprop = leftvar;
        topprop = rightvar;
    }
    else {
        leftprop = (leftvar - pageXOffset);
        topprop = (rightvar - pageYOffset);
    }

    properties = properties + ", left = " + leftprop;
    properties = properties + ", top = " + topprop;

    closePopupR2();
    popupHandleR2 = open(url, name, properties);
}
