$(document).ready(function() {

	var $highlight = $(".highlights");
	var current = 0;
	var t;
	
	$(".next").fadeTo("fast",0.3)
			  .hover(function() {
		$(this).fadeTo("normal",1.0);
	},function() {
		$(this).fadeTo("normal",0.3);
	}).click(function() {
		switchHighlight($(this));
		$(this).parent().unbind();
		return false;
	});
	
	$(".previous").fadeTo("fast",0.3)
				 .hover(function() {
		$(this).fadeTo("normal",1.0);
	},function() {
		$(this).fadeTo("normal",0.3);
	}).click(function() {
		switchHighlight($(this),false);
		$(this).parent().unbind();
		return false;
	});
	
	function switchHighlight($element,next) {
	
		clearTimeout(t);
	
		$highlight.eq(current).children(".next").fadeTo("normal",0.3);
		$highlight.eq(current).children(".previous").fadeTo("normal",0.3);
	
		$this = $element.parent();
		var id = $this.index();
		
		if( next == true ) {
			( id == ($highlight.size()-1) ) ? id = 0 : id++;
		}
		else {
			( id == ($highlight.size()-1) ) ? id = 0 : id++;
		}
		
		current = id;
		
		$this.fadeOut('slow',function() {
			$highlight.eq(current).fadeIn();
		});
		
		t = setTimeout(function() {
			$(".next").eq(current).click();
		},7000);
	
	}
	
	t = setTimeout(function() {
		$('.next').eq(0).click()
	},5000);
	

});
