var xmlHttp

function sap_getquote(){
   xmlHttp=sap_GetXmlHttpObject()
   if (xmlHttp==null){
      alert ("Browser does not support HTTP Request")
      return
   }

   var dep_date = document.getElementById("dep_date").value;
   var ret_date = document.getElementById("ret_date").value;
   var dep_hr = document.getElementById("dep_hr").value;
   var dep_min = document.getElementById("dep_min").value;
   var ret_hr = document.getElementById("ret_hr").value;
   var ret_min = document.getElementById("ret_min").value;
   var val = document.getElementById("val_selected").value;
   var chp = document.getElementById("chp_selected").value;
   var veh = document.getElementById("veh_selected").value;
   
   if(document.getElementById("useearlybird").checked){
      var ebird = 1;      
   }
   else{
      var ebird = 0;   
   }
   
   
   //used to be used to add extra charge for more than 'x' people
   var par = document.getElementById("par").value;

   var dis = document.getElementById("dis").value;
   
   //used to either show the quote or booking details header
   var adisplaymode = document.getElementById("adisplaymode").value;     

   var url="/airinclude/cfm/cfajax/getquote.cfm"
   url=url+"?dep_date="+dep_date
   url=url+"&ret_date="+ret_date
   url=url+"&dep_hr="+dep_hr
   url=url+"&dep_min="+dep_min
   url=url+"&ret_hr="+ret_hr
   url=url+"&ret_min="+ret_min
   url=url+"&val="+val
   url=url+"&chp="+chp
   url=url+"&veh="+veh
   url=url+"&par="+par
   url=url+"&dis="+dis
   url=url+"&adisplaymode="+adisplaymode   
   url=url+"&ebird="+ebird      
   url=url+"&ran="+Math.random()

   xmlHttp.onreadystatechange=stateChanged
   xmlHttp.open("GET",url,true)
   xmlHttp.send(null)
}

function stateChanged(){
   if (xmlHttp.readyState==1){
//      alert(xmlHttp.responseText);
      document.getElementById("sap_invdisplay").innerHTML="<table cellpadding='0' cellspacing='0'><tr height='10'><td style='border:1px solid ##CFCDCD;border-right:1px solid ##ADACAA;border-bottom:0px;'><img src='/images/interface/main/elements/your_quote.gif' width='336' height='30' alt=''></td></tr><tr><td class='invoicearea'><table cellpadding='0' cellspacing='0'><tr><td colspan='2' class='mainbody'>---------------------------------------------------------------</td></tr><tr><td colspan='2' align='center' class='mainbody'>... calculating ...</td></tr><tr><td colspan='2' class='mainbody'>---------------------------------------------------------------</td></tr></table>";
      /*var txtMatchingAlbums = document.getElementById('txtMatchingAlbums')
      if(txtMatchingAlbums.firstChild){
         txtMatchingAlbums.removeChild(txtMatchingAlbums.firstChild);
      }
      txtMatchingAlbums.appendChild(document.createTextNode(xmlHttp.responseText))
      */
      document.getElementById('thecalcholder').style.display = 'block';
      document.getElementById('thesubmitholder').style.display = 'none';
   }
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
//      alert(xmlHttp.responseText);
      document.getElementById("sap_invdisplay").innerHTML=xmlHttp.responseText
		document.getElementById("tval").value = document.getElementById("tval_ajax").value;
      document.getElementById('thecalcholder').style.display = 'none';
      document.getElementById('thesubmitholder').style.display = 'block';
		/*var txtMatchingAlbums = document.getElementById('txtMatchingAlbums')
      if(txtMatchingAlbums.firstChild){
         txtMatchingAlbums.removeChild(txtMatchingAlbums.firstChild);
      }
      txtMatchingAlbums.appendChild(document.createTextNode(xmlHttp.responseText))
      */
   }
}

