(function(a){if(!Array.prototype.indexOf){Array.prototype.indexOf=function(c,d){for(var b=(d||0);b<this.length;b++){if(this[b]==c){return b}}return -1}}a.fn.extend({getSetSSValue:function(b){if(b){a(this).val(b).change();return this}else{return a(this).find(":selected").val()}},resetSS:function(){var b=a(this).data("ssOpts");$this=a(this);$this.next().remove();$this.unbind(".sSelect").sSelect(b)}});a.fn.sSelect=function(b){return this.each(function(){var j={defaultText:"Please select",animationSpeed:0,ddMaxHeight:"",containerClass:""};var m=a.extend(j,b),f=a(this),k=a('<div class="selectedTxt"></div>'),s=a('<div class="newListSelected '+m.containerClass+'"></div>'),A=a('<ul class="newList" style="visibility:hidden;"></ul>'),u=-1,e=-1,n=[],x=false,w=false,y;a(this).data("ssOpts",b);s.insertAfter(f);s.attr("tabindex",f.attr("tabindex")||"0");k.prependTo(s);A.appendTo(s);f.hide();k.data("ssReRender",!k.is(":visible"));if(f.children("optgroup").length==0){f.children().each(function(C){var D=a(this).html();var B=a(this).val();n.push(D.charAt(0).toLowerCase());if(a(this).attr("selected")==true){m.defaultText=D;e=C}A.append(a('<li><a href="JavaScript:void(0);">'+D+"</a></li>").data("key",B))});y=A.children().children()}else{f.children("optgroup").each(function(){var B=a(this).attr("label"),D=a('<li class="newListOptionTitle">'+B+"</li>");D.appendTo(A);var C=a("<ul></ul>");C.appendTo(D);a(this).children().each(function(){++u;var F=a(this).html();var E=a(this).val();n.push(F.charAt(0).toLowerCase());if(a(this).attr("selected")==true){m.defaultText=F;e=u}C.append(a('<li><a href="JavaScript:void(0);">'+F+"</a></li>").data("key",E))})});y=A.find("ul li a")}var p=A.height(),o=s.height(),z=y.length;if(e!=-1){i(e,true)}else{k.text(m.defaultText)}function q(){var C=s.offset().top,B=jQuery(window).height(),D=jQuery(window).scrollTop();if(p>parseInt(m.ddMaxHeight)){p=parseInt(m.ddMaxHeight)}C=C-D;if(C+p>=B){A.css({top:"-"+p+"px",height:p});f.onTop=true}else{A.css({top:o+"px",height:p});f.onTop=false}}q();a(window).bind("resize.sSelect scroll.sSelect",q);function t(){s.css("position","relative")}function d(){s.css("position","static")}k.bind("click.sSelect",function(B){B.stopPropagation();if(a(this).data("ssReRender")){p=A.height("").height();o=s.height();a(this).data("ssReRender",false);q()}a(".newList").not(a(this).next()).hide().parent().css("position","static").removeClass("newListSelFocus");A.toggle();t();y.eq(e).focus()});function c(){A.hide();d()}y.bind("click.sSelect",function(C){var B=a(C.target);e=y.index(B);w=true;i(e);c()});y.bind("mouseenter.sSelect",function(C){var B=a(C.target);B.addClass("newListHover")}).bind("mouseleave.sSelect",function(C){var B=a(C.target);B.removeClass("newListHover")});function i(B,F){y.removeClass("hiLite").eq(B).addClass("hiLite");if(A.is(":visible")){y.eq(B).focus()}var E=y.eq(B).text();var D=y.eq(B).parent().data("key");if(F==true){f.val(D);k.text(E);return false}try{f.val(D)}catch(C){f[0].selectedIndex=B}f.change();k.text(E)}f.bind("change.sSelect",function(B){$targetInput=a(B.target);if(w==true){w=false;return false}$currentOpt=$targetInput.find(":selected");e=$targetInput.find("option").index($currentOpt);i(e,true)});function r(B){a(B).unbind("keydown.sSelect").bind("keydown.sSelect",function(E){var D=E.which;w=true;switch(D){case 40:case 39:v();return false;break;case 38:case 37:l();return false;break;case 33:case 36:h();return false;break;case 34:case 35:g();return false;break;case 13:case 27:c();return false;break}keyPressed=String.fromCharCode(D).toLowerCase();var C=n.indexOf(keyPressed);if(typeof C!="undefined"){++e;e=n.indexOf(keyPressed,e);if(e==-1||e==null||x!=keyPressed){e=n.indexOf(keyPressed)}i(e);x=keyPressed;return false}})}function v(){if(e<(z-1)){++e;i(e)}}function l(){if(e>0){--e;i(e)}}function h(){e=0;i(e)}function g(){e=z-1;i(e)}s.bind("click.sSelect",function(B){B.stopPropagation();r(this)});s.bind("focus.sSelect",function(){a(this).addClass("newListSelFocus");r(this)});s.bind("blur.sSelect",function(){a(this).removeClass("newListSelFocus")});a(document).bind("click.sSelect",function(){s.removeClass("newListSelFocus");c()});k.bind("mouseenter.sSelect",function(C){var B=a(C.target);B.parent().addClass("newListSelHover")}).bind("mouseleave.sSelect",function(C){var B=a(C.target);B.parent().removeClass("newListSelHover")});A.css({left:"0",display:"none",visibility:"visible"});setTimeout(function(){var C=0;A.show();A.find("li a").css("display","inline");A.css("overflow","auto");A.find("li a").each(function(){if(C<a(this).innerWidth()){C=a(this).innerWidth()}});A.hide();A.find("li a").css("display","block");A.find("li a").css("width",C+"px");var B=A.find("li a").outerWidth();A.find("li a").css("width","auto");if(B==0){B="auto"}A.parent().find(".selectedTxt").css("width",B)},200)})}})(jQuery);
