jQuery.fn.selectbox=function(e){var s={className:"jquery-selectbox",animationSpeed:"fast",listboxMaxSize:10,replaceInvisible:!1},t="jquery-custom-selectboxes-replaced",i=!1;showList=function(e){var t=e.parents("."+s.className);return e.slideDown(s.animationSpeed,function(){i=!0}),t.addClass("selecthover"),jQuery(document).bind("click",a),e},hideList=function(e){e.parents("."+s.className);return e.slideUp(s.animationSpeed,function(){i=!1,jQuery(this).parents("."+s.className).removeClass("selecthover")}),jQuery(document).unbind("click",a),e};var a=function(e){var a=e.target,r=jQuery("."+s.className+"-list:visible").parent().find("*").andSelf();jQuery.inArray(a,r)<0&&i&&hideList(jQuery("."+t+"-list"))};return s=jQuery.extend(s,e||{}),this.each(function(){var e=jQuery(this),i="style='background-image: "+e.find("option:first").css("background-image")+"'";if(0!=e.filter(":visible").length||s.replaceInvisible){var a=jQuery("<div class='"+s.className+" "+t+" "+jQuery(this).attr("id")+"'><input type='text' class='"+s.className+"-currentItem' "+i+"/><div class='"+s.className+"-moreButton' /><div class='"+s.className+"-list "+t+"-list' /></div>");jQuery("option",e).each(function(e,t){var t=jQuery(t);if("none"==jQuery(this).css("background-image"))var i=jQuery("<span class='"+s.className+"-item item-"+e+" "+jQuery(this).attr("class")+"' rel='"+t.val()+"'>"+t.text()+"</span>");else var i=jQuery("<span class='"+s.className+"-item item-"+e+" "+jQuery(this).attr("class")+"' rel='"+t.val()+"' style='background-image: "+jQuery(this).css("background-image")+"' >"+t.text()+"</span>");i.click(function(){var e=jQuery(this),t=e.parents("."+s.className),i=e[0].className.split(" ");for(k1 in i)if(/^item-[0-9]+$/.test(i[k1])){i=parseInt(i[k1].replace("item-",""),10);break}var a=e.attr("rel");t.find("."+s.className+"-currentItem").val(e.text()),t.find("select").val(a).trigger("change");var r=t.find("."+s.className+"-list");r.filter(":visible").length>0?hideList(r):showList(r)}).bind("mouseenter",function(){jQuery(this).addClass("listelementhover")}).bind("mouseleave",function(){jQuery(this).removeClass("listelementhover")}),jQuery("."+s.className+"-list",a).append(i),t.filter(":selected").length>0&&jQuery("."+s.className+"-currentItem",a).val(t.text())}),a.find("."+s.className+"-moreButton").click(function(){var e=jQuery(this),t=jQuery("."+s.className+"-list").not(e.siblings("."+s.className+"-list"));hideList(t);var i=e.siblings("."+s.className+"-list");i.filter(":visible").length>0?hideList(i):showList(i)}).bind("mouseenter",function(){jQuery(this).addClass("morebuttonhover")}).bind("mouseleave",function(){jQuery(this).removeClass("morebuttonhover")}),e.hide().replaceWith(a).appendTo(a);var r=a.find("."+s.className+"-list"),n=r.find("."+s.className+"-item").length;n>s.listboxMaxSize&&(n=s.listboxMaxSize),0==n&&(n=1);var l=Math.round(e.width()+5);jQuery.browser.safari&&(l=.94*l),a.css("width",l+"px"),r.css({width:Math.round(l-5)+"px",height:n+"em"})}})},jQuery.fn.unselectbox=function(){var e="jquery-custom-selectboxes-replaced";return this.each(function(){var s=jQuery(this).filter("."+e);s.replaceWith(s.find("select").show())})};