$(function()
{
	getCurrency();
	setSunday(0);
	setGuests(2);
	showKidsAge2();
	window.name='HDBookPage';
	
	$("#city_menu ul li").mouseover(function() {
		$(this).addClass("over");
		$("span", this).addClass("over");
		$("span a", this).addClass("over");
	}).mouseout(function() {
		$(this).removeClass("over");
		$("span", this).removeClass("over");
		$("span a", this).removeClass("over");
	});
	
	$(".date_pick").mouseover(function(){
		$("img", this).attr("src", "img/icon_calendar_on.gif");
	}).mouseout(function(){
		$("img", this).attr("src", "img/icon_calendar.gif");
	});
	$("#arrive_pick").click(function(){
		openCalendar("http://www.hoteldirecteurope.com/calendarStart.htm");
		return false;
	});
	$("#depart_pick").click(function(){
		openCalendar("http://www.hoteldirecteurope.com/calendarEnd.htm");
		return false;
	});
	
	$("#rooms").change(function(){
		for (i = 2; i <= 5; i++)
		{
			$("#room_" + i).hide();
		}
		for (i = 2; i <= $(this).val(); i++)
		{
			$("#room_" + i).show();
		}
	});
	
	$(".room").change(function(){
		kids = 0;
		for (i = 1; i <= 5; i++)
		{
			if ($("#roomtype" + i).val().indexOf('family') > -1)
			{
				$("#kidsage_row").show();
				kids = 1;
			}
		}
		if (kids == 0)
			$("#kidsage_row").hide();
		setGuests(1);
	});
	
	$("#kidsage").blur(function(){
		setGuests(1);
	});
	
	$("#nights").change(function(){
		setEndDate($(this).val());
	});
	
	$("#arrivedate, #arrivedate2").change(function(){
		setEndDate($("#nights").val());
	});
	
	$("#departdate, #departdate2").change(function(){
		setNights();
	});
	
	$(".button").mouseover(function(){
		$(this).addClass("over");
	});
	$(".button").mouseout(function(){
		$(this).removeClass("over");
	});
	
	$(".cheapest").click(function(){
		$("#cheapest_box").toggle()
		if ($("span", this).hasClass("close"))
		{
			$("span", this).removeClass("close");
			$("span", this).text("Open");
		}
		else
		{
			$("span", this).addClass("close");
			$("span", this).text("Close");
		}
		return false;
	});
	
	$(".thumb").mouseover(function() {
		$(this).addClass("over");
	}).mouseout(function() {
		$(this).removeClass("over");
	}).click(function(){
		$(".thumb").each(function(){
			$("p", this).removeClass("click")
		});
		$("p", this).addClass("click");
		$("#slideshow_control").removeClass("pause");
		$("#slideshow_control").removeClass("over");
		$("#slideshow_control").removeClass("pause_on");
		loadImage();
		changeGallery($(this).attr("id").substring(5));
		return false;
	});
	
	$("#slideshow_control").click(function() {
		$(this).toggleClass("pause");
		$(this).toggleClass("pause_on");
		showSlideshow(-1);
		auto();
		return false;
	}).mouseover(function(){
		if ($(this).hasClass("pause"))
			$(this).addClass("pause_on");
		else
			$(this).addClass("over");
	}).mouseout(function(){
		if ($(this).hasClass("pause_on"))
			$(this).removeClass("pause_on");
		else
			$(this).removeClass("over");
	});
	
	$("#period").change(function(){
		if ($(this).val() != "")
		{
			location.href = $(this).val();
		}
	});
});
