/*
 * jQuery UI Tabs 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Tabs
 *
 * Depends:
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 */

(function(d){var n=0,o=0;d.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:!1,cookie:null,collapsible:!1,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"<div></div>",remove:null,select:null,show:null,spinner:"<em>Loading&#8230;</em>",tabTemplate:'<li><a href="#{href}"><span>#{label}</span></a></li>'},_create:function(){this._tabify(!0)},_setOption:function(a,d){a=="selected"?this.options.collapsible&&d==this.options.selected||this.select(d):
(this.options[a]=d,this._tabify())},_tabId:function(a){return a.title&&a.title.replace(/\s/g,"_").replace(/[^A-Za-z0-9\-_:\.]/g,"")||this.options.idPrefix+ ++n},_sanitizeSelector:function(a){return a.replace(/:/g,"\\:")},_cookie:function(){var a=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+ ++o);return d.cookie.apply(null,[a].concat(d.makeArray(arguments)))},_ui:function(a,d){return{tab:a,panel:d,index:this.anchors.index(a)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var a=
d(this);a.html(a.data("label.tabs")).removeData("label.tabs")})},_tabify:function(a){function e(c,b){c.css({display:""});!d.support.opacity&&b.opacity&&c[0].style.removeAttribute("filter")}this.list=this.element.find("ol,ul").eq(0);this.lis=d("li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);var c=this,b=this.options,g=/^#.+/;this.anchors.each(function(a,e){var h=d(e).attr("href"),f=h.split("#")[0],k;if(f&&(f===location.toString().split("#")[0]||
(k=d("base")[0])&&f===k.href))h=e.hash,e.href=h;g.test(h)?c.panels=c.panels.add(c._sanitizeSelector(h)):h!="#"?(d.data(e,"href.tabs",h),d.data(e,"load.tabs",h.replace(/#.*$/,"")),h=c._tabId(e),e.href="#"+h,f=d("#"+h),f.length||(f=d(b.panelTemplate).attr("id",h).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(c.panels[a-1]||c.list),f.data("destroy.tabs",!0)),c.panels=c.panels.add(f)):b.disabled.push(a)});if(a){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");
this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(b.selected===void 0){location.hash&&this.anchors.each(function(c,a){if(a.hash==location.hash)return b.selected=c,!1});if(typeof b.selected!="number"&&b.cookie)b.selected=parseInt(c._cookie(),10);if(typeof b.selected!="number"&&this.lis.filter(".ui-tabs-selected").length)b.selected=
this.lis.index(this.lis.filter(".ui-tabs-selected"));b.selected=b.selected||(this.lis.length?0:-1)}else if(b.selected===null)b.selected=-1;b.selected=b.selected>=0&&this.anchors[b.selected]||b.selected<0?b.selected:0;b.disabled=d.unique(b.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(b){return c.lis.index(b)}))).sort();d.inArray(b.selected,b.disabled)!=-1&&b.disabled.splice(d.inArray(b.selected,b.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");
b.selected>=0&&this.anchors.length&&(this.panels.eq(b.selected).removeClass("ui-tabs-hide"),this.lis.eq(b.selected).addClass("ui-tabs-selected ui-state-active"),c.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[b.selected],c.panels[b.selected]))}),this.load(b.selected));d(window).bind("unload",function(){c.lis.add(c.anchors).unbind(".tabs");c.lis=c.anchors=c.panels=null})}else b.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"));this.element[b.collapsible?"addClass":
"removeClass"]("ui-tabs-collapsible");b.cookie&&this._cookie(b.selected,b.cookie);for(var a=0,f;f=this.lis[a];a++)d(f)[d.inArray(a,b.disabled)!=-1&&!d(f).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");b.cache===!1&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(b.event!="mouseover"){var k=function(c,b){b.is(":not(.ui-state-disabled)")&&b.addClass("ui-state-"+c)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",
function(){d(this).removeClass("ui-state-hover")});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){d(this).closest("li").removeClass("ui-state-focus")})}var j,i;if(b.fx)d.isArray(b.fx)?(j=b.fx[0],i=b.fx[1]):j=i=b.fx;var l=i?function(b,a){d(b).closest("li").addClass("ui-tabs-selected ui-state-active");a.hide().removeClass("ui-tabs-hide").animate(i,i.duration||"normal",function(){e(a,i);c._trigger("show",null,c._ui(b,a[0]))})}:function(b,
a){d(b).closest("li").addClass("ui-tabs-selected ui-state-active");a.removeClass("ui-tabs-hide");c._trigger("show",null,c._ui(b,a[0]))},m=j?function(b,a){a.animate(j,j.duration||"normal",function(){c.lis.removeClass("ui-tabs-selected ui-state-active");a.addClass("ui-tabs-hide");e(a,j);c.element.dequeue("tabs")})}:function(b,a){c.lis.removeClass("ui-tabs-selected ui-state-active");a.addClass("ui-tabs-hide");c.element.dequeue("tabs")};this.anchors.bind(b.event+".tabs",function(){var a=this,e=d(this).closest("li"),
f=c.panels.filter(":not(.ui-tabs-hide)"),g=d(c._sanitizeSelector(this.hash));if(e.hasClass("ui-tabs-selected")&&!b.collapsible||e.hasClass("ui-state-disabled")||e.hasClass("ui-state-processing")||c._trigger("select",null,c._ui(this,g[0]))===!1)return this.blur(),!1;b.selected=c.anchors.index(this);c.abort();if(b.collapsible)if(e.hasClass("ui-tabs-selected"))return b.selected=-1,b.cookie&&c._cookie(b.selected,b.cookie),c.element.queue("tabs",function(){m(a,f)}).dequeue("tabs"),this.blur(),!1;else if(!f.length)return b.cookie&&
c._cookie(b.selected,b.cookie),c.element.queue("tabs",function(){l(a,g)}),c.load(c.anchors.index(this)),this.blur(),!1;b.cookie&&c._cookie(b.selected,b.cookie);if(g.length)f.length&&c.element.queue("tabs",function(){m(a,f)}),c.element.queue("tabs",function(){l(a,g)}),c.load(c.anchors.index(this));else throw"jQuery UI Tabs: Mismatching fragment identifier.";d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return!1})},destroy:function(){var a=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");
this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var a=d.data(this,"href.tabs");if(a)this.href=a;var c=d(this).unbind(".tabs");d.each(["href","load","cache"],function(a,d){c.removeData(d+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});
a.cookie&&this._cookie(null,a.cookie);return this},add:function(a,e,c){if(c===void 0)c=this.anchors.length;var b=this,g=this.options,e=d(g.tabTemplate.replace(/#\{href\}/g,a).replace(/#\{label\}/g,e)),a=!a.indexOf("#")?a.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",!0);var f=d("#"+a);f.length||(f=d(g.panelTemplate).attr("id",a).data("destroy.tabs",!0));f.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");c>=this.lis.length?
(e.appendTo(this.list),f.appendTo(this.list[0].parentNode)):(e.insertBefore(this.lis[c]),f.insertBefore(this.panels[c]));g.disabled=d.map(g.disabled,function(a){return a>=c?++a:a});this._tabify();if(this.anchors.length==1)g.selected=0,e.addClass("ui-tabs-selected ui-state-active"),f.removeClass("ui-tabs-hide"),this.element.queue("tabs",function(){b._trigger("show",null,b._ui(b.anchors[0],b.panels[0]))}),this.load(0);this._trigger("add",null,this._ui(this.anchors[c],this.panels[c]));return this},remove:function(a){var e=
this.options,c=this.lis.eq(a).remove(),b=this.panels.eq(a).remove();c.hasClass("ui-tabs-selected")&&this.anchors.length>1&&this.select(a+(a+1<this.anchors.length?1:-1));e.disabled=d.map(d.grep(e.disabled,function(b){return b!=a}),function(b){return b>=a?--b:b});this._tabify();this._trigger("remove",null,this._ui(c.find("a")[0],b[0]));return this},enable:function(a){var e=this.options;if(d.inArray(a,e.disabled)!=-1)return this.lis.eq(a).removeClass("ui-state-disabled"),e.disabled=d.grep(e.disabled,
function(c){return c!=a}),this._trigger("enable",null,this._ui(this.anchors[a],this.panels[a])),this},disable:function(a){var d=this.options;a!=d.selected&&(this.lis.eq(a).addClass("ui-state-disabled"),d.disabled.push(a),d.disabled.sort(),this._trigger("disable",null,this._ui(this.anchors[a],this.panels[a])));return this},select:function(a){typeof a=="string"?a=this.anchors.index(this.anchors.filter("[href$="+a+"]")):a===null&&(a=-1);if(a==-1&&this.options.collapsible)a=this.options.selected;this.anchors.eq(a).trigger(this.options.event+
".tabs");return this},load:function(a){var e=this,c=this.options,b=this.anchors.eq(a)[0],g=d.data(b,"load.tabs");this.abort();if(!g||this.element.queue("tabs").length!==0&&d.data(b,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(a).addClass("ui-state-processing");if(c.spinner){var f=d("span",b);f.data("label.tabs",f.html()).html(c.spinner)}this.xhr=d.ajax(d.extend({},c.ajaxOptions,{url:g,success:function(f,g){d(e._sanitizeSelector(b.hash)).html(f);e._cleanup();c.cache&&d.data(b,"cache.tabs",
!0);e._trigger("load",null,e._ui(e.anchors[a],e.panels[a]));try{c.ajaxOptions.success(f,g)}catch(i){}},error:function(d,f){e._cleanup();e._trigger("load",null,e._ui(e.anchors[a],e.panels[a]));try{c.ajaxOptions.error(d,f,a,b)}catch(g){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(!1,!0);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));this.xhr&&(this.xhr.abort(),delete this.xhr);this._cleanup();return this},url:function(a,d){this.anchors.eq(a).removeData("cache.tabs").data("load.tabs",
d);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.1"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(a,d){var c=this,b=this.options,g=c._rotate||(c._rotate=function(d){clearTimeout(c.rotation);c.rotation=setTimeout(function(){var a=b.selected;c.select(++a<c.anchors.length?a:0)},a);d&&d.stopPropagation()}),f=c._unrotate||(c._unrotate=!d?function(a){a.clientX&&c.rotate(null)}:function(){t=b.selected;g()});a?(this.element.bind("tabsshow",g),
this.anchors.bind(b.event+".tabs",f),g()):(clearTimeout(c.rotation),this.element.unbind("tabsshow",g),this.anchors.unbind(b.event+".tabs",f),delete this._rotate,delete this._unrotate);return this}})})(jQuery);
