function checkContatti() {
	var err = 0;
	var errtxt = "";
	
	if (document.form.name.value == "") { err = 1; errtxt += "- Il Nome e Cognome o la Ragione Sociale\n"; }
	if (document.form.ind.value == "") { err = 1; errtxt += "- La Via/Piazza\n"; }
	if (document.form.citta.value == "") { err = 1; errtxt += "- La citta'\n"; }
	if (document.form.email.value == "") { err = 1; errtxt += "- L\'indirizzo email\n"; }
	if (document.form.tel.value == "") { err = 1; errtxt += "- Il Numero di Telefono\n"; }
	if (document.form.msg.value == "") { err = 1; errtxt += "- La richiesta\n"; }
	if (document.form.security_code.value == "") { err = 1; errtxt += "- Il Codice di Sicurezza\n"; }
	if (!document.form.privacy.checked) { err = 1; errtxt += "- DEVE accettare la privacy\n"; }
	
	if (err) {
		alert("ATTENZIONE!!\n\nDevi inserire almeno:\n"+errtxt);
	} else {
		document.form.submit();
	}
	
}

function checkPromo() {
	var err = 0;
	var errtxt = "";
	
	if (document.form.name.value == "") { err = 1; errtxt += "- Il Nome e Cognome o la Ragione Sociale\n"; }
	if (document.form.ind.value == "") { err = 1; errtxt += "- La Via/Piazza\n"; }
	if (document.form.citta.value == "") { err = 1; errtxt += "- La citta'\n"; }
	if (document.form.email.value == "") { err = 1; errtxt += "- L\'indirizzo email\n"; }
	if (document.form.tel.value == "") { err = 1; errtxt += "- Il Numero di Telefono\n"; }
	if (document.form.promo.value == "") { err = 1; errtxt += "- Il Codice Promozionale\n"; }
	if (document.form.msg.value == "") { err = 1; errtxt += "- La richiesta\n"; }
	if (document.form.security_code.value == "") { err = 1; errtxt += "- Il Codice di Sicurezza\n"; }
	if (!document.form.privacy.checked) { err = 1; errtxt += "- DEVE accettare la privacy\n"; }
	
	if (err) {
		alert("ATTENZIONE!!\n\nDevi inserire almeno:\n"+errtxt);
	} else {
		document.form.submit();
	}
	
}

function check() {
	
	var err = 0;
	var errtxt = "";
	
	if (document.form.name.value == "") { err = 1; errtxt += "- Il Nome e il cognome\n"; }
	if (document.form.ind.value == "") { err = 1; errtxt += "- L\'indirizzo\n"; }
	if (document.form.tel.value == "") { err = 1; errtxt += "- Il numero di Telefono\n"; }
	if (document.form.email.value == "") { err = 1; errtxt += "- L\'indirizzo Email\n"; }
	
	if (document.form.loca.value == "") { err = 1; errtxt += "- La Localita'\n"; }
	if (document.form.prov.value == -1) { err = 1; errtxt += "- La provincia\n"; }
	if (document.form.comune.value == "") { err = 1; errtxt += "- Il Comune di residenza\n"; }
	if (document.form.cap.value == "") { err = 1; errtxt += "- Il CAP\n"; }
	
	if (document.form.d1.value == -1 ||
		(document.form.d1.value == "Esistente Dal") && (document.form.d1_t.value == "")) { err = 1; errtxt += "- Specifica il Periodo di Realizzazione dell'immobile\n"; }
	if (document.form.d2.value == -1) { err = 1; errtxt += "- Specifica il Periodo di utilizzo dell'immobile\n"; }
	if (document.form.d3.value == -1) { err = 1; errtxt += "- Specifica la tipologia dell'immobile\n"; }
	if (document.form.d4.value == "") { err = 1; errtxt += "- Specifica la dimensione dell'immobile\n"; }
	if (document.form.d3.value == -1) { err = 1; errtxt += "- Specifica la dimensione dell'immobile\n"; }
	if (document.form.d5.value == "") { err = 1; errtxt += "- Specifica la struttura dell'immobile, i piani\n"; }
	if (document.form.d5_1.value == "") { err = 1; errtxt += "- Specifica la struttura dell'immobile, i locali\n"; }
	if (document.form.d6.value == -1) { err = 1; errtxt += "- Specifica la tipologia del tetto dell'immobile\n"; }
	if (document.form.d7.value == "") { err = 1; errtxt += "- Specifica lo spazio esposto al sole del tetto\n"; }
	if (document.form.d8.value == "Altro" &&
		document.form.d8_t.value == "") { err = 1; errtxt += "- Specifica se ci sono altri spazi per installare l'impianto\n"; }
		
	if (document.form.d9.value == "") { err = 1; errtxt += "- Specifica il numero di abitanti\n"; }
	if (document.form.d10.value == -1) { err = 1; errtxt += "- Specifica il sistema di produzione dell'acqua calda\n"; }
	if (document.form.d11.value == -1) { err = 1; errtxt += "- Specifica se e' presente un bollitore\n"; }
	if (document.form.d11.value == "Si" &&
		document.form.d11_t.value == "") { err = 1; errtxt += "- Specifica la dimensione del bollitore\n"; }
	if (document.form.d11.value == "Si" &&
		document.form.d11_1_t.value == "") { err = 1; errtxt += "- Specifica L'eta' del bollitore\n"; }
	if (document.form.d12.value == "") { err = 1; errtxt += "- Specifica la temperatura media\n"; }
	if (document.form.d13.value == -1) { err = 1; errtxt += "- Specifica il dispositivo per il riscaldamento degli ambienti\n"; }
	if (document.form.d14.value == -1) { err = 1; errtxt += "- Specifica il tipo di combustibile\n"; }
	if (document.form.d14.value == "Altro" &&
		document.form.d14_t.value == "") { err = 1; errtxt += "- Specifica il tipo di combustibile\n"; }
	if (document.form.d15.value == -1) { err = 1; errtxt += "- Specifica la tipologia di diffusione termica\n"; }
	if (document.form.d16.value == "") { err = 1; errtxt += "- Specifica la quantita' di combustibile consumata\n"; }
	if (document.form.d17.value == -1) { err = 1; errtxt += "- Specifica il costo del combustibile\n"; }
	if (document.form.d18.value == -1) { err = 1; errtxt += "- Specifica il costo della bolletta elettrica\n"; }
	if (document.form.d19.value == -1) { err = 1; errtxt += "- Specifica gli altri costi energetici\n"; }
	if (document.form.d20.value == -1) { err = 1; errtxt += "- Specifica l'agevolazione economica\n"; }
	if (document.form.d20.value == "Altro" &&
		document.form.d20_t.value == "") { err = 1; errtxt += "- Specifica l'agevolazione economica\n"; }
	if (document.form.d21.value == -1) { err = 1; errtxt += "- Specifica se vuole una rateizzazione\n"; }
	
	if (!document.form.privacy.checked) { err = 1; errtxt += "- DEVE accettare la privacy\n"; }
	
	if (document.form.security_code.value == "") { err = 1; errtxt += "- Inserire il Codice di Sicurezza\n"; }
	
	if (err) {
		alert("ATTENZIONE!!\n\nDevi inserire almeno:\n"+errtxt);
	} else {
		document.form.submit();
	}
	
}

// Controlli del Form Progetto su Misura

function change(elm, id, v) {
	var value = elm.options[elm.selectedIndex].value;
	if (value == v) { document.getElementById(id).style.visibility = "visible"; }
	else { document.getElementById(id).style.visibility = "hidden"; }
}

function changeDouble(elm, id, id2, v) {
	var value = elm.options[elm.selectedIndex].value;
	if (value == v) {
		document.getElementById(id).style.visibility = "visible";
		document.getElementById(id2).style.visibility = "visible";
	}
	else {
		document.getElementById(id).style.visibility = "hidden";
		document.getElementById(id2).style.visibility = "hidden";
	}
}

function writeText(text) {
	var element = document.getElementById("theText");
	var theP = document.createElement("p");
	
	theP.setAttribute("id", "theP");
	
	var newText = document.createTextNode(text);
	element.appendChild(theP);
	theP.appendChild(newText);
	
}

function deleteText() {
	var element = document.getElementById("theText");
	var theP = document.getElementById("theP");
	element.removeChild(theP);
}

function show(element) {
	resetAll();

	dom = document.getElementById(element);
	
	if (dom.style.display == "") { dom.style.display = "block"; }
	else if (dom.style.display == "block") { dom.style.display = ""; }
}

function resetAll() {
	for (a = 0; a < 21; a++) {
		dom = document.getElementById("reg_"+a);
		dom.style.display = "";
	}
}

function map() {
	var win = window.open("mappa.php", "Mappa", "width=510,height=510,scrollbars=no,toolbar=no,statusbar=no");
}