$(document).ready(function(){
	
	$("#datepicker1").datepicker({dateFormat:'yy-mm-dd', minDate: new Date()});
	
	$("#choose_cat").change(function(){
		if($("#choose_cat").val() == "whitchurch")
		{
			$("#whitchurch_link").css("display","block");
			$("#nantwich_link").css("display","none");
			$("#leek_link").css("display","none");
			
		}
		else if($("#choose_cat").val() == "nantwich")
		{
			$("#nantwich_link").css("display","block");
			$("#whitchurch_link").css("display","none");
			$("#leek_link").css("display","none");
		}
		else if($("#choose_cat").val() == "leek")
		{
			$("#leek_link").css("display","block");
			$("#whitchurch_link").css("display","none");
			$("#nantwich_link").css("display","none");
		}
		else
		{
			$("#leek_link").css("display","none");
			$("#whitchurch_link").css("display","none");
			$("#nantwich_link").css("display","none");
		}
	});
	
	$("#cat_hotel").change(function(){
		if($("#cat_hotel").val() == "194673")
		{
			$("#whitchrch_sub").css("display","block");
			$("#nanwich_sub").css("display","none");
			$("#leek_sub").css("display","none");
			$("#hid").val("194673");
		}
		else if($("#cat_hotel").val() == "194665")
		{
			$("#whitchrch_sub").css("display","none");
			$("#nanwich_sub").css("display","block");
			$("#leek_sub").css("display","none");
			$("#hid").val("194665");
		}
		else if($("#cat_hotel").val() == "194675")
		{
			$("#whitchrch_sub").css("display","none");
			$("#nanwich_sub").css("display","none");
			$("#leek_sub").css("display","block");
			$("#hid").val("194675");
		}
		else
		{
			$("#whitchrch_sub").css("display","none");
			$("#nanwich_sub").css("display","none");
			$("#leek_sub").css("display","none");
		}
	});
	
	$("#whitchrch_sub, #nanwich_sub, #leek_sub").change(function(){
		$("#rid").val($(this).val());
	});
});

function hotel_submit(){
	var hid =	$("#hid").val();
	var rid = 	$("#rid").val();
	var d	=	$("#datepicker1").val();
	var ad = parseInt($("#a").val());
	var ch = parseInt($("#c").val());
	if(hid.length == 0)
	{
		alert("Please select a cat");
		return false;
	}
	else if(rid.length == 0)
	{
		alert("Please select a room type");
		return false;
	}
	else if(d.length == 0 || d == "Date")
	{
		alert("Please select a date");
		return false;	
	}
	else if($("#rid").val() == "4487670")
	{
		if((ad + ch) > 2)
		{
			alert("Sorry the Luxury room can only sleep 2 people");
			return false;
		}
	}
	else if($("#rid").val() == "4487672")
	{
		if((ad + ch) > 2)
		{
			alert("Sorry the Suite room can only sleep 2 people");
			return false;
		}
	}
	else if($("#rid").val() == "4487673")
	{
		if((ad + ch) > 1)
		{
			alert("Sorry the Superior room can only sleep 1 people");
			return false;
		}
	}
	else if($("#rid").val() == "4487675")
	{
		if((ad + ch) > 1)
		{
			alert("Sorry the Standard room can only sleep 1 people");
			return false;
		}
	}
	else if($("#rid").val() == "4487961")
	{
		if((ad + ch) > 2)
		{
			alert("Sorry the Luxury room can only sleep 2 people");
			return false;
		}
	}
	else if($("#rid").val() == "4487963")
	{
		if(ad > 2 || ch > 2)
		{
			alert("Sorry the Family room can only sleep 2 adults and 2 children");
			return false;
		}
	}
	else if($("#rid").val() == "4487657")
	{
		if((ad + ch) > 2)
		{
			alert("Sorry the Deluxe room can only sleep 2 people");
			return false;
		}
	}
	else if($("#rid").val() == "4487659")
	{
		if((ad + ch) > 2)
		{
			alert("Sorry the 1 Bed Apartment can only sleep 2 people");
			return false;
		}
	}
	else if($("#rid").val() == "4487660")
	{
		if((ad + ch) > 2)
		{
			alert("Sorry the Executive room can only sleep 2 people");
			return false;
		}
	}
	else if($("#rid").val() == "4487667")
	{
		if((ad + ch) > 4)
		{
			alert("Sorry the 2 Bed Apartment can only sleep 4 people");
			return false;
		}
	}
	else
	{
		return true;
	}
}