//----- CONTROLLO: MAIL -------- 
function checkEMail(objValue)
{
	apos=objValue.indexOf("@");
	dotpos=objValue.lastIndexOf(".");
	lastpos=objValue.length-1;
	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
	{return false;}
	else {return true;}
}
function checkLogin(){
	if(document.formriservata.ut_username.value != "" && document.formriservata.ut_password.value != "" ){
		document.formriservata.submit();
	}
}
function assegnaXMLHttpRequest() {
		 // lista delle variabili locali
		 var
	     // variabile di ritorno, nulla di default
	     XHR = null,
		 // informazioni sul nome del browser
		 browserUtente = navigator.userAgent.toUpperCase();
		 // browser standard con supporto nativo
		 // non importa il tipo di browser
		 if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
		    XHR = new XMLHttpRequest();
		    // browser Internet Explorer
		    // è necessario filtrare la versione 4
		    else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) {
				  // la versione 6 di IE ha un nome differente
				  // per il tipo di oggetto ActiveX
				  if(browserUtente.indexOf("MSIE 5") < 0)
				   XHR = new ActiveXObject("Msxml2.XMLHTTP");
				  // le versioni 5 e 5.5 invece sfruttano lo stesso nome
				  else
				   XHR = new ActiveXObject("Microsoft.XMLHTTP");
				 }
         return XHR;
}
function getContenuto(nomeFile,variabile,valore,container) {
 var ajax = assegnaXMLHttpRequest();
  if(ajax) {
  document.getElementById(container).innerHTML = "<img src='../common/loading.gif'>";
  ajax.open('post', nomeFile, true);
   ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
   var myPost = variabile + '=' + escape(valore);
   ajax.setRequestHeader("connection", "close");
   ajax.send(myPost);
   ajax.onreadystatechange = function() {
	   //document.getElementById(container).innerHTML = ajax.status;
   if(ajax.readyState === 4) {
     if(ajax.status == 200){
       document.getElementById(container).innerHTML = ajax.responseText;
       }else{
       
      }
   }
 }
}
}
function getContenuto2(nomeFile,variabile,valore,variabile2,valore2,container) {
 var ajax = assegnaXMLHttpRequest();
  if(ajax) {
  document.getElementById(container).innerHTML = "<img src='../common/loading.gif'>";
  ajax.open('post', nomeFile, true);
   ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
   var myPost = variabile + '=' + escape(valore);
   myPost+= '&' + variabile2 + '=' + escape(valore2);
   ajax.setRequestHeader("connection", "close");
   ajax.send(myPost);
   ajax.onreadystatechange = function() {
   if(ajax.readyState === 4) {
     if(ajax.status == 200){
       document.getElementById(container).innerHTML = ajax.responseText;
       }else{
       alert("Operazione fallita, errore numero " + ajax.status);
      }
   }
 }
}
}
function mySbm(){
  if(document.fpassw.email.value != ''){
	  document.fpassw.submit();
	  }
}
function checkForm(msg,msg2){
    if(document.form1.nome.value == ''){
	   alert(msg);
	   return;
	}
	if(document.form1.cognome.value == ''){
	   alert(msg);
	   return;
	}
	if(document.form1.azienda.value == ''){
	   alert(msg);
	   return;
	}
	if(document.form1.idProfessione.value == ''){
	   alert(msg);
	   return;
	}
	if(document.form1.telefono.value == ''){
	   alert(msg);
	   return;
	}
	if(document.form1.email.value == ''){
	   alert(msg);
	   return;
	}else{
		if(checkEMail(document.form1.email.value) == false){
		    alert(msg2);
			return;
		 }
		}
	if(document.form1.indirizzo.value == ''){
	   alert(msg);
	   return;
	}
	if(document.form1.cap.value == ''){
	   alert(msg);
	   return;
	}
	if(document.form1.citta.value == ''){
	   alert(msg);
	   return;
	}
	if(document.form1.provincia){
	  if(document.form1.provincia.value == ''){
	   alert(msg);
	   return;
	}
	}
	if(document.form1.nazione.value == ''){
	   alert(msg);
	   return;
	}
    if(document.form1.dati.checked == 0){
	   alert(msg);
	   return;
	}
	document.form1.submit();
}
function checkNazione(nazione){
	      document.getElementById('provincialabel').innerHTML = '';
		  document.getElementById('provinciafield').innerHTML = '';
		  
       if(nazione == 'Italy@IT'){
	      document.getElementById('provincialabel').innerHTML = '<strong style="color:#FF0000;">*</strong>Provincia';
		  getContenuto('../get_province.php','vd','vd','provinciafield')
		 
	   }
}