// JavaScript Document// JavaScript Document
(function($) {
	$.fn.slideshow = function(options) {
		var opts = $.extend({}, $.fn.slideshow.defaults, options);
		return this.each(function() {
			var $this 				= $(this);
			$this.opts 				= $.extend({}, opts);
			$this.opts.active		= 0;
			$this.opts.items		= $this.find('li').length;
			if($this.opts.items <= 1){
				$this.find('div.nav').hide();
			}
			$this.find('a.vorige').bind('click', function(){
				$.fn.slideshow.slide($this, $this.opts.active - 1);
			});
			$this.find('a.volgende').bind('click', function(){
				$.fn.slideshow.slide($this, $this.opts.active + 1);
			});
		});
	};
	$.fn.slideshow.defaults = {
	};
	
	$.fn.slideshow.slide = function($this, $newactive){
		if($newactive != $this.opts.active){
			if($newactive < 0){
				$newactive = $this.opts.items-1;	
			}
			if($newactive >= $this.opts.items){
				$newactive = 0;	
			}
			$this.find('div.nav span').html($newactive+1);
			$this.find('li').css({'zIndex':1});
			$this.find('li:eq('+$this.opts.active+')').css({display:'block', 'zIndex':2}).removeClass('active').fadeTo(300,0);
			$this.opts.active = $newactive;
			$this.find('li:eq('+$this.opts.active+')').addClass('active').css({'opacity':0, 'zIndex':3}).fadeTo(300,1);
		}
	}
	
})(jQuery);
