/*
     $Revision$
     $Id$
*/

function checkInput(evt)
{
  evt = evt || window.event;
  var obj = evt.srcElement || evt.target;
  var new_val = obj.value;
  var sk_kenmerktype = obj.getAttribute("value1");
  //var sk_lengte = parseInt(obj.getAttribute("value2"),10);
  var sk_nmin = parseInt(obj.getAttribute("value3"),10);
  var sk_nmax = parseInt(obj.getAttribute("value4"),10);

  if (sk_kenmerktype == 'N') {
    if( new_val == "" || new_val >= 0 || (!isNaN(new_val) && isGoodNumber(new_val,true,true,-1,-1) &&
        parseInt(new_val,10) >= 0 )) {

      i = obj.id.substring(3);
      last_value = parseInt(document.getElementById("last_val"+i).value,10);
      if( new_val == "" ) new_val = last_value;
      if( new_val < last_value ){
          alert(L("lcl_ins_value_to_low"));
          obj.focus();
          return false;
      }
      else if( !isNaN(sk_nmin) && new_val < sk_nmin ){
          alert(L("lcl_ins_value_below_nmin"));
          obj.focus();
          return false;
      }
      else if( !isNaN(sk_nmax) && new_val > sk_nmax ){
          alert(L("lcl_ins_value_below_nmax"));
          obj.focus();
          return false;
      }
      return true;
    }
    alert(L("lcl_ins_bad_value"));
    obj.focus();
    return false;
  }
  else {
    // yet, only numerical kenmerktypes are supported
    // alert(L("lcl_obj_only_num"));
    obj.value = "";
  }
}
