/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function $(x) {
    return document.getElementById(x);
}
function SubmitForm (form, target) {
    var rc = false;
    // Get parameters
    var q = new Array();
    var selects = form.getElementsByTagName('select');
    for (var s in selects) {
        if (selects[s].name) {
            q.push(selects[s].name + '=' + selects[s].value);
        }
    }
    var inputs = form.getElementsByTagName('input');
    for (var i in inputs) {
        if (inputs[i].name) {
            if ((inputs[i].type == 'checkbox') || (inputs[i].type == 'radio')) {
                if (inputs[i].checked) {
                    q.push(inputs[i].name + '=' + inputs[i].value);
                }
            } else {
                q.push(inputs[i].name + '=' + inputs[i].value);
            }
        }
    }
    // send request
    var x = new XMLHttpRequest();
    x.onreadystatechange = function(a, b, c) {
        // Display results
        $(target).innerHTML = (x.readyState < 4) ? "Veuillez patienter..." : x.responseText;
    };
    x.open(form.method, form.action + '?' + q.join('&'), true);
    x.send();
    // Prepare to display results
    $(target).scrollIntoView(true);
    // Done
    return rc;
}

