﻿/****************************************************************************************/
/* Querystring functions                                                                */
/****************************************************************************************/

//Have a function that takes a document object and matches elements to querystring variables
function Querystring_Document()
{
    for(intForm = 0; intForm < document.forms.length; intForm++)
    {
        for(intElement = 0; intElement < document.forms[intForm].elements.length; intElement++)
        {
            var strValue = Querystring_Variable(document.forms[intForm].elements[intElement].name);
            if (strValue != null)
            {
                strValue = unescape(strValue);
                document.forms[intForm].elements[intElement].value = strValue;
            }
        }
    }
}


function Querystring_Variable(variable)
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    
    for (var i=0; i<vars.length; i++)
    {
        var pair = vars[i].split("=");
        if (pair[0] == variable)
        {
            return pair[1];
        }
    } 
}

