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