var g_typeAheadTextChangeTimer=null;function isTypeaheadDivShowing(e){return"none"!==e.style.display}function setInvalidTextClass(e,t){var a=e.className,n="invalidTextField";t?a.indexOf(n)<0&&(a=trim(a+" "+n)):a=trim(a.replace(n,"")),e.className=a}function updateTypeaheadTextboxValidation(e){var t,a,e=e.typeaheadDiv;e.typeAheadConfigParams&&e.typeAheadConfigParams.forceMatchItem&&(t=(a=getObj(e.typeAheadConfigParams.formId)||0)[e.typeAheadConfigParams.textFieldName]||0,e=a[e.typeAheadConfigParams.idFieldName]||0,a=t.value||"",e.value||!a.length||t.form&&t.form.ignoreFieldValue&&t.form.ignoreFieldValue.value==a?setInvalidTextClass(t,0):setInvalidTextClass(t,1))}function hideTypeAheadDiv(){var e=getObj("typeAheadDiv"),t=0;return e&&(updateTypeaheadTextboxValidation({typeaheadDiv:e}),t=isTypeaheadDivShowing(e),e.scrollTop=0,e.ignoreBlur=!1,e.typeAheadConfigParams=null,e.innerHTML="",e.style.display="none"),t}function hideTypeAheadDivIfNotTypeAheadDiv(e){var t,a=(getObj("typeAheadDiv")||{}).typeAheadConfigParams;a&&(t=!0,t=(a=(getObj(a.formId)||{})[a.textFieldName])?e!=a:t)&&hideTypeAheadDiv()}function fireTypeAheadOnChangeIfNecessary(params_){var objTextControl=params_.textField,tmpUseAsynchForOnChange=params_.useAsynchForOnChange,strOnChangeFunction=objTextControl.getAttribute("mjttypeaheadonchange");strOnChangeFunction&&(tmpUseAsynchForOnChange?setTimeout(function(){eval(unescape(strOnChangeFunction))},0):eval(unescape(strOnChangeFunction)))}function handleExplicitTypeAheadSelection(e){var t,a,n,o,i,e=(e=e||{}).resultOptions,d=!1,r=getObj("typeAheadDiv");return r&&(a=(t=r.typeAheadConfigParams)?t.fnHandleExplicitSelection:null,n=t?t.fnHandleExplicitSelectionP:null,o={},a||n)&&("undefined"!=typeof r.selectedRowIndex&&null!==r.selectedRowIndex&&-1'+(o?o+a:"No matches found")+"";return e&&t&&e.showAdditionalLastRow&&(n+=t),n+=""}function processTypeAheadSearchTextArray(e,t,a,n,o,i,d,r,s){var l=getObj("typeAheadDiv"),h=l.typeAheadConfigParams;if(h){l.onmousedown=mousedownOnTypeahead,l.onblur=blurTypeahead,l.ignoreBlur=!1,l.selectedRowIndex=-1;var c=getObj(h.formId);if(c){var p=c[h.textFieldName],y=c[h.idFieldName],u=y?y.value:null,m=0',I=p.value,b=s||h.ignoreCurrentTextForBold?"":I,F=0,w=[];for(l.itemCount=e.length,mjtElemData(l,"arrTypeaheadRowVals",w),f=0;f"):(S=S.split(":"),D=(w[f]=S)[n],O=S[o],R=unescape(O),!T&&R&&R.toLowerCase()==I.toLowerCase()&&(j=unescape(D),P=y&&j==u,!A||!P&&g||(y&&(y.value=j),T=T||P,g=!0,l.selectedRowIndex=F)),j=null!=i&&-1",j&&(D+=''),D+=''+htmlEncode(P)+""+htmlEncode(R),j&&(D+=""),D+="",-1",d"),C+=D+="",++F)}a&&(C+='"+(" There are more items"+(b?' starting with "'+htmlEncode(b)+'"':""))+""),C+="",l.style.display="none",l.style.zIndex=501,l.innerHTML=C,g&&A&&((v=getObj("typeAheadRow"+l.selectedRowIndex)).className="typeAheadSelectedRow",v.setAttribute("mjtclass","typeAheadSelectedRow"),fireTypeAheadOnChangeIfNecessary({textField:p,useAsynchForOnChange:!1})),setTimeout(doPositionPicker,0)}else m?(s=getNoMatchFoundHtml(h),l.style.display="none",l.style.zIndex=501,l.innerHTML=s,setTimeout(doPositionPicker,0)):(mjtElemData(l,"arrTypeaheadRowVals",null),hideTypeAheadDiv(),t&&fireTypeAheadOnChangeIfNecessary({textField:p,useAsynchForOnChange:!1}))}else ConsoleLogging.logBlockClose("no Form! looking for formId="+h.formId)}}function rsCallbackGetTypeAheadSearchText(e,t,a){var n,o=getObj("typeAheadDiv").typeAheadConfigParams;o&&(o.expectedContextId&&t&&o.expectedContextId!==t?ConsoleLogging.logMessage("TypeAheadPopup: expected to receive callback from ContextId="+o.expectedContextId+", but instead received callback from ContextId="+t):checkResponseForError(e)&&(o=trim(e)?(n="1"==e.substring(0,1),(e=e.substring(2)).split(",")):[],t="undefined"!=typeof a.extraHTMLColumnIndex&&null!==a.extraHTMLColumnIndex?a.extraHTMLColumnIndex:-1,processTypeAheadSearchTextArray(o,!1,n,0,1,"undefined"!=typeof a.isInactiveColumnIndex&&null!==a.isInactiveColumnIndex?a.isInactiveColumnIndex:-1,t,"undefined"!=typeof a.inactiveMeansCompleteColumnIndex&&null!==a.inactiveMeansCompleteColumnIndex?a.inactiveMeansCompleteColumnIndex:-1,a.forceIgnoreCurrentTextForBold?1:0)))}function taGetItemIndexFromTypeAheadRowChildElem(e){var t=null,e=checkAttribute(e,"data-mjtTAIdx");return t=e?parseInt(e.getAttribute("data-mjtTAIdx"),10):t}function processTypeAheadSearchOfJSONArray(e){var t=getObj("typeAheadDiv"),a=t.typeAheadConfigParams;if(a){t.onmousedown=mousedownOnTypeahead,t.onblur=blurTypeahead,t.ignoreBlur=!1,t.selectedRowIndex=-1;var n=getObj(a.formId);if(n){var o=n[a.textFieldName],i=n[a.idFieldName],d=i?i.value:null,r=0',f=o.value,x=e.forceIgnoreCurrentTextForBold||a.ignoreCurrentTextForBold?"":f,v=0,C=(t.itemCount=y.length,[]);for(mjtElemData(t,"arrTypeaheadRowVals",C),e.additionalFirstRowHtml&&(A+=e.additionalFirstRowHtml),m=0;m"):(O=(C[v]=P).id,j=P.name,!P||O||j||""===O||""===j||(j=O=P),!l&&j&&j.toLowerCase()==f.toLowerCase()&&(I=i&&O==d,!h||!I&&s||(i&&(i.value=O),l=l||I,s=!0,t.selectedRowIndex=v)),I=P.isInactive,b=P.inactiveMeansComplete,F=j.substring(0,x.length),w=j.substring(x.length),R="',O=!!p&&P[p],j=c&&P[c]||"",(j=c?'"+(j||"")+"":j)&&O&&(R+=j),R+="",I&&(R+=''),R+=''+htmlEncode(F)+""+htmlEncode(w),I&&(R+=" ("+(b?"Complete":"Inactive")+")"),R+="",j&&!O&&(R+=j),A+=R+="",++v)}e.areMoreItems&&(A+='"+(" There are more items"+(x?' starting with "'+htmlEncode(x)+'"':""))+""),a&&e.additionalLastRowHtml&&a.showAdditionalLastRow&&(A+=e.additionalLastRowHtml),A+="",t.style.display="none",t.style.zIndex=501,t.innerHTML=A,s&&h&&((T=getObj("typeAheadRow"+t.selectedRowIndex)).className="typeAheadSelectedRow",T.setAttribute("mjtclass","typeAheadSelectedRow"),fireTypeAheadOnChangeIfNecessary({textField:o,useAsynchForOnChange:!1})),e.fnPostProcessTypeaheadDisplay&&e.fnPostProcessTypeaheadDisplay({typeaheadDiv:t,arrObjects:y}),setTimeout(doPositionPicker,0)}else r?(T=getNoMatchFoundHtml(a,e.additionalLastRowHtml,e.originalPayload,e.fnNoMessagePostfix),t.style.display="none",t.style.zIndex=501,t.innerHTML=T,setTimeout(doPositionPicker,0)):(mjtElemData(t,"arrTypeaheadRowVals",null),hideTypeAheadDiv(),u&&fireTypeAheadOnChangeIfNecessary({textField:o,useAsynchForOnChange:!1}))}else ConsoleLogging.logBlockClose("No Form! looking for formId="+a.formId)}}function rsCallbackGetTypeAheadSearchTextJSON(e,t){var a=t.originalOptions,n=t.originalPayload,o=t.contextId,i=(getObj("typeAheadDiv")||{}).typeAheadConfigParams,d=e[a.arrayPropertyName||"array"],r=a.fnPreprocessArray,s=a.fnPreprocessObject,n=(n||{}).term||"",e=e.isMore;i&&(i.expectedContextId&&o&&i.expectedContextId!==o?ConsoleLogging.logMessage("TypeAheadPopup: expected to receive json-callback from ContextId="+i.expectedContextId+", but instead received callback from ContextId="+o):(r&&r({arrItems:d,searchTerm:n}),s&&d&&d.forEach(function(e){s(e)}),processTypeAheadSearchOfJSONArray({extraHTMLPropertyName:a.extraHTMLPropertyName,renderExtraOnTheLeftPropertyName:a.renderExtraOnTheLeftPropertyName,forceIgnoreCurrentTextForBold:a.forceIgnoreCurrentTextForBold,arrObjects:d,areMoreItems:e,fnPostProcessTypeaheadDisplay:a.fnPostProcessTypeaheadDisplay,additionalLastRowHtml:a.additionalLastRowHtml,additionalFirstRowHtml:a.additionalFirstRowHtml,originalPayload:t.originalPayload,fnNoMessagePostfix:a.fnNoMessagePostfix})))}function updateTypeAheadBoxTimerFired(){var e,t,a=getObj("typeAheadDiv").typeAheadConfigParams;a&&((e=getObj(a.formId))[a.textFieldName]||console.log('\n\n!!!!\nCan not find text field for type-ahead.\n configParams.textFieldName="'+a.textFieldName+'"\n!!!!'),0!==(t=e[a.textFieldName].value.toLowerCase()).length||a.showTypeAheadWhenUnmatched?a.fnGetTypeAheadData&&a.fnGetTypeAheadData(e,t,a,a.getTypeAheadDataFnParameter):processTypeAheadSearchTextArray([],!0,!1,0,1))}function getSelectedTypeAheadRow(e){return e&&"undefined"==typeof e.selectedRowIndex?e.selectedRowIndex:-1}function handleTypeAheadTextBoxBlur(e,t){var a=getObj("typeAheadDiv");a&&!a.ignoreBlur&&hideTypeAheadDiv()}function fireAsynchHandleTypeAheadTextChange(){g_typeAheadTextChangeTimer&&clearTimeout(g_typeAheadTextChangeTimer);var e=300;getObj("typeAheadDiv").typeAheadConfigParams.forceImmediatePopup&&(e=0),g_typeAheadTextChangeTimer=setTimeout(updateTypeAheadBoxTimerFired,e)}function handleTypeAheadTextBoxFocus(e,t,a){var n=getObj("typeAheadDiv");n.ignoreBlur=!1,!n.ignoreFocus&&(n.typeAheadConfigParams=a,n=getObj(a.formId)[a.idFieldName],a.forceTypeAheadOnFocus||a.showTypeAheadWhenUnmatched&&!n.value.length)&&fireAsynchHandleTypeAheadTextChange()}function incrementTypeAheadSelectionIndex(e){var t=getObj("typeAheadDiv"),a=t.itemCount||0;removeTypeAheadSelectionOrHoverHighlight(!1),"undefined"==typeof t.selectedRowIndex?selectTypeAheadItem(0,!1):(t=parseInt(t.selectedRowIndex,10),e?t++:--t,selectTypeAheadItem(t=(t=a<=t?a-1:t)<0?0:t,!1))}function selectFirstLastInTypeahead(e,t,a){isTypeaheadDivShowing(e)&&(e=e.itemCount||0)&&selectTypeAheadItem(a?0:e-1,!1,!1)}function pageTypeAheadIfNecessary(e,t,a){if(isTypeaheadDivShowing(e)){for(var n=e.itemCount||0,o=e.selectedRowIndex||0,i=0,d=n-1,r=e.scrollTop,s=r+e.clientHeight-1,l=0;l=h.offsetTop&&r+h.offsetHeight/2