(function(a){var i=[],f={};changeZIndex=function(b){b=a("#"+b);var c=b.parent();if(b.is(":visible")){c.css("z-index",f.zIndex);b.css("z-index",f.zIndex+1)}else{c.css("z-index",f.zIndex-2);b.css("z-index",f.zIndex-1)}};setText=function(b,c){var e=f.selectTextLetterCount;if(e>0&&b.length>e+1)b=b.substring(0,e-1)+"...";a("#"+getSelectId(c)+"_selected_text").text(b)};addSelectId=function(b){i[i.length]=b;return i.length-1};getSelectId=function(b){return i[b]};a.fn.customSelect=function(b){if(a(this)!=null){a(this).hide();var c=a(this).attr("id"),e=addSelectId(c),g=c+"_selected_text",j=c+"_option_list";f=b==null||b=="undefined"?a.customSelect.defaults:a.extend({},a.customSelect.defaults,b);b=f.buttonClass;var k="",d="";d+='<div class="custom_dropdown">';d+='<div class="select_box '+b+'" style="z-index:'+(f.zIndex+2)+'" onclick="$.customSelect.selectBoxClick('+e+')">';d+='<div id="'+g+'"></div>';d+="</div>";d+='<div class="list_box" id="'+j+'">';d+="<ul>";a("#"+c+" option").each(function(h){if(h==0)k=a(this).text();d+="<li onclick=\"$.customSelect.listBoxClick('"+a(this).text()+"', '"+a(this).val()+"',"+e+')">'+a(this).text()+"</li>"});d+="</ul>";d+="</div>";d+="</div>";a(this).wrap('<div class="select_container">');a(this).after(d);setText(k,e);a(".select_container").click(function(h){h.stopPropagation()});a(document).click(function(){a(".list_box").hide()});a(document).keypress(function(h){h.keyCode==27&&a(".list_box").hide()})}};a.customSelect=function(){};a.customSelect.setCustomSelectText=function(b,c){setText(b,c)};a.customSelect.listBoxClick=function(b,c,e){var g=getSelectId(e),j=g+"_option_list";a("#"+j).hide();a("#"+g+" option[value='"+c+"']").attr("selected","selected");a("#"+g).trigger("change");changeZIndex(j);setText(b,e)};a.customSelect.selectBoxClick=function(b){var c=getSelectId(b)+"_option_list";a(".list_box").each(function(){if(a(this).attr("id")!=c){a(this).hide();changeZIndex(a(this).attr("id"))}});a("#"+c).toggle();changeZIndex(c)};a.customSelect.defaults={selectTextLetterCount:9,buttonClass:"dark_button",zIndex:1E3}})(jQuery);
