;(function($){$.fn.extend({tabs:function(opt){opt=$.extend({event:'mouseover',timeout:100,auto:0,callback:null},opt);var a=$(this),menu=a.children().eq(0),items=menu.children(),tabBox=a.children().eq(1).children(),timer,tabHandle=function(e){e.addClass('current').siblings().removeClass('current');tabBox.addClass('hide').eq(e.index()).removeClass('hide');},delay=function(e,t){t?setTimeout(function(){tabHandle(e);},t):tabHandle(e);},start=function(){if(!opt.auto)return;timer=setInterval(autoRun,opt.auto);},autoRun=function(){var c=items.filter('.current'),len=items.length,to=c.index()+1,item=to===len?items.eq(0):c.next(),i=to===len?0:to;c.removeClass('current');item.addClass('current');tabBox.addClass('hide').eq(i).removeClass('hide');};items.bind(opt.event,function(){var t=opt.event=='click'?0:opt.timeout;delay($(this),t);if(opt.callback)opt.callback(a);});if(opt.auto){start();a.hover(function(){clearInterval(timer);timer=undefined;},function(){start();});}return this;}});})(jQuery);
