		var currentIndex = 0;
		var currrentTarget = null;
		var target_arr = new Array ('panel1','panel2','panel3','panel4','panel5','panel6','panel7');
		var fade_arr = new Array (false,true,true,true,true,true,true);
		var carouselRef = null;
		
		function changeDisplay(clip, target, fade) {
			
			var clipParent = clip
			var clipIndex = $("#featureCarousel li").index(clipParent);
			
			// removes class from old selection
			var oldClip = $('.thumbHolderSelected');
			oldClip.removeClass('thumbHolderSelected');
			oldClip.addClass('thumbHolder');
			
			// adds class to new selection
			var newClip = $(clipParent).children('.thumbHolder');
			newClip.addClass('thumbHolderSelected');
			
			// reassigns selection
			currentIndex = clipIndex;
			
			// show correct panel
			if(target != currentTarget)
			{
				var oldTarget = currentTarget
				var newTarget = target;
				
				// test to see if oldTarget is undefined
				if(!oldTarget){
					targetShow(newTarget);
				} else {
					$('#'+oldTarget).fadeOut('fast', function() {
						targetShow(newTarget, fade);
					});	
				}			
			}
			
			// scrolls carousel to the correct position
			carouselRef.scroll(currentIndex+1);
			
			
		
		}
		
		function targetShow(newTarget, fade) {
			if(fade == true){
				$('#'+newTarget).fadeIn('fast');
			} else {
				$('#'+newTarget).show();
			}
			currentTarget = newTarget;
			//
		}
		
		function selectNext() {		
			if (currentIndex < target_arr.length - 1) {
				currentIndex++;				
			} else {
				currentIndex = 0;
			}
						
			var newTarget = target_arr[currentIndex];
			var newClip = $('#featureCarousel li').eq(currentIndex);
			
			changeDisplay(newClip, newTarget, fade_arr[currentIndex]);
			
		
		}
		
		
		function carouselCallback(carousel, state){		
			// sets up global reference to carousel	
			carouselRef = carousel;					
		}
	
	
        $(document).ready(function() {
			
			// jCaoursel
			$('#featureCarousel').jcarousel({
				scroll: 4,
				auto: 0,
				/*wrap: 'last',*/
				visible: 4,
				start: 1,
				initCallback: carouselCallback
			});				
			
			// hides features
			$('#mainFeatures li').each(
				function () {
					$(this).hide();					
				}
			);
			
			// stops slideshow if item is clicked
			$('#featureCarousel li').click(
				function () {
					clearInterval(slideInterval);					
				}
			);
			
			// show first feature -- corresponds with initial thumbHolderSelected
			targetShow('panel1', false);		
			var slideInterval = setInterval(selectNext, 26000); 			
			
			// shows hiiden divs
			document.getElementById('homeFeatureCarousel').style.visibility = 'visible';
			document.getElementById('mainFeatures').style.visibility = 'visible';
					
			
			   
    
        });
		
