$.fn.rollOver = function(){
	
	$(this).mouseover(function(e){
			var main = $(this).parent();
			if (main.find(".smallfotobox").length == 0)
				main.append('<div class="smallfotobox"><img src="'+$(this).attr('href').replace(700,200)+'" alt="" /></div>');
			
			var element = main.find(".smallfotobox");
			element.fadeIn(50);
		});
	
	$(this).mousemove(function(e){
			var main = $(this).parent();
			var element = main.find(".smallfotobox");
			
			var height = element.find("img").height() + 20;
			var top = $(window).height() - e.clientY; 
			if (top > height)	top = 0;
			else				top = height - top;
			
			element.css({
						top: e.pageY - top,
						left: e.pageX + 20
						});
		});
	
	$(this).mouseout(function(e){
			
			var main = $(this).parent();
			if (main.find(".smallfotobox").length == 1)
				main.find(".smallfotobox").fadeOut(50);
		});
	
	
	return this;
};

var next;
$.fn.carousel = function(){

	var ullist	= $("ul", this);
	var breed	= $(this).width();
	var aantal	= $("li", this).length;
	var huidig	= 0;
	var side	= true;
	var timer	= null;
	
	ullist.width( breed * aantal );
	
	 next = function(){
		if (side){
			huidig ++;
			if (huidig >= (aantal-1)) side = false;
		} else {
			huidig --;
			if (huidig <= 0) side = true;
		}
		
		ullist.animate({
		    left: "-" + (breed * huidig) + "px"
		  }, 'slow');
	};
	
	$(window).blur(function(){
		clearInterval(timer);
		timer = null;
	});
	$(window).focus(function(){
		if (!timer){
			timer = setInterval("next();", 4000);
		}
	});
	
	timer = setInterval("next();", 4000);
	
};
