/* stylish select 0.4.1 - $ plugin to replace a select drop down box with a stylable unordered list http://github.com/sko77sun/stylish-select requires: jquery 1.3 or newer contributions from justin beasley: http://www.harvest.org/ & anatoly ressin: http://www.artazor.lv/ dual licensed under the mit and gpl licenses. */ (function(a){a("html").addclass("stylish-select");array.prototype.indexof=function(c,d){for(var b=(d||0);b'),r=a('
'),z=a(''),t=-1,d=-1,m=[],w=false,v=false,x;a(this).data("ssopts",b);r.insertafter(e);r.attr("tabindex",e.attr("tabindex")||"0");j.prependto(r);z.appendto(r);e.hide();j.data("ssrerender",!j.is(":visible"));if(e.children("optgroup").length==0){e.children().each(function(b){var c=a(this).html();var a=a(this).val();m.push(c.charat(0).tolowercase());if(a(this).attr("selected")=="selected"){l.defaulttext=c;d=b}z.append(a('
  • '+c+"
  • ").data("key",a))});x=z.children().children()}else{e.children("optgroup").each(function(){var a=a(this).attr("label"),c=a('
  • '+a+"
  • ");c.appendto(z);var b=a("");b.appendto(c);a(this).children().each(function(){++t;var e=a(this).html();var d=a(this).val();m.push(e.charat(0).tolowercase());if(a(this).attr("selected")==true){l.defaulttext=e;d=t}b.append(a('
  • '+e+"
  • ").data("key",d))})});x=z.find("ul li a")}var o=z.height(),n=r.height(),y=x.length;if(d!=-1){h(d,true)}else{j.text(l.defaulttext)}function p(){var b=r.offset().top,a=jquery(window).height(),c=jquery(window).scrolltop();if(o>parseint(l.ddmaxheight)){o=parseint(l.ddmaxheight)}b=b-c;if(b+o>=a){z.css({top:"-"+o+"px",height:o});e.ontop=true}else{z.css({top:n+"px",height:o});e.ontop=false}}p();a(window).bind("resize.sselect scroll.sselect",p);function s(){r.css("position","relative")}function c(){r.css("position","static")}j.bind("click.sselect",function(a){a.stoppropagation();if(a(this).data("ssrerender")){o=z.height("").height();n=r.height();a(this).data("ssrerender",false);p()}a(".newlist").not(a(this).next()).hide().parent().css("position","static").removeclass("newlistselfocus");z.toggle();s();x.eq(d).focus()});x.bind("click.sselect",function(b){var a=a(b.target);d=x.index(a);v=true;h(d);z.hide();r.css("position","static")});x.bind("mouseenter.sselect",function(b){var a=a(b.target);a.addclass("newlisthover")}).bind("mouseleave.sselect",function(b){var a=a(b.target);a.removeclass("newlisthover")});function h(a,e){x.removeclass("hilite").eq(a).addclass("hilite");if(z.is(":visible")){x.eq(a).focus()}var d=x.eq(a).html();var c=x.eq(a).parent().data("key");if(e==true){e.val(c);j.text(d);return false}try{e.val(c)}catch(b){e[0].selectedindex=a}e.change();j.text(d)}e.bind("change.sselect",function(a){$targetinput=a(a.target);if(v==true){v=false;return false}$currentopt=$targetinput.find(":selected");d=$targetinput.find("option").index($currentopt);h(d,true)});function q(a){a(a).unbind("keydown.sselect").bind("keydown.sselect",function(d){var c=d.which;v=true;switch(c){case 40:case 39:u();return false;break;case 38:case 37:k();return false;break;case 33:case 36:g();return false;break;case 34:case 35:f();return false;break;case 13:case 27:z.hide();c();return false;break}keypressed=string.fromcharcode(c).tolowercase();var b=m.indexof(keypressed);if(typeof b!="undefined"){++d;d=m.indexof(keypressed,d);if(d==-1||d==null||w!=keypressed){d=m.indexof(keypressed)}h(d);w=keypressed;return false}})}function u(){if(d<(y-1)){++d;h(d)}}function k(){if(d>0){--d;h(d)}}function g(){d=0;h(d)}function f(){d=y-1;h(d)}r.bind("click.sselect",function(a){a.stoppropagation();q(this)});r.bind("focus.sselect",function(){a(this).addclass("newlistselfocus");q(this)});r.bind("blur.sselect",function(){a(this).removeclass("newlistselfocus")});a(document).bind("click.sselect",function(){r.removeclass("newlistselfocus");z.hide();c()});j.bind("mouseenter.sselect",function(b){var a=a(b.target);a.parent().addclass("newlistselhover")}).bind("mouseleave.sselect",function(b){var a=a(b.target);a.parent().removeclass("newlistselhover")});z.css({left:"0",display:"none",visibility:"visible"})})}})(jquery);