Array.prototype.indexOf=function(d,f){for(var e=(f||0);e<this.length;e++){if(this[e]==d){return e;}}};jQuery.fn.sSelect=function(b){return this.each(function(){var L={defaultText:"Please select"};var I=jQuery.extend(L,b),R=jQuery(this),K=jQuery('<div class="selectedTxt"></div>'),a=jQuery('<ul class="newList"></ul>'),E=jQuery('<div class="newListSelected" tabindex="0"></div>'),C=-1,S=-1,H=[],A=false,O="";
E.insertAfter(R);K.prependTo(E);a.appendTo(E);R.hide();if(R.children("optgroup").length==0){R.children().each(function(d){var c=jQuery(this).text();H.push(c.charAt(0).toLowerCase());if(jQuery(this).attr("selected")==true){I.defaultText=c;S=d;}O+="<li>"+c+"</li>";});a.html(O);var z=a.children();}else{R.children("optgroup").each(function(c){var f=jQuery(this).attr("label"),e=jQuery('<li class="newListOptionTitle"><span class="categoryTitle">'+f+"</span></li>");
e.appendTo(a);var d=jQuery("<ul></ul>");d.appendTo(e);jQuery(this).children().each(function(){++C;var g=jQuery(this).text();H.push(g.charAt(0).toLowerCase());if(jQuery(this).attr("selected")==true){I.defaultText=g;S=C;}O+="<li>"+g+"</li>";});d.html(O);O="";});var z=a.find("ul li");}if(S!=-1){N(S);}else{K.text(I.defaultText);
}var y=z.length;function G(){var c=E.offset().top,g=E.height()+3,e=jQuery(window).scrollTop(),d=jQuery(window).height(),f=a.height()+3;c=c-e;if(c+f>=d){a.css("top","-"+f+"px");}else{a.css("top",g+"px");}}G();jQuery(window).resize(function(c){G(c);});jQuery(window).scroll(function(c){G(c);});function D(){E.css("position","relative");
}function T(){E.css("position","static");}K.click(function(){if(a.is(":visible")){a.hide();T();return false;}E.focus();a.slideDown("fast");D();});E.blur(function(){a.hide();T();});K.hover(function(c){var d=jQuery(c.target);d.addClass("newListSelHover");},function(c){var d=jQuery(c.target);d.removeClass("newListSelHover");
});z.hover(function(c){var d=jQuery(c.target);d.addClass("newListHover");},function(c){var d=jQuery(c.target);d.removeClass("newListHover");});z.click(function(d){var e=jQuery(d.target),c=e.text();S=z.index(e);z.removeClass("hiLite");e.addClass("hiLite");M(c);a.hide();E.css("position","static");});function M(c){R.val(c).change();
K.text(c);}function F(c){c.onkeydown=function(f){if(f==null){var d=event.keyCode;}else{var d=f.which;}switch(d){case 40:case 39:B();return false;break;case 38:case 37:J();return false;break;case 33:case 36:P();return false;break;case 34:case 35:Q();return false;break;case 13:case 27:a.hide();T();return false;
break;}keyPressed=String.fromCharCode(d).toLowerCase();var e=H.indexOf(keyPressed);if(typeof e!="undefined"){f.preventDefault();++S;S=H.indexOf(keyPressed,S);if(S==-1||S==null||A!=keyPressed){S=H.indexOf(keyPressed);}N(S);A=keyPressed;}};}function B(){if(S<(y-1)){++S;N(S);}}function J(){if(S>0){--S;N(S);
}}function P(){S=0;N(S);}function Q(c){S=y-1;N(S);}function N(d){z.removeClass("hiLite").eq(d).addClass("hiLite");var c=z.eq(d).text();M(c);}E.focus(function(){F(this);});E.click(function(){F(this);});});};