Obout.ComboBox=function(e,H,r,o,C,j,i,m,I,G,B,E,F,a,z,s,q,v,p,c,t,A,u,k,h,f,y,l,b,w,n,x,D,d,g){this._dropDownList=new Obout.Interface.OboutDropDownList(e,H,r,o,C,j,i,m,I,G,B,E,a.OnSelectedIndexChanged,a.OnItemClick,s,q,v,c,z,f,b,g);this.ID=this._dropDownList.ID;this._core=Obout.Interface.OboutCore;this._uniqueID=e;this.options=this._dropDownList.options;this.ItemsContainer=this._dropDownList.ItemsContainer;this.AllowCustomText=p;this.AllowMultiSelection=c;this.AutoValidate=t;this.EmptyText=A;this.SelectedText=u;this.EnableLoadOnDemand=k;this.EnableVirtualScrolling=h;this.FilterType=y;this.HasFooterTemplate=l;this.MultiSelectionSeparator=b;this.OpenOnFocus=w;this.ShowSelectedImage=n;this.Mode=f;this.ClientSideEvents=a;this.IsDetail=D;d&&this._initDetail(d);this._sortedItems=x;this._tempSelectedIndex=-1;this._currentSelectedIndex=this._dropDownList._selectedIndex;this._currentSelectedIndexes=this._dropDownList._selectedIndexes;this._currentCustomText="";this._trackSelectedIndex=true;this._useDefaultTextBoxBlurHandler=false;this._keysPressed=0;this._itemsLoadedOnOpen=false;this._lastTextBeforeAutoComplete="";this._lastKeyPressed=null;this._selectedItemImageInTopContainer=null;this._preventOpenOnFocus=false;this._preventDetailLoading=true;this._overridedDetailSelectedIndexChanged=false;this._virtualScrollingInProgress=false;this._itemsLoadedCount=0;this._itemsCount=0;this._init();F&&this.focus(true)};Obout.ComboBox.prototype={_init:function(){this._attachEventHandlers();this._dropDownList._selectedIndex!=-1&&this._handleSelectedIndexChanged();if(this._currentSelectedIndex==-1&&this._dropDownList.TextBox.value!=""&&this._dropDownList.TextBox.value!=this.EmptyText&&this._dropDownList.TextBox.value!=this.SelectedText)if(this.AllowCustomText)this._currentCustomText=this._dropDownList.TextBox.value;else this._dropDownList.TextBox.value=this.EmptyText;this._dropDownList._selectedIndex!=-1&&this.EmptyText&&this._core.removeCssClass(this._dropDownList.TextBox,this._dropDownList.CssSettings.IE_ET);this.Mode==2&&this.EnableLoadOnDemand&&this._handleDropDownListOpen()},_initDetail:function(c){this.Detail=eval(c);this.Detail.Master=this;this.Detail._dropDownList._master=this._dropDownList;this._dropDownList._detail=this.Detail._dropDownList;var d=this.Detail._dropDownList.TextBox;this.Detail._dropDownList.TextBox=this._dropDownList.TextBox;this._dropDownList.TextBox=d;var b=this.Detail._dropDownList.SelectedValueStorage;this.Detail._dropDownList.SelectedValueStorage=this._dropDownList.SelectedValueStorage;this._dropDownList.SelectedValueStorage=b;var a=this.Detail._dropDownList.SelectedIndexStorage;this.Detail._dropDownList.SelectedIndexStorage=this._dropDownList.SelectedIndexStorage;this._dropDownList.SelectedIndexStorage=a;this.Detail._attachKeyHandlers();this.Detail.Detail&&this.Detail._initDetail(this.Detail.Detail.ID)},_attachKeyHandlers:function(){var a=this;this._dropDownList.TextBox.onkeydown=function(b){return a._handleKeyDown(b)};this._dropDownList.TextBox.onkeyup=function(b){return a._handleKeyUp(b)}},_attachBlurEvent:function(){var a=this;this._dropDownList.OnTextBoxBlur=function(){return a._handleTextBoxBlur()}},_attachEventHandlers:function(){var a=this;!this.Detail&&this._attachKeyHandlers();if(this.OpenOnFocus)this._dropDownList.OnTopContainerClick=function(b){return a._handleTopContainerClick(b)};else{this._dropDownList.TopContainer.childNodes[0].onclick=function(){a._handleTopContainerClick()};this._dropDownList.TopContainer.childNodes[2].onclick=function(){a._handleTopContainerClick()}}if(this.OpenOnFocus||this.EmptyText)this._dropDownList.OnTextBoxFocus=function(){return a._handleTextBoxFocus()};this._attachBlurEvent();this._dropDownList.OnSelectedIndexChanged=function(){return a._handleSelectedIndexChanged()};this._dropDownList.OnOpen=function(){return a._handleDropDownListOpen()};this._dropDownList.OnClose=function(){return a._handleDropDownListClose()};this._trackOnClose=true;if(this.EnableLoadOnDemand){this._dropDownList.ItemsContainer.childNodes[2].childNodes[1].onclick=function(){a._loadNextPageOnDemand()};if(this.EnableVirtualScrolling)this._dropDownList.ItemsInnerContainer.onscroll=function(){a._handleVirtualScrolling()}}},_handleKeyDown:function(e){var b=Obout.Interface.OboutCore.getKeyPressed(e),a=null,d=this._tempSelectedIndex;if(this._tempSelectedIndex==-1&&this._currentSelectedIndex!=-1)if(!this.AllowCustomText)this._tempSelectedIndex=this._currentSelectedIndex;else this._currentSelectedIndex=-1;var c=this._dropDownList._getCurrentHighlightedItem();switch(b){case 38:if(c&&c.previousSibling){a=c.previousSibling;this._tempSelectedIndex--}while(a!=null&&!this._isSelectableItem(a)){a=a.previousSibling;this._tempSelectedIndex--}break;case 40:if(c){if(c.nextSibling){a=c.nextSibling;this._tempSelectedIndex++}}else{a=this._dropDownList.ItemsInnerContainer.firstChild;this._tempSelectedIndex=0}while(a!=null&&!this._isSelectableItem(a)){a=a.nextSibling;this._tempSelectedIndex++}break;case 27:if(c){if(!this.AutoValidate)this._trackSelectedIndex=false;if(!this.AutoValidate)this._trackSelectedIndex=true}break;case 13:this._useDefaultTextBoxBlurHandler=true;this._persistCurrentItem();return false;break;case 9:this._useDefaultTextBoxBlurHandler=true;this._persistCurrentItem();return true;break;default:if(!(b<32&&(b!=8&&(this.EnableLoadOnDemand==true||this.FilterType!=0)||this.EnableLoadOnDemand==false&&this.FilterType==0)||b>=33&&b<46||b>=112&&b<=123))if(b!=this._lastKeyPressed||this._keysPressed==0){this._keysPressed++;this._lastKeyPressed=b}return true}if(a){this._dropDownList.Height&&this._scrollItemIntoView(Obout.Interface.OboutCore.getElementIndex(a));if(!this.AutoValidate)this._trackSelectedIndex=false;this._dropDownList.selectItem(a,false,false,null,false);if(!this.AutoValidate)this._trackSelectedIndex=true}else this._tempSelectedIndex=d;return false},_handleKeyUp:function(){var c=false;if(this._keysPressed>0){this._keysPressed--;c=true}var a="";if(this.AllowMultiSelection){var b=this._dropDownList.TextBox.value;a=b[b.length-1]}if(!this.AllowMultiSelection||a!=this.MultiSelectionSeparator){if(this._keysPressed==0&&c)if(!this.EnableLoadOnDemand||this.Master&&!this.Detail)if(this.FilterType==0)this._autoCompleteText();else this._filterItems();else this._dropDownList.TextBox.value.toLowerCase()!=this._lastTextBeforeAutoComplete.toLowerCase()&&this._sendAjaxRequest(this._dropDownList.TextBox.value,false)}else{this._autoCompleteCurrentSuggestion();this._persistTempItem()}},_isSelectableItem:function(a){return a.style.display!="none"&&a.className!="id"},_autoCompleteText:function(){if(!this.AllowMultiSelection)var e=this._dropDownList.TextBox.value,c=e.length;else var a=this._dropDownList.TextBox.value,b=a.lastIndexOf(this.MultiSelectionSeparator),e=a.substr(b+1),c=a.length;this._lastTextBeforeAutoComplete=this._dropDownList.TextBox.value;if(c>0){var d=this._getAutoCompleteText(e);if(!this.AllowMultiSelection)this._dropDownList.TextBox.value=d;else this._dropDownList.TextBox.value=a.substr(0,b+1)+d;this._selectRange(c,this._dropDownList.TextBox.value.length);this._persistTempItem();this._dropDownList.Height&&this._scrollItemIntoView(this._tempSelectedIndex)}},_selectRange:function(c,b){try{if(this._dropDownList.TextBox.createTextRange){var a=this._dropDownList.TextBox.createTextRange();a.moveStart("character",c);a.moveEnd("character",b);a.select()}else this._dropDownList.TextBox.setSelectionRange&&this._dropDownList.TextBox.setSelectionRange(c,b)}catch(d){}},_getAutoCompleteText:function(c){for(var d=c.toLowerCase(),a=0;a<this._sortedItems.length;a++){var b=this._dropDownList.options[this._sortedItems[a]];if(b.enabled&&b.text.toLowerCase().indexOf(d)==0){this._tempSelectedIndex=this._sortedItems[a];return b.text}}this._tempSelectedIndex=-1;return c},_autoCompleteCurrentSuggestion:function(){if(this._tempSelectedIndex!=-1&&this._tempSelectedIndex!=null){var a=this._dropDownList.TextBox.value;a=a.substr(0,a.length-1);a=a.substr(0,a.lastIndexOf(this.MultiSelectionSeparator)+1);var b=this._dropDownList.options[this._tempSelectedIndex].text;this._dropDownList.TextBox.value=a+b+this.MultiSelectionSeparator}},_scrollItemIntoView:function(c){if(c!=-1){var d=0,a=this._dropDownList.ItemsInnerContainer.childNodes[c];while(a){d+=a.offsetHeight;a=a.previousSibling}var b=d-this._dropDownList.ItemsInnerContainer.parentNode.offsetHeight;if(b<0)b=0;this._dropDownList.ItemsInnerContainer.scrollTop=b}},_filterItems:function(){for(var f=this._dropDownList.TextBox.value.toLowerCase(),c=0;c<this._sortedItems.length;c++){var h=this._dropDownList.options[this._sortedItems[c]],d=h.text.toLowerCase().indexOf(f),a=this._dropDownList.ItemsInnerContainer.childNodes[this._sortedItems[c]];a.style.display!="none"&&this._removeFilterHighlighting(a);var b="none";if(this.FilterType==1){if(d!=-1)b=""}else if(this.FilterType==2)if(d==0)b="";if(a.style.display!=b)a.style.display=b;if(b==""){var g=a.firstChild.innerHTML,e=g.substr(d,f.length);a.firstChild.innerHTML=g.replace(e,"<em>"+e+"</em>")}}},_removeFilterHighlighting:function(a){var b=a.firstChild.innerHTML;a.firstChild.innerHTML=b.replace(/<em>/gi,"").replace(/<\/em>/gi,"")},_removeFilterHighlightingForAllItems:function(){for(var b=0;b<this._dropDownList.ItemsInnerContainer.childNodes.length;b++){var a=this._dropDownList.ItemsInnerContainer.childNodes[b];this._removeFilterHighlighting(a);if(a.style.display=="none")a.style.display=""}},_persistTempItem:function(){this._trackSelectedIndex=false;this._dropDownList.selectItemByIndex(this._tempSelectedIndex,null,null,null,true,this.AllowMultiSelection,true);this._trackSelectedIndex=true},_persistCurrentItem:function(a){if(this._tempSelectedIndex!=-1||this.AllowCustomText)this._currentSelectedIndex=this._tempSelectedIndex;try{this._dropDownList.selectItemByIndex(this._currentSelectedIndex,null,null,true,this.AllowCustomText,this.AllowMultiSelection,null,true)}catch(b){}if(this.AllowMultiSelection)this._currentSelectedIndexes=this._dropDownList._selectedIndexes;if(this.AllowCustomText&&this._currentSelectedIndex==-1&&this._dropDownList.TextBox.value!="")this._currentCustomText=this._dropDownList.TextBox.value;this._tempSelectedIndex=-1;a!=true&&this._selectRange(this._dropDownList.TextBox.value.length,this._dropDownList.TextBox.value.length);this._dropDownList.close()},_restoreCurrentItem:function(){if(!this.AllowMultiSelection)this._dropDownList.selectItemByIndex(this._currentSelectedIndex);else for(var b=this._currentSelectedIndexes.toString().split(","),a=0;a<b.length;a++)this._dropDownList.selectItemByIndex(b[a],null,null,null,this.AllowCustomText,a!=0);if(this.AllowCustomText&&this._currentSelectedIndex==-1)this._dropDownList.TextBox.value=this._currentCustomText;this._tempSelectedIndex=-1;this._lastTextBeforeAutoComplete="";this._lastKeyPressed=null},_handleTopContainerClick:function(a){if(a!=1)return!this._dropDownList.IsClosed?false:true;else{if(this._dropDownList.IsClosed)this._dropDownList.open();else this._dropDownList.close();this._preventOpenOnFocus=true;this._dropDownList.focus();this._preventOpenOnFocus=true;return false}},_handleTextBoxFocus:function(){this.ClientSideEvents.OnFocus&&this.ClientSideEvents.OnFocus(this);if(this.OpenOnFocus&&!this._preventOpenOnFocus){this._dropDownList.IsClosed&&this._dropDownList.open();if(this._preventOpenOnFocus)this._preventOpenOnFocus=false}this._tryHidingEmptyText()},_handleTextBoxBlur:function(){this.ClientSideEvents.OnBlur&&this.ClientSideEvents.OnBlur(this);var a=true;if(this.AutoValidate){if(this._tempSelectedIndex==-1&&this._currentSelectedIndex!=-1&&!this.AllowCustomText)this._restoreCurrentItem();else this._persistCurrentItem(true);a=true}else if(!this._useDefaultTextBoxBlurHandler){this._restoreCurrentItem();a=!this._dropDownList.PreventTextBoxBluring}else{this._useDefaultTextBoxBlurHandler=false;if(this._tempSelectedIndex==-1&&(this._currentSelectedIndex!=-1||this._dropDownList._selectedIndexes!=-1)&&!this.AllowCustomText){this._restoreCurrentItem();a=true}else a=true}this._tryShowingEmptyText();this.FilterType!=0&&this._removeFilterHighlightingForAllItems();return a},_tryShowingEmptyText:function(){if(this.Detail){this.Detail._tryShowingEmptyText();return}if(this.EmptyText&&(this._dropDownList._selectedIndex==-1&&!(this._dropDownList.TextBox.value!=""&&this._dropDownList.TextBox.value!=this.EmptyText&&this.AllowCustomText))){this._dropDownList.TextBox.value=this.EmptyText;this._core.addCssClass(this._dropDownList.TextBox,this._dropDownList.CssSettings.IE_ET)}},_tryHidingEmptyText:function(){if(this.Detail){this.Detail._tryHidingEmptyText();return}if(this.EmptyText&&(this._dropDownList._selectedIndex==-1&&!(this._dropDownList.TextBox.value!=""&&this._dropDownList.TextBox.value!=this.EmptyText&&(this.AllowCustomText||this._dropDownList.TextBox.value==this.SelectedText)))){this._dropDownList.TextBox.value="";this._core.removeCssClass(this._dropDownList.TextBox,this._dropDownList.CssSettings.IE_ET)}},_handleSelectedIndexChanged:function(){if(this._trackSelectedIndex){if(this.FilterType!=0)this._tempSelectedIndex=this._dropDownList._selectedIndex;this._currentSelectedIndex=this._dropDownList._selectedIndex;this._currentSelectedIndexes=this._dropDownList._selectedIndexes}if(this.ShowSelectedImage&&this._dropDownList._selectedIndex!=-1){var b=this._dropDownList.ItemsInnerContainer.childNodes[this._dropDownList._selectedIndex],a=this._getItemImage(b);if(this._selectedItemImageInTopContainer==null){this._selectedItemImageInTopContainer=document.createElement("IMG");this._selectedItemImageInTopContainer.style.display="none";this._dropDownList.TextBox.parentNode.parentNode.appendChild(this._selectedItemImageInTopContainer)}if(a){this._selectedItemImageInTopContainer.src=a.src;this._selectedItemImageInTopContainer.style.display="";this._dropDownList.TextBox.parentNode.className=this._dropDownList.CssSettings.IE_WI}else{this._selectedItemImageInTopContainer.style.display="none";this._dropDownList.TextBox.parentNode.className=""}}this.Detail&&this._populateDetail()},_handleDropDownListOpen:function(){if(this.EnableLoadOnDemand&&!this._itemsLoadedOnOpen&&!this.Master){var a="";if(this._dropDownList.TextBox.value!=this.EmptyText)a=this._dropDownList.TextBox.value;this._sendAjaxRequest(a,false);this._itemsLoadedOnOpen=true}this.Detail&&this._openDetail();this.ClientSideEvents.OnOpen&&this.ClientSideEvents.OnOpen(this)},_handleDropDownListClose:function(){if(this._trackOnClose){this._preventOpenOnFocus=true;if(this.Detail&&(!this.Master||this.Master._dropDownList.IsClosed)){if(!this.Detail.Detail)this.Detail._trackOnClose=false;this.Detail._preventOpenOnFocus=true;this._closeDetail();this.Detail._trackOnClose=true}else if(this.Master){if(!this.Master.Master)this.Master._trackOnClose=false;this.Master._preventOpenOnFocus=true;this._closeMaster();this.Master._trackOnClose=true}this._preventOpenOnFocus=false}this.ClientSideEvents.OnClose&&this.ClientSideEvents.OnClose(this)},_getItemImage:function(a){return a.firstChild.firstChild&&a.firstChild.firstChild.nodeName=="IMG"?a.firstChild.firstChild:null},_createAjaxRequestParam:function(){},_sendAjaxRequest:function(a,b){if(!b)this._itemsLoadedCount=0;a=""+a+"";var d=JSON.stringify({Text:a,ItemsOffset:this._itemsLoadedCount}),c={};c.AppendItems=b;WebForm_DoCallback(this._uniqueID,d,this._core.createDelegate(this,this._loadItemsOnDemandCallback),c,this._core.createDelegate(this,this._loadItemsOnDemandException),false);this._showLoadingIndicator()},_loadNextPageOnDemand:function(){(this._itemsLoadedCount==0||this._itemsLoadedCount<this._itemsCount)&&this._sendAjaxRequest(this._lastTextBeforeAutoComplete,true)},_handleVirtualScrolling:function(){if(this._virtualScrollingHelper!=null&&this._dropDownList.ItemsInnerContainer.scrollTop>this._dropDownList.ItemsInnerContainer.scrollHeight-this._virtualScrollingHelper.offsetHeight-this._dropDownList.ItemsInnerContainer.offsetHeight)if(!this._virtualScrollingInProgress){this._virtualScrollingInProgress=true;this._loadNextPageOnDemand()}},_clearItems:function(){this._dropDownList.LastHighlightedItem=null;this._dropDownList.options=[];this._sortedItems=[];this._dropDownList.ItemsInnerContainer.innerHTML=""},_loadItemsOnDemandCallback:function(g,f){var a=document.createElement("DIV");a.innerHTML=g;this._hideLoadingIndicator();this.EnableVirtualScrolling&&this._hideVirtualScrollingHelper();if(f.AppendItems)while(a.firstChild.firstChild)this._dropDownList.ItemsInnerContainer.appendChild(a.firstChild.firstChild);else{this._clearItems();this._dropDownList.ItemsInnerContainer.innerHTML=a.firstChild.innerHTML}var d=JSON.parse(a.lastChild.previousSibling.innerHTML);itemsLoadedCount=d.ItemsLoadedCount;itemsCount=d.ItemsCount;var e=0;if(this.EnableVirtualScrolling&&itemsLoadedCount<itemsCount){this._showVirtualScrollingHelper();e=1}if(a.childNodes.length>2&&this.HasFooterTemplate)this._dropDownList.ItemsContainer.childNodes[2].childNodes[1].innerHTML=a.childNodes[1].innerHTML;for(var b=this._itemsLoadedCount;b<this._dropDownList.ItemsInnerContainer.childNodes.length-e;b++){var c=this._dropDownList.ItemsInnerContainer.childNodes[b],i=this._dropDownList.getItemText(c),h=c.lastChild.innerHTML;this._dropDownList.addToOptionsCollection(i,h,-1,true);this._dropDownList.attachItemEventHandlers(c);this._sortedItems.push(b)}this._updateSortedItems();this.options=this._dropDownList.options;if(!f.AppendItems)if(this._lastKeyPressed!=8)this._autoCompleteText();else this._lastTextBeforeAutoComplete=this._dropDownList.TextBox.value;this._itemsLoadedCount=itemsLoadedCount;this._itemsCount=itemsCount;if(this._virtualScrollingInProgress)this._virtualScrollingInProgress=false},_loadItemsOnDemandException:function(){},_showLoadingIndicator:function(){if(this._loadingIndicator==null)this._loadingIndicator=this._dropDownList.ItemsContainer.lastChild;this._loadingIndicator.style.display=""},_hideLoadingIndicator:function(){this._loadingIndicator.style.display="none"},_showVirtualScrollingHelper:function(){this._virtualScrollingHelper=document.createElement("LI");this._virtualScrollingHelper.className="ob_iCboVSH";this._virtualScrollingHelper.innerHTML="&#160;";this._virtualScrollingHelper.style.height=this._dropDownList.ItemsInnerContainer.scrollHeight/4+"px";this._dropDownList.ItemsInnerContainer.appendChild(this._virtualScrollingHelper)},_hideVirtualScrollingHelper:function(){if(this._virtualScrollingHelper!=null){this._dropDownList.ItemsInnerContainer.removeChild(this._virtualScrollingHelper);this._virtualScrollingHelper=null}},_updateSortedItems:function(){var b=true,d=0;while(b){b=false;for(var a=0;a<this._sortedItems.length-d-1;a++){var c=this._dropDownList.options;if(c[this._sortedItems[a]].text.toLowerCase()>c[this._sortedItems[a+1]].text.toLowerCase()){var e=this._sortedItems[a];this._sortedItems[a]=this._sortedItems[a+1];this._sortedItems[a+1]=e;b=true}}d++}},_openDetail:function(){var b=this._dropDownList.ItemsContainer.style.top,a=parseInt(this._dropDownList.ItemsContainer.style.left)+this._dropDownList.ItemsContainer.offsetWidth+"px";this.Detail._dropDownList.open({x:a,y:b});this._preventDetailLoading=false},_populateDetail:function(){if(!this._preventDetailLoading||this.Mode==2){this.Detail._clearDetailHierarchy();window.setTimeout(this._core.createDelegate(this,this._sendDetailAjaxRequest),10)}},_sendDetailAjaxRequest:function(){this._dropDownList._selectedIndex!=-1&&this.Detail._sendAjaxRequest(this.value(),false)},_clearDetailHierarchy:function(){this._clearItems();this.Detail&&this.Detail._clearDetailHierarchy()},_closeDetail:function(){this.Detail._dropDownList.close();this._preventDetailLoading=true},_closeMaster:function(){this.Master._dropDownList.close()},attachResizeHandler:function(){this._dropDownList.attachResizeHandler()},getItemByIndex:function(a){return this._dropDownList.ItemsInnerContainer.childNodes[a]},selectedIndex:function(a){return this._dropDownList.selectedIndex(a)},value:function(a){return this._dropDownList.value(a)},setValue:function(c,a,b){return this._dropDownList.value(c,a,b)},setText:function(a,b,c){this._currentCustomText=a;return this._dropDownList.setText(a,b,c)},enable:function(){this._dropDownList.enable()},disable:function(){this._dropDownList.disable()},open:function(){this._dropDownList.open()},close:function(){this._dropDownList.close()},focus:function(a){if(a)this._preventOpenOnFocus=true;this._dropDownList.focus()}};var oboutComboBoxJSLoaded=true;try{if(Sys)Sys.Application&&Sys.Application.notifyScriptLoaded()}catch(o_L){};