﻿Type.registerNamespace("AjaxControlToolkit");AjaxControlToolkit.TextBoxWatermarkBehavior=function(a){AjaxControlToolkit.TextBoxWatermarkBehavior.initializeBase(this,[a]);this._watermarkText=null;this._watermarkCssClass=null;this._focusHandler=null;this._blurHandler=null;this._keyPressHandler=null;this._propertyChangedHandler=null;this._watermarkChangedHandler=null;this._oldClassName=null;this._clearedForSubmit=null;this._maxLength=null;if(typeof WebForm_OnSubmit=="function"&&!AjaxControlToolkit.TextBoxWatermarkBehavior._originalWebForm_OnSubmit){AjaxControlToolkit.TextBoxWatermarkBehavior._originalWebForm_OnSubmit=WebForm_OnSubmit;WebForm_OnSubmit=AjaxControlToolkit.TextBoxWatermarkBehavior.WebForm_OnSubmit}};AjaxControlToolkit.TextBoxWatermarkBehavior.prototype={initialize:function(){AjaxControlToolkit.TextBoxWatermarkBehavior.callBaseMethod(this,"initialize");var a=this.get_element(),d=false,b=AjaxControlToolkit.TextBoxWatermarkBehavior.callBaseMethod(this,"get_ClientState");if(b!=null&&b!=""){d=b=="Focused";AjaxControlToolkit.TextBoxWatermarkBehavior.callBaseMethod(this,"set_ClientState",null)}this._oldClassName=a.className;this._focusHandler=Function.createDelegate(this,this._onFocus);this._blurHandler=Function.createDelegate(this,this._onBlur);this._keyPressHandler=Function.createDelegate(this,this._onKeyPress);$addHandler(a,"focus",this._focusHandler);$addHandler(a,"blur",this._blurHandler);$addHandler(a,"keypress",this._keyPressHandler);this.registerPropertyChanged();var e=AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).get_Current(),c=AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element());if(""==e||this._watermarkText==e){c.set_Watermark(this._watermarkText);c.set_IsWatermarked(true)}if(d)this._onFocus();else{a.blur();this._onBlur()}this._clearedForSubmit=false;this.registerPartialUpdateEvents();this._watermarkChangedHandler=Function.createDelegate(this,this._onWatermarkChanged);c.add_WatermarkChanged(this._watermarkChangedHandler)},dispose:function(){var a=this.get_element();if(this._watermarkChangedHandler){AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).remove_WatermarkChanged(this._watermarkChangedHandler);this._watermarkChangedHandler=null}if(a.control&&this._propertyChangedHandler){a.control.remove_propertyChanged(this._propertyChangedHandler);this._propertyChangedHandler=null}if(this._focusHandler){$removeHandler(a,"focus",this._focusHandler);this._focusHandler=null}if(this._blurHandler){$removeHandler(a,"blur",this._blurHandler);this._blurHandler=null}if(this._keyPressHandler){$removeHandler(a,"keypress",this._keyPressHandler);this._keyPressHandler=null}AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).get_IsWatermarked()&&this.clearText(false);AjaxControlToolkit.TextBoxWatermarkBehavior.callBaseMethod(this,"dispose")},_onWatermarkChanged:function(){if(AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).get_IsWatermarked())this._onBlur();else this._onFocus()},clearText:function(c){var a=this.get_element(),b=AjaxControlToolkit.TextBoxWrapper.get_Wrapper(a);b.set_Value("");b.set_IsWatermarked(false);if(c){a.setAttribute("autocomplete","off");a.select()}},_onFocus:function(b){var a=this.get_element();AjaxControlToolkit.TextBoxWrapper.get_Wrapper(a).get_IsWatermarked()&&this.clearText(b?true:false);a.className=this._oldClassName;if(this._maxLength>0){this.get_element().maxLength=this._maxLength;this._maxLength=null}},_onBlur:function(){var a=AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element());if(""==a.get_Current()||a.get_IsWatermarked()){if(this.get_element().maxLength>0&&this._watermarkText.length>this.get_element().maxLength){this._maxLength=this.get_element().maxLength;this.get_element().maxLength=this._watermarkText.length}this._applyWatermark()}},_applyWatermark:function(){var a=AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element());a.set_Watermark(this._watermarkText);a.set_IsWatermarked(true);if(this._watermarkCssClass)this.get_element().className=this._watermarkCssClass},_onKeyPress:function(){AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).set_IsWatermarked(false)},registerPropertyChanged:function(){var a=this.get_element();if(a.control&&!this._propertyChangedHandler){this._propertyChangedHandler=Function.createDelegate(this,this._onPropertyChanged);a.control.add_propertyChanged(this._propertyChangedHandler)}},_onPropertyChanged:function(b,a){"text"==a.get_propertyName()&&this.set_Value(AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).get_Current())},_onSubmit:function(){if(AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).get_IsWatermarked()){this.clearText(false);this._clearedForSubmit=true}},_partialUpdateEndRequest:function(b,a){AjaxControlToolkit.TextBoxWatermarkBehavior.callBaseMethod(this,"_partialUpdateEndRequest",[b,a]);if(this.get_element()&&this._clearedForSubmit){this.get_element().blur();this._onBlur();this._clearedForSubmit=false}},get_WatermarkText:function(){return this._watermarkText},set_WatermarkText:function(a){if(this._watermarkText!=a){this._watermarkText=a;AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).get_IsWatermarked()&&this._applyWatermark();this.raisePropertyChanged("WatermarkText")}},get_WatermarkCssClass:function(){return this._watermarkCssClass},set_WatermarkCssClass:function(a){if(this._watermarkCssClass!=a){this._watermarkCssClass=a;AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).get_IsWatermarked()&&this._applyWatermark();this.raisePropertyChanged("WatermarkCssClass")}},get_Text:function(){return AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).get_Value()},set_Text:function(a){if(""==a){AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).set_Current("");this.get_element().blur();this._onBlur()}else{this._onFocus();AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element()).set_Current(a)}}};AjaxControlToolkit.TextBoxWatermarkBehavior.registerClass("AjaxControlToolkit.TextBoxWatermarkBehavior",AjaxControlToolkit.BehaviorBase);AjaxControlToolkit.TextBoxWatermarkBehavior.WebForm_OnSubmit=function(){var d=AjaxControlToolkit.TextBoxWatermarkBehavior._originalWebForm_OnSubmit();if(d)for(var b=Sys.Application.getComponents(),a=0;a<b.length;a++){var c=b[a];AjaxControlToolkit.TextBoxWatermarkBehavior.isInstanceOfType(c)&&c._onSubmit()}return d};
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();