﻿//Gets an query string parameter
//name = single QS parameter
function GetQueryStringElement(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}
//HIDE/SHOW LAYERS
function toggleLayer(whichLayer, action) {
    if (document.getElementById) {
        // this is the way the standards work
        var style = document.getElementById(whichLayer).style;
    }
    else if (document.all) {
        // this is the way old msie versions work
        var style = document.all[whichLayer].style;
    }
    else if (document.layers) {
        // this is the way nn4 works
        var style = document.layers[whichLayer].style;
    }
    if (action == "show")
        style.display = "block";
    else if (action == "hide")
        style.display = "none";
}
function toggleElement(elementName) {
    var temp = document.getElementById(elementName);
    if (temp)
        if (temp.style.display == 'none') //element is not visible, so expand it.
        toggleLayer(elementName, "show");
    else								//if true, element is visible so hide it
        toggleLayer(elementName, "hide");
}  
/**********
* Javascript functions to pop up a window with customized features 
**************************/
function Popup(url, w, h, menu) {
    x = Math.floor((screen.width - w) / 2);
    y = Math.floor((screen.height - h) / 2);

    features = "screenx=" + x + ",screeny=" + y + ",left=" + x + ",top=" + y + ",width=" + w + ",height=" + h + ",location=no,resizable=yes" + ",directories=no,status=no";
    if (menu != null) {
        features += ",menubar=no,toolbar=no, scrollbars=yes";
    }
    else {
        features += ",menubar=no,toolbar=no,scrollbars=no";
    }
    window.open(url, "newwin", features);
}