// JavaScript Document


$(document).ready(function(){	
	
	//get the number of pager elements there are		   
	var count = $('#pager a').size();


	//rotate the main image
	$('#rotateMain').jCarouselLite({
		visible: 1,				//one image visible at a time
        btnNext: "a.next",		//assign the next button
        btnPrev: "a.prev",		//assign the previous button
		auto: 8000,				//the time (in milliseconds) between each rotation
		speed: 500,				//the time (in milliseconds) for each rotation to take place
		btnGo:
		[".1",".2",".3",".4"],	//assign classes for the 4 circles under the image text

		//this function displays the correct photo text and makes the current circle the active one
        afterEnd: function(a) {
		   $('#text1, #text2, #text3, #text4').css("display","none");
           var photoIndex = a.index();
		   if(photoIndex > count) photoIndex = 1;
		   if(photoIndex < 1) photoIndex = count;
		   $('#text' + photoIndex).css("display","block");
		   
		   $('ul#pager a').removeClass('activeSlide'); 
		   $('ul#pager a.'+photoIndex).addClass('activeSlide');
       }

	});

	//rotate the carousel list on the homepage
	$('.carouselList').jCarouselLite({
		visible: 3,						//3 items visible at a time
        btnNext: "a#carousel-next",		//assign the next button
        btnPrev: "a#carousel-prev"		//assign the previous button
	});
	
	//this function assigns different background colors for the even carousel lists
	$('div.carouselList ul li:even').addClass('even');
	
	//this function adds an ellipsis if the text in the carousel gets too long
	$('div.carouselContent').ellipsis();

});



