﻿var win = null;
var ScreenWidth = null;
var ScreenHeight = null;

function openWindow(mypage, myname) {
    { ScreenWidth = 825 }
    { ScreenHeight = 650 }
    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=yes,scrollbars=yes,resizable=yes,menubar=no"
    win = window.open(mypage, encodeName(myname), settings)
    win.window.focus();
}

function smallWindow(mypage, myname) {
    { ScreenWidth = 640 }
    { ScreenHeight = 480 }
    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 getUniqueID() {
    Stamp = new Date();

    var Hours;
    var Mins;
    var Seconds;
    var Milliseconds;

    Hours = Stamp.getHours();
    Mins = Stamp.getMinutes();
    Seconds = Stamp.getSeconds();
    Milliseconds = Stamp.getMilliseconds();

    return Hours.toString() + Mins.toString() + Seconds.toString() + Milliseconds.toString();
}

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, "");
    name = name.replace(/\=/g, "");
    name = name.replace(/\&/g, "");
    return escape(name);
}
