function CompilaCampi()
{
	document.mioform.z_pag.value = window.location.href;
}

function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Indirizzo email non valido!")
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Indirizzo email non valido!")
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Indirizzo email non valido!")
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Indirizzo email non valido!")
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Indirizzo email non valido!")
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Indirizzo email non valido!")
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Indirizzo email non valido!")
		    return false
		 }
 		 return true					
	}

	
function ValidateForm(){
	
	var email = document.mioform.z_email.value;
	var C1 = document.mioform.z_nome.value;
	var C2 = document.mioform.z_telefono.value;
	var C3 = document.mioform.z_testo.value;
	
	if (C1 == "") {
		alert("Compilare campo 'Nome'");
		document.getElementById('z_nome').focus();	
		
		return false;
		
	}
	
	if (email != "")
	{
		if (echeck(email)==false){
			document.getElementById('z_email').focus();
			return false;
		}
	}
	
	if (C2 == "") {
		alert("Compilare campo 'Telefono'");
		document.getElementById('z_telefono').focus();	
		
		return false;
		
	}
	if (C3 == "") {
		alert("Compilare campo 'Richiesta'");
		document.getElementById('z_testo').focus();	
		
		return false;
		
	}
	return true
}

 function isNumberKey(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode > 31 && (charCode < 48 || charCode > 57)) return false;
	return true;
}
