
	var carouselItem = 0;

	var carouselImages = [
		"Home1.jpg",
		"Home1.jpg",
		"Home2.jpg",
		"Home3.jpg",
		"Home4.jpg",
		"Home5.jpg"
		//"Home6.jpg",
	];

	var carouselColours = [
		"green",
		"green",
		"green",
		"brown",
		"brown",
		"blue"
		//"brown",
	];


	$(document).ready(function() {
		$("#hero_wrapper_home").append("<div id='hero_wrapper_temp_current'></div>");
		$("#hero_wrapper_home").append("<div id='hero_wrapper_temp_next'></div>");
		carouselMove();
	});


	function carouselMove() {
		carouselItem = carouselItem + 1;
		if (carouselItem >= carouselImages.length-1)
		{
			carouselItem = 0;
		}
		$("#next_hero").attr("src", "/media/images/home_carousel/" + carouselImages[carouselItem]);
		//var wrapper_position = $("#hero_wrapper_home").offset();
		$("#hero_wrapper_temp_current").css("top", "-0px");
		$("#hero_wrapper_temp_next").css("top", "-0px");

		$("#hero_wrapper_temp_next").removeClass("hero_wrapper_brown");
		$("#hero_wrapper_temp_next").removeClass("hero_wrapper_green");	
		$("#hero_wrapper_temp_next").removeClass("hero_wrapper_blue");			
		
		//alert("hero_wrapper_" + carouselColours[carouselItem]);


		$("#hero_wrapper_temp_next").addClass("hero_wrapper_" + carouselColours[carouselItem]);
		
		
		$("#hero_wrapper_temp_current").show();
		$("#hero_wrapper_temp_next").hide();

		$("#hero_wrapper_home").removeClass("hero_wrapper_brown");
		$("#hero_wrapper_home").removeClass("hero_wrapper_green");	
		$("#hero_wrapper_home").removeClass("hero_wrapper_blue");	

		$("#hero_wrapper_temp_next").fadeIn(2000, function() {
			// After next hero wrapper has faded in
			$("#hero_wrapper_home").addClass("hero_wrapper_" + carouselColours[carouselItem]);
			$("#hero_wrapper_temp_next").hide();
			//$("#hero_wrapper_temp_current").hide();
			
			// Set up the next one
			$("#hero_wrapper_temp_current").removeClass("hero_wrapper_brown");
			$("#hero_wrapper_temp_current").removeClass("hero_wrapper_green");	
			$("#hero_wrapper_temp_current").removeClass("hero_wrapper_blue");	
			$("#hero_wrapper_temp_current").addClass("hero_wrapper_" + carouselColours[carouselItem]);

			$("#hero_wrapper_home").removeClass("hero_wrapper_brown");
			$("#hero_wrapper_home").removeClass("hero_wrapper_green");	
			$("#hero_wrapper_home").removeClass("hero_wrapper_blue");	

			$("#hero_wrapper_temp_next").removeClass("hero_wrapper_brown");
			$("#hero_wrapper_temp_next").removeClass("hero_wrapper_green");	
			$("#hero_wrapper_temp_next").removeClass("hero_wrapper_blue");	
			
			$("#hero_wrapper_home").addClass("hero_wrapper_" + carouselColours[carouselItem]);

			$("#hero_wrapper_temp_current").hide();

			$("#hero_wrapper_temp_next").hide();


		});
		//$("#hero_wrapper_temp").css("background-color", "red");
		$("#current_hero").fadeOut(2000, function() {
			$("#current_hero").attr("src", "/media/images/home_carousel/" + carouselImages[carouselItem]);			
			$("#current_hero").show();		
			//$("#hero_wrapper_temp_current").hide();
		});	
	}

	$(document).ready(function() {
		setInterval("carouselMove()", 8000);
	});

	$(document).ready(function() {

		
		$("#hero_check_availability").after("<div id='hero_check_availability_placeholder'>&nbsp;</div>");
		$("#hero_check_availability_placeholder").hide();

		$(".hero_popup_wrapper").hide();
		$("#hero_check_availability_wrapper").hide();

		$("#hero_check_availability > a").click(function() {
			$(".hero_popup_wrapper").each(function() {
				if ($(this).is(":visible"))
				{
					$(this).hide("slide", { direction: "down" }, 500);
				}
			});
			$("#hero_check_availability_wrapper").toggle("slide", { direction: "up" }, 500);
			return false;	
		});

		$("#hero_nav_bottom > ul > li > a").click(function() {

			// Hide the "check availability" form
			if ($("#hero_check_availability_wrapper").is(":visible"))
			{
				$("#hero_check_availability_wrapper").hide("slide", { direction: "up" }, 500);
			}

			var clicked_link = this;

			$(".hero_popup_wrapper").each(function() {
				if ($(this).is(":visible") && ($(this).attr("id") != "hero_" + $(clicked_link).attr("rel") + "_wrapper"))
				{
					$(this).hide("slide", { direction: "down" }, 500);
				}
			});



			$("#hero_" + $(this).attr("rel") + "_wrapper").toggle("slide", { direction: "down" }, 500);


			if ($(clicked_link).attr("rel") == "experiences")
			{
				$("#hero_check_availability").toggle();
				$("#hero_check_availability_placeholder").toggle();
			}
			else
			{
				if ($("#hero_check_availability_placeholder").is(":visible"))
				{
					$("#hero_check_availability_placeholder").toggle();
					$("#hero_check_availability").toggle("slide", { direction: "up" }, 500);					
				}
			}	
			

			return false;
		});


	});

