/**
 *
 *
 */
function ActueelSlider()
{
	/*
	 */
	this.current_item = null;
	this.timer		  = null;
	this.delay		  = 3000;

	/**
	 *
	 */
	this.init = function()
	{
		this.current_item = $('.actueel_slider_container').find('div:first');
	
		this.makeCurrent(this.current_item);
	};

	/**
	 *
	 */
	this.makeCurrent = function(item)
	{
		$('.actueel_img_container img').fadeOut(200);
		
		$('.actueel_slider_item').removeClass('actueel_current').find('span').remove();
	
		item.addClass('actueel_current').prepend('<span></span>');
		
		var id = item.attr('id').replace("item", "");
		
		$('#img'+id).fadeIn(200);
		
		this.current_item = item;
		
		this.setTimer();
	};
	
	/**
	 *
	 */
	this.next = function()
	{
		if(this.current_item.attr('id').replace("item", "") == 3)
		{
			this.init();
		}
		else
		{
			var next_item = this.current_item.next()
			
			this.makeCurrent(next_item);
		};
	};
	
	/**
	 *
	 */
	this.setTimer = function()
	{
		var _self = this;
	
		this.timer = setTimeout(function(){ _self.next(); }, this.delay);
	};
	
	/**
	 *
	 */
	this.clear = function()
	{
		clearTimeout(this.timer);
	};
};

$(document).ready(function()
{
	var actueel_slider = new ActueelSlider();

	actueel_slider.init();
	
	$('.actueel_slider_item').hover(function()
	{
		actueel_slider.clear();
		
		actueel_slider.makeCurrent($(this));
		
		actueel_slider.clear();
	}, function()
	{
		actueel_slider.setTimer();
	});
});
