function validateControlsRequired() {
    var rv = true;
    for (currarg = 0; currarg < arguments.length; currarg++) {
        var currControl = document.getElementById(arguments[currarg]);
        var currValidation = document.getElementById("v_" + arguments[currarg]);
        if (currControl && currValidation) {
            if (currControl.value == '') {
                rv = false;
                currValidation.style.display = '';
            }
            else {
                currValidation.style.display = 'none';
            }
        }
    }

    return rv;
}


function validateControlsExpression() {
    var rv = true;
    for (currarg = 0; currarg < arguments.length; currarg++) {
        var currControl = document.getElementById(arguments[currarg]);
        var currValidation = document.getElementById("vexp_" + arguments[currarg]);
        if (currControl && currValidation) {
            expVal = currValidation.getAttribute("exp");
            if (expVal && expVal.length > 0)
            {
                 if (currControl.value.length > 0 && !currControl.value.match(new RegExp(expVal)))
                 {
                       currValidation.style.display = '';
                       rv = false;
                 }
                 else
                 {
                       currValidation.style.display = 'none';
                 }
            }
        }
    }

    return rv;
}

function submitcontactinfo(urlArgs, targetElement, targetHTML)
{
// source, firstname, lastname, email and comment are all well known
// They should be included.

    var s = '';
    
    for (k in urlArgs)
    {
        s += '&' + escape(k) + '=' + escape(urlArgs[k]) ;
    }
    // remove leading '&'
    s = s.substring(1);
    var _h = null;

    // Handle IE and non-IE browsers
    if (window.XMLHttpRequest)
    {
        _h = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
         _h = new ActiveXObject("MSXML2.XMLHTTP.3.0");
    }

    if (_h != null)
    {
        _h.open('get', 'http://www.fluencymedia.com/submitcontact.php?' + s, true);
        // Event handler for the page being loaded. Closure
        // keeps it local
        _h.onreadystatechange = function()
            {
                if (this.readyState == 4 && document.getElementById(targetElement))
                {
                   document.getElementById(targetElement).innerHTML = targetHTML;
                }
            };
        
        // Send the request to the web server
        _h.send(null);
    }
}
