$(document).ready(function() {	

	//start the feature panel timer
	timer = setTimeout("setHPCarouselPanel('next',true)",7000);
	
	//define number of feature panel items
	hpPanelLength = $('#feature_A .item').size();

});

currentIndexStart = 0;

function setHPCarouselPanel(i,x) {				
					
	//hide all the panel elements
	$('#feature_A .item').hide();
	
	//remove the active class from the carousel nav
	$('.homeCarouselIndicators > a').removeClass('current');				
				
	if (i == 'next') {
		currentIndexStart = currentIndexStart + 1;
		if (currentIndexStart >= hpPanelLength) {				
			currentIndexStart = 0;
		}							
	} else if (i == 'prev') {
		currentIndexStart = currentIndexStart - 1;
		if (currentIndexStart < 0) {				
			currentIndexStart = hpPanelLength - 1;
		}					
	} else {
		currentIndexStart = i;
	}

	//show the needed panel	& correct active state on the panel pagination
	$('.homeCarouselGallery > .item:eq(' + currentIndexStart + ')').fadeIn('fast');
	$('.homeCarouselIndicators > a:eq(' + currentIndexStart + ')').addClass('current');
	
	timer = clearTimeout(timer);	
	if (x == true) { 					
		timer = setTimeout("setHPCarouselPanel('next',true)",7000);								
	}
				
}


function setPageCarouselPanel(i) {				
					
	//hide all the panel elements
	$('.pageCarouselGallery > .item').hide();
	
	//remove the active class from the carousel nav
	$('.pageCarouselLinks li span').removeClass('current');				
				
	//show the needed panel	& correct active state on the panel pagination
	$('.pageCarouselGallery > .item').eq(i).show();
	$('.pageCarouselLinks li span').eq(i).addClass('current');
				
}	
