function debug(msg)
{var debug ="false";

if(ServerSide["enable_hda_model"] == "true")
  debug = "true";

if(debug=="true")
 	alert(msg); 
}
// INIZIO DISPLAY BOX LATERALE DESTRO   
function getFixedPosition(item) {
	var coords = new Object();
	coords.left=0;
	coords.top=0; 	
 
	while(item.offsetParent!=null) {
		coords.top+=   item.offsetTop;
		coords.left+=  item.offsetLeft;
		item = item.offsetParent;
	} 
   
   return coords;
 }
 
 
function showHdaInStep (step)
{    
  /*alert("showHdaInStep - Mvs.cod "	+ Vehicle.Mvs.code);
	alert("showHdaInStep - gestione hda mvs - " + getEnabledHdaMvs(Vehicle.Mvs.code));*/
	
  if(ServerSide["hda_enable"] != "true") return false;  
  //if(Vehicle.Model.hdaSenziente !="Y") return false;
  
  if(Vehicle.Model.hdaSenziente !="Y" && ServerSide["enable_hda_model"] != "true") return false;   
  
  if(step >1  ) return (Vehicle.Mvs.hdaSenziente=="Y" || getEnabledHdaMvs(Vehicle.Mvs.code))    
  
	return true;
} 
// ------------ INIZIO Gestione invattività mouse per HDA
var timerEnd = 240000; // Scadenza del timer espressa in millisecondi
var timerID = 0;
var tStart  = null;

var nEventi = 0;



function UpdateTimer_HDA() {
		var   tDate = null;
		if(!tStart){  
			tStart = tDate = new Date();
		}else{
			tDate = new Date();
		} 
		var   tDiff = tDate.getTime() - tStart.getTime();
		//Debug Timer HDA
		if(document.getElementById("timerHdaDebug")!=null){
			//document.getElementById("timerHdaDebug").innerHTML = "Time="+tDiff+" eventi eseguiti= "+nEventi;
			if(tDiff >= timerEnd){
					nEventi++;
					//document.getElementById("timerHdaDebug").innerHTML = "Time="+tDiff+" eventi eseguiti= "+nEventi;
			}   
		}
		//FINE Debug Timer HDA
		if(tDiff >= timerEnd){
			InvioHdaIdleEvent();
			ResetTimer_HDA();
		} 		
		timerID = setTimeout("UpdateTimer_HDA()", 1000); 		
}


function StartTimer_HDA() {
	timerID  = setTimeout("UpdateTimer_HDA()", 1000); 
}

function StopTimer_HDA() {
	//alert('stop');
	if(timerID) {
	  clearTimeout(timerID);
	  timerID  = 0;
	}
	tStart = null;
}

function ResetTimer_HDA(){
	tStart   = new Date(); 	
	//alert('reset');
}

//function ResetTimer_HDA() {}

function FirstStartTimer_HDA(){
	//alert('start inizialwe');
	StartTimer_HDA();
}

function InvioHdaIdleEvent() {
	
	if(getCodModel() != "" && getCodModel() != "150" && (inactivity_1Param_HDA.indexOf(Vehicle.Model.code) < 0)){
	
		//inactivity_1Param_HDA = getCodModel() + "_" + inactivity_1Param_HDA;
		// Gestisco eventuale undefined sul codice modello andando a recuperare il parametro nel Vehicle
			if(getCodModel()!="" && Vehicle.Model!=""){
				inactivity_1Param_HDA = Vehicle.Model.code + "_" + inactivity_1Param_HDA;
			}		
	}  
	
  var inactivity=inactivity_1Param_HDA+Vehicle.step+inactivity_2Param_HDA;
  if(showHdaInStep(Vehicle.step)){
    debug('inactivity('+inactivity+')');
    HDA.sendEvent(inactivity);
  }
}
// ------------ FINE Gestione invattività mouse per HDA
function boxDXCode() {

	var confDetailsString = '';

	var confDetailsStringS2 = ''+
				'<table width="100%">'+
					'<tr>'+
						'<td width="55%"><strong> - '+ServerSide["boxDetailBodyColor"]+':</strong></td>'+
						'<td width="45%">'+
							convertApici(Vehicle.MvsBodyColor.desc)+'<br>'+
							conditionalPrintCurrencySymbolBefore(Vehicle.MvsBodyColor.price, " ")+
						'</td>'+
					'</tr>'+
					'<tr>'+
						'<td width="55%"><strong> - '+ServerSide["boxDetailnnerPreparation"]+':</strong></td>'+
						'<td width="45%">'+
							convertApici(Vehicle.MvsInnerPreparation.desc)+'<br>'+
							conditionalPrintCurrencySymbolBefore(Vehicle.MvsInnerPreparation.price, " ")+
						'</td>'+
					'</tr>'+
					'<tr>'+
						'<td width="55%"><strong> - '+ServerSide["boxDetailRim"]+':</strong></td>'+
						'<td width="45%">'+
							convertApici(getCerchione().desc)+'<br>'+
							conditionalPrintCurrencySymbolBefore(getCerchione().price, " ")+
						'</td>'+
					'</tr>'+
				'</table>';

	var strOP = '';
	for (var VO in Vehicle.Optionals) {
		if (Vehicle.Optionals[VO].category != '-' && Vehicle.Optionals[VO].optType == 'O') {
			strOP += 
				'<tr>'+
					'<td valign="top" width="55%" ><strong> - ' + convertApici(Vehicle.Optionals[VO].desc)+'</strong></td>'+
					'<td width="45%">';
					var eventualPricePromo = calculateSingleOptPromoPrice(Vehicle.Optionals[VO].code);
					if (Vehicle.Optionals[VO].price != eventualPricePromo) {
          	strOP += '<s>'+conditionalPrintCurrencySymbolAfter(Vehicle.Optionals[VO].price, " ")+'</s>'+
										 '<br><b>'+ServerSide["boxOnPromotionLabelFE"]+'</b><br>'+conditionalPrintCurrencySymbolAfter(eventualPricePromo," ");
					} else {
						strOP += conditionalPrintCurrencySymbolAfter( Vehicle.Optionals[VO].price, " ");
					}
			strOP += 
					'</td>'+
				'</tr>';
		}
	}

	var confDetailsStringS3 = '';

	if (strOP != '') {
		confDetailsStringS3 += ''+
					'<table width="100%">'+
						strOP+
					'</table>';
	}

	switch(Vehicle.step) {
		case 1: break;
		case 2: 
			confDetailsString = confDetailsStringS2;
			break;
		case 3: 
			confDetailsString = confDetailsStringS2+confDetailsStringS3;
			break;
		case 4: break;
	}
 
    /*
		Attanasi - Inizio controllo se bisogna visualizzare l'HDA
    */

	if(showHdaInStep(Vehicle.step))
   { //manni
		CodiceHTML += "<table border=0 cellpadding=0 cellspancing=0  width=100% style='height:170px;'><tr><td valign='top' align='left' ><span  id='spacerDiv'></span></td></tr></table><br>";
	CodiceHTML += '';
	}
	/*
		Attanasi - Fine controllo se bisogna visualizzare l'HDA
    */
	
	
	CodiceHTML =
	'<table width="220" cellpadding="0" cellspacing="0" >'+
		'<tr>'+
			'<td><img src="' + ServerSide["imagePath"] + 'tua-auto-top.gif" /></td>'+
		'</tr>'+
		'<tr>'+
			'<td class="configurator-sideright">'+
				'<table width="100%" cellpadding="0" cellpadding="0">';
	
					if (getIncentiviValueByCode(Vehicle.Mvs.code,"INCENTIVI_ROTTAMAZIONE") != 0 && Vehicle.step == 2){
						rottamazioneBooleanFlag = ServerSide["rottamazione"];
						CodiceHTML +=
						'<tr style="visibility:collapse;display:none;"><td colspan="0">'+
						'<form name="rottamazioneForm" action=""><input type="checkbox" '+ (rottamazioneBooleanFlag==true ? " checked " :"") + '  name="rottamazioneField" value="" onclick="javascript:setRottamazioneSelected();"/></form>'+
						'</td></tr>';
					}
	
					CodiceHTML +=
					'<tr>'+
						'<td>'+
							'<img src="'+ServerSide["imageUploadPathFE"]+ServerSide["BoxYourCarTitleImageFE"]+'" />'+
						'</td>'+
					'</tr>'+
					'<tr>'+
						'<td>'+
							convertApici(Vehicle.Mvs.desc) +
						'</td>'+
					'</tr>'+
					'<tr>'+
						'<td>'+
							'<img src="' + ServerSide["imagePath"] + 'spacer.gif" height="16" />'+
						'</td>'+
					'</tr>'+
					'<tr>'+
						'<td>'+
							'<img src="'+ServerSide["imageUploadPathFE"]+ServerSide["BoxBasePriceTitleImageFE"]+'" />'+
						'</td>'+
					'</tr>';
						//20090203 AB Cr Incentivi Statali INIZIO
						// gestisco la renderizzazione custom nel caso in il prezzo del mvs selezionato venga modificato da  Incentivi o Bonus
						
						var incentivoPrice = getIncentiviMvsPrice(Vehicle.Mvs.code, Vehicle.Mvs.price , getRottamazioneSelected());
						
						if(incentivoPrice != calculatePrice('basicPrice')){
							CodiceHTML += '<tr><td>'+getPrezzoBaseBox(Vehicle.Mvs.code, Vehicle.Mvs.price , getRottamazioneSelected())+'</td></tr>';
						//20090203 AB Cr Incentivi Statali FINE  
						}else if(calculatePrice('basicPrice') != calculatePrice('basicPricePromo')) {
							CodiceHTML += '<tr><td><s>'+' '+conditionalPrintCurrencySymbolBefore(calculatePrice('basicPrice'), " ")+' '+ServerSide["boxPriceVatIncluded"]+'</s>'+
										  '<br><b>'+ServerSide["boxOnPromotionLabelFE"]+'</b><br>'+' '+conditionalPrintCurrencySymbolBefore(calculatePrice('basicPricePromo'), " ")+'</b> '+ServerSide["boxPriceVatIncluded"]+'</td></tr>';
						} else {
							CodiceHTML += '<tr><td>'+conditionalPrintCurrencySymbolBefore(calculatePrice('basicPrice'), " ")+' '+ServerSide["boxPriceVatIncluded"] + '</td></tr>';
						}
					CodiceHTML += 
						'<tr><td><img src="' + ServerSide["imagePath"] + 'spacer.gif" height="16" /></td></tr>'+
						'<tr><td><img src="'+ServerSide["imageUploadPathFE"]+ServerSide["BoxTotalPriceTitleImageFE"]+'" /></td></tr>';
						//20090203 AB Cr Incentivi Statali INIZIO
						if(incentivoPrice != calculatePrice('basicPrice')){
						CodiceHTML += conditionalPrintCurrencySymbolBefore(getIncentiviMvsPrice(Vehicle.Mvs.code, calculatePrice('totalPriceNoPromo') , getRottamazioneSelected()), " ")+' '+ServerSide["boxPriceVatIncluded"];
						//20090203 AB Cr Incentivi Statali FINE
						
						}else if (calculatePrice('totalPrice') != calculatePrice('totalPriceNoPromo')) {
							CodiceHTML += '<tr><td><s>'+conditionalPrintCurrencySymbolBefore(calculatePrice('totalPriceNoPromo'), " ")+ServerSide["boxPriceVatIncluded"]+'</s>'+
									'<br><b>'+ServerSide["boxOnPromotionLabelFE"]+'</b><br>'+' '+conditionalPrintCurrencySymbolBefore(calculatePrice('totalPrice'), " ")+ServerSide["boxPriceVatIncluded"] + '</tr></td>';
						} else {
							CodiceHTML += '<tr><td>'+conditionalPrintCurrencySymbolBefore(calculatePrice('totalPriceNoPromo'), " ")+' '+ServerSide["boxPriceVatIncluded"] + '</td></tr>';
						}
						// Uricchio
						//CodiceHTML += 
						//if(Vehicle.Mvs.desc){
						if(Vehicle.Model.code == '999999'){
							titoloSup   = 'Utilizza il nuovo servizio';
							titoloInf   = '"Click to call":';
							testo       = 'Inserisci il tuo numero e parli subito, gratuitamente, con un esperto Fiat  per prenotare il test drive o richiedere informazioni.';
							sospensione = '.............................................................';
							CodiceHTML += drawBoxCalcolatriceFinanziaria("left") +
									'</p><br>'+
												'</td>'+
								'</tr>'+
							  '</table>'+
						 
							  '<br>'+
							  
							  '<table border="1" cellspacing="0" cellpadding="0" width="100%">'+
							  '<tr>'+
								  '<td align="left">'+
									'<img border="0" name="clickCall_Step123" src="/FIAT_ITALIA/images/clickCall_Step123.gif" />'+
									//'<FONT FACE="Helvetica" SIZE="3" COLOR="#FF0000">'+titoloSup+'</FONT>'+
								  '</td>'+
							  '</tr>'+
							  /*'<tr>'+
								  '<td>'+
									'<FONT FACE="Helvetica" SIZE="3" COLOR="#FF0000">'+titoloInf+'</FONT>'+
								  '</td>'+
								'</tr>'+
							  */'<tr>'+
								  '<td class="txt">'+testo+
								  '</td>'+
							  '</tr>'+ 
							  '<tr>'+
								  '<td class="txt">'+sospensione+
								  '</td>'+
							  '</tr>'+ 
							  '<tr>'+
								  '<td align="center">'+
									'<a onclick="MM_openBrWindow(\'http://www.sitofono.com/cc/fiat_auto/\',\'pppShowroom\',\'width=360,height=450\')" '+
									   'href="#" '+
									   'onmouseover="document.images[\'clickCall\'].src=\'/FIAT_ITALIA/images/button_Over_State.png\'" '+
									   'onMouseOut="document.images[\'clickCall\'].src=\'/FIAT_ITALIA/images/button_Normal_State.png\'">'+
												'<img border="0" name="clickCall" src="/FIAT_ITALIA/images/button_Normal_State.png" />'+
									'</a>'+
								  '</td>'+
							  '</tr>'+ 
							  '</table>'+	  
							  
							  '<br>'+
							  
							  '<table border="0" cellspacing="0" cellpadding="0" width="100%" class="bk6">'+
								'<tr>'+
								  '<td class="txt" colspan="2">'+
													'<p style="margin:3px;"><img src="'+ServerSide["imageUploadPathFE"]+ServerSide["BoxConfDetailsTitleImageFE"]+'" class="img_bx10px"><br>'+
													confDetailsString+'</p><br>'+
												'</td>'+
								'</tr>'+
							  '</table>';
						}else{
							CodiceHTML += 
								'<tr><td id="boxCalcFinanziaria">' + drawBoxCalcolatriceFinanziaria("left") + '</td></tr>'+
								'<tr><td><img src="' + ServerSide["imagePath"] + 'spacer.gif" height="16" /></td></tr>'+
								'<tr>'+
									'<td>'+
										'<img src="'+ServerSide["imageUploadPathFE"]+ServerSide["BoxConfDetailsTitleImageFE"]+'" />'+
											confDetailsString + 
									'</td>'+
								'</tr>'+
								'<tr><td><img src="' + ServerSide["imagePath"] + 'spacer.gif" height="16" /></td></tr>';
						}
			CodiceHTML +=
						'</table>'+
					'</td>'+
				'</tr>'+
				'<tr>'+
					'<td><img src="' + ServerSide["imagePath"] + 'tua-auto-bottom.gif" /></td>'+
				'</tr>'+
			'</td>'+
		'</tr>'+
	'</table>';

	return CodiceHTML;
}
// FINE DISPLAY BOX LATERALE DESTRO




// Uricchio
// Box per calcolatrice finanziaria

function drawBoxCalcolatriceFinanziaria(alignment){
	var versione = Vehicle.Mvs.code;
	
	if(versione == undefined)
		versione = "-";
		
	if(arFinancing["finType_" + versione] == undefined)
		versione = "-";
		
	if(arFinancing["finType_" + versione] == undefined)
		versione = "null";
	
	var box = ServerSide["boxCalcFinanziaria_" + arFinancing["finType_" + versione]];
	// modificare label CC_BOX_CALC_FINANZIARIA_4 per modificare testo "Per saperne di piu'...."
	//for(var elemCode in arFinancing)
		//alert(elemCode);
	
	if(box == null)
		return "";
	
	if(alignment == undefined)
		alignment = "right";
	
	
	//20090203 AB Cr Incentivi INIZIO
	//var prezzo = conditionalPrintCurrencySymbolBefore(calculatePrice('totalPrice'), " ");
	var prezzo = 0;
	if(isIncentiviModelEnable()){
		prezzo = conditionalPrintCurrencySymbolBefore(calculatePrice('totalPriceIncentivi'), " ");
	}else{
		prezzo = conditionalPrintCurrencySymbolBefore(calculatePrice('totalPrice'), " ");
	}
	
	//20090203 AB Cr Incentivi FINE
	
	var anticipo = conditionalPrintCurrencySymbolBefore(arFinancing["finAnticipo_" + versione], " ");
	var spese = conditionalPrintCurrencySymbolBefore(arFinancing["finSpese_" + versione], " ");
	var speseRid = conditionalPrintCurrencySymbolBefore(arFinancing["finSpeseRid_" + versione], " ");
	var bolli = conditionalPrintCurrencySymbolBefore(arFinancing["finBolli_" + versione], " ");
	
	if(arFinancing["finMassimoFin_" + "-"] != undefined && arFinancing["finMassimoFin_" + "-"] != '0.0')
	{
		//prezzo=calculatePrice('totalPrice');
		//alert("prezzo: "+ prezzo + " maxfin: "+ arFinancing["finMassimoFin_" + "-"]+ " anticipo: "+arFinancing["finAnticipo_" + versione]);
		anticipo = prezzo - arFinancing["finMassimoFin_" + "-"];
		
		//if(arFinancing["finAnticipo_" + versione]=='0.0' || arFinancing["finAnticipo_" + versione] <= anticipo)
		//{
			//alert(arFinancing["finAnticipo_" + versione] +' minore di '+anticipo);
			//e non devo fare nulla
		//}
		//else 
		if(arFinancing["finAnticipo_" + versione] > anticipo)
		{
			//alert(arFinancing["finAnticipo_" + versione] +' maggiore di '+anticipo);
			anticipo = arFinancing["finAnticipo_" + versione];
			//setto il valore in arfinancing dentro anticipo
		}
		anticipo = conditionalPrintCurrencySymbolBefore(anticipo, " ");
	}
	
	box = box.replace("#prezzo#", prezzo);	
	box = box.replace("#anticipo#", anticipo);
	box = box.replace("#spese#", spese);
	box = box.replace("#speseRid#", speseRid);
	box = box.replace("#bolli#", bolli);
	box = box.replace("#numRate#", arFinancing["finDurata_" + versione]);
	box = box.replace("#numRate1#", arFinancing["finDurata1_" + versione]);
	box = box.replace("#numRate2#", arFinancing["finDurata2_" + versione]);
	//box = box.replace("#bolli#", bolli);
	//box = box.replace("#bolli#", bolli);
	//box = box.replace("#bolli#", bolli);
	
	// Inserimento delle spese
	box = box.replace("#spese#", spese);

	var str = box;
	
	//while(str.indexOf("<finRata>") != -1)
	getImportoRata();
		
	return str;
}

// Uricchio
// Comunicazione AJAX per calcolatrice finanziaria

function getImportoRataOld(){

	function handleStateChange(){
		if(xmlHttp.readyState==4 && xmlHttp.status==200){
			var obj = xmlHttp.responseXML;
	          	
	        var percAnticipo = obj.getElementsByTagName("perc_anticipo")[0].childNodes[0].nodeValue;  
	        	    	
	        var standardNode = obj.getElementsByTagName("standard")[0];  
	        var temp = standardNode.getElementsByTagName("tan");   
	        var tanStandard =(temp[0].childNodes[0].nodeValue);     	          	          	
	        temp = standardNode.getElementsByTagName("taeg");   
	        var taegStandard =(temp[0].childNodes[0].nodeValue);        
			temp = standardNode.getElementsByTagName("rata");   
	        var rataStandard =(temp[0].childNodes[0].nodeValue);                	
	        var doppioTassodNode = obj.getElementsByTagName("doppio_tasso")[0];  
			var temp = doppioTassodNode.getElementsByTagName("tan");   
	        var tanDoppioTasso =(temp[0].childNodes[0].nodeValue);     	          	          	
	        temp = doppioTassodNode.getElementsByTagName("taeg");   
	        var taegDoppioTasso =(temp[0].childNodes[0].nodeValue);        
			temp = doppioTassodNode.getElementsByTagName("rata1");   
	        var rata1DoppioTasso =(temp[0].childNodes[0].nodeValue);     
			temp = doppioTassodNode.getElementsByTagName("rata2");   
	        var rata2DoppioTasso =(temp[0].childNodes[0].nodeValue);            	         	
	        
	        var str = document.getElementById("boxCalcFinanziaria").innerHTML;
	        //alert(document.getElementById("boxCalcFinanziaria").innerHTML + " " + document.getElementById("boxCalcFinanziaria").innerHTML.indexOf("<finRata>"));

	        str = str.replace("#finRata#", conditionalPrintCurrencySymbolBefore(rataStandard, " "));
	        document.getElementById("boxCalcFinanziaria").innerHTML = str;
	        //alert(document.getElementById("boxCalcFinanziaria").innerHTML.indexOf("<finRata>"));
	        
	        var _hdnStdTan = document.getElementById("hdnStdTan");
	        var _hdnStdTaeg = document.getElementById("hdnStdTaeg");
	        var _hdnStdRata = document.getElementById("hdnStdRata");
	        
	        if(_hdnStdTan != null)
	        	document.body.removeChild(_hdnStdTan);
	        	
	        if(_hdnStdTaeg != null)
	        	document.body.removeChild(_hdnStdTaeg);
	        	
	        if(_hdnStdRata != null)
	        	document.body.removeChild(_hdnStdRata);
	        	
	        _hdnStdTan = document.createElement("HIDDEN");
	        _hdnStdTan.id = "hdnStdTan";
	        _hdnStdTan.value = tanStandard;
	        
	        _hdnStdTaeg = document.createElement("HIDDEN");
	        _hdnStdTaeg.id = "hdnStdTaeg";
	        _hdnStdTaeg.value = taegStandard;
	        
	        _hdnStdRata = document.createElement("HIDDEN");
	        _hdnStdRata.id = "hdnStdRata";
	        _hdnStdRata.value = rataStandard;
	        
	        document.body.appendChild(_hdnStdTan);
	        document.body.appendChild(_hdnStdTaeg);
	        document.body.appendChild(_hdnStdRata);
	        
		}
	}
	
	var xmlHttp;

  	if(window.ActiveXObject){
    	xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
	    xmlHttp = new XMLHttpRequest();
	}
	
	var qs = ServerSide["linkString"];
	qs+="&anticipo="+ServerSide["finAnticipo"];
	//20090203 AB CR Incentivi Statali INIZIO
	if(isIncentiviModelEnable()){
		qs+="&prezzo="+calculatePrice('totalPrice');
	}else{
		qs+="&prezzo="+ calculatePrice('totalPriceIncentivi') ;
	}
	//20090203 AB CR Incentivi Statali FINE
	qs+="&durataStandard="+ServerSide["finDurata"];
	qs+="&id="+Math.random();
	
	var url = "../calcolatriceFinanziaria/financingController.jsp";  	
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", qs.length);
	xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(qs);
}

function getImportoRata(){

	function handleStateChange(){
		if(xmlHttp.readyState==4 && xmlHttp.status==200){
			var obj = xmlHttp.responseXML;
	        
	        var modelloAuto = obj.getElementsByTagName("modello_auto")[0].childNodes[0].nodeValue;  
	        var versioneAuto = obj.getElementsByTagName("versione_auto")[0].childNodes.length > 0 ? obj.getElementsByTagName("versione_auto")[0].childNodes[0].nodeValue : "";  
	        var anticipo = obj.getElementsByTagName("anticipo")[0].childNodes[0].nodeValue;
	        //var spese = obj.getElementsByTagName("spese")[0].childNodes[0].nodeValue;
	        var defaultFin = obj.getElementsByTagName("default")[0].childNodes[0].nodeValue;
	        //alert("spese:"+spese);
	        var _hdnDefaultFin = document.getElementById("hdnDefaultFin");
	        if(_hdnDefaultFin == null){
	        	_hdnDefaultFin = document.createElement("HIDDEN");
	        	_hdnDefaultFin.id = "hdnDefaultFin";
	        	document.body.appendChild(_hdnDefaultFin);
	        }
	        _hdnDefaultFin.value = defaultFin;
	        
	        if(defaultFin == "standard"){
	        	var standardNode = obj.getElementsByTagName("standard")[0];  
				var temp = standardNode.getElementsByTagName("tan");
		        var tanStandard =(temp[0].childNodes[0].nodeValue);
		        temp = standardNode.getElementsByTagName("taeg");
	    	    var taegStandard =(temp[0].childNodes[0].nodeValue);
				temp = standardNode.getElementsByTagName("rata");
	        	var rataStandard =(temp[0].childNodes[0].nodeValue);
	        		        	
	        	var str = document.getElementById("boxCalcFinanziaria").innerHTML;
		       	
		        str = str.replace("#rata#", conditionalPrintCurrencySymbolBefore(rataStandard, " "));
		        str = str.replace("#tan#", tanStandard);
		        str = str.replace("#taeg#", taegStandard);
		        
		        document.getElementById("boxCalcFinanziaria").innerHTML = str;
		        		        
		        var _hdnStdTan = document.getElementById("hdnStdTan");
		        var _hdnStdTaeg = document.getElementById("hdnStdTaeg");
		        var _hdnStdRata = document.getElementById("hdnStdRata");
		        
		        if(_hdnStdTan != null)
		        	document.body.removeChild(_hdnStdTan);
		        	
		        if(_hdnStdTaeg != null)
		        	document.body.removeChild(_hdnStdTaeg);
		        	
		        if(_hdnStdRata != null)
		        	document.body.removeChild(_hdnStdRata);
		        	
		        _hdnStdTan = document.createElement("HIDDEN");
		        _hdnStdTan.id = "hdnStdTan";
		        _hdnStdTan.value = tanStandard;
		        
		        _hdnStdTaeg = document.createElement("HIDDEN");
		        _hdnStdTaeg.id = "hdnStdTaeg";
		        _hdnStdTaeg.value = taegStandard;
		        
		        _hdnStdRata = document.createElement("HIDDEN");
		        _hdnStdRata.id = "hdnStdRata";
		        _hdnStdRata.value = rataStandard;
		        
		        document.body.appendChild(_hdnStdTan);
		        document.body.appendChild(_hdnStdTaeg);
		        document.body.appendChild(_hdnStdRata);
	        	
	        }else if(defaultFin == "doppio_tasso"){
	        	var doppioTassodNode = obj.getElementsByTagName("doppio_tasso")[0];  
				var temp = doppioTassodNode.getElementsByTagName("tan");
		        var tanDoppioTasso =(temp[0].childNodes[0].nodeValue);
		        temp = doppioTassodNode.getElementsByTagName("tan1");
		        var tan1DoppioTasso =(temp[0].childNodes[0].nodeValue);
		        temp = doppioTassodNode.getElementsByTagName("tan2");
		        var tan2DoppioTasso =(temp[0].childNodes[0].nodeValue);
	    	    temp = doppioTassodNode.getElementsByTagName("taeg");
	        	var taegDoppioTasso =(temp[0].childNodes[0].nodeValue);
				temp = doppioTassodNode.getElementsByTagName("rata1");
		        var rata1DoppioTasso =(temp[0].childNodes[0].nodeValue);
				temp = doppioTassodNode.getElementsByTagName("rata2");
	        	var rata2DoppioTasso =(temp[0].childNodes[0].nodeValue);
	        	temp = doppioTassodNode.getElementsByTagName("durata1");
	        	var durata1DoppioTasso =(temp[0].childNodes[0].nodeValue);
	        	temp = doppioTassodNode.getElementsByTagName("durata2");
	        	var durata2DoppioTasso =(temp[0].childNodes[0].nodeValue);
	        	
	        	var str = document.getElementById("boxCalcFinanziaria").innerHTML;
		        	
				str = str.replace("#tan1#", tan1DoppioTasso);
		        str = str.replace("#tan2#", tan2DoppioTasso);
			     str = str.replace("#tanmedio#", tanDoppioTasso);
		        str = str.replace("#taeg#", taegDoppioTasso);
		        str = str.replace("#rata1#", conditionalPrintCurrencySymbolBefore(rata1DoppioTasso, " "));
		        str = str.replace("#rata2#", conditionalPrintCurrencySymbolBefore(rata2DoppioTasso, " "));
		        
		        document.getElementById("boxCalcFinanziaria").innerHTML = str;
		        
		        var _hdnRdtTan1 = document.getElementById("hdnRdtTan1");
		        var _hdnRdtTan2 = document.getElementById("hdnRdtTan2");
		        var _hdnRdtTanMedio = document.getElementById("hdnRdtTanMedio");
		        var _hdnRdtTaeg = document.getElementById("hdnRdtTaeg");
		        
		        var _hdnRdtRata1 = document.getElementById("hdnRdtRata1");
		        var _hdnRdtRata2 = document.getElementById("hdnRdtRata2");
		        
		        if(_hdnRdtTan1 != null)
		        	document.body.removeChild(_hdnRdtTan1);
		        	
	        	if(_hdnRdtTan2 != null)
		        	document.body.removeChild(_hdnRdtTan2);
	        	if(_hdnRdtTanMedio != null)
		        	document.body.removeChild(_hdnRdtTanMedio);
		        	
		        if(_hdnRdtTaeg != null)
		        	document.body.removeChild(_hdnRdtTaeg);
		        	
		        if(_hdnRdtRata1 != null)
		        	document.body.removeChild(_hdnRdtRata1);
		        	
		        if(_hdnRdtRata2 != null)
		        	document.body.removeChild(_hdnRdtRata2);
		        	
		        _hdnRdtTan1 = document.createElement("HIDDEN");
		        _hdnRdtTan1.id = "hdnRdtTan1";
		        _hdnRdtTan1.value = tan1DoppioTasso;
		        
		        _hdnRdtTan2 = document.createElement("HIDDEN");
		        _hdnRdtTan2.id = "hdnRdtTan2";
		        _hdnRdtTan2.value = tan2DoppioTasso;

		        _hdnRdtTanMedio = document.createElement("HIDDEN");
		        _hdnRdtTanMedio.id = "hdnRdtTanMedio";
		        _hdnRdtTanMedio.value = tanDoppioTasso;

				
		        _hdnRdtTaeg = document.createElement("HIDDEN");
		        _hdnRdtTaeg.id = "hdnRdtTaeg";
		        _hdnRdtTaeg.value = taegDoppioTasso;
		        	        
		        _hdnRdtRata1 = document.createElement("HIDDEN");
		        _hdnRdtRata1.id = "hdnRdtRata1";
		        _hdnRdtRata1.value = rata1DoppioTasso;
		        
		        _hdnRdtRata2 = document.createElement("HIDDEN");
		        _hdnRdtRata2.id = "hdnRdtRata2";
		        _hdnRdtRata2.value = rata2DoppioTasso;
		        
		        document.body.appendChild(_hdnRdtTan1);
		        document.body.appendChild(_hdnRdtTan2);
		        document.body.appendChild(_hdnRdtTanMedio);
		        document.body.appendChild(_hdnRdtTaeg);
		        document.body.appendChild(_hdnRdtRata1);
		        document.body.appendChild(_hdnRdtRata2);
		        
	        }else if(defaultFin == "rateale_new"){
	        	var ratealeNewNode = obj.getElementsByTagName("rateale_new")[0];  
				var temp = ratealeNewNode.getElementsByTagName("tan");
		        var tanRatealeNew =(temp[0].childNodes[0].nodeValue);
	    	    temp = ratealeNewNode.getElementsByTagName("taeg");
	        	var taegRatealeNew =(temp[0].childNodes[0].nodeValue);
				temp = ratealeNewNode.getElementsByTagName("rata1");
		        var rata1RatealeNew =(temp[0].childNodes[0].nodeValue);
				temp = ratealeNewNode.getElementsByTagName("rata2");
	        	var rata2RatealeNew =(temp[0].childNodes[0].nodeValue);
	        	temp = ratealeNewNode.getElementsByTagName("durata1");
	        	var durata1RatealeNew =(temp[0].childNodes[0].nodeValue);
	        	temp = ratealeNewNode.getElementsByTagName("durata2");
	        	var durata2RatealeNew =(temp[0].childNodes[0].nodeValue);
	        	
				//var sss=ratealeNewNode.getElementsByTagName("spese");
				//alert(sss[0].childNodes[0].nodeValue);
	        	var str = document.getElementById("boxCalcFinanziaria").innerHTML;
		        	
				str = str.replace("#tan#", tanRatealeNew);
		        str = str.replace("#taeg#", taegRatealeNew);
		        str = str.replace("#rata1#", conditionalPrintCurrencySymbolBefore(rata1RatealeNew, " "));
		        str = str.replace("#rata2#", conditionalPrintCurrencySymbolBefore(rata2RatealeNew, " "));
		        
		        document.getElementById("boxCalcFinanziaria").innerHTML = str;
		        
		        var _hdnRnwTan = document.getElementById("hdnRnwTan");
		        var _hdnRnwTaeg = document.getElementById("hdnRnwTaeg");
		        var _hdnRnwRata1 = document.getElementById("hdnRnwRata1");
		        var _hdnRnwRata2 = document.getElementById("hdnRnwRata2");
		        
		        if(_hdnRnwTan != null)
		        	document.body.removeChild(_hdnRnwTan);
		        	
		        if(_hdnRnwTaeg != null)
		        	document.body.removeChild(_hdnRnwTaeg);
		        	
		        if(_hdnRnwRata1 != null)
		        	document.body.removeChild(_hdnRnwRata1);
		        	
		        if(_hdnRnwRata2 != null)
		        	document.body.removeChild(_hdnRnwRata2);
		        	
		        _hdnRnwTan = document.createElement("HIDDEN");
		        _hdnRnwTan.id = "hdnRnwTan";
		        _hdnRnwTan.value = tanRatealeNew;
		        
		        _hdnRnwTaeg = document.createElement("HIDDEN");
		        _hdnRnwTaeg.id = "hdnRnwTaeg";
		        _hdnRnwTaeg.value = taegRatealeNew;
		        
		        _hdnRnwRata1 = document.createElement("HIDDEN");
		        _hdnRnwRata1.id = "hdnRnwRata1";
		        _hdnRnwRata1.value = rata1RatealeNew;
		        
		        _hdnRnwRata2 = document.createElement("HIDDEN");
		        _hdnRnwRata2.id = "hdnRnwRata2";
		        _hdnRnwRata2.value = rata2RatealeNew;
		        
		        document.body.appendChild(_hdnRnwTan);
		        document.body.appendChild(_hdnRnwTaeg);
		        document.body.appendChild(_hdnRnwRata1);
		        document.body.appendChild(_hdnRnwRata2);
	        } else if(defaultFin == "rateale_vgf"){
	        	var vgfNode = obj.getElementsByTagName("rateale_vgf")[0];  
				var temp = vgfNode.getElementsByTagName("tan");
		        var tanVgf =(temp[0].childNodes[0].nodeValue);
		        temp = vgfNode.getElementsByTagName("taeg");
	    	    var taegVgf =(temp[0].childNodes[0].nodeValue);
				temp = vgfNode.getElementsByTagName("rata");
	        	var rataVgf =(temp[0].childNodes[0].nodeValue);
	        	temp = vgfNode.getElementsByTagName("valore_garantito_futuro");
	        	var vgfVgf =(temp[0].childNodes[0].nodeValue);
	        		        	
	        	var str = document.getElementById("boxCalcFinanziaria").innerHTML;
		       	
		        str = str.replace("#rata#", conditionalPrintCurrencySymbolBefore(rataVgf, " "));
		        str = str.replace("#tan#", tanVgf);
		        str = str.replace("#taeg#", taegVgf);
		        str = str.replace("#vgf#", vgfVgf);
		        
		        document.getElementById("boxCalcFinanziaria").innerHTML = str;
		        		        
		        var _hdnVgfTan = document.getElementById("hdnVgfTan");
		        var _hdnVgfTaeg = document.getElementById("hdnVgfTaeg");
		        var _hdnVgfRata = document.getElementById("hdnVgfRata");
		        var _hdnVgfVgf = document.getElementById("hdnVgfVgf");
		        
		        if(_hdnVgfTan != null)
		        	document.body.removeChild(_hdnVgfTan);
		        	
		        if(_hdnVgfTaeg != null)
		        	document.body.removeChild(_hdnVgfTaeg);
		        	
		        if(_hdnVgfRata != null)
		        	document.body.removeChild(_hdnVgfRata);
		        	
	        	if(_hdnVgfVgf != null)
		        	document.body.removeChild(_hdnVgfVgf);
		        	
		        _hdnVgfTan = document.createElement("HIDDEN");
		        _hdnVgfTan.id = "hdnVgfTan";
		        _hdnVgfTan.value = tanVgf;
		        
		        _hdnVgfTaeg = document.createElement("HIDDEN");
		        _hdnVgfTaeg.id = "hdnVgfTaeg";
		        _hdnVgfTaeg.value = taegVgf;
		        
		        _hdnVgfRata = document.createElement("HIDDEN");
		        _hdnVgfRata.id = "hdnVgfRata";
		        _hdnVgfRata.value = rataVgf;
		        
		        _hdnVgfVgf = document.createElement("HIDDEN");
		        _hdnVgfVgf.id = "hdnVgfVgf";
		        _hdnVgfVgf.value = vgfVgf;
		        
		        document.body.appendChild(_hdnVgfTan);
		        document.body.appendChild(_hdnVgfTaeg);
		        document.body.appendChild(_hdnVgfRata);
		        document.body.appendChild(_hdnVgfVgf);
	        }
	        
	        
	        
		}
	}
	
	var xmlHttp;

  	if(window.ActiveXObject){
    	xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
	    xmlHttp = new XMLHttpRequest();
	}
	
	var qs = ServerSide["linkString"];
	qs+="&modello="+Vehicle.Model.code;
	if(Vehicle.Mvs.code != undefined)
		qs+="&versione="+Vehicle.Mvs.code;
	//aggiunto il 12-05-2008
	if(arFinancing["finMassimoFin_" + "-"] != undefined && arFinancing["finMassimoFin_" + "-"] != '0.0')
	{
		qs+="&maxFin="+arFinancing["finMassimoFin_" + "-"];
	}
	//20090203 AB Cr Incentivi Statali INIZIO
	if(isIncentiviModelEnable()){
		qs+="&prezzo="+calculatePrice('totalPriceIncentivi');
	}else{
	
		qs+="&prezzo="+calculatePrice('totalPrice');
	}
	//20090203 AB Cr Incentivi Statali FINE
	qs+="&id="+Math.random();
		
	var url = "./getFinanziamentoXML.jsp";  	
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", qs.length);
	xmlHttp.setRequestHeader("Connection", "close");
  xmlHttp.send(qs);
}

// Uricchio
// Visualizza il tooltip
function showTooltip(e){
	var versione = Vehicle.Mvs.code;
	
	if(versione == undefined)
		versione = "-";
		
	if(arFinancing["finType_" + versione] == undefined)
		versione = "-";
		
	if(arFinancing["finType_" + versione] == undefined)
		versione = "null";
		
	
		
	var newElem=document.createElement("DIV");
	newElem.id="nuovo";
	newElem.style.width="150px";
	newElem.style.backgroundColor = "yellow";
	
	//Qui
									
	var _ptable = document.createElement("TABLE");
	//_ptable.style.backgroundColor = "white";
	_ptable.style.borderTopStyle = "solid";
	_ptable.style.borderTopWidth = "1px";
	_ptable.style.borderBottomStyle = "solid";
	_ptable.style.borderBottomWidth = "1px";
	_ptable.style.borderLeftStyle = "solid";
	_ptable.style.borderLeftWidth = "1px";
	_ptable.style.borderRightStyle = "solid";
	_ptable.style.borderRightWidth = "1px";

	var _frow = document.createElement("TR");
	var _dcell = document.createElement("TD");
	_dcell.className = "calc";
	_dcell.style.borderBottomStyle = "solid";
	_dcell.style.borderBottomWidth = "1px";
	
	_dcell.innerHTML = "<b>" + ServerSide["boxCalcFinTooltipTitle"] + "</b>";
	_dcell.noWrap = true;
	
	_frow.appendChild(_dcell);
	_ptable.appendChild(_frow);
	
	_frow = document.createElement("TR");
	_dcell = document.createElement("TD");
	_dcell.className = "calc";
		
	var _strContent = ServerSide["boxCalcFinTooltipContent_" + arFinancing["finType_" + versione]];
	if(arFinancing["finMassimoFin_" + versione] != undefined && arFinancing["finMassimoFin_" + versione] != '0.0')
	{
		//qui devo aggiungere dei controlli x gestire l'anticipo che eventualmente viene settato dalla calc. fin.
		var dprezzo=calculatePrice('totalPriceIncentivi');
		//alert("prezzo: "+ prezzo + " maxfin: "+ arFinancing["finMassimoFin_" + "-"]+ " anticipo: "+arFinancing["finAnticipo_" + versione]);
		var anticipo = dprezzo - arFinancing["finMassimoFin_" + "-"];
		
		if(arFinancing["finAnticipo_" + versione]=='0.0' || arFinancing["finAnticipo_" + versione] <= anticipo)
		{
			_strContent = _strContent.replace("#importo#", conditionalPrintCurrencySymbolBefore(arFinancing["finMassimoFin_" + versione], " "));
			_strContent = _strContent.replace("#anticipo#", conditionalPrintCurrencySymbolBefore(calculatePrice('totalPriceIncentivi') - arFinancing["finMassimoFin_" + versione], " "));

		}
		else if(arFinancing["finAnticipo_" + versione] > anticipo)
		{
			//calcolo la differenza e la sottraggo al massimo finanziabile
			var scarto = arFinancing["finAnticipo_" + versione] - anticipo;
			//calcolo importo da finanziare
			_strContent = _strContent.replace("#importo#", conditionalPrintCurrencySymbolBefore(arFinancing["finMassimoFin_" + versione] - scarto, " "));
			_strContent = _strContent.replace("#anticipo#", conditionalPrintCurrencySymbolBefore(arFinancing["finAnticipo_" + versione], " "));

		}
		
		
	}
	else
	{
		_strContent = _strContent.replace("#anticipo#", conditionalPrintCurrencySymbolBefore(arFinancing["finAnticipo_" + versione], " "));
		_strContent = _strContent.replace("#importo#", conditionalPrintCurrencySymbolBefore(calculatePrice('totalPriceIncentivi') - arFinancing["finAnticipo_" + versione], " "));

	}
	
	var _hdnDefaultFin = document.getElementById("hdnDefaultFin");
	
	if(_hdnDefaultFin.value == "standard"){
		var _hdnStdTan = document.getElementById("hdnStdTan");
		var _hdnStdTaeg = document.getElementById("hdnStdTaeg");
		var _hdnStdRata = document.getElementById("hdnStdRata");
		
		_strContent = _strContent.replace(/#numRate#/g, arFinancing["finDurata_" + versione]);
		
		if(_hdnStdRata != null)
			_strContent = _strContent.replace(/#rata#/g, conditionalPrintCurrencySymbolBefore(_hdnStdRata.value, " "));
			
		if(_hdnStdTan != null)
			_strContent = _strContent.replace(/#tan#/g, _hdnStdTan.value);
			
		if(_hdnStdTaeg != null)
			_strContent = _strContent.replace(/#taeg#/g, _hdnStdTaeg.value);
		
	}else if(_hdnDefaultFin.value == "doppio_tasso"){
		var _hdnRdtRata1 = document.getElementById("hdnRdtRata1");	
		var _hdnRdtRata2 = document.getElementById("hdnRdtRata2");
		var _hdnRdtTan1 = document.getElementById("hdnRdtTan1");
		var _hdnRdtTan2 = document.getElementById("hdnRdtTan2");
		var _hdnRdtTanMedio = document.getElementById("hdnRdtTanMedio");
		var _hdnRdtTaeg = document.getElementById("hdnRdtTaeg");
		
		_strContent = _strContent.replace(/#numRate1#/g, arFinancing["finDurata1_" + versione]);
		_strContent = _strContent.replace(/#numRate2#/g, arFinancing["finDurata2_" + versione]);
		
		if(_hdnRdtRata1 != null)
			_strContent = _strContent.replace(/#rata1#/g, conditionalPrintCurrencySymbolBefore(_hdnRdtRata1.value, " "));
		
		if(_hdnRdtRata2 != null)
			_strContent = _strContent.replace(/#rata2#/g, conditionalPrintCurrencySymbolBefore(_hdnRdtRata2.value, " "));
			
		if(_hdnRdtTan1 != null)
			_strContent = _strContent.replace(/#tan1#/g, _hdnRdtTan1.value);
			
		if(_hdnRdtTan2 != null)
			_strContent = _strContent.replace(/#tan2#/g, _hdnRdtTan2.value);

		if(_hdnRdtTanMedio != null)
			_strContent = _strContent.replace(/#tanmedio#/g, _hdnRdtTanMedio.value);
			
		if(_hdnRdtTaeg != null)
			_strContent = _strContent.replace(/#taeg#/g, _hdnRdtTaeg.value);
	}else if(_hdnDefaultFin.value == "rateale_new"){
		var _hdnRnwTan = document.getElementById("hdnRnwTan");
		var _hdnRnwTaeg = document.getElementById("hdnRnwTaeg");
		var _hdnRnwRata1 = document.getElementById("hdnRnwRata1");
		var _hdnRnwRata2 = document.getElementById("hdnRnwRata2");
		
		_strContent = _strContent.replace(/#numRate1#/g, arFinancing["finDurata1_" + versione]);
		_strContent = _strContent.replace(/#numRate2#/g, arFinancing["finDurata2_" + versione]);
		
		if(_hdnRnwTan != null)
			_strContent = _strContent.replace(/#tan#/g, _hdnRnwTan.value);
			
		if(_hdnRnwTaeg != null)
			_strContent = _strContent.replace(/#taeg#/g, _hdnRnwTaeg.value);
			
		if(_hdnRnwRata1 != null)
			_strContent = _strContent.replace(/#rata1#/g, conditionalPrintCurrencySymbolBefore(_hdnRnwRata1.value, " "));
			
		if(_hdnRnwRata2 != null)
			_strContent = _strContent.replace(/#rata2#/g, conditionalPrintCurrencySymbolBefore(_hdnRnwRata2.value, " "));
	}else if(_hdnDefaultFin.value == "rateale_vgf"){
		var _hdnVgfTan = document.getElementById("hdnVgfTan");
		var _hdnVgfTaeg = document.getElementById("hdnVgfTaeg");
		var _hdnVgfRata = document.getElementById("hdnVgfRata");
		var _hdnVgfVgf = document.getElementById("hdnVgfVgf");
		
		_strContent = _strContent.replace(/#numRate#/g, arFinancing["finDurata_" + versione]);
		
		if(_hdnVgfRata != null)
			_strContent = _strContent.replace(/#rata#/g, conditionalPrintCurrencySymbolBefore(_hdnVgfRata.value, " "));
			
		if(_hdnVgfTan != null)
			_strContent = _strContent.replace(/#tan#/g, _hdnVgfTan.value);
			
		if(_hdnVgfTaeg != null)
			_strContent = _strContent.replace(/#taeg#/g, _hdnVgfTaeg.value);
			
		if(_hdnVgfVgf != null)
			_strContent = _strContent.replace(/#vgf#/g, _hdnVgfVgf.value);
		
	}
				
	
	
	_dcell.innerHTML = _strContent;
	
	_frow.appendChild(_dcell);
	_ptable.appendChild(_frow);
	
	
	
	//newElem.appendChild(_ptable);
	newElem.innerHTML = "<table style='BORDER-RIGHT: 1px solid black;BORDER-BOTTOM: 1px solid black;BORDER-LEFT: 1px solid black;BORDER-TOP: 1px solid black;BACKGROUND-COLOR:white'>" + _ptable.innerHTML + "</table>";

	var posX = e.clientX + 10 + document.body.scrollLeft;
	var screenWidthCenter = screen.width/2;
	var newElemWidth = newElem.style.width.substr(0, newElem.style.width.length - 2);
		
	if(posX > screenWidthCenter)
		posX = e.clientX - 90 + document.body.scrollLeft - newElemWidth;
	else
		posx = e.clientX + 10 + document.body.scrollLeft;
	
	newElem.style.left=posX;
	newElem.style.top=e.clientY + 10 + document.body.scrollTop;
	newElem.style.position="absolute";
	newElem.style.zIndex=1000;

	document.body.appendChild(newElem);
}

// Uricchio
// Nasconde il tooltip
function hideTooltip(){
	var oldElem = document.getElementById("nuovo");
	document.body.removeChild(oldElem);
}

// INIZIO DISPLAY IMMAGINI NUMERINI
function NumImgCode() {

	var headCode = 	'<table width="100%" class="menu-configurator">'+
						'<tr>';
	var footerCode = 
						'</tr>'+
					'</table>';

	S1 = 
				'<td ><img id="menc1" name="menc1" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseVersionLightImageFE"]+'" /></td>'+
				'<td ><img id="menc2" name="menc2" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseColorLightImageFE"]+'" /></td>'+
				'<td ><img id="menc3" name="menc3" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseOptionalLightImageFE"]+'" /></td>'+
				'<td ><img id="menc4" name="menc4" src="'+ServerSide["imageUploadPathFE"]+ServerSide["SummaryLightImageFE"]+'" /></td>';

	S2 = 
				
				'<td><a href="javascript:previousStep();"><img id="menc1" name="menc1" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseVersionDarkImageFE"]+'" /></a></td>'+
				'<td ><img id="menc2" name="menc2" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseColorLightImageFE"]+'" /></td>'+
				'<td ><img id="menc3" name="menc3" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseOptionalLightImageFE"]+'" /></td>'+
				'<td ><img id="menc4" name="menc4" src="'+ServerSide["imageUploadPathFE"]+ServerSide["SummaryLightImageFE"]+'" /></td>';

	S3 = 
				'<td><a href="javascript:firstStep();"><img id="menc1" name="menc1" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseVersionDarkImageFE"]+'" /></a></td>'+
				'<td ><a href="javascript:previousStep();"><img id="menc2" name="menc2" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseColorDarkImageFE"]+'" /></a></td>'+
				'<td ><img id="menc3" name="menc3" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseOptionalLightImageFE"]+'" /></td>'+
				'<td ><img id="menc4" name="menc4" src="'+ServerSide["imageUploadPathFE"]+ServerSide["SummaryLightImageFE"]+'" /></td>';
				
	S4 = 
				'<td><a href="javascript:firstStep();"><img id="menc1" name="menc1" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseVersionDarkImageFE"]+'" /></a></td>'+
				'<td ><img id="menc2" name="menc2" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseColorDarkImageFE"]+'" /></td>'+
				'<td ><a href="javascript:previousStep();"><img id="menc3" name="menc3" src="'+ServerSide["imageUploadPathFE"]+ServerSide["ChooseOptionalDarkImageFE"]+'" /></a></td>'+
				'<td ><img id="menc4" name="menc4" src="'+ServerSide["imageUploadPathFE"]+ServerSide["SummaryLightImageFE"]+'" /></td>';

	switch(Vehicle.step) {
		case 1: return headCode+S1+footerCode;
		break;
		case 2: return headCode+S2+footerCode;
		break;
		case 3: return headCode+S3+footerCode;
		break;
		case 4: return headCode+S4+footerCode;
		break;
	}
}
// FUNZIONE CHE TORNA IL CODICE HTML PER IL MENU IN ALTO A DESTRA TRA GLI STEP
function menuTopRightCode() {
	var codeHtml = 
			'<img src="'+ServerSide["imageUploadPathFE"]+ServerSide["modelDescImageFE"]+'"><br />';
	return codeHtml;
}

// FINE DISPLAY IMMAGINI NUMERINI

/*  Creates a formatted String from a number
*   @param numberToFormatN number to be formatted
*   @param decimalSeparator decimal separator
*   @param thousSeparator thousand separator
*   @numberOfDecimals if present is the fixed minimun number of decimals, can be null or empty string
*   @alwaysShowDecimals if false for integer numbers the decimal part is not returned, 
*   if true for integer numbers the decimal part is always returned */
function numberToFormattedString(numberToFormatN) {

	var decimalSeparator = ServerSide["decimalSeparator"];
	var thousSeparator = ServerSide["thousSeparator"];
	var numberOfDecimals = 2;
	var alwaysShowDecimals = true;

	var numberToFormat = "" + numberToFormatN;
	var intPart="";
	var decPart="";
	var formattedString="";
	var pointer=numberToFormat.indexOf(".");
	if(pointer == -1) {
		intPart=numberToFormat;
		decpart="";
	} else {
		intPart=numberToFormat.substring(0,pointer);
		decPart=numberToFormat.substring(pointer+1,numberToFormat.length);
	}
	//reversing
	var revString="";
	var cont=0;
	for(i=(intPart.length-1);i>=0;i--) {
		revString+=intPart.charAt(i);
		cont++;
		if (cont%3==0 && cont!=0 && i!=0) {
			revString+=thousSeparator;
		}
	}
	//assembling intPart
	for(i=(revString.length-1);i>=0;i--) {
		formattedString += revString.charAt(i);
	}
	//assembling decPart
	var decNum;
	if (numberOfDecimals==null) numberOfDecimals="";
	decNum=parseInt(numberOfDecimals);
	if (isNaN(decNum)) decNum=-1; 
	if (pointer!=-1) {
		formattedString+=decimalSeparator;
		formattedString+=decPart;
		for (i=decPart.length;i<decNum;i++) {
			formattedString+="0";
		}
	} else {
		if (alwaysShowDecimals && decNum>0) {
			formattedString+=decimalSeparator;
			for (i=decPart.length;i<decNum;i++) {
				formattedString+="0";
			}
		}
	}
	return formattedString;
}

// INIZIO FUNZIONE CHE GESTISCE I BORDI ROSSI DELLE IMMAGINI DEI CERCHIONI
var idImg = '0';

function setBorderRedImg(imgNum) {
	if (idImg != '0') {
		document.getElementById("CCimg"+idImg).style.border = 'transparent';
	}
	document.getElementById("CCimg"+imgNum).style.border = '1px solid #cc0000';
	idImg = imgNum;
}
// FINE FUNZIONE CHE GESTISCE I BORDI ROSSI DELLE IMMAGINI DEI CERCHIONI

// INIZIO FUNZIONE CHE TORNA UN'ARRAY DI OGGETTI OPTIONAL DELLA STESSA CATEGORIA
function getOptByCategory(cat) {
	var outList = new Array();
	indC = 0;
	for (c = 0; c < OptionalList.length; c++) {
		if (OptionalList[c].category == cat) {
			outList[indC] = OptionalList[c];
			indC++;
		}
	}
	return outList;
}
// FINE FUNZIONE CHE TORNA UN'ARRAY DI OGGETTI OPTIONAL DELLA STESSA CATEGORIA

// INIZIO FUNZIONE CHE TORNA UN'ARRAY DI OGGETTI OPTIONAL DELLA STESSA CATEGORIA di OPT STANDARD
function getStandardOptByCategory(cat) {
	var outList = new Array();
	indC = 0;
	for (c = 0; c < StandardOptionalList.length; c++) {
		if (StandardOptionalList[c].category == cat) {
			outList[indC] = StandardOptionalList[c];
			indC++;
		}
	}
	for (var VO in Vehicle.Optionals) {
		if(Vehicle.Optionals[VO].optType == 'X' && Vehicle.Optionals[VO].category == cat){
			outList.push(Vehicle.Optionals[VO]);
		}
	}
	return outList;
}
// FINE FUNZIONE CHE TORNA UN'ARRAY DI OGGETTI OPTIONAL DELLA STESSA CATEGORIA di OPT STANDARD

// INIZIO FUNZIONE CHE A PARTIRE DA LISTA DI OGGETTI E CODICE TORNA LA NUOVA LISTA VINCOLATA
function getConstrainEsclusive(objList,code) {

	var outL = new Array();
	var cnt = 0;
	var constrain = false;
	var insert = true;

	for (var ce in IPEsclusiveByBC) {
		if (code == ce) {	
			for (i = 0; i < objList.length; i++) {
				insert = true;
				for (k = 0; k < IPEsclusiveByBC[ce].length; k++) {
					if (IPEsclusiveByBC[ce][k] == objList[i].code) {
						insert = false;
						break;
					}
				}
				if (insert) {
					outL[cnt] = objList[i];
					cnt++;
				}
			}
			constrain = true;
		}
	}

	if (constrain) return outL;
	else return objList;
}
// FINE FUNZIONE CHE A PARTIRE DA LISTA DI OGGETTI E CODICE TORNA LA NUOVA LISTA VINCOLATA

// INIZIO FUNZIONE CHE DICE SE UN DETERMINATO OPTIONAL PUO' ESSERE INCLUSO
function toBeIncluded(optCode) {
	var oia = new Array();
	oia[0] = true;
	var qq = '';
	for(var Ox in Vehicle.Optionals) {
		// Uricchio
		// Aggiunto la condizione per non eseguire la compatibilità dello stesso optional
		if (Ox != optCode && !areOtpionalsCompatible(Ox, optCode)) {
			oia[0] = false;
			qq += Vehicle.Optionals[Ox].code+'|';
		}
	}
	if (qq != '') oia[1] = qq.substring(0,qq.length - 1);
	else oia[1] = qq;
	return oia;
}
// FINE FUNZIONE CHE DICE SE UN DETERMINATO OPTIONAL PUO' ESSERE INCLUSO

// INIZIO FUNZIONE CHE DICE SE UN DETERMINATO OPTIONAL DEVE PER FORZA ESSERE INCLUSO
function mustInclude(optCode) {
	// Uricchio David
	// Richiamo del nuovo metodo
	// return mustInclude2(optCode);
	return mustInclude3(optCode);
	
	var oia = false;
	if (!OptInclusive[optCode]) {
		return oia;
	}

	for(var Ex in OptInclusive) {
		if (Ex == optCode) {
			for (var ii = 0; ii < OptInclusive[Ex].length; ii++) {
				if (Vehicle.Optionals[OptInclusive[Ex][ii]] == null) {
					oia = true;
				}
			}
		}
	}
	return oia;
}
// FINE FUNZIONE CHE DICE SE UN DETERMINATO OPTIONAL DEVE PER FORZA ESSERE INCLUSO

// INIZIO FUNZIONE CHE DICE SE UN DETERMINATO OPTIONAL DEVE PER FORZA ESSERE INCLUSO SU REMOVE DELLO STESSO
function mustIncludeRem(optCode) {

	var oea = false;
	for(var Ex in OptInclusive) {
		for (var ee = 0; ee < OptInclusive[Ex].length; ee++) {
			if (OptInclusive[Ex][ee] == optCode && Vehicle.Optionals[Ex] != null) {
				oea = true;
			}
		}
	}
	return oea;
}
// FINE FUNZIONE CHE DICE SE UN DETERMINATO OPTIONAL DEVE PER FORZA ESSERE INCLUSO SU REMOVE DELLO STESSO

// INIZIO FUNZIONE CHE TORNA IL CERCHIONE CORRENTE DEL VEICOLO
function getCerchione() {
	var cerchioObj = new Object();
	for (var VO in Vehicle.Optionals) {
		if (Vehicle.Optionals[VO].category == '-') {
			cerchioObj = Vehicle.Optionals[VO];
		}
	}
	return cerchioObj;
}
// FINE FUNZIONE CHE TORNA IL CERCHIONE CORRENTE DEL VEICOLO

// INIZIO FUNZIONE CHE TORNA TUTTI GLI OPTIONALS CORRENTI DEL VEICOLO TRANNE I CERCHIONI
function getVehicleOpts() {
	for(var index in optStdExList){
		if(optStdExList[index].action=='A'){
			addOptional(optStdExList[index].code);
		}
	}
	var allObj = new Array();
	for (var VO in Vehicle.Optionals) {
		if (Vehicle.Optionals[VO].category != '-') {
			allObj[VO] = Vehicle.Optionals[VO];
		}
	}
	return allObj;
}
// FINE FUNZIONE CHE TORNA TUTTI GLI OPTIONALS CORRENTI DEL VEICOLO TRANNE I CERCHIONI

// INIZIO FUNZIONE CHE TORNA IL CODICE DELLE IMMAGINI PER PASSARE DI STEP
function footerTasti() {

	var testoLegale="<b>Ce site Internet a &eacute;t&eacute; con&ccedil;u le plus soigneusement possible : n&eacute;anmoins ni l&#39;exactitude ni la justesse des informations qu&#39;il comporte ne peuvent &ecirc;tre garanties. Aucune responsabilit&eacute; ne peut donc &ecirc;tre engag&eacute;e pour quelque dommage que ce soit r&eacute;sultant directement ou indirectement de l&#39;utilisation de ce site Internet.</b>";
	
	cod = "";
	switch (Vehicle.step)
	{
		case 1:
			cod = footerTastiStep1();
			cod +='</tr><tr>&nbsp;</tr><tr><td colspan="3">'+testoLegale+'<br/><br/></td></tr>';
			break;
		case 2:
			cod = footerTastiStep2();
			cod +='</tr><tr>&nbsp;</tr><tr><td colspan="3">'+testoLegale+'<br/><br/></td></tr>';
			break;
		case 3:
			cod = footerTastiStep3();
			cod +='</tr><tr>&nbsp;</tr><tr><td colspan="3">'+testoLegale+'<br/><br/></td></tr>';
			break;
	}
	
	//cod += '<i>test text</i><br/><br/>';
	
	return cod;
}
function footerTastiStep1()
{
	cod += 
	'<tr>'+
		'<td><img src="' + ServerSide["imagePath"] + 'spacer.gif" height="10" /></td>'+
		'<td><img src="' + ServerSide["imagePath"] + 'spacer.gif" height="10" /></td>';
		if (flagNextStep) {
			if (Vehicle.step != 4) cod += '<td style="vertical-align:bottom"><a href="javascript:nextStep();" class="greenIconLink">Continuez</a></td>';
			else cod += '<td>&nbsp;</td>';
		} else {
			if (Vehicle.step != 4) cod += '<td style="vertical-align:bottom"><a href="javascript:errorAlert();" class="greenIconLink">Continuez</a></td>';
			else cod += '<br>&nbsp;<br>';
		}

	cod +=
	'</tr>';
	
	return cod;
}

function footerTastiStep2()
{
	cod = 
	'<tr>'+
		'<td><img src="' + ServerSide["imagePath"] + 'spacer.gif" height="4px" /></td>';
		if (flagNextStep) {
			cod += '<td><a href="javascript:nextStep();" class="greenIconLink" style="float:right">Continuez</a></td>';
		} else {
			cod += '<td style="vertical-align:bottom"><a href="javascript:errorAlert();" class="greenIconLink">Continuez</a></td>';
		}
	cod +=
	'</tr>';
	return cod;
}

function footerTastiStep3()
{
	cod = 
	'<tr>'+
		'<td><img src="' + ServerSide["imagePath"] + 'spacer.gif" height="4px" /></td>';
		if (flagNextStep) {
			cod += '<td><a href="javascript:nextStep();" class="greenIconLink" style="float:right">Continuez</a></td>';
		} else {
			cod +=	'<td><img src="' + ServerSide["imagePath"] + 'spacer.gif" height="10" /></td>'+
					'<td style="vertical-align:bottom"><a href="javascript:errorAlert();" class="greenIconLink">Continuez</a></td>';
		}
	cod +=
	'</tr>';
	return cod;
}

function goToPageTop()
{
	var html = "";
	html +=
	'<tr><td><img src="' + ServerSide["imagePath"] + 'spacer.gif" height="16" /></td></tr>'+
	'<tr>'+
		'<td>'+
			'<table class="config-ft-menu" width="100%">'+
				'<tr>'+
					'<td><img src="' + ServerSide["imagePath"] + 'spacer.gif" /></td>'+
					'<td align="right" width="200"><strong><a href="#">' + ServerSide["backToTopPageFE"] + ' ^</a></strong></td>'+
				'</tr>'+
			'</table>'+
		'</td>'+
	'</tr>';
	return html;
}
function goToPageTopStep4()
{
	var html = "";
	html += '<td align="right" width="200"><strong><a href="#">' + ServerSide["backToTopPageFE"] + ' ^</a></strong></td>';
	return html;
}
// FINE FUNZIONE CHE TORNA IL CODICE DELLE IMMAGINI PER PASSARE DI STEP

// INIZIO FUNZIONE CHE STABILISCE SE AGGIUNGERE O ELIMINARE UN OPTIONALS IN BASE AL CHECKED
function addOrRemoveOpt(cod, obc) {
	if (obc.checked) mvsOptAdded(cod);
	else mvsOptRemoved(cod);
}
// FINE FUNZIONE CHE STABILISCE SE AGGIUNGERE O ELIMINARE UN OPTIONALS IN BASE AL CHECKED

// INIZIO FUNZIONE CHE CONTROLLA IL POPUP ALERT SUGLI OPTIONALS
function checkCons(cod, stc) {
	mvsOptAdded(cod);
}
// FINE FUNZIONE CHE CONTROLLA IL POPUP ALERT SUGLI OPTIONALS

// INIZIO FUNZIONE CHE STABILISCE SE AGGIUNGERE O ELIMINARE UNA PROMOZIONE IN BASE AL CHECKED
function addOrRemovePromo(codP, obcP) {
	if (obcP.checked) mvsPromoAdded(codP);
	else mvsPromoRemoved(codP);
}
// FINE FUNZIONE CHE STABILISCE SE AGGIUNGERE O ELIMINARE UNA PROMOZIONE IN BASE AL CHECKED

// INIZIO FUNZIONE CHE APRE IL POPUP CHE SPIEGA CHE NON SI PUO' PROSEGUIRE
function errorAlert() {
	//Attanasi - Inizio Modifiche  per HDA  
		
	if(showHdaInStep(Vehicle.step))
	{ 		   		    	                          
		   if(getCodModel() != "" && (onClickStep3PopUpHDA.indexOf(getCodModel()) < 0))
		      onClickStep3PopUpHDA = getCodModel() + "_" + onClickStep3PopUpHDA;
		     
		   HDA.sendEvent(onClickStep3PopUpHDA,'PopUpFlag=true');
			 debug( 'onClick('+onClickStep3PopUpHDA+',PopUpFlag=true) - SendEvent per Pop-up: "Non si Può Proseguire"');
	}
	
	//Attanasi - Fine Modifiche  per HDA  
	var finestraA = window.open('about:blank','popappeA','width=600,height=250,scrollbars=no');
	finestraA.document.open();
	finestraA.document.write(errorAlertHTML());
	finestraA.document.close();
	finestraA.focus();
}
// FINE FUNZIONE CHE APRE IL POPUP CHE SPIEGA CHE NON SI PUO' PROSEGUIRE

// !!!!!!!! INIZIO FUNZIONE CHE APRE IL POPUP PER I VINCOLI SUGLI OPTIONALS -- DEPRECATA !!!!!!!!!!!!!!!!!!!!!!!!!
function optWindowDetails(copt, strEsc, strInc) {
	
	//Attanasi - Inizio Modifiche  per HDA  (Invio di un sendEvent quando viene lanciato un Pop-Up )
	if(showHdaInStep(Vehicle.step))
	{ 
		if(getCodModel() != "" && (onClickStep3PopUpHDA.indexOf(getCodModel()) < 0))
		     onClickStep3PopUpHDA = getCodModel() + "_" + onClickStep3PopUpHDA;
		     
 	  HDA.sendEvent(onClickStep3PopUpHDA,'PopUpFlag=true');
		debug( 'onClick('+onClickStep3PopUpHDA+',PopUpFlag=true) - SendEvent per VINCOLI SUGLI OPTIONALS');
	}
	//Attanasi - Fine Modifiche  per HDA  


	var finestraB = window.open('about:blank','popappeB','width=600,height=350,scrollbars=yes');
	finestraB.document.open();
	finestraB.document.write(optWindowDetailsHTML(copt, strEsc, strInc));
	finestraB.document.close();
	finestraB.focus();
}
// !!!!!!!! FINE FUNZIONE CHE APRE IL POPUP PER I VINCOLI SUGLI OPTIONALS -- DEPRECATA !!!!!!!!!!!!!!!!!!!!!!!!!

// INIZIO FUNZIONE CHE APRE IL POPUP PER I VINCOLI INCLUSIVI SUGLI OPTIONALS
function optWindowDetailsInc(copt, tree) {
	//Attanasi - Inizio Modifiche  per HDA  (Invio di un sendEvent quando viene lanciato un Pop-Up )
	if(showHdaInStep(Vehicle.step))
	{	 
		if(getCodModel() != "" && (onClickStep3PopUpHDA.indexOf(getCodModel()) < 0))
		     onClickStep3PopUpHDA = getCodModel() + "_" + onClickStep3PopUpHDA;
		     
		HDA.sendEvent(onClickStep3PopUpHDA,'PopUpFlag=true');
		debug( 'onClick('+onClickStep3PopUpHDA+',PopUpFlag=true) - SendEvent per VINCOLI INCLUSIVI SUGLI OPTIONALS');
	}
	//Attanasi - Fine Modifiche  per HDA  
	var finestraC = window.open('about:blank','popappeC','width=600,height=350,scrollbars=yes');
	finestraC.document.open();
	finestraC.document.write(optWindowDetailsIncHTML(copt, tree));
	finestraC.document.close();
	finestraC.focus();   
}
// FINE FUNZIONE CHE APRE IL POPUP PER I VINCOLI INCLUSIVI SUGLI OPTIONALS

// INIZIO FUNZIONE CHE APRE IL POPUP PER I VINCOLI ESCLUSIVI SUGLI OPTIONALS
function optWindowDetailsEsc(copt, lista) {
//Attanasi - Inizio Modifiche  per HDA  (Invio di un sendEvent quando viene lanciato un Pop-Up )
	if(showHdaInStep(Vehicle.step))	
	{	 
		 if(getCodModel() != "" && (onClickStep3PopUpHDA.indexOf(getCodModel()) < 0))
		     onClickStep3PopUpHDA = getCodModel() + "_" + onClickStep3PopUpHDA;
		     
		 HDA.sendEvent(onClickStep3PopUpHDA,'PopUpFlag=true');
		 debug( 'onClick('+onClickStep3PopUpHDA+',PopUpFlag=true) - SendEvent per VINCOLI ESCLUSIVI SUGLI OPTIONALS');
	}
	//Attanasi - Fine Modifiche  per HDA 
	
	var finestraC = window.open('about:blank','popappeC','width=600,height=350,scrollbars=yes');
	finestraC.document.open();
	finestraC.document.write(optWindowDetailsEscHTML(copt, lista));
	finestraC.document.close();
	finestraC.focus();
}
// FINE FUNZIONE CHE APRE IL POPUP PER I VINCOLI ESCLUSIVI SUGLI OPTIONALS

// INIZIO FUNZIONE CHE APRE IL POPUP PER I VINCOLI INCLUSIVI SUGLI OPTIONALS RIMOSSI
function optWindowDetailsIncRem(copt, lista) {
	if(showHdaInStep(Vehicle.step))
	{	 
		if(getCodModel() != "" && (onClickStep3PopUpHDA.indexOf(getCodModel()) < 0))
		     onClickStep3PopUpHDA = getCodModel() + "_" + onClickStep3PopUpHDA;
		     
		HDA.sendEvent(onClickStep3PopUpHDA,'PopUpFlag=true');
		debug( 'onClick('+onClickStep3PopUpHDA+',PopUpFlag=true) - SendEvent per VINCOLI INCLUSIVI SUGLI OPTIONALS RIMOSSI');
	}
	//Attanasi - Fine Modifiche  per HDA 
	
	var finestraD = window.open('about:blank','popappeD','width=600,height=350,scrollbars=yes');
	finestraD.document.open();
	finestraD.document.write(optWindowDetailsIncRemHTML(copt, lista));
	finestraD.document.close();
	finestraD.focus();
}
// FINE FUNZIONE CHE APRE IL POPUP PER I VINCOLI INCLUSIVI SUGLI OPTIONALS RIMOSSI

// INIZIO FUNZIONE CHE TORNA IL CODICE DA INSERIRE NEL POPUP DEGLI OPTIONALS CON VINCOLI INCLUSIVI
function optWindowDetailsIncHTML(copt, tree) {

	var stro = '';

	stro+= 
			'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+
			'<html xmlns="http://www.w3.org/1999/xhtml">'+
			'<head>'+
				'<title>FIAT</title>'+
				'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'+
				'<link href="'+ServerSide["stylePath"]+'fiat.css" rel="styleSheet" type="text/css">'+
				'<script language="javascript" src="'+ServerSide["jsPath"]+'fiat.js" type="text/javascript"></script>'+
				'<script language="javascript">'+
				'var ri = \'0\';'+
					'function gettI(fob) {'+
						'if (fob.grpOpt.value == "0") { ri = "0"; }'+
						'else {'+
							'for(var i = 0;i < fob.grpOpt.length; i++) {'+
								'if (fob.grpOpt[i].checked) ri = fob.grpOpt[i].value;'+
							'}'+
						'}'+
						'return ri;'+
					'}'+
				'</script>'+
			'</head>'+
			'<body style="background:none;" onblur="javascript:window.focus();">'+
				'<table class="popup">'+
					'<tr>'+
						'<td>'+
							'<table width="100%">'+
								'<tr>'+
									'<td align="left"><img src="'+ServerSide["imageUploadPathFE"]+ServerSide["page3PTitleImageFE"]+'" width="220" height="26" alt="Per saperne di piu" /></td>'+
								'</tr>'+
							'</table>'+
						'</td>'+
					'</tr>'+
					'<tr><td><img src="'+ServerSide["imagePath"]+'popup_separator.jpg" width="570" height="32" alt="popup separator" /></td></tr>'+
					'<tr>'+
						'<td>'+
							'<table class="main-pop2">'+
								'<tr>'+
									'<td>'+
										'<table width="100%">'+
											'<th>'+ServerSide["page3PH1"]+'</th>'+
											'<tr><td>'+convertApici(getOptionalFromCode(copt).desc)+'</td></tr>'+
											'<tr><td><img src="'+ServerSide["imagePath"]+'spacer.gif" height="16" /></td></tr>'+
										'</table>'+
									'</td>'+
								'</tr>'+
								'<tr>'+
									'<td>'+
										'<table width="100%">'+
											'<th colspan="2">'+ServerSide["page3PH2I"]+'</th>'+
											getGroupOptIncHTML(tree)+
											'<tr><td colspan="2"><img src="'+ServerSide["imagePath"]+'spacer.gif" height="10" /></td></tr>'+
										'</table>'+
									'</td>'+
								'</tr>'+
								'<tr>'+
									'<th style="text-align:right; vertical-align:middle">'+ServerSide["page3PDescI"]+' <img src="'+ServerSide["imagePath"]+'popupSi.gif" width="30" height="19" onclick="javascript:window.opener.indexGRP=gettI(document.grFo);window.opener.mvsOptGroupAdded();window.close();" alt="si" style="cursor:hand;" /><img src="'+ServerSide["imagePath"]+'popupNo.gif" width="30" height="19" alt="no" onclick="javascript:window.close();" onclick="javascript:window.opener.indexGRPEsc=0;window.opener.mvsOptGroupRemoved(true);window.close();" style="cursor:hand;"/></th>'+
								'</tr>'+
							'</table>'+
						'</td>'+
					'</tr>'+
				  	'<tr>'+
						'<td colspan="2">'+
							'<img src="'+ServerSide["imagePath"]+'spacer.gif" height="40" />'+
						'</td>'+
					'</tr>'+
					'<tr>'+
						'<td>'+
							'<img src="'+ServerSide["imagePath"]+'popup_separator.jpg" width="570" height="32" alt="popup separator" />'+
						'</td>'+
					'</tr>'+
					'<tr><td align="right"><a href="#" onClick="close_window();" class="popup-close">chiudi</a></td></tr>'+
				'</table>'+
			'</body>'+
		'</html>';

	return stro;

}
// FINE FUNZIONE CHE TORNA IL CODICE DA INSERIRE NEL POPUP DEGLI OPTIONALS CON VINCOLI INCLUSIVI

// INIZIO FUNZIONE CHE TORNA IL CODICE DA INSERIRE NEL POPUP DEGLI OPTIONALS CON VINCOLI ESCLUSIVI
function optWindowDetailsEscHTML(copt, tree) {

	var stro = '';

	stro+= 
			'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+
			'<html xmlns="http://www.w3.org/1999/xhtml">'+
			'<head>'+
				'<title>FIAT</title>'+
				'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'+
				'<link href="'+ServerSide["stylePath"]+'fiat.css" rel="styleSheet" type="text/css">'+
				'<script language="javascript" src="'+ServerSide["jsPath"]+'fiat.js" type="text/javascript"></script>'+
			'</head>'+
			'<body style="background:none;" onblur="javascript:window.focus();">'+
				'<table class="popup">'+
					'<tr>'+
						'<td>'+
							'<table width="100%">'+
								'<tr>'+
									'<td align="left"><img src="'+ServerSide["imageUploadPathFE"]+ServerSide["page3PTitleImageFE"]+'" width="220" height="26" alt="Per saperne di piu" /></td>'+
								'</tr>'+
							'</table>'+
						'</td>'+
					'</tr>'+
					'<tr><td><img src="'+ServerSide["imagePath"]+'popup_separator.jpg" width="570" height="32" alt="popup separator" /></td></tr>'+
					'<tr>'+
						'<td>'+
							'<table class="main-pop2">'+
								'<tr>'+
									'<td>'+
										'<table width="100%">'+
											'<th>'+ServerSide["page3PH1"]+'</th>'+
											'<tr><td>'+convertApici(getOptionalFromCode(copt).desc)+'</td></tr>'+
											'<tr><td><img src="'+ServerSide["imagePath"]+'spacer.gif" height="16" /></td></tr>'+
										'</table>'+
									'</td>'+
								'</tr>'+
								'<tr>'+
									'<td>'+
										'<table width="100%">'+
											'<th colspan="2">'+ServerSide["page3PH2E"]+'</th>'+
											getGroupOptEscHTML(tree)+
											'<tr><td colspan="2"><img src="'+ServerSide["imagePath"]+'spacer.gif" height="10" /></td></tr>'+
										'</table>'+
									'</td>'+
								'</tr>'+
								'<tr>'+
									'<th style="text-align:right; vertical-align:middle">'+ServerSide["page3PDescE"]+' <img src="'+ServerSide["imagePath"]+'popupSi.gif" width="30" height="19" onclick="javascript:window.opener.indexGRPEsc=0;window.opener.mvsOptGroupRemoved(true);window.close();" alt="si" style="cursor:hand;" /><img src="'+ServerSide["imagePath"]+'popupNo.gif" width="30" height="19" alt="no" onclick="javascript:window.close();" onclick="javascript:window.opener.indexGRPEsc=0;window.opener.mvsOptGroupRemoved(true);window.close();" style="cursor:hand;"/></th>'+
								'</tr>'+
							'</table>'+
						'</td>'+
					'</tr>'+
				  	'<tr>'+
						'<td colspan="2">'+
							'<img src="'+ServerSide["imagePath"]+'spacer.gif" height="40" />'+
						'</td>'+
					'</tr>'+
					'<tr>'+
						'<td>'+
							'<img src="'+ServerSide["imagePath"]+'popup_separator.jpg" width="570" height="32" alt="popup separator" />'+
						'</td>'+
					'</tr>'+
					'<tr><td align="right"><a href="#" onClick="close_window();" class="popup-close">chiudi</a></td></tr>'+
				'</table>'+
			'</body>'+
		'</html>';

	return stro;

}
// FINE FUNZIONE CHE TORNA IL CODICE DA INSERIRE NEL POPUP DEGLI OPTIONALS CON VINCOLI ESCLUSIVI

// INIZIO FUNZIONE CHE TORNA IL CODICE DA INSERIRE NEL POPUP DEGLI OPTIONALS RIMOSSI CON VINCOLI INCLUSIVI
function optWindowDetailsIncRemHTML(copt, tree) {

	var stro = '';

	stro+= 
		'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+
			'<html xmlns="http://www.w3.org/1999/xhtml">'+
			'<head>'+
				'<title>FIAT</title>'+
				'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'+
				'<link href="'+ServerSide["stylePath"]+'fiat.css" rel="styleSheet" type="text/css">'+
				'<script language="javascript" src="'+ServerSide["jsPath"]+'fiat.js" type="text/javascript"></script>'+
			'</head>'+
			'<body style="background:none;" onblur="javascript:window.focus();">'+
				'<table class="popup">'+
					'<tr>'+
						'<td>'+
							'<table width="100%">'+
								'<tr>'+
									'<td align="left"><img src="'+ServerSide["imageUploadPathFE"]+ServerSide["page3PTitleImageFE"]+'" width="220" height="26" alt="Per saperne di piu" /></td>'+
								'</tr>'+
							'</table>'+
						'</td>'+
					'</tr>'+
					'<tr><td><img src="'+ServerSide["imagePath"]+'popup_separator.jpg" width="570" height="32" alt="popup separator" /></td></tr>'+
					'<tr>'+
						'<td>'+
							'<table class="main-pop2">'+
								'<tr>'+
									'<td>'+
										'<table width="100%">'+
											'<th>'+ServerSide["page3PH1"]+'</th>'+
											'<tr><td>'+convertApici(getOptionalFromCode(copt).desc)+'</td></tr>'+
											'<tr><td><img src="'+ServerSide["imagePath"]+'spacer.gif" height="16" /></td></tr>'+
										'</table>'+
									'</td>'+
								'</tr>'+
								'<tr>'+
									'<td>'+
										'<table width="100%">'+
											'<th colspan="2">'+ServerSide["page3PH2IR"]+'</th>'+
											getListOptIncRemHTML(tree)+
											'<tr><td colspan="2"><img src="'+ServerSide["imagePath"]+'spacer.gif" height="10" /></td></tr>'+
										'</table>'+
									'</td>'+
								'</tr>'+
								'<tr>'+
									'<th style="text-align:right; vertical-align:middle">'+ServerSide["page3PDescIR"]+' <img src="'+ServerSide["imagePath"]+'popupSi.gif" width="30" height="19" onclick="javascript:window.opener.indexGRPEsc=0;window.opener.mvsOptGroupRemoved(false);window.close();" alt="si" style="cursor:hand;" /><img src="'+ServerSide["imagePath"]+'popupNo.gif" width="30" height="19" alt="no" onclick="javascript:window.close();" onclick="javascript:window.opener.indexGRPEsc=0;window.opener.mvsOptGroupRemoved(true);window.close();" style="cursor:hand;"/></th>'+
								'</tr>'+
							'</table>'+
						'</td>'+
					'</tr>'+
				  	'<tr>'+
						'<td colspan="2">'+
							'<img src="'+ServerSide["imagePath"]+'spacer.gif" height="40" />'+
						'</td>'+
					'</tr>'+
					'<tr>'+
						'<td>'+
							'<img src="'+ServerSide["imagePath"]+'popup_separator.jpg" width="570" height="32" alt="popup separator" />'+
						'</td>'+
					'</tr>'+
					'<tr><td align="right"><a href="#" onClick="close_window();" class="popup-close">chiudi</a></td></tr>'+
				'</table>'+
			'</body>'+
		'</html>';

	return stro;

}
// FINE FUNZIONE CHE TORNA IL CODICE DA INSERIRE NEL POPUP DEGLI OPTIONALS RIMOSSI CON VINCOLI INCLUSIVI

//ServerSide["page3H3"]="Prezzo";ServerSide["standardOptionalLabel"]="di serie";
function getGroupOptIncHTML(tree) {
	var ch = '';
	var sto = '';
	var frase='';
	var primoGruppoVisualizzato = false;
	sto += '<form name="grFo">';
	for(var i = 0; i < tree.length; i++){
		
		/*
		if (i == 0) ch = ' checked';
		else ch = '';
		*/
		
		// Uricchio David
		// Testa se l'elemento corrente dell'array è valido
		
		if(!isArrayElementValid(tree, i))
			continue;
			
		if(!primoGruppoVisualizzato){
			ch = " checked";
			primoGruppoVisualizzato = true;
		}else{
			ch = "";
		}			
		
		for (var k = 0; k < tree[i].length; k++) {
			sto += '<tr>';
			sto += '<td width="40" align="center"><input type="radio" value="'+i+'" name="grpOpt"'+ch+'></td>';
			sto += '<td class="lgray">';
			
			if(tree[i][k].optType=="O"){
				frase=" - "+ServerSide["page3H3"]+":"+conditionalPrintCurrencySymbolAfter(tree[i][k].price," ");
			}else if(tree[i][k].optType=="S"){
				frase=" - "+ServerSide["standardOptionalLabel"];			
			}
			
			sto += convertApici(tree[i][k].desc + frase)+'<br>';
			sto += '</td>';
			sto += '</tr>';
		}
		
	}
	sto += '</form>';


	return sto;
}
//

//
function getGroupOptEscHTML(lista) {
	var sto = '';
	sto += '<tr>';
	sto += '<td class="lgray">';
	for (var k = 0; k < lista.length; k++) {
		sto += convertApici(lista[k].desc)+'<br>';
	}
	sto += '</td>';
	sto += '</tr><tr><td><img src="'+ServerSide["imagePath"]+'spacer.gif" height="10" /></td></tr>';

	return sto;
}
/*
<tr>
	<td width="40" align="center"><input type="checkbox" /></td>
	<td class="lgray">Sist vivavoce Blu&Me con tecn. Bluetooth, riconosc. vocale, lettore file audio digit con porta USB - Prezzo:300,00 Euro</td>
</tr>
<tr>
	<td width="40" align="center"><input type="checkbox" /></td>
	<td class="lgray">ISTANT NAV C/ BLUE&ME E TMC PREMIUM - Prezzo:1.300,00 Euro</td>
</tr>
*/
function getListOptIncRemHTML(lista) {
	var sto = '';

	sto += '<tr>';
	sto += '<td class="lgray">';
	for (var k = 0; k < lista.length; k++) {
		sto += convertApici(lista[k].desc)+'<br>';
	}
	sto += '</td>';
	sto += '</tr><tr><td><img src="'+ServerSide["imagePath"]+'spacer.gif" height="10" /></td></tr>';

	return sto;
}
//
// !! INIZIO FUNZIONE CHE TORNA IL CODICE DA INSERIRE NEL POPUP DEGLI OPTIONALS CON VINCOLI -- DEPRECATA !!!!!!!!!!!!!!!
function optWindowDetailsHTML(copt, strEsc, strInc) {

	var arrEsc = strEsc.split('|');
	var arrInc = strInc.split('|');
	var tito = '';
	var conto = '';
	var desco = '';

	if (strInc != '') {
		tito = ServerSide["page3PH2I"];
		desco = ServerSide["page3PDescI"];
		for (var i = 0; i < arrInc.length; i++) {
			for (var k = 0; k < OptionalList.length; k++) {
				if (OptionalList[k].code == arrInc[i]) {
					conto += convertApici(OptionalList[k].desc) + ';<br>';
				}
			}
		}
	}
	if (strEsc != '') {
		conto = '';
		tito = ServerSide["page3PH2E"];
		desco = ServerSide["page3PDescE"];
		for (var i = 0; i < arrEsc.length; i++) {
			for (var k = 0; k < OptionalList.length; k++) {
				if (OptionalList[k].code == arrEsc[i]) {
					conto += convertApici(OptionalList[k].desc) + ';<br>';
				}
			}
		}
	}
	var stro = '';

	stro+= 
			'<html>'+
			'<head>'+
			'<title>Alfa Romeo</title>'+
			'<link href="'+ServerSide["stylePath"]+'cc.css" rel="styleSheet" type="text/css">'+
			'<link href="'+ServerSide["stylePath"]+'fiat.css" rel="styleSheet" type="text/css">'+
			'</head>'+
			'<body>'+
			'<table width="483" cellpadding="0" cellspacing="0" border="0">'+
				'<tr>'+
					'<td><img src="'+ServerSide["imagePath"]+'logo_alfaromeo.gif" border="0" alt="Alfa Romeo"></td>'+
				'</tr>'+
				'<tr>'+
					'<td style="height:18px;font-size:1px;" class="bknavprimaria">&nbsp;</td>'+
				'</tr>'+
				'<tr>'+
					'<td style="height:40px;text-align:center;">'+
						'<div style="width:458px;text-align:left;"><span class="titlecontent"><img src="'+ServerSide["imagePath"]+'a6_icona_escla.gif" border="0" alt="Stampa" align="absmiddle" hspace="5">'+ServerSide["page3PTitle"]+'</span></div>'+
					'</td>'+
				'</tr>'+
				'<tr>'+
					'<td style="text-align:center;">'+
						'<div style="width:458px;text-align:left;">'+
							'<table width="458" cellpadding="0" cellspacing="0" border="0" class="alfa6BorderGrigio">'+
								'<tr>'+
									'<td class="bkgrigioscuro" style="padding:3px;height:18px;"><b>'+ServerSide["page3PH1"]+'</b></td>'+
								'</tr>'+
								'<tr>'+
									'<td class="bkgrigio" style="padding:3px;height:18px;"><b>'+convertApici(Vehicle.Optionals[copt].desc)+'</b></td>'+
								'</tr>'+
								'<tr>'+
									'<td class="bkgrigioscuro" style="padding:3px;height:18px;"><b>'+tito+'</b></td>'+
								'</tr>'+
								'<tr>'+
									'<td class="bkgrigio" style="padding:3px;height:18px;"><b>'+conto+'</b></td>'+
								'</tr>'+
							'</table><br>'+
							'<table width="458" cellpadding="0" cellspacing="0" border="0" class="alfa6BorderGrigio">'+
								'<tr>'+
									'<td class="bkgrigio" style="padding:3px;height:18px;"><b>'+desco+'</b></td>'+
								'</tr>'+
							'</table>'+
							'<img src="'+ServerSide["imageLangPath"]+'chiudi_chiara.gif" onclick="window.close();" border="0" alt="Chiudi" align="right" vspace="8" style="cursor:hand;">'+
						'</div>'+
					'</td>'+
				'</tr>'+
			'</table>'+
			'<br><br>'+
			'</body>'+
			'</html>';

	return stro;
}
// FINE FUNZIONE CHE TORNA IL CODICE DA INSERIRE NEL POPUP DEGLI OPTIONALS CON VINCOLI !!!!!!!!!!!!!!!!!!!!!!!!

// INIZIO FUNZIONE CHE TORNA IL CODICE DA INSERIRE NEL POPUP 'NON PUOI PROSEGUIRE'
function errorAlertHTML() {
//Attanasi - Inizio Modifiche  per HDA  (Invio di un sendEvent quando viene lanciato un Pop-Up )
	
	var stro = '';

	stro+= 
			'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+
			'<html xmlns="http://www.w3.org/1999/xhtml">'+
			'<head>'+
				'<title>FIAT</title>'+
				'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'+
				'<link href="'+ServerSide["stylePath"]+'fiat.css" rel="styleSheet" type="text/css">'+
				'<script language="javascript" src="'+ServerSide["jsPath"]+'fiat.js" type="text/javascript"></script>'+
			'</head>'+
			'<body style="background:none;" onblur="javascript:window.focus();">'+
				'<table class="popup">'+
					'<tr>'+
						'<td>'+
							'<table width="100%">'+
								'<tr>'+
									'<td align="left"><img src="'+ServerSide["imageUploadPathFE"]+ServerSide["page3PTitleImageFE"]+'" width="220" height="26" alt="Per saperne di piu" /></td>'+
								'</tr>'+
							'</table>'+
						'</td>'+
					'</tr>'+
					'<tr><td><img src="'+ServerSide["imagePath"]+'popup_separator.jpg" width="570" height="32" alt="popup separator" /></td></tr>'+
					'<tr>'+
						'<td>'+
							'<table class="main-pop2">'+
								'<tr>'+
									'<td>'+
										'<table width="100%">'+
											'<th>'+ServerSide["page3PErrorAlertMessage"]+'</th>'+
											'<tr><td>'+ServerSide["page3PErrorAlertPreImg"]+'<img src="'+ServerSide["imagePath"]+'green-alert.gif" width="13" height="13" vspace="0" hspace="6" border="0" valign="bottom" style="margin-top:3px;margin-bottom:0px;margin-left:5px; margin-right:5px;">'+ServerSide["page3PErrorAlertPostImg"]+'</td></tr>'+
											'<tr><td><img src="'+ServerSide["imagePath"]+'spacer.gif" height="16" /></td></tr>'+
										'</table>'+
									'</td>'+
								'</tr>'+
							'</table>'+
						'</td>'+
					'</tr>'+
				  	'<tr>'+
						'<td colspan="2">'+
							'<img src="'+ServerSide["imagePath"]+'spacer.gif" height="40" />'+
						'</td>'+
					'</tr>'+
					'<tr>'+
						'<td>'+
							'<img src="'+ServerSide["imagePath"]+'popup_separator.jpg" width="570" height="32" alt="popup separator" />'+
						'</td>'+
					'</tr>'+
					'<tr><td align="right"><a href="#" onClick="close_window();" class="popup-close">chiudi</a></td></tr>'+
				'</table>'+
			'</body>'+
		'</html>';
		
	return stro;
}
// FINE FUNZIONE CHE TORNA IL CODICE DA INSERIRE NEL POPUP 'NON PUOI PROSEGUIRE'

// INIZIO FUNZIONE CHE TORNA L'HTML DELL'IMMAGINE AL POSTO DI FLASH
function flashObj() {
	var st = '&nbsp;';
	if (ServerSide["useFlash"] == 'false') st = '<img height="125" width="257" src="'+ServerSide["imagePathCC"]+getImgFF()+'" vspace="0" hspace="0" border="0">';
	return st;
}
// FINE FUNZIONI CHE TORNANO L'HTML DELL'IMMAGINE AL POSTO DI FLASH

// INIZIO FUNZIONE CHE TORNA IL NOME DELL'IMMAGINE AL POSTO DI FLASH
function getImgFF() {
	var imgFF = Vehicle.Mvs.code.substring(0,8)+'c'+Vehicle.MvsBodyColor.code+'.jpg';
	return imgFF;
}
// FINE FUNZIONE CHE TORNA IL NOME DELL'IMMAGINE AL POSTO DI FLASH

// INIZIO FUNZIONE CHE SETTE LO STYLE "CURSOR" ALLE IMMAGINI DELLO STEP 4 IN BASE AL FLAG
function cursorManagerStep4() {
	if (ServerSide["page4H1Flag1"] == "hidden") {
		document.getElementById('p4H1Tr1').className = 'bkgrigio';
		document.getElementById('p4H1Td1').innerHTML = '&nbsp;';
		document.getElementById('p4H1TrG1').className = 'bkgrigio';
		document.getElementById('p4H1TdG1').innerHTML = '&nbsp;';
	} else if (ServerSide["page4H1Flag1"] == "true") {
		document.getElementById('p4H1Img1').style.cursor = 'hand';
		document.getElementById('p4H1Img1').src = ServerSide["imagePath"]+'cc_P4B1.gif';
	}
	if (ServerSide["page4H1Flag2"] == "hidden") {
		document.getElementById('p4H1Tr2').className = 'bkgrigio';
		document.getElementById('p4H1Td2').innerHTML = '&nbsp;';
		document.getElementById('p4H1TrG2').className = 'bkgrigio';
		document.getElementById('p4H1TdG2').innerHTML = '&nbsp;';
	} else if (ServerSide["page4H1Flag2"] == "true") {
		document.getElementById('p4H1Img2').style.cursor = 'hand';
		document.getElementById('p4H1Img2').src = ServerSide["imagePath"]+'cc_P4B2.gif';
	}
	if (ServerSide["page4H2Flag1"] == "hidden") {
		document.getElementById('p4H2Tr1').className = 'bkgrigio';
		document.getElementById('p4H2Td1').innerHTML = '&nbsp;';
		document.getElementById('p4H2TrG1').className = 'bkgrigio';
		document.getElementById('p4H2TdG1').innerHTML = '&nbsp;';
	} else if (ServerSide["page4H2Flag1"] == "true") {
		document.getElementById('p4H2Img1').style.cursor = 'hand';
		document.getElementById('p4H2Img1').src = ServerSide["imagePath"]+'cc_P4B3.gif';
	}
	if (ServerSide["page4H2Flag2"] == "hidden") {
		document.getElementById('p4H2Tr2').className = 'bkgrigio';
		document.getElementById('p4H2Td2').innerHTML = '&nbsp;';
		document.getElementById('p4H2TrG2').className = 'bkgrigio';
		document.getElementById('p4H2TdG2').innerHTML = '&nbsp;';
	} else if (ServerSide["page4H2Flag2"] == "true") {
		document.getElementById('p4H2Img2').style.cursor = 'hand';
		document.getElementById('p4H2Img2').src = ServerSide["imagePath"]+'cc_P4B4.gif';
	}
	if (ServerSide["page4H2Flag3"] == "hidden") {
		document.getElementById('p4H2Tr3').className = 'bkgrigio';
		document.getElementById('p4H2Td3').innerHTML = '&nbsp;';
		document.getElementById('p4H2TrG3').className = 'bkgrigio';
		document.getElementById('p4H2TdG3').innerHTML = '&nbsp;';
	} else if (ServerSide["page4H2Flag3"] == "true") {
		document.getElementById('p4H2Img3').style.cursor = 'hand';
		document.getElementById('p4H2Img3').src = ServerSide["imagePath"]+'cc_P4B5.gif';
	}
	if (ServerSide["page4H2Flag4"] == "hidden") {
		document.getElementById('p4H2Tr4').className = 'bkgrigio';
		document.getElementById('p4H2Td4').innerHTML = '&nbsp;';
		document.getElementById('p4H2TrG4').className = 'bkgrigio';
		document.getElementById('p4H2TdG4').innerHTML = '&nbsp;';
	} else if (ServerSide["page4H2Flag4"] == "true") {
		document.getElementById('p4H2Img4').style.cursor = 'hand';
		document.getElementById('p4H2Img4').src = ServerSide["imagePath"]+'cc_P4B6.gif';
	}
}
// FINE FUNZIONE CHE SETTE LO STYLE "CURSOR" ALLE IMMAGINI DELLO STEP 4 IN BASE AL FLAG

// INIZIO FUNZIONE CHE CONTROLLA SE L'OPT RIGUARDA GLI INTERNI O I COLORI
function setDisabled(cod) {
	for (var i = 0; i < MvsBCList.length; i++) {
		if (cod == MvsBCList[i].codeOpt) return true;
	}
	for (var k = 0; k < MvsIPList.length; k++) {
		if (cod == MvsIPList[k].codeOpt) return true;
	}
	return false;
}
// FINE FUNZIONE CHE CONTROLLA SE L'OPT RIGUARDA GLI INTERNI O I COLORI

// INIZIO FUNZIONE CHE SETTA CHECKED L'OPT SE IL VEICOLO HA UN OPTIONAL CHE LO RIGUARDA
function setChecked(cod) {
	if (Vehicle.MvsInnerPreparation.codeOpt == cod || Vehicle.MvsBodyColor.codeOpt == cod) return true;
	return false;
}
// FINE FUNZIONE CHE SETTA CHECKED L'OPT SE IL VEICOLO HA UN OPTIONAL CHE LO RIGUARDA

// INIZIO FUNZIONE CHE TORNA LA SCRITTA DI DESCRIZIONE DEL TIPO DI COLORE
function getDescBCByOptCode(cod) {
	var ot = '';

	// retromarcia
	return ot;

	for (var i = 0; i < MvsBCList.length; i++) {
		if (cod == MvsBCList[i].code) {
			if (MvsBCList[i].codeOpt != '') {
				for (var k = 0; k < OptionalList.length; k++) {
					if (OptionalList[k].code == MvsBCList[i].codeOpt) ot = ' - '+convertApici(OptionalList[k].desc);
				}
			}
		}
	}
	return ot;
}
// FINE FUNZIONE CHE TORNA LA SCRITTA DI DESCRIZIONE DEL TIPO DI COLORE

function printCurrency(currencyString, spacer){

	var curren="";
	if(spacer==null) spacer="";
	if(ServerSide["currencySymbolAlwaysBefore"]=="true"){
		return (ServerSide["currency"]+spacer+currencyString);
	}
	if(ServerSide["currencySymbolAlwaysAfter"]=="true"){
		return (currencyString+spacer+ServerSide["currency"]);
	}
	if(ServerSide["currencyOrderInverted"]=="true"){
		return (ServerSide["currency"]+spacer+currencyString);
	}
	else{
		return (currencyString+spacer+ServerSide["currency"]);
	}
}

function conditionalPrintCurrencySymbolBefore(price, spacer){
	if(ServerSide["currencySymbolAlwaysBefore"]=="true" || 
		ServerSide["currencySymbolAlwaysAfter"]=="true"){
		return printCurrency(numberToFormattedString(price), spacer);
	}
	else{
		return ServerSide["currency"]+' '+numberToFormattedString(price);
	}
}

function conditionalPrintCurrencySymbolAfter(price, spacer){
	if(ServerSide["currencySymbolAlwaysBefore"]=="true" || 
		ServerSide["currencySymbolAlwaysAfter"]=="true"){
		return printCurrency(numberToFormattedString(price), spacer);
	}
	else{
		return (numberToFormattedString(price)+spacer+ServerSide["currency"]);
	}
}

//Attanasi - INIZIO  Concatenazione dei valori  da inviare all'onload 
 function getValueKeyOnLoadStep()
 {
 	 var cod_model = "000";
 	 
 	 if(Vehicle.Model.code != null) {
 	    cod_model = Vehicle.Model.code + "_"; 	     	    
 	    
 	    if(cod_model == "150_")
 	       cod_model = ""; 	       
 	 }
 	 
   keyValue = cod_model + onLoad_1Parametro_StepHDA + Vehicle.step + onLoad_2Parametro_StepHDA;
   debug("KeyValue " + keyValue);
   return keyValue;
 }
 
 function getValueOnLoadStep()
 { 
  	var returnValueOnLoad='';
	  switch(Vehicle.step) {
		case 1: 
		  returnValueOnLoad=getValueOnLoadStep1();
		  break;
		case 2: 
			returnValueOnLoad=getValueOnLoadStep1()+getValueOnLoadStep2();
		  break;
		case 3: 
		  returnValueOnLoad=getValueOnLoadStep1()+getValueOnLoadStep2()+getValueOnLoadStep3();			
			break;
		case 4: 
		  returnValueOnLoad=getValueOnLoadStep1()+getValueOnLoadStep2()+getValueOnLoadStep3()+getValueOnLoadStep4();
		  break;
	}

  return returnValueOnLoad + "&" + ServerSide["linkString"]; 
  
  }
  
  function getValueOnLoadStep1() 
  {

    //"cookieVal="+false+"&nuovaPagina="+true+"&time="+3+"&codiceModello="+150;
	  var cookie=getCookie('hda_cookie');
	  var booleanCookie="true";// utente nuovo 
	
	  if(cookie==null)
	  {
		  setCookie('hda_cookie',Vehicle.step,365);
	 	  booleanCookie="true";	 	
	  }else 
	  {
	    if(Vehicle.step<=cookie)
	 	  {
	 	 	  booleanCookie="false";// non è un utente nuovo
	 	 		
	 	  }
	    else 
	    {
	  	  setCookie('hda_cookie',Vehicle.step,365);		
	  	  booleanCookie="true";	  	
	    }
	  }
	
	  //var returnValueOnLoadStep1= "cookieVal="+booleanCookie+"&nuovaPagina="+getNuovaPagina()+"&time="+getTime()+"&codiceModello="+Vehicle.Mvs.code.substring(2,5);
	  var returnValueOnLoadStep1= "cookieVal="+booleanCookie+"&nuovaPagina="+getNuovaPagina()+"&time="+getTime()+"&codiceModello="+Vehicle.Model.code;
    return returnValueOnLoadStep1;
  
  }
   
  function getValueOnLoadStep2() {
  
	var returnValueOnLoadStep2= "&MVS="+Vehicle.Mvs.code;
   return returnValueOnLoadStep2;
 
  }
	
	function getValueOnLoadStep3() {
	//&bodyColor=270&innerPreparation=201&rim=432'
	var returnValueOnLoadStep3= "&bodyColor="+Vehicle.MvsBodyColor.code+"&innerPreparation="+Vehicle.MvsInnerPreparation.code+"&rim="+ getCodeCerchioneSelected();
 
   return returnValueOnLoadStep3;
 
  }  
 
 function getValueOnLoadStep4() {
//&optSerieSelected=o150o151o243&optUserSelected=o550o761o799'
	var returnValueOnLoadStep4= "&optSerieSelected="+getOptionalStandard()+"&optUserSelected="+getOptional();
    debug(returnValueOnLoadStep4);
    return returnValueOnLoadStep4;

  }
//Attanasi - FINE  Concatenazione dei valori  da inviare all'onload 
 //Attanasi - INIZIO Gestione Cookie
 function getCookie(NameOfCookie){
	
    if (document.cookie.length > 0) {              
    begin = document.cookie.indexOf(NameOfCookie+"=");       
    if (begin != -1) {           
      begin += NameOfCookie.length+1;       
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end));
    } 
  }
  return null;
}

function setCookie(NameOfCookie, value, expiredays) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

  document.cookie = NameOfCookie + "=" + escape(value) + 
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

//Attanasi - FINE Gestione Cookie

function getNuovaPagina() {

//k(nuova_gagina);
return ServerSide["HDA_NUOVAPAGINA"];
}

function getTime(){

	oggi = new Date();
	return  oggi.getHours();

}
function getOptional()
 { var optional='';	
 	var leng= Vehicle.Optionals.length;
 	var i=0;

    for (var VO in
            Vehicle.Optionals) {
				            
                if (Vehicle.Optionals[VO].category != '-' && Vehicle.Optionals[VO].optType == 'O') {
                i++;
                   optional+='o'+
                            Vehicle.Optionals[VO].code;
								}
				
}

return optional;
 }
 
// getOptionalStandard() - get della lista deli Optional Standard
function getOptionalStandard() 
 { var optional='';	
   var i=0;
   for (var cati in
            StandardCategories) {
                if (cati != '-') {
                
                    for (k = 0; k < getStandardOptByCategory(cati).length; k++) {
                	i++;
                         optional+= 'o'+getStandardOptByCategory(cati)[k].code ;
                    }
                }
            }



return optional;      
 }
 
function getEnabledHdaMvs(code) {
  
  if(ServerSide["enable_hda_mvs"] == "true") {  	
  	var mvs;
    var tot_mvs =	ServerSide["hda_mvs_totali"];           
       
    if(tot_mvs == 1 && ServerSide["hda_mvs0"] == "all")
      return true;
            
    for(var x=0; x<tot_mvs; x++){
      mvs = ServerSide["hda_mvs"+x];     
      //alert("hda_mvs " +ServerSide["hda_mvs"+x]);
      if(mvs == code)
        return true;      	
    }
    return false;  	
  }
  
  return false;
	
}
