var starter = new Date();
var ajaxSearchBoxDD = null;     
var ajaxSearchBoxDPDD = null;  
var ajaxSearchBoxShipDD = null;  
var ajaxSearchBoxShipItinDD = null; 

var m_names = new Array("January", "February", "March", 
"April", "May", "June", "July", "August", "September", 
"October", "November", "December");

onload=function(){
for(i=0; i<document.forms.length; i++) {
    document.forms[i].reset();
}
}


function AddCommaPerThousand(number) {
number = '' + number;
if (number.length > 3) {
var mod = number.length % 3;
var output = (mod > 0 ? (number.substring(0,mod)) : '');
for (i=0 ; i < Math.floor(number.length / 3); i++) {
if ((mod == 0) && (i == 0))
output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
else
output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
}
return (output);
}
else return number;
}

function getSailingStartDateDD(datein) {
    startday = 1;
    
    datearr = datein.split("-");
    
     monthin = datearr[1];
     yearin = datearr[0];
    
     endday = monthin + "-1-" + yearin; 
   return endday; 
}

function getSailingEndDateDD(datein) {
    startday = 1;
 
    datearr = datein.split("-");
    
    yearin = datearr[0];
    monthin = datearr[1];
   
     monthin = parseInt(monthin) + 1;
     if (parseInt(monthin) > 12) {
         monthin=1;
         yearin = parseInt(yearin) +1;
     }
    
     endday = monthin + "-1-" +  yearin; 
     

   return endday; 
}
     
     
function CallAjaxSearchBoxDPDD(portid,vendorid,SailDate,NoNights){
    try{
    ajaxSearchBoxDPDD = new XMLHttpRequest();
    } catch (e){
    try{
    ajaxSearchBoxDPDD = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try{
    ajaxSearchBoxDPDD = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e){
    alert("Please use the site with a recent browser.");
    return false;
}
}
}
//alert(portid);

durationFrom = "";
durationTo = "";   
startSailingDate = "";
endSailingDate = "";

if (SailDate != "")     {
startSailingDate =  getSailingStartDateDD(SailDate);
endSailingDate = getSailingEndDateDD(SailDate);
}


if (NoNights.indexOf("-") > -1) {
    nightsArray = NoNights.split('-');
    durationFrom = nightsArray[0];
    durationTo = nightsArray[1];  
}



ajaxQueryString = "/feed/searchselectionweb.php?DDType=Port&CallBack=&VendorID=" + vendorid + "&ShipID=&PortID=" + portid + "&CruiseDestinationID&Sail_DateFrom=" + startSailingDate + "&Sail_DateTo=" + endSailingDate + "&DurationFrom=" + durationFrom + "&DurationTo=" + durationTo + "&data=JSON&device=websearch&tm=" + starter.getTime();
                              

ajaxSearchBoxDPDD.open("GET", ajaxQueryString, true);
ajaxSearchBoxDPDD.onreadystatechange = handleajaxDPDDResponseText;
ajaxSearchBoxDPDD.send(null);
}     

function handleajaxDPDDResponseText()
{
totalCount = 0;    
elementPort = document.getElementById('dpPortID');
elementCount = document.getElementById('ttlCruisesFoundPort');
elementNN = document.getElementById('dpDuration');  
elementSailingDate = document.getElementById('dpStartDate');

var elementCL = document.getElementById('dpCruiseLine');    
   
           if((ajaxSearchBoxDPDD.readyState == 4)&& (ajaxSearchBoxDPDD.status == 200))  
            {
                
          try{     
                
responsePort = ajaxSearchBoxDPDD.responseText;
daJSON = eval('(' + responsePort + ')');



DaDDCount = daJSON.Response.ItinerariesCount;          

     
totalCount = DaDDCount.Count;   
totalCount = AddCommaPerThousand(totalCount);



                            fullText = totalCount + ' Cruises Found'; 
                            
                              if (totalCount == 0)   {
                               fullText = 'No Cruises Found';   
                              }
                              
                              if (totalCount == 1)   {
                               fullText = '1 Cruise Found';   
                              }
                            
 elementCount.innerHTML = fullText; 
 
     selectedIndexValue = elementPort.selectedIndex;   

     selectedValue = elementPort.options[selectedIndexValue].value

     DaPort = daJSON.Response.Ports;    

     totalPort = DaPort.Port.length;
     

     elementPort.options[0].selected = true;   
     elementPort.options.length = 0;
     elementPort.options[0] = new Option('All Departure Ports', '');        

      for (x=0; x<=totalPort -1; x++)
                        {
                         
                                    daname = DaPort.Port[x].PortName;
                                    
                                    if (DaPort.Port[x].Country != "") {
                                     
                                     if (DaPort.Port[x].Country == "USA") {
                                         
                                        daname = daname + ", " + DaPort.Port[x].State; 
                                     } else {
                                        daname = daname + ", " + DaPort.Port[x].Country;  
                                         
                                     }
                                        
                                    }
                                    
                                    
                                    davalue = DaPort.Port[x].ID;    
                                    elementPort.options[x+1] = new Option(daname, davalue);
                                    
                                       if (davalue == selectedValue) {
                                       elementPort.options[x+1].selected = true; 
                                       } 
                     
                    }
     

 
     selectedIndexValue = elementSailingDate.selectedIndex;   
     selectedValue = elementSailingDate.options[selectedIndexValue].value;
     elementSailingDate.options[0].selected = true; 
     elementSailingDate.options.length = 0;
     elementSailingDate.options[0] = new Option('All Sailing Dates', ''); 
      
     DaSailingDates = daJSON.Response.MonthYear;          
 
     totalSailingDates = DaSailingDates.SailingDate.length;
      
         
        

      for (x=0; x<=totalSailingDates -1; x++)
                        {
                         
                                    daname = m_names[DaSailingDates.SailingDate[x].DAMONTH-1] + " "  + DaSailingDates.SailingDate[x].DAYEAR;
                                    davalue = DaSailingDates.SailingDate[x].DAYEAR + "-"  + DaSailingDates.SailingDate[x].DAMONTH;      

                                    
                                    elementSailingDate.options[x+1] = new Option(daname, davalue);
                                     
                                       if (davalue == selectedValue) {
                                       elementSailingDate.options[x+1].selected = true; 
                                       } 

                                            
                    }
     
     
     selectedIndexValue = elementNN.selectedIndex;  
     selectedValue = elementNN.options[selectedIndexValue].value;   
     elementNN.options[0].selected = true; 
     elementNN.options.length = 0;
     elementNN.options[0] = new Option('Any Number of Nights', ''); 
 
     DaDuration = daJSON.Response.NoOfNights;          
     totalDuration = DaDuration.Range.length;
         


      for (x=0; x<=totalDuration -1; x++)
                        {
                            

                            
                            daname = DaDuration.Range[x].From + " - " + DaDuration.Range[x].To + " nights";
                            
                         
                                                     
                            if (DaDuration.Range[x].From == "15") { daname = DaDuration.Range[x].From + " or longer"; }
                            
                            
                         
                                    davalue = DaDuration.Range[x].From + "-" + DaDuration.Range[x].To;       

                                    elementNN.options[x+1] = new Option(daname, davalue);
                                    
                                  
                                       if (davalue == selectedValue) {
                                       elementNN.options[x+1].selected = true; 
                                       } 
                               
                                    
                                                  
                    }
     
     
     selectedIndexValue = elementCL.selectedIndex; 
     selectedValue = elementCL.options[selectedIndexValue].value;    

     DaCruiseLine = daJSON.Response.CruiseLines;          
 
     totalVendors = DaCruiseLine.Vendor.length;
     elementCL.options[0].selected = true;     
     elementCL.options.length = 0;
     elementCL.options[0] = new Option('Any Cruise Line', '');    

      for (x=0; x<=totalVendors -1; x++)
                        {      
                            daname = DaCruiseLine.Vendor[x].VendorDesc;
                            davalue = DaCruiseLine.Vendor[x].ID;       
                            elementCL.options[x+1] = new Option(daname, davalue);

                                                  
                   
      
      

                                       if (davalue == selectedValue) {
                                       elementCL.options[x+1].selected = true; 
                                       } 
     
                         } 
     
  }    
      catch(e){
             }
              
 } 
  
 

          
  
}  

     
function CallAjaxSearchBoxDD(vendorid,destid,SailDate,NoNights){
    try{
    ajaxSearchBoxDD = new XMLHttpRequest();
    } catch (e){
    try{
    ajaxSearchBoxDD = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try{
    ajaxSearchBoxDD = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e){
    alert("Please use the site with a recent browser.");
    return false;
}
}
}

durationFrom = "";
durationTo = "";   
startSailingDate = "";
endSailingDate = "";

if (SailDate != "")     {
startSailingDate =  getSailingStartDateDD(SailDate);
endSailingDate = getSailingEndDateDD(SailDate);
}


if (NoNights.indexOf("-") > -1) {
    nightsArray = NoNights.split('-');
    durationFrom = nightsArray[0];
    durationTo = nightsArray[1];  
}


ajaxQueryString = "/feed/searchselectionweb.php?DDType=Dest&CallBack=&VendorID=" + vendorid + "&ShipID=&CruiseDestinationID=" + destid + "&PortID=&Sail_DateFrom=" + startSailingDate + "&Sail_DateTo=" + endSailingDate + "&DurationFrom=" + durationFrom + "&DurationTo=" + durationTo + "&data=JSON&device=websearch&tm=" + starter.getTime();

//alert(ajaxQueryString);


ajaxSearchBoxDD.open("GET", ajaxQueryString, true);
ajaxSearchBoxDD.onreadystatechange = handleajaxDDResponseText;
ajaxSearchBoxDD.send(null);
}

function handleajaxDDResponseText()
{
totalCount = 0;    
elementDest = document.getElementById('CruiseDestinationID');
elementCount = document.getElementById('ttlCruisesFound');
elementCountTwo = document.getElementById('ttlCruisesFound2');


elementNN = document.getElementById('Duration');  
elementSailingDate = document.getElementById('StartDate');

var elementCL = document.getElementById('CruiseLine');    
   
           if((ajaxSearchBoxDD.readyState == 4)&& (ajaxSearchBoxDD.status == 200))  
            {
                
           try{     
                
responseDest = ajaxSearchBoxDD.responseText;
daJSON = eval('(' + responseDest + ')');


DaDDCount = daJSON.Response.ItinerariesCount;          
     
totalCount = DaDDCount.Count;   
totalCount = AddCommaPerThousand(totalCount);

                            fullText = totalCount + ' Cruises Found';
                           
                            fullText2 = totalCount;
 
                              if (totalCount == 0)   {
                               fullText = 'No Cruises Found';  
                               fullText2 = "0"; 
                              }
                              
                              if (totalCount == 1)   {
                               fullText = '1 Cruise Found'; 
                               fullText2 = "1";  
                              }

                              if (elementCount != null) { 
                       elementCount.innerHTML = fullText;   
                      }
                      
                        if (elementCountTwo != null) { 
                       elementCountTwo.innerHTML = fullText2;   
                      }
 

     selectedIndexValue = elementDest.selectedIndex;   
     


     
     selectedValue = elementDest.options[selectedIndexValue].value

     
     
     DaDest = daJSON.Response.Destinations;          

     destinationIN = daJSON.Response.CruiseDestinationID; 

      
     totalDest = DaDest.Destination.length;
     elementDest.options[0].selected = true;   
     elementDest.options.length = 0;
     elementDest.options[0] = new Option('All Destinations', '');        

   
      for (x=0; x<=totalDest -1; x++)
                        {
                         
                                    daname = DaDest.Destination[x].DestinationDesc;
                                    davalue = DaDest.Destination[x].CruiseDestinationID;    
                                    elementDest.options[x+1] = new Option(daname, davalue);
                                    
                                       if (davalue == selectedValue) {
                                       elementDest.options[x+1].selected = true; 
                                       } 
                                       
                                       if (davalue == destinationIN) {
                                       elementDest.options[x+1].selected = true; 
                                       }
                                       
                                       
                     
                    }
     

     selectedIndexValue = elementSailingDate.selectedIndex;   
     selectedValue = elementSailingDate.options[selectedIndexValue].value;
     elementSailingDate.options[0].selected = true; 
     elementSailingDate.options.length = 0;
     elementSailingDate.options[0] = new Option('All Sailing Dates', ''); 
      
     DaSailingDates = daJSON.Response.MonthYear;          
 
    SailingDatesIN = daJSON.Response.SailingDates;    

     totalSailingDates = DaSailingDates.SailingDate.length;
      
          arrSailingDatesIN = SailingDatesIN.split("-");
           SailingDatesIN = arrSailingDatesIN[2] + "-" + arrSailingDatesIN[0]; 
           

      for (x=0; x<=totalSailingDates -1; x++)
                        {
                         
                                    daname = m_names[DaSailingDates.SailingDate[x].DAMONTH-1] + " "  + DaSailingDates.SailingDate[x].DAYEAR;
                                    davalue = DaSailingDates.SailingDate[x].DAYEAR + "-"  + DaSailingDates.SailingDate[x].DAMONTH;      

                                    
                                    elementSailingDate.options[x+1] = new Option(daname, davalue);
                                     
                                       if (davalue == selectedValue) {
                                       elementSailingDate.options[x+1].selected = true; 
                                       } 
                                      
                                       
                                          if (davalue == SailingDatesIN) {
                                       elementSailingDate.options[x+1].selected = true; 
                                       }
                                       
                       
                                       

                                            
                    }
     
     
     selectedIndexValue = elementNN.selectedIndex;  
     selectedValue = elementNN.options[selectedIndexValue].value;   
     elementNN.options[0].selected = true; 
     elementNN.options.length = 0;
     elementNN.options[0] = new Option('Any Number of Nights', ''); 
 
     DaDuration = daJSON.Response.NoOfNights;          
     totalDuration = DaDuration.Range.length;
         
      DurationIN = daJSON.Response.Duration;      

      for (x=0; x<=totalDuration -1; x++)
                        {
                            

                            
                            daname = DaDuration.Range[x].From + " - " + DaDuration.Range[x].To + " nights";
                            
                         
                                                     
                            if (DaDuration.Range[x].From == "15") { daname = DaDuration.Range[x].From + " or longer"; }
                            
                            
                         
                                    davalue = DaDuration.Range[x].From + "-" + DaDuration.Range[x].To;       

                                    elementNN.options[x+1] = new Option(daname, davalue);
                                    
                                  
                                       if (davalue == selectedValue) {
                                       elementNN.options[x+1].selected = true; 
                                       } 
                               
                               if (davalue == DurationIN ) {
                                       elementNN.options[x+1].selected = true; 
                                       } 
                               
                               
                                    
                                                  
                    }
     
     
     selectedIndexValue = elementCL.selectedIndex; 
     selectedValue = elementCL.options[selectedIndexValue].value;    

     DaCruiseLine = daJSON.Response.CruiseLines;          
     vendorIDIN = daJSON.Response.VendorID;  

     totalVendors = DaCruiseLine.Vendor.length;
     elementCL.options[0].selected = true;     
     elementCL.options.length = 0;
     elementCL.options[0] = new Option('Any Cruise Line', '');    

      for (x=0; x<=totalVendors -1; x++)
                        {      
                            daname = DaCruiseLine.Vendor[x].VendorDesc;
                            davalue = DaCruiseLine.Vendor[x].ID;       
                            elementCL.options[x+1] = new Option(daname, davalue);

                                                  
                   
                                       if (davalue == selectedValue) {
                                       elementCL.options[x+1].selected = true; 
                                       } 
                                          
                                   
                                       if (davalue == vendorIDIN) {
                                       elementCL.options[x+1].selected = true; 
                                       } 
                                       
                                       
                                       
     
                         } 
     
 }    
 
              catch(e){
                  
                 // CallAjaxDestinationDD('','','',''); 
              }
 } 
  
 

          
  
}  



function CallAjaxSearchBoxShipDD(shipid,itinid,vendorid){
    try{
    ajaxSearchBoxShipDD = new XMLHttpRequest();
    } catch (e){
    try{
    ajaxSearchBoxShipDD = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try{
    ajaxSearchBoxShipDD = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e){
    alert("Please use the site with a recent browser.");
    return false;
}
}
}
//alert(portid);


ajaxQueryString = "/feed/searchselectionweb.php?DDType=Ship&CallBack=&VendorID=" + vendorid + "&ShipID=" + shipid + "&PortID=&ItinID&CruiseDestinationID&Sail_DateFrom=&Sail_DateTo=&DurationFrom=&DurationTo=&data=JSON&device=websearch&tm=" + starter.getTime();

//alert(ajaxQueryString);

ajaxSearchBoxShipDD.open("GET", ajaxQueryString, true);
ajaxSearchBoxShipDD.onreadystatechange = handleajaxShipDDResponseText;
ajaxSearchBoxShipDD.send(null);
}     

function CallAjaxSearchBoxShipItinDD(shipid,itinid,vendorid){
    try{
    ajaxSearchBoxShipItinDD = new XMLHttpRequest();
    } catch (e){
    try{
    ajaxSearchBoxShipItinDD = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try{
    ajaxSearchBoxShipItinDD = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e){
    alert("Please use the site with a recent browser.");
    return false;
}
}
}



ajaxQueryString = "/feed/searchselectionweb.php?DDType=Ship&CallBack=&VendorID=" + vendorid + "&ShipID=" + shipid + "&PortID=&ItinID&CruiseDestinationID&Sail_DateFrom=&Sail_DateTo=&DurationFrom=&DurationTo=&data=JSON&device=websearch&tm=" + starter.getTime();

//alert(ajaxQueryString);

ajaxSearchBoxShipItinDD.open("GET", ajaxQueryString, true);
ajaxSearchBoxShipItinDD.onreadystatechange = handleajaxShipItinDDResponseText;
ajaxSearchBoxShipItinDD.send(null);
}   


function handleajaxShipDDResponseText()
{
totalCount = 0;    
elementitin = document.getElementById('shipItinerary');
elementCount = document.getElementById('ttlCruisesFoundShip');
elementCruiseline = document.getElementById('shipCruiseline');
elementShip = document.getElementById('shipShip');

   
           if((ajaxSearchBoxShipDD.readyState == 4)&& (ajaxSearchBoxShipDD.status == 200))  
            {
                
          try{     
                
responseShip = ajaxSearchBoxShipDD.responseText;
daJSON = eval('(' + responseShip + ')');

//alert(responseShip);

DaDDCount = daJSON.Response.ItinerariesCount;          

     
totalCount = DaDDCount.Count;   
totalCount = AddCommaPerThousand(totalCount);



                            fullText = totalCount + ' Cruises Found'; 
                            
                              if (totalCount == 0)   {
                               fullText = 'No Cruises Found';   
                              }
                              
                              if (totalCount == 1)   {
                               fullText = '1 Cruise Found';   
                              }
                            
 elementCount.innerHTML = fullText; 
 
     selectedIndexValue = elementShip.selectedIndex;   

     selectedValue = elementShip.options[selectedIndexValue].value

     DaShip = daJSON.Response.Ships;    

     totalShip = DaShip.Ship.length;
     

     elementShip.options[0].selected = true;   
     elementShip.options.length = 0;
     elementShip.options[0] = new Option('Select a Cruise Ship', '');        

      for (x=0; x<=totalShip -1; x++)
                        {
                         
                                    daname = DaShip.Ship[x].ShipName;
                          
                               
                                    
                                    
                                    davalue = DaShip.Ship[x].ID;    
                                    elementShip.options[x+1] = new Option(daname, davalue);
                                    
                                       if (davalue == selectedValue) {
                                       elementShip.options[x+1].selected = true; 
                                       } 
                     
                    }
     

          
 

     
  }    
      catch(e){
             }
              
 } 
  
 

          
  
}  



function handleajaxShipItinDDResponseText()
{
totalCount = 0;    
elementitin = document.getElementById('shipItinerary');
elementCount = document.getElementById('ttlCruisesFoundShip');


   
           if((ajaxSearchBoxShipItinDD.readyState == 4)&& (ajaxSearchBoxShipItinDD.status == 200))  
            {
                
    try{     
                
responseItin = ajaxSearchBoxShipItinDD.responseText;
daJSON = eval('(' + responseItin + ')');

//alert(responseItin);

DaDDCount = daJSON.Response.ItinerariesCount;          

     
totalCount = DaDDCount.Count;   
totalCount = AddCommaPerThousand(totalCount);



                            fullText = totalCount + ' Cruises Found'; 
                            
                              if (totalCount == 0)   {
                               fullText = 'No Cruises Found';   
                              }
                              
                              if (totalCount == 1)   {
                               fullText = '1 Cruise Found';   
                              }
                            
 elementCount.innerHTML = fullText; 
 
     selectedIndexValue = elementShip.selectedIndex;   

     selectedValue = elementShip.options[selectedIndexValue].value

     DaItin = daJSON.Response.Itins;    

     totalItin = DaItin.Itin.length;
     

     elementitin.options[0].selected = true;   
     elementitin.options.length = 0;
     elementitin.options[0] = new Option('Select an Itinerary', '');        

      for (x=0; x<=totalItin -1; x++)
                        {
                         
                                    daname = DaItin.Itin[x].Start_Date + " - " + DaItin.Itin[x].ItinDesc;
                          
                               
                                    
                                    
                                    davalue = DaItin.Itin[x].ID;    
                                    elementitin.options[x+1] = new Option(daname, davalue);
                                    
                                       if (davalue == selectedValue) {
                                       elementitin.options[x+1].selected = true; 
                                       } 
                     
                    }
     

          
 

     
  }    
      catch(e){
             }
              
 } 
  
 

          
  
}  



function DoselectDDs(elm,ntype){
    destid = "";
    SailDate = "";
    NoNights = "";
    vendorid = "";
    
   destid = document.getElementById('CruiseDestinationID').value;         
   SailDate = document.getElementById('StartDate').value;
   NoNights = document.getElementById('Duration').value;  
   vendorid = document.getElementById('CruiseLine').value;    

   
  //alert("Destination="+ destid +" vendorid=" + vendorid + " SailDate=" + SailDate + " NoNights=" + NoNights);
  // alert(elm.value);

 CallAjaxSearchBoxDD(vendorid,destid,SailDate,NoNights);  

}



function DoselectDPDDs(elm,ntype){
    portid = "";
    SailDate = "";
    NoNights = "";
    vendorid = "";
    
   portid = document.getElementById('dpPortID').value;         
   SailDate = document.getElementById('dpStartDate').value;
   NoNights = document.getElementById('dpDuration').value;  
   vendorid = document.getElementById('dpCruiseLine').value;    


  //alert("Port="+ portid +" vendorid=" + vendorid + " SailDate=" + SailDate + " NoNights=" + NoNights);
  // alert(elm.value);

 CallAjaxSearchBoxDPDD(portid,vendorid,SailDate,NoNights);  

}

function DoselectShipDDs(elm,ntype){
    shipid = "";
    itinid = "";
    vendorid = "";

   shipid = document.getElementById('shipShip').value;         
   itinid = document.getElementById('shipItinerary').value;
   vendorid = document.getElementById('shipCruiseLine').value;    
if (shipid == "0") {shipid="";}

  //alert("Port="+ portid +" vendorid=" + vendorid + " SailDate=" + SailDate + " NoNights=" + NoNights);
   //alert(elm.value);
 CallAjaxSearchBoxShipDD(shipid,itinid,vendorid);  

}

function DoselectItinDDs(elm,ntype){
    shipid = "";
    itinid = "";
    vendorid = "";
   
   shipid = document.getElementById('shipShip').value;         
   itinid = document.getElementById('shipItinerary').value;
   vendorid = document.getElementById('shipCruiseLine').value;    


  //alert("Port="+ portid +" vendorid=" + vendorid + " SailDate=" + SailDate + " NoNights=" + NoNights);
   //alert(elm.value);
 CallAjaxSearchBoxShipItinDD(shipid,itinid,vendorid);  

}

function clearDropDowns() {
     CallAjaxSearchBoxDD('','','','');  
     CallAjaxSearchBoxDPDD('','','','');  
     clearShipForm();  
     var element = document.getElementById('ttlCruisesFound');    
    element.innerHTML = 'Over 11,000 Cruises Found';
     var element2 = document.getElementById('ttlCruisesFoundPort');    
    element2.innerHTML = 'Over 11,000 Cruises Found';
      var element3 = document.getElementById('ttlCruisesFoundShip');    
    element3.innerHTML = 'Over 11,000 Cruises Found';
           
}

function clearDropDownsSingle() {
     CallAjaxSearchBoxDD('','','','');  
     var element = document.getElementById('ttlCruisesFound');    
    element.innerHTML = 'Over 11,000 Cruises Found';
     
     
           
}

 function switchBoxADCS(valID)
{



    var element = document.getElementById(valID);
    element.style.display ='block';
    

    
    if(valID=='ship')
    {    
        
        var element = document.getElementById('dest');
        element.style.display ='none';    
        var element = document.getElementById('date');
        element.style.display ='none';    
        var element = document.getElementById('port');
        element.style.display ='none';    
        
        
    }
    if(valID=='dest')
    {
        var element = document.getElementById('ship');
        element.style.display ='none';    
        var element = document.getElementById('date');
        element.style.display ='none';    
        var element = document.getElementById('port');
        element.style.display ='none';    
    }
    if(valID=='port')
    {
        
        var element = document.getElementById('dest');
        element.style.display ='none';    
        var element = document.getElementById('ship');
        element.style.display ='none';    
        var element = document.getElementById('date');
        element.style.display ='none';    
        
    }
    if(valID=='date')
    {
        var element = document.getElementById('dest');
        element.style.display ='none';    
        var element = document.getElementById('ship');
        element.style.display ='none';    
        var element = document.getElementById('port');
        element.style.display ='none';    
    }
    if(valID=='ship')
    {
        var element = document.getElementById('dest');
        element.style.display ='none';    
        var element = document.getElementById('date');
        element.style.display ='none';    
        var element = document.getElementById('port');
        element.style.display ='none';    
    }

   // clearPortForm();
   // clearForm();    
   // clearShipForm();
    
    
    
}



function switchBoxADCS2(valID)
{



    var element = document.getElementById(valID);
    element.style.display ='block';
    

    
    if(valID=='ship')
    {    
        
        var element = document.getElementById('destin');
        element.style.display ='none';    
        var element = document.getElementById('datetab');
        element.style.display ='none';    
        var element = document.getElementById('port');
        element.style.display ='none';    
        
        
    }
    if(valID=='destin')
    {
        var element = document.getElementById('ship');
        element.style.display ='none';    
        var element = document.getElementById('datetab');
        element.style.display ='none';    
        var element = document.getElementById('port');
        element.style.display ='none';    
    }
    if(valID=='port')
    {
        
        var element = document.getElementById('destin');
        element.style.display ='none';    
        var element = document.getElementById('ship');
        element.style.display ='none';    
        var element = document.getElementById('datetab');
        element.style.display ='none';    
        
    }
    if(valID=='datetab')
    {
        var element = document.getElementById('destin');
        element.style.display ='none';    
        var element = document.getElementById('ship');
        element.style.display ='none';    
        var element = document.getElementById('port');
        element.style.display ='none';    
    }


   // clearPortForm();
   // clearForm();    
   // clearShipForm();
    
    
    
}



function formbuttonClassNew(obj, new_style) {
    obj.className = new_style;
}
function blockClassNew(obj, new_style) {
    obj.className = new_style;
}

function update_date (formObj) {
  timestamp1 = Date.UTC (formObj.cruise_year.value, formObj.cruise_month.value-1, formObj.cruise_day.value);
  timestamp2 = Date.UTC (formObj.cruise_year2.value, formObj.cruise_month2.value-1, formObj.cruise_day2.value);

  if (timestamp1 > timestamp2) {
    newdate = new Date(formObj.cruise_year.value, formObj.cruise_month.value, formObj.cruise_day.value-1);
    newYear = newdate.getYear()
    if (newYear < 1900) {
      newYear = newYear + 1900;
    }
    formObj.cruise_year2.selectedIndex  = getValueIndex(formObj.cruise_year2, newYear);
    formObj.cruise_month2.selectedIndex = getValueIndex(formObj.cruise_month2, newdate.getMonth()+1);
    formObj.cruise_day2.selectedIndex   = getValueIndex(formObj.cruise_day2, newdate.getDate());
  }
}

function getValueIndex(formObj, objVal) {
  for (lcv=0;lcv < formObj.length;lcv++) {
    if (formObj.options[lcv].value == objVal) return lcv;
  }
  return 0;
}

function checkformADVSEARCH(thisForm) {
  port_string = new String(thisForm.portid.value);
  string_length = port_string.length;
  good_values = port_string.indexOf('X');
  if (string_length != 0 && good_values >= 0) {
    alert('Please select a port.');
    return false;
  }
  return true;
}


function clearShipForm()
{
    
    var element = document.getElementById('shipCruiseLine');
    element.options[0].selected = true;
    
    var element = document.getElementById('ttlCruisesFoundShip');    
    element.innerHTML = 'Over 11,000 Cruises Found'
    
    var element = document.getElementById('shipShip');
    element.options.length = 0
    element.options[0] = new Option('---------------------------------------------', '');
    
    var element = document.getElementById('shipItinerary');
    element.options.length = 0
    element.options[0] = new Option('---------------------------------------------', '');                
                    
}





function ShowModifySearchBox(dest,sailing,nights,cruiseline) {
    
id = 'showModifySearch';  // id of the div to show and hide

  if (document.getElementById) { // DOM3 = IE5, NS6
    current = document.getElementById(id).style.visibility;  

    if (current == 'visible') {
      document.getElementById(id).style.visibility = 'hidden';
      document.getElementById(id).style.display    = 'none';
    }
    else {

        CallAjaxSearchBoxDD(cruiseline,dest,sailing,nights);  
      document.getElementById(id).style.visibility = 'visible';
      document.getElementById(id).style.display    = 'block';
      
    }
  }
  else {
    if (document.layers) { // NS4
      eval('document.' + id + '.visibility = "hidden"');
    }
    else { // IE4
      eval('document.all.' + id + '.style.visibility = "hidden"');
    }
  }
}


