//<![CDATA[

	function setupCS(name, withtext){

		var bannerName = name;
		var isThereText = withtext; // if this script needs to control a text element
		var increment = 712;
		var numElements = $('div.pagination').children().size(); 
		var BannerWidth = numElements * increment;
		var autoTime = 5000;
		var currentElement = 1;
		var previousElement = 1;
		var currentPosition = 0;
		var isAnimating = false;
		var isLocked = false;
			
		auto();
		$('div.pagination a:nth-child(1)').toggleClass('current');
		updateText(1, 0);
		$("#"+bannerName).css("width",BannerWidth+"px");
		$("#homePageBanner").css("overflow","hidden");
		$("#"+bannerName).addClass("jcarousel-list jcarousel-list-horizontal");
		$("#"+bannerName).addClass("jcarousel-container jcarousel-container-horizontal");

		
		  $("#"+bannerName).hover(
			  function () {
					isLocked = true;
			  }, 
			  function () {
					isLocked = false;
			  }
			);
		

		
				$("div.pagination a").click(function () { 
    		  	window.clearTimeout(autoTimer);
				
			   previousElement = currentElement;
			   currentElement = parseInt($(this).html());
	
			   diff = previousElement - currentElement;
			  amount= currentPosition + diff*increment;
			  currentPosition = amount;
			 if(isThereText == 1){updateText(currentElement, previousElement);}
			  move(amount, bannerName);
			  auto();
			  updateClass(currentElement, previousElement);
   		 });
		 
		 function updateClass(on, off){
				 if (on != off){ // if this button is clicked twoce we dont want to switch the class
				  $('div.pagination a:nth-child('+ off+')').toggleClass('current');
				$('div.pagination a:nth-child('+on+')').toggleClass('current');
				}
			};

		 
		function auto(){
		  autoTimer = window.setTimeout(function() {
		if(!isLocked){
		if (currentElement == numElements){
			previousElement = currentElement;
		 	currentElement = 1;
			 diff = previousElement - currentElement;
			 amount= currentPosition + diff*increment;
			currentPosition = amount;
			if(isThereText == 1){updateText(currentElement, previousElement);}
			
			move(amount, bannerName);
			
		}else{
		 previousElement = currentElement;
		 currentElement = currentElement + 1;
		 diff = previousElement - currentElement;
		 amount= currentPosition + diff*increment;
		currentPosition = amount; 
		if(isThereText == 1){updateText(currentElement, previousElement);}
		move(amount, bannerName);
				
		}
		updateClass(currentElement, previousElement);
		 auto();
		 }else{
		 	window.clearTimeout(autoTimer);
			auto();
		 }
		}, autoTime);
	} 
		 
	
	function updateText(objIn, objOut){
		if (objIn != objOut){
			$('div.home_title').fadeOut(200,function(){
														 var newText = $('div.pagination a:nth-child('+ objIn+')').attr("rel");
			 											  $('div.home_title').html(newText);
			 											  $('div.home_title').fadeIn(200);	
													});

		}
	}
	
	
	};
	
	

	
	function move(amount, objectName){
	
	$("#"+objectName).animate({
		left: amount
	}, {duration:1000, easing: 'easeOutCubic'});
	};
	
	

 //]]>
	

