var leftPosition= 0;
var slideWidth= 658;
var sI=0;
$(document).ready(function () {
	
	$('#slides-holder div').each(function (i) {  //arrange slides in one row
			$(this).css({'display':'block', 'left':leftPosition+'px' });
			leftPosition += (slideWidth);
			
	});
	
	$('.primaryPanel div').each(function (i) {  //add listener to buttons
			$(this).click( function () {
				var slideLeft= -slideWidth*i;
				var lightLeft= 145 + 100*i;
				$('#slides-holder').animate({'left':slideLeft+'px'}, 800);
				$('#light').animate({'left':lightLeft+'px'}, 800);
				clearTimeout(t); 
			});							 
	});
	
	slideTimer();  //loop sliding
	
});

function slideTimer() {
	var slideLeft= -slideWidth*sI;
	var lightLeft= 145 + 100*sI;
	$('#slides-holder').animate({'left':slideLeft+'px'}, 800);
	$('#light').animate({'left':lightLeft+'px'}, 800);
	if (sI < 4) {sI++;} else {sI = 0;}
	t = setTimeout('slideTimer()', 8000);
}

