/**
 * Validates the guides order form
 * Requires to have input elements bearing clas "order" to work
 * @return void
 * @see http://www.voyagessuperprix.com/guides-voir
 */
function checkGuidesOrderForm() {
    var orderForm = document.getElementById('selectWhichGuides');
    // Looping through input elements
    var inputs = document.getElementsByTagName('input');
    var error=0;
    var valid=0;
    for (var i=0;i<inputs.length;i++) {
        var current = inputs[i];
        if (current.value.length) {
            // Input is not empty
            if (!isNum(current.value)) {
                error++;
                addClass(current, 'error');
            }
            else {
                valid++;
               removeClass(current, 'error');
            }
        }
    }
    if (!error) {
        if (valid) { orderForm.submit(); }
        else { alert('Vous devez choisir au minimum un (1) guide!'); }
    }
}

/**
 * Determines if a string is numeric or not
 * @param mixed str String to evaluate
 * @return bool
 */
function isNum(str) {
	rx = /^(\d*)$/;
	exp = new RegExp(rx);
	return str.match(exp) == null? false : true;
}