; (function ($) { $.fn.extend({ "nav": function (con) { var $this = $(this), $nav = $this.find('.switch-tab'), t = (con && con.t) || 3000, a = (con && con.a) || 500, i = 0, autochange = function () { $nav.find('a:eq(' + (i + 1 === 3 ? 0 : i + 1) + ')').addclass('current').siblings().removeclass('current'); $this.find('.event-item:eq(' + i + ')').css('display', 'none').end().find('.event-item:eq(' + (i + 1 === 3 ? 0 : i + 1) + ')').css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, a, function () { i = i + 1 === 3 ? 0 : i + 1; }).siblings('.event-item').css({ display: 'none', opacity: 0 }); }, st = setinterval(autochange, t); $this.hover(function () { clearinterval(st); return false; }, function () { st = setinterval(autochange, t); return false; }).find('.switch-nav>a').bind('click', function () { var current = $nav.find('.current').index(); i = $(this).attr('class') === 'prev' ? current - 2 : current; autochange(); return false; }).end().find('.switch-tab>a').bind('click', function () { i = $(this).index() - 1; autochange(); return false; }); return $this; } }); }(jquery));