	function createXMLHTTP() 
	{
		var ajax;
		try 
		{
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(e) 
		{
			try 
			{
				ajax = new ActiveXObject("Msxml2.XMLHTTP");
				alert(ajax);
			}
			catch(ex) 
			{
				try 
				{
					ajax = new XMLHttpRequest();
				}
				catch(exc) 
				{
					 alert("Esse browser não tem recursos para uso do Ajax");
					 ajax = null;
				}
			}
			return ajax;
		}
	
	
		   var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
							    "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
							    "Microsoft.XMLHTTP"];
		   for (var i=0; i < arrSignatures.length; i++) 
		   {
				try 
				{
					var oRequest = new ActiveXObject(arrSignatures[i]);
					return oRequest;
				} 
				catch (oError) 
				{
			    }
		   }
		
			   throw new Error("MSXML is not installed on your system.");
	}



function reset_values(aonde) {
  var elemento = document.getElementById(aonde);
  for (i = elemento.options.length; i >= 0 ; i=i-1) {
	 elemento.options[i] = null;
  }
}

function reset_price() {
  document.getElementById('div_price').innerHTML = '-';
}


function showdestination()
{
	if (frm1.departure.value != 0) {
	frm1.destination.options[0] = new Option('Please wait...', '0');
               var reqdestination = createXMLHTTP();
       			reqdestination.open("post", "search_ajax.php", true);
           		reqdestination.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
				reqdestination.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
				reqdestination.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
				reqdestination.setRequestHeader("Pragma", "no-cache");
				reqdestination.setRequestHeader("encoding", "ISO-8859-1"); 
                reqdestination.onreadystatechange=function(){
                           if (reqdestination.readyState==4){ document.getElementById('div_destination').innerHTML = reqdestination.responseText;  }}
                                      reqdestination.send("where=destination&departure=" + frm1.departure.value);
   }
}

function showvehicle()
{ 
	frm1.vehicle.selectedIndex = 0;
	if (frm1.destination.value != 0) frm1.vehicle.disabled = false; else frm1.vehicle.disabled = true; 
}



function showprice()
{
	if (frm1.vehicle.value != 0) {
	document.getElementById('div_price').innerHTML = 'Calculating...';
               var reqprice = createXMLHTTP();
               reqprice.open("post", "search_ajax.php", true);
                reqprice.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
				reqprice.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
				reqprice.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
				reqprice.setRequestHeader("Pragma", "no-cache");
				reqprice.setRequestHeader("encoding", "ISO-8859-1"); 
               reqprice.onreadystatechange=function(){
                           if (reqprice.readyState==4){ document.getElementById('div_price').innerHTML = reqprice.responseText;}}
                                      reqprice.send("where=price&departure=" + frm1.departure.value + "&destination=" + frm1.destination.value
													 + "&vehicle=" + frm1.vehicle.value);
    }
}


