(function(a,v,ea){a.fn.borderWidth=function(){return a(this).outerWidth()-a(this).innerWidth()};a.fn.paddingWidth=function(){return a(this).innerWidth()-a(this).width()};a.fn.extraWidth=function(){return a(this).outerWidth(!0)-a(this).width()};a.fn.offsetFrom=function(h){h=a(h);return{left:a(this).offset().left-h.offset().left,top:a(this).offset().top-h.offset().top}};a.fn.maxWidth=function(){var h=0;a(this).each(function(){a(this).width()>h&&(h=a(this).width())});return h};a.fn.triggerAll=function(h,
d){return a(this).each(function(){a(this).triggerHandler(h,d)})};var r=Array.prototype.slice,A=function(){return Math.floor(999999999*Math.random())};a.proto=function(h,d,b){var m=d,e={};opts=a.extend({elem:"elem",access:"access",init:"init",instantAccess:!1},b);d._super&&(e[opts.init]=function(){},m=d.extend(e));a.fn[h]=function(){var e,c=arguments;a(this).each(function(){var b=a(this),f=b.data(h),q=!f;q&&(f=new m,d._super&&(f[opts.init]=d.prototype.init),f[opts.elem]=b[0],f[opts.init]&&f[opts.init].apply(f,
opts.instantAccess?[]:r.call(c,0)),b.data(h,f));if(!q||opts.instantAccess)f[opts.access]&&f[opts.access].apply(f,r.call(c,0)),0<c.length?a.isFunction(f[c[0]])?e=f[c[0]].apply(f,r.call(c,1)):1===c.length?e=a.getObject?a.getObject(c[0],f):f[c[0]]:a.setObject?a.setObject(c[0],c[1],f):f[c[0]]=c[1]:void 0===e&&(e=b.data(h))});return void 0===e?a(this):e}};var J=function(){return!1};a.proto("sb",function(){var h=this,d={},b=null,m=null,e=null,k=null,c=null,p=null,f="",q=null,r=null,Q=null,R,B,S,T,C,w,U,
x,l,s,D,K,L,V,W,E,y,X,Y,F,G,Z,M,N,z,t,n,H,$,aa,ba,ca,I,O,u,da,P;R=function(){e=a("<div class='sb "+d.selectboxClass+" "+b.attr("class")+"' id='sb"+A()+"'></div>").attr("role","listbox").attr("aria-has-popup","true").attr("aria-labelledby",m.attr("id")?m.attr("id"):"");a("body").append(e);var g=0<b.children().size()?d.displayFormat.call(b.find("option:selected")[0],0,0):"&nbsp;";k=a("<div class='display "+b.attr("class")+"' id='sbd"+A()+"'></div>").append("<div class='text'>"+g+"</div>").append(d.arrowMarkup);
e.append(k);c=a("<ul class='"+d.selectboxClass+" items "+b.attr("class")+"' role='menu' id='sbdd"+A()+"'></ul>").attr("aria-hidden","true");e.append(c).attr("aria-owns",c.attr("id"));0===b.children().size()?c.append(B()):b.children().each(function(g){var e,b,f,k;a(this).is("optgroup")?(b=a(this),f=a("<li class='optgroup'>"+d.optgroupFormat.call(b[0],g+1)+"</li>").addClass(b.is(":disabled")?"disabled":"").attr("aria-disabled",b.is(":disabled")?"true":""),k=a("<ul class='items'></ul>"),f.append(k),
c.append(f),b.children("option").each(function(){e=B(a(this),g).addClass(b.is(":disabled")?"disabled":"").attr("aria-disabled",b.is(":disabled")?"true":"");k.append(e)})):c.append(B(a(this),g))});p=c.find("li").not(".optgroup");e.attr("aria-active-descendant",p.filter(".selected").attr("id"));c.children(":first").addClass("first");c.children(":last").addClass("last");d.fixedWidth?d.maxWidth&&e.width()>d.maxWidth&&e.width(d.maxWidth):(g=c.find(".text, .optgroup").maxWidth()+k.extraWidth()+1,e.width(d.maxWidth?
Math.min(d.maxWidth,g):g));b.before(e).addClass("has_sb").hide().show();D();da();c.hide();b.is(":disabled")?(e.addClass("disabled").attr("aria-disabled"),k.click(function(a){a.preventDefault()})):(b.bind("blur.sb",T).bind("focus.sb",S),k.mousedown(Z).mousedown(V).click(J).focus(X).blur(Y).hover(F,G),t().click(W).hover(F,G),c.find(".optgroup").hover(F,G).click(J),p.filter(".disabled").click(J),(!a.browser.msie||9<=a.browser.version)&&a(v).resize(a.throttle?a.throttle(100,K):L));e.bind("close.sb",s).bind("destroy.sb",
C);b.bind("reload.sb",w);a.fn.tie&&d.useTie&&b.bind("domupdate.sb",U)};L=function(){clearTimeout(Q);Q=setTimeout(K,50)};K=function(){e.is(".open")&&(D(),x(!0))};B=function(g,c){g||(g=a("<option value=''>&nbsp;</option>"),c=0);var b=a("<li title='"+g.attr("title")+"' id='sbo"+A()+"'></li>").attr("role","option").data("orig",g[0]).data("value",g?g.attr("value"):"").addClass(g.is(":selected")?"selected":"").addClass(g.is(":disabled")?"disabled":"").attr("aria-disabled",g.is(":disabled")?"true":""),e=
a("<div class='item'></div>"),f=a("<div class='text'></div>").html(d.optionFormat.call(g[0],0,c+1));return b.append(e.append(f))};S=function(){O();k.triggerHandler("focus")};T=function(){k.triggerHandler("blur")};C=function(g){e.remove();b.unbind(".sb").removeClass("has_sb");a(v).unbind("resize",L);g||b.removeData("sb")};w=function(){var a=e.is(".open"),c=k.is(".focused");s(!0);C(!0);h.init(d);a?(b.focus(),x(!0)):c&&b.focus()};U=function(){clearTimeout(r);r=setTimeout(w,30)};I=function(){e.removeClass("focused");
s();P()};P=function(){a(document).unbind("click",I).unbind("keyup",E).unbind("keypress",u).unbind("keydown",u).unbind("keydown",y)};O=function(){a(".sb.focused."+d.selectboxClass).not(e[0]).find(".display").blur()};ca=function(){a(".sb.open."+d.selectboxClass).not(e[0]).triggerAll("close")};s=function(a){e.is(".open")&&(k.blur(),p.removeClass("hover"),P(),c.attr("aria-hidden","true"),!0===a?(c.hide(),e.removeClass("open"),e.append(c)):c.fadeOut(d.animDuration,function(){e.removeClass("open");e.append(c)}))};
N=function(){var g=null;return g="self"===d.ddCtx?e:a.isFunction(d.ddCtx)?a(d.ddCtx.call(b[0])):a(d.ddCtx)};z=function(){return p.filter(".selected")};t=function(){return p.not(".disabled")};l=function(){c.scrollTop(c.scrollTop()+z().offsetFrom(c).top-c.height()/2+z().outerHeight(!0)/2)};da=function(){a.browser.msie&&8>a.browser.version&&a("."+d.selectboxClass+" .display").hide().show()};x=function(g){try{a("div.ContextMenuItemsContainer").css("display","none")}catch(fa){}var f;f=N();O();e.addClass("open");
f.append(c);f=D();c.attr("aria-hidden","false");!0===g?(c.show(),l()):"down"===f?c.slideDown(d.animDuration,l):c.fadeIn(d.animDuration,l);b.focus()};D=function(){var g=N(),b=0,e=k.offsetFrom(g).left,f=0,h="",m,l;c.removeClass("above");c.show().css({maxHeight:"none",position:"relative",visibility:"hidden"});d.fixedWidth||c.width(k.outerWidth()-c.extraWidth()+1);b=a(v).scrollTop()+a(v).height()-k.offset().top-k.outerHeight();h=k.offset().top-a(v).scrollTop();f=k.offsetFrom(g).top+k.outerHeight();l=
b-h+d.dropupThreshold;c.outerHeight()<b?(b=d.maxHeight?d.maxHeight:b,h="down"):c.outerHeight()<h?(b=d.maxHeight?d.maxHeight:h,f=k.offsetFrom(g).top-Math.min(b,c.outerHeight()),h="up"):0<=l?(b=d.maxHeight?d.maxHeight:b,h="down"):0>l?(b=d.maxHeight?d.maxHeight:h,f=k.offsetFrom(g).top-Math.min(b,c.outerHeight()),h="up"):(b=d.maxHeight?d.maxHeight:"none",h="down");m=(""+a("body").css("margin-left")).match(/^\d+/)?a("body").css("margin-left"):0;l=(""+a("body").css("margin-top")).match(/^\d+/)?a("body").css("margin-top"):
0;m="1.4.2"<=a().jquery?parseInt(m):a("body").offset().left;l="1.4.2"<=a().jquery?parseInt(l):a("body").offset().top;c.hide().css({left:e+(g.is("body")?m:0),maxHeight:b,position:"absolute",top:f+(g.is("body")?l:0),visibility:"visible"});"up"===h&&c.addClass("above");return h};V=function(a){e.is(".open")?s():x();return!1};n=function(){var g=a(this),c=b.val(),f=g.data("value");d.useTie&&a.fn.tie?(b.find("option").old_removeAttr("selected"),a(g.data("orig")).old_attr("selected","selected")):(b.find("option").removeAttr("selected"),
a(g.data("orig")).attr("selected","selected"));t().removeClass("selected");g.addClass("selected");e.attr("aria-active-descendant",g.attr("id"));k.find(".text").attr("title",g.find(".text").html());k.find(".text").html(d.displayFormat.call(g.data("orig")));c!==f&&b.change()};W=function(a){n.call(this);I();b.focus();return!1};H=function(){f=""};$=function(a){var b,c,d=t();for(b=0;b<d.size();b++)if(c=d.eq(b).find(".text"),c=0==c.children().size()?c.text():c.find("*").text(),0<a.length&&c.toLowerCase().match("^"+
a.toLowerCase()))return d.eq(b);return null};aa=function(a){a=$(a);return null!==a?(n.call(a[0]),!0):!1};u=function(a){a.ctrlKey||a.altKey||38!==a.which&&40!==a.which&&8!==a.which&&32!==a.which||a.preventDefault()};ba=function(a){var b,c;b=z();var d=t();for(b=d.index(b)+1;b<d.size();b++)if(c=d.eq(b).find(".text").text(),""!==c&&c.substring(0,1).toLowerCase()===a.toLowerCase())return n.call(d.eq(b)[0]),!0;return!1};y=function(a){if(a.altKey||a.ctrlKey)return!1;var b=z(),c=t();switch(a.which){case 35:0<
b.size()&&(a.preventDefault(),n.call(c.filter(":last")[0]),l());break;case 36:0<b.size()&&(a.preventDefault(),n.call(c.filter(":first")[0]),l());break;case 38:0<b.size()&&(c.filter(":first")[0]!==b[0]&&(a.preventDefault(),n.call(c.eq(c.index(b)-1)[0])),l());break;case 40:0<b.size()?c.filter(":last")[0]!==b[0]&&(a.preventDefault(),n.call(c.eq(c.index(b)+1)[0]),l()):1<p.size()&&(a.preventDefault(),n.call(p.eq(0)[0]))}};E=function(a){if(a.altKey||a.ctrlKey)return!1;38!==a.which&&40!==a.which&&(f+=String.fromCharCode(a.keyCode),
aa(f)?(clearTimeout(q),q=setTimeout(H,d.acTimeout)):ba(String.fromCharCode(a.keyCode))?(l(),clearTimeout(q),q=setTimeout(H,d.acTimeout)):(H(),clearTimeout(q)))};X=function(){ca();e.addClass("focused");a(document).click(I).keyup(E).keypress(u).keydown(u).keydown(y).keydown(y)};Y=function(){e.removeClass("focused");a(document).unbind("keyup",E).unbind("keydown",u).unbind("keydown",y)};F=function(){a(this).addClass("hover")};G=function(){a(this).removeClass("hover")};Z=function(){k.addClass("active");
a(document).bind("mouseup",M)};M=function(){k.removeClass("active");a(document).unbind("mouseup",M)};this.init=function(c){a.browser.msie&&7>a.browser.version||(b=a(this.elem),b.attr("id")&&(m=a("label[for='"+b.attr("id")+"']:first")),m&&0!==m.size()||(m=b.closest("label")),b.hasClass("has_sb")||(d=a.extend({acTimeout:800,animDuration:200,ddCtx:"body",dropupThreshold:150,fixedWidth:!1,maxHeight:!1,maxWidth:!1,selectboxClass:"selectbox",useTie:!1,arrowMarkup:"<div class='arrow_btn'><span class='arrow'></span></div>",
displayFormat:ea,optionFormat:function(b,c){if(0<a(this).size()){var d=a(this).attr("label");return d&&0<d.length?d:a(this).text()}return""},optgroupFormat:function(b){return"<span class='label'>"+a(this).attr("label")+"</span>"}},c),d.displayFormat=d.displayFormat||d.optionFormat,R()))};this.open=x;this.close=s;this.refresh=w;this.destroy=C;this.options=function(b){d=a.extend(d,b);w()}})})(jQuery,window);
