// (c) 2010 CodePlex Foundation (function(){var b="ExtendedDynamicPopulate";function a(){var d="populated",c="populating",b=false,a=null;Type.registerNamespace("Sys.Extended.UI");Sys.Extended.UI.DynamicPopulateBehavior=function(d){var c=this;Sys.Extended.UI.DynamicPopulateBehavior.initializeBase(c,[d]);c._servicePath=location.pathname;c._serviceMethod=a;c._contextKey=a;c._cacheDynamicResults=b;c._populateTriggerID=a;c._setUpdatingCssClass=a;c._clearDuringUpdate=true;c._customScript=a;c._clickHandler=a;c._callID=0;c._currentCallID=-1;c._populated=b};Sys.Extended.UI.DynamicPopulateBehavior.prototype={initialize:function(){var a=this;Sys.Extended.UI.DynamicPopulateBehavior.callBaseMethod(a,"initialize");$common.prepareHiddenElementForATDeviceUpdate();if(a._populateTriggerID){var b=$get(a._populateTriggerID);if(b){a._clickHandler=Function.createDelegate(a,a._onPopulateTriggerClick);$addHandler(b,"click",a._clickHandler)}}},dispose:function(){var b=this;if(b._populateTriggerID&&b._clickHandler){var c=$get(b._populateTriggerID);c&&$removeHandler(c,"click",b._clickHandler);b._populateTriggerID=a;b._clickHandler=a}Sys.Extended.UI.DynamicPopulateBehavior.callBaseMethod(b,"dispose")},populate:function(c){var a=this;if(a._populated&&a._cacheDynamicResults)return;if(a._currentCallID==-1){var d=new Sys.CancelEventArgs;a.raisePopulating(d);if(d.get_cancel())return;a._setUpdating(true)}if(a._customScript){var e=eval(a._customScript);a._setTargetHtml(e);a._setUpdating(b)}else{a._currentCallID=++a._callID;if(a._servicePath&&a._serviceMethod){Sys.Net.WebServiceProxy.invoke(a._servicePath,a._serviceMethod,b,{contextKey:c?c:a._contextKey},Function.createDelegate(a,a._onMethodComplete),Function.createDelegate(a,a._onMethodError),a._currentCallID);$common.updateFormToRefreshATDeviceBuffer()}}},_onMethodComplete:function(c,a){if(a!=this._currentCallID)return;this._setTargetHtml(c);this._setUpdating(b)},_onMethodError:function(c,d){var a=this;if(d!=a._currentCallID)return;if(c.get_timedOut())a._setTargetHtml(Sys.Extended.UI.Resources.DynamicPopulate_WebServiceTimeout);else a._setTargetHtml(String.format(Sys.Extended.UI.Resources.DynamicPopulate_WebServiceError,c.get_statusCode()));a._setUpdating(b)},_onPopulateTriggerClick:function(){this.populate(this._contextKey)},_setUpdating:function(b){var a=this;a.setStyle(b);if(!b){a._currentCallID=-1;a._populated=true;a.raisePopulated(a,Sys.EventArgs.Empty)}},_setTargetHtml:function(b){var a=this.get_element();if(a)if(a.tagName=="INPUT")a.value=b;else a.innerHTML=b},setStyle:function(d){var b=this,c=b.get_element();if(b._setUpdatingCssClass)if(!d){c.className=b._oldCss;b._oldCss=a}else{b._oldCss=c.className;c.className=b._setUpdatingCssClass}d&&b._clearDuringUpdate&&b._setTargetHtml("")},get_ClearContentsDuringUpdate:function(){return this._clearDuringUpdate},set_ClearContentsDuringUpdate:function(a){if(this._clearDuringUpdate!=a){this._clearDuringUpdate=a;this.raisePropertyChanged("ClearContentsDuringUpdate")}},get_ContextKey:function(){return this._contextKey},set_ContextKey:function(a){if(this._contextKey!=a){this._contextKey=a;this.raisePropertyChanged("ContextKey")}},get_PopulateTriggerID:function(){return this._populateTriggerID},set_PopulateTriggerID:function(a){if(this._populateTriggerID!=a){this._populateTriggerID=a;this.raisePropertyChanged("PopulateTriggerID")}},get_ServicePath:function(){return this._servicePath},set_ServicePath:function(a){if(this._servicePath!=a){this._servicePath=a;this.raisePropertyChanged("ServicePath")}},get_ServiceMethod:function(){return this._serviceMethod},set_ServiceMethod:function(a){if(this._serviceMethod!=a){this._serviceMethod=a;this.raisePropertyChanged("ServiceMethod")}},get_cacheDynamicResults:function(){return this._cacheDynamicResults},set_cacheDynamicResults:function(a){if(this._cacheDynamicResults!=a){this._cacheDynamicResults=a;this.raisePropertyChanged("cacheDynamicResults")}},get_UpdatingCssClass:function(){return this._setUpdatingCssClass},set_UpdatingCssClass:function(a){if(this._setUpdatingCssClass!=a){this._setUpdatingCssClass=a;this.raisePropertyChanged("UpdatingCssClass")}},get_CustomScript:function(){return this._customScript},set_CustomScript:function(a){if(this._customScript!=a){this._customScript=a;this.raisePropertyChanged("CustomScript")}},add_populating:function(a){this.get_events().addHandler(c,a)},remove_populating:function(a){this.get_events().removeHandler(c,a)},raisePopulating:function(b){var a=this.get_events().getHandler(c);a&&a(this,b)},add_populated:function(a){this.get_events().addHandler(d,a)},remove_populated:function(a){this.get_events().removeHandler(d,a)},raisePopulated:function(b){var a=this.get_events().getHandler(d);a&&a(this,b)}};Sys.Extended.UI.DynamicPopulateBehavior.registerClass("Sys.Extended.UI.DynamicPopulateBehavior",Sys.Extended.UI.BehaviorBase);Sys.registerComponent(Sys.Extended.UI.DynamicPopulateBehavior,{name:"dynamicPopulate"})}if(window.Sys&&Sys.loader)Sys.loader.registerScript(b,["ExtendedBase","ExtendedCommon","Network"],a);else a()})();