

//In open JavaScript (not inside a function), define the array
var queryString = new Array();
// and then pull the querystyring parameters from the URL.
// The search property of the window location returns the query string.
// The method substring(1) removes the first character (the question mark).
// The split function then copies the parameters into an array called "parms"
var parameters = window.location.search.substring(1).split('&');
// For each element in the array, find the equal sign that separates the parameter
// name from the parameter value.  If there is one, divide the expression into
// the parameter name
for (var i=0; i<parameters.length; i++) {
    var pos = parameters[i].indexOf('=');
    // If there is an equal sign, separate the parameter into the name and value,
    // and store it into the queryString array.
    if (pos > 0) {
        var paramname = parameters[i].substring(0,pos);
        var paramval = parameters[i].substring(pos+1);
        queryString[paramname] = unescape(paramval.replace(/\+/g,' '));
    } else {
        //special value when there is a querystring parameter with no value
        queryString[parameters[i]]="" 
    }
}
