$(document).ready(function(){

	// homepage carousel config
	$("#carousel").jCarouselLite({
		btnNext: "#next",
		btnPrev: "#prev",
		visible: 1
	});

	// conferences&events carousel config
	$("#conferences-events").jCarouselLite({
		btnNext: "#events-next",
		btnPrev: "#events-prev",
		visible: 1,
		circular:false
	});

	// event handlers to control prev/next links
	// this one removes the next link on the last frame and replaces it with a view more link
	$("#conferences-events #events-next").click(function(e){
		e.preventDefault();
		if($("#conferences-events ul").css("left") == "-435px") {
			$("#events-next").after("<a href='http://www.alzdiscovery.org/index.php/news-events/events/conferences' id='seeMore'>See More Events</a>");
			$("#events-next").hide();
		}
	});

	// this one puts the next link back when the user navigates back
	$("#conferences-events #events-prev").click(function(e){
		e.preventDefault();
		if ($("#conferences-events ul").css("left") == "-870px" || $("#conferences-events ul").css("left") == "-435px" ) {
			$("#seeMore").remove();
			$("#events-next").show();
		}
	});
});