﻿var win = null;
var ScreenWidth = null;
var ScreenHeight = null;

function openWindow(mypage, myname) {
    { ScreenWidth = 885 }
    { ScreenHeight = 700 }
    var TopPosition = (screen.height) ? ((screen.availHeight - ScreenHeight) / 2) - 15 : 0;
    var LeftPosition = (screen.width) ? (screen.availWidth - ScreenWidth) / 2 : 0;
    settings = "height=" + ScreenHeight + ",width=" + ScreenWidth + ",top=" + TopPosition + ",left=" + LeftPosition + ",toolbar=no,titlebar=yes,directories=no,fullscreen=no,status=no,scrollbars=yes,resizable=yes,menubar=no"
    win = window.open(mypage, encodeName(myname), settings)
    win.window.focus();
}

function smallWindow(mypage, myname) {
    { ScreenWidth = 670 }
    { ScreenHeight = 510 }
    var TopPosition = (screen.height) ? ((screen.availHeight - ScreenHeight) / 2) - 15 : 0;
    var LeftPosition = (screen.width) ? (screen.availWidth - ScreenWidth) / 2 : 0;
    settings = "height=" + ScreenHeight + ",width=" + ScreenWidth + ",top=" + TopPosition + ",left=" + LeftPosition + ",toolbar=no,titlebar=yes,directories=no,fullscreen=no,status=no,scrollbars=yes,resizable=yes,menubar=no"
    win = window.open(mypage, encodeName(myname), settings)
    win.window.focus();
}

function tinyWindow(mypage, myname) {
    { ScreenWidth = 450 }
    { ScreenHeight = 350 }
    var TopPosition = (screen.height) ? ((screen.availHeight - ScreenHeight) / 2) - 15 : 0;
    var LeftPosition = (screen.width) ? (screen.availWidth - ScreenWidth) / 2 : 0;
    settings = "height=" + ScreenHeight + ",width=" + ScreenWidth + ",top=" + TopPosition + ",left=" + LeftPosition + ",toolbar=no,titlebar=no,directories=no,fullscreen=no,status=no,scrollbars=no,resizable=no,menubar=no"
    win = window.open(mypage, encodeName(myname), settings)
    win.window.focus();
}

function encodeName(name) {
    name = name.replace(/\+/g, "");
    name = name.replace(/\./g, "");
    name = name.replace(/\-/g, "");
    name = name.replace(/\//g, "");
    name = name.replace(/\?/g, "");
    name = name.replace(/\=/g, "");
    name = name.replace(/\&/g, "");
    return escape(name);
}
