(function(a){a.widget("ui.ringceMenu",{_init:function(){var e=this;a(this.options.menuItemSelector).unbind("click").bind("click",function(f){e.select(this)});if(window.location.hash){var d=parseInt(window.location.hash.substr(1))-1;var c=a(this.options.menuItemSelector).filter(":eq("+d+")");if(c.length!=0){e.select(c)}}else{a(this.options.childSelector+":not(:first)").hide();a(this.options.menuItemSelector+":first").addClass(this.options.selectedItemClass);var b=this.options.menuItemSelector+":first";this.select(b)}},select:function(d){if(a(d).hasClass(this.options.selectedItemClass)){return}var b=this.options.menuItemSelector+"."+this.options.selectedItemClass;var i={height:"toggle",opacity:"toggle"};var h={height:"toggle",opacity:"toggle"};var g=a(b);var c=a(d);var f=this._contentForMenuItem(g);var e=this._contentForMenuItem(c);widget=this;f.stop().animate(i,{queue:this.options.queue,easing:this.options.unselectAnimation,duration:this.options.unselectDuration,complete:function(){a(this).hide();a(b).removeClass(widget.options.selectedItemClass);a(d).addClass(widget.options.selectedItemClass);if(widget.options.unselectionHandler){widget.options.unselectionHandler(c)}}});e.stop().animate(h,{queue:this.options.queue,easing:this.options.selectAnimation,duration:this.options.selectDuration,complete:function(){a(d).addClass(widget.options.selectedItemClass);a(this).show();var j=a(widget.options.childSelector).index(e[0]);widget._setHash(j+1);a(widget.options.childSelector+":not(:eq("+j+"))").hide();if(widget.options.selectionHandler){widget.options.selectionHandler(c)}}})},_contentForMenuItem:function(c){var b=a(this.options.menuItemSelector).index(c[0]);return a(this.options.childSelector+":eq("+b+")")},_setHash:function(b){if(typeof window.location.hash!=="undefined"){if(window.location.hash!==b){window.location.hash=b}}else{if(location.hash!==b){location.hash=b}}return b}});a.extend(a.ui.ringceMenu,{defaults:{selectedItemClass:"selected",menuItemSelector:".ringceMenuItem",childSelector:".ringceMenuContent",unselectAnimation:"easeInBack",unselectDuration:500,selectAnimation:"easeInBack",selectDuration:600,selectFirst:true,queue:false,selectionHandler:null,unselectionHandler:null}})})(jQuery);
