// -----------------------------------------------------------------------------
// Funcs.js for Enerjetica; (c) 2006 Dimitri Giani - dimix.it
// -----------------------------------------------------------------------------

// Choose the type of Form
function chooseForm( element ) {
	if (element.value == 1) {
		document.getElementById("form_foto").style.display = "block";
		document.getElementById("form_solare").style.display = "";
	} else {
		document.getElementById("form_solare").style.display = "block";
		document.getElementById("form_foto").style.display = "";
	}
}

// Choose Type for The Solar System
function chooseTipoSolare( element ) {
	if (element.value == 0) {
		document.getElementById("sanitaria").style.display = "block";
		document.getElementById("riscalda").style.display = "";
		document.getElementById("tutti").style.display = "";
	} else if (element.value == 1) {
		document.getElementById("sanitaria").style.display = "";
		document.getElementById("riscalda").style.display = "block";
		document.getElementById("tutti").style.display = "";
	} else if (element.value == 2) {
		document.getElementById("sanitaria").style.display = "";
		document.getElementById("riscalda").style.display = "";
		document.getElementById("tutti").style.display = "block";
	} else {
		document.getElementById("sanitaria").style.display = "";
		document.getElementById("riscalda").style.display = "";
		document.getElementById("tutti").style.display = "";
	}
}

// Choose the Type of ACS
function chooseTipoSistema( element ) {
	if (element.value == 4) {
		document.getElementById("sistem_spec").style.display = "block";
		document.getElementById("dim_boiler").style.display = "";
		
		document.getElementById("bo_dim").disabled = true;
		document.getElementById("sistem_spec").disabled = false;
	} else if (element.value == 2 || element.value == 5) {
		document.getElementById("sistem_spec").style.display = "";
		document.getElementById("dim_boiler").style.display = "block";
		
		document.getElementById("sistem_spec").disabled = true;
		document.getElementById("bo_dim").disabled = false;
	} else {
		document.getElementById("sistem_spec").style.display = "";
		document.getElementById("dim_boiler").style.display = "";
		
		document.getElementById("sistem_spec").disabled = true;
		document.getElementById("bo_dim").disabled = true;
	}
}

// Choose the Specified Type
function chooseSpecTipoSistema( element ) {
	if (element.value == 3) {
		document.getElementById("spec_tipo_luogo").style.display = "block";

	} else {
		document.getElementById("spec_tipo_luogo").style.display = "";
	}
}

// Choose the Specified Type
function chooseSpecTipoSistema2( element ) {
	if (element.value == 3) {
		document.getElementById("spec_tipo_luogo2").style.display = "block";

	} else {
		document.getElementById("spec_tipo_luogo2").style.display = "";
	}
}

// Choose the Specified Type
function chooseSpecTipoSistema3( element ) {
	if (element.value == 3) {
		document.getElementById("spec_tipo_luogo3").style.display = "block";

	} else {
		document.getElementById("spec_tipo_luogo3").style.display = "";
	}
}

// Choose the Specified Type
function chooseSpecTipoSistema4( element ) {
	if (element.value == 3) {
		document.getElementById("spec_tipo_luogo4").style.display = "block";

	} else {
		document.getElementById("spec_tipo_luogo4").style.display = "";
	}
}

// Choose the Type of ACS
function chooseTipoSistema2( element ) {
	if (element.value == 3) {
		document.getElementById("sistem_att_spec").style.display = "block";
		document.getElementById("sistem_att_spec").disabled = false;
	} else {
		document.getElementById("sistem_att_spec").style.display = "";
		document.getElementById("sistem_att_spec").disabled = true;
	}
}

// Choose the Type of diffusion
function chooseTipoDiffusione( element ) {
	if (element.value == 3) {
		document.getElementById("sistem_att_diff_spec").style.display = "block";
		document.getElementById("sistem_att_diff_spec").disabled = false;
	} else {
		document.getElementById("sistem_att_diff_spec").style.display = "";
		document.getElementById("sistem_att_diff_spec").disabled = true;
	}
}

// Choose the Type of ACS - TUTTI -
function chooseTipoSistemaTutti( element ) {
	if (element.value == 4) {
		document.getElementById("tutti_sistem_spec").style.display = "block";
		document.getElementById("tutti_dim_boiler").style.display = "";
		
		document.getElementById("tutti_bo_dim").disabled = true;
		document.getElementById("tutti_sistem_spec").disabled = false;
	} else if (element.value == 2 || element.value == 5) {
		document.getElementById("tutti_sistem_spec").style.display = "";
		document.getElementById("tutti_dim_boiler").style.display = "block";
		
		document.getElementById("tutti_sistem_spec").disabled = true;
		document.getElementById("tutti_bo_dim").disabled = false;
	} else {
		document.getElementById("tutti_sistem_spec").style.display = "";
		document.getElementById("tutti_dim_boiler").style.display = "";
		
		document.getElementById("tutti_sistem_spec").disabled = true;
		document.getElementById("tutti_bo_dim").disabled = true;
	}
}

// Choose the Type of ACS - TUTTI -
function chooseTipoSistema2Tutti( element ) {
	if (element.value == 3) {
		document.getElementById("tutti_sistem_att_spec").style.display = "block";
		document.getElementById("tutti_sistem_att_spec").disabled = false;
	} else {
		document.getElementById("tutti_sistem_att_spec").style.display = "";
		document.getElementById("tutti_sistem_att_spec").disabled = true;
	}
}

// Choose the Type of diffusion - TUTTI -
function chooseTipoDiffusioneTutti( element ) {
	if (element.value == 3) {
		document.getElementById("tutti_sistem_att_diff_spec").style.display = "block";
		document.getElementById("tutti_sistem_att_diff_spec").disabled = false;
	} else {
		document.getElementById("tutti_sistem_att_diff_spec").style.display = "";
		document.getElementById("tutti_sistem_att_diff_spec").disabled = true;
	}
}

function chooseTipoDiffusione( element ) {
	if (element.value == 3) {
		document.getElementById("sistem_att_diff_spec").style.display = "block";
		document.getElementById("sistem_att_diff_spec").disabled = false;
	} else {
		document.getElementById("sistem_att_diff_spec").style.display = "";
		document.getElementById("sistem_att_diff_spec").disabled = true;
	}
}

function chooseTipoStruttura( element ) {
	if (element.value == 7) {
		document.getElementById("tipo_struttura_riscaldare_spec").style.display = "block";
		document.getElementById("tipo_struttura_riscaldare_spec").disabled = false;
	} else {
		document.getElementById("tipo_struttura_riscaldare_spec").style.display = "";
		document.getElementById("tipo_struttura_riscaldare_spec").disabled = true;
	}
}

// Fotovoltaico
function chooseTipoImpianto( element ) {
	if (element.value == 3) {
		document.getElementById("tipo_impianto_spec").style.display = "block";
		document.getElementById("tipo_impianto_spec").disabled = false;
	} else {
		document.getElementById("tipo_impianto_spec").style.display = "";
		document.getElementById("tipo_impianto_spec").disabled = true;
	}
}

// Check the Form for the Send
function check(a) {
	
	err = 0;
	errtxt = "";
	
	switch(a) {
		case 0:
			if (document.form_solare.nome.value == "") { err = 1; errtxt += "- il nome e il cognome\n"; }
			if (document.form_solare.tel.value == "") { err = 1; errtxt += "- il numero di telefono\n"; }
			
			/*
			if (document.form_solare.posta.value == "") { err = 1; errtxt += "- l\'indirizzo di posta elettronica\n"; }
		
			if (document.form_solare.utenti_medi.value == "") { err = 1; errtxt += "- il numero degli utenti medi\n"; }
			if (document.form_solare.elettro_acs.value == "") { err = 1; errtxt += "- il numero degli elettrodomestici\n"; }
			if (document.form_solare.periodo.value == -1) { err = 1; errtxt += "- il periodo di utilizzo\n"; }
			if (document.form_solare.prov.value == -1) { err = 1; errtxt += "- il luogo cartografico\n"; }
			if (document.form_solare.sistem.value == -1) { err = 1; errtxt += "- il sistema attuale di riscaldamento\n"; }
			if (document.form_solare.sistem.value == 2 && document.form_solare.bo_dim.value == "") { err = 1; errtxt += "- la dimensione del boiler\n"; }
			if (document.form_solare.sistem.value == 4 && (document.form_solare.sistem_spec.value == "" || document.form_solare.sistem_spec.value == "specificare qui")) { err = 1; errtxt += "- il tipo di sistema\n"; }
			if (document.form_solare.tipo_luogo.value == "") { err = 1; errtxt += "- il tipo di luogo dove volete installare il sistema\n"; }
			if (document.form_solare.espo.value == -1) { err = 1; errtxt += "- l\'esposizione del luogo\n"; }
			if (document.form_solare.dist.value == "") { err = 1; errtxt += "- la distanza tra i due sistemi\n"; }
			if (document.form_solare.ombra.value == "") { err = 1; errtxt += "- lo spazio in ombra\n"; }
			*/
			if (!document.form_solare.ok4.checked){ err = 1; errtxt += " \nDEVI ACCETTARE LA PRIVACY"; }
			
			break;
			
		case 1:
			if (document.form_solare.nome.value == "") { err = 1; errtxt += "- il nome e il cognome\n"; }
			if (document.form_solare.tel.value == "") { err = 1; errtxt += "- il numero di telefono\n"; }
			
			/*
			if (document.form_solare.posta.value == "") { err = 1; errtxt += "- l\'indirizzo di posta elettronica\n"; }
		
			if (document.form_solare.dim_strutt.value == "") { err = 1; errtxt += "- la dimensione della struttura\n"; }
			if (document.form_solare.num_stanze.value == "") { err = 1; errtxt += "- il numero delle stanze\n"; }
			if (document.form_solare.utenti_medi2.value == "") { err = 1; errtxt += "- il numero degli utenti medi\n"; }
			if (document.form_solare.tipo_strutt.value == "") { err = 1; errtxt += "- il tipo della struttura\n"; }
			if (document.form_solare.sistem_att.value == -1) { err = 1; errtxt += "- il sistema attuale di riscaldamento\n"; }
			if (document.form_solare.sistem_att.value == 4 && (document.form_solare.sistem_att_spec.value == "" || document.form_solare.sistem_att_spec.value == "specificare qui")) { err = 1; errtxt += "- il tipo di sistema attuale di riscaldamento\n"; }
			if (document.form_solare.sistem_att_diff.value == -1) { err = 1; errtxt += "- il sistema attuale di diffusione\n"; }
			if (document.form_solare.sistem_att_diff.value == 3 && (document.form_solare.sistem_att_diff_spec.value == "" || document.form_solare.sistem_att_spec.value == "specificare qui")) { err = 1; errtxt += "- il tipo di sistema attuale di diffusione\n"; }
			if (document.form_solare.periodo2.value == -1) { err = 1; errtxt += "- il periodo di utilizzo\n"; }
			if (document.form_solare.prov2.value == -1) { err = 1; errtxt += "- il luogo cartografico\n"; }
			if (document.form_solare.tipo_luogo2.value == "") { err = 1; errtxt += "- il tipo di luogo dove volete installare il sistema\n"; }
			if (document.form_solare.espo2.value == -1) { err = 1; errtxt += "- l\'esposizione del luogo\n"; }
			if (document.form_solare.dist2.value == "") { err = 1; errtxt += "- la distanza tra i due sistemi\n"; }
			if (document.form_solare.ombra2.value == "") { err = 1; errtxt += "- lo spazio in ombra\n"; }
			*/
			if (!document.form_solare.ok3.checked) { err = 1; errtxt += " \nDEVI ACCETTARE LA PRIVACY"; }
			
			break;
			
		case 2:
			if (document.form_solare.nome.value == "") { err = 1; errtxt += "- il nome e il cognome\n"; }
			if (document.form_solare.tel.value == "") { err = 1; errtxt += "- il numero di telefono\n"; }
			
			/*
			if (document.form_solare.posta.value == "") { err = 1; errtxt += "- l\'indirizzo di posta elettronica\n"; }
			
			if (document.form_solare.tutti_dim_strutt.value == "") { err = 1; errtxt += "- la dimensione della struttura\n"; }
			if (document.form_solare.tutti_num_stanze.value == "") { err = 1; errtxt += "- il numero delle stanze\n"; }
			if (document.form_solare.tutti_utenti_medi.value == "") { err = 1; errtxt += "- il numero degli utenti medi\n"; }
			if (document.form_solare.tutti_elettro_acs.value == "") { err = 1; errtxt += "- il numero degli elettrodomestici\n"; }
			if (document.form_solare.tutti_tipo_strutt.value == "") { err = 1; errtxt += "- il tipo della struttura\n"; }
			
			if (document.form_solare.tutti_sistem.value == -1) { err = 1; errtxt += "- il sistema attuale di riscaldamento\n"; }
			if (document.form_solare.tutti_sistem.value == 2 && document.form_solare.tutti_bo_dim.value == "") { err = 1; errtxt += "- la dimensione del boiler\n"; }
			if (document.form_solare.tutti_sistem.value == 4 && (document.form_solare.tutti_sistem_spec.value == "" || document.form_solare.tutti_sistem_spec.value == "specificare qui")) { err = 1; errtxt += "- il tipo di sistema\n"; }
			
			
			if (document.form_solare.tutti_sistem_att.value == -1) { err = 1; errtxt += "- il sistema attuale di riscaldamento\n"; }
			if (document.form_solare.tutti_sistem_att.value == 4 && (document.form_solare.tutti_sistem_att_spec.value == "" || document.form_solare.tutti_sistem_att_spec.value == "specificare qui")) { err = 1; errtxt += "- il tipo di sistema attuale di riscaldamento\n"; }
			if (document.form_solare.tutti_sistem_att_diff.value == -1) { err = 1; errtxt += "- il sistema attuale di diffusione\n"; }
			if (document.form_solare.tutti_sistem_att_diff.value == 3 && (document.form_solare.tutti_sistem_att_diff_spec.value == "" || document.form_solare.tutti_sistem_att_spec.value == "specificare qui")) { err = 1; errtxt += "- il tipo di sistema attuale di diffusione\n"; }
			
			if (document.form_solare.tutti_periodo.value == -1) { err = 1; errtxt += "- il periodo di utilizzo\n"; }
			if (document.form_solare.tutti_prov.value == -1) { err = 1; errtxt += "- il luogo cartografico\n"; }
			if (document.form_solare.tipo_luogo3.value == "") { err = 1; errtxt += "- il tipo di luogo dove volete installare il sistema\n"; }
			
			if (document.form_solare.tutti_espo.value == -1) { err = 1; errtxt += "- l\'esposizione del luogo\n"; }
			if (document.form_solare.tutti_dist.value == "") { err = 1; errtxt += "- la distanza tra i due sistemi\n"; }
			if (document.form_solare.tutti_ombra.value == "") { err = 1; errtxt += "- lo spazio in ombra\n"; }
			*/
			
			if (!document.form_solare.ok2.checked) { err = 1; errtxt += " \nDEVI ACCETTARE LA PRIVACY"; }
			
			break;
		
		case 3:
			if (document.form_foto.nome.value == "") { err = 1; errtxt += "- il nome e il cognome\n"; }
			if (document.form_foto.tel.value == "") { err = 1; errtxt += "- il numero di telefono\n"; }
			
			/*
			if (document.form_foto.posta.value == "") { err = 1; errtxt += "- l\'indirizzo di posta elettronica\n"; }
			*/
			if (document.form_foto.consumo.value == "") { err = 1; errtxt += "- il consumo energetico\n"; }
			if (document.form_foto.dime.value == "") { err = 1; errtxt += "- la dimensione dello spazio\n"; }
			if (document.form_foto.tipo_spazio.value == "-1") { err = 1; errtxt += "- luogo dove si intendete installare il sistema\n"; }
			if (document.form_foto.dista.value == "") { err = 1; errtxt += "- la distanza tra impianto fotovoltaico e resto dell'impianto elettrico\n"; }
			/*
			if (document.form_foto.spazio.value == "") { err = 1; errtxt += "- lo spazio in ombra\n"; }
			*/
			if (!document.form_foto.ok.checked) { err = 1; errtxt += " \nDEVI ACCETTARE LA PRIVACY"; }
			
			break;
			
		case 4:
			if (document.form.nome.value == "") { err = 1; errtxt += "- il nome e il cognome\n"; }
			if (document.form.posta.value == "") { err = 1; errtxt += "- l\'indirizzo di posta elettronica\n"; }
			if (document.form.ragsoc.value == "") { err = 1; errtxt += "- la ragione sociale\n"; }
			if (document.form.tel.value == "") { err = 1; errtxt += "- il numero di telefono\n"; }
			if (document.form.indirizzo.value == "") { err = 1; errtxt += "- l\'indirizzo postale\n"; }
			if (document.form.rif.value == "") { err = 1; errtxt += "- il nome della persona di riferimento\n"; }
			
			if (!document.form.ok.checked) { err = 1; errtxt += " \nDEVI ACCETTARE LA PRIVACY"; }
			break;
		
		case 5:
			if (document.form.nome.value == "") { err = 1; errtxt += "- il nome e il cognome\n"; }
			if (document.form.posta.value == "") { err = 1; errtxt += "- l\'indirizzo di posta elettronica\n"; }
			if (document.form.tel.value == "") { err = 1; errtxt += "- il numero di telefono\n"; }
			if (document.form.msg.value == "") { err = 1; errtxt += "- il messaggio\n"; }
			
			break;
		
		case 6:
			if (document.form.nome.value == "") { err = 1; errtxt += "- il nome e il cognome\n"; }
			if (document.form.posta.value == "") { err = 1; errtxt += "- l\'indirizzo di posta elettronica\n"; }
			if (document.form.ragsoc.value == "") { err = 1; errtxt += "- la ragione sociale\n"; }
			if (document.form.tel.value == "") { err = 1; errtxt += "- il numero di telefono\n"; }
			if (document.form.indirizzo.value == "") { err = 1; errtxt += "- l\'indirizzo postale\n"; }
			if (document.form.rif.value == "") { err = 1; errtxt += "- il nome della persona di riferimento\n"; }
			
			if (!document.form.ok.checked) { err = 1; errtxt += " \nDEVI ACCETTARE LA PRIVACY"; }
			break;
		
		case 7:
			if (document.form.nome.value == "") { err = 1; errtxt += "- il nome e il cognome\n"; }
			if (document.form.posta.value == "") { err = 1; errtxt += "- l\'indirizzo di posta elettronica\n"; }
			if (document.form.ragsoc.value == "") { err = 1; errtxt += "- la ragione sociale\n"; }
			if (document.form.piva.value == "") { err = 1; errtxt += "- la partita iva\n"; }
			if (document.form.tel.value == "") { err = 1; errtxt += "- il numero di telefono\n"; }
			if (document.form.indirizzo.value == "") { err = 1; errtxt += "- l\'indirizzo postale\n"; }
			if (document.form.rif.value == "") { err = 1; errtxt += "- il nome della persona di riferimento\n"; }
			
			if (!document.form.ok.checked) { err = 1; errtxt += " \nDEVI ACCETTARE LA PRIVACY"; }
			break;
		
	}
	
	if (err) {
		alert("ATTENZIONE!!\n\nDevi inserire:\n"+errtxt);
	} else {
		switch(a) {
			case 0: document.form_solare.type.value = 0; document.form_solare.submit(); break;
			case 1: document.form_solare.type.value = 1; document.form_solare.submit(); break;
			case 2: document.form_solare.type.value = 2; document.form_solare.submit(); break;
			case 3: document.form_foto.type.value = 3; document.form_foto.submit(); break;
			case 4: document.form.type.value = 4; document.form.submit(); break;
			case 5: document.form.submit(); break;
			case 6: document.form.type.value = 6; document.form.submit(); break;
			case 7: document.form.type.value = 7; document.form.submit(); break;
		}
	}
	
}

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 resetAll() {
	for (a = 0; a < 21; a++) {
		dom = document.getElementById("reg_"+a);
		dom.style.display = "";
	}
}

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 = ""; }
}














