var OverText=new Class({Implements:[Options,Events,Class.Occlude],Binds:["reposition","assert","focus","hide"],options:{element:"label",labelClass:"overTxtLabel",positionOptions:{position:"upperLeft",edge:"upperLeft",offset:{x:4,y:2}},poll:false,pollInterval:250,wrap:false},property:"OverText",initialize:function(element,options){element=this.element=document.id(element);if(this.occlude()){return this.occluded}this.setOptions(options);this.attach(element);OverText.instances.push(this);if(this.options.poll){this.poll()}},toElement:function(){return this.element},attach:function(){var element=this.element,options=this.options,value=options.textOverride||element.get("alt")||element.get("title");if(!value){return this}var text=this.text=new Element(options.element,{"class":options.labelClass,styles:{lineHeight:"normal",position:"absolute",cursor:"text"},html:value,events:{click:this.hide.pass(options.element=="label",this)}}).inject(element,"after");if(options.element=="label"){if(!element.get("id")){element.set("id","input_"+String.uniqueID())}text.set("for",element.get("id"))}if(options.wrap){this.textHolder=new Element("div.overTxtWrapper",{styles:{lineHeight:"normal",position:"relative"}}).grab(text).inject(element,"before")}return this.enable()},destroy:function(){this.element.eliminate(this.property);this.disable();if(this.text){this.text.destroy()}if(this.textHolder){this.textHolder.destroy()}return this},disable:function(){this.element.removeEvents({focus:this.focus,blur:this.assert,change:this.assert});window.removeEvent("resize",this.reposition);this.hide(true,true);return this},enable:function(){this.element.addEvents({focus:this.focus,blur:this.assert,change:this.assert});window.addEvent("resize",this.reposition);this.reposition();return this},wrap:function(){if(this.options.element=="label"){if(!this.element.get("id")){this.element.set("id","input_"+String.uniqueID())}this.text.set("for",this.element.get("id"))}},startPolling:function(){this.pollingPaused=false;return this.poll()},poll:function(stop){if(this.poller&&!stop){return this}if(stop){clearInterval(this.poller)}else{this.poller=(function(){if(!this.pollingPaused){this.assert(true)}}).periodical(this.options.pollInterval,this)}return this},stopPolling:function(){this.pollingPaused=true;return this.poll(true)},focus:function(){if(this.text&&(!this.text.isDisplayed()||this.element.get("disabled"))){return this}return this.hide()},hide:function(suppressFocus,force){if(this.text&&(this.text.isDisplayed()&&(!this.element.get("disabled")||force))){this.text.hide();this.fireEvent("textHide",[this.text,this.element]);this.pollingPaused=true;if(!suppressFocus){try{this.element.fireEvent("focus");this.element.focus()}catch(e){}}}return this},show:function(){if(document.id(this.text)&&!this.text.isDisplayed()){this.text.show();this.reposition();this.fireEvent("textShow",[this.text,this.element]);this.pollingPaused=false}return this},test:function(){return !this.element.get("value")},assert:function(suppressFocus){return this[this.test()?"show":"hide"](suppressFocus)},reposition:function(){this.assert(true);if(!this.element.isVisible()){return this.stopPolling().hide()}if(this.text&&this.test()){this.text.position(Object.merge(this.options.positionOptions,{relativeTo:this.element}))}return this}});OverText.instances=[];Object.append(OverText,{each:function(fn){return OverText.instances.each(function(ot,i){if(ot.element&&ot.text){fn.call(OverText,ot,i)}})},update:function(){return OverText.each(function(ot){return ot.reposition()})},hideAll:function(){return OverText.each(function(ot){return ot.hide(true,true)})},showAll:function(){return OverText.each(function(ot){return ot.show()})}});