;(function($){var H=$.hint=function(txt,opts){return $(document).hint(txt,opts);},toOpts=function(t,o){if(!o&&typeof t=="object"){o=t;t=null;}
o=o||{};if(t){o.text=''+t;}
if(o.keepLabel)o.method='valueSwap';return o;};$.fn.hint=function(txt,opts){opts=toOpts(txt,opts);return this.each(function(){H.init.call(this,opts);});};$.extend(H,{version:"1.7",query:'input:password,input:text:not(._hintPw),textarea',on:'hint',toggleOnFocus:true,attr:false,inline:false,text:undefined,method:'labelOver',parentCss:{position:'relative',float:'left',clear:'left'},inlineCss:{display:'inline',float:'none'},labelCss:{position:'absolute',top:'4px',left:'5px'},getElements:function(opts){var q=opts.query||H.query,inputs=this.is(q)?this:this.find(q);return(inputs.length==0?this:inputs);},init:function(opts){var $e=$(this),meta=$.metadata,Hm=meta?$e.metadata():null;H.getElements.call($e,opts).each(function(){var $i=$(this),hm=meta?$i.metadata():null,h=$.extend(true,{},H,Hm,hm,opts);$.extend(h,h[h.method]);h.create.call($i,h);});},hasValue:function(h){var v=this.val();return(v&&$.trim(v)!='');},start:function(){var i=$(this),h=i.data('hint'),method=h.hasValue.call(i,h)?'hide':'show';h[method].call(i,h);},end:function(){var i=$(this),h=i.data('hint');if(h&&h.hasHint.call(i,h)){h.hide.call(i,h);}},getText:function(h){return h.text||this.attr(h.attr||'title');},create:function(h){if(this.data('hint'))this.data('hint').destroy.call(this);this.data('hint',h);h.setup.call(this,h);h.start.call(this);},destroy:function(){var h=this.data('hint');h.teardown.call(this,h);this.data('hint',null);},valueSwap:{setup:function(h){var self=this,text=h.getText.call(self,h);h.kill=function(){h.destroy.call(self);};if(self.is(':password')){h.password=$('<input type="text" value="'+text+'" class="_hintPw">').focus(function(){self.show().focus();}).addClass(h.on).insertBefore(self);}else if($.browser.msie&&!self.attr('defaultValue')&&self.val()==text){self.val('');}
self.blur(h.start).focus(h.end);$(window).unload(h.kill);$(this[0].form).submit(h.kill);},hide:function(h){if(h.password){h.password.hide();this.show();}else{if(h.hasHint.call(this,h))this.val('');this.removeClass(h.on);}},show:function(h){if(h.password){this.hide();h.password.show();}else{this.addClass(h.on).val(h.getText.call(this,h));}},hasHint:function(h){if(h.password)return h.password.is(':visible');return this.hasClass(h.on)&&(this.val()==h.getText.call(this,h));},teardown:function(h){h.end.call(this);if(h.password)h.password.remove();$(window).unbind('unload',h.kill);$(this[0].form).unbind('submit',h.kill);}},labelOver:{setup:function(h){var self=this,n=this.attr('name'),l=$('label[for='+n+']'),p=self.parent();if(l.size()==0){h.newLabel=true;l=$('<label for="'+n+'">'+h.getText.call(this,h)+'</label>');self.before(l);}else if(h.text||h.attr){h.labelText=l.text();l.text(h.getText.call(this,h));}
p=self.wrap('<div></div>').before(l.remove()).parent().css(h.parentCss);if(h.inline)p.css(h.inlineCss);h.labelStyle=l.attr('style')||'';h.label=l.addClass(h.on).css(h.labelCss).click(function(){self.focus();});if(h.toggleOnFocus){self.blur(h.start).focus(h.end);}else{self.keyup(h.toggle=function(){(h.hasValue.call(self,h)?h.end:h.start).call(self);});}},hide:function(h){h.label.css('textIndent',-10000);},show:function(h){h.label.css('textIndent',0);},hasHint:function(h){return h.label.css('textIndent').charAt(0)=='0';},teardown:function(h){if(h.toggleOnFocus){this.unbind('blur',h.start).unbind('focus',h.end);}else{this.unbind('keyup',h.toggle);}
h.label.removeClass(h.on).attr('style',h.labelStyle);if(h.newLabel){h.label.remove();h.label=null;}else if(h.labelText){h.label.text(h.labelText);}
var p=this.parent().after(this);if(h.label){p.before(h.label);}
p.remove();}}});})(jQuery);
