function switchul(id,typ){
	//alert(id);
	e = eval("document.getElementById('" + id + "')");
	e.style.display = typ;
	
	//if id is africa, india, fareast, middleeast change map
	if (id == 'africa'){
		updateMap(id);
	}
	if (id == 'fareast'){
		updateMap(id);
	}
	if (id == 'middleeast'){
		updateMap(id);
	}
	if (id == 'india'){
		updateMap(id);
	}

	
}

function handlePostRequest(post_data,server_url,output_div,temp_text){
	//alert('postdata ' + post_data);
	//alert('server_url' + server_url);
	//alert('output to' + output_div);
	
	browser = navigator.appName;

	//alert(browser);
	if (browser == "Microsoft Internet Explorer"){
		http = new ActiveXObject("Microsoft.XMLHTTP")
	}
	else
	{

		http = new XMLHttpRequest();

		
	} 

	//alert(post_data);
	http.open("POST",server_url,true);
	http.onreadystatechange = updateData;
	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		
	http.send(post_data);
	
}

function hotellist_page(ctr,totpages){
	i = 1;
	
	//alert(ctr,totpages);
	while (i <= totpages){
		v = "document.getElementById('hotellist_page" + i + "')";
		//alert(v);
		e = eval(v);
		
		if (i == ctr){
			e.style.display = 'block';
		}
		else
		{
			e.style.display = 'none';
		}
		
		
		i++;
	}
	
	//pagenos
	//<input type="hidden" id="current" value="1">

	post_data = "pagenos=" + ctr;
	//alert(post_data);
	server_url = "/setpagenos.php";
	output_div = "pagenos1";
	temp_text = '';
	
	handlePostRequest(post_data,server_url,output_div,temp_text)
	
	
	
	var str;
	str = "";
	i = 1;
	while (i <= totpages){
		
		if (i == ctr){
			str = str + "<div id=\"currentpage\">"
			str = str + i 
			str = str + "</div>"
		}
		else
		{
			str = str + "<u><a href=\"#\" onClick=\"hotellist_page("
			str = str + i + "," + totpages + ")\"  style=\"color:#fff;\">"
			str = str + i
			str = str + "</u></a>"
		}
		i++;
		str = str + "&nbsp;"
	}
	
	//alert(str);
	p = document.getElementById("pagenos");
	p.innerHTML = str;
	//p_bottom = document.getElementById("pagenos_bottom");
	//p_bottom.innerHTML = str;	
	
}
  
function updateData(){
	//alert(http.responseText);
	var browser = "";
	browser = navigator.appName;

	if (http.readyState == 4){
			//alert(http.responseText);
			//WriteToFile(http.responseText);
			//alert(browser);
			//alert(http.responseText);
			
			document.getElementById(output_div).innerHTML = http.responseText;
	}
	else
	{
			document.getElementById(output_div).innerHTML = temp_text;
			
			//ani-busy.gif
			//document.getElementById(output_div).innerHTML = 'Processing...';
	}
}

function getHotelsList(prev_or_next,rescode,typ,curpage,sortby,coucd){

	//var browser = navigator.appName;
	//if (browser == 'Netscape'){
		//alert(prev_or_next + ', ' + rescode + ',' + curpage + ',' + sortby + ',' + coucd);
		//curpage = 2;
	//}
	
	prev = "";
	next = "";
	//sortby = document.getElementById('sortby').value;

	post_data = "";
	
	if (prev_or_next == 'P'){
		prev = "prev";
		post_data = post_data + "prev=";
		post_data = post_data + prev;
		post_data = post_data + "&";
		
	}
	if (prev_or_next == 'N'){
		next = "next";
		post_data = post_data + "next=";
		post_data = post_data + next;
		post_data = post_data + "&";

	}
	if (prev_or_next == 'S'){
		prev = "";
		next = "";
		//alert('S');
	}
	if (prev_or_next == 'X'){
		prev = "";
		next = "";
		post_data = post_data + "new=";
		post_data = post_data + 'Y';
		post_data = post_data + "&";

		//alert('X');
	}
	
	
	//alert(sortby);
	post_data = post_data + "curpage=";
	post_data = post_data + curpage;
	post_data = post_data + "&";	
	post_data = post_data + "rescode=";
	post_data = post_data + rescode;
	post_data = post_data + "&";	
	post_data = post_data + "typ=";
	post_data = post_data + typ;	
	post_data = post_data + "&";	
	post_data = post_data + "coucd=";
	post_data = post_data + coucd;	
	post_data = post_data + "&";	
	post_data = post_data + "sortby=";
	post_data = post_data + sortby;	

	
	//alert(post_data);
	
	//server_url = "http://www.somak.com/hotellist.php";
	server_url = "/hotellist.php";
	output_div = "hotellist";
	temp_text = '<center><img src="http://www.somak.com/loading.gif"></center>';
	
	handlePostRequest(post_data,server_url,output_div,temp_text)
	
	
	
}

function loadhtl(res,typ,coucd,status){
	//alert("hello " + coucd);
	
	if (status == 0){
		//alert("new");
		getHotelsList(null,res,typ,0,null,coucd);
	}
	else
	{
		getHotelsList('X',res,typ,0,null,coucd);
		
	}
	
}

function updatemap(id){
	//alert('in updatemap ' + id);
	if (id){
		document.getElementById("worldMap").src = id + '_hover.gif';
	}
	else
	{
		document.getElementById("worldMap").src = 'world.gif';
	}
}

var win;

function bkmain(){

a = "2";
c = "0";
i = "0";
s = "0";
d = "1";
t = "0";

 if (win){
	if (!win.closed){
	  alert("Your online booking session is already active, clicking on OK takes you to your active session\nto book another date please close this window first.");
	  win.focus()		
	}
	else {
	  win = window.open("http://ws05.somak.com/somakgo/fr_direct_validate.htm","new_window","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,left=0,top=0,width=900,height=600")
	}
  }
  else {
	 win = window.open("http://ws05.somak.com/somakgo/fr_direct_validate.htm","new_window","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,left=0,top=0,width=900,height=600")
 }		

}

function bkmain_gonly(){

a = "2";
c = "0";
i = "0";
s = "0";
d = "1";
t = "0";

if (win){
	if (!win.closed){
	  alert("Your online booking session is already active, clicking on OK takes you to your active session\nto book another date please close this window first.");
	  win.focus()		
	}
	else {
	  //win = window.open("http://ws05.somak.com/gonly/fr_direct_validate.htm","new_window")
	  win = window.open("http://rkpc:8080/gonly/fr_direct_validate.htm","new_window")
	}
}
else {
	 //win = window.open("http://ws05.somak.com/gonly/fr_direct_validate.htm","new_window")
	 win = window.open("http://rkpc:8080/gonly/fr_direct_validate.htm","new_window")
}		

}

var previd;
function showdiv(i){

	if (!previd){
		previd = 0;
	}
	//alert(previd);
	
	f = eval('document.getElementById(\'data' + i + '\')');
	f.style.display = 'block';
	
	f = eval('document.getElementById(\'data' + previd + '\')');
	f.style.display = 'none';
	
	
	previd = i;
	//document.getElementById('data0').style.display = 'none';
	

}


function goAgent(){
	if (this.name == "SomakDestTarget"){
		alert('This page was called from agents\' site, this login button does not work here');
		return false;
	}
	else
	{
		window.open("http://ws05.somak.com/","_blank");
	}
}

function goAgent_gOnly(){
	if (this.name == "SomakDestTarget"){
		alert('This page was called from agents\' site, this login button does not work here');
		return false;
	}
	else
	{
		window.open("http://ws05.somak.com/gonly/","_blank");
	}
}

function changeimage(img,cap){
	//alert(img);
	e = document.getElementById('imageholder');
	e.src='/hotels_info/SiteAssets/Images/' + img;
	
	//if (cap){
		c = document.getElementById('imageholder_text');
		c.innerHTML = cap;
	
	//}
}

function countryxml(coucd,coufile){
	post_data = "";
	post_data = post_data + "coucd=";
	post_data = post_data + coucd;
	post_data = post_data + "&";
	post_data = post_data + "coufile=./XML/";
	post_data = post_data + coufile;
	post_data = post_data + ".xml";
	
	copyright = "The country information is provided by " 
	copyright = copyright + "www.columbusguides.com \n(c) Columbus Travel Media 2010. \n"
	copyright = copyright + "We are not responsible for the accuracy of this information. "
	alert(copyright);
	
	//server_url = "http://www.somak.com/xmlvalues.php";
	server_url = "/xmlvalues.php";
	output_div = "hotellist";
	temp_text = '<center><img src="http://www.somak.com/loading.gif"></center>';
	
	handlePostRequest(post_data,server_url,output_div,temp_text)
	
		
}

function showsunrating(i){
	
	e = document.getElementById('sunrating');
	if (i == 1){
		e.style.display = 'block';
	}
	else
	{
		e.style.display = 'none';
	}
	
	
	/*
	if (e.style.display == 'none'){
		e.style.display = 'block';
	}
	else
	{
		e.style.display = 'none';
	}
	*/
}
function checksearch(){
	if (document.getElementById('search').value == "Search this site..."){
		alert('Please enter a query to search.');
		document.getElementById('search').value="";
		document.getElementById('search').focus();
		return false;
	}
}