
var ReplaceSelect=Class.create({initialize:function(selectId){this.selectId=selectId;this.select=$(this.selectId);this.create();},create:function(){this.wrapper=new Element('span',{'class':'select-replaced-wrapper','id':this.selectId+'-wrapper'}).setStyle({'display':'inline-block','width':$(this.selectId).getWidth()+'px','height':$(this.selectId).getHeight()+'px','position':'relative','z-index':'1','verticalAlign':'middle'});this.replacer=new Element('span',{'class':'select-replaced','id':this.selectId+'-replaced'}).setStyle({'width':'100%','height':'100%','position':'absolute','top':0,'bottom':0,'overflow':'hidden'}).update(this.select.options[this.select.selectedIndex].innerHTML.strip());this.select.setOpacity(0).setStyle({'cursor':'pointer','position':'relative'}).observe('change',this.onchange.bindAsEventListener(this)).observe('focus',this.onfocus.bindAsEventListener(this)).observe('blur',this.onblur.bindAsEventListener(this)).observe('keyup',this.onkeyup.bindAsEventListener(this)).wrap(this.wrapper).insert({'top':this.replacer});},onchange:function(e){var select=Event.element(e);$(this.selectId+'-replaced').update(select.options[select.selectedIndex].innerHTML.strip());},onfocus:function(e){var select=Event.element(e);$(this.selectId+'-replaced').addClassName('focused');},onblur:function(){$(this.selectId+'-replaced').removeClassName('focused');},onkeyup:function(e){if(!Prototype.Browser.IE){var select=Event.element(e);select.blur();select.focus();}}});
