var ERRS="";

function clearERR(fld){
 eval("ERRS=ERRS.replace('"+fld.title+",','')");fld.style.border="2px solid #999";
 fld.style.color="#000";
};

function setERR(fld){
 clearERR(fld); ERRS=ERRS+fld.title+",";
 fld.style.border="2px solid #F00"; fld.style.color="#F00";

};

function halt(fld,msg){setERR(fld); alert(msg);HALT()};

function checkint(fld){  // always eval input
  if(arguments.length==1)nm=fld.title;
  var val,i;
  if(arguments.length<3)emptyval="";
   val=fld.value.replace(/\s/g,"");
   if(val.replace(/[0-9]/g,"")!="")halt(fld,"ERROR: Your input to '"+nm+"' must contain an integer only.")
   try{i=eval(val) }
   catch(evt){halt(fld,"ERROR: Your input to '"+nm+"' must contain an integer.");return NaN}
   
   if(isNaN(i))
     {//alert(nm+" is NaN");
        if(fld=="") i=emptyval // empty fields always allowed as input ELSE use:-
       //else if(isemptyinput(fld))halt("The "+nm+" input box must have a value typed in.")
      else halt(fld,"No number found for "+nm)
     };
   clearERR(fld)
 };
 
function checkang(fld,canbMT){var val,i;
  if(arguments.length==1){nm=fld.title;canbMT=false};
  val=fld.value.replace(/\s/g,"");
  if(val.replace(/\s/,"")=="")
       if(canbMT){clearERR(fld);return}
       else halt(fld,"ERROR:  Your must put something in the "+nm+" input box");
  if(val.replace(/[0-9]/g,"").replace(/\./,"")!="")
    halt(fld,"ERROR: Your input to '"+nm+"' must contain an integer or half-integer "+(canbMT?"":"only")+".")
  try{i=eval(val) }
      catch(evt){halt(fld,"ERROR: Your input for '"+nm+"' must contain an integer or half-integer only.");return NaN}
   
   if(isNaN(i))
     {//alert(nm+" is NaN");
        if(fld=="") i=emptyval // empty fields always allowed as input ELSE use:-
       //else if(isemptyinput(fld))halt("The "+nm+" input box must have a value typed in.")
      else halt(fld,"No number found for "+nm)
      };
   if(Math.abs(Math.round(i*2)-i*2)>0.00001)
         halt(fld,nm+" only recognizes .5 and no other decimal places")
     if(Math.floor(i)==i&&val.indexOf('.')!=-1){val=val.slice(0,val.indexOf('.'));fld.value=val};
   clearERR(fld)
};
 
 function showdiv(dv,yes){  document.getElementById(dv).style.display=(yes?"block":"none") };
 
 function allOK(){
   if(ERRS.length>0){alert("The following inputs need correction first:"+ERRS.slice(0,ERRS.length-1));
      return false};
   if(document.getElementById("starang1").value.replace(/\s/g,"")=="")document.getElementById("starang1").value=0;
   if(document.getElementById("starang2").value.replace(/\s/g,"")=="")document.getElementById("starang2").value=0;
   return  true
 };
 
 function checkCR(evt) {
   var evt  = (evt) ? evt : ((event) ? event : null);
   var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
   if ((evt.keyCode == 13) && (node.type=="text")) {alert("Please use the SUBMIT button - RETURN characters are ignored");return false;}
  }

 document.onkeypress = checkCR; // disable RETURN
  
 function init(){ document.forms[0].reset();showdiv('interlaceDIV',false); showdiv('symmnotes',false); ERRS.length=0;ERRS="" };
 

