
//***************
// createOverlayLayer()
// Raffaele Sgherri - Avanade Italy
// 19/11/2002
//***************
//
//Crea un layer trasparente grande quanto tutta la pagina e lo inserisce nella pagina HTML
//Con questo layer visibile si disattiva l'accesso ad ogni elemento della pagina stessa (drop-down escluse)
//

var IsChkIncendioFurtoChanged = false;

function createOverlayLayer()
{
	var nL;
	var left = 1;
	var top = 1;
	var name = "overlay";
	var html = "";

	var width = document.body.scrollWidth - 2;
	var height = document.body.scrollHeight - 2;
	var divhtml = '<div  id=' + name + ' style="z-index:999;visibility:visible;left:' + left +
		'px;top:' + top + 'px;width:' + width +
		'px;height:' + height + 'px;position:absolute; background: url(/eSIGIppPortale/Imgs/eSIGI-transoverlay.gif) repeat">' +
		html + '</div>';
	document.body.insertAdjacentHTML('beforeEnd', divhtml);
	nL = document.all[name].style;

	return nL;
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+'.'+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + ',' + cents + ' ' + '&euro; ');
}
//  End -->

//***************
// DisableAll()
// Raffaele Sgherri - Avanade Italy
// 19/11/2002
//***************
//
// mette la clessidra su tutti i controlli della pagina
function DisableAll()
{
	document.body.style.cursor = "wait";
	for (var i= 0; i < document.all.length ;i++)
	{
		sTagName =  document.all.item(i).tagName;
		if (sTagName == "INPUT" || sTagName == "SELECT" || sTagName == "TEXTAREA")
		document.all.item(i).style.cursor = 'wait';		
	}

	// Disabilita i controlli inserendo un layer trasparente sopra tutta la pagina
	// NOTA: non vengono disabilitate le drop-down (in IE) a causa di un baco conosciuto
	var layer;	
	if (!layer)
	{	
		layer = createOverlayLayer();
	}
	
	return true;	
}

function goBack()
{
	history.go(-1);
}//




function emptySelect( ddlToEmpty)
{// Empty the drop down list of any choices
	if(null==ddlToEmpty)
	{
		return;
	}
	if(null==ddlToEmpty.options)
	{
		return;
	}
	for ( var q=ddlToEmpty.options.length; q>=0; q--)
	{
		ddlToEmpty.options[q]=null;		
	}
	if(null!=ddlToEmpty.style)
	{
		if(null!=ddlToEmpty.style.visibility)
		{
			ddlToEmpty.style.visibility = "hidden";
		}
	}
}//

function emptyTxt( txtToEmpty)
{// Empty the textBox
	var txtControl = document.getElementById( txtToEmpty.id);
	if(null==txtControl)
	{
		return;
	}
	if(null==txtControl.value)
	{
		return;
	}
	txtControl.value = "";
}// END function emptyTxt

function hideFamiglia()
{
	if( document.getElementById( 'ddlFamiglia').value =="NO"){
		document.getElementById('divCodCli').style.display='none';
	}
	else
	{
		document.getElementById('divCodCli').style.display='inline';
	}
}
function hideControl(controlToHide)
{  	if(null==controlToHide) return;
		 controlToHide.innerText="";
		 controlToHide.style.display = "none";
}

function hideControlById(controlToHideId)
{  	
	var controlToHide = document.getElementById(controlToHideId);
	if(null==controlToHide) return;
		 controlToHide.style.display = "none";
}

function showPremioFrazionato(ctrlDdlFraz)
{  	
	//alert(document.getElementById("lblvPremioAnnualeLordo").innerHTML);
	if (document.getElementById("lblvPremioAnnualeLordo").innerHTML!=""){
			document.getElementById("lblvRCA").innerHTML=formatCurrency(parseFloat(document.getElementById('txtRCA').value.replace('.','').replace(',','.')));
			if (document.getElementById("lblvIncendioFurto")!=null)document.getElementById("lblvIncendioFurto").innerHTML=formatCurrency(parseFloat(document.getElementById('txtIncendioFurto').value.replace('.','').replace(',','.')));
			if (document.getElementById("lblvComplementareARD")!=null)document.getElementById("lblvComplementareARD").innerHTML=formatCurrency(parseFloat(document.getElementById('txtComplementareARD').value.replace('.','').replace(',','.')));
			if (document.getElementById("lblvEventiSocio")!=null)document.getElementById("lblvEventiSocio").innerHTML=formatCurrency(parseFloat(document.getElementById('txtEventiSocio').value.replace('.','').replace(',','.')));
			if (document.getElementById("lblvEventiNaturali")!=null)document.getElementById("lblvEventiNaturali").innerHTML=formatCurrency(parseFloat(document.getElementById('txtEventiNaturali').value.replace('.','').replace(',','.')));
			if (document.getElementById("lblvInfortuniConducente")!=null)document.getElementById("lblvInfortuniConducente").innerHTML=formatCurrency(parseFloat(document.getElementById('txtInfortuniConducente').value.replace('.','').replace(',','.')));
			if (document.getElementById("lblvAssistenza")!=null)document.getElementById("lblvAssistenza").innerHTML=formatCurrency(parseFloat(document.getElementById('txtAssistenza').value.replace('.','').replace(',','.')));
			if (document.getElementById("lblvTutelaGiudiziaria")!=null)document.getElementById("lblvTutelaGiudiziaria").innerHTML=formatCurrency(parseFloat(document.getElementById('txtTutelaGiudiziaria').value.replace('.','').replace(',','.')));
			if (document.getElementById("lblvRitiroPatente")!=null)document.getElementById("lblvRitiroPatente").innerHTML=formatCurrency(parseFloat(document.getElementById('txtRitiroPatente').value.replace('.','').replace(',','.')));
			if (document.getElementById("lblvParziale")!=null)document.getElementById("lblvParziale").innerHTML=formatCurrency(parseFloat(document.getElementById('txtKaskoParziale').value.replace('.','').replace(',','.')));
			if (document.getElementById("lblvKaskoCompleta")!=null)document.getElementById("lblvKaskoCompleta").innerHTML=formatCurrency(parseFloat(document.getElementById('txtKaskoCompleta').value.replace('.','').replace(',','.')));

			document.getElementById("lblvPremioAnnualeLordo").innerHTML=formatCurrency(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML.replace(',','.'));
			if (document.getElementById("lblvPremioAnnualeLordoSconto")!=null)document.getElementById("lblvPremioAnnualeLordoSconto").innerHTML=formatCurrency(document.getElementById('lblvPremioAnnualeLordoScontoValue').innerHTML.replace(',','.'));
	}
}

function showCalcola(controlToShowId,controlToHideId)
{  	
	var controlToShow = document.getElementById(controlToShowId);
	var controlToHide = document.getElementById(controlToHideId);
	/*Modifica by luca passaro*/
	/*if(null==controlToShow) return;
	if(null==controlToHide) return;
	if(null==controlToHide2) return;*/
	if(null!=controlToShow)
		controlToShow.style.display = "block";
	if(null!=controlToHide)
		controlToHide.style.display = "none";

	if(window.document.getElementById("TipoBene")!=null)
	{
		if(window.document.getElementById("lblvPremioAnnualeLordo")!=null)
				window.document.getElementById("lblvPremioAnnualeLordo").innerHTML = "";	
		if(window.document.getElementById("lblvPremioAnnualeLordoValue")!=null)
				window.document.getElementById("lblvPremioAnnualeLordoValue").innerHTML = "";	
		if(window.document.getElementById("lblvPremioAnnualeLordoSconto")!=null)
			window.document.getElementById("lblvPremioAnnualeLordoSconto").innerHTML = "";	
		if(window.document.getElementById("lblvPremioAnnualeLordoScontoValue")!=null)
			window.document.getElementById("lblvPremioAnnualeLordoScontoValue").innerHTML = "";
		if(window.document.getElementById("lblvRataSemLorda")!=null)
			window.document.getElementById("lblvRataSemLorda").innerHTML = "";	
		//manageTotali();
	}
	ResetGaranzie();
	/*fine Modifica by luca passaro*/
}
function hideCalcola(controlToShowId,controlToHideId,controlToHideId2)
{  	
	
	var controlToShow = document.getElementById(controlToShowId);
	var controlToHide = document.getElementById(controlToHideId);
	var controlToHide2 = document.getElementById(controlToHideId2);
	/*Modifica by luca passaro*/
	/*if(null==controlToShow) return;
	if(null==controlToHide) return;
	if(null==controlToHide2) return;*/
	if(null!=controlToShow)
		controlToShow.style.display = "none";
	if(null!=controlToHide)
		controlToHide.style.display = "block";
	if(null!=controlToHide2)
		controlToHide2.style.display = "block";
	/*fine Modifica by luca passaro*/
}
function calculateAllMoto(){
	calculateSumHp1(document.getElementById('chkRCA'),'txtRCA','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkAssistenza'),'txtAssistenza','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkIncendioFurto'),'txtIncendioFurto','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkTutelaGiud'),'txtTutelaGiudiziaria','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	//var TassoSemestrale = window.document.getElementById("HdnTassoSem").value;
	//document.getElementById('lblvRataSemLorda').innerHTML = formatCurrency(parseFloat(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML) * TassoSemestrale / 100);
	//showPremioFrazionato(document.getElementById('ddlFrazionamento'));	 	
	checkSemestralita();

}

function saveState(){
	var allCheck = document.getElementsByTagName('input');
	var blAlert=true;
	document.getElementById('txtSalvaGaranzie').value="";
	for (i=0;i<allCheck.length;i++){
		if (allCheck[i].id.indexOf('chk')>=0){
			if (allCheck[i].checked){
				document.getElementById('txtSalvaGaranzie').value=document.getElementById('txtSalvaGaranzie').value + allCheck[i].id +"#";
			}
		}
	}
}

function loadState(){
	var allCheck = document.getElementsByTagName('input');
	var arrCheck=document.getElementById('txtSalvaGaranzie').value.split('#');
	/*modifica luca: toppa per sistemare il baco delle garanzie kaskoparziale e kaskocompleta quando sono selezionate entrambe*/
	
	if(document.getElementById("chkKaskoCompleta")!=null)
	{
		if((document.getElementById("chkKaskoParziale").checked)&&(document.getElementById("chkKaskoCompleta").checked))
		{
				for (i=0;i<arrCheck.length-1;i++)
				{
					if(arrCheck[i].id == "chkKaskoParziale")
					{	
						//elimina completa
						document.getElementById("chkKaskoCompleta").checked = false;
					}
					else if (arrCheck[i].id == "chkKaskoCompleta")
					{	
						//elimina parziale
						document.getElementById("chkKaskoParziale").checked = false;
					}
				}
		}
	}
	/*fine modifica*/
	for (i=0;i<arrCheck.length-1;i++){
		try{
		if (allCheck[i].id.indexOf('chk')>=0 && !document.getElementById(arrCheck[i]).disabled) {
			document.getElementById(arrCheck[i]).checked=true;
		}
		}catch(ex){}
	}
}

function DisableAllCheck()
{	
	var allCheck = document.getElementsByTagName('input');
	for (i=0;i<allCheck.length;i++){
		if (allCheck[i].id.indexOf('chk')>=0){
			allCheck[i].checked=false;
			/*if(item.id == "chkIncendioFurto")
			{
				IsChkIncendioFurtoChanged = true;
			}*/
		}
	}
}

/*INIZIO GESTIONE CALCOLO PREMIO BY LUCA PASSARO*/

/*vine chiamata ad ogni click sulla singola garanzia*/
function HighlightRowAuto(item,target,bluKasko)
{
	
	var profilo = null;
	if(window.document.getElementById("HdnProfilo")!=null)
	{
		profilo = window.document.getElementById("HdnProfilo").value;
	}
	
	if(item.checked)
	{
		window.document.getElementById(target).className = "campoPr bgOn";
	}
	else
	{
		window.document.getElementById(target).className = "campoPr bgOff";
	}
	CheckIfPackage() 
	/****************************************************************/
	if(window.document.getElementById("chkKaskoCompleta")!=null)
	{
		if(item.id == "chkKaskoCompleta")
		{
			if(item.checked)
			{
				window.document.getElementById(target).className = "campoPr bgOn";
				window.document.getElementById("row_KaskoParziale").className = "campoPr bgOff";
				//window.document.getElementById("chkKaskoParziale").checked = false;
			}
			else
			{
				window.document.getElementById(target).className ="campoPr bgOff";
			}			
		}
		else if(item.id == "chkKaskoParziale")
		{
			if(item.checked)
			{
				window.document.getElementById(target).className = "campoPr bgOn";;
				window.document.getElementById("row_KaskoCompleta").className = "campoPr bgOff";;
				//window.document.getElementById("chkKaskoCompleta").checked = false;
			}
			else
			{
				window.document.getElementById(target).className = "campoPr bgOff";
			}
			
		}
	}
	/****************************************************************/ 
	if(!bluKasko && (item.id == "chkIncendioFurto" || item.id == "chkKaskoParziale"  || item.id == "chkKaskoCompleta"))
	{
		if(!item.checked)
			{
				window.document.getElementById("row_Complementare").className= "campoPr bgOff";
				window.document.getElementById("row_SocioPolitici").className= "campoPr bgOff";
			}
		
		ResetGaranziePremiByIF();
		showCalcola('pnlCalcola','pnlSalva');

	}
	SetMarketingMessages();
	saveState();
}

function HighlightRow(item,target)
{
		if(item.checked)
		{
			window.document.getElementById(target).className = "campoPr bgOn";
		}
		else
		{
			window.document.getElementById(target).className = "campoPr bgOff";
		}
		
		var ischkRCA
		var ischkIncFabbricatoAb
		var ischkIncContenutoAb
		var ischkRicorsoTerziAb
		var ischkAssistenza
		var ischkFurtoContenuto
		var ischkIncContenutoSa
		var ischkTutelaGiud
		
		ischkRCA = window.document.getElementById("chkRCA");
		if (window.document.getElementById("chkIncFabbricatoAb")!=null)
			ischkIncFabbricatoAb = window.document.getElementById("chkIncFabbricatoAb").checked;
		if (window.document.getElementById("chkIncContenutoAb")!=null)
			ischkIncContenutoAb = window.document.getElementById("chkIncContenutoAb").checked;
		if (window.document.getElementById("chkRicorsoTerziAb")!=null)
			ischkRicorsoTerziAb = window.document.getElementById("chkRicorsoTerziAb").checked;
		if (window.document.getElementById("chkAssistenza")!=null)
			ischkAssistenza = window.document.getElementById("chkAssistenza").checked;
		if (window.document.getElementById("chkFurtoContenuto")!=null)
			ischkFurtoContenuto = window.document.getElementById("chkFurtoContenuto").checked;
		if (window.document.getElementById("chkIncContenutoSa")!=null)
			ischkIncContenutoSa = window.document.getElementById("chkIncContenutoSa").checked;
		if (window.document.getElementById("chkTutelaGiud")!=null)
			ischkTutelaGiud = window.document.getElementById("chkTutelaGiud").checked;
			
		resetHighlightPackage("Plus");
		
		/*BASE*/
		if (window.document.getElementById("PackageBase") != null){
			resetHighlightPackage("Base");
			if((ischkRCA)&&(ischkIncFabbricatoAb)&&(ischkIncContenutoAb))
			{
				highlightPackage("Base");
			}
		}
		/*TOP*/
		if (window.document.getElementById("PackageTop") != null){
			resetHighlightPackage("Top");
			if((ischkRCA)&&(ischkIncFabbricatoAb)&&(ischkIncContenutoAb)&&(ischkAssistenza)&&(ischkFurtoContenuto))
			{	
				resetHighlightPackage("Base");
				resetHighlightPackage("Plus");
				highlightPackage("Top");
			}
		}
			
		/*PLUS*/
		if((ischkRCA)&&(ischkIncFabbricatoAb)&&(ischkIncContenutoAb)&&(ischkAssistenza)
		||(ischkRCA)&&(ischkAssistenza)&&(ischkTutelaGiud))
		{
			if (window.document.getElementById("PackageBase") != null)
				resetHighlightPackage("Base");
			highlightPackage("Plus");
		}
		if(window.document.getElementById("chkRicorsoAb")!=null){
 		if(window.document.getElementById("chkRicorsoAb").checked == true && 
	   (window.document.getElementById("txtRicorsoAbValue").value=="0" ||
	   window.document.getElementById("txtRicorsoAbValue").value==""))
 		{
 			window.document.getElementById("txtRicorsoAbValue").value = "100000";
 		}
 		}
}

function ResetGaranziePremiByIF()
{
	ResetGaranzie();				
	/*Resetto i premi semestrale e annuale*/
/*	window.document.getElementById("lblvPremioAnnualeLordoSconto").innerHTML = "";	
	window.document.getElementById("lblvPremioAnnualeLordoScontoValue").innerText = "0";
	window.document.getElementById("lblvRataSemLorda").innerHTML = "";		*/
	IsChkIncendioFurtoChanged = true;
}
function CheckIfPackage()
{
	var profilo = null;
	if(window.document.getElementById("HdnProfilo")!=null)
	{
		profilo = window.document.getElementById("HdnProfilo").value;
	}
	
	if(profilo!=null)
	{
		if((profilo=="T1")||(profilo=="T6")||(profilo=="T7")||(profilo=="T3")||(profilo=="T4")||(profilo=="T5"))
		{
			resetHighlightPackage("Base");
			resetHighlightPackage("Plus");
			resetHighlightPackage("Top");
			
			chkRCA = window.document.getElementById("chkRCA");
			chkAssistenza = window.document.getElementById("chkAssistenza");
			chkInfortuniConducente = window.document.getElementById("chkInfortuniConducente");
			chkIncendioFurto = window.document.getElementById("chkIncendioFurto");
			chkKaskoParziale = window.document.getElementById("chkKaskoParziale");
			
			/*BASE*/
			if((chkRCA.checked == true)&&(chkAssistenza.checked == true)&&(chkInfortuniConducente.checked == true))
			{
				highlightPackage("Base");
			}	
			/*PLUS*/
			if((chkRCA.checked == true)&&(chkIncendioFurto.checked == true)&&(chkInfortuniConducente.checked == true))
			{
				resetHighlightPackage("Base");
				highlightPackage("Plus");
			}
			/*TOP*/
 			if((chkRCA.checked == true)&&(chkInfortuniConducente.checked == true)&&(chkAssistenza.checked == true)&&(chkKaskoParziale.checked == true))
			{	
				resetHighlightPackage("Base");
				resetHighlightPackage("Plus");
				highlightPackage("Top");
			}
			CheckHighlights();	
		}
		else 
		{
			/*if(window.document.getElementById("chkRCA").checked==true)
			{
				window.document.getElementById("row_RCA_1").className 		= "TxtInTableCelesteHL";
				window.document.getElementById("row_RCA_2").className 		= "TxtInTableCelesteHL";
			 	
			 	window.document.getElementById("row_TipoGuida").className 		= "TxtInTableCelesteHL";
				window.document.getElementById("row_TipoGuida_2").className 		= "TxtInTableCelesteHL";
			 
				window.document.getElementById("row_Massimale").className 		= "TxtInTableCelesteHL";
				window.document.getElementById("row_Massimale_2").className 		= "TxtInTableCelesteHL";
			}
			else
			{
				window.document.getElementById("row_RCA_1").className 		= "TxtInTableCelesteHL";
				window.document.getElementById("row_RCA_2").className 		= "TxtInTableCelesteHL";
			 	
			 	window.document.getElementById("row_TipoGuida").className 		= "TxtInTableCelesteHL";
				window.document.getElementById("row_TipoGuida_2").className 		= "TxtInTableCelesteHL";
			 
				window.document.getElementById("row_Massimale").className 		= "TxtInTableCelesteHL";
				window.document.getElementById("row_Massimale_2").className 		= "TxtInTableCelesteHL";
			}*/
			if(window.document.getElementById("chkAssistenza").checked==true)
			{
				window.document.getElementById("row_Assistenza").className 	= "campoPr bgOn";
			}
			if(window.document.getElementById("chkTutelaGiud").checked==true)
			{
				window.document.getElementById("row_Tutela").className 	= "campoPr bgOn";
			}
			
		}
	}
}

function highlightPackage(pkgId){
		window.document.getElementById("Package" + pkgId).className = "boxC170b";
		if (pkgId!="Base")window.document.getElementById("TopPackage" + pkgId).className="top170b";
		window.document.getElementById("BottomPackage" + pkgId).className="bottom170b";
		window.document.getElementById("imgPackage" + pkgId).src="presentation/image/btn_applica_2.gif";
}
function resetHighlightPackage(pkgId){
		window.document.getElementById("Package" + pkgId).className = "boxC170";
		if (pkgId!="Base")window.document.getElementById("TopPackage" + pkgId).className="top170";
		window.document.getElementById("BottomPackage" + pkgId).className="bottom170";
		window.document.getElementById("imgPackage" + pkgId).src="presentation/image/btn_applica_1.gif";
}

function SetMarketingMessages()
{
		var profilo = null;
		if(window.document.getElementById("HdnProfilo")!=null)
		{
			profilo = window.document.getElementById("HdnProfilo").value;
		}
		if (profilo !="T2" && document.getElementById("divScontoRCA")!=null){
		//LORIS REBRANDING
		document.getElementById("divScontoRCA").style.display = "none";
		document.getElementById("divScontoRCAIF").style.display = "none";
		document.getElementById("divScontoRCAFam").style.display = "none";
		document.getElementById("divScontoRCAIFFam").style.display = "none";
		document.getElementById("divScontoCONV").style.display = "none";
		document.getElementById("divScontoRCASem").style.display = "none";
		document.getElementById("divScontoRCAIFSem").style.display = "none";
		document.getElementById("divScontoRCAFamSem").style.display = "none";
		document.getElementById("divScontoRCAIFFamSem").style.display = "none";
		
		if(window.document.getElementById("ScontoRCA").value != "0")
		{
			var sconto = "0";
			
			if((window.document.getElementById("ScontoF")!=null)&&(window.document.getElementById("ScontoF").value!=""))
			{
				sconto = window.document.getElementById("ScontoF").value;
			}
	/*		var container = null;
			if(window.document.getElementById("tableMKT")!=null)
			{
				container = window.document.getElementById("tableMKT");
			}*/
			if(profilo!=null)
			{
				if(profilo=="T1") // profili convenzionati
				{
					document.getElementById("divScontoCONV").style.display = "block";
					/*
					if(kasko.checked==false)
						ups.innerText = "Aggiungi la BluKasko per una protezione completa";
					else
						ups.innerText = "";*/
					
				}
				else if((profilo!="T2"))
				{ 
					strFrazionamento="";
					rca = window.document.getElementById("chkRCA");
					incendio = window.document.getElementById("chkIncendioFurto");
					frazionamento=window.document.getElementById("ddlFrazionamento")
					if (frazionamento!=null && frazionamento.selectedIndex==1)
					{
						strFrazionamento="Sem";
					}	
					
					if(sconto=="0") // no sconto famiglia
					{
						if((rca.checked==true)&&(incendio.checked==false))
						{	
							document.getElementById("divScontoRCA"+strFrazionamento).style.display = "block";
						}
						else if((rca.checked==true)&&(incendio.checked==true))
						{
							document.getElementById("divScontoRCAIF"+strFrazionamento).style.display = "block";
						}
					}
					else	// con sconmto famiglia
					{
						if((rca.checked==true)&&(incendio.checked==false))
						{	
							document.getElementById("divScontoRCAFam"+strFrazionamento).style.display = "block";
						}
						else if((rca.checked==true)&&(incendio.checked==true))
						{
							document.getElementById("divScontoRCAIFFam"+strFrazionamento).style.display = "block";
						}
					}
				}
			}
		}
}
	//END LORIS REBRANDING
}
function DefaultPackage()
{
	DisableAllCheck();
	
	var arrCheck=document.getElementById("txtSalvaGaranzie").value.split('#');
		
	for (i=0;i<arrCheck.length-1;i++){
		try
		{
			document.getElementById(arrCheck[i]).checked=true;
		}catch(ex){}
	}
	saveState();
	SetMarketingMessages();
}
function CheckHighlights()
{

	if(window.document.getElementById("chkAssistenza")!=null && window.document.getElementById("chkAssistenza").checked==true)
	{
		window.document.getElementById("row_Assistenza").className 	= "campoPr bgOn";
	}
	if(window.document.getElementById("chkTutelaGiud")!=null && window.document.getElementById("chkTutelaGiud").checked==true)
	{
		window.document.getElementById("row_Tutela").className 		= "campoPr bgOn";
	}
	if(window.document.getElementById("chkInfortuniConducente")!=null && window.document.getElementById("chkInfortuniConducente").checked==true)
	{
		window.document.getElementById("row_Infortuni").className 	= "campoPr bgOn";
	}
	if(window.document.getElementById("chkIncendioFurto")!=null && window.document.getElementById("chkIncendioFurto").checked==true)
	{
		window.document.getElementById("row_Incendio").className 	= "campoPr bgOn";
	}
	if(window.document.getElementById("chkComplementareARD")!=null && window.document.getElementById("chkComplementareARD").checked==true)
	{
		window.document.getElementById("row_Complementare").className	= "campoPr bgOn";
	}
	if(window.document.getElementById("chkEventiSociopolitici")!=null && window.document.getElementById("chkEventiSociopolitici").checked==true)
	{
		window.document.getElementById("row_SocioPolitici").className 	= "campoPr bgOn";
	}
	if(window.document.getElementById("chkEventiNaturali")!=null && window.document.getElementById("chkEventiNaturali").checked==true)
	{
		window.document.getElementById("row_Naturali").className 	= "campoPr bgOn";
	}
	if(window.document.getElementById("chkRitiroPatente")!=null && window.document.getElementById("chkRitiroPatente").checked==true)
	{
		window.document.getElementById("row_RitiroPatente").className 	= "campoPr bgOn";
	}
	if(window.document.getElementById("chkKaskoParziale")!=null && window.document.getElementById("chkKaskoParziale").checked==true)
	{
		window.document.getElementById("row_KaskoParziale").className 	= "campoPr bgOn";
	}
	if( window.document.getElementById("chkKaskoCompleta")!=null && window.document.getElementById("chkKaskoCompleta").checked==true)
	{
		window.document.getElementById("row_KaskoCompleta").className 	= "campoPr bgOn";
	}
	if(window.document.getElementById("chkRicorsoAb")!= null && window.document.getElementById("chkRicorsoAb").checked == true)
	{
		window.document.getElementById("row_RicAb").className 		= "campoPr bgOn";
	}
	if(window.document.getElementById("chkIncFabbricatoAb")!= null && window.document.getElementById("chkIncFabbricatoAb").checked == true)
	{
		window.document.getElementById("row_IncFaAb").className 		= "campoPr bgOn";
	}
	
	if(window.document.getElementById("chkIncContenutoAb")!= null)
	{	if(window.document.getElementById("chkIncContenutoAb").checked == true)
		{
		window.document.getElementById("row_IncCoAb").className 		= "campoPr bgOn";
		}
		else window.document.getElementById("row_IncCoAb").className 		= "campoPr bgOff";
	}
	
	
	if(window.document.getElementById("chkFurtoContenuto")!= null && window.document.getElementById("chkFurtoContenuto").checked == true)
	{
		window.document.getElementById("row_Furco").className 		= "campoPr bgOn";
	}
	
	if(window.document.getElementById("chkIncContenutoSa")!= null)
	{
		if (window.document.getElementById("chkIncContenutoSa").checked == true)
		{
		window.document.getElementById("row_IncCoSa").className 		= "campoPr bgOn";
		}
		else window.document.getElementById("row_IncCoSa").className 		= "campoPr bgOff";
	}
	
	if(window.document.getElementById("chkIncFabbricatoSa")!= null && window.document.getElementById("chkIncFabbricatoSa").checked == true)
	{
		window.document.getElementById("row_IncFaSa").className 		= "campoPr bgOn";
	}
	
	if(window.document.getElementById("chkFurtoGioielli")!= null)
	{
		if(window.document.getElementById("chkFurtoGioielli").checked == true)
		{
		window.document.getElementById("row_Furgi").className 		= "campoPr bgOn";
		}
		else window.document.getElementById("row_Furgi").className 		= "campoPr bgOff";
	}		

}
function ResetHighlights()
{
	//Pulisco tutti gli highlight
	//window.document.getElementById("row_RCA_1").className 		= "campoPr bgOff";
	
	/*window.document.getElementById("row_TipoGuida").className 		= "TxtInTableCeleste";
	window.document.getElementById("row_TipoGuida_2").className 		= "TxtInTableCeleste";
	
	window.document.getElementById("row_Massimale").className 		= "TxtInTableCeleste";
	window.document.getElementById("row_Massimale_2").className 		= "TxtInTableCeleste";*/

	if (window.document.getElementById("row_Assistenza") != null)
		window.document.getElementById("row_Assistenza").className 	= "campoPr bgOff";

	if (window.document.getElementById("row_Tutela") != null)
		window.document.getElementById("row_Tutela").className 		= "campoPr bgOff";

	if (window.document.getElementById("row_Infortuni") != null)
		window.document.getElementById("row_Infortuni").className 	= "campoPr bgOff";

	if (window.document.getElementById("row_Incendio") != null)
		window.document.getElementById("row_Incendio").className 	= "campoPr bgOff";

	if (window.document.getElementById("row_Complementare") != null)
		window.document.getElementById("row_Complementare").className	= "campoPr bgOff";

	if (window.document.getElementById("row_SocioPolitici") != null)
		window.document.getElementById("row_SocioPolitici").className 	= "campoPr bgOff";

	if (window.document.getElementById("row_Naturali") != null)
		window.document.getElementById("row_Naturali").className 	= "campoPr bgOff";

	if (window.document.getElementById("row_RitiroPatente") != null)
		window.document.getElementById("row_RitiroPatente").className 	= "campoPr bgOff";

	if (window.document.getElementById("row_KaskoParziale") != null)
		window.document.getElementById("row_KaskoParziale").className 	= "campoPr bgOff";
	
	if (window.document.getElementById("row_KaskoCompleta") != null)
		window.document.getElementById("row_KaskoCompleta").className = "campoPr bgOff";
		
	if (window.document.getElementById("row_Furco") != null)
		window.document.getElementById("row_Furco").className = "campoPr bgOff";
}

function HighlightSingleRow(item)
{
		
			ResetHighlights();
			if (window.document.getElementById("PackageBase") != null)
				resetHighlightPackage("Base");
			if (window.document.getElementById("PackagePlus") != null)
				resetHighlightPackage("Plus");
			if (window.document.getElementById("PackageTop") != null)
				resetHighlightPackage("Top");
			
			switch(item)
			{
				case "txtPacchettoBase":
					if(window.document.getElementById("PackageBase")!=null)
						highlightPackage("Base");
					break;
				case "txtPacchettoPlus":
					if(window.document.getElementById("PackagePlus")!=null){
							highlightPackage("Plus");
					}
					break;
				case "txtPacchettoTop":
					if(window.document.getElementById("PackageTop")!=null)
						highlightPackage("Top");
					break;
			} //fine switch
			/*if(window.document.getElementById("chkRCA")!= null && window.document.getElementById("chkRCA").checked	== true)
			{	
				window.document.getElementById("row_RCA_1").className 			= "campoPr bgOn";
			}*/											
			CheckHighlights();	
	//CheckIfPackage();
}

function selectPackage(txtControl)
{
	CurrentPackage = "";
	if(window.document.getElementById("PackageBase").className != "boxC170b")
		CurrentPackage = "PackageBase";
	if(window.document.getElementById("PackagePlus").className != "boxC170b")
		CurrentPackage = "PackagePlus";
	if(window.document.getElementById("PackageTop").className != "boxC170b")
		CurrentPackage = "PackageTop";
	/*chiamando showcalcola si imposta di sbiancare e ricalcolare ogni volta che si prema un bottone applica dei package*/
	showCalcola('pnlCalcola','pnlSalva');
	
	DisableAllCheck();
	
	var allCheck = document.getElementsByTagName('input');
	
	var arrCheck=document.getElementById(txtControl).value.split('#');
	for (i=0;i<arrCheck.length-1;i++){
		try
		{
			document.getElementById(arrCheck[i]).checked=true;
			
			if(document.getElementById(arrCheck[i]).id == "chkIncendioFurto")
			{	
				IsChkIncendioFurtoChanged = true;
			}
		}catch(ex){}
	}
	
	saveState();
	/*modifica luca passaro*/
	
	if(document.getElementById("lblvPremioAnnualeLordoSconto").value!="")
	{	
		calculateAllAuto();
	}
	handleIFChkNew(true); 
	HighlightSingleRow(txtControl);
	window.document.getElementById("btnCalcola").click();
	SetMarketingMessages();
	showCalcola('pnlCalcola','pnlSalva');
}
/*FINE GESTIONE CALCOLO PREMIO BY LUCA PASSARO*/
function manageTotali()
{
	
	var profilo = null;
	if(window.document.getElementById("HdnProfilo")!=null)
	{
		profilo = window.document.getElementById("HdnProfilo").value;
	}
	if(profilo!="T2")
	{
		if((window.document.getElementById("lblvPremioAnnualeLordo").innerHTML == "")&&(window.document.getElementById("lblvRataSemLorda").innerHTML==""))
		{
				if(window.document.getElementById("cellaPremioAnnuo")!=null)
					window.document.getElementById("cellaPremioAnnuo").className = "TxtInTableCeleste22";
				if(window.document.getElementById("cellaPremioSemestrale")!=null)
					window.document.getElementById("cellaPremioSemestrale").className = "TxtInTableCeleste22";
		}	
		else
		{
			//LORIS REBRANDING
			/*
			if(window.document.getElementById("optRataAnnPers").checked==true)
				window.document.getElementById("cellaPremioAnnuo").className = "SfondoAzzurroTot22";
			else
				window.document.getElementById("cellaPremioAnnuo").className = "TxtInTableCeleste22";
			
			if(window.document.getElementById("optRataSemPers")!=null)
			{
				if(window.document.getElementById("optRataSemPers").checked==true)
					window.document.getElementById("cellaPremioSemestrale").className = "SfondoAzzurroTot22";
				else
					window.document.getElementById("cellaPremioSemestrale").className = "TxtInTableCeleste22";
			}*/
			//END LORIS REBRANDING
		}
	}
	else
	{
		if(window.document.getElementById("lblvPremioAnnualeLordo").innerHTML == "")
		{
				if(window.document.getElementById("cellaPremioAnnuo")!=null)
					window.document.getElementById("cellaPremioAnnuo").className = "TxtInTableCeleste22";
				if(window.document.getElementById("cellaPremioSemestrale")!=null)
					window.document.getElementById("cellaPremioSemestrale").className = "TxtInTableCeleste22";
		}	
		else
		{
			//LORIS REBRANDING
			/*
			if(window.document.getElementById("optRataAnnPers").checked==true)
				window.document.getElementById("cellaPremioAnnuo").className = "SfondoAzzurroTot22";
			else
				window.document.getElementById("cellaPremioAnnuo").className = "TxtInTableCeleste22";
			*/
			//END LORIS REBRANDING
		}
	}
}

function selectPackageMoto(txtControl){
	DisableAllCheck();
	var allCheck = document.getElementsByTagName('input');
	var arrCheck=document.getElementById(txtControl).value.split('#');
	for (i=0;i<arrCheck.length-1;i++){
		try{
		document.getElementById(arrCheck[i]).checked=true;
		}catch(ex){}
	}
	calculateAllMoto();
	handleIFChkNew(true);
	if(window.document.getElementById("chkIncendioFurto")!= null && window.document.getElementById("chkIncendioFurto").checked == true)
	{
		window.document.getElementById("row_Incendio").className 	= "campoPr bgOn";
	}
	HighlightSingleRow(txtControl);
}

function selectPackageCasa(txtControl){
	/*chiamando showcalcola si imposta di sbiancare e ricalcolare ogni volta che si prema un bottone applica dei package*/
	showCalcola('pnlCalcola','pnlSalva');
	
	DisableAllCheck();
	if((window.document.getElementById("txtRicorsoAbValue").value=="0" ||
	   window.document.getElementById("txtRicorsoAbValue").value==""))
 		{
 			window.document.getElementById("txtRicorsoAbValue").value = "100000";
 		}
	var allCheck = document.getElementsByTagName('input');
	var arrCheck=document.getElementById(txtControl).value.split('#');
	for (i=0;i<arrCheck.length-1;i++){
		try{
		document.getElementById(arrCheck[i]).checked=true;
		}catch(ex){}
	}
		EnableVal('chkFurtoContenuto','CompareValidator1');
		EnableVal('chkIncContenutoAb','rvIncContenutoAb');
		EnableVal('chkIncFabbricatoAb','rvIncFabbricatoAb');
		EnableVal('chkRicorsoAb','rvRicorsoAb');
	try{
		EnableVal('chkIncContenutoSa','rvIncContenutoSa');
		EnableVal('chkIncFabbricatoSa','rvIncFabbricatoSa');
	}catch(ex){}
	calculateAllCasa();
	HighlightSingleRow(txtControl);
	if(window.document.getElementById("lblvPremioAnnualeLordo")!=null)
			window.document.getElementById("lblvPremioAnnualeLordo").innerHTML = "";	
	if(window.document.getElementById("lblvPremioAnnualeLordoValue")!=null)
			window.document.getElementById("lblvPremioAnnualeLordoValue").innerHTML = "";	
}

function calculateAllCasa(){
		calculateSumHp1(document.getElementById('chkRCA'),'txtRCA','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
		calculateSumHp(document.getElementById('chkAssistenza'),'txtAssistenza','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
		calculateSumHp(document.getElementById('chkFurtoContenuto'),'txtFurtoContenuto','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
		calculateSumHp(document.getElementById('chkFurtoGioielli'),'txtFurtoGioielli','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
		calculateSumHp(document.getElementById('chkIncContenutoAb'),'txtIncContenutoAb','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
		calculateSumHp(document.getElementById('chkIncFabbricatoAb'),'txtIncFabbricatoAb','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
		calculateSumHp(document.getElementById('chkRicorsoAb'),'txtRicorsoAb','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
		try{
		calculateSumHp(document.getElementById('chkIncFabbricatoSa'),'txtIncFabbricatoSa','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
		calculateSumHp(document.getElementById('chkIncContenutoSa'),'txtIncContenutoSa','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
		}catch(ex){}
}

function calculateAllAuto(){
	calculateSumHp1(document.getElementById('chkRCA'),'txtRCA','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkAssistenza'),'txtAssistenza','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkTutelaGiud'),'txtTutelaGiudiziaria','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkKaskoParziale'),'txtKaskoParziale','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	try{
	calculateSumHp(document.getElementById('chkIncendioFurto'),'txtIncendioFurto','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkEventiSociopolitici'),'txtEventiSocio','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkRitiroPatente'),'txtRitiroPatente','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkEventiNaturali'),'txtEventiNaturali','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkInfortuniConducente'),'txtInfortuniConducente','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkComplementareARD'),'txtComplementareARD','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	calculateSumHp(document.getElementById('chkKaskoCompleta'),'txtKaskoCompleta','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
	}catch(ex){}
 	showPremioFrazionato(document.getElementById('ddlFrazionamento'));	 	
	checkSemestralita();
}

function checkSemestralita(){
//	try{
//		var strSem=document.getElementById('optRataSemPers').disabled;
//	}catch(ex){return;}
	var frazionamento=document.getElementById('ddlFrazionamento');
	var PremioMinimoSem;
	if (window.document.getElementById("TipoBene")!=null && window.document.getElementById("TipoBene").value!="CASA")
		PremioMinimoSem = window.document.getElementById("HdnPremioMinimoSem").value;
	if (frazionamento !=null)
	{
		if 	(document.getElementById('lblvPremioAnnualeLordoScontoValue')!=null){
			if (parseFloat(document.getElementById('lblvPremioAnnualeLordoScontoValue').innerHTML) < PremioMinimoSem ||
				frazionamento.length == 1){
					frazionamento.disabled=true;
					frazionamento.selectedIndex=0;	
					//showPremioFrazionato(frazionamento);	 				
			}else
			{
				frazionamento.disabled=false;	
			}
		}
		else
		{
			if (parseFloat(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML) < PremioMinimoSem ||
				frazionamento.length==1){
				frazionamento.disabled=true;	
				frazionamento.selectedIndex=0;			
				//showPremioFrazionato(frazionamento);	 				
			}
			else
			{
				frazionamento.disabled=false;	
			}
		}
		if(window.document.getElementById("HTMLCodConv") != null)
		{
			if(window.document.getElementById("HTMLCodConv").value == "WBK")
			{
				frazionamento.disabled = true;
			}	
		} 
	}
}

function calculateSum(check,controlToSum,lblToUpdate,valueToUpdate)
{  	
/*	if(window.document.getElementById("TipoBene")!=null)
	{
		if((IsChkIncendioFurtoChanged==true)&&(parseInt(window.document.getElementById("lblvPremioAnnualeLordoValue").innerText) == 0))
		{
				return;
		}
	}*/
	var sumValue;
	var sumValueSconto;
	var sum;
	var sumSconto;
	//var TassoSemestrale;
	//if (window.document.getElementById("TipoBene")!=null && window.document.getElementById("TipoBene").value!="CASA")
		//TassoSemestrale = window.document.getElementById("HdnTassoSem").value;
	if(check!=null)
	{
		//var isFrazionato=false;
		//if (document.getElementById("ddlFrazionamento")!= null && document.getElementById("ddlFrazionamento").selectedIndex==1)
		//{
		//	isFrazionato=true;
		//}
		if (check.checked)
		{
		
			sumValue=parseFloat(document.getElementById(valueToUpdate).innerHTML.replace(',','.')) + parseFloat(document.getElementById(controlToSum).value.replace('.','').replace(',','.'));
			sum=sumValue;
			
			//if (isFrazionato)
			//{
			//	sumValue=sumValue * TassoSemestrale / 100;
			//}
			
			if(!isNaN(sumValue)) document.getElementById(lblToUpdate).innerHTML=formatCurrency(sumValue);
			document.getElementById(valueToUpdate).innerHTML=sum;
			
			if (document.getElementById(lblToUpdate + 'Sconto')!=null && document.getElementById(lblToUpdate + 'ScontoValue').innerHTML != "")
			{
				sumValueSconto=parseFloat(document.getElementById(lblToUpdate + 'ScontoValue').innerHTML.replace(',','.')) + parseFloat(document.getElementById(controlToSum + 'Sconto').value.replace('.','').replace(',','.'));
				sumSconto=sumValueSconto;
				//if (isFrazionato){
				//	sumValueSconto=sumValueSconto * TassoSemestrale /100;
				//}

				document.getElementById(lblToUpdate + 'Sconto').innerHTML=formatCurrency(sumValueSconto);
				document.getElementById(lblToUpdate + 'ScontoValue').innerHTML=sumSconto;
			}
		}
		else
		{
			sumValue=parseFloat(document.getElementById(valueToUpdate).innerHTML.replace(',','.')) - parseFloat(document.getElementById(controlToSum).value.replace('.','').replace(',','.'));
			sum=sumValue;
			//if (isFrazionato){
			//	sumValue=sumValue * TassoSemestrale / 100;
			//}
			
			if(!isNaN(sumValue)) document.getElementById(lblToUpdate).innerHTML=formatCurrency(sumValue);
			document.getElementById(valueToUpdate).innerHTML=sum;
			
			if (document.getElementById(lblToUpdate + 'Sconto')!=null && document.getElementById(lblToUpdate + 'ScontoValue').innerHTML != ""){
				sumValueSconto=parseFloat(document.getElementById(lblToUpdate + 'ScontoValue').innerHTML.replace(',','.'))- parseFloat(document.getElementById(controlToSum + 'Sconto').value.replace('.','').replace(',','.'));
				sumSconto=sumValueSconto;

			//	if (isFrazionato){
			//		sumValueSconto = sumValueSconto * TassoSemestrale / 100;
			//	}
				document.getElementById(lblToUpdate + 'Sconto').innerHTML=formatCurrency(sumValueSconto);
				document.getElementById(lblToUpdate + 'ScontoValue').innerHTML=sumSconto;
			}
		}
			
		checkSemestralita();
	}
		if (document.getElementById('Hvalue')!=null){
			if (document.getElementById('lblvPremioAnnualeLordoValue').innerHTML=='NaN'){
					document.getElementById('lblvPremioAnnualeLordoValue').innerHTML='';
			}
			if (document.getElementById('lblvPremioAnnualeLordoScontoValue')!=null){
				document.getElementById('Hvalue').value=Math.round(document.getElementById('lblvPremioAnnualeLordoScontoValue').innerHTML*100)/100;	
				document.getElementById('HvalueFull').value=Math.round(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML*100)/100;
			}else{
				document.getElementById('Hvalue').value=Math.round(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML*100)/100;	
				document.getElementById('HvalueFull').value=Math.round(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML*100)/100;
			}
			//Setto dinamicamente l'Hvalue e HvalueFull   @CG
			if(typeof(window['SASPageID']) != "undefined"){
				var HvaluePos = SASPageID.indexOf('Hvalue');
				if(HvaluePos > 0){
				SASPageID=SASPageID.substring(0,HvaluePos) + 
						'Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';
				}
				else{
					SASPageID= SASPageID +	
					'Hcurr:euro;Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';		
				}
			}
			else{
				var HvaluePos = document.getElementById('SasPageIdTest').innerHTML.indexOf('Hvalue');
				if(HvaluePos > 0){
				document.getElementById('SasPageIdTest').innerHTML=document.getElementById('SasPageIdTest').innerHTML.substring(0,HvaluePos) + 
						'Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';
				}
				else{
					document.getElementById('SasPageIdTest').innerHTML= document.getElementById('SasPageIdTest').innerHTML +	
					'Hcurr:euro;Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';		
				}
			}
		}
}
function calculateSumHp(check,controlToSum,lblToUpdate,valueToUpdate)
{  	
	if(window.document.getElementById("TipoBene")!=null)
	{
		if((IsChkIncendioFurtoChanged==true)&&(parseInt(window.document.getElementById("lblvPremioAnnualeLordoValue").innerText) == 0))
		{
				return;
		}
	}
	var sumValue;
	var sumvalueSconto;
	var sum;
	var sumSconto;

	var isFrazionato=false;
	//var TassoSemestrale;
	//if (window.document.getElementById("TipoBene")!=null && window.document.getElementById("TipoBene").value!="CASA")
	//	TassoSemestrale = window.document.getElementById("HdnTassoSem").value;
	
	if(check!=null)
	{
		//if (document.getElementById("ddlFrazionamento")!= null && document.getElementById("ddlFrazionamento").selectedIndex==1)
		//{
		//	isFrazionato=true;
		//}

		if (check.checked){

			sumValue=parseFloat(document.getElementById(valueToUpdate).innerHTML.replace(',','.')) + parseFloat(document.getElementById(controlToSum).value.replace('.','').replace(',','.'));
			sum=sumValue;
			//if (isFrazionato){
			//	sumValue=sumValue * TassoSemestrale / 100;
			//}
			document.getElementById(lblToUpdate).innerHTML=formatCurrency(sumValue);
			document.getElementById(valueToUpdate).innerHTML=sum;
			if (document.getElementById(lblToUpdate + 'Sconto')!=null){
				sumValueSconto=parseFloat(document.getElementById(lblToUpdate + 'ScontoValue').innerHTML.replace(',','.')) + parseFloat(document.getElementById(controlToSum + 'Sconto').value.replace('.','').replace(',','.'));
				sumSconto=sumValueSconto;
				//if (isFrazionato){
				//	sumValueSconto = sumValueSconto * TassoSemestrale /100;
				//}

				document.getElementById(lblToUpdate + 'Sconto').innerHTML=formatCurrency(sumValueSconto);
				document.getElementById(lblToUpdate + 'ScontoValue').innerHTML=sumSconto;
			}
		}
	}		
	if (document.getElementById('Hvalue')!=null){
		if (document.getElementById('lblvPremioAnnualeLordoScontoValue')!=null){
			document.getElementById('Hvalue').value=Math.round(document.getElementById('lblvPremioAnnualeLordoScontoValue').innerHTML*100)/100;
			document.getElementById('HvalueFull').value=Math.round(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML*100)/100;
		}else{
			document.getElementById('Hvalue').value=Math.round(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML*100)/100;
			document.getElementById('HvalueFull').value=Math.round(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML*100)/100;
		}
		//Setto dinamicamente l'Hvalue e HvalueFull   @CG
			if(typeof(window['SASPageID']) != "undefined"){
				var HvaluePos = SASPageID.indexOf('Hvalue');
				if(HvaluePos > 0){
				SASPageID=SASPageID.substring(0,HvaluePos) + 
						'Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';
				}
				else{
					SASPageID= SASPageID +	
					'Hcurr:euro;Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';		
				}
			}
			else{
				var HvaluePos = document.getElementById('SasPageIdTest').innerHTML.indexOf('Hvalue');
				if(HvaluePos > 0){
				document.getElementById('SasPageIdTest').innerHTML=document.getElementById('SasPageIdTest').innerHTML.substring(0,HvaluePos) + 
						'Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';
				}
				else{
					document.getElementById('SasPageIdTest').innerHTML= document.getElementById('SasPageIdTest').innerHTML +	
					'Hcurr:euro;Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';		
				}
			}
	}
}
function calculateSumHp1(check,controlToSum,lblToUpdate,valueToUpdate)
{  	
	if(window.document.getElementById("TipoBene")!=null)
	{
		if((IsChkIncendioFurtoChanged==true)&&(parseInt(window.document.getElementById("lblvPremioAnnualeLordoValue").innerText) == 0))
		{
				return;
		}
	}
	var sumValue;
	var sumValueSconto;
	var sum;
	var sumSconto;
	//var isFrazionato=false;
	//var TassoSemestrale;
	
	//if (window.document.getElementById("TipoBene")!=null && window.document.getElementById("TipoBene").value!="CASA")
	//	TassoSemestrale = window.document.getElementById("HdnTassoSem").value;

	if (check.checked){
		//if (document.getElementById("ddlFrazionamento")!= null && document.getElementById("ddlFrazionamento").selectedIndex==1)
		//{
		//	isFrazionato=true;
		//}

		sumValue=parseFloat(document.getElementById(controlToSum).value.replace('.','').replace(',','.'))
		sum=sumValue;
		//if (isFrazionato){
		//	sumValue= sumValue * TassoSemestrale /100;
		//}
		document.getElementById(lblToUpdate).innerHTML=formatCurrency(sumValue);
		document.getElementById(valueToUpdate).innerHTML=sum;
		if (document.getElementById(lblToUpdate + 'Sconto')!=null){

			sumValueSconto=parseFloat(document.getElementById(controlToSum + 'Sconto').value.replace('.','').replace(',','.'))
			sumSconto=sumValueSconto;
			//if (isFrazionato){
			//	sumValueSconto=sumValueSconto * TassoSemestrale /100;
			//}
			document.getElementById(lblToUpdate + 'Sconto').innerHTML=formatCurrency(sumValueSconto);
			document.getElementById(lblToUpdate + 'ScontoValue').innerHTML=sumSconto;
		}
	}
		if (document.getElementById('Hvalue')!=null){
			if (document.getElementById('lblvPremioAnnualeLordoScontoValue')!=null){
				document.getElementById('Hvalue').value=Math.round(document.getElementById('lblvPremioAnnualeLordoScontoValue').innerHTML*100)/100;
				document.getElementById('HvalueFull').value=Math.round(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML*100)/100;
			}else{
				document.getElementById('Hvalue').value=Math.round(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML*100)/100;
				document.getElementById('HvalueFull').value=Math.round(document.getElementById('lblvPremioAnnualeLordoValue').innerHTML*100)/100;
			}
			//Setto dinamicamente l'Hvalue e HvalueFull   @CG
			if(typeof(window['SASPageID']) != "undefined"){
				var HvaluePos = SASPageID.indexOf('Hvalue');
				if(HvaluePos > 0){
				SASPageID=SASPageID.substring(0,HvaluePos) + 
						'Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';
				}
				else{
					SASPageID= SASPageID +	
					'Hcurr:euro;Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';		
				}
			}
			else{
				var HvaluePos = document.getElementById('SasPageIdTest').innerHTML.indexOf('Hvalue');
				if(HvaluePos > 0){
				document.getElementById('SasPageIdTest').innerHTML=document.getElementById('SasPageIdTest').innerHTML.substring(0,HvaluePos) + 
						'Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';
				}
				else{
					document.getElementById('SasPageIdTest').innerHTML= document.getElementById('SasPageIdTest').innerHTML +	
					'Hcurr:euro;Hvalue:'+ document.getElementById('Hvalue').value + ';HvalueFull:' + document.getElementById('HvalueFull').value + ';';		
				}
			}
		}
}

function updateRata(lblSem,lblAnn,percTasso){
}


/*function ShowControlById(controlToHideId,visible)
{  	
	var controlToHide = document.getElementById(controlToHideId);
	if(null==controlToHide) return;
	if(visible)
		 controlToHide.style.display = "inline";
	else
		 controlToHide.style.display = "none";
}*/

function showPanel(panelToShow)
{  	if(null==panelToShow) return;
		 panelToHide.style.visibility = "visible";
}




// calcolo data odierna
function getDate()
{
	var Days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
	var today = new Date();
	var Year = takeYear(today);
	var Month = leadingZero(today.getMonth()+1);
	var Day = leadingZero(today.getDate());
	return ( Day+"/"+Month+"/"+Year );
}

function takeYear(theDate)
{
	x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}

function leadingZero(nr)
{
	if (nr < 10) nr = "0" + nr;
	return nr;
}
// END calcolo data odierna


function manageGender(genderCtrl, panelCtrl)
{
	if (genderCtrl.value=="A")
	{
		panelCtrl.style.visibility = "hidden";
	}
	else
	{
		panelCtrl.style.visibility = "visible";
	}
}


function doLogin()
{
	if(event.keyCode == 13)
	{
		event.returnValue = false;
		event.cancel = true;
		document.getElementById('UTBoxLogin1_btnLogin').click();
	}
}


function doHiddenLogin()
{
	document.getElementById('UTBoxLogin1:textBoxUserid').value = document.getElementById('NavMenuDx_UTSlimLogin1_txtUserid').value;
	document.getElementById('UTBoxLogin1:textBoxPwd').value = document.getElementById('NavMenuDx_UTSlimLogin1_txtPwd').value;
	document.getElementById('UTBoxLogin1:hiddenLoginAction').click();
}

function shareTxtContent ( theTxt, theContent)
{
	if( null==theTxt) return;
	var dataScadenzaControl = document.getElementById( theTxt.id);
	if ( dataScadenzaControl.disabled==false && dataScadenzaControl.value=="")
	{// se la dataScadenza e' richiesta (se! non e' prima assicurazione) e NON e' stata ancora valorizzata (perche' non vogliamo correzioni)
		dataScadenzaControl.value = theContent;
	}
}

/*function hideMultiproprieta()
			{
				var ddl = document.getElementById("ddlContraenteProp");
	
				var controlToHide = document.getElementById("pnlMultiproprieta");
				var riga = document.getElementById("rigaMultiProp");
				if(null==controlToHide) return;
				if(ddl.options[0].selected)				{
					controlToHide.style.display = "none";
					riga.style.display = "none";
				}
				else
				{
					controlToHide.style.display = "inline";
					riga.style.display = "inline";
					
				}
			}*/
function hideScadenza()
{
	if( 1000!=document.getElementById('ddlSituazioneAssicurativa').value && document.getElementById('ddlSituazioneAssicurativa').value !=0)
	{
		document.getElementById('dom6Container').style.display = 'none';
		//document.getElementById('rowScadenza').style.visibility='hidden';
		/*document.getElementById('lblBersani').style.display='block';*/
		 
	}
	else
	{
		document.getElementById('dom6Container').style.display = 'inline';
		//document.getElementById('rowScadenza').style.visibility='visible'	
		/*document.getElementById('lblBersani').style.display='none';*/
		  
	}
}



function OpenGlossario(id)
{
	 
	
		try{	
		popUp.close();
		}catch(ex){}
		popUp = window.open('default.aspx?Target=Glossario&id=' + id, 
			'popupglossario', 
			'width=560,height=320,left=250,top=250');
}

function OpenGlossarioRedim(id,width,height)
{ 


		try{	
		popUp.close();
		}catch(ex){}	//DINELLI SIR 233-05 MODIFICA CU
	popUp = window.open('default.aspx?Target=Glossario&id=' + id, 
		'popupglossario', 
		'width=' + width + ',height=' + height + ',left=250,top=250');
		
} 

function OpenShowUidPwd()
{ 
		try{	
		popUp.close();
		}catch(ex){}	//DINELLI SIR 233-05 MODIFICA CU
	popUp = window.open('default.aspx?Target=ShowUidPwd', 
		'popupprint', 
		'width=400,height=200,left=250,top=250');
		
} 
function OpenGCredits()
{
window.open('default.aspx?Target=INCredits','popup','width=480,height=320,left=250,top=250')
}

function clickDefaultButton(defButtonId)
{
		event.returnValue = false;
		event.cancel = true;
		document.getElementById(defButtonId).click();
}

function handleKasko(thisControl,otherControl,txtControl){
	
	if (document.getElementById(thisControl).checked){												 
		document.getElementById(otherControl).checked=false;
	}
}

function handleKaskoPlus(thisControl,otherControl,txtControl,txtOtherControl,lblControl,lblValue)
{
	if (document.getElementById(thisControl).checked && document.getElementById(otherControl)!=null)
	{
		/*if (document.getElementById(otherControl).disabled)
		{
			document.getElementById(thisControl).checked=false;
		}
		else*/
		{	
			
			if (document.getElementById(otherControl).checked==true)
			{
				document.getElementById(otherControl).checked=false;
				calculateSum(document.getElementById(otherControl),txtOtherControl,lblControl,lblValue);

				if(document.getElementById(otherControl).id == "chkKaskoCompleta")
				{
					document.getElementById("row_KaskoCompleta").className = "campoPr bgOff";
					
					document.getElementById("row_KaskoParziale").className = "campoPr bgOn";
				}
				
				if(document.getElementById(otherControl).id == "chkKaskoParziale")
				{
					document.getElementById("row_KaskoParziale").className = "campoPr bgOff";
					
					document.getElementById("row_KaskoCompleta").className = "campoPr bgOn";
				}
			}	
			calculateSum(document.getElementById(thisControl),txtControl,lblControl,lblValue);
		 
		}

	}
	else
	{
		calculateSum(document.getElementById(thisControl),txtControl,lblControl,lblValue);
	}

}

function handleIFChk()
{
	 
	var ifEnabled = document.getElementById('chkIncendioFurto').checked;
	document.getElementById('chkComplementareARD').disabled = !ifEnabled;
	document.getElementById('chkEventiSociopolitici').disabled = !ifEnabled;	
	//document.getElementById('chkKasco').disabled = !ifEnabled;
	
	document.getElementById('chkKaskoCompleta').disabled = !ifEnabled;
	if(document.getElementById('chkKaskoParziale')!=null){
		document.getElementById('chkKaskoParziale').disabled = !ifEnabled;
	}
	if (!ifEnabled){	
		document.getElementById('chkComplementareARD').checked = false;
		document.getElementById('chkEventiSociopolitici').checked = false;
		//document.getElementById('chkKasco').checked = false;
		document.getElementById('chkKaskoCompleta').checked = false;
		if(document.getElementById('chkKaskoParziale')!=null){
		document.getElementById('chkKaskoParziale').checked = false;
		}
	}
}

function handleIFChkNew(isHP)
{
	if (document.getElementById('chkIncendioFurto') != null){
		var ifEnabled = document.getElementById('chkIncendioFurto').checked;
		if((document.getElementById('chkComplementareARD')!=null)||(document.getElementById('chkEventiSociopolitici')!=null))
		{
			document.getElementById('chkComplementareARD').disabled = !ifEnabled;
			if (!ifEnabled){
				document.getElementById('lblCristalli').className=document.getElementById('lblEventiSocio').className="mLeft0 fontGray";
			}else{
				document.getElementById('lblCristalli').className=document.getElementById('lblEventiSocio').className="mLeft0";
			}
			document.getElementById('chkEventiSociopolitici').disabled = !ifEnabled;
		 			
			if (!ifEnabled){	
				if (document.getElementById('chkComplementareARD').checked){
					document.getElementById('chkComplementareARD').checked = false;
					if (!isHP)
					calculateSum(document.getElementById('chkComplementareARD'),'txtComplementareARD','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
				}
				if (document.getElementById('chkEventiSociopolitici').checked){
					document.getElementById('chkEventiSociopolitici').checked = false;
					if (!isHP)
					calculateSum(document.getElementById('chkEventiSociopolitici'),'txtEventiSocio','lblvPremioAnnualeLordo','lblvPremioAnnualeLordoValue');
				}
				EnableChk("lblvComplementareARD",false,"");
				//window.document.getElementById("lblvComplementareARD_0").className = "TxtInTableConvLite";
				EnableChk("lblvEventiSocio",false,"");
				//window.document.getElementById("lblvEventiSocio_0").className = "TxtInTableConvLite";
			}
			else{
				EnableChk("lblvComplementareARD",true,"");
				//window.document.getElementById("lblvComplementareARD_0").className = "TxtInTableConv";
				EnableChk("lblvEventiSocio",true,"");				
				//window.document.getElementById("lblvEventiSocio_0").className = "TxtInTableConv";
			}
		}
	}
}

function handleIFChkNewPers(isHP)
{
	var ifEnabled = document.getElementById('chkIncendioFurto').checked;
	document.getElementById('chkComplementareARD').disabled = !ifEnabled;
	document.getElementById('chkEventiSociopolitici').disabled = !ifEnabled;	
	
	if (!ifEnabled){	
		if (document.getElementById('chkComplementareARD').checked){
			document.getElementById('chkComplementareARD').checked = false;
		}
		if (document.getElementById('chkEventiSociopolitici').checked){
			document.getElementById('chkEventiSociopolitici').checked = false;
		}
	}
}


function handleChkKasko()
{
//	var ifCheck = document.getElementById('chkKasco').checked;
//	document.getElementById('chkKaskoParziale').checked = ifCheck;
//	if (!ifCheck)
//	{
//		document.getElementById('rbKaskoCompleta').checked = ifCheck;
//		document.getElementById('rbKaskoParziale').checked = ifCheck;
//	}
}
function handleRbCompleta()
{
//	var ifCheck = document.getElementById('rbKaskoCompleta').checked;
//	document.getElementById('chkKasco').checked = ifCheck;

}
function handleRbParziale()
{
//	var ifCheck = document.getElementById('rbKaskoParziale').checked;
//	document.getElementById('chkKasco').checked = ifCheck;

}
function validaValAccessori(oSrc, args)
{
	valVeicolo = parseInt(document.getElementById('txtValoriVeicoli').value);
	args.IsValid = (args.Value < 6198 && args.Value < (valVeicolo/2));
}

function resetSelect( ddlToEmpty)
{// Empty the drop down list of any choices
	if(null==ddlToEmpty)
	{
		return;
	}
	if(null==ddlToEmpty.options)
	{
		return;
	}
	ddlToEmpty.options[0].selected=true;
	if(null!=ddlToEmpty.style)
	{
		if(null!=ddlToEmpty.style.visibility)
		{
			ddlToEmpty.style.visibility = "hidden";
		}
	}
	
}//

// utilizzata per i valori
// La stringa sarą valida se conterrą interi(X) nel formato XXXX,XX
function stringaValida(str) 
{
   var patternvalido = "^\\d+(?:\\,\\d{0,2})?$";
   var reg = new RegExp(patternvalido);
   return str.match(reg);
	
 };	
 

		
function getDateNow(){
	var now = new Date();
    var year = now.getYear();
    year=year.toString().substring(2,4);
    var month = now.getMonth() + 1;
    if (month.toString().length==1) month='0'+month.toString();
    var date = now.getDate();
    if (date.toString().length==1) date='0'+date.toString();
	var dateNow=date+month+year;
	return dateNow;
}
//Funzioni per prodotto casa
function CheckFurto(sender, args)
{
	if (document.getElementById('chkFurtoGioielli').checked && !document.getElementById('chkFurtoContenuto').checked)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}
function CheckMinimoAb(sender, args)
{
	if (!document.getElementById('chkIncFabbricatoAb').checked && !document.getElementById('chkIncContenutoAb').checked)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}	
function CheckMinimoSa(sender, args)
{
	if (!document.getElementById('chkIncFabbricatoSa').checked && !document.getElementById('chkIncContenutoSa').checked)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}			
function EnableVal(ctrlToCheck,validatorToEnable)
{
	try{
	if (!document.getElementById(ctrlToCheck).checked){
		ValidatorEnable(document.getElementById(validatorToEnable), false);
	}else{
		ValidatorEnable(document.getElementById(validatorToEnable), true);
	}
	}catch(ex){}
}

/******PRPRQUOTAZIONEPROPOSTEAUTO****************/
//LORIS REBRANDING 
/*function ToggleHL(item,radio)
{
	 
	if(window.document.getElementById('tblRataAnnPers')!= null){
		radio3 = window.document.getElementById('tblRataAnnPers');
		radio3.className = "TxtInTableCeleste22";
	}
	if(window.document.getElementById('tblRataSemPers')!= null){
		radio4 = window.document.getElementById('tblRataSemPers');
		radio4.className = "TxtInTableCeleste22";
		
	}
	 	
		if(radio.checked){ 
			window.document.getElementById(item).className   = "SfondoAzzurroTot22";
		}
		else{
			window.document.getElementById(item).className   = "TxtInTableCeleste22";
		}
}*/
//END LORIS REBRANDING

function EnableChk(itemId,enable,color)
{
	if(window.document.getElementById(itemId)!=null)
	{
		window.document.getElementById(itemId).style.color= color;
	}
 	 
}

/******PRPRQUOTAZIONEPROPOSTEAUTO****************/

function ChangeCssClassPackageMoto()
{
	if(window.document.getElementById("PackageMotoPLus")!=null)
	{
		if(window.document.getElementById("PackageMotoPLus").className == "SfondoFrecciaComm")
			window.document.getElementById("PackageMotoPLus").className = "SfondoFrecciaCommHL";
		else
			window.document.getElementById("PackageMotoPLus").className = "SfondoFrecciaComm";
	}
}

function ViewAllSpedizioni(flag)
{
	window.document.UTPaginaPersonaleForm.allSpedizioni.value = flag; 
	window.document.UTPaginaPersonaleForm.submit();
}

function CheckErrCodFiscale()
{
	if(window.document.getElementById("lblCFError")!=null)
	{
		if(window.document.getElementById("lblCFError").innerText != "")
		{
			window.scroll(0,500);
		}
	}
}
function numpolBersani()
{
window.document.getElementById("pnlNumeroPolizza").style.display  = "";

}
	
function ddlSituazioneAssicurativaChange()
{
	/*if(window.document.getElementById("tblcellPrev") != null)
		classTipoVeicolo = window.document.getElementById("tblcellPrev").className;
	else
		classTipoVeicolo = "";
	*/
	/*if(classTipoVeicolo != "ClaimPreventivoCiclo")
	{*/
		drop1 = window.document.getElementById("DropBersani1");
		drop2 = window.document.getElementById("DropBersani2");
		
			
		ddl = 	window.document.getElementById("ddlSituazioneAssicurativa");
		if((ddl[ddl.selectedIndex].value == "1040")||(ddl[ddl.selectedIndex].value == "1050"))
		{
			window.document.getElementById("PnlBersani1").style.display  = "";
		}
		else
		{
			drop1.selectedIndex = 0;
			drop2.selectedIndex = 0;
			window.document.getElementById("PnlBersani1").style.display  = "none";
			window.document.getElementById("pnlNumeroPolizza").style.display  = "none";
		}
		
		if(drop1.selectedIndex == 1)
		{
			window.document.getElementById("DropBersani2").disabled = false;
		}
		
		if((drop1.selectedIndex == 1)&&(drop2.selectedIndex == 1))
		{
			window.document.getElementById("PnlBersani1").style.display  = "";
			window.document.getElementById("pnlNumeroPolizza").style.display = "";
		}
	/*}*/
}
function DropBersani1Change(value)
{
		
	if(value == "1")//si
	{
		window.document.getElementById("DropBersani2").disabled = false;
	}
	else //no
	{
		window.document.getElementById("DropBersani2").selectedIndex = 0;
		window.document.getElementById("DropBersani2").disabled = true;
		window.document.getElementById("txtPolizzaBersani").value = "";
		window.document.getElementById("pnlNumeroPolizza").style.display = "none";
	}
}
function DropBersani2Change(value)
{
		
	if(value == "1")//si
	{
		window.document.getElementById("pnlNumeroPolizza").style.display = "";
	}
	else //no
	{
		window.document.getElementById("pnlNumeroPolizza").style.display = "none";
		window.document.getElementById("txtPolizzaBersani").value = "";
	}
}

function ResetGaranzie()
{
	if(window.document.getElementById("lblvRCA") != null)
		window.document.getElementById("lblvRCA").innerHTML = "";
		
	if(window.document.getElementById("lblvAssistenza")!=null)
		window.document.getElementById("lblvAssistenza").innerHTML = "";
	
	if(window.document.getElementById("lblvTutelaGiudiziaria")!=null)
		window.document.getElementById("lblvTutelaGiudiziaria").innerHTML = "";
	
	if(window.document.getElementById("lblvIncendioFurto")!=null)
		window.document.getElementById("lblvIncendioFurto").innerHTML = "";
	
	if(window.document.getElementById("lblvComplementareARD")!=null)
		window.document.getElementById("lblvComplementareARD").innerHTML = "";
	
	if(window.document.getElementById("lblvEventiSocio")!=null)
		window.document.getElementById("lblvEventiSocio").innerHTML = "";
	
	if(window.document.getElementById("lblvInfortuniConducente")!=null)
		window.document.getElementById("lblvInfortuniConducente").innerHTML = "";
	
	if(window.document.getElementById("lblvEventiNaturali")!=null)
		window.document.getElementById("lblvEventiNaturali").innerHTML = "";
	
	if(window.document.getElementById("lblvRitiroPatente")!=null)
		window.document.getElementById("lblvRitiroPatente").innerHTML = "";
	
	if(window.document.getElementById("lblvParziale")!=null)
		window.document.getElementById("lblvParziale").innerHTML = "";
	
	if(window.document.getElementById("lblvKaskoParziale")!=null)
		window.document.getElementById("lblvKaskoParziale").innerHTML = "";
	
	if(window.document.getElementById("lblvKaskoCompleta")!=null)
		window.document.getElementById("lblvKaskoCompleta").innerHTML = "";
		
	if(window.document.getElementById("lblvIncFabbricatoAb")!=null)
		window.document.getElementById("lblvIncFabbricatoAb").innerHTML = "";
	
	if(window.document.getElementById("lblvRicorsoAb")!=null)
		window.document.getElementById("lblvRicorsoAb").innerHTML = "";
	
	if(window.document.getElementById("lblvFurtoContenuto")!=null)
		window.document.getElementById("lblvFurtoContenuto").innerHTML = "";
		
	if(window.document.getElementById("lblvIncContenutoSa")!=null)
		window.document.getElementById("lblvIncContenutoSa").innerHTML = "";
	
	if(window.document.getElementById("lblvIncContenutoAb")!=null)
		window.document.getElementById("lblvIncContenutoAb").innerHTML = "";
	
	if(window.document.getElementById("lblvFurtoGioielli")!=null)
		window.document.getElementById("lblvFurtoGioielli").innerHTML = "";
	
	if(window.document.getElementById("lblvIncFabbricatoSa")!=null)
		window.document.getElementById("lblvIncFabbricatoSa").innerHTML = "";
}


/*
	PAGINA UTRegistrazioneDati
	Hide/Show element
*/

function UTRD_ShowHide(elem)
{
	if(document.getElementById(elem).style.display == 'none'){
		document.getElementById(elem).style.display = 'block';
	}
	else{
		document.getElementById(elem).style.display = 'none';
		document.getElementById('SelectDomRes').style.display = 'none';
		document.getElementById('chk_copia_cartacea').checked = false;
	}

}

function UTRD_ShowHideSelect( selectId, elem)
{
	
	if(document.getElementById(selectId).selectedValue=='0'){
		if(document.getElementById(elem).style.display!='block')
		{
			document.getElementById(elem).style.display = 'none';
		}
	}
	else
	{
		if(document.getElementById(elem).style.display=='none')
		{
			document.getElementById(elem).style.display = 'block';
		}
	}
	
}

function UTRD_ShowHideRadio( select, elem)
{
	
	if(select=='no')
		document.getElementById(elem).style.display = 'none';
	else
		document.getElementById(elem).style.display = 'block';		
}
