﻿/**
 * JavaScript implementation of the PHP $_GET function.
 * Original script was found at
 * http://www.onlineaspect.com/2009/06/10/reading-get-variables-with-javascript/
 *
 * @param q
 *   The variable to be retrieved. Given as a string.
 * @param s
 *   Optional parameter. String containing the entire URL portion with the QueryString.
 * @return
 *   Returns the value of the selected variable in the string. If not present, returns an empty string.
 */
function $_GET(q, s) {
    s = (s) ? s : window.location.search;
    var Reg = new RegExp('&' + q + '=([^&]*)', 'i');
    return (s = s.replace(/^\?/, '&').match(Reg)) ? s = s[1] : s = '';
}
