$(document).ready(function() {
	
	/* Config variables*/
	var n_of_boxes = 4;
	var time_interval = 6000;
	/******/
	
	
	//Set the first one to active
	$("#boxes-list li:first").attr("class","active");
	$("#pic-1").show();
	$("#desc-box-1").show();
	
	//Start the scroller
	startScroller();
	
	var counter = 2;
	function startScroller() {
		var interval = setInterval(function()
		{
			//Update right box
			$("#boxes-list li").attr("class","");
			$("#box-"+counter).attr("class","active");
			
			//Update picture
			$(".picture img").fadeOut("slow");
			$("#pic-"+counter).fadeTo(600, 1).fadeIn("slow");
			
			//Update Description
			$(".description").fadeOut("slow");
			$("#desc-box-"+counter).fadeTo(600, 1).fadeIn("slow");
			
			counter++;
			if(counter > n_of_boxes) counter = 1;
			
		}, time_interval);
		
		//Pause function on hover
		$(".boxes-desc").mouseover(function() {
			clearInterval(interval);
		});
		
		//stop function
   		$("#boxes-list li").click(function()
   		{	
	   	 	var url = $(this).find('.content').attr('id');
	   	 	window.location = url;
	   	 	/*
	   	 	//Stop looping
	     	clearInterval(interval);
	     	
	     	var number = $(this).attr("id");
	   		number = number.substr(4);
	     
	     	//Set box
	     	$("#boxes-list li").attr("class","");
	     	$(this).attr("class","active");
	     	//Go to pic
	     	$(".picture img").stop().fadeOut("slow");
	     	$("#pic-"+number).stop().fadeTo(600, 1).fadeIn("slow");
	     	//Go to desc
	     	$(".description").stop().fadeOut("slow");
			$("#desc-box-"+number).stop().fadeTo(600, 1).fadeIn("slow");
			*/
	     
   		});
	}	
	
	//On mouse out, restart the scrolling
	$(".boxes-desc").mouseout(function() {
		startScroller();
	});
	 
});
