
$(document).ready(function() {

	var width = 194;
	var offset = 0;
	var speed = 750;
	var t = "";
	 
	var max = $('#scroller_container').children().size()-1;

	$("#prev").click(function(event) {
		scroll(-1);
		window.clearInterval(t);
		t = window.setTimeout(startloop,8000);
	});
	
	$("#next").click(function(event) {
		scroll(1);
		window.clearInterval(t);
		t = window.setTimeout(startloop,8000);
	});
	
	function scroll(dir)
	{
		offset = offset + 1 * dir;
		
		if(offset >= max) {
			offset = max;
			$("#next").fadeOut(speed);
		} else {
			$("#next").fadeIn(speed);
		}
		
		if(offset <= 0) {
			offset = 0;
			$("#prev").fadeOut(speed);
		} else {
			$("#prev").fadeIn(speed);
		}
	
		$("#scroller_container").animate({marginLeft: -(width * offset) + "px"}, {duration:speed, easing:"easeOutBounce"});
	}

	// accordion
	$(function() {
		$("#accordion").accordion({autoHeight: false});
	});
	$("#medailles").fadeIn(speed);
	
	
	
	
	// loop
	function loop()
	{
		scroll(1);
		if(offset >= max) {
			offset = -1;
		}
	}
	
	// startloop
	function startloop()
	{
		t = window.setInterval(loop,4000);
	}
	startloop();
	
	
	
	
});


	
