(function(a){a.fn.extend({getByteLength:function(d){var c,b=0;for(c=0;c<d.length;c++){if(escape(d.charAt(c)).length>=4){b+=2}else{b++}}return b}});a.fn.extend({getIndexByByte:function(e,b){var d,c=0;for(d=0;d<e.length;d++){if(escape(e.charAt(d)).length>=4){c+=2}else{c++}if(c>b){return[true,d]}}return false}});a.fn.extend({finalselect:function(j){var c={id:null,animalSpeed:100,selectWidth:"150px",selectImage:"/home/templates/images/custom_select.png",zIndex:0,viewHeight:"auto",viewWidth:"148px",viewMouseoverColor:"#cfdfff",viewTop:"18px",viewLeft:" 0px",selectedIndex:0};var f=0;if(typeof(j)!="undefined"){jQuery.extend(c,j)}var e='<div id="'+c.id+'-select" style="cursor: pointer;font-size:11px;z-index:'+c.zIndex+';border: solid 0px #999; padding: 0px; width: 150px; position: relative;">';e+='<div id="'+c.id+'-Text" style="background: url('+c.selectImage+") no-repeat 0 0; width: "+c.selectWidth+'; height: 18px; color: #333; padding: 0  0 0 5px;">';e+='<div class="textshow" style="padding: 1px 0 0 0;">'+c.selectText+'</div><div class="valueshow" style="display:none;"></div></div><div id="'+c.id+'-selectshow" style="overflow-y:hidden; overflow-x:hidden; height:'+c.viewHeight+";width:"+c.viewWidth+"; display:none; position: absolute; z-index: 999; left:"+c.viewLeft+"; top:"+c.viewTop+'; border: solid 1px #999; border-top: none; background: white;"></div></div>';var i=function(){a(this).html(e);d();g();b()};var d=function(){var k=a("#"+c.id+"-Text");a("#"+c.id+"-Text").bind("click",function(m){var l=a("#"+c.id+"-selectshow");if(l.css("display")=="none"){l.slideDown(c.animalSpeed,function(){l.show();l.css("overflow","auto");l.css("overflow-x","hidden")})}else{l.slideUp(c.animalSpeed,function(){l.hide()})}})};var h=function(){var l=0;while(a(".selectitem",a("#"+c.id+"-selectshow")).get(l)!=null){var k=a(".selectitem",a("#"+c.id+"-selectshow")).get(l);a(k).bind("mouseover",function(m){a(this).css("background-color",c.viewMouseoverColor)});a(k).bind("mouseout",function(m){a(this).css("background-color","#fff")});a(k).bind("click",function(o){var n=a(".thistext",a(this)).html();var m=a().getIndexByByte(n,16);if(m[0]==true){n=n.substring(0,m[1])+"..."}a(".textshow",a("#"+c.id+"-Text")).html(n);document.getElementById(c.id+"-selectshow").style.display="none";a(".valueshow",a("#"+c.id+"-Text")).html(a(".selectvalue",a(this)).html())});l++}};var g=function(){a("#"+c.id+"-Text").bind("mouseover",function(){a("#"+c.id+"-Text").css("background-position","0 -18px")})};var b=function(){a("#"+c.id+"-Text").bind("mouseout",function(){a("#"+c.id+"-Text").css("background-position","0 0px")})};this.setViewTop=function(k){a("#"+c.id+"-selectshow").css("top",k+"px")};this.setViewLeft=function(k){a("#"+c.id+"-selectshow").css("left",k+"px")};this.getLength=function(){return a(".selectitem",a("#"+c.id+"-selectshow")).length};this.addItem=function(m,l){var k='<div class="selectitem" style="cursor: pointer; margin: 0px; padding: 2px;"><div class="selecttext" style="width: 100%; text-align: left;">'+m+'</div><div class="selectvalue" style=" display:none;">'+l+'</div></div><div class="selectborder" style="border-bottom: solid 1px #ddd;"><div>';a("#"+c.id+"-selectshow").html(a("#"+c.id+"-selectshow").html()+k);h()};this.removeItem=function(k){if(a(".selectitem",a("#"+c.id+"-selectshow")).length>k){a(a(".selectitem",a("#"+c.id+"-selectshow")).get(k)).remove()}if(a(".selectborder",a("#"+c.id+"-selectshow")).length>k){a(a(".selectborder",a("#"+c.id+"-selectshow")).get(k)).remove()}};this.getValue=function(){return a(".valueshow",a("#"+c.id+"-Text")).html()};this.getText=function(){return a(".textshow",a("#"+c.id+"-Text")).html()};return this.each(i)}})})(jQuery);
