(function(b,k,m){rreturn=/\r/g;selWatermarkDefined="input:data(watermark),textarea:data(watermark)";selWatermarkAble="input:text,input:password,input[type=search],input:not([type]),textarea";triggerFns=["Page_ClientValidate"];pageDirty=!1;hasNativePlaceholder="placeholder"in document.createElement("input");b.watermark=b.watermark||{version:"3.1.3",runOnce:!0,options:{className:"watermark",useNative:!0,hideBeforeUnload:!0},hide:function(a){b(a).filter(selWatermarkDefined).each(function(){b.watermark._hide(b(this))})},
_hide:function(a,b){var e=a[0],f=(e.value||"").replace(rreturn,""),c=a.data("watermarkText")||"",h=a.data("watermarkMaxLength")||0,g=a.data("watermarkClass");c.length&&f==c&&!a.data("watermarkSameValue")&&(e.value="",a.data("watermarkPassword")&&"text"===(a.attr("type")||"")&&(e=a.data("watermarkPassword")||[],f=a.parent()||[],e.length&&f.length&&(f[0].removeChild(a[0]),f[0].appendChild(e[0]),a=e)),h&&(a.attr("maxLength",h),a.removeData("watermarkMaxLength")),b&&(a.attr("autocomplete","off"),k.setTimeout(function(){a.select()},
1)));g&&a.removeClass(g)},show:function(a){b(a).filter(selWatermarkDefined).each(function(){b.watermark._show(b(this))})},_show:function(a){var d=a[0],e=(d.value||"").replace(rreturn,""),f=a.data("watermarkText")||"",c=a.attr("type")||"",h=a.data("watermarkClass");if(0!=e.length&&e!=f||a.data("watermarkFocus")||a.data("watermarkSameValue"))b.watermark._hide(a);else{pageDirty=!0;if(a.data("watermarkPassword")&&"password"===c){var e=a.data("watermarkPassword")||[],g=a.parent()||[];e.length&&g.length&&
(g[0].removeChild(a[0]),g[0].appendChild(e[0]),a=e,a.attr("maxLength",f.length),d=a[0])}if("text"===c||"search"===c)c=a.attr("maxLength")||0,0<c&&f.length>c&&(a.data("watermarkMaxLength",c),a.attr("maxLength",f.length));h&&a.addClass(h);d.value=f}},hideAll:function(){pageDirty&&(b.watermark.hide(selWatermarkAble),pageDirty=!1)},showAll:function(){b.watermark.show(selWatermarkAble)},checkValue:function(a){b(a).filter(selWatermarkDefined).each(function(){b.watermark._checkValue(b(this))})},_checkValue:function(a){var b=
(a[0].value||"").replace(rreturn,""),e=a.data("watermarkText")||"";b==e?a.data("watermarkSameValue",1):a.data("watermarkSameValue",0)}};b.fn.watermark=b.fn.watermark||function(a,d){if(!this.length)return this;var e=!1,f="string"===typeof a;f&&(a=a.replace(rreturn,""));"object"===typeof d?(e="string"===typeof d.className,d=b.extend({},b.watermark.options,d)):"string"===typeof d?(e=!0,d=b.extend({},b.watermark.options,{className:d})):d=b.watermark.options;"function"!==typeof d.useNative&&(d.useNative=
d.useNative?function(){return!0}:function(){return!1});return this.each(function(){var c=b(this);if(c.is(selWatermarkAble)){if(c.data("watermark")){if(f||e)b.watermark._hide(c),f&&c.data("watermarkText",a),e&&c.data("watermarkClass",d.className)}else{if(hasNativePlaceholder&&d.useNative.call(this,c)&&"TEXTAREA"!==(c.attr("tagName")||"")){f&&c.attr("placeholder",a);return}c.data("watermarkText",f?a:"");c.data("watermarkClass",d.className);c.data("watermark",1);if("password"===(c.attr("type")||"")){var h=
c.wrap("<span>").parent(),g=b(h.html().replace(/type=["']?password["']?/i,'type="text"'));g.data("watermarkText",c.data("watermarkText"));g.data("watermarkClass",c.data("watermarkClass"));g.data("watermark",1);g.attr("maxLength",a.length);g.focus(function(){b.watermark._hide(g,!0)}).bind("dragenter",function(){b.watermark._hide(g)}).bind("dragend",function(){k.setTimeout(function(){g.blur()},1)});c.blur(function(){b.watermark._checkValue(c);b.watermark._show(c)}).bind("dragleave",function(a){b.watermark._show(c)}).bind("paste",
function(a){k.setTimeout(function(){b.watermark._checkValue(c)},1)});g.data("watermarkPassword",c);c.data("watermarkPassword",g)}else c.focus(function(){c.data("watermarkFocus",1);b.watermark._hide(c,!0)}).blur(function(){c.data("watermarkFocus",0);b.watermark._checkValue(c);b.watermark._show(c)}).bind("dragenter",function(){b.watermark._hide(c)}).bind("dragleave",function(){b.watermark._show(c)}).bind("dragend",function(){k.setTimeout(function(){b.watermark._show(c)},1)}).bind("drop",function(a){var d=
c[0];a=a.originalEvent.dataTransfer.getData("Text");(d.value||"").replace(rreturn,"").replace(a,"")===c.data("watermarkText")&&(d.value=a,b.watermark._checkValue(c),c.change());c.focus()}).bind("paste",function(a){k.setTimeout(function(){b.watermark._checkValue(c)},1)});if(this.form){var h=this.form,l=b(h);l.data("watermarkSubmit")||(l.submit(b.watermark.hideAll),h.submit?(l.data("watermarkSubmit",h.submit),h.submit=function(a,c){return function(){var d=c.data("watermarkSubmit");b.watermark.hideAll();
d.apply?d.apply(a,Array.prototype.slice.call(arguments)):d()}}(h,l)):(l.data("watermarkSubmit",1),h.submit=function(a){return function(){b.watermark.hideAll();delete a.submit;a.submit()}}(h)))}}b.watermark._checkValue(c);b.watermark._show(c)}})};b.watermark.runOnce&&(b.watermark.runOnce=!1,b.extend(b.expr[":"],{data:function(a,d,e){return!!b.data(a,e[3])}}),function(a){b.fn.val=function(){if(!this.length)return arguments.length?this:m;if(arguments.length)return a.apply(this,arguments),this.data("watermark")&&
(b.watermark.checkValue(this),b.watermark.show(this)),this;if(this.data("watermark")){var d=(this[0].value||"").replace(rreturn,"");return d!==(this.data("watermarkText")||"")||this.data("watermarkSameValue")?d:""}return a.apply(this,arguments)}}(b.fn.val),triggerFns.length&&b(function(){var a,d,e;for(a=triggerFns.length-1;0<=a;a--)d=triggerFns[a],e=k[d],"function"===typeof e&&(k[d]=function(a){return function(){b.watermark.hideAll();return a.apply(null,Array.prototype.slice.call(arguments))}}(e))}),
b(k).bind("beforeunload",function(){b.watermark.options.hideBeforeUnload&&b.watermark.hideAll()}))})(jQuery,window);
