/* The following function creates an XMLHttpRequest object... */

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/* You can get more specific with version information by using 
	parseInt(navigator.appVersion)
	Which will extract an integer value containing the version 
	of the browser being used.
*/
/* The variable http will hold our new XMLHttpRequest object. */
var http = createRequestObject(); 



function dynlang(hotelId,lang){

	http.open('get', 'dyntable.php?hotelId='+hotelId+'&lang='+lang);
	http.onreadystatechange = handleReq;
	http.send(null);
}

function shrtdynlanguage(hotelId,lang){
	http.open('get','shrtdyntable.php?hotelId='+hotelId+'&lang='+lang);
	http.onreadystatechange=handleReq;
	http.send(null);

}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleReq(){
	
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		//document.getElementById('statediv').innerHTML = "";
		//document.getElementById('statediv').innerHTML = response;
			var page=document.getElementById("lochid").value;
			if(page=="hotinfodet"){
							document.getElementById("hotdesc").innerHTML=response;
				}
				if(page=="list_city"){
					var hIds=document.getElementById("hotel_ids").value;
					var hotelDescs=new Array();
					var hotelIds=new Array();
					hotelIds=hIds.split(",");
					hotelDescs=response.split("|");
					var noIds=hotelIds.length;
					for(var i=0;i<noIds;i++){
						document.getElementById(hotelIds[i]).innerHTML=hotelDescs[i]+"...";
						
					}
					
				}
	}
}
