﻿Type.registerNamespace("AjaxControlToolkit");AjaxControlToolkit.AutoCompleteBehavior=function(d){var c=false,b=null,a=this;AjaxControlToolkit.AutoCompleteBehavior.initializeBase(a,[d]);a._servicePath=b;a._serviceMethod=b;a._contextKey=b;a._useContextKey=c;a._minimumPrefixLength=3;a._completionSetCount=10;a._completionInterval=1e3;a._completionListElementID=b;a._completionListElement=b;a._textColor="windowtext";a._textBackground="window";a._popupBehavior=b;a._popupBehaviorHiddenHandler=b;a._onShowJson=b;a._onHideJson=b;a._timer=b;a._cache=b;a._currentPrefix=b;a._selectIndex=-1;a._focusHandler=b;a._blurHandler=b;a._bodyClickHandler=b;a._completionListBlurHandler=b;a._keyDownHandler=b;a._mouseDownHandler=b;a._mouseUpHandler=b;a._mouseOverHandler=b;a._tickHandler=b;a._enableCaching=true;a._flyoutHasFocus=c;a._textBoxHasFocus=c;a._completionListCssClass=b;a._completionListItemCssClass=b;a._highlightedItemCssClass=b;a._delimiterCharacters=b;a._firstRowSelected=c;a._showOnlyCurrentWordInCompletionListItem=c;a._webRequest=b};AjaxControlToolkit.AutoCompleteBehavior.prototype={initialize:function(){var b=null,a=this;AjaxControlToolkit.AutoCompleteBehavior.callBaseMethod(a,"initialize");$common.prepareHiddenElementForATDeviceUpdate();a._popupBehaviorHiddenHandler=Function.createDelegate(a,a._popupHidden);a._tickHandler=Function.createDelegate(a,a._onTimerTick);a._focusHandler=Function.createDelegate(a,a._onGotFocus);a._blurHandler=Function.createDelegate(a,a._onLostFocus);a._keyDownHandler=Function.createDelegate(a,a._onKeyDown);a._mouseDownHandler=Function.createDelegate(a,a._onListMouseDown);a._mouseUpHandler=Function.createDelegate(a,a._onListMouseUp);a._mouseOverHandler=Function.createDelegate(a,a._onListMouseOver);a._completionListBlurHandler=Function.createDelegate(a,a._onCompletionListBlur);a._bodyClickHandler=Function.createDelegate(a,a._onCompletionListBlur);a._timer=new Sys.Timer;a.initializeTimer(a._timer);var c=a.get_element();a.initializeTextBox(c);if(a._completionListElementID!==b)a._completionListElement=$get(a._completionListElementID);if(a._completionListElement==b){a._completionListElement=document.createElement("ul");a._completionListElement.id=a.get_id()+"_completionListElem";if(Sys.Browser.agent===Sys.Browser.Safari)document.body.appendChild(a._completionListElement);else c.parentNode.insertBefore(a._completionListElement,c.nextSibling)}a.initializeCompletionList(a._completionListElement);a._popupBehavior=$create(AjaxControlToolkit.PopupBehavior,{id:a.get_id()+"PopupBehavior",parentElement:c,positioningMode:AjaxControlToolkit.PositioningMode.BottomLeft},b,b,a._completionListElement);a._popupBehavior.add_hidden(a._popupBehaviorHiddenHandler);a._onShowJson&&a._popupBehavior.set_onShow(a._onShowJson);a._onHideJson&&a._popupBehavior.set_onHide(a._onHideJson)},dispose:function(){var b=null,a=this;a._onShowJson=b;a._onHideJson=b;if(a._popupBehavior){a._popupBehaviorHiddenHandler&&a._popupBehavior.remove_hidden(a._popupBehaviorHiddenHandler);a._popupBehavior.dispose();a._popupBehavior=b}if(a._timer){a._timer.dispose();a._timer=b}var c=a.get_element();if(c){$removeHandler(c,"focus",a._focusHandler);$removeHandler(c,"blur",a._blurHandler);$removeHandler(c,"keydown",a._keyDownHandler);$removeHandler(a._completionListElement,"blur",a._completionListBlurHandler);$removeHandler(a._completionListElement,"mousedown",a._mouseDownHandler);$removeHandler(a._completionListElement,"mouseup",a._mouseUpHandler);$removeHandler(a._completionListElement,"mouseover",a._mouseOverHandler)}if(a._bodyClickHandler){$removeHandler(document.body,"click",a._bodyClickHandler);a._bodyClickHandler=b}a._popupBehaviorHiddenHandler=b;a._tickHandler=b;a._focusHandler=b;a._blurHandler=b;a._keyDownHandler=b;a._completionListBlurHandler=b;a._mouseDownHandler=b;a._mouseUpHandler=b;a._mouseOverHandler=b;AjaxControlToolkit.AutoCompleteBehavior.callBaseMethod(a,"dispose")},initializeTimer:function(a){a.set_interval(this._completionInterval);a.add_tick(this._tickHandler)},initializeTextBox:function(a){a.autocomplete="off";$addHandler(a,"focus",this._focusHandler);$addHandler(a,"blur",this._blurHandler);$addHandler(a,"keydown",this._keyDownHandler)},initializeCompletionList:function(c){var b=this;if(b._completionListCssClass)Sys.UI.DomElement.addCssClass(c,b._completionListCssClass);else{var a=c.style;a.textAlign="left";a.visibility="hidden";a.cursor="default";a.listStyle="none";a.padding="0px";a.margin="0px! important";if(Sys.Browser.agent===Sys.Browser.Safari){a.border="solid 1px gray";a.backgroundColor="white";a.color="black"}else{a.border="solid 1px buttonshadow";a.backgroundColor=b._textBackground;a.color=b._textColor}}$addHandler(c,"mousedown",b._mouseDownHandler);$addHandler(c,"mouseup",b._mouseUpHandler);$addHandler(c,"mouseover",b._mouseOverHandler);$addHandler(c,"blur",b._completionListBlurHandler);$addHandler(document.body,"click",b._bodyClickHandler)},_currentCompletionWord:function(){var b=this,f=b.get_element(),c=f.value,d=c;if(b.get_isMultiWord()){var a=b._getCurrentWordStartIndex(),e=b._getCurrentWordEndIndex(a);if(e<=a)d=c.substring(a);else d=c.substring(a,e)}return d},_getCursorIndex:function(){return this.get_element().selectionStart},_getCurrentWordStartIndex:function(){var a=this;for(var g=a.get_element(),f=g.value.substring(0,a._getCursorIndex()),b=0,c=-1,d=0;d<a._delimiterCharacters.length;++d){var e=f.lastIndexOf(a._delimiterCharacters.charAt(d));if(e>c)c=e}b=c;if(b>=a._getCursorIndex())b=0;return b<0?0:b+1},_getCurrentWordEndIndex:function(d){for(var e=this.get_element(),f=e.value.substring(d),a=0,c=0;c<this._delimiterCharacters.length;++c){var b=f.indexOf(this._delimiterCharacters.charAt(c));if(b>0&&(b<a||a==0))a=b}return a<=0?e.value.length:a+d},get_isMultiWord:function(){return this._delimiterCharacters!=null&&this._delimiterCharacters!=""},_getTextWithInsertedWord:function(d){var b=this,h=d,j=0,i=b.get_element(),c=i.value;if(b.get_isMultiWord()){var a=b._getCurrentWordStartIndex(),e=b._getCurrentWordEndIndex(a),f="",g="";if(a>0)f=c.substring(0,a);if(e>a)g=c.substring(e);h=f+d+g}return h},_hideCompletionList:function(){var a=new Sys.CancelEventArgs;this.raiseHiding(a);if(a.get_cancel())return;this.hidePopup()},showPopup:function(){this._popupBehavior.show();this.raiseShown(Sys.EventArgs.Empty)},hidePopup:function(){if(this._popupBehavior)this._popupBehavior.hide();else this._popupHidden()},_popupHidden:function(){var a=this;a._completionListElement.innerHTML="";a._selectIndex=-1;a._flyoutHasFocus=false;a.raiseHidden(Sys.EventArgs.Empty)},_highlightItem:function(c){var a=this;for(var e=a._completionListElement.childNodes,d=0;d<e.length;d++){var b=e[d];if(b._highlighted){if(a._completionListItemCssClass){Sys.UI.DomElement.removeCssClass(b,a._highlightedItemCssClass);Sys.UI.DomElement.addCssClass(b,a._completionListItemCssClass)}else if(Sys.Browser.agent===Sys.Browser.Safari){b.style.backgroundColor="white";b.style.color="black"}else{b.style.backgroundColor=a._textBackground;b.style.color=a._textColor}a.raiseItemOut(new AjaxControlToolkit.AutoCompleteItemEventArgs(b,b.firstChild.nodeValue,b._value))}}if(a._highlightedItemCssClass){Sys.UI.DomElement.removeCssClass(c,a._completionListItemCssClass);Sys.UI.DomElement.addCssClass(c,a._highlightedItemCssClass)}else if(Sys.Browser.agent===Sys.Browser.Safari)c.style.backgroundColor="lemonchiffon";else{c.style.backgroundColor="highlight";c.style.color="highlighttext"}c._highlighted=true;a.raiseItemOver(new AjaxControlToolkit.AutoCompleteItemEventArgs(c,c.firstChild.nodeValue,c._value))},_onCompletionListBlur:function(){this._hideCompletionList()},_onListMouseDown:function(b){var a=this;if(b.target!==a._completionListElement){a._setText(b.target);a._flyoutHasFocus=false}else a._flyoutHasFocus=true},_onListMouseUp:function(){try{this.get_element().focus()}catch(b){}},_onListMouseOver:function(e){var a=this,c=e.target;if(c!==a._completionListElement)for(var d=a._completionListElement.childNodes,b=0;b<d.length;++b)if(c===d[b]){a._highlightItem(c);a._selectIndex=b;break}},_onGotFocus:function(){var a=this;a._textBoxHasFocus=true;a._flyoutHasFocus&&a._hideCompletionList();a._minimumPrefixLength==0&&!a.get_element().value&&a._timer.set_enabled(true)},_onKeyDown:function(b){var a=this;a._textBoxHasFocus=true;a._timer.set_enabled(false);var c=b.keyCode?b.keyCode:b.rawEvent.keyCode;if(c===Sys.UI.Key.esc){a._hideCompletionList();b.preventDefault()}else if(c===Sys.UI.Key.up){if(a._selectIndex>0){a._selectIndex--;a._handleScroll(a._completionListElement.childNodes[a._selectIndex],a._selectIndex);a._highlightItem(a._completionListElement.childNodes[a._selectIndex]);b.stopPropagation();b.preventDefault()}}else if(c===Sys.UI.Key.down){if(a._selectIndex<a._completionListElement.childNodes.length-1){a._selectIndex++;a._handleScroll(a._completionListElement.childNodes[a._selectIndex],a._selectIndex);a._highlightItem(a._completionListElement.childNodes[a._selectIndex]);b.stopPropagation();b.preventDefault()}}else if(c===Sys.UI.Key.enter)if(a._selectIndex!==-1){a._setText(a._completionListElement.childNodes[a._selectIndex]);b.preventDefault()}else a.hidePopup();else if(c===Sys.UI.Key.tab)a._selectIndex!==-1&&a._setText(a._completionListElement.childNodes[a._selectIndex]);else a._timer.set_enabled(true)},_handleScroll:function(e,c){var a=this._completionListElement,b=$common.getBounds(e),d=this._completionListElement.childNodes.length;if(b.height*c-(a.clientHeight+a.scrollTop)>=0)a.scrollTop+=b.height*c-(a.clientHeight+a.scrollTop)+b.height;if(b.height*(d-(c+1))-(a.scrollHeight-a.scrollTop)>=0)a.scrollTop-=b.height*(d-(c+1))-(a.scrollHeight-a.scrollTop)+b.height;if(a.scrollTop%b.height!==0)if(b.height*(c+1)-(a.clientHeight+a.scrollTop)>=0)a.scrollTop-=a.scrollTop%b.height;else a.scrollTop+=b.height-a.scrollTop%b.height},_handleFlyoutFocus:function(){var a=this;if(!a._textBoxHasFocus)if(!a._flyoutHasFocus){if(a._webRequest){a._webRequest.get_executor().abort();a._webRequest=null}a._hideCompletionList()}},_onLostFocus:function(){var a=this;a._textBoxHasFocus=false;a._timer.set_enabled(false);window.setTimeout(Function.createDelegate(a,a._handleFlyoutFocus),500)},_onMethodComplete:function(b,a){this._webRequest=null;this._update(a,b,true)},_onMethodFailed:function(){this._webRequest=null},_onTimerTick:function(f,d){var c=false,a=this;a._timer.set_enabled(c);if(a._servicePath&&a._serviceMethod){var b=a._currentCompletionWord();if(b.trim().length<a._minimumPrefixLength){a._currentPrefix=null;a._update("",null,c);return}if(a._currentPrefix!==b||b==""&&a._minimumPrefixLength==0){a._currentPrefix=b;if(b!=""&&a._cache&&a._cache[b]){a._update(b,a._cache[b],c);return}var d=new Sys.CancelEventArgs;a.raisePopulating(d);if(d.get_cancel())return;var e={prefixText:a._currentPrefix,count:a._completionSetCount};if(a._useContextKey)e.contextKey=a._contextKey;if(a._webRequest){a._webRequest.get_executor().abort();a._webRequest=null}a._webRequest=Sys.Net.WebServiceProxy.invoke(a.get_servicePath(),a.get_serviceMethod(),c,e,Function.createDelegate(a,a._onMethodComplete),Function.createDelegate(a,a._onMethodFailed),b);$common.updateFormToRefreshATDeviceBuffer()}}},_setText:function(b){var a=this,e=b&&b.firstChild?b.firstChild.nodeValue:null;a._timer.set_enabled(false);var d=a.get_element(),c=d.control,f=a._showOnlyCurrentWordInCompletionListItem?a._getTextWithInsertedWord(e):e;if(c&&c.set_text)c.set_text(f);else d.value=f;$common.tryFireEvent(d,"change");a.raiseItemSelected(new AjaxControlToolkit.AutoCompleteItemEventArgs(b,e,b?b._value:null));a._currentPrefix=a._currentCompletionWord();a._hideCompletionList()},_update:function(k,c,n){var e=null,a=this;if(n&&a.get_enableCaching()){if(!a._cache)a._cache={};a._cache[k]=c}if(!a._textBoxHasFocus||k!=a._currentCompletionWord()){a._hideCompletionList();return}if(c&&c.length){a._completionListElement.innerHTML="";a._selectIndex=-1;for(var h=e,f=e,i=e,g=0;g<c.length;g++){var b=e;if(a._completionListElementID)b=document.createElement("div");else b=document.createElement("li");if(h==e)h=b;try{var j=Sys.Serialization.JavaScriptSerializer.deserialize("("+c[g]+")");if(j&&j.First){f=j.First;i=j.Second}else{f=c[g];i=f}}catch(p){f=c[g];i=c[g]}var o=a._showOnlyCurrentWordInCompletionListItem?f:a._getTextWithInsertedWord(f);b.appendChild(document.createTextNode(o));b._value=i;b.__item="";if(a._completionListItemCssClass)Sys.UI.DomElement.addCssClass(b,a._completionListItemCssClass);else{var d=b.style;d.padding="0px";d.textAlign="left";d.textOverflow="ellipsis";if(Sys.Browser.agent===Sys.Browser.Safari){d.backgroundColor="white";d.color="black"}else{d.backgroundColor=a._textBackground;d.color=a._textColor}}a._completionListElement.appendChild(b)}var m=$common.getBounds(a.get_element());a._completionListElement.style.width=Math.max(1,m.width-2)+"px";a._completionListElement.scrollTop=0;a.raisePopulated(Sys.EventArgs.Empty);var l=new Sys.CancelEventArgs;a.raiseShowing(l);if(!l.get_cancel()){a.showPopup();if(a._firstRowSelected&&h!=e){a._highlightItem(h);a._selectIndex=0}}}else a._hideCompletionList()},get_onShow:function(){return this._popupBehavior?this._popupBehavior.get_onShow():this._onShowJson},set_onShow:function(b){var a=this;if(a._popupBehavior)a._popupBehavior.set_onShow(b);else a._onShowJson=b;a.raisePropertyChanged("onShow")},get_onShowBehavior:function(){return this._popupBehavior?this._popupBehavior.get_onShowBehavior():null},onShow:function(){this._popupBehavior&&this._popupBehavior.onShow()},get_onHide:function(){return this._popupBehavior?this._popupBehavior.get_onHide():this._onHideJson},set_onHide:function(b){var a=this;if(a._popupBehavior)a._popupBehavior.set_onHide(b);else a._onHideJson=b;a.raisePropertyChanged("onHide")},get_onHideBehavior:function(){return this._popupBehavior?this._popupBehavior.get_onHideBehavior():null},onHide:function(){this._popupBehavior&&this._popupBehavior.onHide()},get_completionInterval:function(){return this._completionInterval},set_completionInterval:function(a){if(this._completionInterval!=a){this._completionInterval=a;this.raisePropertyChanged("completionInterval")}},get_completionList:function(){return this._completionListElement},set_completionList:function(a){if(this._completionListElement!=a){this._completionListElement=a;this.raisePropertyChanged("completionList")}},get_completionSetCount:function(){return this._completionSetCount},set_completionSetCount:function(a){if(this._completionSetCount!=a){this._completionSetCount=a;this.raisePropertyChanged("completionSetCount")}},get_minimumPrefixLength:function(){return this._minimumPrefixLength},set_minimumPrefixLength:function(a){if(this._minimumPrefixLength!=a){this._minimumPrefixLength=a;this.raisePropertyChanged("minimumPrefixLength")}},get_serviceMethod:function(){return this._serviceMethod},set_serviceMethod:function(a){if(this._serviceMethod!=a){this._serviceMethod=a;this.raisePropertyChanged("serviceMethod")}},get_servicePath:function(){return this._servicePath},set_servicePath:function(a){if(this._servicePath!=a){this._servicePath=a;this.raisePropertyChanged("servicePath")}},get_contextKey:function(){return this._contextKey},set_contextKey:function(b){var a=this;if(a._contextKey!=b){a._contextKey=b;a.set_useContextKey(true);a.raisePropertyChanged("contextKey")}},get_useContextKey:function(){return this._useContextKey},set_useContextKey:function(a){if(this._useContextKey!=a){this._useContextKey=a;this.raisePropertyChanged("useContextKey")}},get_enableCaching:function(){return this._enableCaching},set_enableCaching:function(a){if(this._enableCaching!=a){this._enableCaching=a;this.raisePropertyChanged("enableCaching")}},get_completionListElementID:function(){return this._completionListElementID},set_completionListElementID:function(a){if(this._completionListElementID!=a){this._completionListElementID=a;this.raisePropertyChanged("completionListElementID")}},get_completionListCssClass:function(){return this._completionListCssClass},set_completionListCssClass:function(a){if(this._completionListCssClass!=a){this._completionListCssClass=a;this.raisePropertyChanged("completionListCssClass")}},get_completionListItemCssClass:function(){return this._completionListItemCssClass},set_completionListItemCssClass:function(a){if(this._completionListItemCssClass!=a){this._completionListItemCssClass=a;this.raisePropertyChanged("completionListItemCssClass")}},get_highlightedItemCssClass:function(){return this._highlightedItemCssClass},set_highlightedItemCssClass:function(a){if(this._highlightedItemCssClass!=a){this._highlightedItemCssClass=a;this.raisePropertyChanged("highlightedItemCssClass")}},get_delimiterCharacters:function(){return this._delimiterCharacters},set_delimiterCharacters:function(a){if(this._delimiterCharacters!=a){this._delimiterCharacters=a;this.raisePropertyChanged("delimiterCharacters")}},get_firstRowSelected:function(){return this._firstRowSelected},set_firstRowSelected:function(a){if(this._firstRowSelected!=a){this._firstRowSelected=a;this.raisePropertyChanged("firstRowSelected")}},get_showOnlyCurrentWordInCompletionListItem:function(){return this._showOnlyCurrentWordInCompletionListItem},set_showOnlyCurrentWordInCompletionListItem:function(a){if(this._showOnlyCurrentWordInCompletionListItem!=a){this._showOnlyCurrentWordInCompletionListItem=a;this.raisePropertyChanged("showOnlyCurrentWordInCompletionListItem")}},add_populating:function(a){this.get_events().addHandler("populating",a)},remove_populating:function(a){this.get_events().removeHandler("populating",a)},raisePopulating:function(b){var a=this.get_events().getHandler("populating");a&&a(this,b)},add_populated:function(a){this.get_events().addHandler("populated",a)},remove_populated:function(a){this.get_events().removeHandler("populated",a)},raisePopulated:function(b){var a=this.get_events().getHandler("populated");a&&a(this,b)},add_showing:function(a){this.get_events().addHandler("showing",a)},remove_showing:function(a){this.get_events().removeHandler("showing",a)},raiseShowing:function(b){var a=this.get_events().getHandler("showing");a&&a(this,b)},add_shown:function(a){this.get_events().addHandler("shown",a)},remove_shown:function(a){this.get_events().removeHandler("shown",a)},raiseShown:function(b){var a=this.get_events().getHandler("shown");a&&a(this,b)},add_hiding:function(a){this.get_events().addHandler("hiding",a)},remove_hiding:function(a){this.get_events().removeHandler("hiding",a)},raiseHiding:function(b){var a=this.get_events().getHandler("hiding");a&&a(this,b)},add_hidden:function(a){this.get_events().addHandler("hidden",a)},remove_hidden:function(a){this.get_events().removeHandler("hidden",a)},raiseHidden:function(b){var a=this.get_events().getHandler("hidden");a&&a(this,b)},add_itemSelected:function(a){this.get_events().addHandler("itemSelected",a)},remove_itemSelected:function(a){this.get_events().removeHandler("itemSelected",a)},raiseItemSelected:function(b){var a=this.get_events().getHandler("itemSelected");a&&a(this,b)},add_itemOver:function(a){this.get_events().addHandler("itemOver",a)},remove_itemOver:function(a){this.get_events().removeHandler("itemOver",a)},raiseItemOver:function(b){var a=this.get_events().getHandler("itemOver");a&&a(this,b)},add_itemOut:function(a){this.get_events().addHandler("itemOut",a)},remove_itemOut:function(a){this.get_events().removeHandler("itemOut",a)},raiseItemOut:function(b){var a=this.get_events().getHandler("itemOut");a&&a(this,b)}};AjaxControlToolkit.AutoCompleteBehavior.registerClass("AjaxControlToolkit.AutoCompleteBehavior",AjaxControlToolkit.BehaviorBase);AjaxControlToolkit.AutoCompleteBehavior.descriptor={properties:[{name:"completionInterval",type:Number},{name:"completionList",isDomElement:true},{name:"completionListElementID",type:String},{name:"completionSetCount",type:Number},{name:"minimumPrefixLength",type:Number},{name:"serviceMethod",type:String},{name:"servicePath",type:String},{name:"enableCaching",type:Boolean},{name:"showOnlyCurrentWordInCompletionListItem",type:Boolean}]};AjaxControlToolkit.AutoCompleteItemEventArgs=function(c,d,b){var a=this;AjaxControlToolkit.AutoCompleteItemEventArgs.initializeBase(a);a._item=c;a._text=d;a._value=b!==undefined?b:null};AjaxControlToolkit.AutoCompleteItemEventArgs.prototype={get_item:function(){return this._item},set_item:function(a){this._item=a},get_text:function(){return this._text},set_text:function(a){this._text=a},get_value:function(){return this._value},set_value:function(a){this._value=a}};AjaxControlToolkit.AutoCompleteItemEventArgs.registerClass("AjaxControlToolkit.AutoCompleteItemEventArgs",Sys.EventArgs);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();