(function($){ 
	
	$.fn.gallery = function(options) {  

		// container for settings  
		var settings = $.extend({},options||{});


		var iterator = 0;
		
		
		// Show item i
		function showItem(i) {
			// Display current item
			j_frames.css('display', 'none').eq(i).css('display', 'block');
		}
		
		// Show next item
		function showNextItem() {
			if(++iterator==j_frames.length) {iterator=0;}
			showItem(iterator);
		};
		
		// Show previous item
		function showPrevItem() {
			if(--iterator<0) {iterator = j_frames.length-1;}
			showItem(iterator);
		};

		
		
		// Define gallery
		j_gallery = $(this);
		
		// Find frames
		j_frames = j_gallery.find('li');
		
		// Append previous and next
		j_gallery.append('<div class="FJ_left"><span>Links</span></div><div class="FJ_right"><span>Rechts</span></div>');
		
		// Show 'first' frame
		showItem(iterator);
		
		// Previous and next hover
		$('.FJ_left',j_gallery).hover(function(){ $(this).addClass('active_left');}, function(){ $(this).removeClass('active_left'); });
		$('.FJ_right',j_gallery).hover(function(){ $(this).addClass('active_right');}, function(){ $(this).removeClass('active_right'); });
		
		// Previous and next click
		$('.FJ_left',j_gallery).click(showPrevItem);
		$('.FJ_right',j_gallery).click(showNextItem);
		
	};

})(jQuery);
