/*
 * Ensures a value submitted in a form is numeric and is in a range
 *
 * @param   object   the form
 * @param   string   the name of the form field to check
 * @param   integer  the minimum authorized value
 * @param   integer  the maximum authorized value
 *
 * @return  boolean  whether a valid number has been submitted or not
 */
function CheckFormElementInRange(theForm, theFieldName, min, max)
{
   var theField  = theForm.elements[theFieldName];
   var val       = parseFloat(theField.value);
   var isRange   = (typeof(min) != 'undefined' && typeof(max) != 'undefined');

   // It's not a number
   if (isNaN(val)) {
       theField.select();
       alert(errorMsg1);
       theField.focus();
       return false;
   }
   // It's a number but it is not between min and max
   else if (isRange && (val < min || val > max)) {
       theField.select();
       alert(val + errorMsg21 + min + errorMsg22 + max + errorMsg23 );
       theField.focus();
       return false;
   }
   // It's a valid number
   else {
       theField.value = val;
   }
   return true;
}

