﻿<!--

function visualizzaDIV(nomediv) 
{
    if (NomePagina=='index_step2')
    {
	    document.getElementById('divnave').style.display='none';
	    document.getElementById('divitinerario').style.display='none';
	    document.getElementById('divpartenze').style.display='none';
	    if (document.getElementById('divposizioneCabina'))
	    {    document.getElementById('divposizioneCabina').style.display='none';    }
	    document.getElementById(nomediv).style.display='block';
    }
	if (NomePagina=='index')
	{
        document.getElementById("divcrociere").style.display="none";
        document.getElementById("divcabine").style.display="none";
        document.getElementById("divposizioneCabina").style.display="none";
        document.getElementById("divcontattodiretto").style.display="none";
        if (nomediv=='divpartenze')
            document.getElementById('divcabine').style.display="block";
        else
            document.getElementById(nomediv).style.display="block";
    }
}

// POSIZIONE CABINA TOURICO
    
function posizioneCabinaTOU(CDcatCabina, IDtransazione, adulti, minorenni, RincaroNormaleTipo, RincaroNormale, RincaroNormaleTipo2, RincaroNormale2, RincaroInOffertaTipo, RincaroInOfferta, RincaroInOffertaTipo2, RincaroInOfferta2) 
{
    document.getElementById("divcrociere").style.display="none";
    document.getElementById("divcabine").style.display="none";
    document.getElementById("divposizioneCabina").style.display="block";
    RicercaInCorso('divposizioneCabina');
	Vacanze.it.WebServiceStep2.posizioneCabinaTOU(CDcatCabina, IDtransazione, adulti, minorenni, RincaroNormaleTipo, RincaroNormale, RincaroNormaleTipo2, RincaroNormale2, RincaroInOffertaTipo, RincaroInOfferta, RincaroInOffertaTipo2, RincaroInOfferta2, MostraPosizioneCabinaTOU, MostraErrorePosizioneCabinaTOU)
}

function MostraPosizioneCabinaTOU(ricerca)
{
    var docXML;
    if (window.ActiveXObject)
    {
        //Internet explorer
        docXML=new ActiveXObject("Microsoft.XMLDOM");
        docXML.async="false";
        docXML.loadXML(ricerca);
    }
    else
    {
        //Mozilla, Firefox, Opera
        var parser=new DOMParser();
        docXML=parser.parseFromString(ricerca,"text/xml");
    }
    var cabine=docXML.getElementsByTagName('cabine');
    if (cabine.length > 0)
    {
        var pezziHTML=cabine[0].getElementsByTagName('pezzoHTML');
	    contenuto="";
	    for(i=0; i < pezziHTML.length; i++)
	    {	contenuto=contenuto+pezziHTML[i].firstChild.data;	}
	    document.getElementById("divposizioneCabina").innerHTML = contenuto;//document.write(contenuto);
	}
	else
	{   document.getElementById("divposizioneCabina").innerHTML = ricerca;    }
}

function MostraErrorePosizioneCabinaTOU(risposta)
{
    document.getElementById("divposizioneCabina").innerHTML = "Errore<br/><b>" + risposta.get_exceptionType()+"</b>: "+risposta.get_message()+"<br/>"+risposta.get_stackTrace();
}

function chiudiCabine() 
{
    document.getElementById("divcrociere").style.display="block";
    document.getElementById("divposizioneCabina").style.display="none";
    document.getElementById("divcabine").style.display="none";
}

// RICERCA CROCIERE TOURICO

function RicercaTOUstep1(destinazione, periodo, durata, DataPartenza, CDnave, CDitinerario, adulti, minorenni, RincaroNormaleTipo, RincaroNormale, RincaroNormaleTipo2, RincaroNormale2, RincaroInOffertaTipo, RincaroInOfferta, RincaroInOffertaTipo2, RincaroInOfferta2)
{
    document.getElementById("divcrociere").style.display="none";
    document.getElementById("divcabine").style.display="block";
    document.getElementById("divposizioneCabina").style.display="none";
    RicercaInCorso('divcabine');
	Vacanze.it.WebServiceStep2.ricercaTOUstep1(destinazione, periodo, durata, DataPartenza, CDnave, CDitinerario, adulti, minorenni, RincaroNormaleTipo, RincaroNormale, RincaroNormaleTipo2, RincaroNormale2, RincaroInOffertaTipo, RincaroInOfferta, RincaroInOffertaTipo2, RincaroInOfferta2, MostraRisultatoTOUstep1, MostraErroreRisultatoTOU);
}

function MostraRisultatoTOUstep1(ricerca)
{
    var docXML;
    if (window.ActiveXObject)
    {
        //Internet explorer
        docXML=new ActiveXObject("Microsoft.XMLDOM");
        docXML.async="false";
        docXML.loadXML(ricerca);
    }
    else
    {
        //Mozilla, Firefox, Opera
        var parser=new DOMParser();
        docXML=parser.parseFromString(ricerca,"text/xml");
    }
    var crociere=docXML.getElementsByTagName('crociera');
    if (crociere.length > 0)
    {
	    var pezziHTML=crociere[0].getElementsByTagName("pezzoHTML");
	    if (pezziHTML[0].firstChild.data=="nessunacabina")
	    {
	        document.getElementById(aspxPrefisso2 + "hidndestinazione").value=crociere[0].getElementsByTagName("destinazione")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "hidnCDnave").value=crociere[0].getElementsByTagName("CDnave")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "hidnCDitinerario").value=crociere[0].getElementsByTagName("CDitinerario")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "hidnDataPartenza").value=crociere[0].getElementsByTagName("DataPartenza")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "hidncompagnia").value=crociere[0].getElementsByTagName("compagnia")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "hidnnave").value=crociere[0].getElementsByTagName("nave")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "hidncategoria").value="";
	        document.getElementById(aspxPrefisso2 + "hidnDataPartenza").value=crociere[0].getElementsByTagName("DataPartenza")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "hidnportoPartenza").value=crociere[0].getElementsByTagName("portoPartenza")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "hidndurata").value=crociere[0].getElementsByTagName("notti")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "hidnvaluta").value=crociere[0].getElementsByTagName("valuta")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "hidnimporto").value=crociere[0].getElementsByTagName("importo")[0].firstChild.data;
	        
	        document.getElementById(aspxPrefisso2 + "lblcompagnia").innerHTML=crociere[0].getElementsByTagName("compagnia")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "lblnave").innerHTML=crociere[0].getElementsByTagName("nave")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "lblcategoria").innerHTML="";
	        document.getElementById(aspxPrefisso2 + "lbldataPartenza").innerHTML=crociere[0].getElementsByTagName("DataPartenza")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "lblportoPartenza").innerHTML=crociere[0].getElementsByTagName("portoPartenza")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "lblnotti").innerHTML=crociere[0].getElementsByTagName("notti")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "lbltxtimporto").innerHTML="A partire da:";
	        document.getElementById(aspxPrefisso2 + "lblvaluta").innerHTML=crociere[0].getElementsByTagName("valuta")[0].firstChild.data;
	        document.getElementById(aspxPrefisso2 + "lblimporto").innerHTML=crociere[0].getElementsByTagName("importo")[0].firstChild.data;
	        
            document.getElementById("divcabine").style.display="none";
            document.getElementById("divcontattodiretto").style.display="block";
            document.getElementById("divviscategoriecabine").style.display="block";
            document.getElementById("divvisposizionecabina").style.display="none";
	    }
	    else
	    {
	        contenuto="";
	        for(i=0; i < pezziHTML.length; i++)
	        {	contenuto=contenuto+pezziHTML[i].firstChild.data;	}
	        document.getElementById("divcabine").innerHTML = contenuto;//document.write(contenuto);
	    }
	}
}

function MostraErroreRisultatoTOU(risposta)
{
    document.getElementById("divcrociere").innerHTML = "Errore<br/><b>" + risposta.get_exceptionType()+"</b>: "+risposta.get_message()+"<br/>"+risposta.get_stackTrace();
}

function azzeraNrricerche() 
{
	document.getElementById(aspxPrefisso1 + "lblNrCrociere").innerHTML="";
	document.getElementById(aspxPrefisso1 + "lbltxtNrCrociere").innerHTML="";
	document.getElementById(aspxPrefisso1 + "lblNrItinerari").innerHTML="";
	document.getElementById(aspxPrefisso1 + "lbltxtNrItinerari").innerHTML="";
}

function numerocrociere(selezioni) 
{
    periodo = document.getElementById(aspxPrefisso1 + "ddlPeriodo").value;
    compagnia = document.getElementById(aspxPrefisso1 + "ddlCompagnia").value;
    nave = document.getElementById(aspxPrefisso1 + "ddlNaveCrociera").value;
    destinazione = document.getElementById(aspxPrefisso1 + "ddlDestinazione").value;
    durata = document.getElementById(aspxPrefisso1 + "ddlDurata").value;
    if (NomePagina=='index_step2')
    {
	    document.getElementById(aspxPrefisso1 + "pnlspostamentiSX").style.visibility="hidden";
	    document.getElementById(aspxPrefisso1 + "pnlspostamentiDX").style.visibility="hidden";
    }
    if (periodo != "01/0001" || nave != "" || destinazione != "0" || durata != "1" || compagnia != "0")
    {
        if (selezioni.length > 0)
        {
		    nrcrociere=selezioni[0].getElementsByTagName("crociere")[0].childNodes[0].nodeValue;
		    nrpercorsi=selezioni[0].getElementsByTagName("Nrpercorsi")[0].childNodes[0].nodeValue;
		}
		else
		{
		    nrcrociere=0;
		    nrpercorsi=0;
		}
	    
		if (nrcrociere==0)
		{
			document.getElementById(aspxPrefisso1 + "lblNrCrociere").innerHTML="nessuna";
			document.getElementById(aspxPrefisso1 + "lbltxtNrCrociere").innerHTML="&nbsp;crociera trovata";	
			document.getElementById(aspxPrefisso1 + "lblNrItinerari").innerHTML="";
			document.getElementById(aspxPrefisso1 + "lbltxtNrItinerari").innerHTML="";
		}
		else
		{
			if (nrcrociere==1)
			{
				document.getElementById(aspxPrefisso1 + "lblNrCrociere").innerHTML="una";
				document.getElementById(aspxPrefisso1 + "lbltxtNrCrociere").innerHTML="&nbsp;crociera trovata";
				document.getElementById(aspxPrefisso1 + "lblNrItinerari").innerHTML="";
				document.getElementById(aspxPrefisso1 + "lbltxtNrItinerari").innerHTML="";
			}
			else
			{
                if (NomePagina=='index_step2' && nrpercorsi > 4)
                {
		            document.getElementById(aspxPrefisso1 + "pnlspostamentiSX").style.visibility="visible";
		            document.getElementById(aspxPrefisso1 + "pnlspostamentiDX").style.visibility="visible";
                }
				if (destinazione=="")
				{
					document.getElementById(aspxPrefisso1 + "lblNrCrociere").innerHTML=nrcrociere;
					document.getElementById(aspxPrefisso1 + "lbltxtNrCrociere").innerHTML="&nbsp;crociere trovate";
					document.getElementById(aspxPrefisso1 + "lblNrItinerari").innerHTML="";
					document.getElementById(aspxPrefisso1 + "lbltxtNrItinerari").innerHTML="";
				}
				else
				{
					document.getElementById(aspxPrefisso1 + "lblNrCrociere").innerHTML=nrcrociere;
					document.getElementById(aspxPrefisso1 + "lbltxtNrCrociere").innerHTML="&nbsp;crociere e";
					if (nrpercorsi==1)
					{
						document.getElementById(aspxPrefisso1 + "lblNrItinerari").innerHTML="";
						document.getElementById(aspxPrefisso1 + "lbltxtNrItinerari").innerHTML="&nbsp;un itinerario trovati";
					}
					else
					{
						document.getElementById(aspxPrefisso1 + "lblNrItinerari").innerHTML="&nbsp;"+nrpercorsi;
						document.getElementById(aspxPrefisso1 + "lbltxtNrItinerari").innerHTML="&nbsp;itinerari trovati";
					}
				}
			}
		}
	}
	else
	{
		document.getElementById(aspxPrefisso1 + "lblNrCrociere").innerHTML="";
		document.getElementById(aspxPrefisso1 + "lbltxtNrCrociere").innerHTML="";
		document.getElementById(aspxPrefisso1 + "lblNrItinerari").innerHTML="";
		document.getElementById(aspxPrefisso1 + "lbltxtNrItinerari").innerHTML="";
	}
}

function disabilitaricerca() 
{
    if (document.getElementById(aspxPrefisso1 + "btnCercaTutte"))
    {    document.getElementById(aspxPrefisso1 + "btnCercaTutte").disabled = true;   }
    if (document.getElementById(aspxPrefisso1 + "btnCercaOfferte"))
    {    document.getElementById(aspxPrefisso1 + "btnCercaOfferte").disabled = true; }
    document.getElementById(aspxPrefisso1 + "ddlPeriodo").disabled = true;
    document.getElementById(aspxPrefisso1 + "ddlNaveCrociera").disabled = true;
    document.getElementById(aspxPrefisso1 + "ddlDestinazione").disabled = true;
    document.getElementById(aspxPrefisso1 + "ddlDurata").disabled = true;
    document.getElementById(aspxPrefisso1 + "ddlComposizione").disabled = true;
    document.getElementById(aspxPrefisso1 + "ddlCompagnia").disabled = true;
    if (NomePagina=='index_step2')
    {
        document.getElementById(aspxPrefisso1 + "rbtnRicercaTutte").disabled = true;
        document.getElementById(aspxPrefisso1 + "rbtnRicercaInOfferta").disabled = true;
    }
    document.getElementById("btnreimposta").style.visibility="hidden";
}

function abilitaricerca(selezioni) 
{
    if (document.getElementById(aspxPrefisso1 + "btnCercaTutte"))
    {
        document.getElementById(aspxPrefisso1 + "btnCercaTutte").disabled = false;
    }
    if (document.getElementById(aspxPrefisso1 + "btnCercaOfferte"))
    {
        if (selezioni.length > 0)
        {	nrcrociereofferta=selezioni[0].getElementsByTagName("crociereOfferta")[0].childNodes[0].nodeValue;  }
        else
        {	nrcrociereofferta=0;    }
		if (nrcrociereofferta>0)
		{   document.getElementById(aspxPrefisso1 + "btnCercaOfferte").disabled = false; }
        else
		{   document.getElementById(aspxPrefisso1 + "btnCercaOfferte").disabled = true; }
    }
    document.getElementById(aspxPrefisso1 + "ddlPeriodo").disabled = false;
    if (document.getElementById(aspxPrefisso1 + "ddlCompagnia").value != "0")
    {
        document.getElementById(aspxPrefisso1 + "ddlNaveCrociera").disabled = false;
    }
    else
    {
        document.getElementById(aspxPrefisso1 + "ddlNaveCrociera").disabled = true;
    }
    document.getElementById(aspxPrefisso1 + "ddlDestinazione").disabled = false;
    document.getElementById(aspxPrefisso1 + "ddlDurata").disabled = false;
    document.getElementById(aspxPrefisso1 + "ddlComposizione").disabled = false;
    document.getElementById(aspxPrefisso1 + "ddlCompagnia").disabled = false;
    
    if (document.getElementById(aspxPrefisso1 + "ddlPeriodo").value=="01/0001" && 
        document.getElementById(aspxPrefisso1 + "ddlDestinazione").value=="0" && 
        document.getElementById(aspxPrefisso1 + "ddlDurata").value=="1" && 
        document.getElementById(aspxPrefisso1 + "ddlCompagnia").value=="0")
    {  document.getElementById("btnreimposta").style.visibility="hidden";	}  
    else
    {	document.getElementById("btnreimposta").style.visibility="visible";	}
    
    if (NomePagina=='index_step2')
    {
        if (selezioni.length > 0)
        {	nrcrociereofferta=selezioni[0].getElementsByTagName("crociereOfferta")[0].childNodes[0].nodeValue;  }
        else
        {	nrcrociereofferta=0;    }
		if (nrcrociereofferta>0)
		{
		   document.getElementById(aspxPrefisso1 + "rbtnRicercaTutte").disabled = false;
		   document.getElementById(aspxPrefisso1 + "rbtnRicercaInOfferta").disabled = false;
		}
        else
		{
		   document.getElementById(aspxPrefisso1 + "rbtnRicercaTutte").checked = true;
		   document.getElementById(aspxPrefisso1 + "rbtnRicercaTutte").disabled = true;
		   document.getElementById(aspxPrefisso1 + "rbtnRicercaInOfferta").disabled = true;
		}
    }
}

function nessunaRicerca()
{
	azzeraNrricerche();
    document.getElementById("divpercorsi").style.visibility="hidden";
    document.getElementById(aspxPrefisso1 + "pnlspostamentiSX").style.visibility="hidden";
    document.getElementById(aspxPrefisso1 + "pnlspostamentiDX").style.visibility="hidden";
    document.getElementById(aspxPrefisso1 + "lbltxtNrCrociere").innerHTML="Per effettuare una ricerca è obbligatorio selezionare la destinazione e il periodo!";
    document.getElementById("btnreimposta").style.visibility="hidden";
}

function reimposta()
{
	azzeraNrricerche();
    periodo = "01/0001";
    compagnia = "0";
    nave = "";
    destinazione = "0";
    durata = "1";
	adulti = 2;
	minorenni = 0;
	modo = "tutte";
    disabilitaricerca();
    
    if (NomePagina=='index_step2')
    {
        document.getElementById("divpercorsi").innerHTML = "";
        document.getElementById("divcrociere").innerHTML = "";
        document.getElementById(aspxPrefisso1 + "pnlspostamentiSX").style.visibility="hidden";
        document.getElementById(aspxPrefisso1 + "pnlspostamentiDX").style.visibility="hidden";
    }
	if (NomePagina=='index')
	{
        document.getElementById("divcrociere").style.display="block";
        document.getElementById("divposizioneCabina").style.display="none";
        document.getElementById("divcontattodiretto").style.display="none";
        document.getElementById("divcabine").style.display="none";
    }
    
    RicercaInCorso('divcrociere');
	Vacanze.it.WebServiceStep1.aggiornaSelezioni(NomePagina, periodo, destinazione, durata, compagnia, nave, adulti, minorenni, modo, RincaroNormaleTipo, RincaroNormale, RincaroInOffertaTipo, RincaroInOfferta, RincaroNormaleTipo2, RincaroNormale2, RincaroInOffertaTipo2, RincaroInOfferta2, RicaricoAgenziaMSC, RicaricoAgenziaCosta, reimposta2, aggiornaSelezioni2Errore);
}

function reimposta2(ricerca)
{
    var docXML;
    if (window.ActiveXObject)
    {
        //Internet explorer
        docXML=new ActiveXObject("Microsoft.XMLDOM");
        docXML.async="false";
        docXML.loadXML(ricerca);
    }
    else
    {
        //Mozilla, Firefox, Opera
        var parser=new DOMParser();
        docXML=parser.parseFromString(ricerca,"text/xml");
    }
    var selezioni=docXML.getElementsByTagName('selezioni');
    
    aggiornamenu(aspxPrefisso1 + "ddlPeriodo", "periodo", selezioni, 'SI');
    aggiornamenu(aspxPrefisso1 + "ddlDestinazione", "destinazione", selezioni, 'SI');
    aggiornamenu(aspxPrefisso1 + "ddlDurata", "durata", selezioni, 'SI');
    aggiornamenu(aspxPrefisso1 + "ddlCompagnia", "compagnia", selezioni, 'SI');
    aggiornamenu(aspxPrefisso1 + "ddlNaveCrociera", "nave", selezioni, 'SI');
    document.getElementById(aspxPrefisso1 + "ddlComposizione").options[1].selected = true;
    
    var pezziHTML=selezioni[0].getElementsByTagName('pezzoHTML');
    contenuto="";
    for(i=0; i < pezziHTML.length; i++)
    {	contenuto=contenuto+pezziHTML[i].firstChild.data;	}
    
	if (NomePagina=='index')
	{
        document.getElementById("divcrociere").innerHTML = contenuto;
    }
    if (NomePagina=='index_step2')
    {
        document.getElementById("divpercorsi").innerHTML = "";
        document.getElementById("divcrociere").innerHTML = "";
        document.getElementById(aspxPrefisso1 + "pnlspostamentiSX").style.visibility="hidden";
        document.getElementById(aspxPrefisso1 + "pnlspostamentiDX").style.visibility="hidden";
        document.getElementById(aspxPrefisso1 + "lbltxtNrCrociere").innerHTML="Per effettuare una ricerca è obbligatorio selezionare la destinazione e il periodo!";
	}
	abilitaricerca(selezioni);
}

function aggiornaSelezioni(parametroRicerca)
{
	azzeraNrricerche();
    if (parametroRicerca=="compagnia")
    {
        document.getElementById(aspxPrefisso1 + "ddlNaveCrociera").options[0].selected = true;
    }
    periodo = document.getElementById(aspxPrefisso1 + "ddlPeriodo").value;
    compagnia = document.getElementById(aspxPrefisso1 + "ddlCompagnia").value;
    if (compagnia!="0" && parametroRicerca!="compagnia")
    {
        nave = document.getElementById(aspxPrefisso1 + "ddlNaveCrociera").value;
    }
    else
    {
        nave = "";
    }
    destinazione = document.getElementById(aspxPrefisso1 + "ddlDestinazione").value;
    durata = document.getElementById(aspxPrefisso1 + "ddlDurata").value;
	composizione=document.getElementById(aspxPrefisso1 + "ddlComposizione").value.split(".");
	adulti=composizione[0];
	minorenni=composizione[1];
	if (NomePagina=='index')
	{   modo = "tutte";    }
    if (NomePagina=='index_step2')
    {
        if (document.getElementById(aspxPrefisso1 + "rbtnRicercaTutte").checked == true )
        {   modo = "tutte"; }
        if (document.getElementById(aspxPrefisso1 + "rbtnRicercaInOfferta").checked == true )
        {   modo = "inofferta"; }
	}
    disabilitaricerca();
    
    if (NomePagina=='index_step2')
    {
        document.getElementById("divpercorsi").style.visibility="hidden";
        document.getElementById(aspxPrefisso1 + "pnlspostamentiSX").style.visibility="hidden";
        document.getElementById(aspxPrefisso1 + "pnlspostamentiDX").style.visibility="hidden";
    }
    
	if (NomePagina=='index')
	{
        document.getElementById("divcrociere").style.display="block";
        document.getElementById("divposizioneCabina").style.display="none";
        document.getElementById("divcontattodiretto").style.display="none";
        document.getElementById("divcabine").style.display="none";
    }
    RicercaInCorso('divcrociere');
	Vacanze.it.WebServiceStep1.aggiornaSelezioni(NomePagina, periodo, destinazione, durata, compagnia, nave, adulti, minorenni, modo, RincaroNormaleTipo, RincaroNormale, RincaroNormaleTipo2, RincaroNormale2, RincaroInOffertaTipo, RincaroInOfferta, RincaroInOffertaTipo2, RincaroInOfferta2, RicaricoAgenziaMSC, RicaricoAgenziaCosta, aggiornaSelezioni2, aggiornaSelezioni2Errore);
}

function aggiornaSelezioni2(ricerca)
{
    var docXML;
    if (window.ActiveXObject)
    {
        //Internet explorer
        docXML=new ActiveXObject("Microsoft.XMLDOM");
        docXML.async="false";
        docXML.loadXML(ricerca);
    }
    else
    {
        //Mozilla, Firefox, Opera
        var parser=new DOMParser();
        docXML=parser.parseFromString(ricerca,"text/xml");
    }
    var selezioni=docXML.getElementsByTagName('selezioni');
    
    aggiornamenu(aspxPrefisso1 + "ddlPeriodo", "periodo", selezioni, 'NO');
    aggiornamenu(aspxPrefisso1 + "ddlDestinazione", "destinazione", selezioni, 'NO');
    aggiornamenu(aspxPrefisso1 + "ddlDurata", "durata", selezioni, 'NO');
    aggiornamenu(aspxPrefisso1 + "ddlCompagnia", "compagnia", selezioni, 'NO');
    if (document.getElementById(aspxPrefisso1 + "ddlCompagnia").value != "0")
    {
        aggiornamenu(aspxPrefisso1 + "ddlNaveCrociera", "nave", selezioni, 'NO');
    }
    else
    {
        //document.getElementById(aspxPrefisso1 + "ddlNaveCrociera").disabled = true;
        sel = document.getElementById(aspxPrefisso1 + "ddlNaveCrociera");
        sel.length = 1;
        sel.options[0].text = '';
        sel.options[0].value = "";
        sel.disabled = true;
    }
    
    if (NomePagina=='index_step2')
    {
	    if (document.getElementById(aspxPrefisso1 + "ddlDestinazione").value=="0" 
	        || document.getElementById(aspxPrefisso1 + "ddlPeriodo").value=="01/0001" )
	    {
		    document.getElementById(aspxPrefisso1 + "lbltxtNrCrociere").innerHTML="Per effettuare una ricerca è obbligatorio selezionare la destinazione e il periodo!";
	    }
	    else
	    {   numerocrociere(selezioni);  }
	}
	if (NomePagina=='index')
	{   numerocrociere(selezioni);    }
    
    if (selezioni.length > 0)
    {
        var pezziHTML=selezioni[0].getElementsByTagName('pezzoHTML');
        contenuto="";
        for(i=0; i < pezziHTML.length; i++)
        {	contenuto=contenuto+pezziHTML[i].firstChild.data;	}
	    if (NomePagina=='index')
	    {
            document.getElementById("divcrociere").innerHTML = contenuto;
        }
        if (NomePagina=='index_step2')
        {
            if (pezziHTML.length > 0 && document.getElementById(aspxPrefisso1 + "ddlDestinazione").value!="0" 
	            && document.getElementById(aspxPrefisso1 + "ddlPeriodo").value!="01/0001")
            {
                document.getElementById("divpercorsi").style.visibility="visible";
                document.getElementById("divpercorsi").innerHTML = contenuto;
            }
            else
            {
                document.getElementById("divpercorsi").style.visibility="hidden";
                document.getElementById("divpercorsi").innerHTML = "";
            }
            //document.getElementById("divcrociere").innerHTML = "";
            var RicercaIniziale=selezioni[0].getElementsByTagName('RicercaIniziale');
            if (RicercaIniziale.length > 0 && document.getElementById(aspxPrefisso1 + "ddlDestinazione").value!="0" 
	            && document.getElementById(aspxPrefisso1 + "ddlPeriodo").value!="01/0001")
            {
                var RICDpercorso=RicercaIniziale[0].getElementsByTagName("RicercaInizialeCDpercorso")[0].childNodes[0].nodeValue;
                var RICDnave=RicercaIniziale[0].getElementsByTagName("RicercaInizialeCDnave")[0].childNodes[0].nodeValue;
                var RIdestinazione=RicercaIniziale[0].getElementsByTagName("RicercaInizialedestinazione")[0].childNodes[0].nodeValue;
                var RIperiodo=RicercaIniziale[0].getElementsByTagName("RicercaInizialeperiodo")[0].childNodes[0].nodeValue;
                var RIdurata=RicercaIniziale[0].getElementsByTagName("RicercaInizialedurata")[0].childNodes[0].nodeValue;
                var RIadulti=RicercaIniziale[0].getElementsByTagName("RicercaInizialeadulti")[0].childNodes[0].nodeValue;
                var RIminorenni=RicercaIniziale[0].getElementsByTagName("RicercaInizialeminorenni")[0].childNodes[0].nodeValue;
                
                if (RicercaIniziale[0].getElementsByTagName("RicercaInizialetipo")[0].childNodes[0].nodeValue=="MSC")
                {
                    Vacanze.it.WebServiceStep2.ricercaMSC(RICDpercorso, RICDnave, RIperiodo, RIdestinazione, RIdurata, RIadulti, RIminorenni, RincaroNormaleTipo, RincaroNormale, RincaroNormaleTipo2, RincaroNormale2, RincaroInOffertaTipo, RincaroInOfferta, RincaroInOffertaTipo2, RincaroInOfferta2, RicaricoAgenziaMSC, MostraRisultatoMSC, MostraErroreRisultatoMSC);
                }
                if (RicercaIniziale[0].getElementsByTagName("RicercaInizialetipo")[0].childNodes[0].nodeValue=="Costa")
                {
                    Vacanze.it.WebServiceStep2.ricercaCosta(RICDpercorso, RICDnave, RIperiodo, RIdestinazione, RIdurata, RIadulti, RIminorenni, RincaroNormaleTipo, RincaroNormale, RincaroNormaleTipo2, RincaroNormale2, RincaroInOffertaTipo, RincaroInOfferta, RincaroInOffertaTipo2, RincaroInOfferta2, RicaricoAgenziaCosta, MostraRisultatoCosta, MostraErroreCosta);
                }
                if (RicercaIniziale[0].getElementsByTagName("RicercaInizialetipo")[0].childNodes[0].nodeValue=="Tourico")
                {
	        	    Vacanze.it.WebServiceStep2.ricercaTOU(RIdestinazione, RIperiodo, RIdurata, RICDnave, RICDpercorso, RIadulti, RIminorenni, RincaroNormaleTipo, RincaroNormale, RincaroNormaleTipo2, RincaroNormale2, RincaroInOffertaTipo, RincaroInOfferta, RincaroInOffertaTipo2, RincaroInOfferta2, MostraRisultatoTOU, MostraErroreRisultatoTOU);
                }
            }
            else document.getElementById("divcrociere").innerHTML = "";
        }
    }
	abilitaricerca(selezioni);
}

function aggiornamenu(selezioneNome, selezione, selezioni, reimposta)
{
	sel = document.getElementById(selezioneNome);
	valore = document.getElementById(selezioneNome).value;
	
    if (selezioni.length > 0)
    {
	    var elementi=selezioni[0].getElementsByTagName(selezione);
        sel.length = elementi.length + 1;
	    
	    if (selezione=='periodo')
	    {
	        if (NomePagina=='index')
	        {   sel.options[0].text = 'selezionare';    }
	        else if (NomePagina=='index_step2')
	        {   sel.options[0].text = 'periodo';    }
            sel.options[0].value = "01/0001";
            if (reimposta == 'SI') sel.options[0].selected = true;
        }
	    if (selezione=='destinazione')
	    {
	        if (NomePagina=='index')
	        {   sel.options[0].text = 'selezionare';    }
	        else if (NomePagina=='index_step2')
	        {   sel.options[0].text = 'destinazione';    }
            sel.options[0].value = "0";
            if (reimposta == 'SI') sel.options[0].selected = true;
        }
	    if (selezione=='durata')
	    {
	        if (NomePagina=='index')
	        {   sel.options[0].text = 'qualsiasi';    }
	        else if (NomePagina=='index_step2')
	        {   sel.options[0].text = 'durata';    }
            sel.options[0].value = "1";
            if (reimposta == 'SI') sel.options[0].selected = true;
        }
	    if (selezione=='compagnia')
	    {
	        if (NomePagina=='index')
	        {   sel.options[0].text = 'qualsiasi';    }
	        else if (NomePagina=='index_step2')
	        {   sel.options[0].text = 'compagnia';    }
            sel.options[0].value = "0";
            if (reimposta == 'SI') sel.options[0].selected = true;
        }
	    if (selezione=='nave')
	    {
	        if (NomePagina=='index')
	        {   sel.options[0].text = 'qualsiasi';    }
	        else if (NomePagina=='index_step2')
	        {   sel.options[0].text = 'nave';    }
            sel.options[0].value = "";
            if (reimposta == 'SI') sel.options[0].selected = true;
        }
        for (var i = 1; i <= elementi.length; i++)
        {
            sel.options[i].text = elementi[i - 1].getElementsByTagName("testo")[0].childNodes[0].nodeValue;
            sel.options[i].value = elementi[i - 1].getElementsByTagName("valore")[0].childNodes[0].nodeValue;
            if (reimposta == 'NO' && valore == sel.options[i].value) sel.options[i].selected = true;
        }
	}
}


function aggiornaSelezioni2Errore(risposta)
{
    document.getElementById("divcrociere").innerHTML = "Errore<br/><b>" + risposta.get_exceptionType()+"</b>: "+risposta.get_message()+"<br/>"+risposta.get_stackTrace();
}

function controllaselezioni()
{
	var esitoControlli = true;
    destinazione=document.getElementById(aspxPrefisso1 + "ddlDestinazione").value;
    periodo=document.getElementById(aspxPrefisso1 + "ddlPeriodo").value;
	if (destinazione=="0" || periodo=="01/0001" )
	{
		window.alert("Per effettuare una ricerca è obbligatorio selezionare la destinazione e il periodo!");
		esitoControlli=false;
	}
	else
	{
        RicercaInCorso('divcrociere');
    }
    return esitoControlli;
}

GiorniMesi = new Array();
GiorniMesi["01"] = 31;
GiorniMesi["02"] = 29;// anno bisestile?
GiorniMesi["03"] = 31;
GiorniMesi["04"] = 30;
GiorniMesi["05"] = 31;
GiorniMesi["06"] = 30;
GiorniMesi["07"] = 31;
GiorniMesi["08"] = 31;
GiorniMesi["09"] = 30;
GiorniMesi["10"] = 31;
GiorniMesi["11"] = 30;
GiorniMesi["12"] = 31;

function controllacampi()
{
	var nome=document.getElementById(aspxPrefisso2 + "txtNomeA1").value;
	var cognome=document.getElementById(aspxPrefisso2 + "txtCognomeA1").value;
	var giorno=document.getElementById(aspxPrefisso2 + "ddlGiornoA1").value;
	var mese=document.getElementById(aspxPrefisso2 + "ddlMesiA1").value;
	var anno=document.getElementById(aspxPrefisso2 + "ddlAnniA1").value;
	
	PsgInseriti=true;
	DateCorrette=true;
	
	if (nome=="" || cognome=="" || giorno=="" || mese=="" || anno=="" )
	{	PsgInseriti=false;	}
	if (GiorniMesi[mese]<giorno)
	{	DateCorrette=false;	}
	
	var esitoControlli = true;
	if (PsgInseriti==false || DateCorrette==false)
	{
	    esitoControlli = false;
		if (PsgInseriti==false)
			window.alert("Attenzione! Non sono stati inseriti tutti i dati!");
		else
		{
			if (DateCorrette==false)
				window.alert("Attenzione! La data inserita non è corretta!");
		}
	}
	else
	{
	    esitoControlli = false;
		via=document.getElementById(aspxPrefisso2 + "txtViaA1").value;
		nr=document.getElementById(aspxPrefisso2 + "txtNrA1").value;
		cap=document.getElementById(aspxPrefisso2 + "txtCAPA1").value;
		citta=document.getElementById(aspxPrefisso2 + "txtCittaA1").value;
		ddlNazioni=document.getElementById(aspxPrefisso2 + "ddlNazioni").value;
		ddlProvincie=document.getElementById(aspxPrefisso2 + "ddlProvincie").value;
		telefono=document.getElementById(aspxPrefisso2 + "txtTelefonoA1").value;
		cellulare=document.getElementById(aspxPrefisso2 + "txtCellulareA1").value;
		email_da=document.getElementById(aspxPrefisso2 + "txtEmailA1").value;
		/*RecapitiInseriti=true;
		if (via=="" || nr=="" || cap=="" || citta=="" || ddlNazioni=="" || telefono=="" || cellulare=="" || email_da=="" )
		{	RecapitiInseriti=false;	}
		if (ddlNazioni=="Italy" && ddlProvincie=="")
		{	RecapitiInseriti=false;	}*/
		if ((telefono=="" && cellulare=="") || email_da=="")
		{
			if (telefono=="" && cellulare=="")
			{	window.alert("Attenzione! Bisogna inserire il telefono fisso o il cellulare!");	}
			else
			{	window.alert("Attenzione! E' obbligatorio inserire l'email!");	}
		}
		else
		{
			var pe=email_da.indexOf('.');
			var ss=email_da.indexOf(' ');
			var lch=email_da.length-1;
			var atr=email_da.indexOf('@');
			var att=atr+1;
			var sq=email_da.substring(0,atr); 
			var sw=email_da.substring(atr,pe); 
			var se=email_da.substring(pe,lch);
			if((atr<1) || (pe==lch) || (pe<1)  || (ss != -1) || (sq.length<=2) || (sw.length<=3) || (se.length<=1)) // || (pe<=att)
			{	window.alert("L'email non è valida");	}
			else
			{
				if (isNaN(telefono) || isNaN(cellulare))
				{	window.alert("Il telefono o il cellulare non sono corretti, inserire solo caratteri numerici");	}
				else
				{
					if (document.getElementById(aspxPrefisso2 + "chkConsenso").checked==false )
					{	window.alert("E' obbligatorio esprimere il consenso alla privacy!");	}
					else
					{
						if (document.getElementById(aspxPrefisso2 + "chkTerminiCondizioni").checked==false )
						{	window.alert("E' obbligatorio accettare i termini e le condizioni di vendita!");	}
						else
						{   esitoControlli = true; }
					}
				}
			}
		}
	}
    return esitoControlli;
}

function RicercaInCorso(contenitore) 
{
    contenuto="<table width='100%' height='300px'><tr><td align='center'>";
    contenuto=contenuto+"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='150' height='150' id='banner_intro' align='middle'>";
    contenuto=contenuto+"<param name='allowScriptAccess' value='sameDomain' />";
    contenuto=contenuto+"<param name='movie' value='immagini/loader.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><embed src='immagini/loader.swf' quality='high' bgcolor='#ffffff' width='150' height='150' name='banner_intro' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
    contenuto=contenuto+"</object>";
    contenuto=contenuto+"</td></tr></table>";
    contenuto=contenuto+"<script type='text/javascript'> \n";
    contenuto=contenuto+"// <![CDATA[ \n";
    contenuto=contenuto+"var fo = new FlashObject(\"immagini/loader.swf\", \"main\", \"150px\", \"150px\", \"8\", \"#000000\");";
    contenuto=contenuto+"fo.addParam(\"wmode\", \"transparent\");fo.addParam(\"salign\", \"t\"); fo.addParam(\"menu\", \"false\"); fo.write(\"banner\"); \n";
    contenuto=contenuto+"// ]]> \n";
    contenuto=contenuto+"</script>";
    document.getElementById(contenitore).innerHTML = contenuto;
}


//-->