$(function() {	
	
	var restaurant = "restaurant";
	
	function showRest(whatRest) {
		var source = $(whatRest).attr("href");
		var target = "#" + source;
		$(target).fadeIn("slow");
		$(".restTimes").hide();
		var targHeight = $(target).css("height");
		var divHeight = parseInt(targHeight);
		var sectHeight = parseInt($("topSectionRestaurants").css("height"));
		var newHeight = (divHeight + 160) +"px";
		$("#topSectionRestaurants").animate(
			{height: newHeight},
			1000, showLower);
	}
	
	function goTop() {
		$("#topSectionRestaurants").animate(
			{height: newHeight},
			1000, showLower);
	}
	
	function showLower() {
		if($("#lowerSectionRestaurants").css("display") == "none") {
		$("#lowerSectionRestaurants").css("width", "0");
			$("#lowerSectionRestaurants").css("height", "120px");
			//$("#lowerSectionRestaurants").slideDown("slow", showTimes);
			$("#lowerSectionRestaurants").animate({width: "648px"}, 1000, showTimes);
		} else {
			showTimes();
		}
	}
	
	function showTimes() {
		var source = $(".restaurant:visible").attr("id");
		var times = "#" + (source + "Times");
		$(".restTimes").hide();
		$(times).fadeIn("slow");
	}
	
	$("ul#tabLinks li a").click(
		function() {
			restaurant = $(this).attr("href");
			$("ul#tabLinks li a").removeClass("active");
			$(this).addClass("active");
			imageSwap();
			$(".restaurant").hide();
			//alert($("#topSectionRestaurants").css("height"));
			showRest(this);
			return false;
		}
	);
	
	function imageSwap() {
		$("#mainImage img").hide();
		var roomImage = "#mainImage img#" + restaurant + "Image";
		$(roomImage).fadeIn("slow");
	}
	
});