// Generic Form Validator
// You know, goes through all the controls, sees what's filled and what's not
// It's so tempting to write a story in these comments...:)
// If mode=0, user is warned but allowed to submit an incomplete form
// If mode=1, user is not allowed to submit an incomplete form
function validateMe(form,mode) {
    var i=0;
    var eles=form.elements;
    var rtn=true;
    var warned=false;
    for(i=0;i<eles.length;i++) {
      if (eles[i].name!="") {
        if (eles[i].value=="" && !eles[i].disabled) {
          if (warned==false) {
            switch(mode) {
              case 0:
                rtn=confirm("All fields have not been filled in! Proceed anyway?");
                if (rtn==false) {
                  badHighlight(eles[i]);
                }
                break;
              case 1:
                rtn=false;
                alert("¡Hay que rellenar todos los campos!");
                badHighlight(eles[i]);
                break;
            }
            warned=true;
          } else {
            badHighlight(eles[i]);
          }
        }
      }
    }
    return rtn;
}

function badHighlight (ele) {
  ele.style.background="#601515";
}

