function switchSearchEngine(state, init)
{
	if(init == undefined)
		init = false;

	if(init)
		$('result').toggle();

	if(state == 1)
	{
		$('criteria').toggle();
		document.getElementById('criteria').style.display = "block";
	}
	
	if(state == 2)
		$('result').toggle();
}


var nb_photos = parseInt(hotel_photos.size());
var photo_by_page = 3;
var max_pages = (nb_photos/photo_by_page).ceil();
//alert("nb photos="+nb_photos);
//alert("nb pages="+max_pages);
function changePhoto(nav)
{
	if(nb_photos == 0)
		return;

	var action = (nav == "next") ? 1 : -1;
	var page = parseInt($F("page"))+(action);
	
	//return at the beginning
	if(page > max_pages && nav == "next")
	{
		$("page").value = 1;
		page = 1;
	}
	
	//return at the end
	if(page < 1 && nav == "prev")
	{
		$("page").value = max_pages;
		page = max_pages;
	}
	
	var end = page * photo_by_page;
	var begin = (end - photo_by_page)+1;

	var i=0;
	for(var index = begin; index <= end; index++)
	{
		i++;
		var thumb_id = "thumb"+i;
		if(hotel_photos[index-1] != undefined)
		{
 			var thumb = "http://images.fastbooking.com/IMG/"+hotel_photos[index-1].substring(0,2)+"/"+hotel_photos[index-1];
 			$(thumb_id).src = thumb;
 		}
 		else
 		{
 			var reload=0;
 			var thumb = "http://images.fastbooking.com/IMG/"+hotel_photos[index-1].substring(0,2)+"/"+hotel_photos[reload];
 			$(thumb_id).src = thumb;
 			reload++;
 		}
	}
	$("page").value = page;
}

function viewPhoto(id)
{
	$('big').src = $(id).src;
}

function ajx_info(hname)
{
	if($("ajx_info").empty() == true)
	{
		var params = "keypoint=true&hname="+hname;
		new Ajax.Request(hname+".htm",
		{
			method: 'post',
			parameters: params,
			asynchronous: false,
			onComplete: showResponse,
			contentType:'application/x-www-form-urlencoded',
			//encoding : "UTF-8",
			onFailure: function (xhr)
            {
              $('ajx_info').innerHTML = xhr.status 
                         + ' : ' + xhr.statusText;
            }
		});
	}
	else
	{
		$('ajx_info').toggle();
	}

	function showResponse(originalRequest)
	{
		var data = originalRequest.responseText;

		data = data.replace(/&lt;/g,"<");
		data = data.replace(/&gt;/g,">");
		data = data.replace(/&nbsp;/g,"");

		$("ajx_info").innerHTML = data;
	}
}



function printPage(hname)
{
	window.open('../printpage.htm?hname='+hname,'_blank'," menubar=0, resizable=0, status=0, scrollbars=1, width=1050 ");
}
