// JavaScript Document

// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}






function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    }
  }
}
return req;
}

var http2 = getXMLHTTPRequest();




function get_ftour_allotment(tour_id,fdate,basis) {
	
  var tour_id = trim(tour_id); 
  var fdate = trim(fdate);
  var basis = trim(basis);
  

//alert(uname);
  var myurl = 'change_ftour.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&tour_id="+tour_id+"&fdate="+fdate+"&basis="+basis+"&action=ftour_allotment";
  http2.open("GET", modurl, true);
  http2.onreadystatechange = ftour_allotment_Response;
  http2.send(null);  
	  


function ftour_allotment_Response() {
   if (http2.readyState == 4) {
    if(http2.status == 200) {
       var mytext = http2.responseText;

		  	document.getElementById('d_tour_allotment').innerHTML = mytext;
			document.getElementById('d_price').innerHTML = "";
	   	  
    }
  } 
  
} 
	  

}//end of function get_ftour_allotment(tour_id,fdate) {
	



function get_all_types(people) {
	
  var people = trim(people); 
 

//alert(uname);
  var myurl = 'change_hotels.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&people="+people+"&action=get_all_types";
  http2.open("GET", modurl, true);
  http2.onreadystatechange = all_types_Response;
  http2.send(null);  
	  
	document.getElementById('d_price').innerHTML = "";

function all_types_Response() {
   if (http2.readyState == 4) {
    if(http2.status == 200) {
       var mytext = http2.responseText;

		  	document.getElementById('d_all_types').innerHTML = mytext;
			//document.getElementById('d_price').innerHTML = "";
	   	  
    }
  } 
  
} 
	  

}//end of function function get_all_types(people) {





function get_other_types_Htriple(allotment,triple,roomTypeID) {
	
  var allotment = allotment;
  var triple = triple; 
  var roomTypeID = roomTypeID; 
  


//alert(uname);
  var myurl = 'change_hotels.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&allotment="+allotment+"&triple="+triple+"&roomTypeID="+roomTypeID+"&action=get_other_types_triple";
  http2.open("GET", modurl, true);
  http2.onreadystatechange = other_types_Htriple_Response;
  http2.send(null);  
	  


function other_types_Htriple_Response() {
   if (http2.readyState == 4) {
    if(http2.status == 200) {
       var mytext = http2.responseText;

		  	document.getElementById('d_all_types'+roomTypeID).innerHTML = mytext;
			//document.getElementById('d_price').innerHTML = "";
	   	  
    }
  } 
  
} 
	  

}//end of function function get_other_types_triple(people,count,type) {




function get_other_types_Hdouble(allotment,triple,double,roomTypeID) {
	
  var allotment = allotment;
  var triple = triple; 
  var double = double; 
  var roomTypeID = roomTypeID; 
 

//alert(triple);
  var myurl = 'change_hotels.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&allotment="+allotment+"&triple="+triple+"&double="+double+"&roomTypeID="+roomTypeID+"&action=get_other_types_double";
  http2.open("GET", modurl, true);
  http2.onreadystatechange = other_types_Hdouble_Response;
  http2.send(null);  
	  


function other_types_Hdouble_Response() {
   if (http2.readyState == 4) {
    if(http2.status == 200) {
       var mytext = http2.responseText;

		  	document.getElementById('d_all_types'+roomTypeID).innerHTML = mytext;
			//document.getElementById('d_price').innerHTML = "";
	   	  
    }
  } 
  
} 
	  

}//end of function function get_other_types_triple(people,count,type) {






function valid_tour(tour_id,button){
	
	var tour_id = tour_id;
	var button = button;
	
	if(button == 0){
		
		if(tour_id == "no"){
	  	
			alert("Select Tour Package!");
			return false;
		}else{
			window.location = 'viewfixed_tour.php?id='+tour_id;	
			return false;
		}
	
	}else{
		
		if(tour_id == "no"){
	  	
			alert("Select Tour Package!");
			return false;
		}else{
			
			return true;
		}
		
	}

}



