(function($){$.tools=$.tools||{version:'latest'};$.tools.tabs={conf:{tabs:'a',current:'current',onBeforeClick:null,onClick:null,effect:'default',initialEffect:false,initialIndex:0,event:'click',rotate:false,slideUpSpeed:400,slideDownSpeed:400,history:false},addEffect:function(a,b){j[a]=b}};var j={'default':function(i,a){this.getPanes().hide().eq(i).show();a.call()},fade:function(i,a){var b=this.getConf(),speed=b.fadeOutSpeed,panes=this.getPanes();if(speed){panes.fadeOut(speed)}else{panes.hide()}panes.eq(i).fadeIn(b.fadeInSpeed,a)},slide:function(i,a){var b=this.getConf();this.getPanes().slideUp(b.slideUpSpeed);this.getPanes().eq(i).slideDown(b.slideDownSpeed,a)},ajax:function(i,a){this.getPanes().eq(0).load(this.getTabs().eq(i).attr("href"),a)}};var k,w;$.tools.tabs.addEffect("horizontal",function(i,b){if(k)return;var c=this.getPanes().eq(i),currentPane=this.getCurrentPane();w||(w=this.getPanes().eq(0).width());k=true;c.show();currentPane.animate({width:0},{step:function(a){c.css("width",w-a)},complete:function(){$(this).hide();b.call();k=false}});if(!currentPane.length){b.call();k=false}});function Tabs(d,f,g){var h=this,trigger=d.add(this),tabs=d.find(g.tabs),panes=f.jquery?f:d.children(f),current;if(!tabs.length){tabs=d.children()}if(!panes.length){panes=d.parent().find(f)}if(!panes.length){panes=$(f)}$.extend(this,{click:function(i,e){var a=tabs.eq(i),firstRender=!d.data('tabs');if(typeof i=='string'&&i.replace("#","")){a=tabs.filter("[href*=\""+i.replace("#","")+"\"]");i=Math.max(tabs.index(a),0)}if(g.rotate){var b=tabs.length-1;if(i<0){return h.click(b,e)}if(i>b){return h.click(0,e)}}if(!a.length){if(current>=0){return h}i=g.initialIndex;a=tabs.eq(i)}if(i===current){return h}e=e||$.Event();e.type="onBeforeClick";trigger.trigger(e,[i]);if(e.isDefaultPrevented()){return}var c=firstRender?g.initialEffect&&g.effect||'default':g.effect;j[c].call(h,i,function(){current=i;e.type="onClick";trigger.trigger(e,[i])});tabs.removeClass(g.current);a.addClass(g.current);return h},getConf:function(){return g},getTabs:function(){return tabs},getPanes:function(){return panes},getCurrentPane:function(){return panes.eq(current)},getCurrentTab:function(){return tabs.eq(current)},getIndex:function(){return current},next:function(){return h.click(current+1)},prev:function(){return h.click(current-1)},destroy:function(){tabs.off(g.event).removeClass(g.current);panes.find("a[href^=\"#\"]").off("click.T");return h}});$.each("onBeforeClick,onClick".split(","),function(i,b){if($.isFunction(g[b])){$(h).on(b,g[b])}h[b]=function(a){if(a){$(h).on(b,a)}return h}});if(g.history&&$.fn.history){$.tools.history.init(tabs);g.event='history'}tabs.each(function(i){$(this).on(g.event,function(e){h.click(i,e);return e.preventDefault()})});panes.find("a[href^=\"#\"]").on("click.T",function(e){h.click($(this).attr("href"),e)});if(location.hash&&g.tabs=="a"&&d.find("[href=\""+location.hash+"\"]").length){h.click(location.hash)}else{if(g.initialIndex===0||g.initialIndex>0){h.click(g.initialIndex)}}}$.fn.tabs=function(a,b){var c=this.data("tabs");if(c){c.destroy();this.removeData("tabs")}if($.isFunction(b)){b={onBeforeClick:b}}b=$.extend({},$.tools.tabs.conf,b);this.each(function(){c=new Tabs($(this),a,b);$(this).data("tabs",c)});return b.api?c:this}})(jQuery);