function contatta()
{
	var nomecognome = document.getElementById("nomecognome").value.trim();
	var indi = document.getElementById("indi").value.trim();
	var msg = document.getElementById("msg").value.trim();
	var infor = document.getElementById("informativa").checked;
	if(nomecognome == "")
	{
		alert("Nome e Cognome obbligatorio");
		document.getElementById("nomecognome").focus();
		return;
	}
	if(indi == "")
	{
		alert("Indirizzo mail Obbligatorio");
		document.getElementById("indi").focus();
		return;
	}
	else if(!isEmail(indi))
	{
		alert("Indirizzo mail non valido");
		document.getElementById("indi").focus();
		return;
	}
	if(msg == "")
	{
		alert("Messaggio bbligatorio");
		document.getElementById("msg").focus();
		return;
	}
	if(!infor)
	{
		alert("Accettare infromattiva per poter spedire il messaggio");
		document.getElementById("informativa").focus();
		return;	
	}
	document.getElementById("form1").submit();

}
function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) != -1)
	return 1;
	else
	return 0;
}
String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}


function updMarc()
{
	var prov =  $("prov").value;
	var marc =  $("marc").value;

	if(prov != "")
	{

		new Ajax.Request('getAjax', { method:'post', parameters: {tipo: 'marc', prov: prov},
		onSuccess: function(transport){
		var response = transport.responseText;
		if(response != "")
		{
			$("marc").options.length = 0;
			var json = transport.responseText.evalJSON();
			var opt = document.createElement('option');
			opt.text = "Seleziona Marchio";
			opt.value = "";
			$("marc").options.add(opt);
			json.each(function(item) {
		       var opt = document.createElement('option');
               opt.text = item["V"];
               opt.value = item["K"];
               $("marc").options.add(opt);
			});
			$("marc").value = marc;
		}
		else
		{
		       var opt = document.createElement('option');
               opt.text = "Nessun Marc.";
               opt.value = "-1";
               $("marc").options.add(opt);
		}

		updLoc();


		},
		onFailure: function(){ alert('Errore aggiornamento') }

		  });

	}



}
function updLoc()
{
	var prov =  $("prov").value;
	var marc =  $("marc").value;
	if(prov != "" && marc != "")
	{

		new Ajax.Request('getAjax', { method:'post', parameters: {tipo: 'loc', prov: prov, marc: marc},
		onSuccess: function(transport){
		var response = transport.responseText;
		$("loc").options.length = 0;
		if(response != "")
		{
			var json = transport.responseText.evalJSON();

			var opt = document.createElement('option');
			opt.text = "Seleziona Loc.";
			opt.value = "";

			$("loc").options.add(opt);
			json.each(function(item) {
		       var opt = document.createElement('option');
               opt.text = item["L"];
               opt.value = item["L"];
               $("loc").options.add(opt);
			});

		}
		else
		{
		       var opt = document.createElement('option');
               opt.text = "Nessun Loc.";
               opt.value = "-1";
               $("loc").options.add(opt);
		}



		},
		onFailure: function(){ alert('Errore aggiornamento') }

		  });

	}
	else
	{
	   $("loc").options.length = 0;
	   var opt = document.createElement('option');
	   opt.text = "Seleziona Loc.";
	   opt.value = "";
	   $("loc").options.add(opt);
	}
}
function cercaMarc()
{
	var prov =  $("prov").value;
	if(prov == "")
	{
		alert("Selezionare provincia");
		return;
	}
	var marc =  $("marc").value;
	if(marc == "")
	{
		alert("Selezionare marchio");
		return;
	}
	var loc =  $("loc").value;
	if(loc == "-1")
	{
		alert("Marchio non presente nella provincia selezionata");
		return;
	}
	$('formMarc').submit();
}
