$(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(){
		$("#txtAdult2").val("");
		$("#txtChild2").val("");
		var room = $("#txtRoom2").val();
		if(room == "5+")
		{
			$("#frmQuickReserve").fadeOut(500, function(){
				$("#reservationNote").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();
			$("#txtAdult2").val(adult);					   
		});
		$("#selectChild li").click(function(){
			var child = $(this).text();
			$("#txtChild2").val(child);							   
		}); 
	});
/*
	$("#txtCi2").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 reservation_back()
{
	$("#reservationNote").fadeOut(500, function(){
		$("#frmQuickReserve form input").each(function() {
			var type = this.type;
			var tag = this.tagName.toLowerCase();
			if(type == 'text' || type == 'password' || tag == 'textarea')
			{
				this.value = "";
			}
			else if (type == 'checkbox' || type == 'radio')
			{
				this.checked = false;
			}
			else if (tag == 'select')
			{
				this.selectedIndex = -1;
			}
		});
		$("#frmQuickReserve").fadeIn(250);							
	});
}

function photo_gallery(path)
{
	$("#main-banner-display").fadeOut(250, function(){
		$(this).html("");
		$(this).html("<img src='" + path + "'>").fadeIn(250);
	});	
}
function panorama(type)
{
	$("#main-banner-display").fadeOut(250, function(){
		$(this).html("");
		$(this).load("rooms/pnrm_" + type + ".php").fadeIn(250);
	});	
}
function load_360()
{
	$("#loading").fadeOut(250, function(){
		$("#panorama").fadeIn(250);
	});
}
/*function content(id)
{
	$.ajax({
			type: "POST",
			url: "content.php",
			data: "id=" + id ,
			dataType: "html",
			cache: false, 
			error: function() 
			{ 
				alert("Error Something.")
			},
			success: function(data) 
			{
				$("#content").fadeOut(250, function(){
					$(this).html(data).fadeIn(250);									   
				});
			}
		});
}*/