/**
 *
 *
 */
var slider_timer;

function Slider(options)
{

	//1e slide achteraan zetten
	$('.slides ul').find('li').eq(0).clone().appendTo('.slides ul').attr('id','final-first');


	var defaults =
	{
		//count  : $('#s-container img').length,
		count  : $('.slides ul li img').length,
		current: 0,
		delay  : 8000,
		speed  : 3000,
		/*delay  : 1000,
		speed  : 500,*/
		width  : 780
	};
	
	var options = $.extend(defaults, options);
	
	/**
	 *
	 */
	this.slide = function(c)
	{
		var _self = this;

		if(typeof c == "undefined")
			options.current++;
		else
		{
			clearTimeout(slider_timer);
			
			options.current = c;
		};
		
		if(options.current >= options.count)
		{
			options.current = 0;
			var m = 0;
			var q = 1;
			$('.slides ul').css({marginLeft: "-"+(m * options.current)+"px"});
		}
		else
		{
			var m = 780;
			var q = 0;
		}
		
		if(q == 0)
			$('.slides ul').animate({marginLeft: "-"+(m * options.current)+"px"}, options.speed);
			
		if(options.count > 0)
		{
			this.slideInfoBox();
			this.slideNavigation();
		}

		var aant = ($('#slideshow .slides ul li').length);
		if (aant > 1)
		{
			if(q == 1)
				slider_timer = setTimeout(function(){ _self.slide(); }, 0);
			else
				slider_timer = setTimeout(function(){ _self.slide(); }, options.delay);
		}
	};
	
	/**
	 *
	 */
	this.slideInfoBox = function()
	{
		$('#info ul li').hide();
		
		if(options.current >= options.count -1)
			$('#info ul li:eq(0)').fadeIn(500);
		else
			$('#info ul li:eq('+options.current+')').fadeIn(500);
	}
	
	this.slideNavigation = function()
	{
		$('ul.slides-nav li span.active').removeClass('active');
		
		if(options.current >= options.count -1)
			$('ul.slides-nav li:eq(0) span').addClass('active');
		else
			$('ul.slides-nav li:eq('+options.current+') span').addClass('active');
	}
	
};
