	  function getRadioValueIE(RadioName)
	  {
	     for (var i = 0; i < RadioName.length; i++)
	     {
	        if (RadioName[i].checked)
					{
					   return i;
					}
			 }
			 return 0;
		}

	 	function svuota_auto(i)
		{
 	 	   num_option=document.getElementById('modellovehicle_'+i).options.length;
			 for (a=num_option;a>=0;a--)
			 {
				 	 document.getElementById('modellovehicle_'+i).options[a]=null;
		   }
		}

		function aggiungivoce(valore, testo, i)
		{
 	 	   num_option=document.getElementById('modellovehicle_'+i).options.length;
  	 	 document.getElementById('modellovehicle_'+i).options[num_option]=new Option('', valore, false, false);
		 	 document.getElementById('modellovehicle_'+i).options[num_option].innerHTML = testo;
		}

		var xmlHttp;
		function showCars(str, i)
		{ 
   		 xmlHttp=GetXmlHttpObject();
   		 if (xmlHttp==null)
   		 {
       		alert ("Browser does not support HTTP Request");
      		return;
   		 }
			 var num_option=document.getElementById('marcavehicle_'+i).selectedIndex;
			 document.getElementById('marcavehicle_str_'+i).value=document.getElementById('marcavehicle_'+i).options[num_option].innerHTML;
   		 var url="booking_seleziona_auto.php?idmarca="+str+"&i="+i;
   		 xmlHttp.onreadystatechange=stateChanged;
   		 xmlHttp.open("GET",url,true);
   		 xmlHttp.send(null);
		}

		function stateChanged()
    {
       if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   		 { 
			 	 	var stringa=xmlHttp.responseText;
					var auto = stringa.split(",");
					j=auto[0];
					svuota_auto(j);
					auto_da_caricare=auto.length;
					aggiungivoce("-1:0:0:0", "-------", j);
					for (i=1;i<auto_da_caricare;i++)
					{
           		aggiungivoce(auto[i], auto[i+1], j);
							i++;
					}
   		 }
    }

		function showDimensions(value, i)
		{ 
			 var dimensioni=value.split("#");			
			 var lunghezza=dimensioni[1].split(".");
			 var altezza=dimensioni[2].split(".");
			 var larghezza=dimensioni[3].split(".");			
			 var cm=0;			 
			 var mt=0;			 
			 cm=(Math.round(lunghezza[1]/10))*10;			 
			 if(cm>=95) {
				cm=0;
				mt=parseInt(lunghezza[0])+parseInt(1);			 
			 }
			 else mt=lunghezza[0];
			 document.getElementById('lunAutoMt'+i).value=mt;			 
			 document.getElementById('lunAutoCm'+i).value=cm;			 
			 cm=(Math.round(altezza[1]/10))*10;			 
			 if(cm>=95) {
				cm=0;
				mt=parseInt(altezza[0])+parseInt(1);			 
			 }
			 else mt=altezza[0];	
			 document.getElementById('altAutoMt'+i).value=mt;
			 document.getElementById('altAutoCm'+i).value=cm;			 			 
			 cm=(Math.round(larghezza[1]/10))*10;
			 if(cm>=95) {
				cm=0;
				mt=parseInt(larghezza[0])+parseInt(1);			 
			 }
			 else mt=larghezza[0];
			 document.getElementById('larAutoMt'+i).value=mt;			 
			 document.getElementById('larAutoCm'+i).value=cm;			

			 var num_option=document.getElementById('modellovehicle_'+i).selectedIndex;
			 document.getElementById('modellovehicle_str_'+i).value=document.getElementById('modellovehicle_'+i).options[num_option].innerHTML;
		}

		function checkUserLogin()
		{ 
   		 xmlHttp=GetXmlHttpObject();
   		 if (xmlHttp==null)
   		 {
       		alert ("Browser does not support HTTP Request");
      		return;
   		 }
   		 var url="select.php?loginValue="+document.getElementById('loginscelta').value+"&&requestItems=checkUserLogin";
   		 xmlHttp.onreadystatechange=stateChangedLogin;
   		 xmlHttp.open("GET",url,true);
   		 xmlHttp.send(null);
		}

		function stateChangedLogin()
    {
       if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   		 { 
			 	 	var stringa=xmlHttp.responseText;
					if(isset(document.getElementById('checkloginok')))
						document.getElementById('checkloginok').value=stringa;
					//alert("IN AJAX "+document.getElementById('checkloginok').value);
   		 }
    }

		function pulisciStr(str)
		{
		 	 //var myRegExPattern = /[\-,?~!@#$%&*+\-'="]/g;
		   str=str.replace(":", "");str=str.replace(";", "");str=str.replace("*|*", "");str=str.replace("'", "");
			 str=str.replace("à", "a");str=str.replace("ò", "o");str=str.replace("ù", "u");str=str.replace("ì", "i");str=str.replace("è", "e");str=str.replace("é", "e");
			 //str=str.replace(myRegExPattern, "");

			 return str;
		}

		function hide_province()
		{
		   if (document.getElementById('nazionepax_1').value!="1")
			 {
			 		document.getElementById('provinciadiv').style.visibility = 'hidden';
			 }
			 else
			 {
			 		document.getElementById('provinciadiv').style.visibility = 'visible';
			 }
		} 

		function hideCc(val, orig_height, cc_height, diz_totale_andata, diz_totale_ritorno, diz_extra_carta, diz_extra_spedizione, diz_assicurazione, diz_totale_viaggio, totale_andata, totale_ritorno, costo_extra_pagamento, costo_totale_generale, costo_assicurazione)
		{
		   if (val!="2")
			 {
					document.getElementById('div_ccdata').style.display = 'none';
					altezza_div_container=orig_height-cc_height;
					document.getElementById('container').style.height=altezza_div_container+"px";
			 }
			 else
			 {
			 		document.getElementById('div_ccdata').style.display = 'inline';
					document.getElementById('container').style.height=orig_height+"px";
			 }

			 var strhtml="<div id='total_pay_andata' style='color: #666666; font-size: 10px; margin-top:3px;'>\n<div style='width:255px; float:left;'><strong>"+diz_totale_andata+"</strong>: </div><div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+totale_andata+" &euro;</div></div>\n<div style='clear:both'></div>\n";
			 if (totale_ritorno>0)
			 {
			 	  strhtml=strhtml+"<div id='total_pay_andata' style='color: #666666; font-size: 10px; margin-top:3px;'>\n";
				 	strhtml=strhtml+"<div style='width:255px; float:left;'><strong>"+diz_totale_ritorno+"</strong>: </div>";
				 	strhtml=strhtml+"<div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+totale_ritorno+" &euro;</div>";
				 	strhtml=strhtml+"</div>";
				 	strhtml=strhtml+"<div style='clear:both'></div>\n";
			 }

			 strhtml=strhtml+"<div id='extra_pay' style='color: #666666; font-size: 10px; margin-top:3px;'>\n";
  		 strhtml=strhtml+"<div style='width:255px; float:left;'><strong>"+diz_extra_carta+"</strong>: </div>";
			 strhtml=strhtml+"<div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+costo_extra_pagamento+" &euro;</div>";
			 strhtml=strhtml+"</div>";
			 strhtml=strhtml+"<div style='clear:both'></div>\n";

			 costo_totale_generale=parseFloat(totale_andata)+parseFloat(totale_ritorno)+parseFloat(costo_extra_pagamento);
			 if (parseFloat(costo_assicurazione)>0)
			 {
			 		strhtml=strhtml+"<div id='extra_pay' style='color: #666666; font-size: 10px; margin-top:3px;'>\n";
  		 		strhtml=strhtml+"<div style='width:255px; float:left;'><strong>"+diz_assicurazione+"</strong>: </div>";
			 		strhtml=strhtml+"<div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+costo_assicurazione+" &euro;</div>";
			 		strhtml=strhtml+"</div>";
			 		strhtml=strhtml+"<div style='clear:both'></div>\n";
					costo_totale_generale=costo_totale_generale+parseFloat(costo_assicurazione);
			 }

			 if (document.getElementById('costo_spedizione').value>0)
			 {
			 		strhtml=strhtml+"<div id='extra_pay' style='color: #666666; font-size: 10px; margin-top:3px;'>\n";
  		 		strhtml=strhtml+"<div style='width:255px; float:left;'><strong>"+diz_extra_spedizione+"</strong>: </div>";
			 		strhtml=strhtml+"<div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+document.getElementById('costo_spedizione').value+" &euro;</div>";
			 		strhtml=strhtml+"</div>";
			 		strhtml=strhtml+"<div style='clear:both'></div>\n";
					costo_totale_generale=costo_totale_generale+parseFloat(document.getElementById('costo_spedizione').value);
			 }
			 costo_totale_generale=Math.round(costo_totale_generale*Math.pow(10, 2))/Math.pow(10, 2);

			 strhtml=strhtml+"<div id='extra_pay' style='color: #666666; font-size: 11px; margin-top:3px;'>\n";
			 strhtml=strhtml+"<div style='width:255px; float:left;'><strong>"+diz_totale_viaggio+"</strong>: </div>";
			 strhtml=strhtml+"<div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+costo_totale_generale+" &euro;</div>";
			 strhtml=strhtml+"</div>";
			 strhtml=strhtml+"<div style='clear:both'></div>\n";

			 document.getElementById('riepilogo_prezzi').innerHTML=strhtml;
			 
			 return;
		} 

		function calcSped(val, orig_height, cc_height, diz_totale_andata, diz_totale_ritorno, diz_extra_carta, diz_extra_spedizione, diz_assicurazione, diz_totale_viaggio, totale_andata, totale_ritorno, costo_extra_pagamento, costo_totale_generale, costo_assicurazione)
		{
			 var strhtml="<div id='total_pay_andata' style='color: #666666; font-size: 10px; margin-top:3px;'>\n<div style='width:255px; float:left;'><strong>"+diz_totale_andata+"</strong>: </div><div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+totale_andata+" &euro;</div></div>\n<div style='clear:both'></div>\n";
			 if (totale_ritorno>0)
			 {
			 	  strhtml=strhtml+"<div id='total_pay_andata' style='color: #666666; font-size: 10px; margin-top:3px;'>\n";
				 	strhtml=strhtml+"<div style='width:255px; float:left;'><strong>"+diz_totale_ritorno+"</strong>: </div>";
				 	strhtml=strhtml+"<div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+totale_ritorno+" &euro;</div>";
				 	strhtml=strhtml+"</div>";
				 	strhtml=strhtml+"<div style='clear:both'></div>\n";
			 }

			 if (costo_extra_pagamento>0)
			 {
			 		strhtml=strhtml+"<div id='extra_pay' style='color: #666666; font-size: 10px; margin-top:3px;'>\n";
  		 		strhtml=strhtml+"<div style='width:255px; float:left;'><strong>"+diz_extra_carta+"</strong>: </div>";
			 		strhtml=strhtml+"<div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+costo_extra_pagamento+" &euro;</div>";
			 		strhtml=strhtml+"</div>";
			 		strhtml=strhtml+"<div style='clear:both'></div>\n";
			 }

			 costo_totale_generale=parseFloat(totale_andata)+parseFloat(totale_ritorno)+parseFloat(costo_extra_pagamento);
			 if (parseFloat(costo_assicurazione)>0)
			 {
			 		strhtml=strhtml+"<div id='extra_pay' style='color: #666666; font-size: 10px; margin-top:3px;'>\n";
  		 		strhtml=strhtml+"<div style='width:255px; float:left;'><strong>"+diz_assicurazione+"</strong>: </div>";
			 		strhtml=strhtml+"<div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+costo_assicurazione+" &euro;</div>";
			 		strhtml=strhtml+"</div>";
			 		strhtml=strhtml+"<div style='clear:both'></div>\n";
					costo_totale_generale=costo_totale_generale+parseFloat(costo_assicurazione);
			 }

			 if (val==1)
			 {
			 		//AGGIUNGO IL COSTO DELLA SPEDIZIONE VIA CORRIERE
					if (document.getElementById('nazione_spedizione').value!=0)
					{
					 	 var naz=document.getElementById('nazione_spedizione').value;
						 var ar_naz=naz.split(":");
						 document.getElementById('costo_spedizione').value=ar_naz[2];
			 			 strhtml=strhtml+"<div id='extra_pay' style='color: #666666; font-size: 10px; margin-top:3px;'>\n";
  		 			 strhtml=strhtml+"<div style='width:255px; float:left;'><strong>"+diz_extra_spedizione+"</strong>: </div>";
			 			 strhtml=strhtml+"<div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+ar_naz[2]+" &euro;</div>";
			 			 strhtml=strhtml+"</div>";
			 			 strhtml=strhtml+"<div style='clear:both'></div>\n";
						 costo_totale_generale=costo_totale_generale+parseFloat(ar_naz[2]);
					}
			 }
			 else if (val==3)
			 {
			 		//AGGIUNGO IL COSTO DELLA SPEDIZIONE VIA CORRIERE
					if (document.getElementById('prefisso_spedizione').value!=0)
					{
					 	 var naz=document.getElementById('prefisso_spedizione').value;
						 var ar_naz=naz.split(":");
						 document.getElementById('costo_spedizione').value=ar_naz[2];
			 			 strhtml=strhtml+"<div id='extra_pay' style='color: #666666; font-size: 10px; margin-top:3px;'>\n";
  		 			 strhtml=strhtml+"<div style='width:255px; float:left;'><strong>"+diz_extra_spedizione+"</strong>: </div>";
			 			 strhtml=strhtml+"<div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+ar_naz[2]+" &euro;</div>";
			 			 strhtml=strhtml+"</div>";
			 			 strhtml=strhtml+"<div style='clear:both'></div>\n";
						 costo_totale_generale=costo_totale_generale+parseFloat(ar_naz[2]);
					}
			 }

			 costo_totale_generale=Math.round(costo_totale_generale*Math.pow(10, 2))/Math.pow(10, 2);

			 strhtml=strhtml+"<div id='extra_pay' style='color: #666666; font-size: 11px; margin-top:3px;'>\n";
			 strhtml=strhtml+"<div style='width:255px; float:left;'><strong>"+diz_totale_viaggio+"</strong>: </div>";
			 strhtml=strhtml+"<div style='width:65px; float:left; text-align: right; font-size: 11px;'>"+costo_totale_generale+" &euro;</div>";
			 strhtml=strhtml+"</div>";
			 strhtml=strhtml+"<div style='clear:both'></div>\n";

			 document.getElementById('riepilogo_prezzi').innerHTML=strhtml;
			 
			 return;
		} 

		function copyData(idval, val)
		{
		   document.getElementById(idval).value=val;
		} 

		function isNumber(Expression)
		{
 		   var puntook=false;

    	 //Expression = Expression.toLowerCase();
    	 RefString = "0123456789.";
    	 for (var i = 0; i < Expression.length; i++)
       {
          var ch = Expression.substr(i, 1);
        	var a = RefString.indexOf(ch, 0);
        	if (a == -1 || (ch=='.' && puntook==true))
             return (false);
				  if (ch=='.')
					   puntook=true;
       }
       return(true);
    }

		function checkBookingForm (numpax, numveh, id_agenzia, f, msg, disabilita_pagamento_agenzia, emetti_bonifico)
		{
			 var i;
			 var ar_passeggeri="";
			 var ar_veicoli="";
			 var cc=0;
			 var check_cc=0;
			 var checked_sped=0;

			 //SE PRESENTE CONTROLLO MOD SPEDIZIONE
			 if (isset(document.getElementById('mod_spedizione_1')))
			 {
			 		if (document.getElementById('mod_spedizione_1').checked)
						 checked_sped=1;
			 		if (document.getElementById('mod_spedizione_1').checked && document.getElementById('nazione_spedizione').value=="0")
			 		{	getAlert(62, '');return; }
			 }
			 if (isset(document.getElementById('mod_spedizione_2')))
			 {
			 		if (document.getElementById('mod_spedizione_2').checked)
						 checked_sped=1;
					if (isset(document.getElementById('email_spedizione')))
					{
			 		 	 if (document.getElementById('mod_spedizione_2').checked && document.getElementById('email_spedizione').value=="")
			 			 {	getAlert(63, '');return; }
					}
			 }
			 if (isset(document.getElementById('mod_spedizione_3')))
			 {
			 		if (document.getElementById('mod_spedizione_3').checked)
						 checked_sped=1;
					if (isset(document.getElementById('prefisso_spedizione')) && isset(document.getElementById('numero_spedizione')))
					{
			 		 	 if (document.getElementById('mod_spedizione_3').checked && (document.getElementById('prefisso_spedizione').value=="0" || document.getElementById('numero_spedizione').value==""))
			 			 {	getAlert(64, '');return; }
					}
			 }

			 if (!isset(document.getElementById('mod_spedizione_1')) && !isset(document.getElementById('mod_spedizione_2')) && !isset(document.getElementById('mod_spedizione_3')))
			 		checked_sped=1;

			 if (checked_sped==0)
			 		{	getAlert(65, '');return; }

			 if (isset(document.getElementById('iscriviti_al_sito')))
			 {
			 		if (document.getElementById('iscriviti_al_sito').checked)
					{
					 	 if(document.getElementById('loginscelta').value=="" || document.getElementById('passwdscelta').value=="")
			 			 {	getAlert(49, '');return; }
					}
					//var loginscelta=document.getElementById('loginscelta').value;
					//$.get("./select.php", { loginValue: loginscelta, requestItems: 'checkUserLogin'},
	  			//function(esito)
					//{
						 //document.getElementById('checkloginok').value=esito;
  				//});
					//$.ajax({type: "GET", url: "select.php", data: "loginValue="+loginscelta+"&requestItems=checkUserLogin", success: function(response){
					//  $("#checkloginok").attr('value', response);
					//	alert(response);}
					//});
					//checkUserLogin(loginscelta);
					//alert("NELLA F PRINCIPALE"+document.getElementById('checkloginok').value);
    			if (document.getElementById('checkloginok').value=="KO")
					{	getAlert(50, '');return; }
			 }

			 if (disabilita_pagamento_agenzia!="SI" && emetti_bonifico!="1")
			 {
			    if (isset(document.getElementById('mod_pagamento')))
			 		{
	     		   for (var z = 0; z < document.forms['booking'].elements['mod_pagamento'].length; z++)
	     		   {
	         		  if (document.forms['booking'].elements['mod_pagamento'][z].checked)
	   			 	  	   cc=z;
					   }
					   //DECOMMENTARE PER METTERE SOLO CARTA
					   //cc=1;
			    }

			    //SE IL CLIENTE PAGA CON CC CONTROLLO CHE I CAMPI SIANO CORRETTI
			    if (cc==0)
			    {
			 		   check_cc=CheckCardNumber(f);
			 		   if (check_cc>0)
					   {	getAlert((check_cc+34), '');return; }
			    }
			 }

			 //CONTROLLO CHE ABBIA ACCETTATO LE CONDIZIONI PRIVACY
			 if (!document.getElementById('privacy_accept').checked)
			 {	getAlert(45, '');return; }

			 //CONTROLLO CHE ABBIA ACCETTATO LE CONDIZIONI CONTRATTO
			 if (!document.getElementById('contract_accept').checked)
			 {	getAlert(46, '');return; }

			 //CONTROLLO CHE ABBIA ACCETTATO IL REGOLAMENTO DELLE COMPAGNIE
			 if (!document.getElementById('company_accept').checked)
			 {	getAlert(47, '');return; }

			 //CONTROLLO CHE LE 2 EMAIL DIGITATE COINCIDANO
			 if (document.getElementById('emailpax_1').value!=document.getElementById('ripeti_emailpax_1').value)
			 {	getAlert(48, '');return; }

			 //CONTROLLO PASSEGGERI
			 for (i=1;i<=numpax;i++)
			 {
			 		 if (document.getElementById('nomepax_'+i).value=="")
					 {	getAlert(14, i);return; }
			 		 if (document.getElementById('cognomepax_'+i).value=="")
					 {	getAlert(15, i);return; }
			 		 if (document.getElementById('documentopax_'+i).value=="")
					 {	getAlert(16, i);return; }
			 		 if (document.getElementById('luogonascitapax_'+i).value=="")
					 {	getAlert(17, i);return; }
			 }

			 if (document.getElementById('cittapax_1').value=="")
			 {	getAlert(20, 1);return; }

			 if (id_agenzia=="")
			 {
			 		if (document.getElementById('indirizzopax_1').value=="")
			 		{	getAlert(18, 1);return; }
			 		if (document.getElementById('cappax_1').value=="")
			 		{	getAlert(19, 1);return; }
			 		if (document.getElementById('nazionepax_1').value==1 && document.getElementById('provinciapax_1').value=="")
			 		{	getAlert(21, 1);return; }
			 		if (document.getElementById('telefonopax_1').value=="")
			 		{	getAlert(22, 1);return; }
			 }

			 if (document.getElementById('cellularepax_1').value.length<5 || isNumber(document.getElementById('cellularepax_1'))==0)
			 {	getAlert(23, 1);return; }
			 if (document.getElementById('emailpax_1').value==""||isEmail(document.getElementById('emailpax_1'))==0)
			 {	getAlert(24, 1);return; }

			 //CONTROLLO VEICOLI
			 for (i=1;i<=numveh;i++)
			 {
			 		 if (document.getElementById('marcavehicle_'+i).value=="-1" || document.getElementById('marcavehicle_'+i).value=="")
					 {	getAlert(25, i);return; }
			 		 if (document.getElementById('modellovehicle_'+i).value=="-1#0#0#0" || document.getElementById('modellovehicle_'+i).value=="-1" || document.getElementById('modellovehicle_'+i).value=="")
					 {	getAlert(26, i);return; }
			 		 if (document.getElementById('targavehicle_'+i).value=="")
					 {	getAlert(27, i);return; }
					 /*
			 		 if (document.getElementById('lungvehicle_'+i).value=="")// || !isNumber(document.getElementById('lungvehicle_'+i).value))// || parseFloat(document.getElementById('lungvehicle_'+i).value)<=2)
					 {	getAlert(28, i+1);return; }
			 		 if (document.getElementById('largvehicle_'+i).value=="")// || !isNumber(document.getElementById('largvehicle_'+i).value))// || parseFloat(document.getElementById('lungvehicle_'+i).value)<=1)
					 {	getAlert(29, i+1);return; }
			 		 if (document.getElementById('altvehicle_'+i).value=="")// || !isNumber(document.getElementById('altvehicle_'+i).value))// || parseFloat(document.getElementById('lungvehicle_'+i).value)<=0.5)
					 {	getAlert(30, i+1);return; }
					 */
			 }

			 //SE ARRIVO QUI I CONTROLLI SONO TUTTI OK, INSERISCO IL VALORE CORRETTO NEI CAMPI booking_andata E booking_ritorno
			 if (isset(document.getElementById('booking_andata')))
			 {
			 		var ba=document.getElementById('booking_andata').value;
			 		if (document.getElementById('prezzo_variato').value==1)
					{
					 	 var nuovo_prezzo=document.getElementById('nuovo_prezzo_andata').value;
					 	 var vecchio_prezzo=document.getElementById('vecchio_prezzo_andata').value;
						 //alert("sostituisco "+vecchio_prezzo+" con "+nuovo_prezzo);
			 			 ba=ba.replace(vecchio_prezzo, nuovo_prezzo);
						 //alert(ba);
					}
					//ar_andata[0]=dati_viaggio, ar_andata[1]=passeggeri, ar_andata[2]=sistemazioni, ar_andata[3]=veicoli, ar_andata[4]=animali, ar_andata[5]=prezzi, ar_andata[6]=extra_fields
			 		var ar_andata=ba.split("*|*");

					//LASCIO dati_viaggio, sistemazioni, animali, prezzi ED extra_fields INVARIATI
					//AGGIUNGO A passeggeri E veicoli I DATI TROVATI NEL FORM
					var passeggeri=ar_andata[1].split(";");
					for (var i=1;i<=passeggeri.length;i++)
					{
					//alert("UNO");
					 		var nome=document.getElementById('nomepax_'+i).value;nome=pulisciStr(nome);
					//alert("DUE "+nome);
					 		var cognome=document.getElementById('cognomepax_'+i).value;cognome=pulisciStr(cognome);
					//alert("TRE "+cognome);
							var luogonascita=document.getElementById('luogonascitapax_'+i).value;luogonascita=pulisciStr(luogonascita);
					//alert("Quattro "+luogonascita);
							var documento=document.getElementById('documentopax_'+i).value;documento=pulisciStr(documento);
					//alert("CINQUE "+documento);
					 		if (i==1)
					 			 ar_passeggeri=passeggeri[0];
							else
								 ar_passeggeri=ar_passeggeri+";"+passeggeri[i-1];
					//alert("SEI "+ar_passeggeri);

	     				for (var z = 0; z < document.forms['booking'].elements['sessopax_'+i].length; z++)
	     				{
	        				if (document.forms['booking'].elements['sessopax_'+i][z].checked)
					   			 	 idx=z;
			 				}
							if (idx==0)
								 ar_passeggeri=ar_passeggeri+":M";
							else
								 ar_passeggeri=ar_passeggeri+":F";
							//ar_passeggeri=ar_passeggeri+":"+document.getElementById('sessopax_'+i);
							//alert("1 "+ar_passeggeri);
							ar_passeggeri=ar_passeggeri+":"+nome+":"+cognome+":"+document.getElementById('nazionalitapax_'+i).value;
							//alert("2 "+ar_passeggeri);
							ar_passeggeri=ar_passeggeri+":"+document.getElementById('annonascitapax_'+i).value+"-"+document.getElementById('mesenascitapax_'+i).value+"-"+document.getElementById('giornonascitapax_'+i).value+":"+luogonascita+":"+documento;
							//alert("3 "+ar_passeggeri);
							var tipodoc=document.getElementById('documentotipopax_'+i).value;tipodoc=pulisciStr(tipodoc);
							if (i==1)
							{
							 	 var indirizzo=document.getElementById('indirizzopax_'+i).value;indirizzo=pulisciStr(indirizzo);
							 	 var cap=document.getElementById('cappax_'+i).value;cap=pulisciStr(cap);
							 	 var citta=document.getElementById('cittapax_'+i).value;citta=pulisciStr(citta);
							 	 var provincia=document.getElementById('provinciapax_'+i).value;provincia=pulisciStr(provincia);
							 	 var telefono=document.getElementById('telefonopax_'+i).value;telefono=pulisciStr(telefono);
							 	 var cellulare=document.getElementById('cellularepax_'+i).value;cellulare=pulisciStr(cellulare);
							 	 var email=document.getElementById('emailpax_'+i).value;email=pulisciStr(email);
							 	 ar_passeggeri=ar_passeggeri+":"+indirizzo+":"+cap+":"+citta+":"+provincia+":"+document.getElementById('nazionepax_'+i).value;
	 							 //alert("4 "+ar_passeggeri);
							 	 ar_passeggeri=ar_passeggeri+":"+telefono+":"+cellulare+":"+email+":"+tipodoc+":"+document.getElementById('annodocumentoscadenzapax_'+i).value+"-"+document.getElementById('mesedocumentoscadenzapax_'+i).value+"-"+document.getElementById('giornodocumentoscadenzapax_'+i).value;
							//alert("5 "+ar_passeggeri);
							}
							else
								 ar_passeggeri=ar_passeggeri+":::::::::"+tipodoc+":"+document.getElementById('annodocumentoscadenzapax_'+i).value+"-"+document.getElementById('mesedocumentoscadenzapax_'+i).value+"-"+document.getElementById('giornodocumentoscadenzapax_'+i).value;
							//alert(ar_passeggeri);
					}

					var veicoli=ar_andata[3].split(";");
					for (var i=1;i<=veicoli.length;i++)
					{
					 		if (isset(document.getElementById('marcavehicle_'+i)))
							{
					 		 	 var marca=document.getElementById('marcavehicle_'+i).value;marca=pulisciStr(marca);
					 			 var modello=document.getElementById('modellovehicle_'+i).value;modello=pulisciStr(modello);
					 			 var targa=document.getElementById('targavehicle_'+i).value;targa=pulisciStr(targa);
								 /*
					 			 var lung=document.getElementById('lungvehicle_'+i).value;lung=pulisciStr(lung);
					 			 var alt=document.getElementById('altvehicle_'+i).value;alt=pulisciStr(alt);
					 			 var larg=document.getElementById('largvehicle_'+i).value;larg=pulisciStr(larg);
								 */
								 var veicoli_val=veicoli[i-1].split(":");
								 var new_veicoli="";
								 for (var j=0;j<veicoli_val.length;j++)
								 {
								    if (j==9)
								 		   new_veicoli=new_veicoli+":"+marca;
								    else if (j==10)
								 		   new_veicoli=new_veicoli+":"+modello;
								    else if (j==11)
								 		   new_veicoli=new_veicoli+":"+targa;
										else if (j==0)
											 new_veicoli=veicoli_val[j];
										else
								 		   new_veicoli=new_veicoli+":"+veicoli_val[j];
								 }

					 			 if (i==1)
					 			 		ar_veicoli=new_veicoli;
								 else
								 		ar_veicoli=ar_veicoli+";"+new_veicoli;
					 			 //ar_veicoli=ar_veicoli+":"+marca+":"+modello+":"+targa;
								 //alert(ar_veicoli);
							}
					}

					document.getElementById('booking_andata').value=ar_andata[0]+"*|*"+ar_passeggeri+"*|*"+ar_andata[2]+"*|*"+ar_veicoli+"*|*"+ar_andata[4]+"*|*"+ar_andata[5]+"*|*"+ar_andata[6];
			 }

			 if (isset(document.getElementById('booking_ritorno')))
			 {
			 		var br=document.getElementById('booking_ritorno').value;
			 		if (document.getElementById('prezzo_variato').value==1)
					{
					 	 var nuovo_prezzo=document.getElementById('nuovo_prezzo_ritorno').value;
					 	 var vecchio_prezzo=document.getElementById('vecchio_prezzo_ritorno').value;
			 			 br=br.replace(vecchio_prezzo, nuovo_prezzo);
					}
					//ar_andata[0]=dati_viaggio, ar_andata[1]=passeggeri, ar_andata[2]=sistemazioni, ar_andata[3]=veicoli, ar_andata[4]=animali, ar_andata[5]=prezzi, ar_andata[6]=extra_fields
			 		var ar_ritorno=br.split("*|*");

					ar_passeggeri="";
					ar_veicoli="";

					var passeggeri=ar_ritorno[1].split(";");
					for (var i=1;i<=passeggeri.length;i++)
					{
					 		var nome=document.getElementById('nomepax_'+i).value;nome=pulisciStr(nome);
					 		var cognome=document.getElementById('cognomepax_'+i).value;cognome=pulisciStr(cognome);
							var luogonascita=document.getElementById('luogonascitapax_'+i).value;luogonascita=pulisciStr(luogonascita);
							var documento=document.getElementById('documentopax_'+i).value;documento=pulisciStr(documento);
					 		if (i==1)
					 			 ar_passeggeri=passeggeri[0];
							else
								 ar_passeggeri=ar_passeggeri+";"+passeggeri[i-1];

	     				for (var z = 0; z < document.forms['booking'].elements['sessopax_'+i].length; z++)
	     				{
	        				if (document.forms['booking'].elements['sessopax_'+i][z].checked)
					   			 	 idx=z;
			 				}
							if (idx==0)
								 ar_passeggeri=ar_passeggeri+":M";
							else
								 ar_passeggeri=ar_passeggeri+":F";
							//ar_passeggeri=ar_passeggeri+":"+document.getElementById('sessopax_'+i).value;
							ar_passeggeri=ar_passeggeri+":"+nome+":"+cognome+":"+document.getElementById('nazionalitapax_'+i).value;
							ar_passeggeri=ar_passeggeri+":"+document.getElementById('annonascitapax_'+i).value+"-"+document.getElementById('mesenascitapax_'+i).value+"-"+document.getElementById('giornonascitapax_'+i).value+":"+luogonascita+":"+documento;
							var tipodoc=document.getElementById('documentotipopax_'+i).value;tipodoc=pulisciStr(tipodoc);
							if (i==1)
							{
							 	 var indirizzo=document.getElementById('indirizzopax_'+i).value;indirizzo=pulisciStr(indirizzo);
							 	 var cap=document.getElementById('cappax_'+i).value;cap=pulisciStr(cap);
							 	 var citta=document.getElementById('cittapax_'+i).value;citta=pulisciStr(citta);
							 	 var provincia=document.getElementById('provinciapax_'+i).value;provincia=pulisciStr(provincia);
							 	 var telefono=document.getElementById('telefonopax_'+i).value;telefono=pulisciStr(telefono);
							 	 var cellulare=document.getElementById('cellularepax_'+i).value;cellulare=pulisciStr(cellulare);
							 	 var email=document.getElementById('emailpax_'+i).value;email=pulisciStr(email);
							 	 ar_passeggeri=ar_passeggeri+":"+indirizzo+":"+cap+":"+citta+":"+provincia+":"+document.getElementById('nazionepax_'+i).value;
							 	 ar_passeggeri=ar_passeggeri+":"+telefono+":"+cellulare+":"+email+":"+tipodoc+":"+document.getElementById('annodocumentoscadenzapax_'+i).value+"-"+document.getElementById('mesedocumentoscadenzapax_'+i).value+"-"+document.getElementById('giornodocumentoscadenzapax_'+i).value;
							}
							else
								 ar_passeggeri=ar_passeggeri+":::::::::"+tipodoc+":"+document.getElementById('annodocumentoscadenzapax_'+i).value+"-"+document.getElementById('mesedocumentoscadenzapax_'+i).value+"-"+document.getElementById('giornodocumentoscadenzapax_'+i).value;
					}

					var veicoli=ar_ritorno[3].split(";");
					for (var i=1;i<=veicoli.length;i++)
					{
					 		if (isset(document.getElementById('marcavehicle_'+i)))
							{
					 		 	 var marca=document.getElementById('marcavehicle_'+i).value;marca=pulisciStr(marca);
					 			 var modello=document.getElementById('modellovehicle_'+i).value;modello=pulisciStr(modello);
					 			 var targa=document.getElementById('targavehicle_'+i).value;targa=pulisciStr(targa);
								 /*
					 			 var lung=document.getElementById('lungvehicle_'+i).value;lung=pulisciStr(lung);
					 			 var alt=document.getElementById('altvehicle_'+i).value;alt=pulisciStr(alt);
					 			 var larg=document.getElementById('largvehicle_'+i).value;larg=pulisciStr(larg);
								 */
								 var veicoli_val=veicoli[i-1].split(":");
								 var new_veicoli="";
								 for (var j=0;j<veicoli_val.length;j++)
								 {
								    if (j==9)
								 		   new_veicoli=new_veicoli+":"+marca;
								    else if (j==10)
								 		   new_veicoli=new_veicoli+":"+modello;
								    else if (j==11)
								 		   new_veicoli=new_veicoli+":"+targa;
										else if (j==0)
											 new_veicoli=veicoli_val[j];
										else
								 		   new_veicoli=new_veicoli+":"+veicoli_val[j];
								 }

					 			 if (i==1)
					 			 		ar_veicoli=new_veicoli;
								 else
								 		ar_veicoli=ar_veicoli+";"+new_veicoli;
							}
					}

					document.getElementById('booking_ritorno').value=ar_ritorno[0]+"*|*"+ar_passeggeri+"*|*"+ar_ritorno[2]+"*|*"+ar_veicoli+"*|*"+ar_ritorno[4]+"*|*"+ar_ritorno[5]+"*|*"+ar_ritorno[6];
			 }
//alert(document.getElementById('booking_andata').value);
//alert(document.getElementById('booking_ritorno').value);
			 var conf=confirm(msg);
			 if(conf!=true) return;
			 myForm=document.booking;
			 myForm.submit();
		}

		function hideSubscription()
		{
		   if (document.getElementById('iscriviti_al_sito').checked)
			 {
					document.getElementById('subscription_div').style.display = 'inline';
					document.getElementById('subscription_div_hidden').style.display = 'none';
			 }
			 else
			 {
			 		document.getElementById('subscription_div').style.display = 'none';
			 		document.getElementById('subscription_div_hidden').style.display = 'inline';
			 }
		}

		function showTestData(npax, nveh)
		{
		   if (document.getElementById('test_data_on').checked)
			 {
					for (var i=1;i<=npax;i++)
					{
					 		document.getElementById('nomepax_'+i).value="TestName";
					 		document.getElementById('cognomepax_'+i).value="TestSurname";
							document.getElementById('luogonascitapax_'+i).value="Sassari";
							document.getElementById('documentopax_'+i).value="00000";
							if (i==1)
							{
							 	 document.getElementById('indirizzopax_'+i).value="Via dei Platani 111";
							 	 document.getElementById('cappax_'+i).value="56121";
							 	 document.getElementById('cittapax_'+i).value="Pisa";
							 	 document.getElementById('telefonopax_'+i).value="050754411";
							 	 document.getElementById('cellularepax_'+i).value="3473473470";
							 	 document.getElementById('emailpax_'+i).value="hiporto@tiscali.it";
							}
					}
					for (var i=1;i<=nveh;i++)
					{
					 		document.getElementById('marcavehicle_'+i).value="TestVehicle"+i;
					 		document.getElementById('modellovehicle_'+i).value="TestModel"+i;
					 		document.getElementById('targavehicle_'+i).value=i+"XXX"+i;
					}
			 }
			 else
			 {
					for (var i=1;i<=npax;i++)
					{
					 		document.getElementById('nomepax_'+i).value="";
					 		document.getElementById('cognomepax_'+i).value="";
							document.getElementById('luogonascitapax_'+i).value="";
							document.getElementById('documentopax_'+i).value="";
							if (i==1)
							{
							 	 document.getElementById('indirizzopax_'+i).value="";
							 	 document.getElementById('cappax_'+i).value="";
							 	 document.getElementById('cittapax_'+i).value="";
							 	 document.getElementById('telefonopax_'+i).value="";
							 	 document.getElementById('cellularepax_'+i).value="";
							 	 document.getElementById('emailpax_'+i).value="";
							}
					}
					for (var i=1;i<=nveh;i++)
					{
					 		document.getElementById('marcavehicle_'+i).value="";
					 		document.getElementById('modellovehicle_'+i).value="";
					 		document.getElementById('targavehicle_'+i).value="";
					}
			 }

		}

