$(function() {	
	
	var theRoom = "rooms"; 
	
	function showRoom(whatRoom) {
		var source = $(whatRoom).attr("href");
		var target = "#" + source;
		$(target).fadeIn("slow");
	}
	
	$("ul#tabLinks li a").click(
		function() {
			$("ul#tabLinks li a").removeClass("active");
			$(this).addClass("active");
			theRoom = $(this).attr("href");
			if($("#roomInfo").css("display") == "none") {
				$("#topSection p").fadeOut("slow");
				$("#topSection").animate({height: "100px"}, 1000);
				$("#contentRight").animate({height: "396px"}, 1000, goInfo);
				theRoom = $(this).attr("href");
			} else {
				showInfo();
			}
			return false;
		}
	);
	
	function goInfo() {
		$("#roomInfo").animate({width: "644px"}, 1000, showInfo);

	}
	
	function showInfo() {
		$("#roomInfo div").hide();
		imageSwap();
		var daRoom = "#" + theRoom;
		$(daRoom).fadeIn("slow");
		if(daRoom != ("#guestRooms" || "#executiveLounge")) {
			var theSub = "ul" + daRoom + "Links";
				$(".subLinks").fadeOut("fast");
				$(theSub).slideDown("slow");
		} else {
			$(".subLinks").fadeOut("fast");
		}
	}
	
	$("ul.subLinks li a").click(
		function() {
			$("#roomInfo div").hide();
			theRoom = $(this).attr("href");
			imageSwap();
			var type = $(this).attr("href");
			if(type != "presedential") {
				$("#contentRight").animate({height: "396px"}, 1000);
				$("#roomInfo").animate({height: "190px"}, 1000);
				showRoom(this);
			} else {
				$("#contentRight").animate({height: "650px"}, 1000);
				$("#roomInfo").animate({height: "444px"}, 1000);
				showRoom(this);
			}
			return false;
		}
	);		
	
	function imageSwap() {
		$("#mainImage div").hide();
		$("mainImage div").cycle('stop');
		var roomImage = "#mainImage div#" + theRoom + "Image";
		/*$("#mainImage img").attr("src", roomImage, fader());*/
		$(roomImage).fadeIn("slow");
		$(roomImage).cycle({
			fx:'fade',
			timeout:'6000'
		});

	}
	
	function fader() {
		$("#mainImage div").fadeIn("slow");
	}
	
});
