(function ($) { $.fn.jqtab = function(o){ var o = jquery.extend({ active: 'click' }, o); function tabto(wrapper,index){ $('.gm_tabs_head a',wrapper).removeclass('current').eq(index).addclass('current'); $('.pro_list_more',wrapper).attr("href",$('.gm_tabs_head a',wrapper).eq(index).attr("rel")); $('.gm_tabs_content',wrapper).removeclass('current').eq(index).addclass('current'); } return this.each(function (index, wrapper){ if(!wrapper._jqtab){ var theads = $('.gm_tabs_head a',wrapper).each(function(i,a){ $(a).attr('tindex',i); }); if(o.active == 'hover'){ theads.hover(function(){ tabto(wrapper,parseint($(this).attr('tindex'))); },function(){}).click(function(){ this.blur(); return false; }); }else{ theads.click(function(){ tabto(wrapper,parseint($(this).attr('tindex'))); this.blur(); return false; }); } var tcontents = $('.gm_tabs_content',wrapper).each(function(i,c){ $(c).attr('tindex',i); }); var currentindex = 0; if($('.gm_tabs_head a.current',wrapper).length > 1){ currentindex = parseint($('.gm_tabs_head a.current',wrapper).attr('tindex')); } tabto(wrapper,currentindex); wrapper.tabto = function(index){ tabto(wrapper,index); }; wrapper._jqtab = true; } }); }; })(jquery)