function xmlHttpRequest()
{
    var xmlHttp;
    try
      {
        // Firefox, Opera 8.0+, Safari
         xmlHttp=new XMLHttpRequest();
         return xmlHttp;
      }
      catch (e)
      {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
            return xmlHttp;
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                return xmlHttp;
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
      }
  }
  
  function getArrivalAirports()
  {
    //var airport = document.getElementById('arrival').value;
    var airport = document.getElementById('displayarrival').value;
    var xmlHttpReqObj = xmlHttpRequest();
    
    var url = "arrivalAirports.php?airport="+airport;
    
    if(airport)
    {
        xmlHttpReqObj.onreadystatechange=function()
        {
            if(xmlHttpReqObj.readyState == 4)
            {        
                var response = xmlHttpReqObj.responseText;  
                //alert(response);  
                document.getElementById('arrivalAirports').style.display = '';    
                document.getElementById('arrivalAirports').innerHTML = response; 
                         
            }
         }

         xmlHttpReqObj.open("GET",url,true); 
         xmlHttpReqObj.send(null);    
    }
  }
  
  function addElement(airportName , airportCode)
  {    
     document.getElementById('arrival').value = airportCode; 
     document.getElementById('displayarrival').value = airportName; 
     document.getElementById('arrivalAirports').style.display = 'none'; 
  }

  function changeClass(object , classname, airportName , airportCode)
  {
    object.className = classname; 
    if(classname)
    {
       document.getElementById('arrival').value = airportCode; 
       document.getElementById('displayarrival').value = airportName; 
    }   
  }
  
  function disableSearch()
  {
    document.getElementById('arrivalAirports').style.display = 'none';   
  }
  
  function updateOptionalExtra(checkbox, optionId, applyTo, totalPassengers)
    {    
        var select;
        
        var optionDisplayId = checkbox.id;
        
        var xmlHttpReqObj = xmlHttpRequest();
        
        chkObj = document.getElementById(optionDisplayId);   
         
        var fareId = document.getElementById('fareId').value;    
     
        if(checkbox.checked == true)
        {
            select = 1;
        }
        else
        {
            select = 0;
        }
        
        var quantity;   
        
        var url = "optionalExtras.php?update=optionalExtras&optionId="+optionId+"&select="+select+"&totalPassengers="+totalPassengers+"&applyTo="+applyTo+"&optionIndex="+optionDisplayId+"&fareId="+fareId; 
         
       /* $.ajax({
                  url: url ,
                  cache: false,          
                  dataType: "html",      
                  
                  success: function(data) 
                  {                
                        document.getElementById('tdTotalFABCost').innerHTML = data;
                  }
             
                });  
       */
                
       xmlHttpReqObj.onreadystatechange=function()
        {
            if(xmlHttpReqObj.readyState == 4)
            {        
                var response = xmlHttpReqObj.responseText;  
                //document.getElementById('tdTotalFABCost').innerHTML = response;
            }
         }

         xmlHttpReqObj.open("GET",url,true); 
         xmlHttpReqObj.send(null);    
             
                
    }