// JavaScript Document

function check_toto(theform , tot_item){
  if(theform.persone.value==''|| !(CheckNumber(theform.persone.value))){
    alert('Inserire il numero di persone');
      theform.persone.focus();
      return false;
  }
  
  

  if(document.getElementById('titolo') && theform.titolo.value==''){
    alert('inserire il titolo della ricetta');
    theform.titolo.focus();
    return false;
  }
  
  if(document.getElementById('procedimento') && theform.procedimento.value==''){
    alert('inserire il procedimento della ricetta');
    theform.procedimento.focus();
    return false;
  }

  
  
  if (theform.ing1.value!='' && theform.qta1.value==''){
    alert('inserire la quantità');
    theform.qta1.focus();
    return false;
  }

  if (theform.ing2.value!='' && theform.qta2.value==''){
    alert('inserire la quantità');
    theform.qta2.focus();
    return false;
  }

  if (theform.ing3.value!='' && theform.qta3.value==''){
    alert('inserire la quantità');
    theform.qta3.focus();
    return false;
  }

  if (theform.ing4.value!='' && theform.qta4.value==''){
    alert('inserire la quantità');
    theform.qta4.focus();
    return false;
  }

  if (theform.ing5.value!='' && theform.qta5.value==''){
    alert('inserire la quantità');
    theform.qta5.focus();
    return false;
  }

  if (theform.ing6.value!='' && theform.qta6.value==''){
    alert('inserire la quantità');
    theform.qta6.focus();
    return false;
  }

  if (theform.ing7.value!='' && theform.qta7.value==''){
    alert('inserire la quantità');
    theform.qta7.focus();
    return false;
  }

  if (theform.ing8.value!='' && theform.qta8.value==''){
    alert('inserire la quantità');
    theform.qta8.focus();
    return false;
  }

  if (theform.ing9.value!='' && theform.qta9.value==''){
    alert('inserire la quantità');
    theform.qta9.focus();
    return false;
  }

  if (theform.ing10.value!='' && theform.qta10.value==''){
    alert('inserire la quantità');
    theform.qta10.focus();
    return false;
  }

  if (theform.ing11.value!='' && theform.qta11.value==''){
    alert('inserire la quantità');
    theform.qta11.focus();
    return false;
  }
  if (theform.ing12.value!='' && theform.qta12.value==''){
    alert('inserire la quantità');
    theform.qta11.focus();
    return false;
  }
  if (theform.ing13.value!='' && theform.qta13.value==''){
    alert('inserire la quantità');
    theform.qta13.focus();
    return false;
  }
  if (theform.ing14.value!='' && theform.qta14.value==''){
    alert('inserire la quantità');
    theform.qta14.focus();
    return false;
  }
  if (theform.ing15.value!='' && theform.qta15.value==''){
    alert('inserire la quantità');
    theform.qta15.focus();
    return false;
  }


// 	for (i=0;i<11;i++) {
// 		box = theform.elements[i];
// 		
//     myString = new String(box.name);
// 		ret=myString.indexOf('ing',0);
//     if (ret!=0){
//     if (!box.value) {
// 			alert('You haven\'t filled in ' + box.name + '!');
//       box.focus()
// 			return false;
// 		}
// 	
//   }
//   
//   }

return true;

}



function chech_qta(me){
  if(!CheckNumber(me.value)){
    me.value='';
  }
}

function add_value(){
  actual=document.frm1.incr.value;
  if (actual>0){
    document.frm1.incr.value=++actual;
  }
}

function remove_value(){
  actual=document.frm1.incr.value;
  if (actual>0){
    document.frm1.incr.value=--actual;
  }
}



function CheckNumber(nomecampo){	
	validRegExp =/[-+]?([0-9]*\.[0-9]+|[0-9]+)/;
	if (nomecampo.search(validRegExp) == -1)
	{
		return false;
	}else{
		return true;
	}	
}
