
jQuery.log = function(message) { if(window.console) { console.debug(message); } };


$(document).ready(function() {

	var $slider_items = $('#slider a');
	
	//$slider_items.eq(0).addClass('active');
	var i = slideshow_interval = 1;
	//$.log($current.rel);
	// initialize scrollable together with the circular plugin
	var slider = $("#slider").scrollable({
		api: true,
		steps: 5,
		size: 5,
		clickable:false,
		easing: 'kslide', speed: 700
	});



	stop = function(){
		//$.log('Stop Animation');
		clearInterval(slideshow_interval);

	};

	start = function(){

		slideshow_interval = setInterval(
		function(){
			if(i > 4) { i = 0 ;}
			//src = .rel;
			show($slider_items[i]);
			i++;
		}, 3000);
	}

	show = function(el){
		//src = el.rel

		$slider_items.removeClass('active');
		$('#slider a[rel="'+el.rel+'"]').addClass('active');
		$('#content img').hide();

		$('#current').fadeIn('fast').attr('src',el.rel);
	}





	slider.onBeforeSeek(function() {
		stop();
	});

	/*$slider_items.click(function() {
		//src =  this.rel
		//$.log(this);
		show(this);
		return false;

	});*/





	//start();



});


$.easing.kslide = function (x, t, b, c, d) {
	var s = 1.70158;
	if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
}
