$(document).ready(function(){
	

	$("div.thumb-img img").click(function(){
	//alert(this.src);	
	var file = $(this).attr("title");
	$("#photo_banner").attr("src", file);
	});
	
	$("#photo li").hide();
	$("#photo li.1").show();
	$("a.pagination, a.pagination_active").click(function(){
		$("a.pagination_active").addClass("pagination");
		$("a.pagination_active").removeClass("pagination_active");	
		$(this).removeClass("pagination");
		$(this).addClass("pagination_active");
		var page = $(this).attr("id");
		$("#photo li").hide();
		$("#photo li." + page).show();
		$("#page").text(page);
	});
	
	var contentHeight = $("#main-content").height();
	$("#main-content div.center").css("height", contentHeight);
	var date = new Date();
	var yyyy = date.getFullYear();
	var mm = date.getMonth();
	var dd = date.getDate();
	$("#txtBoxSelectRoom").selectBox();
	$("#txtBoxSelectAdult").selectBox();	
	$("#txtBoxSelectChild").selectBox();
	$("#txtBoxSelectLanguage").selectBox();
	$("#selectLanguage li").click(function(){
		var language = $(this).text();
		$.ajax({
			type: "POST",
			url: "language.php",
			data: "language=" + language ,
			dataType: "html",
			cache: false, 
			error: function() 
			{ 
				alert("Error Something.")
			},
			success: function(data) 
			{
				$("body").fadeOut(250, function(){
					window.location.reload();									   
				});
			}
		});
	});
	$("#selectRoom li").click(function(){
		$("#txtNumOfAdult").val("");
		$("#slcChild").val("");
		var room = $("#txtNumOfRoom").val();
		if(room == "5+")
		{
			$("#frmQuickReserve").fadeOut(500, function(){
				$(this).html('<p>If you want to reserve more than 5 rooms.<br />Please, contact<br /><a href="mailto:reservation@gulliverhotel.com" title="reservation@gulliverhotel.com">reservation@gulliverhotel.com</a></p>').fadeIn(250);							
			});
		}
		else
		{
			var adult = parseInt(room);
			$("#selectAdult li").remove();
			$("#selectChild li").remove();
			for(var i = 1; i <= Math.round(adult * 2); i ++)
			{
				$("#selectAdult").append("<li>" + i + "</li>");
			}
			for(var i = 1; i <= adult; i ++)
			{
				$("#selectChild").append("<li>" + i + "</li>");
			}
		}
		$("#selectAdult li").click(function(){
			var adult = $(this).text();
			$("#txtNumOfAdult").val(adult);					   
		});
		$("#selectChild li").click(function(){
			var child = $(this).text();
			$("#slcChild").val(child);							   
		}); 
	});

	$("#slcCheckInMonthYear").datepicker({
		minDate: 'Y M D',
		dateFormat: 'MM, yy',
		altField: '#txtCheckInDay', 
		altFormat: 'd',
		showOn: 'button', 
		buttonImage: 'images/content/right/quick_reservation/icon_calendar.png', 
		buttonImageOnly: true,
		onSelect: function(dateText, inst) {
			var min_date = parseInt(inst.selectedDay);
			min_date = Math.round(min_date + 1);
			$("#txtCheckOutDay").val(min_date);
			$("#slcCheckOutMonthYear").val(dateText);
			$("#slcCheckOutMonthYear").datepicker('option', 'minDate', new Date(yyyy, mm, min_date));
		}
	});
	
	$("#slcCheckOutMonthYear").datepicker({
		minDate: 'Y M D',
		dateFormat: 'MM, yy',
		altField: '#txtCheckOutDay', 
		altFormat: 'd',
		showOn: 'button', 
		buttonImage: 'images/content/right/quick_reservation/icon_calendar.png', 
		buttonImageOnly: true
	});
});

function rooms_type(menu)
{
	var title = $("#" + menu).attr("title");
	var detail = $("#" + menu).attr("detail");
	$("#content div.title").html(title);	
	$("#content div.detail").html(detail);	
}