$(function(){
	time = 10 //Seconds.
	speed = 1000
	easeMethod = 'cubicEaseInOut'
	index = 0
	total = $('#slider .holder ul.items > li').length
	
	inter = setInterval(nextAd, time*1000)
	
	$('a[class=next]').click(function(){
		nextAd();
	});
	$('a[class=previous]').click(function(){
		previousAd();}
	);
	$('#slider .thumbs ul li').each(function(){
		$(this).click(function(){
			clearInterval(inter)
			inter = setInterval(nextAd, time*1000)
			index = $('#slider .thumbs li').index(this)
			moveto(index)
		});
	});
	function nextAd(){
		if(index>=total-1)
			index=-1;
		moveto(++index)
	}
	function previousAd(){
		if(index<=0)
			index=total;
		moveto(--index);
	}
	function moveto(index){
		$('#slider .holder ul.items').stop().animate({'top':-$('#slider .holder ul.items li:first').height()*index} ,{queue:false, duration:speed, easing:easeMethod})
		$('#slider .thumbs ul').stop().animate({'top':-(82*index-1)} ,{queue:false, duration:speed, easing:easeMethod})
	}
});
