(function($){
	$.fn.imgShow = function(options){
		var set = {
			timeout: 20000, 
			next:   '#next', 
			prev:   '#prev'
		};
		var opts = $.extend(set,options);
		var n = 0;
		var timer = null;
		var that = this;
		var stopClick = false;
		function play(){
			timer = setInterval(function(){
				n++
				if(n==$(that).find('a').size()) n =0;
				$(that).find('a').hide().eq(n).fadeIn('slow');
				ml();
			},opts.timeout);
		}
		play();
		$(options.next).click(function(){
			if(stopClick) return;
			stopClick = true;
			clearInterval(timer);
			n++;
			if(n==$(that).find('a').size()) n =0;
			$(that).find('a').hide().eq(n).fadeIn('slow', function() { stopClick = false });
			ml();
			play();
		});
		
		$(options.prev).click(function(){
			if(stopClick) return;
			stopClick = true;
			clearInterval(timer);
			if(n==0) n = $(that).find('a').size();
            n--;
            $(that).find('a').hide().eq(n).fadeIn('slow', function() { stopClick = false });
            ml();
			play();
		});
        function ml(){
            if (n != 0) { $('#navmenu').hide(); } else { $('#navmenu').show(); }
        }
	}
})(jQuery);

