﻿function SetCookie(sName, sValue) {
    document.cookie = sName + "=" + escape(sValue) + "; "
}
function GetCookie(sName) {
    var aCookie = document.cookie.split("; ");
    for (var i = 0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
            return unescape(aCrumb[1]);
    }
    return null;
}
function SetPermanentCookie(sName, sValue) {
    var date = new Date();
    date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
    document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString() + ";";
}
function DelCookie(sName) {
    document.cookie = sName + "=delete; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}

function openCenteredWindow(url, pgname, w, h) {
    if (!w) w = 520;
    if (!h) h = 500;
    var width = w;
    var myWindow;
    var height = h;
    var left = parseInt((screen.availWidth / 2) - (width / 2));
    var top = parseInt((screen.availHeight / 2) - (height / 2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    Fig1Window = window.open(url, pgname, windowFeatures);
    FigureToFront();
    return false;
}
function FigureToFront() {
    Fig1Window.focus()
}
function openInNewWindow(link) {
    var newWindow = window.open(link, '_blank');
    newWindow.focus();
}
