function verEmail(stringa)
   {
   if (stringa.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
      return true;
    else
      return false;
   }

function LunghezzaMax(campo)
	{
	if ((campo.value.length>300)== true )
		return true;
	else
		return false;	
	}

function nome(stringa)
   {
   if (stringa.value != "")
      return false;
   else
      return true;
}

function isDate(str) { 
	var month_names = new Array("January","February","March","April", "May","June","July","August","September","October","November","December");

	if (str.indexOf(" ")==str.lastIndexOf(" ")) 
		return false;
	spz = str.split(" ");
	
	for(m=0;m<12;m++){
		if(spz[1]==month_names[m]){
			var my_m = m;
			//alert(my_m);
		}
	}
	
	dat = new Date(spz[2], my_m, spz[0]);
	
	if	( 
		dat.getFullYear() == parseFloat(spz[2]) &&
		dat.getMonth() == (parseFloat(my_m)) &&
		dat.getDate() == parseFloat(spz[0]) 
		) {
			return dat;
	}
	return false;
} 

function c_data(form)
   {
 
  if (nome(form.cal_data) == true) 
	 {
	alert("Select a date for the move");  
	//form.p_via.focus();
	return false;
	 }
	 
	var msg = "";
	var wdata = isDate(form.cal_data.value);
	//alert(wdata);
	if (!wdata) {
		msg += "Please select a date click the calendar icon \n";
		alert(msg);
		form.cal_data.value="";
		return false;	
	}
		
	//var dmin = isDate(obj.scadenza.options[obj.scadenza.selectedIndex].value);
	var oggi = new Date();
	var dmin = new Date();
	dmin.setDate(oggi.getDate()+7);
	
	
	if (wdata<dmin)
		msg += 'The removal can not be made before 7 days of the request for quote ';
	
	//if (wscad<wdata)
		//msg += "The expiration date and 'child's date\n";
	
	if (msg) {
		alert(msg);
		return false;
	}
	 
	 return true;
   }

function ana_casa(form)
   {
 
  if (nome(form.surname) == true) 
	 {
	alert("The name is required");  
	form.surname.value=""; 
	form.surname.focus();
	return false;
	 }
 
   if (nome(form.name) == true) 
	 {
	 alert("The name is required"); 
	form.name.value=""; 
	form.name.focus();
	return false;
	 }
	
	if (verEmail(form.email.value) == false)
	{
	alert("Enter a valid email address");
	form.email.focus();
	return false;
	}

	if(form.privacy.checked==0){
		alert ("To continue you must accept the privacy policy");
		return false;
	}

	 return true;
   }
   
   function ana_uff(form)
   {
 
  if (nome(form.ragione) == true) 
	 {
	alert("The reason is mandatory");  
	form.ragione.value=""; 
	form.ragione.focus();
	return false;
	 }
	 
	 if (nome(form.tel2) == true) 
	 {
	alert("The telephone field is mandatory");  
	form.tel2.value=""; 
	form.tel2.focus();
	return false;
	 }
  
	if (verEmail(form.mail.value) == false)
	{
	alert("Enter a valid email address");
	form.mail.focus();
	return false;
	}

	if(form.privacy.checked==0){
		alert ("To continue you must accept the privacy policy");
		return false;
	}

	 return true;
   }
   
   
   function part_casa(form)
   {
 
  if (nome(form.p_via) == true) 
	 {
	alert("The address field is mandatory");  
	form.p_via.focus();
	return false;
	 }
 
   if (nome(form.p_citta) == true) 
	 {
	 alert("The City field is mandatory"); 
	form.p_citta.focus();
	return false;
	 }
	 
	  if (nome(form.p_pr) == true) 
	 {
	 alert("Select a province"); 
	form.p_pr.focus();
	return false;
	 }
	 
	 
	  if ((nome(form.p_cap) == true)||(isNaN(form.p_cap.value)))  
	 {
	 alert("Enter a valid zip code."); 
	form.p_cap.focus();
	return false;
	 }
	 
	  if ((nome(form.p_piano) == true)||(isNaN(form.p_piano.value))) 
	 {
	 alert("Enter the floor (numeric) of the dwelling. Enter 0 if the ground floor."); 
	form.p_piano.focus();
	return false;
	 }
	

	if(!(form.p_ascensore[0].checked || form.p_ascensore[1].checked)){
	 alert("The field is required elevators"); 
	return false;
	}	
	
	 
	 return true;
   }

function volume(form)
   {
 
 	if (nome(form.totalevolume) == true)  
	 {
	alert("To continue you must calculate the volume of strasloco");  
	//form.p_via.focus();
	return false;
	 }
 
	 return true;
   }
   
   
   function service(n, form)
   {
 
 	//var array_check = document.getElementsByTagName('input');
  var serv = n;
  //for (i=1;i<=serv; i++) {
    //var inp = array_check[i];
    //alert(inp);
	//if ((inp.getAttribute('type') == 'radio')) {
		//var inpName =  document.getElementById("ch_"+i);
		//var inpName = inpName.getAttribute('name');
		//alert(inpName);
		
		//document.getElementById('questionario').informativa[1].checked 
		
        if ((document.servizi.ch_1[0].checked)||(document.servizi.ch_1[1].checked)){
			cont = "ok";
			//alert(inpName+"è selezionato")
		}else {
			cont = "ko";
			alert('Select the services to be included in the estimate and excluded');
			return false;  
			//alert(inpName+" non è selezionato")
		}
		 if ((document.servizi.ch_2[0].checked)||(document.servizi.ch_2[1].checked)){
			cont = "ok";
			//alert(inpName+"è selezionato")
		}else {
			cont = "ko";
			alert('Select the services to be included in the estimate and excluded');
			return false;  
			//alert(inpName+" non è selezionato")
		}
		 if ((document.servizi.ch_3[0].checked)||(document.servizi.ch_3[1].checked)){
			cont = "ok";
			//alert(inpName+"è selezionato")
		}else {
			cont = "ko";
			alert('Select the services to be included in the estimate and excluded');
			return false;  
			//alert(inpName+" non è selezionato")
		}
		 if ((document.servizi.ch_4[0].checked)||(document.servizi.ch_4[1].checked)){
			cont = "ok";
			//alert(inpName+"è selezionato")
		}else {
			cont = "ko";
			alert('Select the services to be included in the estimate and excluded');
			return false;  
			//alert(inpName+" non è selezionato")
		}
		 if ((document.servizi.ch_5[0].checked)||(document.servizi.ch_5[1].checked)){
			cont = "ok";
			//alert(inpName+"è selezionato")
		}else {
			cont = "ko";
			alert('Select the services to be included in the estimate and excluded');
			return false;  
			//alert(inpName+" non è selezionato")
		}
		 if ((document.servizi.ch_6[0].checked)||(document.servizi.ch_6[1].checked)){
			cont = "ok";
			//alert(inpName+"è selezionato")
		}else {
			cont = "ko";
			alert('Select the services to be included in the estimate and excluded');
			return false;  
			//alert(inpName+" non è selezionato")
		}
		 if ((document.servizi.ch_7[0].checked)||(document.servizi.ch_7[1].checked)){
			cont = "ok";
			//alert(inpName+"è selezionato")
		}else {
			cont = "ko";
			alert('Select the services to be included in the estimate and excluded');
			return false;  
			
			//alert(inpName+" non è selezionato")
		}
		 if ((document.servizi.ch_8[0].checked)||(document.servizi.ch_8[1].checked)){
			cont = "ok";
			//alert(inpName+"è selezionato")
		}else {
			cont = "ko";
			alert('Select the services to be included in the estimate and excluded');
			return false;  
			//alert(inpName+" non è selezionato")
		}
		 if ((document.servizi.ch_9[0].checked)||(document.servizi.ch_9[1].checked)){
			cont = "ok";
			//alert(inpName+"è selezionato")
		}else {
			cont = "ko";
			alert('Select the services to be included in the estimate and excluded');
			return false;  
			//alert(inpName+" non è selezionato")
		}
		
       
		 
    //}
  //}
  
  
 
  
   }
   
   
   
   
   
   
   
    function sopralluogo(form)
   {
	   
	   if (nome(form.cal_data) == true) 
	 {
	alert("Select a date for the move");  
	//form.p_via.focus();
	return false;
	 }
	 
	var msg = "";
	var wdata = isDate(form.cal_data.value);
	//alert(wdata);
	if (!wdata) {
		msg += "Please select a date click the calendar icon \n";
		alert(msg);
		form.cal_data.value="";
		form.cal_data.focus();
		return false;	
	}
		
	//var dmin = isDate(obj.scadenza.options[obj.scadenza.selectedIndex].value);
	var oggi = new Date();
	var dmin = new Date();
	dmin.setDate(oggi.getDate()+7);
	
	
	if (wdata<dmin)
		msg += 'The removal can not be made before 7 days of the request for quote ';
	
	//if (wscad<wdata)
		//msg += "La data di scadenza e' minore della data\n";
	
	if (msg) {
		alert(msg);
		form.cal_data.focus();
		return false;
	}
	   
	
 
   if (nome(form.name) == true) 
	 {
	 alert("The name is required"); 
	form.name.value=""; 
	form.name.focus();
	return false;
	 }
	 
	     if (nome(form.surname) == true) 
	 {
	alert("Last name is required");  
	form.surname.value=""; 
	form.surname.focus();
	return false;
	 }
	 
	  if ((nome(form.tel) == true)&&(nome(form.tel2) == true)&&(nome(form.mobile) == true)) 
	 {
	alert("Enter at least one telephone number");  
	form.tel.focus();
	return false;
	 }
	
	if (verEmail(form.email.value) == false)
	{
	alert("Enter a valid email address");
	form.email.focus();
	return false;
	}

	
 
  if (nome(form.p_via) == true) 
	 {
	alert("The address field is mandatory");  
	form.p_via.focus();
	return false;
	 }
 
   if (nome(form.p_citta) == true) 
	 {
	 alert("The City field is mandatory"); 
	form.p_citta.focus();
	return false;
	 }
	 
	  if (nome(form.p_pr) == true) 
	 {
	 alert("Select a province"); 
	form.p_pr.focus();
	return false;
	 }
	 
	 
	  if ((nome(form.p_cap) == true)||(isNaN(form.p_cap.value)))  
	 {
	 alert("Enter a valid ZIP code."); 
	form.p_cap.focus();
	return false;
	 }
	 
	  if ((nome(form.p_piano) == true)||(isNaN(form.p_piano.value))) 
	 {
	 alert("Enter the floor (numeric) of the dwelling. Enter 0 if on the ground floor."); 
	form.p_piano.focus();
	return false;
	 }
	

	if(!(form.p_ascensore[0].checked || form.p_ascensore[1].checked)){
	 alert("Field elevators is required"); 
	return false;
	}	
	
	if (nome(form.a_via) == true) 
	 {
	alert("The field address is required");  
	form.a_via.focus();
	return false;
	 }
 
   if (nome(form.a_citta) == true) 
	 {
	 alert("The field City is mandatory"); 
	form.a_citta.focus();
	return false;
	 }
	 
	  if (nome(form.a_pr) == true) 
	 {
	 alert("Select a province"); 
	form.a_pr.focus();
	return false;
	 }
	 
	 
	  if ((nome(form.a_cap) == true)||(isNaN(form.a_cap.value)))  
	 {
	 alert("Enter a valid ZIP code."); 
	form.a_cap.focus();
	return false;
	 }
	 
	  if ((nome(form.a_piano) == true)||(isNaN(form.a_piano.value))) 
	 {
	 alert("Enter the floor (numeric) of the dwelling. Enter 0 if on the ground floor."); 
	form.a_piano.focus();
	return false;
	 }
	

	if(!(form.a_ascensore[0].checked || form.a_ascensore[1].checked)){
	 alert("The elevators field is required"); 
	return false;
	}	
	
	if(form.privacy.checked==0){
		alert ("To continue you must accept the privacy policy");
		return false;
	}
	 
	 return true;
   }
   
   
  function normativa(){
larghezza = 490; 
altezza = 300; 
var x = (screen.width-larghezza)/2; 
var y = (screen.height-altezza)/2; 

window.open("normativa.php","","scrollbars=yes, width=" + larghezza + ",height=" + altezza + ",left=" + x + ",top=" + y)
}
   
   
