(function($){ $.fn.jslider = function(options){ var defaults = { pause:3000, fadeouttime:500, fadeintime:500, navislider:'navislider' } var options = $.extend(defaults, options); var obj = $(this); obj.find('li:first').show(); var itemcount = obj.children('li').length; var naviobj=$("#"+options.navislider); var i=0; naviobj.children('li').click(function(){ //var index = $(this).text(); var index =$(this).attr("sindex"); i = parseint(index)-2; showslider(); }) var showslider = function(){ var next =i+1; if(i >= (itemcount-1)){ i=-1; next=0; } obj.children('li').filter(":visible").fadeout(options.fadeouttime).parent().children().eq(next).fadein(options.fadeintime); naviobj.children('li').removeclass('on').eq(next).addclass('on'); i = i+1; } var interval = setinterval(function(){ showslider(); }, options.pause); obj.hover(function() { clearinterval(interval); }, function() { interval = setinterval(function(){ showslider(); }, options.pause); /* stuff to do when the mouse leaves the element */ }); } })(jquery);