	function inStr(String1, String2)
	{
	    var a = 0;
    
	    if (String1 == null || String2 == null)
	        return (false);
    
	    String1 = String1.toLowerCase();
	    String2 = String2.toLowerCase();
    
	    a = String1.indexOf(String2);
	    if (a == -1)
	        return 0;
	    else
	        return a + 1;
	}


function fInvio()
{
	var nome;
	var mail;
	var telefono;
	var msg;
	
	var info = document.getElementById("info");
	
	if(info.nome.value == "")
	{
		check = false;
		alert("Inserire Nome");
		info.nome.focus();
		return;		
	}
	else
	{
		check = true;	
	}
	
	if(info.cognome.value == "")
	{
		check = false;
		alert("Inserire Cognome");
		info.cognome.focus();
		return;		
	}
	else
	{
		check = true;	
	}	
	

	if(info.mailInfo.value == "")
	{		
		check = false;
		alert("Inserire E-Mail");
		info.mailInfo.focus();
		return;		
	}
	else
	{
		check = true;	
	}
	
	if(!info.mailInfo.value == "")
	{
    	if(!check_email(info.mailInfo.value))
    	{
    		alert("E-MAIL non valida");
    		info.mailInfo.focus();
    		check = false;	
    		return;			
    	}	
	}
	
	if(info.msg.value == "")
	{
		check = false;
		alert("Inserire un messaggio");
		info.msg.focus();
		return;		
	}
	else
	{
			if(inStr(info.msg.value,'http://') > 0)
			{
				alert("Testo messaggio \"http\" non valido.");
				info.msg.focus(); 
				info.msg.select();
				return;				
			}
			else
			{
				check = true;
			}
	}
	
	if(!info.dati.checked)
	{
		check = false;
		alert("Per poter elaborare la sua richiesta è necessario autorizzare il trattamento dei suoi dati personali");
		return;
	}
	else
	{
		check = true;
	}
	
	if(check)
	{
		fSendInfoLoc();
	}
}


function check_email(v)
{
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < v.length ;i++)
	{
		if(ok.indexOf(v.charAt(i))<0)
		{ 
			return (false);
		}	
	} 
	if (document.images)
	{
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!v.match(re) && v.match(re_two))
		{
			return (true);		
		} 

	}
}

function fSendInfoLoc() {
	//var params = Form.serialize($('info'));
	var params = document.getElementById("info").serialize();
	//alert(params);
	//window.open("/lib/info/infoLoc/invio_info.asp?"+params);

	new Ajax.Request('/lib/info/infoLoc/invio_info.asp', {parameters:params,onSuccess:function(requester){$('fInfoLoc').update(requester.responseText);}, onFailure:function(){}} );

}