/********************************************************************************************************** 
 ***************** JS - Fabio Lucattini ******************************************************************
 **********************************************************************************************************/
 

 

/**************************************************************************************************************************
	GESTISCE LA POSIZIONE DEL SITO		
***************************************************************************************************************************/
 	function posSito(resize){
		
		var offerte = document.getElementById("offerte");
		var posY = 0;		
		
		if (navigator.appName != "Microsoft Internet Explorer"){
			screenW = document.width;
			screenH = document.height*2;
		}else {
			screenW = document.body.offsetWidth;
			screenH = document.body.offsetHeight;
		}

		/**
			Posiziona il sito
			document.getElementById("tab").style.marginLeft = ((screenW - 949)/2)+"px";
		*/
		posY = (screenW - 949)/2;  
		posY += 949 - 220;
		posY = (posY < 750) ? 751 : posY;
		
		if(resize != 1){
			offerte.style.marginLeft = Math.round(posY)+"px" ;
		}
	}
	
	function testMail(){
	if(document.getElementById("nome").value=='')
	{
		alert("INSERIRE IL NOME"); return false;
	}
	else if(document.getElementById("cognome").value=='')
	{
		alert("INSERIRE IL COGNOME"); return false;
	}
	else if(document.getElementById("emailMitt").value=='')
	{
		alert("INSERIRE LA VOSTRA E-MAIL"); return false;	
	}
	else if(document.getElementById("emailMitt").value!='')
	{
		var mail = document.getElementById("emailMitt").value;
	
		if(mail.search("@") != -1){
			if(mail.search("@") == (mail.length -1)){
				alert("Mail inserita non corretta ERRORE 1");
				return false;	
			}else{
					if(mail.split("@")[1].search(".") == (mail.split("@")[1].length -1)){		
						alert("Mail inserita non corretta ERRORE 2");
						return false;	
					}else{
						if(document.getElementById("testo").value=='')
						{
							alert("INSERIRE UN CORPO PER L'E-MAIL"); return false;	
						}
						else if( document.getElementById("nonaccetto").checked )
						{
							alert("DEVE ACCETTARE L'INFORMATIVA SULLA PRIVACY"); return false;	
						}
						else if( !document.getElementById("accetto").checked )
						{
							alert("DEVE ACCETTARE L'INFORMATIVA SULLA PRIVACY"); return false;
						}else{
							if(document.getElementById("nonaccetto").checked){
								alert("DEVE ACCETTARE L'INFORMATIVA SULLA PRIVACY"); return false;
							}else{
								sendMail();
							}
						}
					}
			}
		}else{
			alert("Mail inserita non corretta ERRORE 0");
			return false;	
		}
		
	}
}

function sendMail(){
	var nome = document.getElementById("nome").value;
	var cognome = document.getElementById("cognome").value;
	var email = document.getElementById("emailMitt").value;
	var testo = document.getElementById("testo").value;
	
	
	
	var action = "pagine/mail.php?stato=1&nome="+nome+"&cognome="+cognome+"&emailMitt="+email+"&testo="+testo;
	httpPagine.open('get', action);  
	httpPagine.onreadystatechange = sendMailRisp;  
	httpPagine.send(null);  
	
}


	 
	function sendMailRisp() {  
	   var divMail = document.getElementById("form");
	   
	   if(httpPagine.readyState < 4){	
	   		 divMail.innerHTML = ".. INVIO IN CORSO ..";
	   }
	   else if(httpPagine.readyState == 4)
	   {
		   if(httpPagine.status == 200)
		   {	
		   		
				
				divMail.innerHTML = httpPagine.responseText ;	
				
		   }
		   else
		   {
			   
			   	
				altezza = h.substr(0, h.length-2);				
		   		area.innerHTML = "<div align='center' style='margin-top:"+parseInt((altezza/2)-30)+"px;' class='verdana12'>.: ERRORE PAGINA :.</div>"
		   
		   }
		   distruggiLoad();
	   }
	   
	}
	
/***************************************************************************************************************************/
