  $(document).ready(function() {
		// Setup homepage carousel
		var scrollCarouselStep = 900; // Scroll the carousel this much each time
		var scrollCarouselTo = 0; // First scroll
		carouselImageWidth = 310; // The width of each image in the carousel
		carouselImageTrueWidth = 300; // The real width of each image on the page (as we have a 10px overlap with the previous)

		
		$("#home_carousel_outer").scrollTo(0, 500); // Reset the scroll when the page is loaded

		var carouselNumber = $("#home_carousel_inner ul li").length; // Get the number of images in the carousel

		var carouselMod = carouselNumber % 3; // Get remainder from 3

		var carouselInnerWidth = carouselNumber * carouselImageWidth; // Set the initial width of the carousel to be 300 (width of an image) * the number of images

		if (carouselMod > 0)
		{
			// If we need to pad the carousel because of an uneven amount of images
			carouselInnerWidth = carouselInnerWidth + (3-carouselMod) * carouselImageWidth;
		}
		
		$("#home_carousel_inner").css("width", carouselInnerWidth); 


		// Right arrow is clicked
		$("#home_carousel_next").click(function() {
			scrollCarouselTo = scrollCarouselTo + scrollCarouselStep;


			if (($("#home_carousel_inner").width() - scrollCarouselTo) < carouselImageWidth)
			{
				// We're at the end, scroll back to the start
				scrollCarouselTo = 0;
			}
			$("#home_carousel_outer").scrollTo(scrollCarouselTo, 1000);
			return false;
		});


		// Left arrow is clicked
		$("#home_carousel_prev").click(function() {
			scrollCarouselTo = scrollCarouselTo - scrollCarouselStep;


			if (scrollCarouselTo < 0)
			{
				// We're at the start, scroll back to the end
				scrollCarouselTo = ((carouselNumber + (3-carouselMod)) / 3) * scrollCarouselStep;
				scrollCarouselTo = scrollCarouselTo - scrollCarouselStep;

				if (carouselMod == 0)
				{
					// If thare are an even number of items (3 on every step), don't scroll too far to the right
					scrollCarouselTo = scrollCarouselTo - scrollCarouselStep;
				}
			}
			$("#home_carousel_outer").scrollTo(scrollCarouselTo, 1000);
			return false;
		});
	

});
