// Sovrascrive funzione in common_template.js
function onLoadFunction()
{
	// get the querystring 
	queryString = window.top.location.search.substring(1);
	
	if (queryString!=null && queryString.length > 0)
	{
		type = getParameterFromQueryString(queryString, "type");
		solution = getParameterFromQueryString(queryString, "solution");
		
		// Pagina presentazione soluzioni
		index=0;
	 	if (type!="null" && type.length > 0)
	 	{
			if (type=="comfort")
			{
				index=1;
			}
			else if (type=="sicurezza")
			{
				index=2;
			}
			else if (type=="comunicazione")
			{
				index=4;
			}
			else if (type=="controllo")
			{
				index=5;
			}
			else if (type=="risparmio")
			{
				index=3;
			}
	 		
			for (i=1; i<=5; i++)
			{
				if (index==i)
				{
					document.getElementById("menu_" + i).style.display="inline";
				}
				else
				{
				  document.getElementById("menu_" + i).style.display="none";
				}	
			}
	 	}
	 	
	 	// Pagina approfondimenti soluzioni
		indexSol=0;
	 	if (solution!="null" && solution.length > 0)
	 	{
			if (solution=="illuminazione" || solution=="automazione" || solution=="suono")
			{
				/*k=0;
				exitLoop=false;
				while (k<document.soluzioniApprofondimentiForm.comfortSelect.options.length && !exitLoop)
				{
					if (document.soluzioniApprofondimentiForm.comfortSelect.options[k].value==solution)
					{
						document.soluzioniApprofondimentiForm.comfortSelect.options[k].selected=true;
						exitLoop=true;
					}
					k++;
				}*/
				indexSol=1;
			}
			else if (solution=="antifurto" || solution=="videocontrollo" || solution=="allarmi" || solution=="telesoccorso")
			{
				/*k=0;
				exitLoop=false;
				while (k<document.soluzioniApprofondimentiForm.sicurezzaSelect.options.length && !exitLoop)
				{
					if (document.soluzioniApprofondimentiForm.sicurezzaSelect.options[k].value==solution)
					{
						document.soluzioniApprofondimentiForm.sicurezzaSelect.options[k].selected=true;
						exitLoop=true;
					}
					k++;
				}*/
				indexSol=2;
			}
			else if (solution=="gestione energia" || solution=="termoregolazione")
			{
				/*k=0;
				exitLoop=false;
				while (k<document.soluzioniApprofondimentiForm.risparmioSelect.options.length && !exitLoop)
				{
					if (document.soluzioniApprofondimentiForm.risparmioSelect.options[k].value==solution)
					{
						document.soluzioniApprofondimentiForm.risparmioSelect.options[k].selected=true;
						exitLoop=true;
					}
					k++;
				}*/	
				indexSol=3;
			}
			else if (solution=="audio e video" || solution=="rete dati e segnali")
			{
				/*k=0;
				exitLoop=false;
				while (k<document.soluzioniApprofondimentiForm.comunicazioneSelect.options.length && !exitLoop)
				{
					if (document.soluzioniApprofondimentiForm.comunicazioneSelect.options[k].value==solution)
					{
						document.soluzioniApprofondimentiForm.comunicazioneSelect.options[k].selected=true;
						exitLoop=true;
					}
					k++;
				}*/
				indexSol=4;
			}
			else if (solution=="controllo locale" || solution=="controllo remoto")
			{
				/*k=0;
				exitLoop=false;
				while (k<document.soluzioniApprofondimentiForm.controlloSelect.options.length && !exitLoop)
				{
					if (document.soluzioniApprofondimentiForm.controlloSelect.options[k].value==solution)
					{
						document.soluzioniApprofondimentiForm.controlloSelect.options[k].selected=true;
						exitLoop=true;
					}
					k++;
				}*/
				indexSol=5;
			}
			for (i=1; i<=5; i++)
			{
				if (indexSol==i)
				{
					document.getElementById("menu_" + i).style.display="inline";
				}
				else
				{
				  	document.getElementById("menu_" + i).style.display="none";
				}	
			}
	 	}
	}
}

function submitSolutionTypeInfo(formName, type)
{
	if (type=="comfort")
	{
		document.forms[formName].typePath.value = escape("/html/soluzioni_comfort.html");
	}
	else if (type=="sicurezza")
	{
		document.forms[formName].typePath.value = escape("/html/soluzioni_sicurezza.html");
	}
	else if (type=="comunicazione")
	{
		document.forms[formName].typePath.value = escape("/html/soluzioni_comunicazione.html");
	}
	else if (type=="controllo")
	{
		document.forms[formName].typePath.value = escape("/html/soluzioni_controllo.html");
	}
	else if (type=="risparmio")
	{
		document.forms[formName].typePath.value = escape("/html/soluzioni_risparmio.html");
	}

	// invio form
	document.forms[formName].action = "soluzioni_intro.page?type=" + escape(type) + "&activepage=/web/presentazione_soluzioni.page";
	document.forms[formName].method="POST";
	document.forms[formName].submit();
}

function submitSolutionInfo(formName, solution)
{
	if (solution=="illuminazione")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_illuminazione.html");
	}
	else if (solution=="automazione")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_automazione.html");
	}
	else if (solution=="suono")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_suono.html");
	}
	else if (solution=="antifurto")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_antifurto.html");
	}
	else if (solution=="videocontrollo")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_videocontrollo.html");
	}
	else if (solution=="allarmi")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_allarmi.html");
	}
	else if (solution=="telesoccorso")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_telesoccorso.html");
	}
	else if (solution=="gestione energia")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_gestioneenergia.html");
	}
	else if (solution=="termoregolazione")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_termoregolazione.html");
	}
	else if (solution=="audio e video")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_audioevideo.html");
	}
	else if (solution=="rete dati e segnali")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_retedatiesegnali.html");
	}
	else if (solution=="controllo locale")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_controllolocale.html");
	}
	else if (solution=="controllo remoto")
	{
		document.forms[formName].solutionPath.value = escape("/html/soluzioni_controlloremoto.html");
	}
	
	// invio form
	document.forms[formName].action = "soluzioni_approfondimenti.page?solution=" + escape(solution) + "&activepage=/web/presentazione_soluzioni.page";
	document.forms[formName].method="POST";
	document.forms[formName].submit();
}
