var ua = navigator.userAgent.toLowerCase(), os;
ua.search("windows nt 6.1") != -1 ? os = "win7" : ua.search("windows nt 6.0") != -1 ? os = "winv" : ua.search("windows nt 5.1") != -1 ? os = "winxp" : ua.search("mac") != -1 ? os = "mac" : ua.search("linux") != -1 ? os = "linux" : os = "other";
 
// Read a page's GET URL variables and return them as an associative array.
function getUrlVars(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

// Open Window
var URL, width, height, scroll, menubar, toolbar, loc, resize, xPos, yPos, newWin, winName, center, alignRight;
function openWin(URL, width, height, scroll, menubar, loc, toolbar, resize, xPos, yPos, winName, center, alignRight, fullscreen){
    if (width == "") 
        width = screen.availWidth;
    if (height == "") 
        height = screen.availHeight;
    if (loc == "") 
        loc = "no";
    if (scroll == "") 
        scroll = "auto";
    if (menubar == "") 
        menubar = "no";
    if (toolbar == "") 
        toolbar = "no";
    if (resize == "") 
        resize = "yes";
    if (xPos == "") 
        xPos = "5";
    if (yPos == "") 
        yPos = "5";
    if (winName == "") 
        winName = "win";
    if (center == 'yes') {
        var centerWidth = screen.availWidth / 2;
        var centerHeight = screen.availHeight / 2;
        tempW = width / 2;
        tempH = height / 2;
        xPos = centerWidth - tempW;
        yPos = centerHeight - tempH;
    }
    if (alignRight == "yes") 
        xPos = screen.availWidth - width - 7;
    if (fullscreen == "yes") {
        xPos = 0;
        yPos = 0;
        if (navigator.appVersion.indexOf("mac") == 1) {
            width = screen.availWidth;
            height = screen.availHeight;
        } else {
            width = screen.availWidth - 7;
            height = screen.availHeight - 20;
        }
    }
    var features = "width=" + width + ",height=" + height + ",loc=" + loc + ",scrollbars=" + scroll + ",menubar=" + menubar + ",toolbar=" + toolbar + ",resizable=" + resize + ",left=" + xPos + ",top=" + yPos;
    newWin = window.open(URL, winName, features);
    if (window.focus) 
        newWin.focus();
    
}
