function getXMLHTTP() {
	var xmlhttp=false;	
	try{
		xmlhttp=new XMLHttpRequest();
	}
	catch(e)	{		
		try{			
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e){
			try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e1){
				xmlhttp=false;
			}
		}
	}
		
	return xmlhttp;
}
function getDeparture(departure, xml_file)
{
   var strURL="http://www.redtag.ca/search_engine_new/includes/findDeparture.php?departure="+departure+"&xml_file="+xml_file;
   var req = getXMLHTTP();
   if (req)
   {
     req.onreadystatechange = function()
     {
      if (req.readyState == 4)
      {
	 // only if "OK"
	 if (req.status == 200){
	    document.getElementById('departurediv').innerHTML=req.responseText;
	 } else {
   	   alert("There was a problem while using XMLHTTP:\n" + req.statusText);
	 }
       }
      }
   req.open("GET", strURL, true);
   req.send(null);
   }
}

function getDestination(departure, xml_file)
{
   var strURL="http://www.redtag.ca/search_engine_new/includes/findDestination.php?departure="+departure+"&xml_file="+xml_file;
   var req = getXMLHTTP();
   if (req)
   {
     req.onreadystatechange = function()
     {
      if (req.readyState == 4)
      {
	 // only if "OK"
	 if (req.status == 200)
         {
	    document.getElementById('destinationdiv').innerHTML=req.responseText;
	 } else {
   	   alert("There was a problem while using XMLHTTP:\n" + req.statusText);
	 }
       }
      }
   req.open("GET", strURL, true);
   req.send(null);
   }
   
}

function getHotel(departure,destination, xml_file)
{
  document.getElementById('hoteldiv').innerHTML="<select name='hotel' style='width: 260px;' disabled='disabled'><option>Populating Hotel List...</option></select>";
  //alert(xml_file);
  var strURL="http://www.redtag.ca/search_engine_new/includes/findHotel.php?departure="+departure+"&destination="+destination+"&xml_file="+xml_file;
  var req = getXMLHTTP();
  if (req)
  {
    req.onreadystatechange = function()
    {
      if (req.readyState == 4) // only if "OK"
      {
        if (req.status == 200)
        {
          document.getElementById('hoteldiv').innerHTML=req.responseText;
        } else {
          alert("There was a problem while using XMLHTTP:\n" + req.statusText);
        }
      }
    }
    req.open("GET", strURL, true);
    req.send(null);
  }
}

function getDuration(departure,destination, xml_file)
{
  var strURL="http://www.redtag.ca/search_engine_new/includes/findDuration.php?departure="+departure+"&destination="+destination+"&xml_file="+xml_file;
  var req = getXMLHTTP();
  if (req)
  {
    req.onreadystatechange = function()
    {
      if (req.readyState == 4) // only if "OK"
      {
        if (req.status == 200)
        {
          document.getElementById('durationdiv').innerHTML=req.responseText;
        } else {
          alert("There was a problem while using XMLHTTP:\n" + req.statusText);
        }
      }
    }
    req.open("GET", strURL, true);
    req.send(null);
  }
}

function resetHotel(){
 document.getElementById('hoteldiv').innerHTML="<select name='hotel' style='width: 260px;' disabled='disabled'><option>All Hotels</option></select>";
}

function blurSelections(){
 document.getElementById('stardiv').innerHTML="<select name='rating' style='width: 118px;' disabled='disabled'><option>All Ratings</option></select>";
 document.getElementById('pricediv').innerHTML="<select name='price' style='width: 127px;' disabled='disabled'><option>Get Me a Deal!</option></select>";
 document.getElementById('all_inclusive').innerHTML="<input type='checkbox' name='all_inclusive' value='Y' disabled='disabled'> <font color='#999999'>All Inclusive</font>";
 document.getElementById('beach').innerHTML="<input type='checkbox' name='beach' value='Y' disabled='disabled'> <font color='#999999'>Beachfront</font>";
 document.getElementById('adults_only').innerHTML="<input type='checkbox' name='adults_only' value='Y' disabled='disabled'> <font color='#999999'>Adults Only</font>";
 document.getElementById('golf').innerHTML="<input type='checkbox' name='golf' value='Y' disabled='disabled'> <font color='#999999'>Golf</font>";
 document.getElementById('family').innerHTML="<input type='checkbox' name='family' value='Y' disabled='disabled'> <font color='#999999'>Family</font>";
 document.getElementById('wedding').innerHTML="<input type='checkbox' name='wedding' value='Y' disabled='disabled'> <font color='#999999'>Wedding</font>";
}

function updateDeparture(){
 var form = document.forms["searchForm"]["gateway_dep"];
 var departure = form[form.selectedIndex].text;
 document.getElementById('departure_var').innerHTML='<input type="hidden" name="remember_dep" value="'+departure+'" />';
}

function updateDestination(){
 var form = document.forms["searchForm"]["dest_dep"];
 var destination = form[form.selectedIndex].text;

 if(destination == "All Countries" || destination == "All South" || destination == "All Europe"){
    document.getElementById('destination_var').innerHTML="<input type='hidden' name='sentdest' value='"+destination+"' />"; 
 }else{
	 if(destination == "Antigua and Barbuda - Antigua"){
		destination = "Antigua and Barbuda"; 
	 }
 	 if(destination == "Austria - Vienna"){
		destination = "Vienna"; 
	 }
	 if(destination == "Bahamas - Nassau"){
		destination = "Nassau"; 
	 }
	 if(destination == "Barbados - Bridgetown"){
		destination = "Bridgetown"; 
	 }
	 if(destination == "Belize - Belize City"){
		destination = "Belize City"; 
	 }
	 if(destination == "Cayman Islands - Grand Cayman"){
		destination = "Grand Cayman"; 
	 }
	 if(destination == "Colombia - Cartagena"){
		destination = "Cartagena"; 
	 }
	 if(destination == "El Salvador - San Salvador"){
		destination = "San Salvador"; 
	 }
	 if(destination == "France - Paris"){
		destination = "Paris"; 
	 }
	 if(destination == "Greece - Athens"){
		destination = "Athens"; 
	 }
	 if(destination == "Guadeloupe - Pointe a Pitre"){
		destination = "Pointe a Pitre"; 
	 }
	 if(destination == "Honduras - Roatan"){
		destination = "Roatan"; 
	 }
	 if(destination == "Ireland - Dublin"){
		destination = "Dublin"; 
	 }
	 if(destination == "Netherlands - Amsterdam"){
		destination = "Amsterdam"; 
	 }
	 if(destination == "Puerto Rico - San Juan"){
		destination = "San Juan"; 
	 }
	 if(destination == "Saint Kitts Nevis - St Kitts"){
		destination = "St Kitts"; 
	 }
	 if(destination == "Saint Lucia - St Lucia"){
		destination = "St Lucia"; 
	 }
	 if(destination == "Spain - Madrid"){
		destination = "Madrid"; 
	 }
	 if(destination == "Turks And Caicos - Providenciales"){
		destination = "Providenciales"; 
	 }
	 if(destination == "Venezuela - Margarita Island"){
		destination = "Margarita Island"; 
	 }
	 destination = destination.replace(/- /i, "");
	 destination = destination.replace(/^[\s\xA0]+|[\s\xA0]+$/g,"");
	 document.getElementById('destination_var').innerHTML='<input type="hidden" name="sentdest" value="'+destination+'" />';
 }
}


function setmatch(A,wotstring){
  var L=A.length,who,val;  
  for(var i=0; i<L; i++){  
    who=A[i];	
	if(who.text===wotstring){	
	  who.parentNode.selectedIndex=i;
	  return who;		
	}  
  }	
}