function Contattaci() {
	if (document.contattaci.nome.value == "")
	{
		alert('Attenzione, inserire il nome');
		return(false);
	}
	if (document.contattaci.cognome.value == "")
	{
		alert('Attenzione, inserire il cognome');
		return(false);
	}
	if (document.contattaci.telefono.value == "")
	{
		alert('Attenzione, inserisci il numero di telefono');
		return(false);
	}
	if (document.contattaci.email.value == "")
	{
		alert('Attenzione, inserire un indirizzo e-mail');
		return(false);
	}
	if (!document.contattaci.autorizzo.checked)
	{
		alert('Attenzione, devi acconsentire al trattamento dei tuoi dati personali');
		return(false);
	}
}

function Registrazione() {

	var mail = document.registrazione.mail.value;
	var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
	if (!espressione.test(mail))
	{
	    //alert("l'adresse mail n'est pas correct");
	    //return(false);
	}
}
function RegistrazioneDati() {
	if (document.registrazione.denominazione.value == '')
	{
		alert('Attenzione, inserisci il tuo nome e cognome');
		return(false);
	}
	
	if (document.registrazione.tel.value == '')
	{
		alert('Attenzione, inserisci almeno un contatto telefonico!');
		return(false);
	}

	if (document.registrazione.password.value == '')
	{
		alert('Attenzione, inserisci la password!');
		return(false);
	}
}

function Mostra(value) {
	tr = document.getElementById(value);

	check = document.getElementById('check_procedi');

	if (check.checked)
	{
		tr.style.display = 'block';
	}
	else
	{
		tr.style.display = 'none';
	}
	
}

function CalcolaRata(importo, rate, spese) {
	importo = importo*1;
	frame = document.getElementById('frame_rata');
	if ((rate != 0) && (importo != '') && (importo != 0) && (rate != '')) {
		frame.src = 'calcola_rata.php?importo='+importo+'&rate='+rate;
	} else {
		frame.src = 'calcola_rata.php';
	}
}

function MostraStockGamma(value) {
	frame = document.getElementById('gamma_stock');
	frame.src = 'gamma_stock.php?marca='+value;
}


function Display(id) {
	div = document.getElementById(id);
	div.style.display = 'block';
}

function Show(value) {
	 tr = document.getElementById('tr_riv')
	 if (value == "2") {
		 tr.style.display = '';
	 } else {
		 tr.style.display = 'none';
	 }
}

function Azzera() {
	input = document.getElementById('importo_rata');
	input.value = '';
	frame = document.getElementById('frame_rata');
	frame.src = 'calcola_rata.php';
}
