	$.fn.VahanenCarousel = function(opts) {
		var defaults = {
			items : '.CarouselItem',
			itemsArea : '.CarouselItems',
			next : false,
			prev : false,
			auto : false,
			speed : 500,
			loop : true
		};
		var options = $.extend(defaults, opts);
	
	//---------------------------------------------------
	
		this.each(function(){
			var carousel = $(this);
			options.carousel = $(this);
			carousel.find(options.itemsArea).prepend('<div class="IW_CarouselItemsRoller" style="position:relative;width:100%;overflow:hidden;"><table border="0" cellpadding="0" cellspacing="0"><tr></tr></table></div>');
			var roller = carousel.find(options.itemsArea).find('.IW_CarouselItemsRoller');
			
			carousel.find(options.items).each(function(e){
				roller.find('tr').append('<td class="item'+(e+1)+'"></td>');
				roller.find('td:last').append($(this));
			});
			
			carousel.find(options.next).addClass('IW_CarouselNavButton');
			carousel.find(options.prev).addClass('IW_CarouselNavButton');
			
			if(options.loop){
				var count = roller.find('td').length;
				if(count == 1){
					if(options.prev){
						$(options.prev).hide();
					}
					if(options.next){
						$(options.next).hide();
					}
				}else if(count == 2){
					var adj = roller.find('td').clone();
					roller.animate({scrollLeft: roller.width()}, 0).find('tr').prepend(adj);
				}else if(count > 2){
					var adj = roller.find('td:last');
					roller.animate({scrollLeft: roller.width()}, 0).find('tr').prepend(adj);
				}
			}
			
			if(options.auto !== false){
				carousel.addClass('AutoScrolledCarousel');
			}
		});
		
	//---------------------------------------------------
		
		this.find(options.next).click(function(){
			Scroll($(this), 'fw');
		});
	
	//---------------------------------------------------
	
		this.find(options.prev).click(function(){
			Scroll($(this), 'bw');
		});
	
	//---------------------------------------------------
	
		this.hover(function(){
			$(this).removeClass('AutoScrolledCarousel');
		}, function(){
			$(this).addClass('AutoScrolledCarousel');
		});
	
	//---------------------------------------------------
		
		$('.AutoScrolledCarousel').each(function(){
			AutoScroll($(this));
		});
	
	//---------------------------------------------------
	
		function AutoScroll(carousel){
			var btn = carousel.find(options.next);
			setTimeout(function(){
				if($('.AutoScrolledCarousel').length){	
					Scroll(btn, 'fw');
				}
				AutoScroll(carousel);
			}, options.auto);
		}
		
	//---------------------------------------------------
		
		function Scroll(btn, dir){
			if(!btn.is('.busy')){
				var roller = btn.parents(options.carousel).find('.IW_CarouselItemsRoller');
				
				if(dir == 'fw'){
					var left = roller.scrollLeft() + roller.width();
				}else{
					var left = roller.scrollLeft() - roller.width();
				}
				
				$('.IW_CarouselNavButton').addClass('busy');
				roller.animate({scrollLeft: left}, options.speed, function(){
					$('.IW_CarouselNavButton').removeClass('busy');
					if(options.loop){
						if(dir == 'fw'){
							var td = roller.find('td:first');
							roller.find('tr').append(td);
							roller.animate({scrollLeft: roller.width()}, 0)
						}
						else{
							var td = roller.find('td:last');
							roller.find('tr').prepend(td);
							roller.animate({scrollLeft: roller.width()}, 0)
						}
					}
				});
			}
		}
	
	};
