window.project=(window.project)?window.project:{};(function($)
{project.SelectBoxBehaviour=function(dom_element,options)
{this.dom_element=dom_element;this.is_open=false;this.options={"open_classname":"open","position_left_open":"0px","position_left_closed":"-9999px"};$.extend(this.options,options);this.initialize();};project.SelectBoxBehaviour.prototype.initialize=function()
{var that=this;var select_box_id="select_box_label_"+project.getNextIdSequence();var dropdown_box_id="dropdown_box_"+project.getNextIdSequence();this.select_box=$(this.dom_element.children(".select_box").first());this.select_box.attr({"role":"button","id":select_box_id,"aria-haspopup":true,"aria-owns":dropdown_box_id});this.dropdown_box=$(this.dom_element.children(".dropdown_box").first());this.dropdown_box.attr({"role":"listbox","id":dropdown_box_id,"aria-hidden":true,"aria-labelledby":select_box_id});this.li_elements=this.dropdown_box.children("ul").children("li");this.li_elements.attr("role","option");this.select_box.click(function()
{that.toggleDropdownBox();});this.dropdown_box.focusin(function()
{that.openDropdownBox();}).focusout(function()
{that.closeDropdownBox();});};project.SelectBoxBehaviour.prototype.openDropdownBox=function()
{this.select_box.addClass(this.options.open_classname);this.dropdown_box.css("left",this.options.position_left_open);this.dropdown_box.attr("aria-hidden",false);this.is_open=true;};project.SelectBoxBehaviour.prototype.closeDropdownBox=function()
{this.select_box.removeClass(this.options.open_classname);this.dropdown_box.css("left",this.options.position_left_closed);this.dropdown_box.attr("aria-hidden",true);this.is_open=false;};project.SelectBoxBehaviour.prototype.toggleDropdownBox=function()
{if(!this.is_open)
{this.openDropdownBox();}
else
{this.closeDropdownBox();}};JsBehaviourToolkit.registerHandler("select_box",project.SelectBoxBehaviour);})(jQuery)
