function JCAdminTitleSearch(e){var t=this;this.arParams={AJAX_PAGE:e.AJAX_PAGE,CONTAINER_ID:e.CONTAINER_ID,INPUT_ID:e.INPUT_ID,MIN_QUERY_LEN:parseInt(e.MIN_QUERY_LEN)};if(e.WAIT_IMAGE)this.arParams.WAIT_IMAGE=e.WAIT_IMAGE;if(e.MIN_QUERY_LEN<=0)e.MIN_QUERY_LEN=1;this.cache=[];this.cache_key=null;this.startText="";this.currentRow=-1;this.RESULT=null;this.CONTAINER=null;this.INPUT=null;this.WAIT=null;this.Hide=function(){t.RESULT.style.display="none";t.RESULT.innerHTML="";t.currentRow=-1;t.UnSelectAll();BX.removeClass(t.INPUT.parentNode,"adm-header-search-block-active-popup")};this.ShowResult=function(e){this.AdjustResult();if(e!=null){t.RESULT.innerHTML=e;setTimeout(this.AdjustResult,50)}if(t.RESULT.innerHTML.length>0){t.RESULT.style.display="block";BX.addClass(t.INPUT.parentNode,"adm-header-search-block-active-popup")}else{this.Hide()}};this.AdjustResult=function(e){var s=BX.pos(t.CONTAINER);s.width=s.right-s.left;t.RESULT.style.position="absolute";t.RESULT.style.top="4px";t.RESULT.style.left=s.left-7+"px";t.RESULT.style.width=s.width+14+"px"};this.onKeyPress=function(e){var s=BX.findChild(t.RESULT,{tag:"table",class:"adm-search-result"},true);if(!s)return false;var a=s.rows.length;switch(e){case 27:t.Hide();return true;case 40:if(t.RESULT.style.display=="none")t.RESULT.style.display="block";var i=-1;for(var n=0;n=0;n--){if(r==-1)r=n;if(t.currentRow>n){t.currentRow=n;break}else if(s.rows[n].className=="adm-search-selected"){s.rows[n].className=""}}if(n<0)t.currentRow=r;s.rows[t.currentRow].className="adm-search-selected";return true;case 13:if(t.RESULT.style.display=="block"){for(var n=0;n=t.arParams.MIN_QUERY_LEN){t.oldValue=t.INPUT.value;t.cache_key=t.arParams.INPUT_ID+"|"+t.INPUT.value;if(t.cache[t.cache_key]==null){if(t.WAIT){var e=BX.pos(t.INPUT);var s=e.bottom-e.top-2;t.WAIT.style.top=e.top+1+"px";t.WAIT.style.height=s+"px";t.WAIT.style.width=s+"px";t.WAIT.style.left=e.right-s+2+"px";t.WAIT.style.display="block"}BX.ajax.post(t.arParams.AJAX_PAGE,{ajax_call:"y",INPUT_ID:t.arParams.INPUT_ID,q:t.INPUT.value},function(e){t.cache[t.cache_key]=e;t.ShowResult(e);t.currentRow=-1;t.EnableMouseEvents();if(t.WAIT)t.WAIT.style.display="none";setTimeout(t.onTimeout,500)})}else{t.ShowResult(t.cache[t.cache_key]);t.currentRow=-1;t.EnableMouseEvents();setTimeout(t.onTimeout,500)}}else{t.Hide();setTimeout(t.onTimeout,500)}}else{setTimeout(t.onTimeout,500)}};this.UnSelectAll=function(){var e=BX.findChild(t.RESULT,{tag:"table",class:"adm-search-result"},true);if(e){var s=e.rows.length;for(var a=0;a