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 SetValues() {
		var scrOfX = 0, scrOfY = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}
    var s = 'X=' + window.event.clientX +  ' Y=' + window.event.clientY + " scroll=" + scrOfY;
    document.getElementById('divCoord').innerText = s;
}  
var maraX = new Array("409","399","616","510","412","400","411","438","526","510","462","666","509",
											"454","565","479","434","433","388","445","679","550","402","626","539",
											"505","398","599","658");

var maraY = new Array("342","160","513","59","213","204","225","134","264","109","294","300","246",
											"114","366","294","175","313","172","194","329","327","151","355","104",
											"406","294","342","429");

var maraName = new Array("Ashnil Mara Camp",
													"&Beyond Bateleur Camp","Cottars 1920s Safari Camp",
													"Fairmont Mara Safari Club","Governors (Il Moran Camp)",
													"Governors (Little Camp)","Governors (Main Camp)",
													"Karen Blixen","Kicheche Bush Camp",
													"Kicheche Mara Camp","Mara Intrepids Camp",
													"Mara Porini Camp","Porini Lion Camp",
													"Royal Mara Safari","Sarova Mara Camp",
													"Mara Explorer","Elephant Pepper Camp",
													"Naibor Camp","Olonana",
													"Rekero Camp","Leleshwa Camp",
													"Tipilikwani Mara Camp","Kichwa Tembo Tented Camp",
													"Siana Springs","Saruni Masai Mara",
													"L1 Keekorok Lodge","L2 Mara Serena Safari Lodge",
													"L3 Mara Simba Lodge","L4 Mara Sopa Lodge");

var maraCodes = new Array("KSAMC1","KNMBCKT","KSMCOTT","KNMSAF1","KSGOIL","KNGOVL","KNGOV1",
													"KNMKBC1","KNMKIBC","KNMKIMC","KSMINTR","KSMPORI","KSMLION","KNMROY1",
													"KNMSARO","KSMEXPL","KSMELE","KNMNAIC","KNMOLONA","KNMREKE","KNMLEL1",
													"KNMTIP1","KNMKICH1","KNMSIA1","KNMSARC",
													"KSMKEEK","KNMSL1","KNMSIM1","KNMSOPA");

function show_mara_div(i){
	if ( i < 29 ) {
		str = maraName[i] + "<br>" +
					"<img src='/hotels_info/SiteAssets/Images/out_sq_150/" + maraCodes[i] + "-1-square.jpg'>";
					
		document.getElementById('maralocdiv').innerHTML = str;
		document.getElementById('maralocdiv').style.left = maraX[i] + "px";
		document.getElementById('maralocdiv').style.top = maraY[i] + "px";
		document.getElementById('maralocdiv').style.display = 'block';
	}
}

function hide_mara_div(){
	document.getElementById('maralocdiv').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;
	}
}

function open_div(d){
	//alert("open_div");
	e = eval("document.getElementById('" + d + "')");
	e.style.display = 'block';
}

function close_div(d){
	//alert("close_div");
	e = eval("document.getElementById('" + d + "')");
	e.style.display = 'none';
	/*e.style.visibility = 'hidden';*/
}



