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