var SelectoMoo=new Class({Implements:[Options],options:{element:null,css:"selectoMoo",listHeight:220},initialize:function(A){this.setOptions(A);this.visible=0;this.selBox=$(this.options.element);this.selBoxContainer=new Element("div",{styles:{opacity:0.00001,position:"absolute",top:-5000}});this.opt=this.selBox.getElements("option");this.currentOption=0;this.selectedOption=new Element("div",{"class":this.options.css+"_selectedOption"});this.container=new Element("div",{"class":this.options.css+"_container",events:{click:function(B){B.stopPropagation();this.selBox.focus();this.showList()}.bind(this)},styles:{overflow:"hidden"}}).injectAfter(this.selBox).adopt(this.selBoxContainer.adopt(this.selBox),this.selectedOption);this.outerOptContainer=new Element("div",{"class":this.options.css+"_options",styles:{opacity:0,height:this.options.listHeight,top:0},events:{click:function(B){B.stopPropagation()}.bind(this),mousewheel:function(C){new Event(C).stop();var B=this.currentOption-C.wheel;if(C.wheel>0&&B<0){B=0}if(C.wheel<0&&B>=this.totalOptions-1){B=this.totalOptions-1}this.scrollFx.toElement(this.fakeOptions[B]);this.fakeOptions[this.currentOption].removeClass(this.options.css+"_naved");this.fakeOptions[B].addClass(this.options.css+"_naved");this.currentOption=B}.bind(this)}}).injectInside(this.container);this.optContainer=new Element("div",{"class":this.options.css+"_options_inner"}).injectInside(this.outerOptContainer);this.outerOptContainer.set("morph",{duration:300,transition:"back:out",wait:false});this.scrollFx=new Fx.Scroll(this.outerOptContainer,{wait:false,duration:300,wheelStops:false,transition:Fx.Transitions.Sine.easeOut});$(document).getElement("label[for="+this.options.element+"]").addEvent("click",function(B){B.stopPropagation();new Event(B).stop();if(this.visible){}else{this.selBox.focus();this.showList()}}.bind(this));this.addOptions();this.totalOptions=this.fakeOptions.length;$(document).addEvent("click",function(B){if(this.visible){}}.bind(this));this.selBox.addEvents({focus:function(B){if(this.visible){return}this.showList()}.bind(this),blur:function(B){if(!this.visible){return}}.bind(this),keydown:function(B){if(B.key=="enter"){this.fakeOptions[this.currentOption].fireEvent("click");return}if(B.key!=="up"&&B.key!=="down"){return}var D=B.key=="up"?-1:1;var C=this.currentOption+D;if(B.key=="up"&&C<0){C=0}if(B.key=="down"&&C>=this.totalOptions-1){C=this.totalOptions-1}this.scrollFx.toElement(this.fakeOptions[C]);this.fakeOptions[this.currentOption].removeClass(this.options.css+"_naved");this.fakeOptions[C].addClass(this.options.css+"_naved");this.currentOption=C}.bind(this),mousewheel:function(C){new Event(C).stop();var B=this.currentOption-C.wheel;if(C.wheel>0&&B<0){B=0}if(C.wheel<0&&B>=this.totalOptions-1){B=this.totalOptions-1}this.scrollFx.toElement(this.fakeOptions[B]);this.fakeOptions[this.currentOption].removeClass(this.options.css+"_naved");this.fakeOptions[B].addClass(this.options.css+"_naved");this.currentOption=B}.bind(this)})},addOptions:function(){this.fakeOptions=new Array();this.opt.each(function(C,A){if(C.selected==true){this.selectedOption.set({text:C.get("text")})}if(C.get("value")!==""){var B=new Element("div",{"class":this.options.css+"_option"+(C.selected==true?" "+this.options.css+"_selected":""),text:C.get("text"),events:{click:function(D){if(D){D.stopPropagation()}/*console.log(A + ' ' + C.get('text'));*/ this.setOption(A,C.get("text"))}.bind(this),mouseenter:function(){B.addClass(this.options.css+"_hovered")}.bind(this),mouseleave:function(){B.removeClass(this.options.css+"_hovered")}.bind(this)}}).injectInside(this.optContainer);this.fakeOptions.include(B);if(C.selected==true){this.currentOption=this.fakeOptions.indexOf(B)}this.opt[A]["fakeOption"]=B}}.bind(this))},showList:function(){if(!Browser.Engine.trident){this.selBox.focus()}if(this.visible==1){return}this.visible=1;this.container.setStyle("overflow","visible");this.outerOptContainer.morph({height:[0,this.options.listHeight],opacity:[0.5,1],top:-this.options.listHeight/2});this.scrollFx.toElement(this.fakeOptions[this.currentOption])},hideList:function(){if(this.visible==0){return}this.visible=0;this.outerOptContainer.morph({height:30,opacity:0,top:0});this.container.setStyle("overflow","hidden");this.selBox.blur()},setOption:function(A,B){this.opt.each(function(D,C){if(D.selected==true){D.selected=false}if(C==A){D.set({selected:true})}}.bind(this));$$("."+this.options.css+"_selected").removeClass(this.options.css+"_selected");this.opt[A]["fakeOption"].addClass(this.options.css+"_selected");this.selectedOption.set({text:B});this.hideList()}});

window.addEvent('domready', function(){
    if ('undefined' == typeof(selectManualOverride)) {
        new SelectoMoo({
            element: 'category'
        });
    }
})
