LI.define("GhostLabel");
LI.GhostLabel=function(c,s){var h=YDom.get(c.htmlFor),m=h.type,j,a,g="password",b=!!("placeholder" in document.createElement("input")&&"placeholder" in document.createElement("textarea")),p="ghost-hide",l="ghost-show",e="hint",i="clone-hint",k=this;
s=s||{};
s={placeholder:(YAHOO&&YAHOO.lang&&YAHOO.lang.trim)?YAHOO.lang.trim(s.placeholder||c.firstChild.nodeValue):(s.placeholder||c.firstChild.nodeValue),showLabel:s.showLabel||false,isDefault:s.isDefault||false};
if(b){h.setAttribute("placeholder",s.placeholder)
}var t=function(){if(!b){if(s.placeholder&&h.value===""){if(m===g){if(!j){j=document.createElement("input");
j.type="text";
j.value=s.placeholder;
YDom.addClass(j,e);
YDom.addClass(j,i);
YDom.addClass(j,YDom.getAttribute(h,"class"));
j.setAttribute("tabindex",h.getAttribute("tabindex"));
YDom.insertAfter(j,h);
a=true;
YEvent.on(j,"focus",u)
}if(!a){YDom.removeClass(j,p);
YDom.removeClass(h,l)
}YDom.addClass(j,l);
YDom.addClass(h,p);
a=true
}YDom.addClass(h,e);
if(m!==g){h.value=s.placeholder
}}}};
var u=function(){if(!b){if(s.placeholder&&(m===g||h.value===s.placeholder)&&YDom.hasClass(h,e)){if(j&&m===g){if(a){YDom.removeClass(j,l);
YDom.removeClass(h,p)
}YDom.addClass(j,p);
YDom.addClass(h,l);
a=false;
h.focus()
}if(m!==g){h.value=""
}YDom.removeClass(h,e)
}}};
var d=function(){if(b){if(h.value===""){return true
}}else{if(YDom.hasClass(h,e)){return true
}}return false
};
var q=function(v){s.placeholder=v
};
var r=function(){return s.placeholder
};
var f=function(v){if(b){h.setAttribute("placeholder",s.placeholder)
}else{if(v){if(d()){h.value=s.placeholder
}}else{h.value=s.placeholder;
YDom.addClass(h,e)
}}};
var n=function(){if(s.isDefault){if(h.value===""){h.value=s.placeholder
}}else{u()
}};
var o=function(){var v=h.form;
if(!s.showLabel){LI.hide(c)
}if(!b){if(m!==g){YEvent.on(h,"focus",u)
}YEvent.on(h,"blur",t);
if(s.placeholder&&(h.value===s.placeholder)){h.value="";
YDom.removeClass(h,e)
}t()
}if(v){YEvent.on(v,"submit",n)
}if(v&&v.id&&h.id){LI.GhostLabel.Manager.register(v.id,h.id,k)
}};
o();
this.showGhostLabel=t;
this.hideGhostLabel=u;
this.setLabel=q;
this.getLabel=r;
this.updateLabel=f;
this.isGhostLabelVisible=d
};
LI.GhostLabel.Manager={registry:{},register:function(c,a,b){if(!this.registry[c]){this.registry[c]={}
}this.registry[c][a]=b
},destroy:function(b,a){if(this.registry[b][a]){delete this.registry[b][a]
}},show:function(b){if(this.registry[b]){for(var a in this.registry[b]){if(YAHOO.lang.hasOwnProperty(this.registry[b],a)){this.registry[b][a].showGhostLabel()
}}}},hide:function(b){if(this.registry[b]){for(var a in this.registry[b]){if(YAHOO.lang.hasOwnProperty(this.registry[b],a)){this.registry[b][a].hideGhostLabel()
}}}}};(function(){YEvent.onDOMReady(function(){var a=false;
YEvent.on(Y$(".btn-primary"),"click",function(b){if(a){YEvent.stopEvent(b);
return
}a=true;
YDom.addClass(this,"disabled")
})
})
})();