// JavaScript Document
// @author Rainer Wagner www.crash-design.de
(function($) {
	$.fn.extend({
		jRotate: function(imgCount) { 
		
			var width = $(this).width();
			var count = 0;
			var maxCount = imgCount-1;
			var innerDiv = $(this).children(".inner");
			
			function rotateImages(direction) {
				count = direction == "next" ? count+1 : count-1;
				count = count > maxCount ? 0 : count;
				count = count < 0 ? maxCount : count;
				innerDiv.animate({marginLeft: (-width*count)+"px"}, 500);
			}
		
			return this.each(function() {
				$(this).append("<a class='next'></a>");
				$(this).append("<a class='prev'></a>");
				$(this).children(".next").click(function() { rotateImages("next"); });
				$(this).children(".prev").click(function() { rotateImages("prev"); });
			});
		}	
	});
})(jQuery);
