/*
CONTROLLO INSERIMENTO DATA NEL FORMATO GG-MM-AAAA E CONVERSIONE IN AAAAMMGG PER MYSQL
*/
function controllo_data() 
{		
	
	  if (document.f.new_start_date.value =="") {
	   alert("Field From must be written.");
	   document.f.new_start_date.select();
	   return false;
	}
	


			if (document.f.new_start_date.value.substring(2,3) != "-" ||
	   document.f.new_start_date.value.substring(5,6) != "-" ||
	   isNaN(document.f.new_start_date.value.substring(0,2)) ||
	   isNaN(document.f.new_start_date.value.substring(3,5)) ||
	   isNaN(document.f.new_start_date.value.substring(6,10)) ||
	   document.f.new_start_date.value.substring(6,10) <2000 ) {
	      alert("Insert the date From using the format dd/mm/yyyy");
	      //document.f.new_start_date.value = "";
	      document.f.new_start_date.focus();
	      return false;
	}
	
	    if (document.f.new_start_date.value.substring(0,2) > 31) {
	   alert("Impossible using a value over 31 for days into field From");
	   document.f.new_start_date.select();
	   return false;
	}
	
	    if (document.f.new_start_date.value.substring(3,5) > 12) {
	   alert("Impossible using a value over 12 for months into field From");
	   //document.f.new_start_date.value = "";
	   document.f.new_start_date.focus();
	   return false;
	}
	
	if (document.f.new_end_date.value =="") {
	   alert("Field To must be written.");
	   document.f.new_end_date.select();
	   return false;
	}
				if (document.f.new_end_date.value.substring(2,3) != "-" ||
	   document.f.new_end_date.value.substring(5,6) != "-" ||
	   isNaN(document.f.new_end_date.value.substring(0,2)) ||
	   isNaN(document.f.new_end_date.value.substring(3,5)) ||
	   isNaN(document.f.new_end_date.value.substring(6,10)) ||
	   document.f.new_end_date.value.substring(6,10) < 2000 ) {
	      alert("Insert the date To using the format dd/mm/yyyy");
	      //document.f.new_end_date.value = "";
	      document.f.new_end_date.focus();
	      return false;
	}
	
	     if (document.f.new_end_date.value.substring(0,2) > 31) {
	   alert("Impossible using a value over 31 for days");
	   document.f.new_end_date.select();
	   return false;
	}
	
	    if (document.f.new_end_date.value.substring(3,5) > 12) {
	   alert("Impossible using a value over 12 for months");
	   //document.f.new_end_date.value = "";
	   document.f.new_end_date.focus();
	   return false;
	}
	
		if (isNaN(document.f.persone.value)==true || document.f.persone.value=="") {
	   alert("Incorrect persons' number. Insert a number");
	   //document.f.persone.value = "";
	   document.f.persone.focus();
	   return false;
	}
	
//VALORE RADIO BUTTON PIAZZOLE - APPARTAMENTI
if(document.f.posizione.value==undefined){
for (var i=0; i < document.f.posizione.length; i++)
   {
   if (document.f.posizione[i].checked)
      {
      var rad_val = document.f.posizione[i].value;
      }
   }
	
	//alert(rad_val);
	if (rad_val=="" || rad_val==undefined) { 
	alert("Camping pitch? Apartment?");
       return  false; 
	}	
}

	
       //INVIA IL MODULO
	else{
	return true;
	}		
}

/*
INSERIMENTO DATA ODIERNA DI DEFAULT
*/
function data_odierna() 
{	
		var data=new Date();
		var anno=data.getFullYear();
		var mese=data.getMonth()+1;
		var giorno=data.getDate();
		if(mese<10) mese = "0" + mese;
  		if(giorno<10) giorno= "0" + giorno;

    if (document.f.da_quando.value == "01/01/1970" ||
    document.f.da_quando.value == "" ) {
	document.f.da_quando.value = giorno + "/" + mese + "/" + anno;
	}
	    if (document.f.a_quando.value == "01/01/1970" ||
    document.f.a_quando.value == "" ) {
	document.f.a_quando.value = giorno + "/" + mese + "/" + anno;

	}

}	