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(b,a){b=this.element=document.id(b);if(this.occlude()){return this.occluded}this.setOptions(a);this.attach(b);OverText.instances.push(this);if(this.options.poll){this.poll()}},toElement:function(){return this.element},attach:function(){var b=this.element,a=this.options,c=a.textOverride||b.get("alt")||b.get("title");if(!c){return this}var d=this.text=new Element(a.element,{"class":a.labelClass,styles:{lineHeight:"normal",position:"absolute",cursor:"text"},html:c,events:{click:this.hide.pass(a.element=="label",this)}}).inject(b,"after");if(a.element=="label"){if(!b.get("id")){b.set("id","input_"+String.uniqueID())}d.set("for",b.get("id"))}if(a.wrap){this.textHolder=new Element("div.overTxtWrapper",{styles:{lineHeight:"normal",position:"relative"}}).grab(d).inject(b,"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.assert(true);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(a){if(this.poller&&!a){return this}if(a){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(c,a){if(this.text&&(this.text.isDisplayed()&&(!this.element.get("disabled")||a))){this.text.hide();this.fireEvent("textHide",[this.text,this.element]);this.pollingPaused=true;if(!c){try{this.element.fireEvent("focus");this.element.focus()}catch(b){}}}return this},show:function(){if(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(a){return this[this.test()?"show":"hide"](a)},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(a){return OverText.instances.each(function(c,b){if(c.element&&c.text){a.call(OverText,c,b)}})},update:function(){return OverText.each(function(a){return a.reposition()})},hideAll:function(){return OverText.each(function(a){return a.hide(true,true)})},showAll:function(){return OverText.each(function(a){return a.show()})}});