// JavaScript Document
var globalWBMemForm;

function displayPopup(str)
{
    var d;
    d=document.getElementById('CMS_BodyPopup');
    if (!d) {
		d=document.createElement('div')
		d.id='CMS_BodyPopup';
		d.style.display='none';
		d.style.border='1px solid #000000';
		d.style.backgroundColor='#FCFCFC';
		document.body.insertBefore(d,document.body.childNodes[0])			
	}
	d.cssClass='divPopupFisso';
    d.innerHTML=str;
    
    hs.align = 'center';
	
	var objL;
    objL=document.getElementById('linkPopupFisso');
    objL.onclick=function() {return hs.htmlExpand(this, { contentId: 'highslide-html' } )}
	return objL.onclick();
	
}

function testoSelect(obj)
{
    return obj.options[obj.selectedIndex].text;
}

function apriMappaWB(filtro,tipoFiltro, objLink,indirizzo)
{
    objLink.href='WB_creaMappa.asp?filtro=' + filtro + '&tipofiltro=' + tipoFiltro + '&indirizzo=' + indirizzo;
    return hs.htmlExpand(objLink, {objectType: 'iframe', objectWidth: 700, objectHeight: 500,cacheAjax:false,preserveContent:false} );
}



function calcolaTotaleTariffaCar(idcar)
{
	try
	{
	var m, cqta, numGiorni, nelem, Tot, Totale, prezzo;
	m=document.getElementById('moduloCars' + idcar);
	numGiorni=m.numgiorni.value;
	nelem=eval('m.elementi'+ idcar +'.value');
	Totale=0;
	for (i=0;i<=nelem-1;i++)   
		 { 
		 Tot=0;
		 cqta=eval('m.selectQta' + idcar + i +'.value');
		 prezzo=eval('m.prezzo' + idcar + i +'.value');
		 if (cqta>=0) Tot=prezzo*cqta;
		 Totale = Totale + Tot;
		 }
		var decimale, inputtot;
		decimale="00";
		if (Totale - Math.floor(Totale) >0) {decimale=Math.round((Totale - Math.floor(Totale))*100) };
		decimale=decimale.toString();
		if (decimale.length == 1) {decimale="0" + decimale};
    inputtot = document.getElementById('totale' + idcar);
		inputtot.value=Math.floor(Totale) + "." + decimale   ;//MoneyFormat(Totale);
	//	m.totale.value=Totale;
	}
	catch(ee)
		{false }
				
}

function calcolaTotaleTariffaCarxOra(idcar)
{
	try
	{
	
	var m, numGiorni, nelem, Tot, Totale,objSpan;
	m=document.getElementById('moduloCars' + idcar);
	numGiorni=m.numgiorni.value;
	nelem=eval('m.elementi'+ idcar +'.value');
	Totale=0;
	//Totale= parseFloat(Totale);
		var oraRit,oraRil,prezzoExtra1,prezzoExtra2,prezzoExtra,prezzoex,prezzoExtot, decimale, inputtot;
		  		

		
				oraRit=eval('m.ora1value'+idcar+'.value');
        oraRil=eval('m.ora2value'+idcar+'.value');	
        prezzoExtra2=0;
	    	prezzoExtra1=0;
        prezzoExtot=0;	
		if (parseFloat(oraRil) - parseFloat(oraRit)> 30)
		{
         
      	for (i=0;i<=nelem-1;i++)
		{	   
                                   
        prezzoExtra=eval('m.prezzo' + idcar + i +'.value');
        prezzoExtra1=parseFloat(prezzoExtra)/numGiorni;
        prezzoExtot = prezzoExtot +prezzoExtra1;
				prezzoExtra2=prezzoExtra2+prezzoExtra1;
				Totale=Totale+parseFloat(prezzoExtra);
				decimale="00";
		if (prezzoExtra1 - Math.floor(prezzoExtra1) >0) {decimale=Math.round((prezzoExtra1 - Math.floor(prezzoExtra1))*100) };
		decimale=decimale.toString();
		if (decimale.length == 1) {decimale="0" + decimale};
				prezzoExtra1=Math.floor(prezzoExtra1) + "." + decimale   ;
				
				objSpan=document.getElementById(idcar + '_prezzover'+i);
				if(objSpan) objSpan.innerHTML=' (More ' + prezzoExtra1+')';
				prezzoex = document.getElementById('prezzoex'+idcar + i);
				
		    prezzoex.value=prezzoExtot ;

		} 
		}
    else
    { 
       for (i=0;i<=nelem-1;i++)
		{	                              
				prezzoExtra=eval('m.prezzo' + idcar + i +'.value');
        Totale=Totale+parseFloat(prezzoExtra);
        objSpan=document.getElementById(idcar + '_prezzover'+i);
				if(objSpan) objSpan.innerHTML='';
		} 
    }
    	Totale += parseFloat(prezzoExtra2);	
      //objSpan=document.getElementById(idcar + '_prezzover'+i);
      //alert(objSpan);
			
			
			//alert(Totale);
	
		decimale="00";
		if (Totale - Math.floor(Totale) >0) {decimale=Math.round((Totale - Math.floor(Totale))*100) };
		decimale=decimale.toString();
		if (decimale.length == 1) {decimale="0" + decimale};
    inputtot = document.getElementById('totale' + idcar);
		inputtot.value=Math.floor(Totale) + "." + decimale   ;
		
		
    
			}
	catch(ee)
		{}
		
}
function ControlloCar(idcar)
{
  	try
	{
	var m, qta, qtatot, nelem;
	m=document.getElementById('moduloCars' + idcar);
	
	nelem=eval('m.elementi'+ idcar +'.value');
	 	qtatot=0;
  for (i=0;i<=nelem-1;i++)   
		 { 
		 
		 qta=eval('m.selectQta' + idcar + i +'.value');
		 qta=parseInt(qta);
		qtatot = qtatot+qta;
		 }
      
      
      
      if (qtatot > 0) 
      {       
       //m.submit();
				return true;
     
      }				
      else {
      
         alert(Lang_JS23)
         return false;
				}				
				
    }
	
	catch(ee)
		{false }
}
function ControlloTourPax(idcar, adt, chd)
{
  	try
	{
	var m, pax, tpax, npax, qta, nelem;
	m=document.getElementById('moduloCars' + idcar);
	npax=adt+chd; 
	tpax=0;
	nelem=eval('m.elementi'+ idcar +'.value');
	 	
  for (i=0;i<=nelem-1;i++)   
		 { 
		 
		 qta=eval('m.selectQta' + idcar + i +'.value');
		 pax=eval('m.nPax' + idcar + i +'.value');
		 qta=parseInt(qta);
		 pax=parseInt(pax);
		 
		 tpax= qta * pax + tpax;
		 //alert(qta+ ',' +  pax + ',' +i)   
		 }
      
      
      
      if (tpax == npax) 
      {       
       //m.submit();
				return true;
     
      }				
      else {
         alert(Lang_JS02)
         return false;
				}				
				
    }
	
	catch(ee)
		{false }
}


function calcolaTotaleTariffa(idhotel, adt, chd, chkCongruenza)
{
	try
	{
		var m, qta, numGiorni, uPP, uG, mioTot, prezzo,nPax,mioTotNpax,nTipoVoce,bVociConMax,nFlagAllotment,percentuale ;
		var qtaNW,sValutaNW,sValuta,nPaxNW,prezzoNW,P,z,ApplicaRiduzioneLetto;
		m=document.getElementById('moduloHotel' + idhotel);
		//se la textbox totale non esiste esco dalla funzione
		try
		{	m.totale.value="";	}
		catch(ee)
		{ 	return false; }
		
		numGiorni=m.numgiorni.value;
		mioTotNpax=0;
		mioTot=0;
		bVociConMax=false;
		for (i=1;i<=m.numvoci.value -1;i++)   //cancello gli span
		 {       
		        for (nz=0;nz<=12;nz++) //max 12 giorni
				    {
				        try
				        { objSpan=document.getElementById(idhotel + 'prezzovero' + i + 'giorno' + nz ); objSpan.innerHTML='';}
                        catch(e)
                        {}				    
				    }
		}		    

		for (nz=0;nz<=numGiorni -1;nz++)      //scorro tutti i giorni e calcolo i prezzi veri....
			{		      
		      for (i=1;i<=m.numvoci.value -1;i++)   // scorro tutte le voci e elaboro quelle espresse in % 
		        {
					qta=eval('m.qta' + i +'.value');
				    nPax=eval('m.npax' + i + '.value');
				    sValuta=eval('m.valuta' + i + '.value');
				    nTipoVoce=eval('m.tipovoce' + i + '.value');
				    percentuale=eval('m.prezzo' + i + 'giorno' + 0 + '.value');
			        percentuale=percentuale.replace(",",".")
    		        percentuale = parseFloat(percentuale);    //--la percentuale di riduzione/supplemento--

				    if (sValuta=='%' && qta > 0 && ! isNaN(qta))        // ----se la riga è espressa in percentuale calcolo il suo prezzovero -----  
				      {
                        P=0;
                        for (z=1;z<=m.numvoci.value -1;z++)   // scorro tutte le voci e elaboro quelle con qta >0, nPax >0 e non espresse in % 
		                  {		      
                            qtaNW=eval('m.qta' + z +'.value');
                            nPaxNW=eval('m.npax' + z + '.value');
                            sValutaNW=eval('m.valuta' + z + '.value');
    				        uPP=eval('m.upp' + z + 'giorno' + nz + '.value');
							uG=eval('m.ug' + z + 'giorno' + nz + '.value');
							prezzoNW=eval('m.prezzo' + z + 'giorno' + nz + '.value');  prezzoNW=prezzoNW.replace(",",".");  prezzoNW = parseFloat(prezzoNW);
							try {
							ApplicaRiduzioneLetto=0;
							ApplicaRiduzioneLetto=document.getElementById('parametri_' + idhotel + '_' + z).getAttribute('ApplicaRiduzioneLetto') ;
				            }
				            catch (Erro)
				            {ApplicaRiduzioneLetto=0;}
				            
				            if (isNaN(prezzoNW)) prezzoNW=0;
				            // ricavo il prezzo per persona della tripla
				            if (nPaxNW>2 && qtaNW>0 && sValutaNW !='%' && ! isNaN(qta))
    				            {
    				                if (uPP.toUpperCase() == "U" && nPaxNW > 0)
    				                    {P = P + (parseFloat(prezzoNW) / parseFloat(nPaxNW));}
    				                else
    				                    {P = P + parseFloat(prezzoNW);}
    				            }                            
    				        if (ApplicaRiduzioneLetto !=0 && nPaxNW==0 && qtaNW>0 && sValutaNW !='%' && ! isNaN(qta))
    				            {
    				                // Aggiungo alla riduzione anche gli altri servizi flaggati
    				                P = P + parseFloat(prezzoNW);
    				            }                            
                          }
                          P=(parseFloat(percentuale) * parseFloat(P)) / 100  // applico la percentuale
                          eval('m.prezzovero' + i + 'giorno' + nz + '.value="' + P.toString().replace('.',',') + '"');                           
                          objSpan=document.getElementById(idhotel + 'prezzovero' + i + 'giorno' + nz );
				  //       objSpan.innerHTML='<br>(' + P + '€)';
                        
				      }
				    else    // ----se la riga non è espressa in percentuale prezzovero=0
				      {
						eval('m.prezzovero' + i + 'giorno' + nz + '.value="' + 0 + '"');
				      }		        
		        }
            }
		
		//calcolo il totale 
		for (i=1;i<=m.numvoci.value -1;i++)
			{	
				qta=eval('m.qta' + i +'.value');
				nPax=eval('m.npax' + i + '.value');
				nTipoVoce=eval('m.tipovoce' + i + '.value');
				eval('m.qta' + i +'.className="InputQtaTariffa"; ');
				if (qta>0 && ! isNaN(qta) && nTipoVoce !=20 && nTipoVoce !=21)
					{						    
					    eval('m.qta' + i +'.className="InputQtaTariffaInserita"; ');
						mioTotNpax += qta * nPax
						salta=1;
						nFlagAllotment=eval('m.flagallotment' + i + '.value');				
						if (nFlagAllotment==2) { bVociConMax=true; };

						for (nz=0;nz<=numGiorni -1;nz++)
							{
								try
								{
									uPP=eval('m.upp' + i + 'giorno' + nz + '.value');
									uG=eval('m.ug' + i + 'giorno' + nz + '.value');
									prezzo=eval('m.prezzo' + i + 'giorno' + nz + '.value');
									prezzo=prezzo.replace(",",".") ;
									
									prezzoNW=eval('m.prezzovero' + i + 'giorno' + nz + '.value');
									prezzoNW=prezzoNW.replace(",",".") ;									
									if (prezzoNW !=0) prezzo=prezzoNW ;
									
									if (uPP.toUpperCase()=="P" && nPax >0) {prezzo=prezzo * nPax};
									prezzo=prezzo * salta;
									if (uG.toUpperCase()=="U") {salta=0};
									mioTot += prezzo * qta ;
								}	
								catch(ee)
								{
								}
							}
					}
				
			}
	/*	//////////////////////// opzioni per ora ritiro e rilascio auto ////////////////////		
		var oraRit,oraRil,prezzoExtra,objRigaTotale;
		var nGiorni;
		nGiorni=m.numgiorni.value;
		nGiorni=nGiorni -1;
		for (i=1;i<=m.numvoci.value -1;i++)
		{	
				nTipoVoce=eval('m.tipovoce' + i + '.value');				
				if (nTipoVoce==20)
				{  oraRit=eval('m.qta' + i +'.value'); 		}
				
				if (nTipoVoce==21)
				{
					oraRil=eval('m.qta' + i +'.value');
					prezzoExtra=eval('m.prezzo' + i + 'giorno0.value');
					objSpan=document.getElementById(idhotel + 'prezzovero' + i + 'giorno' + nGiorni );
					objRigaTotale=document.getElementById('CellaTotaleRiga' + idhotel + '_' + i);
				}
		}		
		if (parseFloat(oraRil) > parseFloat(oraRit))
		{
			mioTot += parseFloat(prezzoExtra);	
			objSpan.innerHTML='More ' + MoneyFormat(prezzoExtra);
			if (objRigaTotale) {objRigaTotale.innerHTML=MoneyFormat(prezzoExtra);};
		}
		/////////////////////// fine opzioni auto ///////////////////////////////////////
		
*/		
		var decimale;
		decimale="00";
		if (mioTot - Math.floor(mioTot) >0) {decimale=Math.round((mioTot - Math.floor(mioTot))*100) };
		decimale=decimale.toString();
		if (decimale.length == 1) {decimale="0" + decimale};
		m.totale.value=Math.floor(mioTot) + "." + decimale   ;//MoneyFormat(mioTot);
		
		if (mioTot <=0) {return false;}
		if (  ((chkCongruenza==1) && (bVociConMax==true && (mioTotNpax < (adt + chd))) ) ) {return false;}
		if (  ((chkCongruenza==1) && (bVociConMax==false && (mioTotNpax != (adt + chd))) ) ) {return false;}
		
		return true;
	}
	
	catch(ex)
	{
		alert(ex.message);
		return false;
	}
}


function chkDisponibilita(idhotel)
{
    var i,m, qta, qtaDis,desMessage;
    m=document.getElementById('moduloHotel' + idhotel);
    for (i=1;i<=m.numvoci.value -1;i++)
	{	
		try
		{
		    qta=eval('m.qta' + i + '.value');
		    qtaDis=document.getElementById('dispoVoce_' + i).getAttribute('Disponibilita');
		    desMessage=document.getElementById('dispoVoce_' + i).getAttribute('descrizioneTool');
		    document.getElementById('dispoVoce_' + i).className='WB';
		    if(parseInt(qta) > parseInt(qtaDis) || parseInt(qtaDis)<=0)
		    {
		        document.getElementById('dispoVoce_' + i).className='WBVoceNonDisponibile';
		    }
		}
		catch(w)
		{}
	}
}

function chkToolDisponibilita(obj,kVoce,idH)
{
	var qta, qDisp,desMessage;
	qta=document.getElementById('qta' + idH + '_' + kVoce).value;
	qDisp=obj.getAttribute('Disponibilita');
	desMessage=obj.getAttribute('descrizioneTool');
	if (qta>qDisp || qDisp <=0) {mostratool(desMessage,280,'html'); }
}


function controllopax(idhotel, adt, chd)
{
      try
	{
	  var m, qta, qtarid,MaxRidchd, nPax,mioTotNpax,nTipoVoce,bContieneRidChd,nFlagAllotment ;
		m=document.getElementById('moduloHotel' + idhotel);
    MaxRidchd=0;
    var iNdoppie, iNsingole, iNtriple,iNquadruple  ;
    iNdoppie=0; iNsingole=0; iNtriple=0; iNquadruple=0;
    qtarid = 0;
    // vedo quante sono le singole, doppie, triple e quadruple selezionate //
		for (i=1;i<=m.numvoci.value -1;i++)
			{	
				
				nPax=eval('m.npax' + i + '.value');
				nTipoVoce=eval('m.tipovoce' + i + '.value');
			    qta=eval('m.qta' + i + '.value');
			    if (parseInt(nTipoVoce)==11) 
           {
            bContieneRidChd=true;
            qtarid = qtarid + parseInt(qta);
           } 
				switch (parseInt(nPax))
			        {
			            case 1:
			                if (qta != '' && qta>0) iNsingole = parseInt(iNsingole) + parseInt(qta);
			                break;
			            case 2:
			                if (qta != '' && qta>0) iNdoppie = parseInt(iNdoppie) + parseInt(qta);
                            break;
                  case 3:
			                if (qta != '' && qta>0) iNtriple = parseInt(iNtriple) + parseInt(qta);
			                break;
			            case 4:
			                if (qta != '' && qta>0) iNquadruple = parseInt(iNquadruple) + parseInt(qta);
			                break;
			        }    
			    			    
			}
			MaxRidchd =  iNtriple + 2 * iNquadruple;
			if (qtarid != MaxRidchd) { 
      alert(Lang_JS24);

      return false;
       }
       else   {
       calcolaTotaleTariffa(idhotel, adt, chd,0);
       return true;
          }
  }  
  
  	catch(ex)
	{
		alert(ex.message);
		return false;
	}
 }
 
     
function suggerisciRiduzioni(idhotel, adt, chd)
{
    try
	{
	    var m, qta, nPax,mioTotNpax,nTipoVoce,bContieneRidChd,nFlagAllotment ;
		m=document.getElementById('moduloHotel' + idhotel);
		mioTotNpax=0;
		bContieneRidChd=false;
		var iNdoppie, iNsingole, iNtriple,iNquadruple,iPaxRestanti,iTotPax
		iNdoppie=0; iNsingole=0; iNtriple=0; iNquadruple=0;
		iTotPax=parseInt(adt) + parseInt(chd);
		
		// vedo quante sono le singole, doppie, triple e quadruple selezionate //
		for (i=1;i<=m.numvoci.value -1;i++)
			{	
				
				nPax=eval('m.npax' + i + '.value');
				nTipoVoce=eval('m.tipovoce' + i + '.value');
			    qta=eval('m.qta' + i + '.value');
			    if (parseInt(nTipoVoce)==11) bContieneRidChd=true;
				switch (parseInt(nPax))
			        {
			            case 1:
			                if (qta != '' && qta>0) iNsingole = parseInt(iNsingole) + parseInt(qta);
			                break;
			            case 2:
			                if (qta != '' && qta>0) iNdoppie = parseInt(iNdoppie) + parseInt(qta);
                            break;
                  case 3:
			                if (qta != '' && qta>0) iNtriple = parseInt(iNtriple) + parseInt(qta);
			                break;
			            case 4:
			                if (qta != '' && qta>0) iNquadruple = parseInt(iNquadruple) + parseInt(qta);
			                break;
			        }    
			    			    
			}
			
			
			//  calcolo il numero di riduzioni necessarie   //		     
		    var adtFatto, chdFatto, iNridADT, iNridCHD;
			adtFatto=0; chdFatto=0; iNridADT=0; iNridCHD=0; 
			     
		    if(iNtriple + (2 * iNquadruple) > 0 && chd >0) iNridCHD = chd ;
		    if(iNtriple + (2 * iNquadruple) < iNridCHD ) iNridCHD=iNtriple + (2 * iNquadruple);
		    if(iNtriple + (2 * iNquadruple) - iNridCHD  >0) iNridADT = iNtriple + (2 * iNquadruple) - iNridCHD  ;
			if (bContieneRidChd==false) {iNridADT=iNridADT + iNridCHD ; iNridCHD=0};
			for (i=1;i<=m.numvoci.value -1;i++)
			{					
		        nPax=eval('m.npax' + i + '.value');
				nTipoVoce=eval('m.tipovoce' + i + '.value');
			    switch (parseInt(nTipoVoce))
		           {
		               case 10:  // 3°/4° letto ADT
		                   if (adtFatto==0) { eval('m.qta' + i + '.value=' + iNridADT); adtFatto=1; if (iNridADT>0) {document.getElementById('rigaPrezzo' + idhotel + '_' + i).style.display='';} }
		                   break;
		               case 11:   // 3°/4° letto CHD
		                   if (chdFatto==0) { eval('m.qta' + i + '.value=' + iNridCHD); chdFatto=1;if (iNridCHD>0) {document.getElementById('rigaPrezzo' + idhotel + '_' + i).style.display='';} }
                           break;
                       case 12:  // 3°/4° letto CHD Free
					   	   break;
					}
		    }	
		return true;
	}
	
	catch(ex)
	{
		return false;
	}
}


function suggerisciSistemazione(idhotel, adt, chd,iControllaPax)
{
	if (iControllaPax=='1' || iControllaPax=='-1') {return true;}
	
	try
	{
		var m, qta, numGiorni, uPP, uG, mioTot, prezzo,nPax,mioTotNpax,nTipoVoce,bVociConMax,nFlagAllotment ;
		m=document.getElementById('moduloHotel' + idhotel);
		m.totale.value="";
		numGiorni=m.numgiorni.value;
		mioTotNpax=0;
		mioTot=0;
		bVociConMax=false;
		var MaxNpax, okSingola, okDoppia, okTripla, okQuadrupla;
		var iNdoppie, iNsingole, iNtriple,iNquadruple,iPaxRestanti,iTotPax
		iNdoppie=0; iNsingole=0; iNtriple=0; iNquadruple=0;
		MaxNpax=0; okSingola=0 ; okDoppia=0;  okTripla=0;  okQuadrupla=0;
		iTotPax=parseInt(adt) + parseInt(chd);
		iPaxRestanti=iTotPax;
		for (i=1;i<=m.numvoci.value -1;i++)
			{	
				nPax=eval('m.npax' + i + '.value');
				nTipoVoce=eval('m.tipovoce' + i + '.value');
			    if (nPax > MaxNpax) { MaxNpax = nPax} ;
			    if (nPax==1) {okSingola=1};
			    if (nPax==2) {okDoppia=1};
			    if (nPax==3) {okTripla=1};
			    if (nPax==4) {okQuadrupla=1};			    
			}
		if (okQuadrupla==1)
		    {
		        iNquadruple=0;
		        if (iTotPax >= 4) {iNquadruple=Math.floor(iTotPax / 4)} ;
		        iPaxRestanti=iTotPax - (4 * iNquadruple) ;
		    }
		if (okTripla==1)
		    {
		        if (iPaxRestanti >= 3) {iNtriple=Math.floor(iPaxRestanti / 3)} ;
		        iPaxRestanti=iPaxRestanti - (3 * iNtriple) ;
		    }
		if (okDoppia==1)
		    {
		        if (iPaxRestanti >= 2) {iNdoppie=Math.floor(iPaxRestanti / 2)} ;
		        iPaxRestanti=iPaxRestanti - (2 * iNdoppie) ;
		    }
		if (okSingola==1)
		    {
		        if (iPaxRestanti >= 1) {iNsingole=Math.floor(iPaxRestanti)} ;
		        iPaxRestanti=0;
		    }
		
		var sOK, dOK, tOK,qOK;
		sOK=0;  dOK=0; tOK=0; qOK=0;
		for (i=1;i<=m.numvoci.value -1;i++)
			{	
				nPax=eval('m.npax' + i + '.value');
				nTipoVoce=eval('m.tipovoce' + i + '.value');
				if (GLOBAL_SoloVociSistemazioneEconomica=='1') {
				    if(i==1) MostraNascondiRigheTabella(document.getElementById('rigaPrezzo' + idhotel + '_' + i),'none');
				}
				switch (parseInt(nPax))
			        {
			            case 1:
			                if (sOK==0) {eval('m.qta' + i + '.value=' + iNsingole); sOK=1; if (iNsingole>0) {document.getElementById('rigaPrezzo' + idhotel + '_' + i).style.display='';}}
			                break;
			            case 2:
			                if (dOK==0) {eval('m.qta' + i + '.value=' + iNdoppie); dOK=1; if (iNdoppie>0) {document.getElementById('rigaPrezzo' + idhotel + '_' + i).style.display='';}}
                            break;
                        case 3:
			                if (tOK==0) {eval('m.qta' + i + '.value=' + iNtriple); tOK=1; if(iNtriple>0) {document.getElementById('rigaPrezzo' + idhotel + '_' + i).style.display='';}}
			                break;
			            case 4:
			                if (qOK==0) {eval('m.qta' + i + '.value=' + iNquadruple); qOK=1;if (iNquadruple>0) {document.getElementById('rigaPrezzo' + idhotel + '_' + i).style.display='';}}
			                break;
			        } 
			}		
		suggerisciRiduzioni(idhotel, adt, chd);
		return true;
	}
	catch(ex)
	{
		return false;
	}
}


function MostraNascondiRigheTabella(TR,display)
{
    //------ nasconde le righe della tabella prezzi tranne quelle con attributo VisualizzaSempre=1 -------
    var M;
    M=TR.parentNode
    if (M.nodeName.toLowerCase()=='tbody' || M.nodeName.toLowerCase()=='table' )
    {
        for (var ii=0;ii<M.childNodes.length;ii++)
        {
            if (M.childNodes[ii].nodeName.toLowerCase()=='tr')
            {
                var vSempre;
                vSempre=M.childNodes[ii].getAttribute('VisualizzaSempre');
                if (vSempre !='1' && M.childNodes[ii].className.toLowerCase() !='rigatotalitariffa' && M.childNodes[ii].className.toLowerCase() !='rigaintestazionetariffa') {M.childNodes[ii].style.display=display;}
            }
        }
    }
}

function WBDisplayDatiFattura(obj)
{
	if(obj.checked)
		{obj.value='YES';document.getElementById('bloccoDatiFatturazione').style.display='block';}
	else
		{obj.value='NO';document.getElementById('bloccoDatiFatturazione').style.display='none';}
}



function prenotaHotel(azione,idhotel, adt, chd,DisableCheckPax,objSubmit)
{
	try
	{ 
  if (controllopax(idhotel, adt, chd))
  {
		if (calcolaTotaleTariffa(idhotel, adt, chd, 1))
			{
				var oForm,possoAndare;
				oForm=document.getElementById('moduloHotel' + idhotel);
				possoAndare=true;
				
				for (i=1;i<=oForm.numvoci.value -1 && azione !='variahotel';i++)   //controllo se ci sono valori selezionati e non consentiti
	             {       
            		try
		             {  
		                var objSpan;
    		            objSpan=document.getElementById('qta' + idhotel + '_' + i);
	                    if (objSpan.tagName.toUpperCase().indexOf("SELECT")>=0) {
	                        var vNonOK;
	                        vNonOK=objSpan.options[objSpan.selectedIndex].getAttribute('NonConsentito');	                        
	                        if (parseInt(vNonOK)==1 || parseInt(vNonOK)==-1) { mostraAvvisoFisso(objSpan,Lang_JS04);possoAndare=false;  };
	                    };		    
		             }
                    catch(e)
                     {}	
                     
                    try
                    { 
                    var nQtaVoce,sDipendenze,objParametri,objQta;
    		        objQta=document.getElementById('qta' + idhotel + '_' + i)
    		        nQtaVoce=objQta.value;
	                // leggo i parametri di questa voce .. es. dipendenze, età minima e massima etc...    
	                objParametri = document.getElementById('parametri_' + idhotel + '_' + i);
	                sDipendenze=objParametri.getAttribute('dipendenza');
	                
	                if (nQtaVoce >0 && sDipendenze !='') {
	                    // verifico se le dipendenze sono soddisfatte.	                    
	                    if (chkDipendenze(idhotel, oForm.numvoci.value -1, i)==false) {mostraAvvisoFisso(objQta,Lang_JS05);possoAndare=false;}
	                }	                                     
                    }
                    catch(e)
                    {}
            }
	            if (possoAndare==false){ return false;}
	            
				//displayPopup(Lang_JS11);
				oForm.azione.value=azione;
				if(objSubmit) objSubmit.disabled=true;
				oForm.submit();
				
			}
			else
			{
				if (DisableCheckPax==1 || DisableCheckPax==-1)
				{
				var oForm;
				oForm=document.getElementById('moduloHotel' + idhotel);
				oForm.azione.value=azione;
				oForm.submit();
				return;
				}				
				alert(Lang_JS02);
			}			
	}
				else
			{
				if (DisableCheckPax==1 || DisableCheckPax==-1)
				{
				var oForm;
				oForm=document.getElementById('moduloHotel' + idhotel);
				oForm.azione.value=azione;
				oForm.submit();
				return;
				}				
				alert(Lang_JS02);
			}	
  }
	catch(ex)
	{		
	}
}


function chkDipendenze(idhotel, nVoci, nVoceCheck)
{
    // Segna le voci che dipendono dalla corrente e che non sono state scelte  //
    // Se le dipendenze sono OK (voci selezionate) non segna nulla e ritorna true
    var nQtaVoce,sDipendenze,objParametri,nIdVoce,matDipendenze,i,k,nIdVoceCheck,valRitorno;
    objParametri = document.getElementById('parametri_' + idhotel + '_' + nVoceCheck );
    sDipendenze=objParametri.getAttribute('dipendenza');
    sVoceCheck='<b>' + objParametri.getAttribute('testoVero') + '</b>'; 
    if (sDipendenze.substring(sDipendenze.length -1,sDipendenze.length)==']') {sDipendenze=sDipendenze.substring(0,sDipendenze.length -1);}  //tolgo l'ultimo carattere
    if (nVoci==0) nVoci=document.getElementById('moduloHotel' + idhotel).numvoci.value -1;
    
    matDipendenze=sDipendenze.split(']');
    valRitorno=true;
    
    for (k=0;k<matDipendenze.length;k++)
    {
        nIdVoceCheck=matDipendenze[k];
        nIdVoceCheck=nIdVoceCheck.replace('[','');
        for (i=1;i<=nVoci;i++)
        {       
    		nQtaVoce=document.getElementById('qta' + idhotel + '_' + i).value;
    		if (nQtaVoce=='' || nQtaVoce=='null') {nQtaVoce=0;}
	        // leggo i parametri di questa voce .. es. dipendenze, età minima e massima etc...    
	        objParametri = document.getElementById('parametri_' + idhotel + '_' + i);
	        nIdVoce=objParametri.getAttribute('idVoce');
	        if (nIdVoce==nIdVoceCheck && parseInt(nQtaVoce) <=0) {
	            // dipendenza non soddisfatta 
	            mostraAvvisoFisso(document.getElementById('qta' + idhotel + '_' + i),Lang_JS06 + ' ' + sVoceCheck);
	           valRitorno=false;
	        }	             
	    }
    }
    return valRitorno;
}


function aggiungiHotel(idhotel, adt, chd,objSubmit)
{
	var oForm;
	displayPopup(Lang_JS11);
	oForm=document.getElementById('moduloHotel' + idhotel);
	oForm.azione.value='aggiungihotel';
	if(objSubmit) objSubmit.disabled=true;
	oForm.submit();
}


function checkNomi()
{
	try
	{
		//inserire il controllo di obbligatorietà della data di nascita dei bambini
		var elenco,chd, matT, i, obj, obj2,datan;
		elenco=document.getElementById("elencoTextboxNomi").value;
		chd=document.getElementById("chd").value;
		matT=elenco.split(";");
		i=0
		while (i < matT.length)
 			{				 
				if (matT[i].length >0) 
				{
				obj=document.getElementById('txtCognome' + matT[i])
				obj2=document.getElementById('txtNome' + matT[i])
				 if (obj.value.length < 3 || obj2.value.length < 3) 
				 	{
						//mostraAvvisoFisso(obj,Lang_JS08);
						alert(Lang_JS08)
						return false;
						
					}				
				}
			  i+=1;
			}
			for (i=1;i<=chd;i++)
        { 
         datan=document.getElementById('datanascita' + i)
         if (datan.value.length < 10)
          {
            alert(Lang_JS25)
						return false;
          }
        }      
		return true;
	}
	catch (ex)
	{
		alert(ex.message)
		return false;
	}
}

function WB_CheckValoriCombo(idHotel,SkipCheck,objSubmit)
{
	var k,n,i,obj,objD;
	n=objSubmit.form.numvoci.value;
	i=1;
	while (i < n)
 		{
			obj=eval('objSubmit.form.qta' + i);
			objD=eval('objSubmit.form.desQta' + i);
			if(obj.type.toLowerCase().indexOf('select') >=0)
				{
					for (k=0;k<obj.options.length;k++)
					{
						if (obj.selectedIndex==k) {objD.value=obj.options[k].text;};
						if (obj.options[k].getAttribute('NonConsentito') !=0 && obj.selectedIndex==k)
						{	mostraAvvisoFisso(obj,Lang_JS09); return false;}
					}
				}			
			i+=1;
		}
return true;
}

function memorizzaHotel(idHotel,SkipCheck)
{
	if (SkipCheck !=1 && SkipCheck !=-1) { if (!checkNomi()) {return false;} }
	//if (WB_CheckValoriCombo(idHotel,SkipCheck,objSubmit) == false) {return false;}
	if (confirm(Lang_JS14))
		{
			//displayPopup(Lang_JS11); // elaborazione in corso
	       // if(objSubmit) objSubmit.disabled=true;
			document.getElementById('moduloHotel' + idHotel).azione.value='memorizzahotel';
			document.getElementById('moduloHotel' + idHotel).submit();
		}
}

function WB_MemorizzaPrenotazione(msg,oForm)
{
	var sCF,sPIVA      //P.IVA o Cod. Fisc.     
	//-----------verifica dei valori immessi-------------------------
 	if (! validaValoreCampo(oForm.RagSoc,3,60,'','Ragione sociale') ) {oForm.RagSoc.focus();oForm.RagSoc.style.backgroundColor='Yellow'; return false;}
 	else oForm.RagSoc.style.backgroundColor='';
   if (! validaValoreCampo(oForm.Via,3,60,'','Indirizzo') ) {oForm.Via.focus();oForm.Via.style.backgroundColor='Yellow'; return false;}
   else oForm.Via.style.backgroundColor='';
 	if (! validaValoreCampo(oForm.Comune,2,30,'','Comune') ) {oForm.Comune.focus();oForm.Comune.style.backgroundColor='Yellow'; return false;}
 	else oForm.Comune.style.backgroundColor='';
 	if (! validaValoreCampo(oForm.Provincia,2,30,'','Provincia') ) {oForm.Provincia.focus();oForm.Provincia.style.backgroundColor='Yellow';return false;} 
   else oForm.Provincia.style.backgroundColor='';	
	if (! validaValoreCampo(oForm.email,5,30,'','Email') ) {oForm.email.focus();oForm.email.style.backgroundColor='Yellow';return false;} 
  else oForm.email.style.backgroundColor='';	
	if (oForm.conditions) {
	if(oForm.conditions.checked==false)   {alert (Lang_JS26);return false;}
	}
  if (oForm.conditionscar) {
    if(oForm.conditionscar.checked==false)   {alert (Lang_JS26);return false;}
  }
  if(oForm.privacy.checked==false)   {alert (Lang_JS27);return false;}  
	//sCF=oForm.CF.value; sPIVA=oForm.PIVA.value;
	//if (sCF != '') {if (sCF.length != 16) {alert('Inserire il Codice Fiscale corretto.');return false; } }	
	//if (sCF =='' || sPIVA != '') { if (! validaValoreCampo(oForm.PIVA,11,16,'','Partita Iva') ) {return false;}  }
		
	if(oForm.RichiestaFattura.checked==true)
	{
		// --------- Dati per la fatturazione -------------------------------------------- s//
		if (! validaValoreCampo(oForm.RagSocFatturazione,3,60,'','Ragione sociale Fatturazione') ) {oForm.RagSocFatturazione.focus();oForm.RagSocFatturazione.style.backgroundColor='Yellow';return false;}
		 	else oForm.RagSocFatturazione.style.backgroundColor='';
    if (! validaValoreCampo(oForm.ViaFatturazione,3,60,'','Indirizzo Fatturazione') ) {oForm.ViaFatturazione.focus();oForm.ViaFatturazione.style.backgroundColor='Yellow';return false;}
		 	else oForm.ViaFatturazione.style.backgroundColor='';
    if (! validaValoreCampo(oForm.ComuneFatturazione,2,30,'','Comune Fatturazione') ) {oForm.ComuneFatturazione.focus();oForm.ComuneFatturazione.style.backgroundColor='Yellow';return false;}
		 	else oForm.ComuneFatturazione.style.backgroundColor='';
    if (! validaValoreCampo(oForm.ProvinciaFatturazione,2,30,'','Provincia Fatturazione') ) {oForm.ProvinciaFatturazione.focus();oForm.ProvinciaFatturazione.style.backgroundColor='Yellow';return false;} 	
		 	else oForm.ProvinciaFatturazione.style.backgroundColor='';
    //sCF=oForm.CFFatturazione.value; sPIVA=oForm.PIVAFatturazione.value;
		//if (sCF != '') {if (sCF.length != 16) {alert('Inserire il Codice Fiscale Fatturazione corretto.');return false; } }	
		//if (sCF =='' || sPIVA != '') { if (! validaValoreCampo(oForm.PIVAFatturazione,11,16,'','Partita Iva Fatturazione') ) {return false;}  }			
	}
	
	
	// ----- dati per prodotti in prenotazione -------------  //
	var sElencoID,aryID,n,sIdElemento,oElemento;
	var lMin,lMax,tipoDati,sNomeCampo,bObbligatorio;
	sElencoID=document.getElementById('ElencoIdCampiRichiesti').value;
	aryID=sElencoID.split(';');
	for (n=0;n<aryID.length;n++)
	{
		sIdElemento=aryID[n];
		if (sIdElemento.length >0)
		{
			oElemento=document.getElementById(sIdElemento);
			try
			{
			lMin=oElemento.getAttribute('lMin');
			lMax=oElemento.getAttribute('lMax');
			tipoDati=oElemento.getAttribute('tipoDati');
			bObbligatorio=oElemento.getAttribute('obbligatorio');
			if (bObbligatorio=='1' || bObbligatorio=='-1') {bObbligatorio=true;} else {bObbligatorio=false;}
			sNomeCampo=oElemento.getAttribute('nomeCampo');		
			
			if (! validaValoreCampo(oElemento,lMin,lMax,tipoDati,sNomeCampo,bObbligatorio) ) {return false;}
			}
			catch(ss)
			{}
		}
	}
	
	if(confirm(msg))
        {
            //oForm.memorizza.disabled=true;
			//displayPopup(Lang_JS12);
			globalWBMemForm=oForm;
			setTimeout('submitFormWB()',600);
        }
}

function submitFormWB()
{globalWBMemForm.submit();}

function WB_MostraSchedaProdotto(idProdotto)
{
    var i;
    i=0;
	while (i < 30)
 		{
 		  try
 		    {
 		        document.getElementById('divWBProdotto' + i).style.display='none';
 		        document.getElementById('CellaTabPulsantiAltriProdotti' + i).className='CellaTabPulsantiAltriProdotti';
 		    }
 		   catch(ex)
 		    {
 		    }
		  i+=1;
		}
		document.getElementById('divWBProdotto' + idProdotto).style.display='block';
		document.getElementById('CellaTabPulsantiAltriProdotti' + idProdotto).className='CellaTabPulsantiAltriProdottiAttiva';
}

function WB_AggiungiServizioSingolo(strForm,data, idVoce,k)
{
    var oForm, tipoP, idP, dalCercato, alCercato, nVoci, nGiorni, tariffa, sVoce, sData,iQta;
    oForm=document.getElementById(strForm);
    tariffa=oForm.tariffa.value;
    tipoP=oForm.tipoProdotto.value;
    nVoci=oForm.numvoci.value;
    idP=oForm.idHotel.value;
    sVoce=document.getElementById('desVoce' + tipoP + '_' + k).getAttribute('testoVero');
    //sVoce=TestoDaHtml(sVoce);  //--questa istruzione  incasina la funzione....
    sData=data.toString();
    sData=sData.substring(6,8) + '/' + sData.substring(4,6) + '/' + sData.substring(0,4);
    iQta=0;
	try
		{
			iQta=eval('oForm.qta' + k + '.value');
			if (iQta=='') iQta=0;
			if (iQta <=0) {alert(Lang_JS03); return; }
		}
	catch(ee)
		{}
		
	if (confirm(Lang_JS14 + '\n\n' + Lang_JS16 + ': ' + iQta + '\n' + Lang_JS15 +': ' + sVoce + '\n' + Lang_JS17 + ': ' + sData ))
    {
        var qString ='wb_actionAjax.asp?azione=aggiungisingoloservizio';
        qString =qString + '&qtaScelta=' + iQta ;
        qString =qString + '&dataScelta=' + data ;
        qString =qString + '&idVoceScelta=' + idVoce ;
        qString =qString + '&idHotel=' + idP ;
        qString =qString + '&tipoProdotto=' + tipoP ;
        qString =qString + '&desQtaScelta=' + eval('oForm.desQta' + k + '.value') ;
        //alert(qString);
        AJAX(qString ,esitoAggiungiSingoloServizio);          
    }
}

function esitoAggiungiSingoloServizio(w)
{
    displayPopup(w);
}

function WB_EliminaHotel(act)
{
    if (confirm(Lang_JS18))
    {
        location.href=act;    
    }
}

function WB_CancellaServizio(act)
{
    if (confirm(Lang_JS19))
    {
        location.href=act;    
    }
}

function WB_MostraDiv(blocco)
{ document.getElementById(blocco).style.display="block";}

function WB_NascondiDiv(blocco)
{ document.getElementById(blocco).style.display="none";}

function WB_MostraRicercaHotel(valoreProdotto,idBlocco,bSubmit)
{
	var matDiv,i;
	matDiv=WB_ElencoDivRicerca.split(',');
	for(i=0;i<matDiv.length;i++ ) 	{document.getElementById('WBPulsCerca' + matDiv[i]).className='CellaPulsantiBloccoRicerca'; 	}
	document.getElementById('WBPulsCerca' + idBlocco).className='CellaAttivaPulsantiBloccoRicerca';
	
	modu=document.getElementById('moduloWBMenuCercaHotel')
    modu.wbcurrentdivcerca.value=idBlocco;
	document.getElementById('BloccoMenuRicercaHotel').style.display="block";
    document.getElementById('BloccoMenuRicercaAltri').style.display="none";
    document.getElementById('BloccoMenuRicercaPacchetti').style.display="none";	
}

function WB_MostraRicercaPacchetti(valoreProdotto,idBlocco,bSubmit,testo)
{
    var matDiv,i;
	matDiv=WB_ElencoDivRicerca.split(',');
	for(i=0;i<matDiv.length;i++ ) 	{document.getElementById('WBPulsCerca' + matDiv[i]).className='CellaPulsantiBloccoRicerca'; 	}
	if (idBlocco=='') {return;}
	document.getElementById('WBPulsCerca' + idBlocco).className='CellaAttivaPulsantiBloccoRicerca';
	try {document.getElementById('WBIntestazioneCercaProdotto').innerHTML=ReplaceTags(document.getElementById('WBPulsCerca' + idBlocco).innerHTML);} catch(exc){};
	modu=document.getElementById('moduloWBMenuCercaPacchetti')
    modu.wbcurrentdivcerca.value=idBlocco;
    document.getElementById('BloccoMenuRicercaHotel').style.display="none";
    document.getElementById('BloccoMenuRicercaAltri').style.display="none";    
	document.getElementById('BloccoMenuRicercaPacchetti').style.display="block";
	if (valoreProdotto != -1)
	{		
		document.getElementById('WBCercaTipologiaPacchetto').value=valoreProdotto;
		document.getElementById('WBPulsCerca' + idBlocco).className='CellaAttivaPulsantiBloccoRicerca';	
	};
	if (bSubmit) {submitWBRicerca('nuovaricerca',document.getElementById('WBCercaTipologiaPacchetto').form);}
	if (bSubmit==false) {initComboWB(true,idBlocco,valoreProdotto)}
}

function WB_MostraRicercaAltri(valoreProdotto,idBlocco,bSubmit)
{
    var matDiv,i;
	matDiv=WB_ElencoDivRicerca.split(',');
	for(i=0;i<matDiv.length;i++ ) 	{document.getElementById('WBPulsCerca' + matDiv[i]).className='CellaPulsantiBloccoRicerca'; 	}
	document.getElementById('WBPulsCerca' + idBlocco).className='CellaAttivaPulsantiBloccoRicerca';
	
	modu=document.getElementById('moduloWBMenuCercaAltri')
    modu.wbcurrentdivcerca.value=idBlocco;
	document.getElementById('BloccoMenuRicercaHotel').style.display="none";
    document.getElementById('BloccoMenuRicercaPacchetti').style.display="none";	
    document.getElementById('BloccoMenuRicercaAltri').style.display="block"; 
    if (valoreProdotto !='-1') {chkTipologiaAltriProdotti(document.getElementById('WBCercaTipologiaAltri').value, document.getElementById('WBCercaTipologiaAltri').form.id);    }
}

function submitWBRicerca(azione,modulo)
{ 
	var x;	
	if (azione == 'nuovaricerca') x=document.getElementById("localitaMenuCerca");
	if (azione == 'nuovaricercaaltri') 	x=document.getElementById("localitaMenuCercaAltri");	
	try {document.getElementById('desLocalitaCerca').value=x.options[x.selectedIndex].text; } catch(ee) { };
	modulo.azione.value='nuovaricerca';
	//verifica ricerca hotel
	if (modulo.id=='moduloWBMenuCercaHotel') {
	    if (document.getElementById('gruppolocalitaMenuCerca').selectedIndex==0 && document.getElementById('localitaMenuCerca').selectedIndex==0 && document.getElementById('WBCercaTipologiaHotel').selectedIndex==0) {
	        mostraAvvisoFisso(document.getElementById('gruppolocalitaMenuCerca'),Lang_JS01);
	        return false;
	        }
	}
	//verifica ricerca pacchetti
	if (modulo.id=='moduloWBMenuCercaPacchetti') {
	    if (document.getElementById('WBCercaTipologiaPacchetto').selectedIndex==0 && document.getElementById('gruppolocalitaMenuCerca').selectedIndex==0 && document.getElementById('localitaPacchettiMenuCerca').selectedIndex==0) {
	        mostraAvvisoFisso(document.getElementById('WBCercaTipologiaPacchetto'),Lang_JS01);	        
	        return false;
	        }
	}
	displayPopup(Lang_JS11);
	setTimeout(function(){modulo.submit();},0);
}

function MostraHotelPerLocalita(link)
{
    var o;
    o=document.getElementById('gruppolocalitaMenuCerca');
    if(o.value=='0') {mostraAvvisoFisso(o,Lang_JS13); return false;}
    location.href=link + '&zona=' + o.value;
}

function WB_AggiornaData(idObjInizio,idObjFine)
{
    var data1=document.getElementById(idObjInizio).value;
    var data2=document.getElementById(idObjFine).value;
    if (data1=="") return true;
    var oggetto2,gg,mm,aaaa;
    var oggetto1=new Date(parseInt(data1.substr(6)) ,parseInt(data1.substr(3, 2)-1),parseInt(data1.substr(0, 2)));
    if (data2=="") {oggetto2=new Date(2007,0,1) } else { oggetto2=new Date(parseInt(data2.substr(6)), parseInt(data2.substr(3, 2)-1), parseInt(data2.substr(0, 2)));  } ;
    if (oggetto2-oggetto1<0) {        
        newdate=dateAdd("d",7,oggetto1);
        gg=datePart("d",newdate); if(gg<10) {gg='0'+gg};
        mm=datePart("m",newdate);if(mm<10) {mm='0'+mm};
        aaaa=datePart("yyyy",newdate);
        document.getElementById(idObjFine).value=gg + '/' + mm + '/' + aaaa;
	    }    
}

function chkComboCercaTipologiaPacchetti()
{
    var obj,vl;
    try
    {
        obj=document.getElementById('WBCercaTipologiaPacchetto');
        vl='0';
        if (obj) {vl=obj.value;}
        if(vl.indexOf('[')>=0 || vl=='0')
            {
                document.getElementById('rigaDatePartenze').style.display='none';
				document.getElementById('rigaCercaLocalitaPartenza').style.display='none';
                document.getElementById('localitaPartenzaMenuCerca').value='0';
            }
        else
            {   
				document.getElementById('rigaCercaLocalitaPartenza').style.display='';
				document.getElementById('rigaDatePartenze').style.display='';
			}    
    
        initComboWB(false);
    }
    catch(aa)
    {}

}


function chkAdult(o,valore)
{return chkPaxChange(o,valore)}

function chkChild(o,valore)
{return chkPaxChange(o,valore)}

function chkInfant(o,valore)
{return chkPaxChange(o,valore)}

function chkPaxChange(o,valoreSel)
{
 if (!o) {return false;}
 var adH, chH, adP, chP,totP,oCamP,oCamH;
 adH=document.getElementById('adultiHotel');
 chH=document.getElementById('childHotel');
 adP=document.getElementById('adultiPacchetto');
 chP=document.getElementById('childPacchetto');
 if(o.id.toLowerCase().indexOf('pacchetto') >0)
    {  adH.value=adP.value; chH.value=chP.value;   }
 else
    {  adP.value=adH.value; chP.value=chH.value;   } 
 
 try 
 {
    totP=parseInt(adH.value) + parseInt(chH.value);
    oCamP=document.getElementById('numeroCamerePacchetti');
    oCamH=document.getElementById('numeroCamereHotel');
    var optDefault=document.createElement('option');
    var optDefaultH=document.createElement('option'); 
 
     optDefault=oCamP.options[0];
     optDefaultH=oCamH.options[0];
     oCamP.options.length=0;
     oCamH.options.length=0;
     //  --- creo numero massimo camere per Pacchetti ----
     try { oCamP.add(optDefault, null); }  catch(ex) {oCamP.add(optDefault);}
     
     for (iJ=1; iJ<=totP; iJ++)
     {
        optDefault=document.createElement('option');
        optDefault.text=iJ;
        optDefault.value=iJ;
        try
            { oCamP.add(optDefault, null);}
        catch(ex)
            {oCamP.add(optDefault);} 
      }

    //  --- creo numero massimo camere per Hotel ----
     try { oCamH.add(optDefaultH, null); } catch(ex) {oCamH.add(optDefaultH);}
     
     for (iJ=1; iJ<=totP; iJ++)
     {
        optDefault=document.createElement('option');
        optDefault.text=iJ;
        optDefault.value=iJ;
        try
            { oCamH.add(optDefault, null);}
        catch(ex)
            {oCamH.add(optDefault);} 
      } 
     if(valoreSel=='') {valoreSel=0;}
     try {oCamP.selectedIndex=parseInt(valoreSel); oCamH.selectedIndex=parseInt(valoreSel);chkSpecificheCamere(oCamH);chkSpecificheCamere(oCamP)} catch(ex) {}
}
catch(iii)
{
    //la gestione camere non è abilitata
}
}

function chkSpecificheCamere(obj)
{
    return;
    
    var i, k, oDiv, s, sHoP;
    s='';
    if(obj.id.indexOf('Hotel') >0) {oDiv=document.getElementById('specificheCamereHotel');sHoP='H';} else {oDiv=document.getElementById('specificheCamerePacchetti');sHoP='P';}
    if (obj.value == 0) {oDiv.innerHTML='';return;}
    for (k=1;k<=obj.value;k++)
    {
        s +='<div style="width:100%;border:1px solid #999999;margin-top:4px;background-color:#F2F2F2" class="divSpecificheSingolaCamera" >';
        s +='Camera ' + k + '<br>ADT:' + '<select id="adtCamera' + sHoP + k + '" name="adtCamera' + k + '"" class="mySelect" >' ;
        for (i=1;i<=10;i++)
        {
            if(i==1) {s +='<option value="0" >-</option>';}
            s +='<option value="' + i + '" >' + i + '</option>';
        }
        s +='</select>';
        // --- numero child ----
        if (obj.form.chd.value >0)
        {
            s +=' CHD: <select id="chdCamera' + sHoP + k + '" name="chdCamera' + k + '"" class="mySelect" >' ;
            for (i=1;i<=6;i++)
            {
                if(i==1) {s +='<option value="0" >-</option>';}
                s +='<option value="' + i + '" >' + i + '</option>';
            }
            s +='</select>';
        }
        else
        {s +='<input type="hidden" name="chdCamera' + k + '" value="0" id="chdCamera' + sHoP + k + '">';}
        // numero infant -----
        if (obj.form.inf.value >0)
        {
            s +=' INF: <select id="infCamera' + sHoP + k + '" name="infCamera' + k + '"" class="mySelect" >' ;
            for (i=1;i<=4;i++)
            {
                if(i==1) {s +='<option value="0" >-</option>';}
                s +='<option value="' + i + '" >' + i + '</option>';
            }        
            s +='</select>';
        }
        else
        {s +='<input type="hidden" name="infCamera' + k + '" value="0" id="infCamera' + sHoP + k + '">';}
        
        s +='</div>';
    }
    oDiv.innerHTML=s;
}


