$(document).ready(function() {
	$('#headerFeature').css("display", "block");
	
	$('#headerNav li:last').css("border-right", "none");
	elements = $("#headerFeature > div").size();	
	counter = 0;
	
	$("#headerFeature > div:not(:first)").hide();
	
	$("#nextSlide").click( function() {
		if (counter == (elements-1)) {
			//We are at the start element
			//therefore we set the next counter as the last element
			var nextSlideCount = 0
		} else {
			var nextSlideCount = counter + 1
		}
			
		var thisSlide = "#headerFeature > div:eq(" + counter + ")"
		var nextSlide = "#headerFeature > div:eq(" + nextSlideCount + ")"
	
		$(thisSlide).fadeOut(1500);
		$(thisSlide).removeClass("bannerActive");
		$(nextSlide).fadeIn(1500);	
		$(nextSlide).addClass("bannerActive");
		counter = nextSlideCount;
		
		clearInterval(timerval);
		
		timerval = setInterval("moveBanner()", 12000 );

		
	});
	
	$("#prevSlide").click( function() {
		if (counter == 0) {
			//We are at the start element
			//therefore we set the next counter as the last element
			var nextSlideCount = (elements-1)
		} else {
			var nextSlideCount = counter - 1
		}
		var thisSlide = "#headerFeature > div:eq(" + counter + ")"
		var nextSlide = "#headerFeature > div:eq(" + nextSlideCount + ")"
	
		$(thisSlide).fadeOut(1500);
		$(nextSlide).fadeIn(1500);	
		counter = nextSlideCount;
		
		clearInterval(timerval);
		
		timerval = setInterval("moveBanner()", 12000 );

	});
	
	
	var timerval = setInterval("moveBanner()", 12000 );
});

	function moveBanner(){
		if (counter == (elements-1)) {
			//We are at the start element
			//therefore we set the next counter as the last element
			var nextSlideCount = 0
		} else {
			var nextSlideCount = counter + 1
		}
			
		var thisSlide = "#headerFeature > div:eq(" + counter + ")"
		var nextSlide = "#headerFeature > div:eq(" + nextSlideCount + ")"
	
		$(thisSlide).fadeOut(1500);
		$(thisSlide).removeClass("bannerActive");
		$(nextSlide).fadeIn(1500);	
		$(nextSlide).addClass("bannerActive");
		counter = nextSlideCount;
		
		
	}

