//Gets the browser specific XmlHttpRequest Object 
function getXmlHttpRequestObject() {
 if (window.XMLHttpRequest) {
    return new XMLHttpRequest(); //Mozilla, Safari ...
 } else if (window.ActiveXObject) {
    return new ActiveXObject("Microsoft.XMLHTTP"); //IE
 } else {
    //Display our error message
    alert("Your browser doesn't support the XmlHttpRequest object.");
 }
}

//Our XmlHttpRequest object
var receiveReq = getXmlHttpRequestObject();

//Initiate the AJAX request
function makeRequest(url, param) {
//If our readystate is either not started or finished, initiate a new request
 if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
   //Set up the connection to captcha_test.html. True sets the request to asyncronous(default) 
   receiveReq.open("POST", url, true);
   //Set the function that will be called when the XmlHttpRequest objects state changes
   receiveReq.onreadystatechange = updatePage; 

   receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   receiveReq.setRequestHeader("Content-length", param.length);
   receiveReq.setRequestHeader("Connection", "close");

   //Make the request
   receiveReq.send(param);
 }   
}

//Called every time our XmlHttpRequest objects state changes
function updatePage() {
 //Check if our response is ready
 if (receiveReq.readyState == 4) {
   //Set the content of the DIV element with the response text
   if(receiveReq.responseText=="<font color='#FF0000'><strong>Query Sent Successfully</strong></font>"){
		document.book.reset();
   }   
   document.getElementById('result').innerHTML = receiveReq.responseText;
   //Get a reference to CAPTCHA image
   img = document.getElementById('imgCaptcha'); 
   //Change the image
   img.src = 'captcha.php';
 }
}

//Called every time when form is perfomed

function getParampage(theForm) {
 //Set the URL
 
 var url = 'bookingform.php';
 //Set up the parameters of our AJAX call
 for (var i=0; i < theForm.trans.length; i++)
   {
   if (theForm.trans[i].checked)
      {
      var trans = theForm.trans[i].value;
      }
   }



 var postStr = theForm.txtCaptcha.name + "=" + encodeURIComponent( theForm.txtCaptcha.value );
 postStr += '&tourname='+ theForm.tourname.value +'&name='+ theForm.name.value +'&email='+ theForm.email.value +'&nation='+ theForm.nation.value
+'&adults='+ theForm.adults.value +'&child='+ theForm.child.value +'&hotel='+ theForm.hotel.value +'&sgl='+ theForm.sgl.value
+'&dbl='+ theForm.dbl.value +'&ebed='+ theForm.ebed.value +'&arrdate='+ theForm.arrdate.value +'&depdate='+ theForm.depdate.value
+'&trans='+ trans +'&phone='+ theForm.phone.value +'&others='+ theForm.others.value;
 //Call the function that initiate the AJAX request
 makeRequest(url, postStr);
}


function customized_tours(theForm) {
 //Set the URL
 
 var url = 'mailcustomized_tours.php';
 //Set up the parameters of our AJAX call
   var trans='';
for (var i=0; i < theForm.also_interested_in.length; i++)
   {
  
  if (theForm.also_interested_in[i].checked)
       {
        trans  += theForm.also_interested_in[i].value+'<br>';
       }
   }

//alert(trans); return false;

 var postStr = theForm.txtCaptcha.name + "=" + encodeURIComponent( theForm.txtCaptcha.value );
 postStr += '&arrdate='+ theForm.arrdate.value +'&Local_Transport='+ theForm.Local_Transport.value +'&Number_of_Adults='+ theForm.Number_of_Adults.value +'&Number_of_Children='+ theForm.Number_of_Children.value
+'&Approx_Budget_per_person_per_day='+ theForm.Approx_Budget_per_person_per_day.value +'&no_of_days='+ theForm.no_of_days.value +'&Accommodation_Type='+ theForm.Accommodation_Type.value +'&places_to_be_covered='+ theForm.places_to_be_covered.value +'&also_interested_in='+ trans +'&your_name='+ theForm.your_name.value
+'&your_mail='+ theForm.your_mail.value +'&country='+ theForm.country.value +'&phone='+ theForm.phone.value +'&travel_plan='+ theForm.travel_plan.value ;
 //Call the function that initiate the AJAX request
 makeRequest(url, postStr);
}


function getParamindex(theForm) {
 //Set the URL
 
 var url = 'indexform.php';
 //Set up the parameters of our AJAX call



 var postStr = theForm.txtCaptcha.name + "=" + encodeURIComponent( theForm.txtCaptcha.value );
 postStr += '&dd='+ theForm.dd.value +'&mm='+ theForm.mm.value +'&yy='+ theForm.yy.value +'&duration='+ theForm.duration.value
+'&people='+ theForm.people.value +'&count='+ theForm.count.value +'&budget='+ theForm.budget.value +'&style='+ theForm.style.value
+'&plan='+ theForm.plan.value +'&name='+ theForm.name.value +'&email='+ theForm.email.value +'&country='+ theForm.country.value
+'&phone='+ theForm.phone.value;
 //Call the function that initiate the AJAX request
 makeRequest(url, postStr);
}