Error Info from INTER-Mediator

============ERROR MESSAGE on Sun May 25 2025 21:02:32 GMT+0000 (Coordinated Universal Time)============
Unexpected token '/', "/*
* INTE"... is not valid JSON - Connection Error in db_query=SyntaxError: Unexpected token '/', "/*
* INTE"... is not valid JSON//*
* INTER-Mediator
* Copyright (c) INTER-Mediator Directive Committee (http://inter-mediator.org)
* This project started at the end of 2009 by Masayuki Nii msyk@msyk.net.
*
* INTER-Mediator is supplied under MIT License.
* Please see the full license for details:
* https://github.com/INTER-Mediator/INTER-Mediator/blob/master/dist-docs/License.txt
*/
var INTERMediator={separator:'@',defDivider:'|',defaultTargetInnerHTML:!1,navigationLabel:null,elementIds:[],dontSelectRadioCheck:!1,ignoreOptimisticLocking:!1,additionalFieldValueOnNewRecord:{},additionalFieldValueOnUpdate:{},additionalFieldValueOnDelete:{},waitSecondsAfterPostMessage:4,pagedAllCount:0,totalRecordCount:null,currentEncNumber:0,isIE:!1,isTrident:!1,isEdge:!1,ieVersion:-1,titleAsLinkInfo:!0,classAsLinkInfo:!0,isDBDataPreferable:!1,noRecordClassName:'_im_for_noresult_',rootEnclosure:null,useSessionStorage:!0,partialConstructing:!0,linkedElmCounter:0,pusherObject:null,buttonIdNum:0,masterNodeOriginalDisplay:'block',detailNodeOriginalDisplay:'none',pusherAvailable:!1,dateTimeFunction:!1,postOnlyNumber:1,isTablet:!1,isMobile:!1,crossTableStage:0,eventListenerPostAdding:null,appendingNodesAtLast:null,propertyIETridentSetup:function(){'use strict';var ua,position,c,i;ua=navigator.userAgent;position=ua.toLocaleUpperCase().indexOf('MSIE');if(position>=0){INTERMediator.isIE=!0;for(i=position+4;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+4,i));break}}}
position=ua.indexOf('; Trident/');if(position>=0){INTERMediator.isTrident=!0;for(i=position+10;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+10,i))+4;if(INTERMediator.ieVersion===11){INTERMediator.isIE=!0}
break}}}
position=ua.indexOf(' Edge/');if(position>=0){INTERMediator.isEdge=!0;for(i=position+6;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))||i===ua.length-1){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+6,i));break}}}},propertyW3CUserAgentSetup:function(){'use strict';var u=window.navigator.userAgent.toLowerCase();INTERMediator.isTablet=(u.indexOf('windows')>-1&&u.indexOf('touch')>-1&&u.indexOf('tablet pc')===-1)||u.indexOf('ipad')>-1||(u.indexOf('android')>-1&&u.indexOf('mobile')===-1)||(u.indexOf('firefox')>-1&&u.indexOf('tablet')>-1)||u.indexOf('kindle')>-1||u.indexOf('silk')>-1||u.indexOf('playbook')>-1;INTERMediator.isMobile=(u.indexOf('windows')>-1&&u.indexOf('phone')>-1)||u.indexOf('iphone')>-1||u.indexOf('ipod')>-1||(u.indexOf('android')>-1&&u.indexOf('mobile')>-1)||(u.indexOf('firefox')>-1&&u.indexOf('mobile')>-1)||u.indexOf('blackberry')>-1},initialize:function(){'use strict';INTERMediatorOnPage.removeCookie('_im_localcontext');INTERMediator.additionalCondition={};INTERMediator.additionalSortKey={};INTERMediator.startFrom=0;IMLibLocalContext.archive()},construct:function(indexOfKeyFieldObject){'use strict';var timerTask;if(indexOfKeyFieldObject===!0||indexOfKeyFieldObject===undefined){if(INTERMediatorOnPage.isFinishToConstruct){return}
INTERMediatorOnPage.isFinishToConstruct=!0;timerTask=function(){INTERMediator.constructMain(!0)}}else{timerTask=function(){INTERMediator.constructMain(indexOfKeyFieldObject)}}
setTimeout(timerTask,0)},constructMain:function(updateRequiredContext,recordset){'use strict';var i,theNode,postSetFields=[],radioName={},nameSerial=1,nameAttrCounter=1,imPartsShouldFinished=[],isAcceptNotify=!1,originalNodes,parentNode,sybilingNode;INTERMediator.eventListenerPostAdding=[];if(INTERMediatorOnPage.doBeforeConstruct){INTERMediatorOnPage.doBeforeConstruct()}
if(!INTERMediatorOnPage.isAutoConstruct){return}
INTERMediatorOnPage.showProgress();INTERMediator.crossTableStage=0;INTERMediator.appendingNodesAtLast=[];IMLibEventResponder.setup();INTERMediatorOnPage.retrieveAuthInfo();try{if(Pusher.VERSION){INTERMediator.pusherAvailable=!0;if(!INTERMediatorOnPage.clientNotificationKey){INTERMediatorLog.setErrorMessage(Error('Pusher Configuration Error'),INTERMediatorOnPage.getMessages()[1039]);INTERMediator.pusherAvailable=!1}}}catch(ex){INTERMediator.pusherAvailable=!1;if(INTERMediatorOnPage.clientNotificationKey){INTERMediatorLog.setErrorMessage(Error('Pusher Configuration Error'),INTERMediatorOnPage.getMessages()[1038])}}
try{if(updateRequiredContext===!0||updateRequiredContext===undefined){IMLibPageNavigation.deleteInsertOnNavi=[];INTERMediator.partialConstructing=!1;INTERMediator.buttonIdNum=1;IMLibContextPool.clearAll();pageConstruct()}else{IMLibPageNavigation.deleteInsertOnNavi=[];INTERMediator.partialConstructing=!0;postSetFields=[];try{if(!recordset){updateRequiredContext.removeContext();originalNodes=updateRequiredContext.original;for(i=0;i<originalNodes.length;i++){updateRequiredContext.enclosureNode.appendChild(originalNodes[i].cloneNode(!0))}
seekEnclosureNode(updateRequiredContext.enclosureNode,updateRequiredContext.foreignValue,updateRequiredContext.dependingParentObjectInfo,updateRequiredContext)}else{expandRepeaters(updateRequiredContext,updateRequiredContext.enclosureNode,{recordset:recordset,targetTotalCount:1,targetCount:1})}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-8')}}
for(i=0;i<postSetFields.length;i++){if(postSetFields[i].id&&document.getElementById(postSetFields[i].id)){document.getElementById(postSetFields[i].id).value=postSetFields[i].value}}
IMLibCalc.updateCalculationFields()}}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.hideProgress();INTERMediatorOnPage.authenticating(function(){INTERMediator.constructMain(updateRequiredContext)});INTERMediator.partialConstructing=!0;return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-7');INTERMediator.partialConstructing=!0}}
for(i=0;i<imPartsShouldFinished.length;i++){imPartsShouldFinished[i].finish()}
for(i=0;i<INTERMediator.appendingNodesAtLast.length;i++){theNode=INTERMediator.appendingNodesAtLast[i].targetNode;parentNode=INTERMediator.appendingNodesAtLast[i].parentNode;sybilingNode=INTERMediator.appendingNodesAtLast[i].siblingNode;if(theNode&&parentNode){if(sybilingNode){parentNode.insertBefore(theNode,sybilingNode)}else{parentNode.appendChild(theNode)}}}
for(i=0;i<INTERMediator.eventListenerPostAdding.length;i++){theNode=document.getElementById(INTERMediator.eventListenerPostAdding[i].id);if(theNode){INTERMediatorLib.addEvent(theNode,INTERMediator.eventListenerPostAdding[i].event,INTERMediator.eventListenerPostAdding[i].todo)}}
if(INTERMediatorOnPage.doAfterConstruct){INTERMediatorOnPage.doAfterConstruct()}
IMLibPageNavigation.navigationSetup();INTERMediatorOnPage.isFinishToConstruct=!1;INTERMediator.partialConstructing=!0;INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage();function pageConstruct(){var i,bodyNode,emptyElement;IMLibCalc.calculateRequiredObject={};INTERMediator.currentEncNumber=1;INTERMediator.elementIds=[];bodyNode=document.getElementsByTagName('BODY')[0];if(!INTERMediator.rootEnclosure){INTERMediator.rootEnclosure=bodyNode.innerHTML}else{bodyNode.innerHTML=INTERMediator.rootEnclosure}
postSetFields=[];INTERMediatorOnPage.setReferenceToTheme();IMLibPageNavigation.initializeStepInfo(!1);IMLibLocalContext.bindingDescendant(document.documentElement);try{seekEnclosureNode(bodyNode,null,null,null)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-9')}}
for(i=0;i<postSetFields.length;i++){if(postSetFields[i].value===''&&document.getElementById(postSetFields[i].id).tagName==='SELECT'){emptyElement=document.createElement('option');emptyElement.setAttribute('id',INTERMediator.nextIdValue());emptyElement.setAttribute('value','');emptyElement.setAttribute('data-im-element','auto-generated');document.getElementById(postSetFields[i].id).insertBefore(emptyElement,document.getElementById(postSetFields[i].id).firstChild)}
document.getElementById(postSetFields[i].id).value=postSetFields[i].value}
IMLibCalc.updateCalculationFields();if(isAcceptNotify&&INTERMediator.pusherAvailable){var channelName=INTERMediatorOnPage.clientNotificationIdentifier();var appKey=INTERMediatorOnPage.clientNotificationKey();if(appKey&&appKey!=='_im_key_isnt_supplied'&&!INTERMediator.pusherObject){try{Pusher.log=function(message){if(window.console&&window.console.log){window.console.log(message)}};INTERMediator.pusherObject=new Pusher(appKey);INTERMediator.pusherChannel=INTERMediator.pusherObject.subscribe(channelName);INTERMediator.pusherChannel.bind('update',function(data){IMLibContextPool.updateOnAnotherClient('update',data)});INTERMediator.pusherChannel.bind('create',function(data){IMLibContextPool.updateOnAnotherClient('create',data)});INTERMediator.pusherChannel.bind('delete',function(data){IMLibContextPool.updateOnAnotherClient('delete',data)})}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-47')}}}
appendCredit()}
function seekEnclosureNode(node,currentRecord,parentObjectInfo,currentContextObj){var children,className,i,attr;if(node.nodeType===1){try{if(INTERMediatorLib.isEnclosure(node,!1)){className=INTERMediatorLib.getClassAttributeFromNode(node);attr=node.getAttribute('data-im-control');if((className&&className.match(/_im_post/))||(attr&&attr.indexOf('post')>=0)){setupPostOnlyEnclosure(node)}else{if(INTERMediator.isIE){try{expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}}}else{expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}}}else{children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){seekEnclosureNode(children[i],currentRecord,parentObjectInfo,currentContextObj)}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-10')}}}}
function setupPostOnlyEnclosure(node){var nodes,postNodes;postNodes=INTERMediatorLib.getElementsByClassNameOrDataAttr(node,'_im_post');for(i=0;i<postNodes.length;i++){if(postNodes[i].tagName==='BUTTON'||(postNodes[i].tagName==='INPUT'&&(postNodes[i].getAttribute('type').toLowerCase()==='button'||postNodes[i].getAttribute('type').toLowerCase()==='submit'))){if(!postNodes[i].id){postNodes[i].id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(postNodes[i].id,(function(){var targetNode=postNodes[i];return function(){IMLibUI.clickPostOnlyButton(targetNode)}})())}}
nodes=node.childNodes;for(i=0;i<nodes.length;i++){seekEnclosureInPostOnly(nodes[i])}
function seekEnclosureInPostOnly(node){var children,wInfo,i,target;if(node.nodeType===1){try{target=node.getAttribute('data-im');if(!target){target=node.getAttribute('data-im-group')}
if(target){if(!node.id){node.id='IMPOST-'+INTERMediator.postOnlyNumber;INTERMediator.postOnlyNumber++}
INTERMediatorLib.addEvent(node,'blur',function(){var idValue=node.id;IMLibUI.valueChange(idValue,!0)});if(node.tagName==='INPUT'&&node.getAttribute('type')==='radio'){if(!radioName[target]){radioName[target]='Name-'+nameSerial;nameSerial++}
node.setAttribute('name',radioName[target])}}
if(INTERMediatorLib.isWidgetElement(node)){wInfo=INTERMediatorLib.getWidgetInfo(node);if(wInfo[0]){IMParts_Catalog[wInfo[0]].instanciate(node);if(imPartsShouldFinished.indexOf(IMParts_Catalog[wInfo[0]])<0){imPartsShouldFinished.push(IMParts_Catalog[wInfo[0]])}}}else if(INTERMediatorLib.isEnclosure(node,!1)){expandEnclosure(node,null,null,null)}else{children=node.childNodes;for(i=0;i<children.length;i++){seekEnclosureInPostOnly(children[i])}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-11')}}}}}
function expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj){var recId,repNodeTag,repeatersOriginal;var imControl=node.getAttribute('data-im-control');if(currentContextObj&&currentContextObj.contextName&&currentRecord&&currentRecord[currentContextObj.contextName]&&currentRecord[currentContextObj.contextName][currentContextObj.contextName+'::'+INTERMediatorOnPage.defaultKeyName]){recId=currentRecord[currentContextObj.contextName][currentContextObj.contextName+'::'+INTERMediatorOnPage.defaultKeyName];currentRecord=currentRecord[currentContextObj.contextName][recId]}
if(imControl&&imControl.match(/cross-table/)){expandCrossTableEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}else{repNodeTag=INTERMediatorLib.repeaterTagFromEncTag(node.tagName);repeatersOriginal=collectRepeatersOriginal(node,repNodeTag);enclosureProcessing(node,repeatersOriginal,currentRecord,parentObjectInfo,currentContextObj)}
IMLibLocalContext.bindingDescendant(node);function enclosureProcessing(enclosureNode,repeatersOriginal,currentRecord,parentObjectInfo,currentContextObj,procBeforeRetrieve,customExpandRepeater){var linkedNodes,repeaters,linkDefs,voteResult,currentContextDef,fieldList,i,targetRecords,newNode,keyValue,selectedNode,isExpanding,calcFields,contextObj=null,targetRecordset,ix,keyingValue,footerNodes,headerNodes,nInfo;var tempObj={};repeaters=collectRepeaters(repeatersOriginal);linkedNodes=INTERMediatorLib.seekLinkedAndWidgetNodes(repeaters,!0).linkedNode;linkDefs=collectLinkDefinitions(linkedNodes);voteResult=tableVoting(linkDefs);currentContextDef=voteResult.targettable;INTERMediator.currentEncNumber++;if(!enclosureNode.getAttribute('id')){enclosureNode.setAttribute('id',INTERMediator.nextIdValue())}
if(!currentContextDef){for(i=0;i<repeatersOriginal.length;i++){newNode=enclosureNode.appendChild(repeatersOriginal[i]);if(repeatersOriginal[i].getAttribute('selected')){selectedNode=newNode}
if(selectedNode!==undefined){selectedNode.selected=!0}
seekEnclosureNode(newNode,null,enclosureNode,currentContextObj)}}else{isExpanding=!IMLibPageNavigation.isNotExpandingContext(currentContextDef);contextObj=IMLibContextPool.generateContextObject(currentContextDef,enclosureNode,repeaters,repeatersOriginal);calcFields=contextObj.getCalculationFields();fieldList=voteResult.fieldlist.map(function(elm){if(!calcFields[elm]){calcFields.push(elm)}
return elm});if(currentContextDef.relation&&currentContextDef.relation[0]&&Boolean(currentContextDef.relation[0].portal)===!0){contextObj.isPortal=!0;if(!currentRecord){tempObj=IMLibContextPool.generateContextObject({'name':contextObj.sourceName},enclosureNode,repeaters,repeatersOriginal);if(targetRecords===undefined){targetRecords=retrieveDataForEnclosure(tempObj,fieldList,contextObj.foreignValue)}
recId=targetRecords.recordset[0][INTERMediatorOnPage.defaultKeyName];currentRecord=targetRecords.recordset[0]}}
contextObj.setRelationWithParent(currentRecord,parentObjectInfo,currentContextObj);if(contextObj.isPortal===!0){if(currentRecord){currentContextDef.currentrecord=currentRecord;keyValue=currentRecord[currentContextDef.relation[0]['join-field']]}}
if(procBeforeRetrieve){procBeforeRetrieve(contextObj)}
if(isExpanding){targetRecords=retrieveDataForEnclosure(contextObj,fieldList,contextObj.foreignValue)}else{targetRecords=[];if(enclosureNode.tagName==='TBODY'){enclosureNode.parentNode.style.display='none'}else{enclosureNode.style.display='none'}}
contextObj.storeRecords(targetRecords);callbackForAfterQueryStored(currentContextDef,contextObj);if(customExpandRepeater===undefined){contextObj.registeredId=targetRecords.registeredId;contextObj.nullAcceptable=targetRecords.nullAcceptable;isAcceptNotify|=!(INTERMediatorOnPage.notifySupport===!1);expandRepeaters(contextObj,enclosureNode,targetRecords);IMLibPageNavigation.setupInsertButton(contextObj,keyValue,enclosureNode,contextObj.foreignValue);IMLibPageNavigation.setupBackNaviButton(contextObj,enclosureNode);callbackForEnclosure(currentContextDef,enclosureNode)}else{customExpandRepeater(contextObj,targetRecords)}
contextObj.sequencing=!1;if(enclosureNode.tagName==='TBODY'){footerNodes=enclosureNode.parentNode.getElementsByTagName('TFOOT');linkedNodes=seekWithAttribute(footerNodes[0],'data-im');if(linkedNodes){INTERMediator.setIdValue(footerNodes[0]);targetRecordset={};ix=null;keyingValue='_im_footer';for(i=0;i<linkedNodes.length;i++){nInfo=INTERMediatorLib.getNodeInfoArray(INTERMediatorLib.getLinkedElementInfo(linkedNodes[i])[0]);if(linkedNodes[i]&&currentContextDef.name===nInfo.table){INTERMediator.setIdValue(linkedNodes[i])}
IMLibCalc.updateCalculationInfo(contextObj,keyingValue,linkedNodes[i].id,nInfo,targetRecordset);if(contextObj.binding._im_footer){contextObj.binding._im_footer._im_repeater=footerNodes}}}
headerNodes=enclosureNode.parentNode.getElementsByTagName('THEAD');linkedNodes=seekWithAttribute(headerNodes[0],'data-im');if(linkedNodes){INTERMediator.setIdValue(headerNodes[0]);targetRecordset={};ix=null;keyingValue='_im_header';for(i=0;i<linkedNodes.length;i++){INTERMediator.setIdValue(linkedNodes[i]);nInfo=INTERMediatorLib.getNodeInfoArray(INTERMediatorLib.getLinkedElementInfo(linkedNodes[i])[0]);IMLibCalc.updateCalculationInfo(contextObj,keyingValue,linkedNodes[i].id,nInfo,targetRecordset);if(contextObj.binding._im_header){contextObj.binding._im_header._im_repeater=headerNodes}}}}}
return contextObj}
function seekWithAttribute(node,attrName){if(!node||node.nodeType!==1){return null}
var result=seekWithAttributeImpl(node,attrName);return result}
function seekWithAttributeImpl(node,attrName){var ix,adding,result=[];if(node&&node.nodeType===1){if(node.getAttribute(attrName)){result.push(node)}
if(node.childNodes){for(ix=0;ix<node.childNodes.length;ix++){adding=seekWithAttributeImpl(node.childNodes[ix],attrName);if(adding.length>0){[].push.apply(result,adding)}}}}
return result}
function expandCrossTableEnclosure(node,currentRecord,parentObjectInfo,currentContextObj){var i,j,colArray,rowArray,nodeForKeyValues,record,targetRepeater,lineNode,colContext,rowContext,appendingNode,trNodes,repeaters,linkedNodes,linkDefs,crossCellContext,labelKeyColumn,labelKeyRow;var ctComponentNodes=crossTableComponents(node);if(ctComponentNodes.length!==4){throw 'Exception-xx: Cross Table Components aren\'t prepared.'}
while(node.childNodes.length>0){node.removeChild(node.childNodes[0])}
repeaters=collectRepeaters([ctComponentNodes[3].cloneNode(!0)]);linkedNodes=INTERMediatorLib.seekLinkedAndWidgetNodes(repeaters,!0).linkedNode;linkDefs=collectLinkDefinitions(linkedNodes);crossCellContext=tableVoting(linkDefs).targettable;labelKeyColumn=crossCellContext.relation[0]['join-field'];labelKeyRow=crossCellContext.relation[1]['join-field'];INTERMediator.crossTableStage=1;lineNode=document.createElement('TR');targetRepeater=ctComponentNodes[0].cloneNode(!0);lineNode.appendChild(targetRepeater);node.appendChild(lineNode);targetRepeater=ctComponentNodes[1].cloneNode(!0);colContext=enclosureProcessing(lineNode,[targetRepeater],null,parentObjectInfo,currentContextObj);colArray=colContext.indexingArray(labelKeyColumn);INTERMediator.crossTableStage=2;targetRepeater=ctComponentNodes[2].cloneNode(!0);lineNode=document.createElement('TR');lineNode.appendChild(targetRepeater);rowContext=enclosureProcessing(node,[lineNode],null,parentObjectInfo,currentContextObj);rowArray=rowContext.indexingArray(labelKeyRow);INTERMediator.crossTableStage=3;targetRepeater=ctComponentNodes[3].cloneNode(!0);nodeForKeyValues={};trNodes=node.getElementsByTagName('TR');for(i=1;i<trNodes.length;i+=1){for(j=0;j<colArray.length;j+=1){appendingNode=targetRepeater.cloneNode(!0);trNodes[i].appendChild(appendingNode);INTERMediator.setIdValue(appendingNode);if(!nodeForKeyValues[colArray[j]]){nodeForKeyValues[colArray[j]]={}}
nodeForKeyValues[colArray[j]][rowArray[i-1]]=appendingNode}}
INTERMediator.setIdValue(node);enclosureProcessing(node,[targetRepeater],null,parentObjectInfo,currentContextObj,function(context){var currentContextDef=context.getContextDef();INTERMediator.clearCondition(currentContextDef.name,'_imlabel_crosstable');INTERMediator.addCondition(currentContextDef.name,{field:currentContextDef.relation[0]['foreign-key'],operator:'IN',value:colArray,onetime:!0},undefined,'_imlabel_crosstable');INTERMediator.addCondition(currentContextDef.name,{field:currentContextDef.relation[1]['foreign-key'],operator:'IN',value:rowArray,onetime:!0},undefined,'_imlabel_crosstable')},function(contextObj,targetRecords){var dataKeyColumn,dataKeyRow,currentContextDef,ix,linkedElements,targetNode,keyField,keyValue,keyingValue;currentContextDef=contextObj.getContextDef();keyField=contextObj.getKeyField();dataKeyColumn=currentContextDef.relation[0]['foreign-key'];dataKeyRow=currentContextDef.relation[1]['foreign-key'];if(targetRecords.recordset){for(ix=0;ix<targetRecords.recordset.length;ix++){record=targetRecords.recordset[ix];if(nodeForKeyValues[record[dataKeyColumn]]&&nodeForKeyValues[record[dataKeyColumn]][record[dataKeyRow]]){targetNode=nodeForKeyValues[record[dataKeyColumn]][record[dataKeyRow]];if(targetNode){linkedElements=INTERMediatorLib.seekLinkedAndWidgetNodes([targetNode],!1);keyValue=record[keyField];if(keyField&&!keyValue&&keyValue!==0){keyValue=ix}
keyingValue=keyField+'='+keyValue}
setupLinkedNode(linkedElements,contextObj,targetRecords.recordset,ix,keyingValue)}}}})}
function crossTableComponents(node){var components=[],count=0;repeatCTComponents(node.childNodes);return components;function repeatCTComponents(nodes){var childNodes,i;for(i=0;i<nodes.length;i++){if(nodes[i].nodeType===1&&(nodes[i].tagName==='TH'||nodes[i].tagName==='TD')){components[count]=nodes[i];count+=1}else{childNodes=nodes[i].childNodes;if(childNodes){repeatCTComponents(childNodes)}}}}}}
function setupLinkedNode(linkedElements,contextObj,targetRecordset,ix,keyingValue){var currentWidgetNodes,currentLinkedNodes,nInfo,currentContextDef,j,keyField,k,nodeId,curVal,replacedNode,typeAttr,children,wInfo,nameTable,idValuesForFieldName={},linkInfoArray,nameTableKey,nameNumber,nameAttr,curTarget;currentContextDef=contextObj.getContextDef();try{currentWidgetNodes=linkedElements.widgetNode;currentLinkedNodes=linkedElements.linkedNode;keyField=contextObj.getKeyField();if(targetRecordset[ix]&&(targetRecordset[ix][keyField]||targetRecordset[ix][keyField]===0)){for(k=0;k<currentLinkedNodes.length;k++){nodeId=currentLinkedNodes[k].getAttribute('id');replacedNode=INTERMediator.setIdValue(currentLinkedNodes[k]);typeAttr=replacedNode.getAttribute('type');if(typeAttr==='checkbox'||typeAttr==='radio'){children=replacedNode.parentNode.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1&&children[i].tagName==='LABEL'&&nodeId===children[i].getAttribute('for')){children[i].setAttribute('for',replacedNode.getAttribute('id'));break}}}}
for(k=0;k<currentWidgetNodes.length;k++){wInfo=INTERMediatorLib.getWidgetInfo(currentWidgetNodes[k]);if(wInfo[0]){IMParts_Catalog[wInfo[0]].instanciate(currentWidgetNodes[k]);if(imPartsShouldFinished.indexOf(IMParts_Catalog[wInfo[0]])<0){imPartsShouldFinished.push(IMParts_Catalog[wInfo[0]])}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-101')}}
nameTable={};for(k=0;k<currentLinkedNodes.length;k++){try{nodeId=currentLinkedNodes[k].getAttribute('id');if(INTERMediatorLib.isWidgetElement(currentLinkedNodes[k])){nodeId=currentLinkedNodes[k]._im_getComponentId()}
typeAttr=currentLinkedNodes[k].getAttribute('type');linkInfoArray=INTERMediatorLib.getLinkedElementInfo(currentLinkedNodes[k]);if(typeAttr==='radio'){nameTableKey=linkInfoArray.join('|');if(!nameTable[nameTableKey]){nameTable[nameTableKey]=nameAttrCounter;nameAttrCounter++}
nameNumber=nameTable[nameTableKey];nameAttr=currentLinkedNodes[k].getAttribute('name');if(nameAttr){currentLinkedNodes[k].setAttribute('name',nameAttr+'-'+nameNumber)}else{currentLinkedNodes[k].setAttribute('name','IM-R-'+nameNumber)}}
for(j=0;j<linkInfoArray.length;j++){nInfo=INTERMediatorLib.getNodeInfoArray(linkInfoArray[j]);curVal=targetRecordset[ix][nInfo.field];if(!INTERMediator.isDBDataPreferable||curVal){IMLibCalc.updateCalculationInfo(contextObj,keyingValue,nodeId,nInfo,targetRecordset[ix])}
if(nInfo.table===currentContextDef.name){curTarget=nInfo.target;if(IMLibElement.setValueToIMNode(currentLinkedNodes[k],curTarget,curVal)){postSetFields.push({'id':nodeId,'value':curVal})}
contextObj.setValue(keyingValue,nInfo.field,curVal,nodeId,curTarget);if(idValuesForFieldName[nInfo.field]===undefined){idValuesForFieldName[nInfo.field]=[]}
idValuesForFieldName[nInfo.field].push(nodeId)}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-27')}}}
return idValuesForFieldName}
function expandRepeaters(contextObj,node,targetRecords){var newNode,nodeClass,dataAttr,repeatersOneRec,newlyAddedNodes,encNodeTag,repNodeTag,ix,repeatersOriginal,targetRecordset,targetTotalCount,i,currentContextDef,indexContext,insertNode,countRecord,linkedElements,keyingValue,keyField,keyValue,idValuesForFieldName;encNodeTag=node.tagName;repNodeTag=INTERMediatorLib.repeaterTagFromEncTag(encNodeTag);repeatersOriginal=contextObj.original;currentContextDef=contextObj.getContextDef();targetRecordset=targetRecords.recordset;targetTotalCount=targetRecords.totalCount;repeatersOneRec=cloneEveryNodes(repeatersOriginal);for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}}}
if(targetRecords.count===0){for(i=0;i<repeatersOriginal.length;i++){newNode=repeatersOriginal[i].cloneNode(!0);nodeClass=INTERMediatorLib.getClassAttributeFromNode(newNode);dataAttr=newNode.getAttribute('data-im-control');if((nodeClass&&nodeClass.indexOf(INTERMediator.noRecordClassName)>-1)||(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>-1)){node.appendChild(newNode);INTERMediator.setIdValue(newNode);seekEnclosureNode(newNode,null,null,null)}}}
countRecord=targetRecordset?targetRecordset.length:0;for(ix=0;ix<countRecord;ix++){repeatersOneRec=cloneEveryNodes(repeatersOriginal);linkedElements=INTERMediatorLib.seekLinkedAndWidgetNodes(repeatersOneRec,!0);keyField=contextObj.getKeyField();for(i=0;i<repeatersOneRec.length;i++){INTERMediator.setIdValue(repeatersOneRec[i])}
if(targetRecordset[ix]&&(targetRecordset[ix][keyField]||targetRecordset[ix][keyField]===0)){keyValue=targetRecordset[ix][keyField];if(keyField&&!keyValue&&keyValue!==0){INTERMediatorLog.setErrorMessage('The value of the key field is null.','This No.['+ix+'] record should be ignored.');keyValue=ix}
keyingValue=keyField+'='+keyValue}
idValuesForFieldName=setupLinkedNode(linkedElements,contextObj,targetRecordset,ix,keyingValue);IMLibPageNavigation.setupDeleteButton(encNodeTag,repeatersOneRec,contextObj,keyField,keyValue);IMLibPageNavigation.setupNavigationButton(encNodeTag,repeatersOneRec,currentContextDef,keyField,keyValue,contextObj);IMLibPageNavigation.setupCopyButton(encNodeTag,repNodeTag,repeatersOneRec,contextObj,targetRecordset[ix]);if(!currentContextDef.portal||(!!currentContextDef.portal&&targetTotalCount>0)){newlyAddedNodes=[];insertNode=null;if(!contextObj.sequencing){indexContext=contextObj.checkOrder(targetRecordset[ix]);insertNode=contextObj.getRepeaterEndNode(indexContext+1)}
for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];nodeClass=INTERMediatorLib.getClassAttributeFromNode(newNode);dataAttr=newNode.getAttribute('data-im-control');if(!(nodeClass&&nodeClass.indexOf(INTERMediator.noRecordClassName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)){if(!insertNode){node.appendChild(newNode)}else{insertNode.parentNode.insertBefore(newNode,insertNode)}
newlyAddedNodes.push(newNode);if(!newNode.id){INTERMediator.setIdValue(newNode)}
contextObj.setValue(keyingValue,'_im_repeater','',newNode.id,'',currentContextDef.portal);seekEnclosureNode(newNode,targetRecordset[ix],idValuesForFieldName,contextObj)}}
if((ix+1)!==countRecord){for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}else{insertNode.parentNode.insertBefore(newNode,insertNode)}}}}
callbackForRepeaters(currentContextDef,node,newlyAddedNodes)}
contextObj.rearrangePendingOrder()}
IMLibPageNavigation.setupDetailAreaToFirstRecord(currentContextDef,contextObj);repeatersOneRec=cloneEveryNodes(repeatersOriginal);for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}}}}
function retrieveDataForEnclosure(contextObj,fieldList,relationValue){var targetRecords,recordNumber,useLimit,key,recordset=[];if(Boolean(contextObj.contextDefinition.cache)===!0){targetRecords=retrieveDataFromCache(contextObj.contextDefinition,relationValue)}else if(contextObj.contextDefinition.data){for(key in contextObj.contextDefinition.data){if(contextObj.contextDefinition.data.hasOwnProperty(key)){recordset.push(contextObj.contextDefinition.data[key])}}
targetRecords={'recordset':recordset,'count':recordset.length,'totalCount':recordset.length,'nullAcceptable':!0}}else{try{targetRecords=contextObj.getPortalRecords();if(!targetRecords){useLimit=contextObj.isUseLimit();recordNumber=contextObj.getRecordNumber();targetRecords=INTERMediator_DBAdapter.db_query({'name':contextObj.contextDefinition.name,'records':isNaN(recordNumber)?100000000:recordNumber,'paging':contextObj.contextDefinition.paging,'fields':fieldList,'parentkeyvalue':relationValue,'conditions':null,'useoffset':!0,'uselimit':useLimit})}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-12')}}}
if(contextObj.contextDefinition['appending-data']){for(key in contextObj.contextDefinition['appending-data']){if(contextObj.contextDefinition['appending-data'].hasOwnProperty(key)){targetRecords.recordset.push(contextObj.contextDefinition['appending-data'][key])}}}
return targetRecords}
function retrieveDataFromCache(currentContextDef,relationValue){var targetRecords=null,pagingValue,counter,ix,oneRecord,isMatch,index,keyField,fieldName,recordsValue;try{if(!INTERMediatorOnPage.dbCache[currentContextDef.name]){INTERMediatorOnPage.dbCache[currentContextDef.name]=INTERMediator_DBAdapter.db_query({name:currentContextDef.name,records:null,paging:null,fields:null,parentkeyvalue:null,conditions:null,useoffset:!1})}
if(relationValue===null){targetRecords=INTERMediatorOnPage.dbCache[currentContextDef.name]}else{targetRecords={recordset:[],count:0};counter=0;for(ix in INTERMediatorOnPage.dbCache[currentContextDef.name].recordset){if(INTERMediatorOnPage.dbCache[currentContextDef.name].recordset.hasOwnProperty(ix)){oneRecord=INTERMediatorOnPage.dbCache[currentContextDef.name].recordset[ix];isMatch=!0;index=0;for(keyField in relationValue){if(relationValue.hasOwnProperty(keyField)){fieldName=currentContextDef.relation[index]['foreign-key'];if(oneRecord[fieldName]!==relationValue[keyField]){isMatch=!1;break}
index++}}
if(isMatch){pagingValue=currentContextDef.paging?currentContextDef.paging:!1;recordsValue=currentContextDef.records?currentContextDef.records:10000000000;if(!pagingValue||(pagingValue&&(counter>=INTERMediator.startFrom))){targetRecords.recordset.push(oneRecord);targetRecords.count++;if(recordsValue<=targetRecords.count){break}}
counter++}}}
return targetRecords}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-24')}}}
function callbackForRepeaters(currentContextDef,node,newlyAddedNodes){try{if(INTERMediatorOnPage.additionalExpandingRecordFinish[currentContextDef.name]){INTERMediatorOnPage.additionalExpandingRecordFinish[currentContextDef.name](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.additionalExpandingRecordFinish['+currentContextDef.name+'] with the context.',2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-33: hint: post-repeater of '+currentContextDef.name)}}
try{if(INTERMediatorOnPage.expandingRecordFinish){INTERMediatorOnPage.expandingRecordFinish(currentContextDef.name,newlyAddedNodes);INTERMediatorLog.setDebugMessage('Call INTERMediatorOnPage.expandingRecordFinish with the context: '+currentContextDef.name,2)}
if(currentContextDef['post-repeater']){INTERMediatorOnPage[currentContextDef['post-repeater']](newlyAddedNodes);INTERMediatorLog.setDebugMessage('Call the post repeater method INTERMediatorOnPage.'+currentContextDef['post-repeater']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-23')}}}
function callbackForEnclosure(currentContextDef,node){try{if(INTERMediatorOnPage.additionalExpandingEnclosureFinish[currentContextDef.name]){INTERMediatorOnPage.additionalExpandingEnclosureFinish[currentContextDef.name](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.additionalExpandingEnclosureFinish['+currentContextDef.name+'] with the context.',2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-32: hint: post-enclosure of '+currentContextDef.name)}}
try{if(INTERMediatorOnPage.expandingEnclosureFinish){INTERMediatorOnPage.expandingEnclosureFinish(currentContextDef.name,node);INTERMediatorLog.setDebugMessage('Call INTERMediatorOnPage.expandingEnclosureFinish with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-21')}}
try{if(currentContextDef['post-enclosure']){INTERMediatorOnPage[currentContextDef['post-enclosure']](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.'+currentContextDef['post-enclosure']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-22: hint: post-enclosure of '+currentContextDef.name)}}}
function callbackForAfterQueryStored(currentContextDef,context){try{if(currentContextDef['post-query-stored']){INTERMediatorOnPage[currentContextDef['post-query-stored']](context);INTERMediatorLog.setDebugMessage('Call the post query stored method INTERMediatorOnPage.'+currentContextDef['post-enclosure']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-41: hint: post-query-stored of '+currentContextDef.name)}}}
function collectRepeatersOriginal(node,repNodeTag){var i,repeatersOriginal=[],children,imControl;children=node.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(children[i].tagName===repNodeTag){repeatersOriginal.push(children[i])}else if(!repNodeTag&&(children[i].getAttribute('data-im-control'))){imControl=children[i].getAttribute('data-im-control');if(imControl.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>-1){repeatersOriginal.push(children[i])}}else if(!repNodeTag&&INTERMediatorLib.getClassAttributeFromNode(children[i])&&INTERMediatorLib.getClassAttributeFromNode(children[i]).match(/_im_repeater/)){imControl=INTERMediatorLib.getClassAttributeFromNode(children[i]);if(imControl.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>-1){repeatersOriginal.push(children[i])}}}}
return repeatersOriginal}
function collectRepeaters(repeatersOriginal){var i,repeaters=[],inDocNode,parentOfRep,cloneNode;for(i=0;i<repeatersOriginal.length;i++){inDocNode=repeatersOriginal[i];parentOfRep=repeatersOriginal[i].parentNode;cloneNode=repeatersOriginal[i].cloneNode(!0);repeaters.push(cloneNode);cloneNode.setAttribute('id',INTERMediator.nextIdValue());if(parentOfRep){parentOfRep.removeChild(inDocNode)}}
return repeaters}
function collectLinkDefinitions(linkedNodes){var linkDefs=[],nodeDefs,j,k;for(j=0;j<linkedNodes.length;j++){nodeDefs=INTERMediatorLib.getLinkedElementInfo(linkedNodes[j]);if(nodeDefs){for(k=0;k<nodeDefs.length;k++){linkDefs.push(nodeDefs[k])}}}
return linkDefs}
function tableVoting(linkDefs){var j,nodeInfoArray,nodeInfoField,nodeInfoTable,maxVoted,maxTableName,tableName,nodeInfoTableIndex,context,restDefs=[],tableVote=[],fieldList=[];for(j=0;j<linkDefs.length;j++){nodeInfoArray=INTERMediatorLib.getNodeInfoArray(linkDefs[j]);nodeInfoField=nodeInfoArray.field;nodeInfoTable=nodeInfoArray.table;nodeInfoTableIndex=nodeInfoArray.tableindex;if(nodeInfoTable!=IMLibLocalContext.contextName){if(nodeInfoField&&nodeInfoField.length!==0&&nodeInfoTable&&nodeInfoTable.length!==0){if(!fieldList[nodeInfoTableIndex]){fieldList[nodeInfoTableIndex]=[]}
fieldList[nodeInfoTableIndex].push(nodeInfoField);if(!tableVote[nodeInfoTableIndex]){tableVote[nodeInfoTableIndex]=1}else{++tableVote[nodeInfoTableIndex]}}else{INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1006,[linkDefs[j]]))}}}
maxVoted=-1;maxTableName='';for(tableName in tableVote){if(tableVote.hasOwnProperty(tableName)){if(maxVoted<tableVote[tableName]){maxVoted=tableVote[tableName];maxTableName=tableName.substring(10)}}}
context=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',maxTableName);if(linkDefs.length>0&&!context){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1046,[maxTableName]))}
for(j=0;j<linkDefs.length;j++){if(linkDefs[j].indexOf(maxTableName)!==0&&linkDefs[j].indexOf('_@')!==0){restDefs.push(linkDefs[j])}}
if(linkDefs.length>0&&context&&restDefs.length>0){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1047,[maxTableName,restDefs.toString()]))}
return{targettable:context,fieldlist:fieldList['_im_index_'+maxTableName]}}
function cloneEveryNodes(originalNodes){var i,clonedNodes=[];for(i=0;i<originalNodes.length;i++){clonedNodes.push(originalNodes[i].cloneNode(!0))}
return clonedNodes}
function getEnclosedNode(rootNode,tableName,fieldName){var i,j,nodeInfo,nInfo,children,r;if(rootNode.nodeType===1){nodeInfo=INTERMediatorLib.getLinkedElementInfo(rootNode);for(j=0;j<nodeInfo.length;j++){nInfo=INTERMediatorLib.getNodeInfoArray(nodeInfo[j]);if(nInfo.table===tableName&&nInfo.field===fieldName){return rootNode}}}
children=rootNode.childNodes;for(i=0;i<children.length;i++){r=getEnclosedNode(children[i],tableName,fieldName);if(r){return r}}
return null}
function appendCredit(){var bodyNode,creditNode,cNode,spNode,aNode,versionString;if(document.getElementById('IM_CREDIT')===null){if(INTERMediatorOnPage.creditIncluding){bodyNode=document.getElementById(INTERMediatorOnPage.creditIncluding)}
if(!bodyNode){bodyNode=document.getElementsByTagName('BODY')[0]}
creditNode=document.createElement('div');bodyNode.appendChild(creditNode);creditNode.setAttribute('id','IM_CREDIT');creditNode.setAttribute('class','IM_CREDIT');cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#F6F7FF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#EBF1FF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#E1EAFF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.setAttribute('align','right');cNode.style.backgroundColor='#D7E4FF';cNode.style.padding='2px';cNode.style.margin='0';cNode.style.padding='0';spNode=document.createElement('span');cNode.appendChild(spNode);cNode.style.color='#666666';cNode.style.fontSize='7pt';aNode=document.createElement('a');aNode.appendChild(document.createTextNode('INTER-Mediator'));aNode.setAttribute('href','http://inter-mediator.com/');aNode.setAttribute('target','_href');spNode.appendChild(document.createTextNode('Generated by '));spNode.appendChild(aNode);if(INTERMediatorOnPage.metadata){versionString=' Ver.'+INTERMediatorOnPage.metadata.version+'('+INTERMediatorOnPage.metadata.releasedate+')'}else{versionString=' Ver. Development Now!'}
spNode.appendChild(document.createTextNode(versionString))}}},setIdValue:function(node){'use strict';var i,elementInfo,comp,overwrite=!0;if(node.getAttribute('id')===null){node.setAttribute('id',INTERMediator.nextIdValue())}else{if(INTERMediator.elementIds.indexOf(node.getAttribute('id'))>=0){elementInfo=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<elementInfo.length;i++){comp=elementInfo[i].split(INTERMediator.separator);if(comp[2]==='#id'){overwrite=!1}}
if(overwrite){node.setAttribute('id',INTERMediator.nextIdValue())}}
INTERMediator.elementIds.push(node.getAttribute('id'))}
return node},nextIdValue:function(){'use strict';INTERMediator.linkedElmCounter++;return currentIdValue();function currentIdValue(){return'IM'+INTERMediator.currentEncNumber+'-'+INTERMediator.linkedElmCounter}},getLocalProperty:function(localKey,defaultValue){'use strict';var value;value=IMLibLocalContext.getValue(localKey);return value===null?defaultValue:value},setLocalProperty:function(localKey,value){'use strict';IMLibLocalContext.setValue(localKey,value,!0)},addCondition:function(contextName,condition,notMatching,label){'use strict';var value,i,hasIdentical;if(notMatching){condition.matching=!notMatching}else{condition.matching=INTERMediator_DBAdapter.eliminateDuplicatedConditions}
if(label){condition.label=label}
if(INTERMediator.additionalCondition){value=INTERMediator.additionalCondition;if(condition){if(!value[contextName]){value[contextName]=[]}
if(!condition.matching){value[contextName].push(condition)}else{hasIdentical=!1;for(i=0;i<value[contextName].length;i++){if(value[contextName][i].field===condition.field&&value[contextName][i].operator===condition.operator){hasIdentical=!0;value[contextName][i].value=condition.value;break}}
if(!hasIdentical){value[contextName].push(condition)}}}
INTERMediator.additionalCondition=value}
IMLibLocalContext.archive()},clearCondition:function(contextName,label){'use strict';var i,value=INTERMediator.additionalCondition;if(label===undefined){if(value[contextName]){delete value[contextName];INTERMediator.additionalCondition=value;IMLibLocalContext.archive()}}else{if(value[contextName]){for(i=0;i<value[contextName].length;i++){if(value[contextName][i].label===label){value[contextName].splice(i,1);i--}}
INTERMediator.additionalCondition=value;IMLibLocalContext.archive()}}},addSortKey:function(contextName,sortKey){'use strict';var value=INTERMediator.additionalSortKey;if(value[contextName]){value[contextName].push(sortKey)}else{value[contextName]=[sortKey]}
INTERMediator.additionalSortKey=value;IMLibLocalContext.archive()},clearSortKey:function(contextName){'use strict';var value=INTERMediator.additionalSortKey;if(value[contextName]){delete value[contextName];INTERMediator.additionalSortKey=value;IMLibLocalContext.archive()}},setRecordLimit:function(contextName,limit){'use strict';var value=INTERMediator.recordLimit;value[contextName]=limit;INTERMediator.recordLimit=value;IMLibLocalContext.archive()},clearRecordLimit:function(contextName){'use strict';var value=INTERMediator.recordLimit;if(value[contextName]){delete value[contextName];INTERMediator.recordLimit=value;IMLibLocalContext.archive()}},flushMessage:function(){'use strict';INTERMediatorLog.flushMessage()},setErrorMessage:function(ex,moreMessage){'use strict';INTERMediatorLog.setErrorMessage(ex,moreMessage)},setDebugMessage:function(message,level){'use strict';INTERMediatorLog.setDebugMessage(message,level)}};if(!Object.keys){Object.keys=function(obj){'use strict';var results=[],prop;if(obj!==Object(obj)){throw new TypeError('Object.keys called on a non-object')}
for(prop in obj){if(Object.prototype.hasOwnProperty.call(obj,prop)){results.push(prop)}}
return results}}
if(!Array.indexOf){var isWebkit='WebkitAppearance' in document.documentElement.style;if(!isWebkit){Array.prototype.indexOf=function(target){'use strict';var i;for(i=0;i<this.length;i++){if(this[i]===target){return i}}
return-1}}}
if(typeof String.prototype.trim!=='function'){String.prototype.trim=function(){'use strict';return this.replace(/^\s+|\s+$/g,'')}}
var INTERMediatorOnPage={authCountLimit:4,authCount:0,authUser:'',authHashedPassword:'',authCryptedPassword:'',authUserSalt:'',authUserHexSalt:'',authChallenge:'',requireAuthentication:!1,clientId:null,authRequiredContext:null,authStoring:'cookie',authExpired:3600,isOnceAtStarting:!0,publickey:null,isNativeAuth:!1,httpuser:null,httppasswd:null,mediaToken:null,realm:'',dbCache:{},isEmailAsUsername:!1,passwordPolicy:null,creditIncluding:null,masterScrollPosition:null,nonSupportMessageId:'nonsupportmessage',isFinishToConstruct:!1,isAutoConstruct:!0,isShowChangePassword:!0,isSetDefaultStyle:!1,authPanelTitle:null,isOAuthAvailable:!1,oAuthClientID:null,oAuthClientSecret:null,oAuthBaseURL:null,oAuthRedirect:null,oAuthScope:null,additionalExpandingEnclosureFinish:{},additionalExpandingRecordFinish:{},getEditorPath:null,getEntryPath:null,getIMRootPath:null,getDataSources:null,getOptionsAliases:null,getOptionsTransaction:null,dbClassName:null,defaultKeyName:null,browserCompatibility:null,clientNotificationIdentifier:null,metadata:null,isLDAP:null,appLocale:null,localeInfo:{mon_decimal_point:'.',mon_thousands_sep:',',currency_symbol:'¥'},appCurrency:null,isShowProgress:!0,clearCredentials:function(){'use strict';INTERMediatorOnPage.authChallenge=null;INTERMediatorOnPage.authHashedPassword=null;INTERMediatorOnPage.authCryptedPassword=null},getMessages:function(){'use strict';return null},getURLParametersAsArray:function(){'use strict';var i,params,eqPos,result,key,value;result={};params=location.search.substring(1).split('&');for(i=0;i<params.length;i++){eqPos=params[i].indexOf('=');if(eqPos>0){key=params[i].substring(0,eqPos);value=params[i].substring(eqPos+1);result[key]=decodeURIComponent(value)}}
return result},getContextInfo:function(contextName){'use strict';var dataSources,index;dataSources=INTERMediatorOnPage.getDataSources();for(index in dataSources){if(dataSources.hasOwnProperty(index)&&dataSources[index].name===contextName){return dataSources[index]}}
return null},isComplementAuthData:function(){'use strict';return INTERMediatorOnPage.authUser!==null&&INTERMediatorOnPage.authUser.length>0&&INTERMediatorOnPage.authHashedPassword!==null&&INTERMediatorOnPage.authHashedPassword.length>0&&INTERMediatorOnPage.authUserSalt!==null&&INTERMediatorOnPage.authUserSalt.length>0&&INTERMediatorOnPage.authChallenge!==null&&INTERMediatorOnPage.authChallenge.length>0},retrieveAuthInfo:function(){'use strict';if(INTERMediatorOnPage.requireAuthentication){if(INTERMediatorOnPage.isOnceAtStarting){switch(INTERMediatorOnPage.authStoring){case 'cookie':case 'cookie-domainwide':INTERMediatorOnPage.authUser=INTERMediatorOnPage.getCookie('_im_username');INTERMediatorOnPage.authHashedPassword=INTERMediatorOnPage.getCookie('_im_credential');INTERMediatorOnPage.mediaToken=INTERMediatorOnPage.getCookie('_im_mediatoken');INTERMediatorOnPage.authCryptedPassword=INTERMediatorOnPage.getCookie('_im_crypted');break;case 'session-storage':INTERMediatorOnPage.authUser=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_username');INTERMediatorOnPage.authHashedPassword=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_credential');INTERMediatorOnPage.mediaToken=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_mediatoken');INTERMediatorOnPage.authCryptedPassword=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_crypted');break;default:INTERMediatorOnPage.removeCookie('_im_username');INTERMediatorOnPage.removeCookie('_im_credential');INTERMediatorOnPage.removeCookie('_im_mediatoken');INTERMediatorOnPage.removeCookie('_im_crypted');break}
INTERMediatorOnPage.isOnceAtStarting=!1}
if(INTERMediatorOnPage.authUser.length>0){if(!INTERMediator_DBAdapter.getChallenge()){INTERMediatorLog.flushMessage()}}}},logout:function(){'use strict';INTERMediatorOnPage.authUser='';INTERMediatorOnPage.authHashedPassword='';INTERMediatorOnPage.authCryptedPassword='';INTERMediatorOnPage.authUserSalt='';INTERMediatorOnPage.authChallenge='';INTERMediatorOnPage.clientId='';INTERMediatorOnPage.removeCredencialsFromCookieOrStorage();INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_localcontext')},storeSessionStorageWithFallDown:function(key,value){'use strict';if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{sessionStorage.setItem(INTERMediatorOnPage.getKeyWithRealm(key),value)}catch(ex){INTERMediatorOnPage.setCookie(key,value)}}else{INTERMediatorOnPage.setCookie(key,value)}},getSessionStorageWithFallDown:function(key){'use strict';var value;if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{value=sessionStorage.getItem(INTERMediatorOnPage.getKeyWithRealm(key));value=value?value:''}catch(ex){value=INTERMediatorOnPage.getCookie(key)}}else{value=INTERMediatorOnPage.getCookie(key)}
return value},removeFromSessionStorageWithFallDown:function(key){'use strict';if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{sessionStorage.removeItem(INTERMediatorOnPage.getKeyWithRealm(key))}catch(ex){INTERMediatorOnPage.removeCookie(key)}}else{INTERMediatorOnPage.removeCookie(key)}},removeCredencialsFromCookieOrStorage:function(){'use strict';switch(INTERMediatorOnPage.authStoring){case 'cookie':case 'cookie-domainwide':INTERMediatorOnPage.removeCookie('_im_username');INTERMediatorOnPage.removeCookie('_im_credential');INTERMediatorOnPage.removeCookie('_im_mediatoken');INTERMediatorOnPage.removeCookie('_im_crypted');break;case 'session-storage':INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_username');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_credential');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_mediatoken');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_crypted');break}},storeCredentialsToCookieOrStorage:function(){'use strict';switch(INTERMediatorOnPage.authStoring){case 'cookie':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.setCookie('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.setCookie('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.setCookie('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.setCookie('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break;case 'cookie-domainwide':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.setCookieDomainWide('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.setCookieDomainWide('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.setCookieDomainWide('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.setCookieDomainWide('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break;case 'session-storage':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break}},loginPanelHTML:null,authenticating:function(doAfterAuth,doTest){'use strict';var bodyNode,backBox,frontPanel,labelWidth,userLabel,userSpan,userBox,msgNumber,passwordLabel,passwordSpan,passwordBox,breakLine,chgpwButton,authButton,panelTitle,newPasswordLabel,newPasswordSpan,newPasswordBox,newPasswordMessage,realmBox,keyCode,messageNode,oAuthButton,addingButton,resetMessage;var encrypt=new JSEncrypt();this.checkPasswordPolicy=function(newPassword,userName,policyString){var terms,i,message=[],minLen;if(!policyString){return message}
terms=policyString.split(/[\s,]/);for(i=0;i<terms.length;i++){switch(terms[i].toUpperCase()){case 'USEALPHABET':if(!newPassword.match(/[A-Za-z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2015))}
break;case 'USENUMBER':if(!newPassword.match(/[0-9]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2016))}
break;case 'USEUPPER':if(!newPassword.match(/[A-Z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2017))}
break;case 'USELOWER':if(!newPassword.match(/[a-z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2018))}
break;case 'USEPUNCTUATION':if(!newPassword.match(/[^A-Za-z0-9]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2019))}
break;case 'NOTUSERNAME':if(newPassword===userName){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2020))}
break;default:if(terms[i].toUpperCase().indexOf('LENGTH')===0){minLen=terms[i].match(/[0-9]+/)[0];if(newPassword.length<minLen){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2021,[minLen]))}}}}
return message};if(doTest){return}
if(INTERMediatorOnPage.authCount>INTERMediatorOnPage.authCountLimit){INTERMediatorOnPage.authenticationError();INTERMediatorOnPage.logout();INTERMediatorLog.flushMessage();return}
bodyNode=document.getElementsByTagName('BODY')[0];backBox=document.createElement('div');backBox.id='_im_authpback';bodyNode.insertBefore(backBox,bodyNode.childNodes[0]);if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.height='100%';backBox.style.width='100%';backBox.style.backgroundImage='url('+INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=background.gif)';backBox.style.position='absolute';backBox.style.padding=' 50px 0 0 0';backBox.style.top='0';backBox.style.left='0';backBox.style.zIndex='999998'}
if(INTERMediatorOnPage.loginPanelHTML){backBox.innerHTML=INTERMediatorOnPage.loginPanelHTML;passwordBox=document.getElementById('_im_password');userBox=document.getElementById('_im_username');authButton=document.getElementById('_im_authbutton');chgpwButton=document.getElementById('_im_changebutton');oAuthButton=document.getElementById('_im_oauthbutton')}else{frontPanel=document.createElement('div');if(INTERMediatorOnPage.isSetDefaultStyle){frontPanel.style.width='450px';frontPanel.style.backgroundColor='#333333';frontPanel.style.color='#DDDDAA';frontPanel.style.margin='50px auto 0 auto';frontPanel.style.padding='20px';frontPanel.style.borderRadius='10px';frontPanel.style.position='relative'}
frontPanel.id='_im_authpanel';backBox.appendChild(frontPanel);panelTitle='';if(INTERMediatorOnPage.authPanelTitle&&INTERMediatorOnPage.authPanelTitle.length>0){panelTitle=INTERMediatorOnPage.authPanelTitle}else if(INTERMediatorOnPage.realm&&INTERMediatorOnPage.realm.length>0){panelTitle=INTERMediatorOnPage.realm}
if(panelTitle&&panelTitle.length>0){realmBox=document.createElement('DIV');realmBox.appendChild(document.createTextNode(panelTitle));realmBox.id='_im_authrealm';frontPanel.appendChild(realmBox);breakLine=document.createElement('HR');frontPanel.appendChild(breakLine)}
labelWidth='100px';userLabel=document.createElement('LABEL');frontPanel.appendChild(userLabel);userSpan=document.createElement('span');if(INTERMediatorOnPage.isSetDefaultStyle){userSpan.style.minWidth=labelWidth;userSpan.style.textAlign='right';userSpan.style.cssFloat='left'}
INTERMediatorLib.setClassAttributeToNode(userSpan,'_im_authlabel');userLabel.appendChild(userSpan);msgNumber=INTERMediatorOnPage.isEmailAsUsername?2011:2002;userSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(msgNumber)));userBox=document.createElement('INPUT');userBox.type='text';userBox.id='_im_username';userBox.size='20';userBox.setAttribute('autocapitalize','off');userLabel.appendChild(userBox);breakLine=document.createElement('BR');breakLine.clear='all';frontPanel.appendChild(breakLine);passwordLabel=document.createElement('LABEL');frontPanel.appendChild(passwordLabel);passwordSpan=document.createElement('SPAN');if(INTERMediatorOnPage.isSetDefaultStyle){passwordSpan.style.minWidth=labelWidth;passwordSpan.style.textAlign='right';passwordSpan.style.cssFloat='left'}
INTERMediatorLib.setClassAttributeToNode(passwordSpan,'_im_authlabel');passwordLabel.appendChild(passwordSpan);passwordSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2003)));passwordBox=document.createElement('INPUT');passwordBox.type='password';passwordBox.id='_im_password';passwordBox.size='20';passwordLabel.appendChild(passwordBox);authButton=document.createElement('BUTTON');authButton.id='_im_authbutton';authButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2004)));frontPanel.appendChild(authButton);breakLine=document.createElement('BR');breakLine.clear='all';frontPanel.appendChild(breakLine);newPasswordMessage=document.createElement('DIV');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordMessage.style.textAlign='center';newPasswordMessage.style.textSize='10pt';newPasswordMessage.style.color='#994433'}
newPasswordMessage.id='_im_login_message';frontPanel.appendChild(newPasswordMessage);if(this.isShowChangePassword&&!INTERMediatorOnPage.isNativeAuth){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);newPasswordLabel=document.createElement('LABEL');frontPanel.appendChild(newPasswordLabel);newPasswordSpan=document.createElement('SPAN');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordSpan.style.minWidth=labelWidth;newPasswordSpan.style.textAlign='right';newPasswordSpan.style.cssFloat='left';newPasswordSpan.style.fontSize='0.7em';newPasswordSpan.style.paddingTop='4px'}
INTERMediatorLib.setClassAttributeToNode(newPasswordSpan,'_im_authlabel_pwchange');newPasswordLabel.appendChild(newPasswordSpan);newPasswordSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2006)));newPasswordBox=document.createElement('INPUT');newPasswordBox.type='password';newPasswordBox.id='_im_newpassword';newPasswordBox.size='12';newPasswordLabel.appendChild(newPasswordBox);chgpwButton=document.createElement('BUTTON');chgpwButton.id='_im_changebutton';chgpwButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2005)));frontPanel.appendChild(chgpwButton);newPasswordMessage=document.createElement('DIV');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordMessage.style.textAlign='center';newPasswordMessage.style.textSize='10pt';newPasswordMessage.style.color='#994433'}
newPasswordMessage.id='_im_newpass_message';frontPanel.appendChild(newPasswordMessage)}
if(this.isOAuthAvailable){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);oAuthButton=document.createElement('BUTTON');oAuthButton.id='_im_oauthbutton';oAuthButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2014)));frontPanel.appendChild(oAuthButton)}
if(INTERMediatorOnPage.enrollPageURL){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);addingButton=document.createElement('BUTTON');addingButton.id='_im_enrollbutton';addingButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2022)));addingButton.onclick=function(){location.href=INTERMediatorOnPage.enrollPageURL};frontPanel.appendChild(addingButton)}
if(INTERMediatorOnPage.resetPageURL){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);addingButton=document.createElement('BUTTON');addingButton.id='_im_resetbutton';addingButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2023)));addingButton.onclick=function(){location.href=INTERMediatorOnPage.resetPageURL};frontPanel.appendChild(addingButton);resetMessage=document.createElement('div');resetMessage.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2024)));frontPanel.appendChild(resetMessage)}}
passwordBox.onkeydown=function(event){keyCode=(window.event)?window.event.which:event.keyCode;if(keyCode===13){authButton.onclick()}};userBox.value=INTERMediatorOnPage.authUser;userBox.onkeydown=function(event){keyCode=(window.event)?window.event.which:event.keyCode;if(keyCode===13){passwordBox.focus()}};authButton.onclick=function(){var inputUsername,inputPassword,challengeResult,messageNode;messageNode=document.getElementById('_im_newpass_message');if(messageNode){INTERMediatorLib.removeChildNodes(messageNode)}
inputUsername=document.getElementById('_im_username').value;inputPassword=document.getElementById('_im_password').value;if(inputUsername===''||inputPassword===''){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2013)));return}
INTERMediatorOnPage.authUser=inputUsername;bodyNode.removeChild(backBox);if(inputUsername!==''&&(INTERMediatorOnPage.authChallenge===null||INTERMediatorOnPage.authChallenge.length<24)){INTERMediatorOnPage.authHashedPassword='need-hash-pls';challengeResult=INTERMediator_DBAdapter.getChallenge();if(!challengeResult){INTERMediatorLog.flushMessage();return}}
encrypt.setPublicKey(INTERMediatorOnPage.publickey);INTERMediatorOnPage.authCryptedPassword=encrypt.encrypt(inputPassword);INTERMediatorOnPage.authHashedPassword=SHA1(inputPassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt;if(INTERMediatorOnPage.authUser.length>0){INTERMediatorOnPage.storeCredentialsToCookieOrStorage()}
doAfterAuth();INTERMediatorLog.flushMessage()};if(chgpwButton){var checkPolicyMethod=this.checkPasswordPolicy;chgpwButton.onclick=function(){var inputUsername,inputPassword,inputNewPassword,result,messageNode,message;messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode=document.getElementById('_im_newpass_message');INTERMediatorLib.removeChildNodes(messageNode);inputUsername=document.getElementById('_im_username').value;inputPassword=document.getElementById('_im_password').value;inputNewPassword=document.getElementById('_im_newpassword').value;if(inputUsername===''||inputPassword===''||inputNewPassword===''){messageNode=document.getElementById('_im_newpass_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2007)));return}
message=checkPolicyMethod(inputNewPassword,inputUsername,INTERMediatorOnPage.passwordPolicy);if(message.length>0){messageNode.appendChild(document.createTextNode(message.join(', ')));return}
result=INTERMediator_DBAdapter.changePassword(inputUsername,inputPassword,inputNewPassword);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(result?2009:2010)));INTERMediatorLog.flushMessage()}}
if(this.isOAuthAvailable&&oAuthButton){oAuthButton.onclick=function(){var authURL;INTERMediatorOnPage.setCookieDomainWide('_im_oauth_backurl',location.href,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_realm',INTERMediatorOnPage.realm,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_expired',INTERMediatorOnPage.authExpired,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_storing',INTERMediatorOnPage.authStoring,!0);authURL=INTERMediatorOnPage.oAuthBaseURL+'?scope='+encodeURIComponent(INTERMediatorOnPage.oAuthScope)+'&redirect_uri='+encodeURIComponent(INTERMediatorOnPage.oAuthRedirect)+'&response_type=code'+'&client_id='+encodeURIComponent(INTERMediatorOnPage.oAuthClientID);location.href=authURL}}
if(INTERMediatorOnPage.publickeysize<2048){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2025)))}else if(INTERMediatorOnPage.authCount>0){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2012)))}
window.scroll(0,0);userBox.focus();INTERMediatorOnPage.authCount++},authenticationError:function(){'use strict';var bodyNode,backBox,frontPanel;INTERMediatorOnPage.hideProgress();bodyNode=document.getElementsByTagName('BODY')[0];backBox=document.createElement('div');backBox.id='_im_autherrorback';bodyNode.insertBefore(backBox,bodyNode.childNodes[0]);if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.height='100%';backBox.style.width='100%';if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.backgroundImage='url('+INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=background-error.gif)'}
backBox.style.position='absolute';backBox.style.padding=' 50px 0 0 0';backBox.style.top='0';backBox.style.left='0';backBox.style.zIndex='999999'}
frontPanel=document.createElement('div');frontPanel.id='_im_autherrormessage';if(INTERMediatorOnPage.isSetDefaultStyle){frontPanel.style.width='240px';frontPanel.style.backgroundColor='#333333';frontPanel.style.color='#DD6666';frontPanel.style.fontSize='16pt';frontPanel.style.margin='50px auto 0 auto';frontPanel.style.padding='20px 4px 20px 4px';frontPanel.style.borderRadius='10px';frontPanel.style.position='relatvie';frontPanel.style.textAlign='Center'}
frontPanel.onclick=function(){bodyNode.removeChild(backBox)};backBox.appendChild(frontPanel);frontPanel.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2001)))},INTERMediatorCheckBrowser:function(deleteNode){'use strict';var positiveList,matchAgent,matchOS,versionStr,agent,os,judge=!1,specifiedVersion,versionNum,agentPos=-1,dotPos,bodyNode,elm,childElm,grandChildElm,i;positiveList=INTERMediatorOnPage.browserCompatibility();matchAgent=!1;matchOS=!1;if(positiveList.edge&&navigator.userAgent.indexOf('Edge/')>-1){positiveList={'edge':positiveList.edge}}else if(positiveList.trident&&navigator.userAgent.indexOf('Trident/')>-1){positiveList={'trident':positiveList.trident}}else if(positiveList.msie&&navigator.userAgent.indexOf('MSIE ')>-1){positiveList={'msie':positiveList.msie}}else if(positiveList.opera&&(navigator.userAgent.indexOf('Opera/')>-1||navigator.userAgent.indexOf('OPR/')>-1)){positiveList={'opera':positiveList.opera,'opr':positiveList.opera}}
for(agent in positiveList){if(positiveList.hasOwnProperty(agent)){if(navigator.userAgent.toUpperCase().indexOf(agent.toUpperCase())>-1){matchAgent=!0;if(positiveList[agent]instanceof Object){for(os in positiveList[agent]){if(positiveList[agent].hasOwnProperty(os)&&navigator.platform.toUpperCase().indexOf(os.toUpperCase())>-1){matchOS=!0;versionStr=positiveList[agent][os];break}}}else{matchOS=!0;versionStr=positiveList[agent];break}}}}
if(matchAgent&&matchOS){specifiedVersion=parseInt(versionStr,10);if(navigator.appVersion.indexOf('Edge/')>-1){agentPos=navigator.appVersion.indexOf('Edge/')+5}else if(navigator.appVersion.indexOf('Trident/')>-1){agentPos=navigator.appVersion.indexOf('Trident/')+8}else if(navigator.appVersion.indexOf('MSIE ')>-1){agentPos=navigator.appVersion.indexOf('MSIE ')+5}else if(navigator.appVersion.indexOf('OPR/')>-1){agentPos=navigator.appVersion.indexOf('OPR/')+4}else if(navigator.appVersion.indexOf('Opera/')>-1){agentPos=navigator.appVersion.indexOf('Opera/')+6}else if(navigator.appVersion.indexOf('Chrome/')>-1){agentPos=navigator.appVersion.indexOf('Chrome/')+7}else if(navigator.appVersion.indexOf('Safari/')>-1&&navigator.appVersion.indexOf('Version/')>-1){agentPos=navigator.appVersion.indexOf('Version/')+8}else if(navigator.userAgent.indexOf('Firefox/')>-1){agentPos=navigator.userAgent.indexOf('Firefox/')+8}else if(navigator.appVersion.indexOf('WebKit/')>-1){agentPos=navigator.appVersion.indexOf('WebKit/')+7}
if(agentPos>-1){if(navigator.userAgent.indexOf('Firefox/')>-1){dotPos=navigator.userAgent.indexOf('.',agentPos);versionNum=parseInt(navigator.userAgent.substring(agentPos,dotPos),10)}else{dotPos=navigator.appVersion.indexOf('.',agentPos);versionNum=parseInt(navigator.appVersion.substring(agentPos,dotPos),10)}}else{dotPos=navigator.appVersion.indexOf('.');versionNum=parseInt(navigator.appVersion.substring(0,dotPos),10)}
if(INTERMediator.isTrident){specifiedVersion=specifiedVersion+4}
if(versionStr.indexOf('-')>-1){judge=(specifiedVersion>=versionNum);if(document.documentMode){judge=(specifiedVersion>=document.documentMode)}}else if(versionStr.indexOf('+')>-1){judge=(specifiedVersion<=versionNum);if(document.documentMode){judge=(specifiedVersion<=document.documentMode)}}else{judge=(specifiedVersion===versionNum);if(document.documentMode){judge=(specifiedVersion===document.documentMode)}}}
if(judge===!0){if(deleteNode){deleteNode.parentNode.removeChild(deleteNode)}}else{bodyNode=document.getElementsByTagName('BODY')[0];elm=document.createElement('div');elm.setAttribute('align','center');childElm=document.createElement('font');childElm.setAttribute('color','gray');grandChildElm=document.createElement('font');grandChildElm.setAttribute('size','+2');grandChildElm.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[1022]));childElm.appendChild(grandChildElm);childElm.appendChild(document.createElement('br'));childElm.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[1023]));childElm.appendChild(document.createElement('br'));childElm.appendChild(document.createTextNode(navigator.userAgent));elm.appendChild(childElm);for(i=bodyNode.childNodes.length-1;i>=0;i--){bodyNode.removeChild(bodyNode.childNodes[i])}
bodyNode.appendChild(elm)}
return judge},getNodeIdFromIMDefinition:function(imDefinition,fromNode,justFromNode){'use strict';console.error('INTERMediatorOnPage.getNodeIdFromIMDefinition method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'The alternative method is getNodeIdsHavingTargetFromNode or getNodeIdsHavingTargetFromRepeater.');var repeaterNode;if(justFromNode){repeaterNode=fromNode}else{repeaterNode=INTERMediatorLib.getParentRepeater(fromNode)}
return seekNode(repeaterNode,imDefinition);function seekNode(node,imDefinition){var children,i,nodeDefs,returnValue;if(node.nodeType!==1){return null}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[i])){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs.indexOf(imDefinition)>-1){returnValue=children[i].getAttribute('id');return returnValue}}
returnValue=seekNode(children[i],imDefinition);if(returnValue!==null){return returnValue}}}}
return null}},getNodeIdFromIMDefinitionOnEnclosure:function(imDefinition,fromNode){'use strict';console.error('INTERMediatorOnPage.getNodeIdFromIMDefinitionOnEnclosure method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'The alternative method is getNodeIdsHavingTargetFromEnclosure.');var repeaterNode;repeaterNode=INTERMediatorLib.getParentEnclosure(fromNode);return seekNode(repeaterNode,imDefinition);function seekNode(node,imDefinition){var children,i,nodeDefs,returnValue;if(node.nodeType!==1){return null}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[i])){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs.indexOf(imDefinition)>-1&&children[i].getAttribute){returnValue=children[i].getAttribute('id');return returnValue}}
returnValue=seekNode(children[i],imDefinition);if(returnValue!==null){return returnValue}}}}
return null}},getNodeIdsFromIMDefinition:function(imDefinition,fromNode,justFromNode){'use strict';var enclosureNode,nodeIds=[],i,j;if(justFromNode===!0){enclosureNode=[fromNode]}else if(justFromNode===!1){enclosureNode=[INTERMediatorLib.getParentEnclosure(fromNode)]}else{enclosureNode=INTERMediatorLib.getParentRepeaters(fromNode)}
if(!enclosureNode){return[]}
for(i=0;i<enclosureNode.length;i+=1){if(enclosureNode[i]!==null){if(Array.isArray(enclosureNode[i])){for(j=0;j<enclosureNode[i].length;j++){seekNode(enclosureNode[i][j],imDefinition)}}else{seekNode(enclosureNode[i],imDefinition)}}}
return nodeIds;function seekNode(node,imDefinition){var children,i,nodeDefs;if(node.nodeType!==1){return}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs&&nodeDefs.indexOf(imDefinition)>-1){if(children[i].getAttribute('id')){nodeIds.push(children[i].getAttribute('id'))}else{nodeIds.push(children[i])}}}
seekNode(children[i],imDefinition)}}}},getNodeIdsHavingTargetFromNode:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,!0)},getNodeIdsHavingTargetFromRepeater:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,'others')},getNodeIdsHavingTargetFromEnclosure:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,!1)},getKeyWithRealm:function(str){'use strict';if(INTERMediatorOnPage.realm.length>0){return str+'_'+INTERMediatorOnPage.realm}
return str},getCookie:function(key){'use strict';var s,i,targetKey;s=document.cookie.split('; ');targetKey=this.getKeyWithRealm(key);for(i=0;i<s.length;i++){if(s[i].indexOf(targetKey+'=')===0){return decodeURIComponent(s[i].substring(s[i].indexOf('=')+1))}}
return''},removeCookie:function(key){'use strict';document.cookie=this.getKeyWithRealm(key)+'=; path=/; max-age=0; expires=Thu, 1-Jan-1900 00:00:00 GMT;';document.cookie=this.getKeyWithRealm(key)+'=; max-age=0; expires=Thu, 1-Jan-1900 00:00:00 GMT;'},setCookie:function(key,val){'use strict';this.setCookieWorker(this.getKeyWithRealm(key),val,!1,INTERMediatorOnPage.authExpired)},setCookieDomainWide:function(key,val,noRealm){'use strict';var realKey;realKey=(noRealm===!0)?key:this.getKeyWithRealm(key);this.setCookieWorker(realKey,val,!0,INTERMediatorOnPage.authExpired)},setCookieWorker:function(key,val,isDomain,expired){'use strict';var cookieString;var d=new Date();d.setTime(d.getTime()+expired*1000);cookieString=key+'='+encodeURIComponent(val)+(isDomain?';path=/':'')+';';if(expired>0){cookieString+='max-age='+expired+';expires='+d.toUTCString()+';'}
if(document.URL.substring(0,8)==='https://'){cookieString+='secure;'}
document.cookie=cookieString},hideProgress:function(){'use strict';if(!INTERMediatorOnPage.isShowProgress){return}
var frontPanel,themeName;frontPanel=document.getElementById('_im_progress');if(frontPanel){themeName=INTERMediatorOnPage.getTheme().toLowerCase();if(themeName==='least'||themeName==='thosedays'){frontPanel.style.display='none'}else{frontPanel.style.transitionDuration='0.3s';frontPanel.style.opacity=0;frontPanel.style.zIndex=-9999}}},showProgress:function(){'use strict';if(!INTERMediatorOnPage.isShowProgress){return}
var brNode,bodyNode,frontPanel,imageProgress,imageIM,themeName=INTERMediatorOnPage.getTheme().toLowerCase();frontPanel=document.getElementById('_im_progress');if(!frontPanel){frontPanel=document.createElement('div');frontPanel.setAttribute('id','_im_progress');bodyNode=document.getElementsByTagName('BODY')[0];if(bodyNode.firstChild){bodyNode.insertBefore(frontPanel,bodyNode.firstChild)}else{bodyNode.appendChild(frontPanel)}
if(themeName==='least'||themeName==='thosedays'){imageIM=document.createElement('img');imageIM.setAttribute('id','_im_logo');imageIM.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=logo.gif');frontPanel.appendChild(imageIM);imageProgress=document.createElement('img');imageProgress.setAttribute('id','_im_animatedimage');imageProgress.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=inprogress.gif');frontPanel.appendChild(imageProgress);brNode=document.createElement('BR');brNode.setAttribute('clear','all');frontPanel.appendChild(brNode);frontPanel.appendChild(document.createTextNode('INTER-Mediator working'))}else{imageIM=document.createElement('img');imageIM.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=gears.svg');frontPanel.appendChild(imageIM)}}
if(themeName!=='least'&&themeName!=='thosedays'){frontPanel.style.transitionDuration='0';frontPanel.style.opacity=1.0;frontPanel.style.display='flex';frontPanel.style.zIndex=9999}},setReferenceToTheme:function(){'use strict';var headNode,linkElement,i,styleIndex=-1;headNode=document.getElementsByTagName('HEAD')[0];linkElement=document.createElement('link');linkElement.setAttribute('href',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=css');linkElement.setAttribute('rel','stylesheet');linkElement.setAttribute('type','text/css');for(i=0;i<headNode.childNodes.length;i++){if(headNode.childNodes[i]&&headNode.childNodes[i].nodeType===1&&headNode.childNodes[i].tagName==='LINK'&&headNode.childNodes[i].rel==='stylesheet'){styleIndex=i;break}}
if(styleIndex>-1){headNode.insertBefore(linkElement,headNode.childNodes[styleIndex])}else{headNode.appendChild(linkElement)}}};var IMLibContextPool={poolingContexts:null,clearAll:function(){'use strict';this.poolingContexts=null},registerContext:function(context){'use strict';if(this.poolingContexts===null){this.poolingContexts=[context]}else{this.poolingContexts.push(context)}},excludingNode:null,synchronize:function(context,recKey,key,value,target,portal){'use strict';var i,j,viewName,refNode,targetNodes,result=[],calcKey;viewName=context.viewName;if(this.poolingContexts===null){return null}
if(portal){for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].viewName===viewName&&this.poolingContexts[i].binding[recKey]!==undefined&&this.poolingContexts[i].binding[recKey][key]!==undefined&&this.poolingContexts[i].binding[recKey][key][portal]!==undefined&&this.poolingContexts[i].store[recKey]!==undefined&&this.poolingContexts[i].store[recKey][key]!==undefined&&this.poolingContexts[i].store[recKey][key][portal]!==undefined){this.poolingContexts[i].store[recKey][key][portal]=value;targetNodes=this.poolingContexts[i].binding[recKey][key][portal];for(j=0;j<targetNodes.length;j++){refNode=document.getElementById(targetNodes[j].id);if(refNode){IMLibElement.setValueToIMNode(refNode,targetNodes[j].target,value,!0);result.push(targetNodes[j].id)}}}}}else{for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].viewName===viewName&&this.poolingContexts[i].binding[recKey]!==undefined&&this.poolingContexts[i].binding[recKey][key]!==undefined&&this.poolingContexts[i].store[recKey]!==undefined&&this.poolingContexts[i].store[recKey][key]!==undefined){this.poolingContexts[i].store[recKey][key]=value;targetNodes=this.poolingContexts[i].binding[recKey][key];for(j=0;j<targetNodes.length;j++){refNode=document.getElementById(targetNodes[j].id);calcKey=targetNodes[j].id;if(targetNodes[j].target&&targetNodes[j].target.length>0){calcKey+=INTERMediator.separator+targetNodes[j].target}
if(refNode&&!(calcKey in IMLibCalc.calculateRequiredObject)){IMLibElement.setValueToIMNode(refNode,targetNodes[j].target,value,!0);result.push(targetNodes[j].id)}}}}}
return result},getContextInfoFromId:function(idValue,target){'use strict';var i,targetContext,element,linkInfo,nodeInfo,targetName,result=null;if(!idValue){return result}
element=document.getElementById(idValue);if(!element){return result}
linkInfo=INTERMediatorLib.getLinkedElementInfo(element);if(!linkInfo&&INTERMediatorLib.isWidgetElement(element.parentNode)){linkInfo=INTERMediatorLib.getLinkedElementInfo(element.parentNode)}
nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);targetName=target?target:'_im_no_target';if(this.poolingContexts===null){return null}
for(i=0;i<this.poolingContexts.length;i++){targetContext=this.poolingContexts[i];if(targetContext.contextInfo[idValue]&&targetContext.contextInfo[idValue][targetName]&&targetContext.contextInfo[idValue][targetName].context.contextName===nodeInfo.table){result=targetContext.contextInfo[idValue][targetName];return result}}
return null},getKeyFieldValueFromId:function(idValue,target){'use strict';var contextInfo=this.getContextInfoFromId(idValue,target);if(!contextInfo){return null}
var contextName=contextInfo.context.contextName;var contextDef=IMLibContextPool.getContextDef(contextName);if(!contextDef){return null}
var keyField=contextDef.key?contextDef.key:'id';return contextInfo.record.substr(keyField.length+1)},updateContext:function(idValue,target){'use strict';var contextInfo,value;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,target);value=IMLibElement.getValueFromIMNode(document.getElementById(idValue));if(contextInfo){contextInfo.context.setValue(contextInfo.record,contextInfo.field,value,!1,target,contextInfo.portal)}},getContextFromEnclosure:function(enclosureNode){'use strict';var i;for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].enclosureNode===enclosureNode){return this.poolingContexts[i]}}},contextFromEnclosureId:function(idValue){'use strict';var i,enclosure;if(!idValue){return!1}
for(i=0;i<this.poolingContexts.length;i++){enclosure=this.poolingContexts[i].enclosureNode;if(enclosure.getAttribute('id')===idValue){return this.poolingContexts[i]}}
return null},contextFromName:function(cName){'use strict';var i;if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName){return this.poolingContexts[i]}}
return null},getContextFromName:function(cName){'use strict';var i,result=[];if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName){result.push(this.poolingContexts[i])}}
return result},getContextsFromNameAndForeignValue:function(cName,fValue,parentKeyField){'use strict';var i,result=[];if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName&&this.poolingContexts[i].foreignValue[parentKeyField]===fValue){result.push(this.poolingContexts[i])}}
return result},dependingObjects:function(idValue){'use strict';var i,j,result=[];if(!idValue){return!1}
for(i=0;i<this.poolingContexts.length;i++){for(j=0;j<this.poolingContexts[i].dependingObject.length;j++){if(this.poolingContexts[i].dependingObject[j]===idValue){result.push(this.poolingContexts[i])}}}
return result.length===0?!1:result},getChildContexts:function(parentContext){'use strict';var i,childContexts=[];for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].parentContext===parentContext){childContexts.push(this.poolingContexts[i])}}
return childContexts},childContexts:null,removeContextsFromPool:function(contexts){'use strict';var i,regIds=[],delIds=[];for(i=0;i<this.poolingContexts.length;i++){if(contexts.indexOf(this.poolingContexts[i])>-1){regIds.push(this.poolingContexts[i].registeredId);delIds.push(i)}}
for(i=delIds.length-1;i>-1;i--){this.poolingContexts.splice(delIds[i],1)}
return regIds},removeRecordFromPool:function(repeaterIdValue){'use strict';var i,j,field,nodeIds=[],targetKeying,targetKeyingObj,parentKeying,relatedId,idValue,delNodes,contextAndKey,sameOriginContexts,countDeleteNodes;contextAndKey=getContextAndKeyFromId(repeaterIdValue);if(contextAndKey===null){return}
sameOriginContexts=this.getContextsWithSameOrigin(contextAndKey.context);targetKeying=contextAndKey.key;for(i=0;i<sameOriginContexts.length;i++){targetKeyingObj=sameOriginContexts[i].binding[targetKeying];for(field in targetKeyingObj){if(targetKeyingObj.hasOwnProperty(field)){for(j=0;j<targetKeyingObj[field].length;j++){if(nodeIds.indexOf(targetKeyingObj[field][j].id)<0){nodeIds.push(targetKeyingObj[field][j].id)}}}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){parentKeying=Object.keys(contextAndKey.context.binding)[0];relatedId=targetKeying.split('=')[1];if(sameOriginContexts[i].binding[parentKeying]&&sameOriginContexts[i].binding[parentKeying]._im_repeater&&sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId]&&sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId][0]){nodeIds.push(sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId][0].id)}}}
delNodes=[];for(i=0;i<sameOriginContexts.length;i++){for(idValue in sameOriginContexts[i].contextInfo){if(sameOriginContexts[i].contextInfo.hasOwnProperty(idValue)){if(nodeIds.indexOf(idValue)>=0){delete contextAndKey.context.contextInfo[idValue];delNodes.push(idValue)}}}
delete sameOriginContexts[i].binding[targetKeying];delete sameOriginContexts[i].store[targetKeying]}
countDeleteNodes=delNodes.length;IMLibElement.deleteNodes(delNodes);this.poolingContexts=this.poolingContexts.filter(function(context){return nodeIds.indexOf(context.enclosureNode.id)<0});return countDeleteNodes;function getContextAndKeyFromId(repeaterIdValue){var i,field,j,keying,foreignKey;for(i=0;i<IMLibContextPool.poolingContexts.length;i++){for(keying in IMLibContextPool.poolingContexts[i].binding){if(IMLibContextPool.poolingContexts[i].binding.hasOwnProperty(keying)){for(field in IMLibContextPool.poolingContexts[i].binding[keying]){if(IMLibContextPool.poolingContexts[i].binding[keying].hasOwnProperty(field)&&field==='_im_repeater'){for(j=0;j<IMLibContextPool.poolingContexts[i].binding[keying][field].length;j++){if(repeaterIdValue===IMLibContextPool.poolingContexts[i].binding[keying][field][j].id){return({context:IMLibContextPool.poolingContexts[i],key:keying})}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){for(foreignKey in IMLibContextPool.poolingContexts[i].binding[keying][field]){if(IMLibContextPool.poolingContexts[i].binding[keying][field].hasOwnProperty(foreignKey)){for(j=0;j<IMLibContextPool.poolingContexts[i].binding[keying][field][foreignKey].length;j++){if(repeaterIdValue===IMLibContextPool.poolingContexts[i].binding[keying][field][foreignKey][j].id){return({context:IMLibContextPool.poolingContexts[i],key:INTERMediatorOnPage.defaultKeyName+'='+foreignKey})}}}}}}}}}}
return null}},getContextsWithSameOrigin:function(originalContext){'use strict';var i,contexts=[],contextDef,isPortal=!1;contextDef=IMLibContextPool.getContextDef(originalContext.contextName);if(contextDef&&contextDef.relation){for(i in contextDef.relation){if(contextDef.relation.hasOwnProperty(i)&&contextDef.relation[i].portal){isPortal=!0;break}}}
for(i=0;i<IMLibContextPool.poolingContexts.length;i++){if(IMLibContextPool.poolingContexts[i].sourceName===originalContext.sourceName){if(!isPortal||originalContext.parentContext!==IMLibContextPool.poolingContexts[i]){contexts.push(IMLibContextPool.poolingContexts[i])}}}
return contexts},updateOnAnotherClient:function(eventName,info){'use strict';var i,j,k,entityName=info.entity,contextDef,contextView,keyField,recKey;if(eventName==='update'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){keyField=contextDef.key;recKey=keyField+'='+info.pkvalue;this.poolingContexts[i].setValue(recKey,info.field[0],info.value[0]);var bindingInfo=this.poolingContexts[i].binding[recKey][info.field[0]];for(j=0;j<bindingInfo.length;j++){var updateRequiredContext=IMLibContextPool.dependingObjects(bindingInfo[j].id);for(k=0;k<updateRequiredContext.length;k++){updateRequiredContext[k].foreignValue={};updateRequiredContext[k].foreignValue[info.field[0]]=info.value[0];if(updateRequiredContext[k]){INTERMediator.constructMain(updateRequiredContext[k])}}}}}
IMLibCalc.recalculation()}else if(eventName==='create'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){if(this.poolingContexts[i].isContaining(info.value[0])){INTERMediator.constructMain(this.poolingContexts[i],info.value)}}}
IMLibCalc.recalculation()}else if(eventName==='delete'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){this.poolingContexts[i].removeEntry(info.pkvalue)}}
IMLibCalc.recalculation()}},getMasterContext:function(){'use strict';var i,contextDef;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){contextDef=this.poolingContexts[i].getContextDef();if(contextDef['navi-control']&&contextDef['navi-control'].match(/master/)){return this.poolingContexts[i]}}
return null},getDetailContext:function(){'use strict';var i,contextDef;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){contextDef=this.poolingContexts[i].getContextDef();if(contextDef['navi-control']&&contextDef['navi-control'].match(/detail/)){return this.poolingContexts[i]}}
return null},getContextDef:function(contextName){'use strict';return INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',contextName)},getContextFromNodeId:function(nodeId){'use strict';var i,context,contextDef,rKey,fKey,pKey,isPortal,bindInfo;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];contextDef=context.getContextDef();isPortal=!1;if(contextDef.relation){for(rKey in contextDef.relation){if(contextDef.relation[rKey].portal){isPortal=!0}}}
for(rKey in context.binding){if(context.binding.hasOwnProperty(rKey)){for(fKey in context.binding[rKey]){if(isPortal){for(pKey in context.binding[rKey][fKey]){if(context.binding[rKey][fKey].hasOwnProperty(pKey)){bindInfo=context.binding[rKey][fKey][pKey];if(bindInfo.nodeId===nodeId){return context}}}}else{bindInfo=context.binding[rKey][fKey];if(bindInfo.nodeId===nodeId){return context}}}}}}
return null},getContextFromEnclosureNode:function(enclosureNode){'use strict';var i,context;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];if(context.enclosureNode===enclosureNode){return context}}
return null},generateContextObject:function(contextDef,enclosure,repeaters,repeatersOriginal){'use strict';var contextObj=new IMLibContext(contextDef.name);contextObj.contextDefinition=contextDef;contextObj.enclosureNode=enclosure;contextObj.repeaterNodes=repeaters;contextObj.original=repeatersOriginal;contextObj.sequencing=!0;return contextObj},getPagingContext:function(){'use strict';var i,context,contextDef;if(this.poolingContexts){for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];contextDef=context.getContextDef();if(contextDef.paging){return context}}}
return null}};var IMLibContext=function(contextName){'use strict';this.contextName=contextName;this.tableName=null;this.viewName=null;this.sourceName=null;this.contextDefinition=null;this.store={};this.binding={};this.contextInfo={};this.modified={};this.recordOrder=[];this.pendingOrder=[];IMLibContextPool.registerContext(this);this.foreignValue={};this.enclosureNode=null;this.repeaterNodes=null;this.dependingObject=[];this.original=null;this.nullAcceptable=!0;this.parentContext=null;this.registeredId=null;this.sequencing=!1;this.dependingParentObjectInfo=null;this.isPortal=!1;this.potalContainingRecordKV=null;this.setTable(this)};IMLibContext.prototype.updateFieldValue=function(idValue,succeedProc,errorProc,warnMultipleRecProc,warnOthersModifyProc){'use strict';var nodeInfo,contextInfo,linkInfo,changedObj,criteria,newValue;changedObj=document.getElementById(idValue);linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);if(INTERMediator.ignoreOptimisticLocking){IMLibContextPool.updateContext(idValue,nodeInfo.target);newValue=IMLibElement.getValueFromIMNode(changedObj);if(newValue!==null){criteria=contextInfo.record.split('=');INTERMediatorOnPage.retrieveAuthInfo();if(contextInfo.context.isPortal){criteria=contextInfo.context.potalContainingRecordKV.split('=');INTERMediator_DBAdapter.db_update_async({name:contextInfo.context.parentContext.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field+'.'+contextInfo.record.split('=')[1],value:newValue}]},succeedProc,errorProc)}else{criteria=contextInfo.record.split('=');INTERMediator_DBAdapter.db_update_async({name:contextInfo.context.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field,value:newValue}]},succeedProc,errorProc)}}}else{var targetContext=contextInfo.context;var parentContext,keyingComp;if(targetContext.isPortal===!0){parentContext=IMLibContextPool.getContextFromName(targetContext.sourceName)[0]}else{parentContext=targetContext.parentContext}
var targetField=contextInfo.field;if(targetContext.isPortal===!0){keyingComp=Object.keys(parentContext.store)[0].split('=')}else{keyingComp=(targetContext.isPortal?targetContext.potalContainingRecordKV:contextInfo.record).split('=')}
var keyingField=keyingComp[0];keyingComp.shift();var keyingValue=keyingComp.join('=');INTERMediator_DBAdapter.db_query_async({name:targetContext.isPortal?parentContext.contextName:targetContext.contextName,records:1,paging:!1,fields:[contextInfo.field],parentkeyvalue:null,conditions:[{field:keyingField,operator:'=',value:keyingValue}],useoffset:!1,primaryKeyOnly:!0},(function(){var targetFieldCapt=targetField;var contextInfoCapt=contextInfo;var targetContextCapt=targetContext;var changedObjectCapt=changedObj;var nodeInfoCapt=nodeInfo;var idValueCapt=idValue;return function(result){var initialvalue,newValue,isOthersModified,currentFieldVal,recordset=[],portalRecords,index,keyField,keyingComp,criteria;if(targetContextCapt.isPortal){portalRecords=targetContextCapt.getPortalRecordsetImpl(result.dbresult[0],targetContextCapt.contextName);keyField=targetContextCapt.getKeyField();keyingComp=contextInfoCapt.record.split('=');for(index=0;index<portalRecords.length;index++){if(portalRecords[index][keyField]===keyingComp[1]){recordset.push(portalRecords[index]);break}}}else{recordset=result.dbresult}
if(!recordset||!recordset[0]||recordset[0][targetFieldCapt]===undefined){errorProc();return}
if(result.resultCount>1){if(!warnMultipleRecProc()){return}}
if(targetContextCapt.isPortal){for(var i=0;i<recordset.length;i++){if(recordset[i][INTERMediatorOnPage.defaultKeyName]===contextInfo.record.split('=')[1]){currentFieldVal=recordset[i][targetFieldCapt];break}}
initialvalue=targetContextCapt.getValue(Object.keys(parentContext.store)[0],targetFieldCapt,INTERMediatorOnPage.defaultKeyName+'='+recordset[i][INTERMediatorOnPage.defaultKeyName])}else{currentFieldVal=recordset[0][targetFieldCapt];initialvalue=targetContextCapt.getValue(contextInfoCapt.record,targetFieldCapt)}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){if(typeof(initialvalue)==='number'&&typeof(currentFieldVal)==='string'){initialvalue=initialvalue.toString()}}
isOthersModified=checkSameValue(initialvalue,currentFieldVal);if(changedObjectCapt.tagName==='INPUT'&&changedObjectCapt.getAttribute('type')==='checkbox'){if(initialvalue===changedObjectCapt.value){isOthersModified=!1}else if(!parseInt(currentFieldVal)){isOthersModified=!1}else{isOthersModified=!0}}
if(isOthersModified){newValue=IMLibElement.getValueFromIMNode(changedObjectCapt);if(!warnOthersModifyProc(initialvalue,newValue,currentFieldVal)){return}
INTERMediatorOnPage.retrieveAuthInfo()}
IMLibContextPool.updateContext(idValueCapt,nodeInfoCapt.target);newValue=IMLibElement.getValueFromIMNode(changedObjectCapt);if(newValue!==null){if(targetContextCapt.isPortal){if(targetContextCapt.potalContainingRecordKV==null){criteria=Object.keys(targetContextCapt.foreignValue);criteria[1]=targetContextCapt.foreignValue[criteria[0]]}else{criteria=targetContextCapt.potalContainingRecordKV.split('=')}
INTERMediator_DBAdapter.db_update_async({name:targetContextCapt.isPortal?targetContextCapt.sourceName:targetContextCapt.parentContext.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfoCapt.field+'.'+contextInfoCapt.record.split('=')[1],value:newValue}]},succeedProc,errorProc)}else{criteria=contextInfoCapt.record.split('=');INTERMediator_DBAdapter.db_update_async({name:targetContextCapt.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field,value:newValue}]},succeedProc,errorProc)}}}})(),function(){INTERMediatorOnPage.hideProgress();INTERMediatorLog.setErrorMessage('Error in valueChange method.','EXCEPTION-1')})}
var handleAsNullValue=['0000-00-00','0000-00-00 00:00:00'];function checkSameValue(initialValue,currentFieldVal){if(handleAsNullValue.indexOf(initialValue)>=0){initialValue=''}
if(handleAsNullValue.indexOf(currentFieldVal)>=0){currentFieldVal=''}
return initialValue!==currentFieldVal}};IMLibContext.prototype.getKeyField=function(){'use strict';var keyField;if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){if(this.isPortal){keyField=INTERMediatorOnPage.defaultKeyName}else{keyField=this.contextDefinition.key?this.contextDefinition.key:INTERMediatorOnPage.defaultKeyName}}else{keyField=this.contextDefinition.key?this.contextDefinition.key:'id'}
return keyField};IMLibContext.prototype.getCalculationFields=function(){'use strict';var calcDef=this.contextDefinition.calculation;var calcFields=[],ix;for(ix in calcDef){if(calcDef.hasOwnProperty(ix)){calcFields.push(calcDef[ix].field)}}
return calcFields};IMLibContext.prototype.isUseLimit=function(){'use strict';var useLimit=!1;if(this.contextDefinition.records&&this.contextDefinition.paging){useLimit=!0}
return useLimit};IMLibContext.prototype.getPortalRecords=function(){'use strict';var targetRecords={};if(!this.isPortal){return null}
if(this.contextDefinition&&this.contextDefinition.currentrecord){targetRecords.recordset=this.getPortalRecordsetImpl(this.contextDefinition.currentrecord,this.contextName)}else{targetRecords.recordset=this.getPortalRecordsetImpl(this.parentContext.store[this.potalContainingRecordKV],this.contextName)}
return targetRecords};IMLibContext.prototype.getPortalRecordsetImpl=function(store,contextName){'use strict';var result,recId,recordset,key,contextDef;recordset=[];if(store[0]){if(!store[0][contextName]){for(key in store[0]){if(store[0].hasOwnProperty(key)){contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',key);if(contextName===contextDef.view&&!store[0][contextName]){contextName=key;break}}}}
if(store[0][contextName]){result=store[0][contextName];for(recId in result){if(result.hasOwnProperty(recId)&&isFinite(recId)){recordset.push(result[recId])}}}}
return recordset};IMLibContext.prototype.getRecordNumber=function(){'use strict';var recordNumber,key,value,keyParams;if(this.contextDefinition['navi-control']&&this.contextDefinition['navi-control']==='detail'){recordNumber=1}else{recordNumber=parseInt(this.contextDefinition.records,10);for(key in INTERMediator.recordLimit){if(INTERMediator.recordLimit.hasOwnProperty(key)){value=String(INTERMediator.recordLimit[key]);if(key===this.contextDefinition.name&&value.length>0){recordNumber=parseInt(value);INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}}}
if(parseInt(INTERMediator.pagedSize,10)>0){recordNumber=INTERMediator.pagedSize;INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}
for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){value=String(IMLibLocalContext.store[key]);keyParams=key.split(':');if(keyParams&&keyParams.length>1&&keyParams[1].trim()===this.contextDefinition.name&&value.length>0&&keyParams[0].trim()==='limitnumber'){recordNumber=parseInt(value);INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}}}
if(!this.contextDefinition.relation&&this.contextDefinition.paging&&Boolean(this.contextDefinition.paging)===!0){INTERMediator.setLocalProperty('_im_pagedSize',recordNumber);INTERMediator.pagedSize=recordNumber}}
return recordNumber};IMLibContext.prototype.setRelationWithParent=function(currentRecord,parentObjectInfo,parentContext){'use strict';var relationDef,index,joinField,fieldName,i;this.parentContext=parentContext;if(currentRecord){try{relationDef=this.contextDefinition.relation;if(relationDef){for(index in relationDef){if(relationDef.hasOwnProperty(index)){if(Boolean(relationDef[index].portal)===!0){this.isPortal=!0;this.potalContainingRecordKV=INTERMediatorOnPage.defaultKeyName+'='+currentRecord[INTERMediatorOnPage.defaultKeyName]}
joinField=relationDef[index]['join-field'];this.addForeignValue(joinField,currentRecord[joinField]);for(fieldName in parentObjectInfo){if(fieldName===relationDef[index]['join-field']){for(i=0;i<parentObjectInfo[fieldName].length;i++){this.addDependingObject(parentObjectInfo[fieldName][i])}
this.dependingParentObjectInfo=JSON.parse(JSON.stringify(parentObjectInfo))}}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-25')}}}};IMLibContext.prototype.getInsertOrder=function(){'use strict';var cName,sortKeys=[],contextDef,i,sortFields=[],sortDirections=[];for(cName in INTERMediator.additionalSortKey){if(cName===this.contextName){sortKeys.push(INTERMediator.additionalSortKey[cName])}}
contextDef=this.getContextDef();if(contextDef.sort){sortKeys.push(contextDef.sort)}
for(i=0;i<sortKeys.length;i++){if(sortFields.indexOf(sortKeys[i].field)<0){sortFields.push(sortKeys[i].field);sortDirections.push(sortKeys[i].direction)}}};IMLibContext.prototype.indexingArray=function(keyField){'use strict';var ar=[],key,counter=0;for(key in this.store){if(this.store.hasOwnProperty(key)){ar[counter]=this.store[key][keyField];counter+=1}}
return ar};IMLibContext.prototype.clearAll=function(){'use strict';this.store={};this.binding={}};IMLibContext.prototype.setContextName=function(name){'use strict';this.contextName=name};IMLibContext.prototype.getContextDef=function(){'use strict';return INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName)};IMLibContext.prototype.setTableName=function(name){'use strict';this.tableName=name};IMLibContext.prototype.setViewName=function(name){'use strict';this.viewName=name};IMLibContext.prototype.addDependingObject=function(idNumber){'use strict';this.dependingObject.push(idNumber)};IMLibContext.prototype.addForeignValue=function(field,value){'use strict';this.foreignValue[field]=value};IMLibContext.prototype.setOriginal=function(repeaters){'use strict';var i;this.original=[];for(i=0;i<repeaters.length;i++){this.original.push(repeaters[i].cloneNode(!0))}};IMLibContext.prototype.setTable=function(context){'use strict';var contextDef;if(!context||!INTERMediatorOnPage.getDataSources){this.tableName=this.contextName;this.viewName=this.contextName;this.sourceName=this.contextName;return}
contextDef=this.getContextDef();if(contextDef){this.viewName=contextDef.view?contextDef.view:contextDef.name;this.tableName=contextDef.table?contextDef.table:contextDef.name;this.sourceName=(contextDef.source?contextDef.source:(contextDef.table?contextDef.table:(contextDef.view?contextDef.view:contextDef.name)))}};IMLibContext.prototype.removeContext=function(){'use strict';var regIds=[],childContexts=[];seekRemovingContext(this);regIds=IMLibContextPool.removeContextsFromPool(childContexts);while(this.enclosureNode.firstChild){this.enclosureNode.removeChild(this.enclosureNode.firstChild)}
INTERMediator_DBAdapter.unregister(regIds);function seekRemovingContext(context){var i,myChildren;childContexts.push(context);regIds.push(context.registeredId);myChildren=IMLibContextPool.getChildContexts(context);for(i=0;i<myChildren.length;i++){seekRemovingContext(myChildren[i])}}};IMLibContext.prototype.setModified=function(recKey,key,value){'use strict';if(this.modified[recKey]===undefined){this.modified[recKey]={}}
this.modified[recKey][key]=value};IMLibContext.prototype.getModified=function(){'use strict';return this.modified};IMLibContext.prototype.clearModified=function(){'use strict';this.modified={}};IMLibContext.prototype.getContextDef=function(){'use strict';var contextDef;contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName);return contextDef};IMLibContext.prototype.checkOrder=function(oneRecord,isDebug){'use strict';var i,fields=[],directions=[],oneSortKey,condtextDef,lower,upper,index,targetRecord,contextValue,checkingValue,stop;if(isDebug!==!0){if(INTERMediator&&INTERMediator.additionalSortKey[this.contextName]){for(i=0;i<INTERMediator.additionalSortKey[this.contextName].length;i++){oneSortKey=INTERMediator.additionalSortKey[this.contextName][i];if(!(oneSortKey.field in fields)){fields.push(oneSortKey.field);directions.push(oneSortKey.direction)}}}
condtextDef=this.getContextDef();if(condtextDef&&condtextDef.sort){for(i=0;i<condtextDef.sort.length;i++){oneSortKey=condtextDef.sort[i];if(!(oneSortKey.field in fields)){fields.push(oneSortKey.field);directions.push(oneSortKey.direction)}}}}else{fields=['field1','field2']}
lower=0;upper=this.recordOrder.length;for(i=0;i<fields.length;i++){if(oneRecord[fields[i]]){index=parseInt((upper+lower)/2);do{targetRecord=this.store[this.recordOrder[index]];contextValue=targetRecord[fields[i]];checkingValue=oneRecord[fields[i]];if(contextValue<checkingValue){lower=index}else if(contextValue>checkingValue){upper=index}else{lower=upper=index}
index=parseInt((upper+lower)/2)}while(upper-lower>1);targetRecord=this.store[this.recordOrder[index]];contextValue=targetRecord[fields[i]];if(contextValue===checkingValue){lower=upper=index;stop=!1;do{targetRecord=this.store[this.recordOrder[lower-1]];if(targetRecord&&targetRecord[fields[i]]&&targetRecord[fields[i]]===checkingValue){lower--}else{stop=!0}}while(!stop);stop=!1;do{targetRecord=this.store[this.recordOrder[upper+1]];if(targetRecord&&targetRecord[fields[i]]&&targetRecord[fields[i]]===checkingValue){upper++}else{stop=!0}}while(!stop);if(lower===upper){break}
upper++}else if(contextValue<checkingValue){break}else if(contextValue>checkingValue){index--;break}}}
return index};IMLibContext.prototype.rearrangePendingOrder=function(isDebug){'use strict';var i,index,targetRecord;for(i=0;i<this.pendingOrder.length;i++){targetRecord=this.store[this.pendingOrder[i]];index=this.checkOrder(targetRecord,isDebug);if(index>=-1){this.recordOrder.splice(index+1,0,this.pendingOrder[i])}}
this.pendingOrder=[]};IMLibContext.prototype.getRepeaterEndNode=function(index){'use strict';var nodeId,field,repeaters=[],repeater,node,i,enclosure,children;var recKey=this.recordOrder[index];for(field in this.binding[recKey]){if(this.binding[recKey].hasOwnProperty(field)){nodeId=this.binding[recKey][field].nodeId;repeater=INTERMediatorLib.getParentRepeaters(document.getElementById(nodeId));for(i=0;i<repeater.length;i+=1){if(!(repeater[i]in repeaters)){repeaters.push(repeater[i])}}}}
if(repeaters.length<1){return null}
node=repeaters[0];enclosure=INTERMediatorLib.getParentEnclosure(node);children=enclosure.childNodes;for(i=0;i<children.length;i++){if(children[i]in repeaters){node=repeaters[i];break}}
return node};IMLibContext.prototype.storeRecords=function(records){'use strict';var ix,record,field,keyField,keyValue;var contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName);keyField=contextDef.key?contextDef.key:'id';if(records.recordset){for(ix=0;ix<records.recordset.length;ix++){record=records.recordset[ix];for(field in record){if(record.hasOwnProperty(field)){keyValue=record[keyField]?record[keyField]:ix;this.setValue(keyField+'='+keyValue,field,record[field])}}}}};IMLibContext.prototype.getDataAtLastRecord=function(key){'use strict';var lastKey;var storekeys=Object.keys(this.store);if(storekeys.length>0){lastKey=storekeys[storekeys.length-1];return this.getValue(lastKey,key)}
return undefined};IMLibContext.prototype.setDataAtLastRecord=function(key,value){'use strict';var lastKey,keyAndValue,contextName;var storekeys=Object.keys(this.store);if(storekeys.length>0){lastKey=storekeys[storekeys.length-1];this.setValue(lastKey,key,value);contextName=this.contextName;keyAndValue=lastKey.split('=');IMLibQueue.setTask((function(){var params={name:contextName,conditions:[{field:keyAndValue[0],operator:'=',value:keyAndValue[1]}],dataset:[{field:key,value:value}]};return function(completeTask){INTERMediator_DBAdapter.db_update(params);IMLibCalc.recalculation();INTERMediatorLog.flushMessage();completeTask()}})())}};IMLibContext.prototype.setDataWithKey=function(pkValue,key,value){'use strict';var targetKey,contextDef,storeElements,contextName;contextDef=this.getContextDef();if(!contextDef){return}
targetKey=contextDef.key+'='+pkValue;storeElements=this.store[targetKey];if(storeElements){this.setValue(targetKey,key,value);contextName=this.contextName;IMLibQueue.setTask((function(){var params={name:contextName,conditions:[{field:contextDef.key,operator:'=',value:pkValue}],dataset:[{field:key,value:value}]};return function(completeTask){INTERMediator_DBAdapter.db_update(params);INTERMediatorLog.flushMessage();completeTask()}})())}};IMLibContext.prototype.setValue=function(recKey,key,value,nodeId,target,portal){'use strict';var updatedNodeIds=null;if(portal){console.error('Using the portal parameter in IMLibContext.setValue')}
if(recKey){if(this.store[recKey]===undefined){this.store[recKey]={}}
if(portal&&this.store[recKey][key]===undefined){this.store[recKey][key]={}}
if(this.binding[recKey]===undefined){this.binding[recKey]={};if(this.sequencing){this.recordOrder.push(recKey)}else{this.pendingOrder.push(recKey)}}
if(this.binding[recKey][key]===undefined){this.binding[recKey][key]=[]}
if(portal&&this.binding[recKey][key][portal]===undefined){if(this.binding[recKey][key].length<1){this.binding[recKey][key]={}}
this.binding[recKey][key][portal]=[]}
if(key){if(portal){this.store[recKey][key]=value}else{this.store[recKey][key]=value}
if(nodeId){if(portal){this.binding[recKey][key].push({id:nodeId,target:target})}else{this.binding[recKey][key].push({id:nodeId,target:target})}
if(this.contextInfo[nodeId]===undefined){this.contextInfo[nodeId]={}}
this.contextInfo[nodeId][target?target:'_im_no_target']={context:this,record:recKey,field:key};if(portal){this.contextInfo[nodeId][target?target:'_im_no_target'].portal=portal}}else{if(INTERMediator.partialConstructing){updatedNodeIds=IMLibContextPool.synchronize(this,recKey,key,value,target,portal)}}}}
return updatedNodeIds};IMLibContext.prototype.getValue=function(recKey,key,portal){'use strict';var value;try{if(portal){value=this.store[portal][key]}else{value=this.store[recKey][key]}
if(Array.isArray(value)){value=value.join()}
return value===undefined?null:value}catch(ex){return null}};IMLibContext.prototype.isValueUndefined=function(recKey,key,portal){'use strict';var value,tableOccurence,relatedRecId;try{if(portal){tableOccurence=key.split('::')[0];relatedRecId=portal.split('=')[1];value=this.store[recKey][0][tableOccurence][relatedRecId][key]}else{value=this.store[recKey][key]}
return value===undefined?!0:!1}catch(ex){return null}};IMLibContext.prototype.getContextInfo=function(nodeId,target){'use strict';try{var info=this.contextInfo[nodeId][target?target:'_im_no_target'];return info===undefined?null:info}catch(ex){return null}};IMLibContext.prototype.getContextValue=function(nodeId,target){'use strict';try{var info=this.contextInfo[nodeId][target?target:'_im_no_target'];var value=info.context.getValue(info.record,info.field);return value===undefined?null:value}catch(ex){return null}};IMLibContext.prototype.getContextRecord=function(nodeId){'use strict';var infos,keys,i;try{infos=this.contextInfo[nodeId];keys=Object.keys(infos);for(i=0;i<keys.length;i++){if(infos[keys[i]]){return this.store[infos[keys[i]].record]}}
return null}catch(ex){return null}};IMLibContext.prototype.removeEntry=function(pkvalue){'use strict';var keyField,keying,bindingInfo,contextDef,targetNode,repeaterNodes,i,removingNodeIds=[];contextDef=this.getContextDef();keyField=contextDef.key;keying=keyField+'='+pkvalue;bindingInfo=this.binding[keying];if(bindingInfo){repeaterNodes=bindingInfo._im_repeater;if(repeaterNodes){for(i=0;i<repeaterNodes.length;i++){removingNodeIds.push(repeaterNodes[i].id)}}}
if(removingNodeIds.length>0){for(i=0;i<removingNodeIds.length;i++){IMLibContextPool.removeRecordFromPool(removingNodeIds[i])}
for(i=0;i<removingNodeIds.length;i++){targetNode=document.getElementById(removingNodeIds[i]);if(targetNode){targetNode.parentNode.removeChild(targetNode)}}}};IMLibContext.prototype.isContaining=function(value){'use strict';var contextDef,contextName,checkResult=[],i,fieldName,result,opePosition,leftHand,rightHand,leftResult,rightResult;contextDef=this.getContextDef();contextName=contextDef.name;if(contextDef.query){for(i in contextDef.query){if(contextDef.query.hasOwnProperty(i)){checkResult.push(checkCondition(contextDef.query[i],value))}}}
if(INTERMediator.additionalCondition[contextName]){for(i=0;i<INTERMediator.additionalCondition[contextName].length;i++){checkResult.push(checkCondition(INTERMediator.additionalCondition[contextName][i],value))}}
result=!0;if(checkResult.length!==0){opePosition=checkResult.indexOf('D');if(opePosition>-1){leftHand=checkResult.slice(0,opePosition);rightHand=opePosition.slice(opePosition+1);if(rightHand.length===0){result=(leftHand.indexOf(!1)<0)}else{leftResult=(leftHand.indexOf(!1)<0);rightResult=(rightHand.indexOf(!1)<0);result=leftResult||rightResult}}else{opePosition=checkResult.indexOf('EX');if(opePosition>-1){leftHand=checkResult.slice(0,opePosition);rightHand=opePosition.slice(opePosition+1);if(rightHand.length===0){result=(leftHand.indexOf(!0)>-1)}else{leftResult=(leftHand.indexOf(!0)>-1);rightResult=(rightHand.indexOf(!0)>-1);result=leftResult&&rightResult}}else{opePosition=checkResult.indexOf(!1);if(opePosition>-1){result=(checkResult.indexOf(!1)<0)}}}
if(result===!1){return!1}}
if(this.foreignValue){for(fieldName in this.foreignValue){if(contextDef.relation){for(i in contextDef.relation){if(contextDef.relation[i]['join-field']===fieldName){result&=(checkCondition({field:contextDef.relation[i]['foreign-key'],operator:'=',value:this.foreignValue[fieldName]},value))}}}}}
return result;function checkCondition(conditionDef,oneRecord){var realValue;if(conditionDef.field==='__operation__'){return conditionDef.operator==='ex'?'EX':'D'}
realValue=oneRecord[conditionDef.field];if(!realValue){return!1}
switch(conditionDef.operator){case '=':case 'eq':return String(realValue)===String(conditionDef.value);case '>':case 'gt':return realValue>conditionDef.value;case '<':case 'lt':return realValue<conditionDef.value;case '>=':case 'gte':return realValue>=conditionDef.value;case '<=':case 'lte':return realValue<=conditionDef.value;case '!=':case 'neq':return String(realValue)!==String(conditionDef.value);default:return!1}}};IMLibContext.prototype.insertEntry=function(pkvalue,fields,values){'use strict';var i,field,value;for(i=0;i<fields.length;i++){field=fields[i];value=values[i];this.setValue(pkvalue,field,value)}};var IMLibLocalContext={contextName:'_',store:{},binding:{},clearAll:function(){'use strict';this.store={}},setValue:function(key,value,withoutArchive){'use strict';var i,hasUpdated,refIds,node;hasUpdated=!1;if(key){if(value===undefined||value===null){delete this.store[key]}else{this.store[key]=value;hasUpdated=!0;refIds=this.binding[key];if(refIds){for(i=0;i<refIds.length;i++){node=document.getElementById(refIds[i]);IMLibElement.setValueToIMNode(node,'',value,!0)}}}}
if(hasUpdated&&withoutArchive!==!0){this.archive()}},getValue:function(key){'use strict';var value=this.store[key];return value===undefined?null:value},archive:function(){'use strict';var jsonString,key,searchLen,hashLen,trailLen;INTERMediatorOnPage.removeCookie('_im_localcontext');if(INTERMediator.isIE&&INTERMediator.ieVersion<9){this.store._im_additionalCondition=INTERMediator.additionalCondition;this.store._im_additionalSortKey=INTERMediator.additionalSortKey;this.store._im_startFrom=INTERMediator.startFrom;this.store._im_pagedSize=INTERMediator.pagedSize;jsonString=JSON.stringify(this.store,function(k,v){return v===''?'':v})}else{jsonString=JSON.stringify(this.store)}
if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{searchLen=location.search?location.search.length:0;hashLen=location.hash?location.hash.length:0;trailLen=searchLen+hashLen;key='_im_localcontext'+document.URL.toString();key=(trailLen>0)?key.slice(0,-trailLen):key;sessionStorage.setItem(key,jsonString)}catch(ex){INTERMediatorOnPage.setCookieWorker('_im_localcontext',jsonString,!1,0)}}else{INTERMediatorOnPage.setCookieWorker('_im_localcontext',jsonString,!1,0)}},unarchive:function(){'use strict';var localContext='',searchLen,hashLen,key,trailLen;if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{searchLen=location.search?location.search.length:0;hashLen=location.hash?location.hash.length:0;trailLen=searchLen+hashLen;key='_im_localcontext'+document.URL.toString();key=(trailLen>0)?key.slice(0,-trailLen):key;localContext=sessionStorage.getItem(key)}catch(ex){localContext=INTERMediatorOnPage.getCookie('_im_localcontext')}}else{localContext=INTERMediatorOnPage.getCookie('_im_localcontext')}
if(localContext&&localContext.length>0){this.store=JSON.parse(localContext);if(INTERMediator.isIE&&INTERMediator.ieVersion<9){if(this.store._im_additionalCondition){INTERMediator.additionalCondition=this.store._im_additionalCondition}
if(this.store._im_additionalSortKey){INTERMediator.additionalSortKey=this.store._im_additionalSortKey}
if(this.store._im_startFrom){INTERMediator.startFrom=this.store._im_startFrom}
if(this.store._im_pagedSize){INTERMediator.pagedSize=this.store._im_pagedSize}}
this.updateAll(!0)}},bindingNode:function(node){'use strict';var linkInfos,nodeInfo,idValue,i,j,value,params,unbinding,unexistId,dataImControl;if(node.nodeType!==1){return}
linkInfos=INTERMediatorLib.getLinkedElementInfo(node);dataImControl=node.getAttribute('data-im-control');unbinding=(dataImControl&&dataImControl==='unbind');for(i=0;i<linkInfos.length;i++){nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===this.contextName){if(!node.id){node.id=INTERMediator.nextIdValue()}
idValue=node.id;if(!this.binding[nodeInfo.field]){this.binding[nodeInfo.field]=[]}
if(this.binding[nodeInfo.field].indexOf(idValue)<0&&!unbinding){this.binding[nodeInfo.field].push(idValue)}
unexistId=-1;while(unexistId>=0){for(j=0;j<this.binding[nodeInfo.field].length;j++){if(!document.getElementById(this.binding[nodeInfo.field][j])){unexistId=j}}
if(unexistId>=0){delete this.binding[nodeInfo.field][unexistId]}}
value=this.store[nodeInfo.field];IMLibElement.setValueToIMNode(node,nodeInfo.target,value,!0);params=nodeInfo.field.split(':');switch(params[0]){case 'addorder':IMLibMouseEventDispatch.setExecute(idValue,IMLibUI.eventAddOrderHandler);break;case 'update':IMLibMouseEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})());break;case 'condition':var attrType=node.getAttribute('type');if(attrType&&attrType==='text'){IMLibKeyDownEventDispatch.setExecuteByCode(idValue,13,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})())}else if(attrType&&(attrType==='checkbox'||attrType==='radio')){IMLibChangeEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})())}
break;case 'limitnumber':if(node.value){this.store[nodeInfo.field]=node.value}
IMLibChangeEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})());node.setAttribute('data-imchangeadded','set');break;default:IMLibChangeEventDispatch.setExecute(idValue,IMLibLocalContext.update);break}}}},update:function(idValue){'use strict';IMLibLocalContext.updateFromNodeValue(idValue)},updateFromNodeValue:function(idValue){'use strict';var node,nodeValue,linkInfos,nodeInfo,i;node=document.getElementById(idValue);nodeValue=IMLibElement.getValueFromIMNode(node);linkInfos=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<linkInfos.length;i++){IMLibLocalContext.store[linkInfos[i]]=nodeValue;nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===IMLibLocalContext.contextName){IMLibLocalContext.setValue(nodeInfo.field,nodeValue)}}},updateFromStore:function(idValue){'use strict';var node,nodeValue,linkInfos,nodeInfo,i,target,comp;node=document.getElementById(idValue);target=node.getAttribute('data-im');comp=target.split(INTERMediator.separator);if(comp[1]){nodeValue=IMLibLocalContext.store[comp[1]];linkInfos=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<linkInfos.length;i++){IMLibLocalContext.store[linkInfos[i]]=nodeValue;nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===IMLibLocalContext.contextName){IMLibLocalContext.setValue(nodeInfo.field,nodeValue)}}}},updateAll:function(isStore){'use strict';var index,key,nodeIds,idValue,targetNode;for(key in IMLibLocalContext.binding){if(IMLibLocalContext.binding.hasOwnProperty(key)){nodeIds=IMLibLocalContext.binding[key];for(index=0;index<nodeIds.length;index++){idValue=nodeIds[index];targetNode=document.getElementById(idValue);if(targetNode&&(targetNode.tagName==='INPUT'||targetNode.tagName==='TEXTAREA'||targetNode.tagName==='SELECT')){if(isStore===!0){IMLibLocalContext.updateFromStore(idValue)}else{IMLibLocalContext.updateFromNodeValue(idValue)}
break}}}}},checkedBinding:[],bindingDescendant:function(rootNode){'use strict';var self=this;seek(rootNode);IMLibLocalContext.checkedBinding.push(rootNode);function seek(node){var children,i;if(node!==rootNode&&IMLibLocalContext.checkedBinding.indexOf(node)>-1){return}
if(node.nodeType===1){try{self.bindingNode(node);children=node.childNodes;if(children){for(i=0;i<children.length;i++){seek(children[i])}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-31')}}}}}};var IMLib={nl_char:'\n',cr_char:'\r',tab_char:'\t',singleQuote_char:'\'',doubleQuote_char:'"',backSlash_char:'\\',get zerolength_str(){'use strict';return''},set zerolength_str(value){},get crlf_str(){'use strict';return'\r\n'},set crlf_str(value){}};var INTERMediatorLib={ignoreEnclosureRepeaterClassName:'_im_ignore_enc_rep',ignoreEnclosureRepeaterControlName:'ignore_enc_rep',roleAsRepeaterClassName:'_im_repeater',roleAsEnclosureClassName:'_im_enclosure',roleAsRepeaterDataControlName:'repeater',roleAsEnclosureDataControlName:'enclosure',roleAsSeparatorDataControlName:'separator',roleAsHeaderDataControlName:'header',roleAsFooterDataControlName:'footer',roleAsNoResultDataControlName:'noresult',initialize:function(){'use strict';IMLibLocalContext.unarchive();return null},setup:function(){'use strict';if(window.addEventListener){window.addEventListener('load',this.initialize,!1)}else if(window.attachEvent){window.attachEvent('onload',this.initialize)}else{window.onload=this.initialize}
return null},markProcessed:function(node){'use strict';node.setAttribute('data-im-element','processed')},isProcessed:function(node){'use strict';return node.getAttribute('data-im-element')==='processed'},generatePasswordHash:function(password){'use strict';var numToHex,salt,saltHex,code,lowCode,highCode,i;numToHex=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];salt='';saltHex='';for(i=0;i<4;i++){code=Math.floor(Math.random()*(128-32)+32);lowCode=code&0xF;highCode=(code>>4)&0xF;salt+=String.fromCharCode(code);saltHex+=numToHex[highCode]+numToHex[lowCode]}
return encodeURIComponent(SHA1(password+salt)+saltHex)},getParentRepeater:function(node){console.error('INTERMediatorLib.getParentRepeater method in INTER-Mediator-Lib.js will be removed in Ver.6.0. '+'The alternative method is getParentRepeaters.');'use strict';var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null},getParentRepeaters:function(node){'use strict';var i,target='',linkInfo,result=[],linkComp,nInfos,repeaters;if(!node){return null}
linkInfo=INTERMediatorLib.getLinkedElementInfo(node);if(linkInfo){linkComp=linkInfo[0].split('@');if(linkComp.length>2){target=linkComp[2]}
nInfos=IMLibContextPool.getContextInfoFromId(node.id,target);if(nInfos){repeaters=nInfos.context.binding[nInfos.record]._im_repeater}else{repeaters=seekFromContextPool(node)}}else{repeaters=seekFromContextPool(node)}
if(repeaters){for(i=0;i<repeaters.length;i+=1){result.push(document.getElementById(repeaters[i].id))}}
return result;function seekFromContextPool(node){var i,j,k,currentNode,repeaters;if(!node){return null}
currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){for(i=0;i<IMLibContextPool.poolingContexts.length;i++){for(j in IMLibContextPool.poolingContexts[i].binding){if(IMLibContextPool.poolingContexts[i].binding.hasOwnProperty(j)&&IMLibContextPool.poolingContexts[i].binding[j].hasOwnProperty('_im_repeater')){for(k=0;k<IMLibContextPool.poolingContexts[i].binding[j]._im_repeater.length;k++){if(IMLibContextPool.poolingContexts[i].binding[j]._im_repeater[k].id===currentNode.id){repeaters=IMLibContextPool.poolingContexts[i].binding[j]._im_repeater;return repeaters}}}}}}
currentNode=currentNode.parentNode}
return null}},getParentEnclosure:function(node){'use strict';var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isEnclosure(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null},isEnclosure:function(node,nodeOnly){'use strict';var tagName,className,children,k,controlAttr;if(!node||node.nodeType!==1){return!1}
className=INTERMediatorLib.getClassAttributeFromNode(node);if(className&&className.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterClassName)>=0){return!1}
controlAttr=node.getAttribute('data-im-control');if(controlAttr&&controlAttr.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterControlName)>=0){return!1}
tagName=node.tagName;if((tagName==='TBODY')||(tagName==='UL')||(tagName==='OL')||(tagName==='SELECT')||((tagName==='DIV'||tagName==='SPAN')&&className&&className.indexOf(INTERMediatorLib.roleAsEnclosureClassName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsEnclosureDataControlName)>=0)){if(nodeOnly){return!0}else{children=node.childNodes;for(k=0;k<children.length;k++){if(INTERMediatorLib.isRepeater(children[k],!0)){return!0}}}}
return!1},isRepeater:function(node,nodeOnly){'use strict';var tagName,className,children,k,controlAttr;if(!node||node.nodeType!==1){return!1}
className=INTERMediatorLib.getClassAttributeFromNode(node);if(className&&className.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterClassName)>=0){return!1}
controlAttr=node.getAttribute('data-im-control');if(controlAttr&&controlAttr.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterControlName)>=0){return!1}
tagName=node.tagName;if((tagName==='TR')||(tagName==='LI')||(tagName==='OPTION')||(className&&className.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)){if(nodeOnly){return!0}else{return searchLinkedElement(node)}}
return!1;function searchLinkedElement(node){if(INTERMediatorLib.isLinkedElement(node)){return!0}
children=node.childNodes;for(k=0;k<children.length;k++){if(children[k].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[k])){return!0}else if(searchLinkedElement(children[k])){return!0}}}
return!1}},isLinkedElement:function(node){'use strict';var classInfo,matched,attr;if(node!==null&&node.getAttribute){attr=node.getAttribute('data-im');if(attr){return!0}
if(INTERMediator.titleAsLinkInfo){if(node.getAttribute('TITLE')!==null&&node.getAttribute('TITLE').length>0){return!0}}
if(INTERMediator.classAsLinkInfo){classInfo=INTERMediatorLib.getClassAttributeFromNode(node);if(classInfo!==null){matched=classInfo.match(/IM\[.*\]/);if(matched){return!0}}}}
return!1},isWidgetElement:function(node){'use strict';var classInfo,matched,attr,parentNode;if(!node){return!1}
if(INTERMediatorLib.getLinkedElementInfo(node)){attr=node.getAttribute('data-im-widget');if(attr){return!0}
classInfo=INTERMediatorLib.getClassAttributeFromNode(node);if(classInfo!==null){matched=classInfo.match(/IM_WIDGET\[.*\]/);if(matched){return!0}}}else{parentNode=node.parentNode;if(!parentNode&&INTERMediatorLib.getLinkedElementInfoImpl(parentNode)){attr=parentNode.getAttribute('data-im-widget');if(attr){return!0}
classInfo=INTERMediatorLib.getClassAttributeFromNode(parentNode);if(classInfo!==null){matched=classInfo.match(/IM_WIDGET\[.*\]/);if(matched){return!0}}}}
return!1},isNamedElement:function(node){'use strict';var nameInfo,matched;if(node!==null){nameInfo=node.getAttribute('data-im-group');if(nameInfo){return!0}
nameInfo=node.getAttribute('name');if(nameInfo){matched=nameInfo.match(/IM\[.*\]/);if(matched){return!0}}}
return!1},getEnclosureSimple:function(node){'use strict';if(INTERMediatorLib.isEnclosure(node,!0)){return node}
return INTERMediatorLib.getEnclosureSimple(node.parentNode)},getEnclosure:function(node){'use strict';var currentNode,detectedRepeater;currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){detectedRepeater=currentNode}else if(isRepeaterOfEnclosure(detectedRepeater,currentNode)){detectedRepeater=null;return currentNode}
currentNode=currentNode.parentNode}
return null;function isRepeaterOfEnclosure(repeater,enclosure){var repeaterTag,enclosureTag,enclosureClass,repeaterClass,enclosureDataAttr,repeaterDataAttr,repeaterType;if(!repeater||!enclosure){return!1}
repeaterTag=repeater.tagName;enclosureTag=enclosure.tagName;if((repeaterTag==='TR'&&enclosureTag==='TBODY')||(repeaterTag==='OPTION'&&enclosureTag==='SELECT')||(repeaterTag==='LI'&&enclosureTag==='OL')||(repeaterTag==='LI'&&enclosureTag==='UL')){return!0}
enclosureClass=INTERMediatorLib.getClassAttributeFromNode(enclosure);enclosureDataAttr=enclosure.getAttribute('data-im-control');if((enclosureClass&&enclosureClass.indexOf(INTERMediatorLib.roleAsEnclosureClassName)>=0)||(enclosureDataAttr&&enclosureDataAttr.indexOf('enclosure')>=0)){repeaterClass=INTERMediatorLib.getClassAttributeFromNode(repeater);repeaterDataAttr=repeater.getAttribute('data-im-control');if((repeaterClass&&repeaterClass.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)){return!0}else if(repeaterTag==='INPUT'){repeaterType=repeater.getAttribute('type');if(repeaterType&&((repeaterType.indexOf('radio')>=0||repeaterType.indexOf('check')>=0))){return!0}}}
return!1}},getLinkedElementInfo:function(node){'use strict';var result=INTERMediatorLib.getLinkedElementInfoImpl(node);if(result!==!1){return result}
if(INTERMediatorLib.isWidgetElement(node.parentNode)){return INTERMediatorLib.getLinkedElementInfo(node.parentNode)}
return!1},getLinkedElementInfoImpl:function(node){'use strict';var defs=[],eachDefs,reg,i,attr,matched;if(INTERMediatorLib.isLinkedElement(node)){attr=node.getAttribute('data-im');if(attr!==null&&attr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=attr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(resolveAlias(eachDefs[i]))}}
return defs}
if(INTERMediator.titleAsLinkInfo&&node.getAttribute('TITLE')){eachDefs=node.getAttribute('TITLE').split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(resolveAlias(eachDefs[i]))}
return defs}
if(INTERMediator.classAsLinkInfo){attr=INTERMediatorLib.getClassAttributeFromNode(node);if(attr!==null&&attr.length>0){matched=attr.match(/IM\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(resolveAlias(eachDefs[i]))}}
return defs}}
return!1;function resolveAlias(def){var aliases=INTERMediatorOnPage.getOptionsAliases();if(aliases&&aliases[def]){return aliases[def]}
return def}},getWidgetInfo:function(node){'use strict';var defs=[],eachDefs,i,classAttr,matched,reg;if(INTERMediatorLib.isWidgetElement(node)){classAttr=node.getAttribute('data-im-widget');if(classAttr&&classAttr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=classAttr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(eachDefs[i])}}
return defs}
classAttr=INTERMediatorLib.getClassAttributeFromNode(node);if(classAttr&&classAttr.length>0){matched=classAttr.match(/IM_WIDGET\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(eachDefs[i])}
return defs}}
return!1},getNamedInfo:function(node){'use strict';var defs=[],eachDefs,i,nameAttr,matched,reg;if(INTERMediatorLib.isNamedElement(node)){nameAttr=node.getAttribute('data-im-group');if(nameAttr&&nameAttr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=nameAttr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(eachDefs[i])}}
return defs}
nameAttr=node.getAttribute('name');if(nameAttr&&nameAttr.length>0){matched=nameAttr.match(/IM\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(eachDefs[i])}
return defs}}
return!1},repeaterTagFromEncTag:function(tag){'use strict';if(tag==='TBODY'){return'TR'}else if(tag==='SELECT'){return'OPTION'}else if(tag==='UL'){return'LI'}else if(tag==='OL'){return'LI'}
return null},getNodeInfoArray:function(nodeInfo){'use strict';var comps,tableName,fieldName,targetName;if(!nodeInfo||!nodeInfo.split){return{'table':null,'field':null,'target':null,'tableindex':null,'crossTable':!1}}
comps=nodeInfo.split(INTERMediator.separator);tableName='';fieldName='';targetName='';if(comps.length===3){tableName=comps[0];fieldName=comps[1];targetName=comps[2]}else if(comps.length===2){tableName=comps[0];fieldName=comps[1]}else{fieldName=nodeInfo}
return{'table':tableName,'field':fieldName,'target':targetName,'tableindex':'_im_index_'+tableName,'crossTable':INTERMediator.crossTableStage===3}},getCalcNodeInfoArray:function(idValue){'use strict';console.error('INTERMediatorLib.getCalcNodeInfoArray method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'Here is no alternative method.');var comps,tableName,fieldName,targetName,node,attribute;if(!idValue){return null}
node=document.getElementById(idValue);if(!node){return null}
attribute=node.getAttribute('data-im');if(!attribute){return null}
comps=attribute.split(INTERMediator.separator);tableName='';fieldName='';targetName='';if(comps.length===3){tableName=comps[0];fieldName=comps[1];targetName=comps[2]}else if(comps.length===2){fieldName=comps[0];targetName=comps[1]}else{fieldName=attribute}
return{'table':tableName,'field':fieldName,'target':targetName,'tableindex':'_im_index_'+tableName}},getClassAttributeFromNode:function(node){'use strict';var str='';if(node===null){return''}
if(INTERMediator.isIE&&INTERMediator.ieVersion<8){str=node.getAttribute('className')}else{str=node.getAttribute('class')}
return str},setClassAttributeToNode:function(node,className){'use strict';if(node===null){return}
if(INTERMediator.isIE&&INTERMediator.ieVersion<8){node.setAttribute('className',className)}else{node.setAttribute('class',className)}},eventInfos:[],addEvent:function(node,evt,func){'use strict';if(node.addEventListener){node.addEventListener(evt,func,!1);this.eventInfos.push({'node':node,'event':evt,'function':func});return this.eventInfos.length-1}else if(node.attachEvent){node.attachEvent('on'+evt,func);this.eventInfos.push({'node':node,'event':evt,'function':func});return this.eventInfos.length-1}
return-1},removeEvent:function(serialId){'use strict';if(this.eventInfos[serialId].node.removeEventListener){this.eventInfos[serialId].node.removeEventListener(this.eventInfos[serialId].evt,this.eventInfos[serialId].func,!1)}else if(this.eventInfos[serialId].node.detachEvent){this.eventInfos[serialId].node.detachEvent('on'+this.eventInfos[serialId].evt,this.eventInfos[serialId].func)}},toNumber:function(str){'use strict';var s='',i,c;str=str.toString();for(i=0;i<str.length;i++){c=str.charAt(i);if((c>='0'&&c<='9')||c==='.'||c==='-'||c===INTERMediatorOnPage.localeInfo.mon_decimal_point){s+=c}else if(c>='0'&&c<='9'){s+=String.fromCharCode(c.charCodeAt(0)-'0'.charCodeAt(0)+'0'.charCodeAt(0))}}
return parseFloat(s)},RoundHalfToEven:function(value,digit){'use strict';throw 'RoundHalfToEven method is NOT implemented.'},Round:function(value,digit){'use strict';var powers=Math.pow(10,digit);return Math.round(value*powers)/powers},normalizeNumerics:function(value){'use strict';var i;var punc=INTERMediatorOnPage.localeInfo.decimal_point?INTERMediatorOnPage.localeInfo.decimal_point:'.';var mpunc=INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.';var rule='0123456789';if(punc){rule+='\\'+punc}
if(mpunc&&mpunc!==punc){rule+='\\'+mpunc}
rule='[^'+rule+']';value=String(value);if(value&&value.match(/[0123456789]/)){for(i=0;i<10;i++){value=value.split(String.fromCharCode(65296+i)).join(String(i))}
value=value.replace('.','.')}
return value?parseFloat(value.replace(new RegExp(rule,'g'),'')):''},objectToString:function(obj){'use strict';var str,i,key,sq=String.fromCharCode(39);if(obj===null){return'null'}
if(typeof obj==='object'){str='';if(obj.constructor===Array){for(i=0;i<obj.length;i++){str+=INTERMediatorLib.objectToString(obj[i])+', '}
return'['+str+']'}else{for(key in obj){if(obj.hasOwnProperty(key)){str+=sq+key+sq+':'+INTERMediatorLib.objectToString(obj[key])+', '}}
return'{'+str+'}'}}else{return sq+obj+sq}},numberFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormat(str,digit,flags)},getTargetTableForRetrieve:function(element){'use strict';if(element.view!==null){return element.view}
return element.name},getTargetTableForUpdate:function(element){'use strict';if(element.table!==null){return element.table}
return element.name},getInsertedString:function(tmpStr,dataArray){'use strict';var resultStr,counter;resultStr=tmpStr;if(dataArray!==null){for(counter=1;counter<=dataArray.length;counter++){resultStr=resultStr.replace('@'+counter+'@',dataArray[counter-1])}}
return resultStr},getInsertedStringFromErrorNumber:function(errNum,dataArray){'use strict';var resultStr,counter,messageArray;messageArray=INTERMediatorOnPage.getMessages();resultStr=messageArray?messageArray[errNum]:'Error:'+errNum;if(dataArray){for(counter=1;counter<=dataArray.length;counter++){resultStr=resultStr.replace('@'+counter+'@',dataArray[counter-1])}}
return resultStr},getNamedObject:function(obj,key,named){'use strict';var index;for(index in obj){if(obj[index][key]===named){return obj[index]}}
return null},getNamedObjectInObjectArray:function(ar,key,named){'use strict';var i;for(i=0;i<ar.length;i++){if(ar[i][key]===named){return ar[i]}}
return null},getNamedValueInObject:function(ar,key,named,retrieveKey){var result=[],index;for(index in ar){if(ar[index][key]===named){result.push(ar[index][retrieveKey])}}
if(result.length===0){return null}else if(result.length===1){return result[0]}else{return result}},is_array:function(target){'use strict';return target&&typeof target==='object'&&typeof target.length==='number'&&typeof target.splice==='function'&&!(target.propertyIsEnumerable('length'))},getNamedValuesInObject:function(ar,key1,named1,key2,named2,retrieveKey){'use strict';var result=[],index;for(index in ar){if(ar.hasOwnProperty(index)&&ar[index][key1]===named1&&ar[index][key2]===named2){result.push(ar[index][retrieveKey])}}
if(result.length===0){return null}else if(result.length===1){return result[0]}else{return result}},getRecordsetFromFieldValueObject:function(obj){'use strict';var recordset={},index;for(index in obj){if(obj.hasOwnProperty(index)){recordset[obj[index].field]=obj[index].value}}
return recordset},getNodePath:function(node){'use strict';if(node.tagName===null){return''}else{return INTERMediatorLib.getNodePath(node.parentNode)+'/'+node.tagName}},isPopupMenu:function(element){'use strict';if(!element||!element.tagName){return!1}
if(element.tagName==='SELECT'){return!0}
return!1},getElementsByClassNameOrDataAttr:function(node,cName){'use strict';var nodes=[],attrValue;attrValue=(cName.match(/^_im_/))?cName.substr(4):cName;if(attrValue){checkNode(node)}
return nodes;function checkNode(target){var value,i,items;if(target===undefined||target.nodeType!==1){return}
value=INTERMediatorLib.getClassAttributeFromNode(target);if(value){items=value.split('|');for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
value=target.getAttribute('data-im-control');if(value){items=value.split(/[| ]/);for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
value=target.getAttribute('data-im');if(value){items=value.split(/[| ]/);for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByAttributeValue:function(node,attribute,value){'use strict';var nodes=[];var reg=new RegExp(value);checkNode(node);return nodes;function checkNode(target){var aValue,i;if(target===undefined||target.nodeType!==1){return}
aValue=target.getAttribute(attribute);if(aValue&&aValue.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByClassName:function(node,cName){'use strict';var nodes=[];var reg=new RegExp(cName);checkNode(node);return nodes;function checkNode(target){var className,i;if(target===undefined||target.nodeType!==1){return}
className=INTERMediatorLib.getClassAttributeFromNode(target);if(className&&className.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByIMManaged:function(node){'use strict';var nodes=[];var reg=new RegExp(/^IM/);checkNode(node);return nodes;function checkNode(target){var nodeId,i;if(target===undefined||target.nodeType!==1){return}
nodeId=target.getAttribute('id');if(nodeId&&nodeId.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},seekLinkedAndWidgetNodes:function(nodes,ignoreEnclosureCheck){'use strict';var linkedNodesCollection=[];var widgetNodesCollection=[];var i,doEncCheck=ignoreEnclosureCheck;if(ignoreEnclosureCheck===undefined||ignoreEnclosureCheck===null){doEncCheck=!1}
for(i=0;i<nodes.length;i++){seekLinkedElement(nodes[i])}
return{linkedNode:linkedNodesCollection,widgetNode:widgetNodesCollection};function seekLinkedElement(node){var nType,currentEnclosure,children,i;nType=node.nodeType;if(nType===1){if(INTERMediatorLib.isLinkedElement(node)){currentEnclosure=doEncCheck?INTERMediatorLib.getEnclosure(node):null;if(currentEnclosure===null){linkedNodesCollection.push(node)}else{return currentEnclosure}}
if(INTERMediatorLib.isWidgetElement(node)){currentEnclosure=doEncCheck?INTERMediatorLib.getEnclosure(node):null;if(currentEnclosure===null){widgetNodesCollection.push(node)}else{return currentEnclosure}}
children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElement(children[i])}}
return null}},createErrorMessageNode:function(tag,message){'use strict';var messageNode;messageNode=document.createElement(tag);INTERMediatorLib.setClassAttributeToNode(messageNode,'_im_alertmessage');messageNode.appendChild(document.createTextNode(message));return messageNode},removeChildNodes:function(node){'use strict';if(node){while(node.childNodes.length>0){node.removeChild(node.childNodes[0])}}},clearErrorMessage:function(node){'use strict';var errorMsgs,j;if(node){errorMsgs=INTERMediatorLib.getElementsByClassName(node.parentNode,'_im_alertmessage');for(j=0;j<errorMsgs.length;j++){errorMsgs[j].parentNode.removeChild(errorMsgs[j])}}},dateTimeStringISO:function(dt){'use strict';dt=(!dt)?new Date():dt;return dt.getFullYear()+'-'+('0'+(dt.getMonth()+1)).substr(-2,2)+'-'+('0'+dt.getDate()).substr(-2,2)+' '+('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)},dateTimeStringFileMaker:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+(dt.getMonth()+1)).substr(-2,2)+'/'+('0'+dt.getDate()).substr(-2,2)+'/'+dt.getFullYear()+' '+('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)},dateStringISO:function(dt){'use strict';dt=(!dt)?new Date():dt;return dt.getFullYear()+'-'+('0'+(dt.getMonth()+1)).substr(-2,2)+'-'+('0'+dt.getDate()).substr(-2,2)},dateStringFileMaker:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+(dt.getMonth()+1)).substr(-2,2)+'/'+('0'+dt.getDate()).substr(-2,2)+'/'+dt.getFullYear()},timeString:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)}};INTERMediatorLib.initialize();var IMLibNodeGraph={nodes:[],edges:[],clear:function(){'use strict';this.nodes=[];this.edges=[]},addNode:function(node){'use strict';if(this.nodes.indexOf(node)<0){this.nodes.push(node)}},addEdge:function(fromNode,toNode){'use strict';if(this.nodes.indexOf(fromNode)<0){this.addNode(fromNode)}
if(this.nodes.indexOf(toNode)<0){this.addNode(toNode)}
this.edges.push({from:fromNode,to:toNode})},getAllNodesInEdge:function(){'use strict';var i,nodes=[];for(i=0;i<this.edges.length;i++){if(nodes.indexOf(this.edges[i].from)<0){nodes.push(this.edges[i].from)}
if(nodes.indexOf(this.edges[i].to)<0){nodes.push(this.edges[i].to)}}
return nodes},getLeafNodes:function(){'use strict';var i,srcs=[],dests=[],srcAndDests=this.getAllNodesInEdge();for(i=0;i<this.edges.length;i++){srcs.push(this.edges[i].from)}
for(i=0;i<this.edges.length;i++){if(srcs.indexOf(this.edges[i].to)<0&&dests.indexOf(this.edges[i].to)<0){dests.push(this.edges[i].to)}}
for(i=0;i<this.nodes.length;i++){if(srcAndDests.indexOf(this.nodes[i])<0){dests.push(this.nodes[i])}}
return dests},getLeafNodesWithRemoving:function(){'use strict';var i,newEdges=[],dests=this.getLeafNodes();for(i=0;i<this.edges.length;i++){if(dests.indexOf(this.edges[i].to)<0){newEdges.push(this.edges[i])}}
this.edges=newEdges;for(i=0;i<dests.length;i++){this.nodes.splice(this.nodes.indexOf(dests[i]),1)}
return dests},removeNode:function(node){'use strict';var i,newEdges=[];for(i=0;i<this.edges.length;i++){if(this.edges[i].to!=node){newEdges.push(this.edges[i])}}
this.edges=newEdges;this.nodes.splice(this.nodes.indexOf(node),1)},applyToAllNodes:function(f){'use strict';var i;for(i=0;i<this.nodes.length;i++){f(this.nodes[i])}},};var IMLibFormat={numberFormatImpl:function(str,digit,decimalPoint,thousandsSep,currencySymbol,flags){'use strict';var s,n,prefix,i,sign,tailSign='',power,underDot,underNumStr,pstr,roundedNum,underDecimalNum,integerNum,formatted,numStr,j,isMinusValue,numerals,numbers;if(str===''||str===null||str===undefined){return''}
prefix=(String(str).substring(0,1)==='-')?'-':'';if(String(str).match(/[-]/)){str=prefix+String(str).split('-').join('')}
n=INTERMediatorLib.toNumber(str);if(isNaN(n)){return''}
if(flags===undefined){flags={}}
sign=INTERMediatorOnPage.localeInfo.positive_sign;isMinusValue=!1;if(n<0){sign=INTERMediatorOnPage.localeInfo.negative_sign;if(flags.negativeStyle===0||flags.negativeStyle===1){sign='-'}else if(flags.negativeStyle===2){sign='(';tailSign=')'}else if(flags.negativeStyle===3){sign='<';tailSign='>'}else if(flags.negativeStyle===4){sign=' CR'}else if(flags.negativeStyle===5){sign='▲'}
n=-n;isMinusValue=!0}
if(flags.blankIfZero===!0&&n===0){return''}
if(flags.usePercentNotation){n=n*100}
underDot=(digit===undefined)?INTERMediatorOnPage.localeInfo.frac_digits:INTERMediatorLib.toNumber(digit);power=Math.pow(10,underDot);roundedNum=Math.round(n*power);underDecimalNum=(underDot>0)?roundedNum%power:0;integerNum=(roundedNum-underDecimalNum)/power;underNumStr=(underDot>0)?String(underDecimalNum):'';while(underNumStr.length<underDot){underNumStr='0'+underNumStr}
if(flags.useSeparator===!0){if(n===0){formatted='0'}else{n=integerNum;s=[];if(flags.kanjiSeparator===1||flags.kanjiSeparator===2){numerals=['万','億','兆','京','垓','𥝱','穣','溝','澗','正','載','極','恒河沙','阿僧祇','那由他','不可思議','無量大数'];i=0;formatted='';for(n=Math.floor(n);n>0;n=Math.floor(n/10000)){if(n>=10000){pstr='0000'+(n%10000).toString()}else{pstr=(n%10000).toString()}
if(flags.kanjiSeparator===1){if(n>=10000){if(pstr.substr(pstr.length-4)!=='0000'){formatted=numerals[i]+Number(pstr.substr(pstr.length-4))+formatted}else{if(numerals[i-1]!==formatted.charAt(0)){formatted=numerals[i]+formatted}else{formatted=numerals[i]+formatted.slice(1)}}}else{formatted=n+formatted}}else if(flags.kanjiSeparator===2){numStr=pstr.substr(pstr.length-4);pstr='';if(numStr==='0001'){pstr='1'}else if(numStr!=='0000'){for(j=0;j<numStr.length;j++){if(numStr.charAt(j)>1){pstr=pstr+numStr.charAt(j)}
if(numStr.charAt(j)>0){if(numStr.length-j===4){pstr=pstr+'千'}else if(numStr.length-j===3){pstr=pstr+'百'}else if(numStr.length-j===2){pstr=pstr+'十'}}}}
if(n>=10000){if(pstr.length>0){formatted=numerals[i]+pstr+formatted}else{if(numerals[i-1]!==formatted.charAt(0)){formatted=numerals[i]+formatted}else{formatted=numerals[i]+formatted.slice(1)}}}else{if(numStr.length===1){formatted=n+formatted}else{formatted=pstr+formatted}}}
i++}
formatted=formatted+(underNumStr===''?'':decimalPoint+underNumStr)}else{for(n=Math.floor(n);n>0;n=Math.floor(n/1000)){if(n>=1000){pstr='000'+(n%1000).toString();s.push(pstr.substr(pstr.length-3))}else{s.push(n)}}
formatted=s.reverse().join(thousandsSep)+(underNumStr===''?'':decimalPoint+underNumStr)}
if(flags.negativeStyle===0||flags.negativeStyle===5){formatted=sign+formatted}else if(flags.negativeStyle===1||flags.negativeStyle===4){formatted=formatted+sign}else if(flags.negativeStyle===2||flags.negativeStyle===3){formatted=sign+formatted+tailSign}else{formatted=sign+formatted}}}else{formatted=integerNum+(underNumStr===''?'':decimalPoint+underNumStr);if(flags.negativeStyle===0||flags.negativeStyle===5){formatted=sign+formatted}else if(flags.negativeStyle===1||flags.negativeStyle===4){formatted=formatted+sign}else if(flags.negativeStyle===2||flags.negativeStyle===3){formatted=sign+formatted+tailSign}else{formatted=sign+formatted}}
if(currencySymbol){if(!isMinusValue){if(parseInt(INTERMediatorOnPage.localeInfo.p_cs_precedes)===1){if(parseInt(INTERMediatorOnPage.localeInfo.p_sep_by_space)===1){formatted=currencySymbol+' '+formatted}else{formatted=currencySymbol+formatted}}else{if(parseInt(INTERMediatorOnPage.localeInfo.p_sep_by_space)===1){formatted=formatted+' '+currencySymbol}else{formatted=formatted+currencySymbol}}}else{if(parseInt(INTERMediatorOnPage.localeInfo.n_cs_precedes)===1){if(parseInt(INTERMediatorOnPage.localeInfo.n_sep_by_space)===1){formatted=currencySymbol+' '+formatted}else{formatted=currencySymbol+formatted}}else{if(parseInt(INTERMediatorOnPage.localeInfo.n_sep_by_space)===1){formatted=formatted+' '+currencySymbol}else{formatted=formatted+currencySymbol}}}}
if(flags.charStyle){if(flags.charStyle===1){for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String.fromCharCode(65296+i))}}else if(flags.charStyle===2){numbers={0:'〇',1:'一',2:'二',3:'三',4:'四',5:'五',6:'六',7:'七',8:'八',9:'九'};for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String(numbers[i]))}}else if(flags.charStyle===3){numbers={0:'〇',1:'壱',2:'弐',3:'参',4:'四',5:'伍',6:'六',7:'七',8:'八',9:'九'};for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String(numbers[i]))}}}
if(flags.usePercentNotation===!0&&formatted!==''){formatted=formatted+'%'}
return formatted},getKanjiNumber:function(n){'use strict';var s=[],count=0;String(n).split('').reverse().forEach(function(c){s.push(IMLibFormat.kanjiDigit[count]);count++;s.push(IMLibFormat.kanjiNumbers[parseInt(c)])});return s.reverse().join('')},numberFormat:function(str,digit,flags){'use strict';if(flags===undefined){flags={}}
flags.useSeparator=!0;return this.decimalFormat(str,digit,flags)},percentFormat:function(str,digit,flags){'use strict';if(typeof flags!=='object'){flags={}}
flags.usePercentNotation=!0;return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',!1,flags)},decimalFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',!1,flags)},currencyFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',INTERMediatorOnPage.localeInfo.currency_symbol?INTERMediatorOnPage.localeInfo.currency_symbol:'¥',flags)},booleanFormat:function(str,forms){'use strict';var trueString='true',falseString='false',fmtStr;var params=forms.split(',');if(params[0]){fmtStr=params[0].trim();if(fmtStr.length>0){trueString=fmtStr}}
if(params[1]){fmtStr=params[1].trim();if(fmtStr.length>0){falseString=fmtStr}}
if(str===''||str===null){return''}else{if(parseInt(str,10)!==0){return trueString}else{return falseString}}},datetimeFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'datetime')},dateFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'date')},timeFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'time')},placeHolder:{'%Y':Date.prototype.getFullYear,'%y':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getFullYear())},'%g':function(){'use strict';return IMLibFormat.getLocalYear(this,1)},'%G':function(){'use strict';return IMLibFormat.getLocalYear(this,2)},'%M':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getMonth()+1)},'%m':function(){'use strict';return this.getMonth()+1},'%b':function(){'use strict';return INTERMediatorOnPage.localeInfo.ABMON[this.getMonth()]},'%B':function(){'use strict';return INTERMediatorOnPage.localeInfo.MON[this.getMonth()]},'%t':function(){'use strict';return IMLibFormat.eMonAbbr[this.getMonth()]},'%T':function(){'use strict';return IMLibFormat.eMonName[this.getMonth()]},'%D':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getDate())},'%d':Date.prototype.getDate,'%a':function(){'use strict';return IMLibFormat.eDayAbbr[this.getDay()]},'%A':function(){'use strict';return IMLibFormat.eDayName[this.getDay()]},'%w':function(){'use strict';return INTERMediatorOnPage.localeInfo.ABDAY[this.getDay()]},'%W':function(){'use strict';return INTERMediatorOnPage.localeInfo.DAY[this.getDay()]},'%H':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getHours())},'%h':Date.prototype.getHours,'%J':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getHours()%12)},'%j':function(){'use strict';return this.getHours()%12},'%K':function(){'use strict';var n=this.getHours()%12;return IMLibFormat.tweDigitsNumber(n===0?12:n)},'%k':function(){'use strict';var n=this.getHours()%12;return n===0?12:n},'%I':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getMinutes())},'%i':Date.prototype.getMinutes,'%S':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getSeconds())},'%s':Date.prototype.getSeconds,'%P':function(){'use strict';return Math.floor(this.getHours()/12)===0?'AM':'PM'},'%p':function(){'use strict';return Math.floor(this.getHours()/12)===0?'am':'pm'},'%N':function(){'use strict';return Math.floor(this.getHours()/12)===0?INTERMediatorOnPage.localeInfo.AM_STR:INTERMediatorOnPage.localeInfo.PM_STR},'%%':function(){'use strict';return'%'}},tweDigitsNumber:function(n){'use strict';var v=parseInt(n);return('0'+v.toString()).substr(-2,2)},jYearStartDate:{'2019/5/1':'令和','1989/1/8':'平成','1926/12/25':'昭和','1912/7/30':'大正','1868/1/25':'明治'},eDayName:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],eDayAbbr:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],eMonName:['January','February','March','April','May','June','July','August','September','October','November','December'],eMonAbbr:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],kanjiNumbers:['〇','一','二','三','四','五','六','七','八','九'],kanjiDigit:['','十','百','千','万'],getLocalYear:function(dt,fmt){'use strict';var gengoName,gengoYear,startDateStr,dtStart;if(!dt){return''}
gengoName='';gengoYear=0;for(startDateStr in IMLibFormat.jYearStartDate){if(IMLibFormat.jYearStartDate.hasOwnProperty(startDateStr)){dtStart=new Date(startDateStr);if(dt>=dtStart){gengoName=IMLibFormat.jYearStartDate[startDateStr];gengoYear=dt.getFullYear()-dtStart.getFullYear()+1;gengoYear=((gengoYear===1)?'元':(fmt===2?IMLibFormat.getKanjiNumber(gengoYear):gengoYear));break}}}
return gengoName+gengoYear+'年'},datetimeFormatImpl:function(str,params,flags){'use strict';var dt,c,result='',replaced,hasColon,hasSlash,hasDash;str=(Object.prototype.toString.call(str)==='[object Array]')?str.join():str;var paramStr=params.trim().toUpperCase();var kind=flags.trim().toUpperCase();var key=kind.substr(0,1)+'_FMT_'+paramStr;if(INTERMediatorOnPage.localeInfo[key]){params=INTERMediatorOnPage.localeInfo[key];if(kind==='DATETIME'){params+=' '+INTERMediatorOnPage.localeInfo['T_FMT_'+paramStr]}}
hasColon=str.indexOf(':')>-1;hasSlash=str.indexOf('/')>-1;hasDash=str.indexOf('-')>-1;if(!hasColon&&(hasSlash||hasDash)){str+=' 00:00:00'}else if(hasColon&&!hasSlash&&!hasDash){str='1970/01/01 '+str}
dt=new Date(str);if(dt.toString()==='Invalid Date'){dt=new Date(str.replace(/-/g,'/'))}
if(dt.toString()==='Invalid Date'){return''}
for(c=0;c<params.length;c++){if((c+1)<params.length&&IMLibFormat.placeHolder[params.substr(c,2)]){replaced=(IMLibFormat.placeHolder[params.substr(c,2)]).apply(dt);result+=replaced;c++}else{result+=params.substr(c,1)}}
return result},convertNumeric:function(value){'use strict';value=value.replace(new RegExp(INTERMediatorOnPage.localeInfo.mon_thousands_sep,'g'),'');value=INTERMediatorLib.normalizeNumerics(value);if(value!==''){value=parseFloat(value)}
return value},convertBoolean:function(value,forms){'use strict';var trueString='true',falseString='false',fmtStr;value=value.trim();var params=forms.split(',');if(params[0]){fmtStr=params[0].trim();if(fmtStr.length>0){trueString=fmtStr}}
if(params[1]){fmtStr=params[1].trim();if(fmtStr.length>0){falseString=fmtStr}}
if(value===trueString){return!0}else if(value===falseString){return!1}
return null},convertPercent:function(value){'use strict';value=value.replace(new RegExp(INTERMediatorOnPage.localeInfo.mon_thousands_sep,'g'),'');value=value.replace('%','');value=INTERMediatorLib.normalizeNumerics(value);if(value!==''){value=parseFloat(value)/100}
return value},convertDate:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'date')},convertTime:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'time')},convertDateTime:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'datetime')},convertDateTimeImpl:function(value,params,flags){'use strict';var c,result,replacement=[],regexp='';var r,matched,y,m,d,h,i,s,paramStr,kind,key,mon;paramStr=params.trim().toUpperCase();kind=flags.trim().toUpperCase();key=kind.substr(0,1)+'_FMT_'+paramStr;if(INTERMediatorOnPage.localeInfo[key]){params=INTERMediatorOnPage.localeInfo[key];if(kind==='DATETIME'){params+=' '+INTERMediatorOnPage.localeInfo['T_FMT_'+paramStr]}}
params=params.replace(/([\(\)])/g,'\\$1');for(c=0;c<params.length;c++){if((c+1)<params.length&&IMLibFormat.reverseRegExp[params.substr(c,2)]){regexp+=IMLibFormat.reverseRegExp[params.substr(c,2)];replacement.push(params.substr(c,2));c++}else{regexp+=params.substr(c,1)}}
r=new RegExp(regexp);matched=r.exec(value);result=value;if(matched){for(c=0;c<replacement.length;c++){switch(replacement[c]){case '%Y':case '%y':y=matched[c+1];break;case '%M':case '%m':m=matched[c+1];break;case '%T':case '%t':mon=matched[c+1];m=IMLibFormat.eMonAbbr.indexOf(mon.substr(0,1).toUpperCase()+mon.substr(1,2).toLowerCase());m++;break;case '%D':case '%d':d=matched[c+1];break;case '%H':case '%h':h=matched[c+1];break;case '%I':case '%i':i=matched[c+1];break;case '%S':case '%s':s=matched[c+1];break}}
if(y&&m&&d&&h&&i&&s){result=y+'-'+m+'-'+d+' '+h+':'+i+':'+s}else if(y&&m&&d){result=y+'-'+m+'-'+d}else if(h&&i&&s){result=h+':'+i+':'+s}}
return result},reverseRegExp:{'%Y':'([\\d]{4})','%y':'([\\d]{2})','%g':'(明治|大正|昭和|平成|令和)(元|[\\d]{1,2})年','%G':'(明治|大正|昭和|平成|令和)(.+)年','%M':'([\\d]{1,2})','%m':'([\\d]{1,2})','%b':'(.+)','%B':'(.+)','%t':'(.+)','%T':'(.+)','%D':'([\\d]{1,2})','%d':'([\\d]{1,2})','%a':'(.+)','%A':'(.+)','%w':'(.+)','%W':'(.+)','%H':'([\\d]{1,2})','%h':'([\\d]{1,2})','%J':'([\\d]{1,2})','%j':'([\\d]{1,2})','%K':'([\\d]{1,2})','%k':'([\\d]{1,2})','%I':'([\\d]{1,2})','%i':'([\\d]{1,2})','%S':'([\\d]{1,2})','%s':'([\\d]{1,2})','%P':'(AM|PM)','%p':'(am|pm)','%N':'('+INTERMediatorOnPage.localeInfo.AM_STR+'|'+INTERMediatorOnPage.localeInfo.PM_STR+')','%%':'[\%]'}};var IMLibElement={formatters:{number:IMLibFormat.decimalFormat,currency:IMLibFormat.currencyFormat,boolean:IMLibFormat.booleanFormat,percent:IMLibFormat.percentFormat,date:IMLibFormat.dateFormat,datetime:IMLibFormat.datetimeFormat,time:IMLibFormat.timeFormat},unformatters:{number:IMLibFormat.convertNumeric,currency:IMLibFormat.convertNumeric,boolean:IMLibFormat.convertBoolean,percent:IMLibFormat.convertPercent,date:IMLibFormat.convertDate,datetime:IMLibFormat.convertDateTime,time:IMLibFormat.convertTime},formatOptions:{'useseparator':{useSeparator:!0},'blankifzero':{blankIfZero:!0}},formatNegativeStyle:{leadingminus:{negativeStyle:0},'leading-minus':{negativeStyle:0},trailingminus:{negativeStyle:1},'trailing-minus':{negativeStyle:1},parenthesis:{negativeStyle:2},angle:{negativeStyle:3},credit:{negativeStyle:4},triangle:{negativeStyle:5}},formatNumeralType:{'half-width':{charStyle:0},'full-width':{charStyle:1},'kanji-numeral-modern':{charStyle:2},'kanji-numeral':{charStyle:3}},formatKanjiSeparator:{'every-4th-place':{kanjiSeparator:1,useSeparator:!0},'full-notation':{kanjiSeparator:2,useSeparator:!0}},appendObject:function(obj,adding){'use strict';var result=obj;if(adding){for(var key in adding){if(adding.hasOwnProperty(key)){result[key]=adding[key]}}}
return result},initilaizeFlags:function(element){'use strict';var flags,formatOption,negativeStyle,charStyle,kanjiSeparator;flags={useSeparator:!1,blankIfZero:!1,negativeStyle:0,charStyle:0,kanjiSeparator:0};formatOption=element.getAttribute('data-im-format-options');flags=IMLibElement.appendObject(flags,IMLibElement.formatOptions[formatOption]);negativeStyle=element.getAttribute('data-im-format-negative-style');flags=IMLibElement.appendObject(flags,IMLibElement.formatNegativeStyle[negativeStyle]);charStyle=element.getAttribute('data-im-format-numeral-type');flags=IMLibElement.appendObject(flags,IMLibElement.formatNumeralType[charStyle]);kanjiSeparator=element.getAttribute('data-im-format-kanji-separator');flags=IMLibElement.appendObject(flags,IMLibElement.formatKanjiSeparator[kanjiSeparator]);return flags},getFormattedValue:function(element,curVal){'use strict';var flags,formatSpec,parsed,formattedValue=null,params,formatFunc,firstParen,lastParen;formatSpec=element.getAttribute('data-im-format');if(!formatSpec){return null}
flags=IMLibElement.initilaizeFlags(element);params=0;formatFunc=IMLibElement.formatters[formatSpec.trim().toLocaleLowerCase()];if(!formatFunc){firstParen=formatSpec.indexOf('(');lastParen=formatSpec.lastIndexOf(')');parsed=formatSpec.substr(0,firstParen).match(/[^a-zA-Z]*([a-zA-Z]+).*/);formatFunc=IMLibElement.formatters[parsed[1].toLocaleLowerCase()];params=formatSpec.substring(firstParen+1,lastParen);if(params.length===0){params=0}}
if(formatFunc){formattedValue=formatFunc(curVal,params,flags)}
return formattedValue},getUnformattedValue:function(element,value){'use strict';var formatSpec,unformatFunc,parsed,params,convertedValue,flags,firstParen,lastParen;formatSpec=element.getAttribute('data-im-format');if(!formatSpec){return null}
flags=IMLibElement.initilaizeFlags(element);unformatFunc=IMLibElement.unformatters[formatSpec.trim().toLocaleLowerCase()];if(!unformatFunc){firstParen=formatSpec.indexOf('(');lastParen=formatSpec.lastIndexOf(')');parsed=formatSpec.substr(0,firstParen).match(/[^a-zA-Z]*([a-zA-Z]+).*/);unformatFunc=IMLibElement.unformatters[parsed[1].toLocaleLowerCase()];params=formatSpec.substring(firstParen+1,lastParen)}
if(unformatFunc){convertedValue=unformatFunc(value,params,flags)}
return convertedValue},setValueToIMNode:function(element,curTarget,curVal,clearField){'use strict';var styleName,currentValue,scriptNode,typeAttr,valueAttr,textNode,formatSpec,formattedValue,needPostValueSet=!1,curValues,i,isReplaceOrAppend=!1,imControl,negativeColor,originalValue,negativeSign,negativeTailSign,flags;if(curVal===undefined){return!1}
if(!element){return!1}
if(curVal===null||curVal===!1){curVal=''}
if(typeof curVal==='object'&&curVal.constructor===Array&&curVal.length>0){curVal=curVal[0]}
imControl=element.getAttribute('data-im-control');if(clearField&&curTarget===''){switch(element.tagName){case 'INPUT':switch(element.getAttribute('type')){case 'text':element.value='';break}
break;case 'SELECT':break;default:while(element.childNodes.length>0){if(element.parentNode.getAttribute('data-im-element')==='processed'||INTERMediatorLib.isWidgetElement(element.parentNode)){return!1}
element.removeChild(element.childNodes[0])}
break}}
formattedValue=IMLibElement.getFormattedValue(element,curVal);if(element.getAttribute('data-im-format')){if(formattedValue===null){INTERMediatorLog.setErrorMessage('The \'data-im-format\' attribute is not valid: '+formatSpec)}else{curVal=formattedValue}}
curVal=String(curVal);negativeColor=element.getAttribute('data-im-format-negative-color');if(curTarget!==null&&curTarget.length>0){if(curTarget.charAt(0)==='#'){curTarget=curTarget.substring(1);originalValue=element.getAttribute('data-im-original-'+curTarget);if(curTarget==='innerHTML'){currentValue=originalValue?originalValue:element.innerHTML;element.innerHTML=currentValue+curVal}else if(curTarget==='textNode'||curTarget==='script'){currentValue=originalValue?originalValue:element.textContent;element.textContent=currentValue+curVal}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);currentValue=originalValue?originalValue:element.style[styleName];if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=currentValue+curVal}}else{currentValue=originalValue?originalValue:element.getAttribute(curTarget);if(curVal.indexOf('/fmi/xml/cnt/')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal}else if(curVal.indexOf('https://'+location.hostname+'/Streaming_SSL/MainDB')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+encodeURIComponent(curVal.replace('https://'+location.hostname,''))}
element.setAttribute(curTarget,currentValue+curVal)}
isReplaceOrAppend=!0;if(!originalValue){element.setAttribute('data-im-original-'+curTarget,currentValue)}}else if(curTarget.charAt(0)==='){curTarget=curTarget.substring(1);originalValue=element.getAttribute('data-im-original-'+curTarget);if(curTarget==='innerHTML'){currentValue=element.innerHTML;curVal=currentValue.replace(',curVal);if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else if(curTarget==='textNode'||curTarget==='script'){currentValue=element.textContent;element.textContent=currentValue.replace(',curVal)}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);currentValue=element.style[styleName];if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=currentValue.replace(',curVal)}}else{currentValue=element.getAttribute(curTarget);if(curVal.indexOf('/fmi/xml/cnt/')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal}else if(curVal.indexOf('https://'+location.hostname+'/Streaming_SSL/MainDB')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal.replace('https://'+location.hostname,'')}
element.setAttribute(curTarget,currentValue.replace(',curVal))}
isReplaceOrAppend=!0;if(!originalValue){element.setAttribute('data-im-original-'+curTarget,currentValue)}}else{if(INTERMediatorLib.isWidgetElement(element)){if(element._im_setValue){element._im_setValue(curVal)}}else if(curTarget==='innerHTML'){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else if(curTarget==='textNode'){textNode=document.createTextNode(curVal);element.appendChild(textNode)}else if(curTarget==='script'){textNode=document.createTextNode(curVal);if(element.tagName==='SCRIPT'){element.appendChild(textNode)}else{scriptNode=document.createElement('script');scriptNode.type='text/javascript';scriptNode.appendChild(textNode);element.appendChild(scriptNode)}}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=curVal}}else{if(INTERMediator.isIE&&INTERMediator.ieVersion<10&&element.tagName==='TEXTAREA'){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.setAttribute(curTarget,curVal)}}}else{if(INTERMediatorLib.isWidgetElement(element)){if(element._im_setValue){element._im_setValue(curVal)}}else if(element.tagName==='INPUT'){typeAttr=element.getAttribute('type');if(typeAttr==='checkbox'||typeAttr==='radio'){valueAttr=element.value;if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){curValues=curVal.split(IMLib.cr_char)}else{curValues=curVal.split(IMLib.nl_char)}
if(typeAttr==='checkbox'&&curValues.length>1){for(i=0;i<curValues.length;i++){if(valueAttr===curValues[i]&&!INTERMediator.dontSelectRadioCheck){if(INTERMediator.isIE){element.setAttribute('checked','checked')}else{element.checked=!0}}}}else{if(valueAttr===curVal&&!INTERMediator.dontSelectRadioCheck){if(INTERMediator.isIE){element.setAttribute('checked','checked')}else{element.checked=!0}}else{element.checked=!1}}}else{element.value=curVal}}else if(element.tagName==='SELECT'){needPostValueSet=!0;element.value=curVal}else if(element.tagName==='TEXTAREA'){if(INTERMediator.defaultTargetInnerHTML){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else{element.value=curVal}}else{if(INTERMediator.defaultTargetInnerHTML){element.innerHTML=curVal}else{element.appendChild(document.createTextNode(curVal))}}}
if(formatSpec&&negativeColor){negativeSign=INTERMediatorOnPage.localeInfo.negative_sign;negativeTailSign='';flags=IMLibElement.initilaizeFlags(element);if(flags.negativeStyle===0||flags.negativeStyle===1){negativeSign='-'}else if(flags.negativeStyle===2){negativeSign='(';negativeTailSign=')'}else if(flags.negativeStyle===3){negativeSign='<';negativeTailSign='>'}else if(flags.negativeStyle===4){negativeSign=' CR'}else if(flags.negativeStyle===5){negativeSign='▲'}
if(flags.negativeStyle===0||flags.negativeStyle===5){if(curVal.indexOf(negativeSign)===0){element.style.color=negativeColor}}else if(flags.negativeStyle===1||flags.negativeStyle===4){if(curVal.indexOf(negativeSign)>-1&&curVal.indexOf(negativeSign)===curVal.length-negativeSign.length){element.style.color=negativeColor}}else if(flags.negativeStyle===2||flags.negativeStyle===3){if(curVal.indexOf(negativeSign)===0){if(curVal.indexOf(negativeTailSign)>-1&&curVal.indexOf(negativeTailSign)===curVal.length-1){element.style.color=negativeColor}}}}
if((element.tagName==='INPUT'||element.tagName==='SELECT'||element.tagName==='TEXTAREA')&&!isReplaceOrAppend&&(!imControl||imControl.indexOf('unbind')>0)){if(!element.getAttribute('data-imbluradded')){INTERMediatorLib.addEvent(element,'blur',(function(){var idValue=element.id;var elementCapt=element;return function(){if(!IMLibUI.valueChange(idValue,!0)){elementCapt.focus()}}})());element.setAttribute('data-imbluradded','set')}
if(!element.getAttribute('data-imchangeadded')){IMLibChangeEventDispatch.setExecute(element.id,(function(){var idValue=element.id;var elementCapt=element;return function(){if(!IMLibUI.valueChange(idValue,!1)){elementCapt.focus()}}})());element.setAttribute('data-imchangeadded','set')}
if((INTERMediator.isTrident||INTERMediator.isEdge)&&!element.getAttribute('data-iminputadded')){IMLibInputEventDispatch.setExecute(element.id,(function(){var idValue=element.id;var elementCapt=element;return function(){if(document.getElementById(idValue).value===''){if(!IMLibUI.valueChange(idValue,!1)){elementCapt.focus()}}}})());element.setAttribute('data-iminputadded','set')}}
element.setAttribute('data-im-element','processed');return needPostValueSet},getValueFromIMNode:function(element){'use strict';var nodeTag,typeAttr,newValue,mergedValues,targetNodes,k,valueAttr,convertedValue;if(element){nodeTag=element.tagName;typeAttr=element.getAttribute('type')}else{return''}
if(INTERMediatorLib.isWidgetElement(element)||(INTERMediatorLib.isWidgetElement(element.parentNode))){newValue=element._im_getValue()}else if(nodeTag==='INPUT'){if(typeAttr==='checkbox'){if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){mergedValues=[];targetNodes=element.parentNode.getElementsByTagName('INPUT');for(k=0;k<targetNodes.length;k++){if(targetNodes[k].checked){mergedValues.push(targetNodes[k].getAttribute('value'))}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){newValue=mergedValues.join(IMLib.cr_char)}else{newValue=mergedValues.join(IMLib.nl_char)}}else{valueAttr=element.getAttribute('value');if(element.checked){newValue=valueAttr}else{newValue=''}}}else if(typeAttr==='radio'){newValue=element.value}else{newValue=element.value}}else if(nodeTag==='SELECT'){newValue=element.value}else if(nodeTag==='TEXTAREA'){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){newValue=element.innerHTML.replace(/<br[\/]{0,1}>/g,'\n')}else{newValue=element.value}}else{newValue=element.innerHTML}
convertedValue=IMLibElement.getUnformattedValue(element,newValue);newValue=convertedValue?convertedValue:newValue;return newValue},deleteNodes:function(removeNodes){'use strict';var removeNode,removingNodes,i,j,k,removeNodeId,nodeId,calcObject,referes,values,key;for(key=0;key<removeNodes.length;key++){removeNode=document.getElementById(removeNodes[key]);if(removeNode){removingNodes=INTERMediatorLib.getElementsByIMManaged(removeNode);if(removingNodes){for(i=0;i<removingNodes.length;i++){removeNodeId=removingNodes[i].id;if(removeNodeId in IMLibCalc.calculateRequiredObject){delete IMLibCalc.calculateRequiredObject[removeNodeId]}}
for(i=0;i<removingNodes.length;i++){removeNodeId=removingNodes[i].id;for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];referes={};values={};for(j in calcObject.referes){if(calcObject.referes.hasOwnProperty(j)){referes[j]=[];values[j]=[];for(k=0;k<calcObject.referes[j].length;k++){if(removeNodeId!==calcObject.referes[j][k]){referes[j].push(calcObject.referes[j][k]);values[j].push(calcObject.values[j][k])}}}}
calcObject.referes=referes;calcObject.values=values}}}}
try{removeNode.parentNode.removeChild(removeNode)}catch(ex){}}}}};var Parser=(function(scope){var TNUMBER=0;var TOP1=1;var TOP2=2;var TOP3=5;var SEP=65;var TVAR=3;var TFUNCALL=4;Parser.regFirstVarChar=new RegExp('[\u00A0-\u1FFF\u2C00-\uDFFFa-zA-Z@_]');Parser.regRestVarChar=new RegExp('[\u00A0-\u1FFF\u2C00-\uDFFFa-zA-Z@_:0-9]');function Token(type_,index_,prio_,number_){this.type_=type_;this.index_=index_||0;this.prio_=prio_||0;this.number_=(number_!==undefined&&number_!==null)?number_:0;this.toString=function(){switch(this.type_){case TNUMBER:return this.number_;case TOP1:case TOP2:case TOP3:case TVAR:return this.index_;case TFUNCALL:return'CALL';case SEP:return'SEPARATOR';default:return'Invalid Token'}}}
function Expression(tokens,ops1,ops2,functions,ops3,ops3Trail){this.tokens=tokens}
var escapable=/[\\\'\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;var meta={'\b':IMLib.backSlash_char+'b','\t':IMLib.backSlash_char+'t','\n':IMLib.backSlash_char+'n','\f':IMLib.backSlash_char+'f','\r':IMLib.backSlash_char+'r','\'':IMLib.backSlash_char+IMLib.singleQuote_char,'\\':IMLib.backSlash_char+IMLib.backSlash_char};function escapeValue(v){if(typeof v==='string'){escapable.lastIndex=0;return escapable.test(v)?IMLib.singleQuote_char+v.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})+IMLib.singleQuote_char:IMLib.singleQuote_char+v+IMLib.singleQuote_char}
return v}
Expression.prototype={simplify:function(values){values=values||{};var nstack=[];var newexpression=[];var n1;var n2;var n3;var f;var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TNUMBER){nstack.push(item)}else if(type_===TVAR&&(item.index_ in values)){item=new Token(TNUMBER,0,0,values[item.index_]);nstack.push(item)}else if(type_===TOP3&&nstack.length>2){n3=nstack.pop();n2=nstack.pop();n1=nstack.pop();f=Parser.ops3[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_,n2.number_,n3.number_));nstack.push(item)}else if(type_===TOP2&&nstack.length>1){n2=nstack.pop();n1=nstack.pop();f=Parser.ops2[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_,n2.number_));nstack.push(item)}else if(type_===TOP1&&nstack.length>0){n1=nstack.pop();f=Parser.ops1[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_));nstack.push(item)}else{while(nstack.length>0){newexpression.push(nstack.shift())}
newexpression.push(item)}}
while(nstack.length>0){newexpression.push(nstack.shift())}
return new Expression(newexpression)},substitute:function(variable,expr){if(!(expr instanceof Expression)){expr=new Parser().parse(String(expr))}
var newexpression=[];var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TVAR&&item.index_===variable){for(var j=0;j<expr.tokens.length;j++){var expritem=expr.tokens[j];var replitem=new Token(expritem.type_,expritem.index_,expritem.prio_,expritem.number_);newexpression.push(replitem)}}else{newexpression.push(item)}}
return new Expression(newexpression)},evaluate:function(values){values=values||{};var nstack=[];var n1;var n2;var n3;var f;var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TNUMBER){nstack.push(item.number_)}else if(type_===TOP3){n3=nstack.pop();n2=nstack.pop();n1=nstack.pop();f=Parser.ops3Trail[item.index_];nstack.push(f(n1,n2,n3))}else if(type_===TOP2){n2=nstack.pop();n1=nstack.pop();f=Parser.ops2[item.index_];nstack.push(f(n1,n2))}else if(type_===TVAR){if(item.index_ in values){nstack.push(values[item.index_])}else if(item.index_ in Parser.functions){nstack.push(Parser.functions[item.index_])}else{throw new Error('undefined variable: '+item.index_)}}else if(type_===TOP1){n1=nstack.pop();f=Parser.ops1[item.index_];nstack.push(f(n1))}else if(type_===SEP){n2=nstack.pop();n1=nstack.pop();nstack.push([n1,n2])}else if(type_===TFUNCALL){n1=nstack.pop();f=nstack.pop();if(f.apply&&f.call){if(Object.prototype.toString.call(n1)=='[object Array]'){nstack.push(f.apply(undefined,n1))}else{nstack.push(f.call(undefined,n1))}}else{throw new Error(f+' is not a function')}}else{throw new Error('invalid Expression')}}
if(nstack.length>1){throw new Error('invalid Expression (parity)')}
return nstack[0]},variables:function(){var L=this.tokens.length;var vars=[];for(var i=0;i<L;i++){var item=this.tokens[i];if(item.type_===TVAR&&(vars.indexOf(item.index_)==-1)&&!(item.index_ in Parser.functions)){vars.push(item.index_)}}
return vars}};function iff(a,b,c){var vala,valb,valc;vala=(a instanceof Array)?arguments[0][0]:arguments[0];valb=(b instanceof Array)?arguments[1][0]:arguments[1];valc=(c instanceof Array)?arguments[2][0]:arguments[2];return vala?valb:valc}
function greaterthan(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)>Number(numb)}
return a>b}
function lessthan(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)<Number(numb)}
return a<b}
function greaterequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)>=Number(numb)}
return a>=b}
function lessequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)<=Number(numb)}
return a<=b}
function equal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)==Number(numb)}
return a==b}
function notequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)!=Number(numb)}
return a!=b}
function isReallyNaN(x){return x!==x}
function add(a,b){var numa,numb;if((typeof a)=="string"||(typeof b)=="string"){return addstring(a,b)}
if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numb)){return Number(numa)+Number(numb)}
return a+b}
function addstring(a,b){return String(a)+String(b)}
function sub(a,b){var numa,numb,str,pos;if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numb)){return numa-numb}
str=String(a);do{pos=str.indexOf(b);if(pos>-1){str=str.substr(0,pos)+str.substr(pos+b.length)}}while(pos>-1);return str}
function mul(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a*b}
function div(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a/b}
function mod(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a%b}
function neg(a){if(isReallyNaN(a)){return NaN}
a=toNumber(a);return-a}
function random(a){a=toNumber(a);return Math.random()*(a||1)}
function fac(a){if(isReallyNaN(a)){return NaN}
a=toNumber(a);a=Math.floor(a);var b=a;while(a>1){b=b*(--a)}
return b}
function logicalnot(a){a=toNumber(a);return!a}
function logicaland(a,b){a=toNumber(a);b=toNumber(b);return a&&b}
function logicalor(a,b){a=toNumber(a);b=toNumber(b);return a||b}
function sumfunc(){var result=0,i;for(i=0;i<arguments.length;i++){result+=toNumber(arguments[i])}
return result}
function averagefunc(){var result=0,i,count=0;for(i=0;i<arguments.length;i++){result+=toNumber(arguments[i]);count++}
return result/count}
function countElements(){var i,count=0;for(i=0;i<arguments.length;i++){count+=Array.isArray(arguments[i])?arguments[i].length:1}
return count}
function listfunc(){var result=IMLib.zerolength_str,i;for(i=0;i<arguments.length;i++){result+=String(arguments[i]);result+=IMLib.nl_char}
return result}
function roundfunc(a,b){if(b==undefined){return Math.round(a)}else{a=(a instanceof Array)?a.join():a;b=(b instanceof Array)?b.join():b;return INTERMediatorLib.Round(a,b)}}
function length(a){if(a==undefined||a==null){return 0}else{a=(a instanceof Array)?a.join():a;return(new String(a)).length}}
function toNumber(str){var value;if(str===undefined){return NaN}
if(str===!0){return!0}
if(str===!1){return!1}
if(str==IMLib.zerolength_str){return 0}
value=str;if(INTERMediatorLib.is_array(str)){if(str.length<1){return 0}else{value=str[0]}}
value=unformat(value);return value}
function pyt(a,b){return Math.sqrt(a*a+b*b)}
function append(a,b){if(Object.prototype.toString.call(a)!='[object Array]'){return[a,b]}
a=a.slice();a.push(b);return a}
function charsetand(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<stra.length;i++){if(strb.indexOf(stra.substr(i,1))>-1){result+=stra.substr(i,1)}}
return result}
function charsetor(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<strb.length;i++){if(stra.indexOf(strb.substr(i,1))<0){result+=strb.substr(i,1)}}
return stra+result}
function charsetnoother(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<stra.length;i++){if(strb.indexOf(stra.substr(i,1))<0){result+=stra.substr(i,1)}}
return result}
function parametersOfMultiline(a,b){var stra,strb,arraya,arrayb,i,nls,nl=IMLib.nl_char;stra=(a instanceof Array)?a.join():a;nls=[stra.indexOf(IMLib.crlf_str),stra.indexOf(IMLib.cr_char),stra.indexOf(IMLib.nl_char)];for(i=0;i<nls.length;i++){nls[i]=(nls[i]<0)?stra.length:nls[i]}
if(nls[0]<stra.length&&nls[0]<=nls[1]&&nls[0]<nls[2]){nl=IMLib.crlf_str}else if(nls[1]<stra.length&&nls[1]<nls[0]&&nls[1]<nls[2]){nl=IMLib.cr_char}
arraya=stra.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char).split(IMLib.nl_char);strb=(b instanceof Array)?b.join():b;arrayb=strb.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char).split(IMLib.nl_char);return[arraya,arrayb,nl]}
function itemsetand(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arrayb.indexOf(arraya[i])>-1&&arraya[i].length>0){result+=arraya[i]+nl}}
return result}
function itemsetor(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arraya[i].length>0){result+=arraya[i]+nl}}
for(i=0;i<arrayb.length;i++){if(arraya.indexOf(arrayb[i])<0&&arrayb[i].length>0){result+=arrayb[i]+nl}}
return result}
function itemsetnoother(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arrayb.indexOf(arraya[i])<0&&arraya[i].length>0){result+=arraya[i]+nl}}
return result}
function itematindex(a,start,end){var params,arraya,nl,i,result='';params=parametersOfMultiline(a,'');arraya=params[0];nl=params[2];end=(end==undefined)?arraya.length:end;for(i=start;(i<start+end)&&(i<arraya.length);i++){result+=arraya[i]+nl}
return result}
function itemIndexOfFunc(list,str){if(!list){return-1}
var a=list.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char);var ix=0;var item,pos;while(a.length>0){pos=a.indexOf(IMLib.nl_char);if(pos>-1){item=a.substr(0,pos);a=a.substr(pos+1)}else{item=a;a=IMLib.zerolength_str}
if(item==str){return ix}
ix++}
return-1}
function numberformat(val,digit){var stra,strb;stra=(val instanceof Array)?val.join():val;strb=(digit instanceof Array)?digit.join():digit;return IMLibFormat.numberFormat(stra,strb,{useSeparator:!0})}
function currencyformat(val,digit){var stra,strb;stra=(val instanceof Array)?val.join():val;strb=(digit instanceof Array)?digit.join():digit;return IMLibFormat.currencyFormat(stra,strb,{useSeparator:!0})}
function substr(str,pos,len){var stra,p,l;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;p=(pos instanceof Array)?pos.join():pos;l=(len instanceof Array)?len.join():len;return stra.substr(p,l)}
function substring(str,start,end){var stra,s,e;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(start instanceof Array)?start.join():start;e=(end instanceof Array)?end.join():end;return stra.substring(s,e)}
function leftstring(str,start){var stra,s;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);return stra.substring(0,s)}
function midstring(str,start,end){var stra,s,e;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);e=parseInt((end instanceof Array)?end.join():end);return stra.substr(s,e)}
function rightstring(str,start){var stra,s;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);return stra.substring(stra.length-s)}
function indexof(str,search,from){var stra,s;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;if(from==undefined){return stra.indexOf(s)}
return stra.indexOf(s,from)}
function lastindexof(str,search,from){var stra,s;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;if(from==undefined){return stra.lastIndexOf(s)}
return stra.lastIndexOf(s,from)}
function replace(str,start,end,rep){var stra,s,e,r;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(start instanceof Array)?start.join():start;e=(end instanceof Array)?end.join():end;r=(rep instanceof Array)?rep.join():rep;return stra.substr(0,s)+r+stra.substr(e)}
function substitute(str,search,rep){var stra,s,r,reg;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;r=(rep instanceof Array)?rep.join():rep;reg=new RegExp(s,'g');return stra.replace(reg,r)}
function match(str,pattern){var stra,p;stra=(str instanceof Array)?str.join():str;p=(pattern instanceof Array)?pattern.join():pattern;return stra.match(new RegExp(p))}
function test(str,pattern){var stra,p;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;p=(pattern instanceof Array)?pattern.join():pattern;return(new RegExp(p)).test(stra)}
Parser.timeOffset=(new Date()).getTimezoneOffset();function DateInt(str){var theDate;if(str===undefined){theDate=Date.now()}else{theDate=Date.parse(str.replace(/-/g,'/'));theDate-=Parser.timeOffset*60000}
return parseInt(theDate/86400000)}
function SecondInt(str){var theDate;if(str===undefined){theDate=Date.now()}else{theDate=Date.parse(str.replace(/-/g,'/'))}
return parseInt(theDate/1000)}
function dvalue(s){if(parseInt(s).length==s.length){return s}else{return DateInt(s)}}
function dtvalue(s){if(parseInt(s).length==s.length){return s}else{return SecondInt(s)}}
function calcDateComponent(d,a,index){var dtComp=[];dtComp.push(yeard(d));dtComp.push(monthd(d));dtComp.push(dayd(d));dtComp[index]+=a;return datecomponents(dtComp[0],dtComp[1],dtComp[2])}
function calcDateTimeComponent(dt,a,index){var dtComp=[];dtComp.push(yeardt(dt));dtComp.push(monthdt(dt));dtComp.push(daydt(dt));dtComp.push(hourdt(dt));dtComp.push(minutedt(dt));dtComp.push(seconddt(dt));dtComp[index]+=a;return datetimecomponents(dtComp[0],dtComp[1],dtComp[2],dtComp[3],dtComp[4],dtComp[5])}
function datecomponents(y,m,d){var m0=m-1;if(m0<0||m0>11){y+=parseInt(m0/12);m=m0%12+1}
return parseInt(Date.UTC(y,m-1,d,0,0,0)/86400000)}
function datetimecomponents(y,m,d,h,i,s){if(s<0||s>59){i+=parseInt(s/60);s=s%60}
if(i<0||i>59){h+=parseInt(i/60);i=i%60}
if(h<0||h>23){d+=parseInt(h/24);h=h%24}
var m0=m-1;if(m0<0||m0>11){y+=parseInt(m0/12);m=m0%12+1}
return Date.UTC(y,m-1,d,h,i,s)/1000}
function yearAlt(d){return INTERMediator.dateTimeFunction?yeardt(d):yeard(d)}
function monthAlt(d){return INTERMediator.dateTimeFunction?monthdt(d):monthd(d)}
function dayAlt(d){return INTERMediator.dateTimeFunction?daydt(d):dayd(d)}
function weekdayAlt(d){return INTERMediator.dateTimeFunction?weekdaydt(d):weekdayd(d)}
function hourAlt(d){return INTERMediator.dateTimeFunction?hourdt(d):0}
function minuteAlt(d){return INTERMediator.dateTimeFunction?minutedt(d):0}
function secondAlt(d){return INTERMediator.dateTimeFunction?seconddt(d):0}
function yeard(d){return new Date(dvalue(d)*86400000).getFullYear()}
function monthd(d){return new Date(dvalue(d)*86400000).getMonth()+1}
function dayd(d){return new Date(dvalue(d)*86400000).getDate()}
function weekdayd(d){return new Date(dvalue(d)*86400000).getDay()}
function yeardt(dt){return new Date(dtvalue(dt)*1000).getFullYear()}
function monthdt(dt){return new Date(dtvalue(dt)*1000).getMonth()+1}
function daydt(dt){return new Date(dtvalue(dt)*1000).getDate()}
function weekdaydt(dt){return new Date(dtvalue(dt)*1000).getDay()}
function hourdt(dt){return new Date(dtvalue(dt)*1000).getHours()}
function minutedt(dt){return new Date(dtvalue(dt)*1000).getMinutes()}
function seconddt(dt){return new Date(dtvalue(dt)*1000).getSeconds()}
function addyear(d,a){return INTERMediator.dateTimeFunction?addyeardt(d,a):addyeard(d,a)}
function addmonth(d,a){return INTERMediator.dateTimeFunction?addmonthdt(d,a):addmonthd(d,a)}
function addday(d,a){return INTERMediator.dateTimeFunction?adddaydt(d,a):adddayd(d,a)}
function addhour(d,a){return INTERMediator.dateTimeFunction?addhourdt(d,a):NaN}
function addminute(d,a){return INTERMediator.dateTimeFunction?addminutedt(d,a):NaN}
function addsecond(d,a){return INTERMediator.dateTimeFunction?addseconddt(d,a):NaN}
function addyeard(d,a){return calcDateComponent(d,a,0)}
function addmonthd(d,a){return calcDateComponent(d,a,1)}
function adddayd(d,a){return calcDateComponent(d,a,2)}
function addyeardt(dt,a){return calcDateTimeComponent(dt,a,0)}
function addmonthdt(dt,a){return calcDateTimeComponent(dt,a,1)}
function adddaydt(dt,a){return calcDateTimeComponent(dt,a,2)}
function addhourdt(dt,a){return calcDateTimeComponent(dt,a,3)}
function addminutedt(dt,a){return calcDateTimeComponent(dt,a,4)}
function addseconddt(dt,a){return calcDateTimeComponent(dt,a,5)}
function endofmonth(d){return INTERMediator.dateTimeFunction?endofmonthdt(d):endofmonthd(d)}
function endofmonthd(d){return adddayd(addmonthd(startofmonthd(d),1),-1)}
function endofmonthdt(dt){return addseconddt(addmonthdt(startofmonthdt(dt),1),-1)}
function startofmonth(d){return INTERMediator.dateTimeFunction?startofmonthdt(d):startofmonthd(d)}
function startofmonthd(d){var str=yeard(d)+'/'+('0'+monthd(d)).substr(-2,2)+'/01';return DateInt(str)}
function startofmonthdt(dt){var str=yeardt(dt)+'/'+('0'+monthdt(dt)).substr(-2,2)+'/01 00:00:00';return SecondInt(str)}
function today(){return parseInt(Date.now()/86400)}
function nowFunction(){return parseInt(Date.now()/1000)}
function unformat(value){var valueString,numberString,i,c;valueString=String(value);numberString=IMLib.zerolength_str;for(i=0;i<valueString.length;i++){c=valueString.substr(i,1);if(c>='0'&&c<='9'){numberString+=c}else if(c>='0'&&c<='9'){numberString+=String.fromCharCode('0'.charCodeAt(0)+c.charCodeAt(0)-'0'.charCodeAt(0))}else if(c=='.'||c=='-'){numberString+=c}}
return parseFloat(numberString)}
function choiceFunc(){var index;if(arguments[0]==null||arguments[0]==undefined){return arguments[0]}
index=parseInt(arguments[0]);if(index<0||index>=(arguments.length-1)){return undefined}
return arguments[index+1]}
function conditionFunc(){var index;for(index=0;index<arguments.length;index+=2){if(arguments[index]==!0&&index+1<arguments.length){return arguments[index+1]}}
return undefined}
function accumulateFunc(){var index,c='';for(index=0;index<arguments.length;index+=2){if(arguments[index]==!0&&index+1<arguments.length){c=c+arguments[index+1]+'\n'}}
return c}
function Parser(){this.success=!1;this.errormsg=IMLib.zerolength_str;this.expression=IMLib.zerolength_str;this.pos=0;this.tokennumber=0;this.tokenprio=0;this.tokenindex=0;this.tmpprio=0;Parser.functions={'count':countElements,'random':random,'fac':fac,'min':Math.min,'max':Math.max,'pyt':pyt,'pow':Math.pow,'atan2':Math.atan2,'if':iff,'sum':sumfunc,'average':averagefunc,'list':listfunc,'format':numberformat,'currency':currencyformat,'substr':substr,'substring':substring,'indexof':indexof,'lastindexof':lastindexof,'replace':replace,'substitute':substitute,'match':match,'test':test,'sin':Math.sin,'cos':Math.cos,'tan':Math.tan,'asin':Math.asin,'acos':Math.acos,'atan':Math.atan,'sqrt':Math.sqrt,'log':Math.log,'abs':Math.abs,'ceil':Math.ceil,'floor':Math.floor,'round':roundfunc,'exp':Math.exp,'items':itematindex,'length':length,'datetime':SecondInt,'date':DateInt,'datecomponents':datecomponents,'datetimecomponents':datetimecomponents,'year':yearAlt,'month':monthAlt,'day':dayAlt,'weekday':weekdayAlt,'hour':hourAlt,'minute':minuteAlt,'second':secondAlt,'yeard':yeard,'monthd':monthd,'dayd':dayd,'weekdayd':weekdayd,'yeardt':yeardt,'monthdt':monthdt,'daydt':daydt,'weekdaydt':weekdaydt,'hourdt':hourdt,'minutedt':minutedt,'seconddt':seconddt,'addyear':addyear,'addmonth':addmonth,'addday':addday,'addhour':addhour,'addminute':addminute,'addsecond':addsecond,'addyeard':addyeard,'addmonthd':addmonthd,'adddayd':adddayd,'addyeardt':addyeardt,'addmonthdt':addmonthdt,'adddaydt':adddaydt,'addhourdt':addhourdt,'addminutedt':addminutedt,'addseconddt':addseconddt,'endofmonth':endofmonth,'startofmonth':startofmonth,'endofmonthd':endofmonthd,'startofmonthd':startofmonthd,'endofmonthdt':endofmonthdt,'startofmonthdt':startofmonthdt,'today':today,'now':nowFunction,'right':rightstring,'mid':midstring,'left':leftstring,'itemIndexOf':itemIndexOfFunc,'choice':choiceFunc,'condition':conditionFunc,'accumulate':accumulateFunc};this.consts={'E':Math.E,'PI':Math.PI};Parser.operators={'!':[1,logicalnot,2],'+':[2,add,4],'⊕':[2,addstring,4],'-':[2,sub,4],'*':[2,mul,3],'/':[2,div,3],'%':[2,mod,3],'^':[2,Math.pow,1],',':[2,append,15],'>':[2,greaterthan,6],'<':[2,lessthan,6],'>=':[2,greaterequal,6],'<=':[2,lessequal,6],'==':[2,equal,7],'=':[2,equal,7],'!=':[2,notequal,7],'<>':[2,notequal,7],'&&':[2,logicaland,11],'||':[2,logicalor,12],'∩':[2,charsetand,3],'∪':[2,charsetor,4],'⊁':[2,charsetnoother,4],'⋀':[2,itemsetand,3],'⋁':[2,itemsetor,4],'⊬':[2,itemsetnoother,4],'?':[2,iff,13],':':[4,iff,13]};Parser.ops1={'-':neg};Parser.ops2={};Parser.ops3={};Parser.ops3Trail={};for(var op in Parser.operators){if(Parser.operators.hasOwnProperty(op)){switch(Parser.operators[op][0]){case 1:Parser.ops1[op]=Parser.operators[op][1];break;case 2:Parser.ops2[op]=Parser.operators[op][1];break;case 3:Parser.ops3[op]=Parser.operators[op][1];break;case 4:Parser.ops3Trail[op]=Parser.operators[op][1];break}}}}
Parser.parse=function(expr){return new Parser().parse(expr)};Parser.evaluate=function(expr,variables){var result;result=Parser.parse(expr).evaluate(variables);return result};Parser.Expression=Expression;var PRIMARY=1<<0;var OPERATOR=1<<1;var FUNCTION=1<<2;var LPAREN=1<<3;var RPAREN=1<<4;var COMMA=1<<5;var SIGN=1<<6;var CALL=1<<7;var NULLARY_CALL=1<<8;Parser.prototype={parse:function(expr){this.errormsg=IMLib.zerolength_str;this.success=!0;var operstack=[];var tokenstack=[];this.tmpprio=0;var expected=(PRIMARY|LPAREN|FUNCTION|SIGN);var noperators=0;this.expression=expr;this.pos=0;var funcstack=[],token;while(this.pos<this.expression.length){if(this.isOperator()){if(this.isSign()&&(expected&SIGN)){if(this.isNegativeSign()){this.tokenprio=2;this.tokenindex='-';noperators++;this.addfunc(tokenstack,operstack,TOP1)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN)}else if(this.isComment()){}else{if((expected&OPERATOR)===0){this.error_parsing(this.pos,'unexpected operator')}
if(this.tokenindex=='?'){this.tmpprio-=40;this.tokenindex='if';this.addfunc(tokenstack,operstack,TOP2);this.tmpprio+=40;this.tokenindex=',';noperators+=3;this.addfunc(tokenstack,operstack,TOP2)}else if(this.tokenindex==':'){this.tokenindex=',';noperators+=2;this.addfunc(tokenstack,operstack,TOP2)}else{noperators+=2;this.addfunc(tokenstack,operstack,TOP2)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN)}}else if(this.isNumber()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected number')}
token=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(token);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isString()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected string')}
token=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(token);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isLeftParenth()){if((expected&LPAREN)===0){this.error_parsing(this.pos,'unexpected \'(\"')}
if(expected&CALL){funcstack.push(!0)}else{funcstack.push(!1)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN|NULLARY_CALL)}else if(this.isRightParenth()){var isFunc=funcstack.pop();if(isFunc){noperators+=2;this.tokenprio=-2;this.tokenindex=-1;this.addfunc(tokenstack,operstack,TFUNCALL)}
if(expected&NULLARY_CALL){token=new Token(TNUMBER,0,0,[]);tokenstack.push(token)}else if((expected&RPAREN)===0){this.error_parsing(this.pos,'unexpected \")\"')}
expected=(OPERATOR|RPAREN|COMMA|LPAREN|CALL)}else if(this.isConst()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected constant')}
var consttoken=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(consttoken);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isVar()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected variable')}
var vartoken=new Token(TVAR,this.tokenindex,0,0);tokenstack.push(vartoken);expected=(OPERATOR|RPAREN|COMMA|LPAREN|CALL)}else if(this.isWhite()){}else{if(this.errormsg===IMLib.zerolength_str){this.error_parsing(this.pos,'unknown character')}else{this.error_parsing(this.pos,this.errormsg)}}}
if(this.tmpprio<0||this.tmpprio>=10){this.error_parsing(this.pos,'unmatched \"()\"')}
while(operstack.length>0){var tmp=operstack.pop();tokenstack.push(tmp)}
return new Expression(tokenstack)},evaluate:function(expr,variables){var result;this.parse(expr).evaluate(variables);return result},error_parsing:function(column,msg){this.success=!1;this.errormsg='parse error [column '+(column)+']: '+msg;throw new Error(this.errormsg)},addfunc:function(tokenstack,operstack,type_){var operator=new Token(type_,this.tokenindex,this.tokenprio+this.tmpprio,0);while(operstack.length>0){if(operator.prio_>=operstack[operstack.length-1].prio_){tokenstack.push(operstack.pop())}else{break}}
operstack.push(operator)},isNumber:function(){var r=!1;var str=IMLib.zerolength_str;while(this.pos<this.expression.length){var code=this.expression.charCodeAt(this.pos);if((code>=48&&code<=57)||code===46){str+=this.expression.charAt(this.pos);this.pos++;this.tokennumber=parseFloat(str);r=!0}else{break}}
return r},unescape:function(v,pos){var buffer=[];var escaping=!1;for(var i=0;i<v.length;i++){var c=v.charAt(i);if(escaping){switch(c){case IMLib.singleQuote_char:buffer.push(IMLib.singleQuote_char);break;case IMLib.backSlash_char:buffer.push(IMLib.backSlash_char);break;case '/':buffer.push('/');break;case 'b':buffer.push('\b');break;case 'f':buffer.push('\f');break;case 'n':buffer.push(IMLib.nl_char);break;case 'r':buffer.push(IMLib.cr_char);break;case 't':buffer.push(IMLib.tab_char);break;case 'u':var codePoint=parseInt(v.substring(i+1,i+5),16);buffer.push(String.fromCharCode(codePoint));i+=4;break;default:throw this.error_parsing(pos+i,'Illegal escape sequence: \'\\'+c+IMLib.singleQuote_char)}
escaping=!1}else{if(c==IMLib.backSlash_char){escaping=!0}else{buffer.push(c)}}}
return buffer.join('')},isString:function(){var r=!1;var str=IMLib.zerolength_str;var startpos=this.pos;if(this.pos<this.expression.length&&this.expression.charAt(this.pos)==IMLib.singleQuote_char){this.pos++;while(this.pos<this.expression.length){var code=this.expression.charAt(this.pos);if(code!=IMLib.singleQuote_char||str.slice(-1)==IMLib.backSlash_char){str+=this.expression.charAt(this.pos);this.pos++}else{this.pos++;this.tokennumber=this.unescape(str,startpos);r=!0;break}}}
return r},isConst:function(){var str,i;for(i in this.consts){if(this.consts.hasOwnProperty(i)){var L=i.length;str=this.expression.substr(this.pos,L);if(i===str){this.tokennumber=this.consts[i];this.pos+=L;return!0}}}
return!1},isOperator:function(){var code;if(this.pos+1<this.expression.length){code=this.expression.substr(this.pos,2);if(Parser.operators[code]){this.tokenprio=Parser.operators[code][2];this.tokenindex=code;this.pos+=2;return!0}}
code=this.expression.substr(this.pos,1);if(Parser.operators[code]){this.tokenprio=Parser.operators[code][2];this.tokenindex=code;this.pos++;return!0}
return!1},isSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===45||code===43){return!0}
return!1},isPositiveSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===43){return!0}
return!1},isNegativeSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===45){return!0}
return!1},isLeftParenth:function(){var code=this.expression.charCodeAt(this.pos);if(code===40){this.pos++;this.tmpprio-=20;return!0}
return!1},isRightParenth:function(){var code=this.expression.charCodeAt(this.pos);if(code===41){this.pos++;this.tmpprio+=20;return!0}
return!1},isComma:function(){var code=this.expression.charCodeAt(this.pos);if(code===44){this.pos++;this.tokenprio=15;this.tokenindex=',';return!0}
return!1},isWhite:function(){var code=this.expression.charCodeAt(this.pos);if(code===32||code===9||code===10||code===13){this.pos++;return!0}
return!1},isVar:function(){var str=IMLib.zerolength_str;for(var i=this.pos;i<this.expression.length;i++){var c=this.expression.charAt(i);if(i===this.pos){if(!c.match(Parser.regFirstVarChar)){break}}else{if(!c.match(Parser.regRestVarChar)){break}}
str+=c}
if(str.length>0){this.tokenindex=str;this.tokenprio=0;this.pos+=str.length;return!0}
return!1},isComment:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===47&&this.expression.charCodeAt(this.pos)===42){this.pos=this.expression.indexOf('*/',this.pos)+2;if(this.pos===1){this.pos=this.expression.length}
return!0}
return!1}};scope.Parser=Parser;return Parser})(typeof exports==='undefined'?{}:exports);var IMLibCalc={calculateRequiredObject:null,updateCalculationInfo:function(contextObj,keyingValue,nodeId,nInfo,currentRecord){'use strict';var calcDef,exp,field,elements,i,index,objectKey,itemIndex,values,referes,calcDefField,atPos,fieldLength;calcDef=contextObj.getContextDef().calculation;for(index in calcDef){if(calcDef.hasOwnProperty(index)){atPos=calcDef[index].field.indexOf(INTERMediator.separator);fieldLength=calcDef[index].field.length;calcDefField=calcDef[index].field.substring(0,atPos>=0?atPos:fieldLength);if(calcDefField===nInfo.field){try{exp=calcDef[index].expression;field=calcDef[index].field;elements=Parser.parse(exp).variables();objectKey=nodeId+(nInfo.target.length>0?(INTERMediator.separator+nInfo.target):'')}catch(ex){INTERMediatorLog.setErrorMessage(ex,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1036],[field,exp]))}
if(elements&&objectKey){values={};referes={};for(i=0;i<elements.length;i++){itemIndex=elements[i];if(itemIndex){values[itemIndex]=currentRecord[itemIndex];referes[itemIndex]=undefined}
contextObj.setValue(keyingValue,itemIndex,currentRecord[itemIndex],nodeId,nInfo.target,null)}
IMLibCalc.calculateRequiredObject[objectKey]={'field':field,'expression':exp,'nodeInfo':nInfo,'values':values,'referes':referes}}}}}},updateCalculationFields:function(){'use strict';var nodeId,exp,nInfo,valuesArray,leafNodes,calcObject,ix,refersArray,key,fName,vArray;var targetNode,field,valueSeries,targetElement,i,hasReferes,contextInfo,idValue,record,val;IMLibCalc.setUndefinedToAllValues();IMLibNodeGraph.clear();for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];if(calcObject){hasReferes=!1;for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){IMLibNodeGraph.addEdge(nodeId,calcObject.referes[field][ix]);hasReferes=!1}}}
if(!hasReferes){IMLibNodeGraph.addEdge(nodeId)}}}}
do{leafNodes=IMLibNodeGraph.getLeafNodesWithRemoving();for(i=0;i<leafNodes.length;i++){calcObject=IMLibCalc.calculateRequiredObject[leafNodes[i]];if(calcObject){idValue=leafNodes[i].match(IMLibCalc.regexpForSeparator)?leafNodes[i].split(IMLibCalc.regexpForSeparator)[0]:leafNodes[i];targetNode=document.getElementById(idValue);exp=calcObject.expression;nInfo=calcObject.nodeInfo;valuesArray=calcObject.values;refersArray=calcObject.referes;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nInfo.target);if(contextInfo&&contextInfo.context){record=contextInfo.context.getContextRecord(idValue)}else{record=null}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){if(field.indexOf(nInfo.table+'@')===0){fName=field.substr(field.indexOf('@')+1);vArray=[];for(key in contextInfo.context.store){if(contextInfo.context.store.hasOwnProperty(key)&&contextInfo.context.store[key][fName]){vArray.push(contextInfo.context.store[key][fName])}}
valuesArray[field]=vArray}}}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){valueSeries=[];for(ix=0;ix<valuesArray[field].length;ix++){if(valuesArray[field][ix]===undefined){if(record[field]){valueSeries.push(record[field])}else if(refersArray[field][ix]){targetElement=document.getElementById(refersArray[field][ix]);valueSeries.push(IMLibElement.getValueFromIMNode(targetElement))}}else{valueSeries.push(valuesArray[field][ix])}}
calcObject.values[field]=valueSeries}}
val=Parser.evaluate(exp,valuesArray);IMLibElement.setValueToIMNode(targetNode,nInfo.target,val,!0);contextInfo.context.setValue(contextInfo.record,contextInfo.field,val,nodeId,targetNode,!1)}}}while(leafNodes.length>0);if(IMLibNodeGraph.nodes.length>0){INTERMediatorLog.setErrorMessage(new Error('Expressons are cyclic.'),INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1037],[]))}},recalculation:function(updatedNodeId){'use strict';var nodeId,newValueAdded,leafNodes,calcObject,ix,updatedValue,isRecalcAll=!1,targetNode;var newValue,field,i,updatedNodeIds,updateNodeValues,cachedIndex,nInfo,valuesArray;var refersArray,valueSeries,targetElement,contextInfo,record,idValue,key,fName,vArray;if(updatedNodeId===undefined){isRecalcAll=!0;updatedNodeIds=[];updateNodeValues=[]}else{newValue=IMLibElement.getValueFromIMNode(document.getElementById(updatedNodeId));updatedNodeIds=[updatedNodeId];updateNodeValues=[newValue]}
IMLibCalc.setUndefinedToAllValues();IMLibNodeGraph.clear();for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){IMLibNodeGraph.addEdge(nodeId,calcObject.referes[field][ix])}}}}}
do{leafNodes=IMLibNodeGraph.getLeafNodesWithRemoving();for(i=0;i<leafNodes.length;i++){calcObject=IMLibCalc.calculateRequiredObject[leafNodes[i]];if(calcObject){idValue=leafNodes[i].match(IMLibCalc.regexpForSeparator)?leafNodes[i].split(IMLibCalc.regexpForSeparator)[0]:leafNodes[i];targetNode=document.getElementById(idValue);nInfo=calcObject.nodeInfo;valuesArray=calcObject.values;refersArray=calcObject.referes;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nInfo.target);if(contextInfo&&contextInfo.context){record=contextInfo.context.getContextRecord(idValue)}else{record=null}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){if(field.indexOf(nInfo.table+'@')===0){fName=field.substr(field.indexOf('@')+1);vArray=[];for(key in contextInfo.context.store){if(contextInfo.context.store.hasOwnProperty(key)&&contextInfo.context.store[key][fName]){vArray.push(contextInfo.context.store[key][fName])}}
valuesArray[field]=vArray}}}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){valueSeries=[];for(ix=0;ix<valuesArray[field].length;ix++){if(valuesArray[field][ix]===undefined){if(record[field]){valueSeries.push(record[field])}else if(refersArray[field][ix]){targetElement=document.getElementById(refersArray[field][ix]);valueSeries.push(IMLibElement.getValueFromIMNode(targetElement))}}else{valueSeries.push(valuesArray[field][ix])}}
calcObject.values[field]=valueSeries}}
if(isRecalcAll){newValueAdded=!0}else{newValueAdded=!1;for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){cachedIndex=updatedNodeIds.indexOf(calcObject.referes[field][ix]);if(cachedIndex>=0){calcObject.values[field][ix]=updateNodeValues[cachedIndex];newValueAdded=!0}}}}}
if(newValueAdded){updatedValue=Parser.evaluate(calcObject.expression,calcObject.values);IMLibElement.setValueToIMNode(document.getElementById(idValue),nInfo.target,updatedValue,!0);updatedNodeIds.push(idValue);updateNodeValues.push(updatedValue);contextInfo.context.setValue(contextInfo.record,contextInfo.field,updatedValue,idValue,targetNode,!1)}}}}while(leafNodes.length>0);if(IMLibNodeGraph.nodes.length>0){INTERMediatorLog.setErrorMessage(new Error('Expressons are cyclic.'),INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1037],[]))}},setUndefinedToAllValues:function(){'use strict';var nodeId,calcObject,ix,targetNode,field,targetExp,targetIds,isContextName,isRemoved,idValue,repeaterTop,checkRepeater,nodeInfo,linkInfos;do{isRemoved=!1;for(nodeId in IMLibCalc.calculateRequiredObject){idValue=nodeId.match(IMLibCalc.regexpForSeparator)?nodeId.split(IMLibCalc.regexpForSeparator)[0]:nodeId;if(!document.getElementById(idValue)){delete IMLibCalc.calculateRequiredObject[nodeId];isRemoved=!0;break}}}while(isRemoved);for(nodeId in IMLibCalc.calculateRequiredObject){calcObject=IMLibCalc.calculateRequiredObject[nodeId];idValue=nodeId.match(IMLibCalc.regexpForSeparator)?nodeId.split(IMLibCalc.regexpForSeparator)[0]:nodeId;targetNode=document.getElementById(idValue);linkInfos=INTERMediatorLib.getLinkedElementInfo(targetNode);if(INTERMediatorLib.is_array(linkInfos)){linkInfos=linkInfos[0]}
nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos);for(field in calcObject.values){if(field.indexOf(INTERMediator.separator)>-1){targetExp=field;isContextName=!0}else{targetExp=calcObject.nodeInfo.table+INTERMediator.separator+field;isContextName=!1}
if(nodeInfo&&nodeInfo.crossTable){repeaterTop=targetNode;while(repeaterTop.tagName!=='TD'&&repeaterTop.tagName!=='TH'){repeaterTop=repeaterTop.parentNode}
do{targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromNode(repeaterTop,targetExp);if(targetIds&&targetIds.length>0){break}
repeaterTop=getParentRepeater(INTERMediatorLib.getParentEnclosure(repeaterTop))}while(repeaterTop);}else{checkRepeater=targetNode;do{targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromRepeater(checkRepeater,targetExp);if(targetIds&&targetIds.length>0){break}
if(isContextName){targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromEnclosure(checkRepeater,targetExp);if(targetIds&&targetIds.length>0){break}}
checkRepeater=getParentRepeater(INTERMediatorLib.getParentEnclosure(checkRepeater))}while(checkRepeater);}
if(INTERMediatorLib.is_array(targetIds)&&targetIds.length>0){calcObject.referes[field]=[];calcObject.values[field]=[];for(ix=0;ix<targetIds.length;ix++){calcObject.referes[field].push(targetIds[ix]);calcObject.values[field].push(undefined)}}else{calcObject.referes[field]=[undefined];calcObject.values[field]=[undefined]}}}
function getParentRepeater(node){var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null}}};var IMParts_Catalog={};IMParts_Catalog.fileupload={html5DDSuported:!1,progressSupported:!1,forceOldStyleForm:!1,uploadButtonLabel:'送信',uploadCancelButtonLabel:'キャンセル',uploadId:'sign'+Math.random(),instanciate:function(parentNode){'use strict';var inputNode,formNode,buttonNode,hasTapEvent;var newId=parentNode.getAttribute('id')+'-e';var newNode=document.createElement('DIV');IMLibLocalContext.setValue('uploadFileSelect','false');INTERMediatorLib.setClassAttributeToNode(newNode,'_im_fileupload');newNode.setAttribute('id',newId);this.ids.push(newId);if(this.forceOldStyleForm||(INTERMediator.isEdge&&INTERMediator.ieVersion<14)){this.html5DDSuported=!1}else{if(window.FileReader&&window.FormData){this.html5DDSuported=!0}else{this.html5DDSuported=!1}}
hasTapEvent=('ontouchstart' in window);if(hasTapEvent){this.html5DDSuported=!1}
var autoReload=(parentNode.getAttribute('data-im-widget-reload')!==null)?parentNode.getAttribute('data-im-widget-reload'):!1;newNode.setAttribute('data-im-widget-reload',autoReload);if(this.html5DDSuported){newNode.dropzone='copy';var widgetStyle=(parentNode.getAttribute('data-im-widget-style')==='false')?!1:!0;if(widgetStyle){newNode.style.width='200px';newNode.style.height='100px';newNode.style.paddingTop='20px';newNode.style.backgroundColor='#AAAAAA';newNode.style.border='3px dotted #808080';newNode.style.textAlign='center';newNode.style.fontSize='75%';var eachLine=INTERMediatorOnPage.getMessages()[3101].split(/\n/);for(var i=0;i<eachLine.length;i++){if(i>0){newNode.appendChild(document.createElement('BR'))}
newNode.appendChild(document.createTextNode(eachLine[i]))}}}else{formNode=document.createElement('FORM');formNode.className='_im_fileupload_form';formNode.setAttribute('method','post');formNode.setAttribute('action',INTERMediatorOnPage.getEntryPath()+'?access=uploadfile');formNode.setAttribute('enctype','multipart/form-data');var divNode=document.createElement('DIV');divNode.className='_im_fileupload_form_wrapper form-wrapper';divNode.appendChild(formNode);newNode.appendChild(divNode);if(this.progressSupported){inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','APC_UPLOAD_PROGRESS');inputNode.setAttribute('id','progress_key');inputNode.setAttribute('value',this.uploadId+(this.ids.length-1));formNode.appendChild(inputNode)}
inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_redirect');inputNode.setAttribute('value',location.href);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_contextnewrecord');inputNode.setAttribute('value','uploadfile');formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','access');inputNode.setAttribute('value','uploadfile');formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','file');inputNode.setAttribute('accept','*/*');inputNode.setAttribute('name','_im_uploadfile');inputNode.className='_im_uploadfile';inputNode.addEventListener('change',function(){if(this.files[0].size>0){this.nextSibling.removeAttribute('disabled')}},!1);formNode.appendChild(inputNode);var cancelButtonWrapper,cancelButton;cancelButtonWrapper=document.createElement('DIV');cancelButtonWrapper.className='_im_fileupload_cancel_button_wrapper';cancelButton=document.createElement('BUTTON');cancelButton.className='_im_fileupload_cancel_button';cancelButton.appendChild(document.createTextNode(this.uploadCancelButtonLabel));cancelButtonWrapper.appendChild(cancelButton);buttonNode=document.createElement('BUTTON');buttonNode.className='_im_fileupload_button';buttonNode.setAttribute('type','submit');buttonNode.setAttribute('disabled','');buttonNode.appendChild(document.createTextNode(this.uploadButtonLabel));if(!newNode.id){newNode.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(newNode.id,function(){var node=document.getElementById(newNode.id);if(node!==null&&node.children.length>0){if(node.children[0].style.display==='none'||node.children[0].style.display===''){node.children[0].style.display='flex';node.children[0].style.display='-webkit-flex'}}},!0);if(!cancelButtonWrapper.id){cancelButtonWrapper.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(cancelButtonWrapper.id,function(){this.parentNode.style.display='none'});divNode.appendChild(cancelButtonWrapper);formNode.appendChild(buttonNode);this.formFromId[newId]=formNode}
if(parentNode.getAttribute('data-im-widget-inner')==='true'){var children=parentNode.children;for(var c=children.length-1;c>=0;c--){newNode.appendChild(children[c])}}
parentNode.appendChild(newNode);newNode._im_getValue=function(){var targetNode=newNode;return targetNode.value};parentNode._im_getValue=function(){var targetNode=newNode;return targetNode.value};parentNode._im_getComponentId=function(){var theId=newId;return theId}},ids:[],formFromId:{},finish:function(){'use strict';var shaObj,hmacValue,targetNode,formNode,i,tagetIdLocal,isProgressingLocal,serialIdLocal,uploadIdLocal;var encrypt=new JSEncrypt();if(this.html5DDSuported){for(i=0;i<this.ids.length;i++){tagetIdLocal=this.ids[i];targetNode=document.getElementById(tagetIdLocal);if(targetNode){INTERMediatorLib.addEvent(targetNode,'dragleave',function(event){event.preventDefault();event.target.style.backgroundColor='#AAAAAA'});INTERMediatorLib.addEvent(targetNode,'dragover',function(event){event.preventDefault();event.target.style.backgroundColor='#AADDFF'});isProgressingLocal=this.progressSupported;serialIdLocal=this.ids.length;uploadIdLocal=this.uploadId;INTERMediatorLib.addEvent(targetNode,'drop',(function(){var iframeId=i;var isProgressing=isProgressingLocal;var serialId=serialIdLocal;var uploadId=uploadIdLocal;var tagetId=tagetIdLocal;return function(event){var file,fileNameNode,i,updateInfo,infoFrame;event.preventDefault();var eventTarget=event.currentTarget;if(isProgressing){infoFrame=document.createElement('iframe');infoFrame.setAttribute('id','upload_frame'+serialId);infoFrame.setAttribute('name','upload_frame');infoFrame.setAttribute('frameborder','0');infoFrame.setAttribute('border','0');infoFrame.setAttribute('scrolling','no');infoFrame.setAttribute('scrollbar','no');infoFrame.style.width='100%';infoFrame.style.height='24px';eventTarget.appendChild(infoFrame)}
for(i=0;i<event.dataTransfer.files.length;i++){file=event.dataTransfer.files[i];fileNameNode=document.createElement('DIV');fileNameNode.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[3102]+file.name));fileNameNode.style.marginTop='20px';fileNameNode.style.backgroundColor='#FFFFFF';fileNameNode.style.textAlign='center';event.target.appendChild(fileNameNode)}
updateInfo=IMLibContextPool.getContextInfoFromId(eventTarget.getAttribute('id'),'');if(isProgressing){if(infoFrame){infoFrame.style.display='block'}
setTimeout((function(){var frameNode=infoFrame;var param=uploadId+iframeId;return function(){if(frameNode){frameNode.setAttribute('src','upload_frame.php?up_id='+param)}}})())}
IMLibQueue.setTask((function(){var uploadData='&_im_contextname='+encodeURIComponent(updateInfo.context.contextName)+'&_im_field='+encodeURIComponent(updateInfo.field)+'&_im_keyfield='+encodeURIComponent(updateInfo.record.split('=')[0])+'&_im_keyvalue='+encodeURIComponent(updateInfo.record.split('=')[1])+'&_im_contextnewrecord='+encodeURIComponent('uploadfile')+(isProgressing?('&APC_UPLOAD_PROGRESS='+encodeURIComponent(uploadId+iframeId)):'');var uploadSpec={fileName:file.name,content:file};var contextName=updateInfo.context.contextName;var updateField=updateInfo.field;var targetIdCapt=tagetId;var targetNodeCapt=targetNode;var finishFunc=(function(){var infoFrameCapt=infoFrame;var fileNameNodeCapt=fileNameNode;return function(){if(infoFrameCapt){infoFrameCapt.setAttribute('src','')}
if(fileNameNodeCapt){fileNameNodeCapt.parentNode.removeChild(fileNameNodeCapt)}}})();return function(completeTask){INTERMediator_DBAdapter.uploadFile(uploadData,uploadSpec,function(dbresult){var contextObj,contextInfo,contextObjects=null,fvalue,i,context,relatedContextName='',index;context=IMLibContextPool.getContextDef(contextName);if(context['file-upload']){for(index in context['file-upload']){if(context['file-upload'][index].field===updateField){relatedContextName=context['file-upload'][index].context;break}}
fvalue=IMLibContextPool.getKeyFieldValueFromId(targetIdCapt,'');contextObjects=IMLibContextPool.getContextsFromNameAndForeignValue(relatedContextName,fvalue,context.key)}else{contextObjects=IMLibContextPool.getContextFromName(contextName)}
contextInfo=IMLibContextPool.getContextInfoFromId(targetIdCapt,'');contextInfo.context.setValue(contextInfo.record,contextInfo.field,dbresult);if(contextObjects){for(i=0;i<contextObjects.length;i++){contextObj=contextObjects[i];INTERMediator.construct(contextObj)}}
INTERMediatorLog.flushMessage();if(targetNodeCapt.getAttribute('data-im-widget-reload')==='true'){INTERMediator.construct()}
event.target.style.backgroundColor='#AAAAAA';finishFunc();completeTask()},function(){event.target.style.backgroundColor='#AAAAAA';finishFunc();completeTask()})}})())}})())}}}else{for(i=0;i<this.ids.length;i++){targetNode=document.getElementById(this.ids[i]);formNode=targetNode.getElementsByTagName('FORM')[0];if(targetNode&&formNode){var updateInfo=IMLibContextPool.getContextInfoFromId(this.ids[i],'');var inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_contextname');inputNode.setAttribute('value',updateInfo.context.contextName);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_field');inputNode.setAttribute('value',updateInfo.field);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_keyfield');inputNode.setAttribute('value',updateInfo.record.split('=')[0]);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_keyvalue');inputNode.setAttribute('value',updateInfo.record.split('=')[1]);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','clientid');if(INTERMediatorOnPage.authUser.length>0){inputNode.value=INTERMediatorOnPage.clientId}
formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','authuser');if(INTERMediatorOnPage.authUser.length>0){inputNode.value=INTERMediatorOnPage.authUser}
formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','response');if(INTERMediatorOnPage.authUser.length>0){if(INTERMediatorOnPage.authHashedPassword&&INTERMediatorOnPage.authChallenge){shaObj=new jsSHA(INTERMediatorOnPage.authHashedPassword,'ASCII');hmacValue=shaObj.getHMAC(INTERMediatorOnPage.authChallenge,'ASCII','SHA-256','HEX');inputNode.value=hmacValue}else{inputNode.value='dummy'}}
formNode.appendChild(inputNode);if(INTERMediatorOnPage.authUser.length>0){encrypt.setPublicKey(INTERMediatorOnPage.publickey);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','cresponse');inputNode.setAttribute('value',encrypt.encrypt(INTERMediatorOnPage.authCryptedPassword.substr(0,220)+IMLib.nl_char+INTERMediatorOnPage.authChallenge)+IMLib.nl_char+INTERMediatorOnPage.authCryptedPassword.substr(220));formNode.appendChild(inputNode)}
if(this.progressSupported){inputNode=document.createElement('iframe');inputNode.setAttribute('id','upload_frame'+i);inputNode.setAttribute('name','upload_frame');inputNode.setAttribute('frameborder','0');inputNode.setAttribute('border','0');inputNode.setAttribute('scrolling','no');inputNode.setAttribute('scrollbar','no');formNode.appendChild(inputNode);INTERMediatorLib.addEvent(formNode,'submit',(function(){var iframeId=i;return function(){var iframeNode=document.getElementById('upload_frame'+iframeId);iframeNode.style.display='block';setTimeout(function(){var infoURL=selfURL()+'?uploadprocess='+this.uploadId+iframeId;iframeNode.setAttribute('src',infoURL)});return!0}})())}}}}
this.ids=[];this.formFromId={};function selfURL(){var nodes=document.getElementsByTagName('SCRIPT');for(var i=0;i<nodes.length;i++){var srcAttr=nodes[i].getAttribute('src');if(srcAttr.match(/\.php/)){return srcAttr}}
return null}}};IMParts_Catalog.jsonformat={instanciate:function(parentNode){'use strict';var newId=parentNode.getAttribute('id')+'-jsonf';var newNode=document.createElement('pre');newNode.setAttribute('id',newId);parentNode.appendChild(newNode);IMParts_Catalog.jsonformat.ids.push(newId);parentNode._im_getComponentId=(function(){var theId=newId;return function(){return theId}})();parentNode._im_setValue=(function(){var theId=newId;return function(str){IMParts_Catalog.jsonformat.initialValues[theId]=str?JSON.stringify(JSON.parse(str),null,' '):''}})()},ids:[],initialValues:{},finish:function(){'use strict';for(var i=0;i<IMParts_Catalog.jsonformat.ids.length;i++){var targetId=IMParts_Catalog.jsonformat.ids[i];var targetNode=document.getElementById(targetId);if(targetNode){targetNode.appendChild(document.createTextNode(IMParts_Catalog.jsonformat.initialValues[targetId]))}}
IMParts_Catalog.jsonformat.ids=[];IMParts_Catalog.jsonformat.initialValues={}}};IMParts_Catalog.popupselector={instanciate:function(parentNode){'use strict';var widgetId,node,inNode,valueNode;if(parentNode.getAttribute('class')!=='_im_widget_popup'){parentNode.setAttribute('class','_im_widget_popup');parentNode.style.zIndex=(IMParts_Catalog.popupselector.zIndex--);node=document.createElement('SPAN');node.setAttribute('data-im-control','enclosure');node.setAttribute('class','_im_widget_popup_panel');parentNode.appendChild(node);IMParts_Catalog.popupselector.selectionRoots.push(node);inNode=document.createElement('SPAN');inNode.setAttribute('data-im-control','repeater');inNode.setAttribute('data-im',parentNode.getAttribute('data-im-popup'));node.appendChild(inNode);inNode=document.createElement('DIV');inNode.setAttribute('class','_im_widget_popup_close');inNode.appendChild(document.createTextNode('×'));node.appendChild(inNode);INTERMediatorLib.addEvent(inNode,'click',(function(){return function(){IMParts_Catalog.popupselector.clearSelection()}})());widgetId=parentNode.getAttribute('id');IMParts_Catalog.popupselector.ids.push(widgetId);valueNode=document.createElement('span');valueNode.setAttribute('class','_im_widget_popup_value');INTERMediatorLib.addEvent(valueNode,'click',(function(){var selRoot=node;return function(){IMParts_Catalog.popupselector.clearSelection();IMParts_Catalog.popupselector.clickValue(selRoot)}})());parentNode.appendChild(valueNode);parentNode._im_getComponentId=(function(){var theId=widgetId;return function(){return theId}})();parentNode._im_setValue=(function(){var theId=widgetId;return function(str){IMParts_Catalog.popupselector.initialValues[theId]=str}})()}},ids:[],selectionRoots:[],initialValues:{},zIndex:9000,finish:function(){'use strict';var i,targetId,targetNode,j,nodes,selectionRoot,nodeValue,displayValue,innodes,k;for(i=0;i<IMParts_Catalog.popupselector.ids.length;i++){targetId=IMParts_Catalog.popupselector.ids[i];targetNode=document.getElementById(targetId);selectionRoot=IMParts_Catalog.popupselector.selectionRoots[i];nodeValue=IMParts_Catalog.popupselector.initialValues[targetId];if(selectionRoot){displayValue=null;nodes=selectionRoot.childNodes;for(j=0;j<nodes.length;j++){if(nodes[j]&&nodes[j].nodeType===1&&nodes[j].getAttribute('data-im-control')==='repeater'){nodes[j].setAttribute('class','_im_widget_popup_selection');if(nodeValue===nodes[j].getAttribute('data-im-value')){displayValue=nodes[j].innerHTML;nodes[j].setAttribute('class','_im_widget_popup_selection _im_widget_popup_selected')}
IMLibMouseEventDispatch.setExecute(nodes[j].id,(function(){var node=nodes[j];return function(){IMParts_Catalog.popupselector.clearSelection();IMParts_Catalog.popupselector.setData(node)}})())}}
if(targetNode){innodes=targetNode.getElementsByClassName('_im_widget_popup_value');for(k=0;k<innodes.length;k++){innodes[k].innerHTML=displayValue?displayValue:'[Not selected]'}}}}},clickValue:function(selectionRoot){'use strict';var body,panelBack;selectionRoot.style.display='block';body=document.getElementsByTagName('BODY')[0];panelBack=document.createElement('DIV');body.appendChild(panelBack);panelBack.setAttribute('class','_im_widget_popup_panelback');panelBack.setAttribute('id','_im_widget_popup_panelback');panelBack.style.width=body.clientWidth+'px';panelBack.style.height=body.clientHeight+'px';IMLibMouseEventDispatch.setExecute('_im_widget_popup_panelback',function(){IMParts_Catalog.popupselector.clearSelection()})},clearSelection:function(){'use strict';var i,body,targetNode,selectionRoot;body=document.getElementsByTagName('BODY')[0];targetNode=document.getElementById('_im_widget_popup_panelback');if(targetNode){body.removeChild(targetNode)}
for(i=0;i<IMParts_Catalog.popupselector.ids.length;i++){selectionRoot=IMParts_Catalog.popupselector.selectionRoots[i];if(selectionRoot){selectionRoot.style.display='none'}}},setData:function(node){'use strict';var i,selectedData,target,targetField,bindingId,keyRec,nodes,contextInfo;selectedData=node.getAttribute('data-im-value');target=node.parentNode.parentNode.getAttribute('data-im').split(' ')[0].split('@');targetField=target[1];bindingId=node.parentNode.parentNode.id;contextInfo=IMLibContextPool.getContextInfoFromId(bindingId,target[2]);keyRec=contextInfo.record.split('=');contextInfo.context.setDataWithKey(keyRec[1],targetField,selectedData);nodes=node.parentNode.parentNode.getElementsByClassName('_im_widget_popup_value');for(i=0;i<nodes.length;i++){nodes[i].innerHTML=node.innerHTML}
nodes=node.parentNode.getElementsByClassName('_im_widget_popup_selection');for(i=0;i<nodes.length;i++){if(node.getAttribute('data-im-value')===nodes[i].getAttribute('data-im-value')){nodes[i].setAttribute('class','_im_widget_popup_selection _im_widget_popup_selected')}else{nodes[i].setAttribute('class','_im_widget_popup_selection')}}}};var IMLibPageNavigation={deleteInsertOnNavi:[],previousModeDetail:null,stepNavigation:[],stepCurrentContextName:null,stepStartContextName:null,navigationSetup:function(){'use strict';var navigation,i,insideNav,navLabel,node,start,pageSize,allCount,dataSources,disableClass,c_node,prevPageCount,nextPageCount,endPageCount,contextName,contextDef,buttonLabel,dataSource;navigation=document.getElementById('IM_NAVIGATOR');if(navigation!==null){if(!IMLibContextPool.getPagingContext()){navigation.style.display='none';return}
insideNav=navigation.childNodes;for(i=0;i<insideNav.length;i++){navigation.removeChild(insideNav[i])}
navigation.innerHTML='';navigation.setAttribute('class','IM_NAV_panel');navLabel=INTERMediator.navigationLabel;if(navLabel===null||navLabel[8]!==!1){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(((navLabel===null||navLabel[8]===null)?INTERMediatorOnPage.getMessages()[2]:navLabel[8])));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){INTERMediator.initialize();IMLibLocalContext.archive();location.reload()})}
if(navLabel===null||navLabel[4]!==!1){start=Number(INTERMediator.startFrom);dataSource=IMLibContextPool.getPagingContext().getContextDef();if(dataSource&&dataSource.maxrecords&&dataSource.maxrecords<parseInt(INTERMediator.pagedSize,10)){INTERMediator.pagedSize=dataSource.maxrecords}
pageSize=Number(INTERMediator.pagedSize);allCount=Number(INTERMediator.pagedAllCount);disableClass=' IM_NAV_disabled';node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(((navLabel===null||navLabel[4]===null)?INTERMediatorOnPage.getMessages()[1]:navLabel[4])+(allCount===0?0:start+1)+((Math.min(start+pageSize,allCount)-start>1)?(((navLabel===null||navLabel[5]===null)?'-':navLabel[5])+Math.min(start+pageSize,allCount)):'')+((navLabel===null||navLabel[6]===null)?' / ':navLabel[6])+(allCount)+((navLabel===null||navLabel[7]===null)?'':navLabel[7])));node.setAttribute('class','IM_NAV_info')}
if((navLabel===null||navLabel[0]!==!1)&&INTERMediator.pagination===!0){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[0]===null)?'<<':navLabel[0]));node.setAttribute('class','IM_NAV_button'+(start===0?disableClass:''));if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',0)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[1]===null)?'<':navLabel[1]));node.setAttribute('class','IM_NAV_button'+(start===0?disableClass:''));prevPageCount=(start-pageSize>0)?start-pageSize:0;if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',prevPageCount)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[2]===null)?'>':navLabel[2]));node.setAttribute('class','IM_NAV_button'+(start+pageSize>=allCount?disableClass:''));nextPageCount=(start+pageSize<allCount)?start+pageSize:((allCount-pageSize>0)?start:0);if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',nextPageCount)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[3]===null)?'>>':navLabel[3]));node.setAttribute('class','IM_NAV_button'+(start+pageSize>=allCount?disableClass:''));if(allCount%pageSize===0){endPageCount=allCount-(allCount%pageSize)-pageSize}else{endPageCount=allCount-(allCount%pageSize)}
if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',(endPageCount>0)?endPageCount:0)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[10]));c_node=document.createElement('INPUT');c_node.setAttribute('class','IM_NAV_JUMP');c_node.setAttribute('type','text');if(!c_node.id){c_node.id=INTERMediator.nextIdValue()}
c_node.setAttribute('value',String(Math.ceil(INTERMediator.startFrom/pageSize+1)));node.appendChild(c_node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[11]));IMLibChangeEventDispatch.setExecute(c_node.id,function(){var moveTo,max_page;moveTo=INTERMediatorLib.toNumber(c_node.value);if(moveTo<1){moveTo=1}
max_page=Math.ceil(allCount/pageSize);if(max_page<moveTo){moveTo=max_page}
INTERMediator.startFrom=(moveTo-1)*pageSize;INTERMediator.constructMain(!0)})}
if(navLabel===null||navLabel[9]!==!1){for(i=0;i<IMLibPageNavigation.deleteInsertOnNavi.length;i++){switch(IMLibPageNavigation.deleteInsertOnNavi[i].kind){case 'INSERT':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].insert){buttonLabel=contextDef['button-names'].insert}else{buttonLabel=INTERMediatorOnPage.getMessages()[3]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextName=obj.name,keyValue=obj.key,confirming=obj.confirm;return function(){IMLibPageNavigation.insertRecordFromNavi(contextName,keyValue,confirming)}})());break;case 'DELETE':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].delete){buttonLabel=contextDef['button-names'].delete}else{buttonLabel=INTERMediatorOnPage.getMessages()[4]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');INTERMediatorLib.addEvent(node,'click',(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextName=obj.name,keyName=obj.key,keyValue=obj.value,confirming=obj.confirm;return function(){IMLibPageNavigation.deleteRecordFromNavi(contextName,keyName,keyValue,confirming)}})());break;case 'COPY':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].copy){buttonLabel=contextDef['button-names'].copy}else{buttonLabel=INTERMediatorOnPage.getMessages()[15]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextDef=obj.contextDef,record=obj.keyValue;return function(){IMLibPageNavigation.copyRecordFromNavi(contextDef,record)}})());break}}}
if(navLabel===null||navLabel[10]!==!1){if(INTERMediatorOnPage.getOptionsTransaction()==='none'){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[10]===null)?INTERMediatorOnPage.getMessages()[7]:navLabel[10]));node.setAttribute('class','IM_NAV_button');INTERMediatorLib.addEvent(node,'click',IMLibPageNavigation.saveRecordFromNavi)}}
if(navLabel===null||navLabel[11]!==!1){if(INTERMediatorOnPage.requireAuthentication){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[8]+INTERMediatorOnPage.authUser));node.setAttribute('class','IM_NAV_info');node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[11]===null)?INTERMediatorOnPage.getMessages()[9]:navLabel[11]));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){INTERMediatorOnPage.logout();location.reload()})}}}},moveRecordFromNavi:function(targetName,page){'use strict';INTERMediator_DBAdapter.unregister();INTERMediator.startFrom=page;INTERMediator.constructMain(!0)},insertRecordFromNavi:function(targetName,keyField,isConfirm){'use strict';var contextDef;if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1026])){return}}
INTERMediatorOnPage.showProgress();contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',targetName);if(contextDef===null){window.alert('no targetname :'+targetName);INTERMediatorOnPage.hideProgress();return}
IMLibQueue.setTask((function(){var conditions,restore;var contextDefCapt=contextDef;var targetNameCapt=targetName;var keyFieldCapt=keyField;var isConfirmCapt=isConfirm;return function(completeTask){try{INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_createRecord_async({name:targetNameCapt,dataset:[]},function(response){var newId=response.newRecordKeyValue;if(newId>-1){restore=INTERMediator.additionalCondition;if(contextDefCapt.records<=1){INTERMediator.startFrom=0;INTERMediator.pagedAllCount=1;conditions=INTERMediator.additionalCondition;conditions[targetNameCapt]={field:keyFieldCapt,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}else{INTERMediator.pagedAllCount++}
completeTask();INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(!0);INTERMediator.additionalCondition=restore;IMLibPageNavigation.navigationSetup()}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()},completeTask)}catch(ex){completeTask();if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibPageNavigation.insertRecordFromNavi(targetNameCapt,keyFieldCapt,isConfirmCapt)});INTERMediatorLog.flushMessage()}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-5')}}}})())},deleteRecordFromNavi:function(targetName,keyField,keyValue,isConfirm){'use strict';if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1025])){return}}
IMLibQueue.setTask((function(){var deleteArgs={name:targetName,conditions:[{field:keyField,operator:'=',value:keyValue}]};return function(completeTask){INTERMediatorOnPage.showProgress();try{INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_delete_async(deleteArgs,(function(){return function(){INTERMediator.pagedAllCount--;INTERMediator.totalRecordCount--;if(INTERMediator.pagedAllCount-INTERMediator.startFrom<1){INTERMediator.startFrom--;if(INTERMediator.startFrom<0){INTERMediator.startFrom=0}}
completeTask();INTERMediator.constructMain(!0);INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),completeTask())}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-6');completeTask()}}})())},copyRecordFromNavi:function(contextDef,keyValue){'use strict';if(contextDef['repeat-control'].match(/confirm-copy/)){if(!window.confirm(INTERMediatorOnPage.getMessages()[1041])){return}}
IMLibQueue.setTask((function(){var contextDefCapt=contextDef;var keyValueCapt=keyValue;return function(completeTask){var assocDef,i,def,assocContexts,pStart,copyTerm,index;INTERMediatorOnPage.showProgress();try{if(contextDefCapt.relation){for(index in contextDefCapt.relation){if(contextDefCapt.relation[index].portal===!0){contextDefCapt.portal=!0}}}
assocDef=[];if(contextDefCapt['repeat-control'].match(/copy-/)){pStart=contextDefCapt['repeat-control'].indexOf('copy-');copyTerm=contextDefCapt['repeat-control'].substr(pStart+5);if((pStart=copyTerm.search(/\s/))>-1){copyTerm=copyTerm.substr(0,pStart)}
assocContexts=copyTerm.split(',');for(i=0;i<assocContexts.length;i++){def=IMLibContextPool.getContextDef(assocContexts[i]);if(def.relation[0]['foreign-key']){assocDef.push({name:def.name,field:def.relation[0]['foreign-key'],value:keyValueCapt})}}}
INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_copy_async({name:contextDefCapt.name,conditions:[{field:contextDefCapt.key,operator:'=',value:keyValueCapt}],associated:assocDef.length>0?assocDef:null},(function(){var contextDefCapt2=contextDefCapt;return function(result){var restore,conditions;var newId=result.newRecordKeyValue;completeTask();if(newId>-1){restore=INTERMediator.additionalCondition;INTERMediator.startFrom=0;if(contextDefCapt2.records<=1){conditions=INTERMediator.additionalCondition;conditions[contextDefCapt2.name]={field:contextDefCapt2.key,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}
INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(!0);INTERMediator.additionalCondition=restore}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),completeTask)}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-43');completeTask()}}})())},saveRecordFromNavi:function(dontUpdate){'use strict';var keying,field,keyingComp,keyingField,keyingValue,checkQueryParameter,i,initialValue,currentVal,fieldArray,valueArray,difference,needUpdate=!0,context,updateData,response;INTERMediatorOnPage.showProgress();INTERMediatorOnPage.retrieveAuthInfo();for(i=0;i<IMLibContextPool.poolingContexts.length;i++){context=IMLibContextPool.poolingContexts[i];updateData=context.getModified();for(keying in updateData){if(updateData.hasOwnProperty(keying)){fieldArray=[];valueArray=[];for(field in updateData[keying]){if(updateData[keying].hasOwnProperty(field)){fieldArray.push(field);valueArray.push({field:field,value:updateData[keying][field]})}}
keyingComp=keying.split('=');keyingField=keyingComp[0];keyingComp.shift();keyingValue=keyingComp.join('=');if(!INTERMediator.ignoreOptimisticLocking){checkQueryParameter={name:context.contextName,records:1,paging:!1,fields:fieldArray,parentkeyvalue:null,conditions:[{field:keyingField,operator:'=',value:keyingValue}],useoffset:!1,primaryKeyOnly:!0};try{currentVal=INTERMediator_DBAdapter.db_query(checkQueryParameter)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating((function(){var qParam=checkQueryParameter;return function(){INTERMediator.db_query(qParam)}})());return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-28')}}
if(currentVal.recordset===null||currentVal.recordset[0]===null){window.alert(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1003],[fieldArray.join(',')]));return}
if(currentVal.count>1){response=window.confirm(INTERMediatorOnPage.getMessages()[1024]);if(!response){return}}
difference=!1;for(field in updateData[keying]){if(updateData[keying].hasOwnProperty(field)){initialValue=context.getValue(keying,field);if(initialValue!==currentVal.recordset[0][field]){difference+=INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1035],[field,currentVal.recordset[0][field],updateData[keying][field]])}}}
if(difference!==!1){if(!window.confirm(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1034],[difference]))){return}
INTERMediatorOnPage.retrieveAuthInfo()}}
try{INTERMediator_DBAdapter.db_update({name:context.contextName,conditions:[{field:keyingField,operator:'=',value:keyingValue}],dataset:valueArray})}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibPageNavigation.saveRecordFromNavi(dontUpdate)});return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-29')}}
context.clearModified()}}}
if(needUpdate&&(dontUpdate!==!0)){INTERMediator.constructMain(!0)}
INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()},setupCopyButton:function(encNodeTag,repNodeTag,repeaters,currentContext,currentRecord){'use strict';var buttonNode,thisId,tdNodes,tdNode,buttonName,currentContextDef;currentContextDef=currentContext.getContextDef();if(!currentContextDef['repeat-control']||!currentContextDef['repeat-control'].match(/copy/i)){return}
if(currentContextDef.relation||currentContextDef.records===undefined||!currentContextDef.paging||(currentContextDef.records>1&&Number(INTERMediator.pagedSize)!==1)){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Copy');buttonName=INTERMediatorOnPage.getMessages()[14];if(currentContextDef['button-names']&&currentContextDef['button-names'].copy){buttonName=currentContextDef['button-names'].copy}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;IMLibMouseEventDispatch.setExecute(thisId,(function(){var currentContextCapt=currentContext,currentRecordCapt=currentRecord[currentContextDef.key];return function(){IMLibUI.copyButton(currentContextCapt,currentRecordCapt)}})());switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[tdNodes.length-1];tdNode.appendChild(buttonNode);break;case 'SELECT':break;default:if(repeaters[0]&&repeaters[0].childNodes){repeaters[repeaters.length-1].appendChild(buttonNode)}else{repeaters.push(buttonNode)}
break}}else{IMLibPageNavigation.deleteInsertOnNavi.push({kind:'COPY',name:currentContextDef.name,contextDef:currentContextDef,keyValue:currentRecord[currentContextDef.key]})}},setupDeleteButton:function(encNodeTag,repeaters,currentContext,keyField,keyValue){'use strict';var buttonNode,thisId,tdNodes,tdNode,buttonName,currentContextDef;currentContextDef=currentContext.contextDefinition;if(!currentContextDef['repeat-control']||!currentContextDef['repeat-control'].match(/delete/i)){return}
if(currentContextDef.relation||currentContextDef.records===undefined||!currentContextDef.paging||(currentContextDef.records>1&&Number(INTERMediator.pagedSize)!==1)){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Delete');buttonName=INTERMediatorOnPage.getMessages()[6];if(currentContextDef['button-names']&&currentContextDef['button-names'].delete){buttonName=currentContextDef['button-names'].delete}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;IMLibMouseEventDispatch.setExecute(thisId,(function(){var currentContextCapt=currentContext,keyFieldCapt=keyField,keyValueCapt=keyValue,confirmingCapt=!!currentContextDef['repeat-control'].match(/confirm-delete/i);return function(){IMLibUI.deleteButton(currentContextCapt,keyFieldCapt,keyValueCapt,confirmingCapt)}})());switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[tdNodes.length-1];tdNode.appendChild(buttonNode);break;case 'SELECT':break;default:if(repeaters[0]&&repeaters[0].childNodes){repeaters[repeaters.length-1].appendChild(buttonNode)}else{repeaters.push(buttonNode)}
break}}else{IMLibPageNavigation.deleteInsertOnNavi.push({kind:'DELETE',name:currentContextDef.name,key:keyField,value:keyValue,confirm:currentContextDef['repeat-control'].match(/confirm-delete/i)})}},setupInsertButton:function(currentContext,keyValue,node,relationValue){'use strict';var buttonNode,enclosedNode,footNode,trNode,tdNode,liNode,divNode,i,firstLevelNodes,targetNodeTag,existingButtons,keyField,thisId,encNodeTag,buttonName,setTop,currentContextDef;encNodeTag=node.tagName;currentContextDef=currentContext.getContextDef();if(currentContextDef['repeat-control']&&currentContextDef['repeat-control'].match(/insert/i)){if(relationValue.length>0||!currentContextDef.paging||currentContextDef.paging===!1){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Insert');buttonName=INTERMediatorOnPage.getMessages()[5];if(currentContextDef['button-names']&&currentContextDef['button-names'].insert){buttonName=currentContextDef['button-names'].insert}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;switch(encNodeTag){case 'TBODY':setTop=!1;targetNodeTag='TFOOT';if(currentContextDef['repeat-control'].match(/top/i)){targetNodeTag='THEAD';setTop=!0}
enclosedNode=node.parentNode;firstLevelNodes=enclosedNode.childNodes;footNode=null;for(i=0;i<firstLevelNodes.length;i++){if(firstLevelNodes[i].tagName===targetNodeTag){footNode=firstLevelNodes[i];break}}
if(footNode===null){footNode=document.createElement(targetNodeTag);enclosedNode.appendChild(footNode)}
existingButtons=INTERMediatorLib.getElementsByClassName(footNode,'IM_Button_Insert');if(existingButtons.length===0){trNode=document.createElement('TR');INTERMediatorLib.setClassAttributeToNode(trNode,'IM_Insert_TR');tdNode=document.createElement('TD');tdNode.setAttribute('colspan',100);INTERMediatorLib.setClassAttributeToNode(tdNode,'IM_Insert_TD');INTERMediator.setIdValue(trNode);if(setTop&&footNode.childNodes){footNode.insertBefore(trNode,footNode.childNodes[0])}else{footNode.appendChild(trNode)}
trNode.appendChild(tdNode);tdNode.appendChild(buttonNode)}
break;case 'UL':case 'OL':liNode=document.createElement('LI');existingButtons=INTERMediatorLib.getElementsByClassName(liNode,'IM_Button_Insert');if(existingButtons.length===0){liNode.appendChild(buttonNode);if(currentContextDef['repeat-control'].match(/top/i)){node.insertBefore(liNode,node.firstChild)}else{node.appendChild(liNode)}}
break;case 'SELECT':break;default:divNode=document.createElement('DIV');existingButtons=INTERMediatorLib.getElementsByClassName(divNode,'IM_Button_Insert');if(existingButtons.length===0){divNode.appendChild(buttonNode);if(currentContextDef['repeat-control'].match(/top/i)){node.insertBefore(divNode,node.firstChild)}else{node.appendChild(divNode)}}
break}
IMLibMouseEventDispatch.setExecute(buttonNode.id,(function(){var context=currentContext,keyValueCapt=keyValue,relationValueCapt=relationValue,nodeId=node.getAttribute('id'),confirming=!!currentContextDef['repeat-control'].match(/confirm-insert/i);return function(){IMLibUI.insertButton(context,keyValueCapt,relationValueCapt,nodeId,confirming)}})())}else{if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){keyField=currentContextDef.key?currentContextDef.key:INTERMediatorOnPage.defaultKeyName}else{keyField=currentContextDef.key?currentContextDef.key:'id'}
IMLibPageNavigation.deleteInsertOnNavi.push({kind:'INSERT',name:currentContextDef.name,key:keyField,confirm:currentContextDef['repeat-control'].match(/confirm-insert/i)})}}},setupNavigationButton:function(encNodeTag,repeaters,currentContextDef,keyField,keyValue,contextObj){'use strict';var buttonNode,thisId,tdNodes,tdNode,firstInNode,isMasterDetail,isStep,isHide,masterContext,detailContext,showingNode,isHidePageNavi,buttonName,i,isTouchRepeater,moveToDetailFunc;if(!currentContextDef['navi-control']||(!currentContextDef['navi-control'].match(/master/i)&&!currentContextDef['navi-control'].match(/step/i))||encNodeTag==='SELECT'){return}
isTouchRepeater=INTERMediator.isMobile||INTERMediator.isTablet;isHide=!!currentContextDef['navi-control'].match(/hide/i);isHidePageNavi=isHide&&!!currentContextDef.paging;isMasterDetail=!!currentContextDef['navi-control'].match(/master/i);isStep=!!currentContextDef['navi-control'].match(/step/i);if(isMasterDetail&&INTERMediator.detailNodeOriginalDisplay){detailContext=IMLibContextPool.getDetailContext();if(detailContext){showingNode=detailContext.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
INTERMediator.detailNodeOriginalDisplay=showingNode.style.display}}
buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Master');buttonName=INTERMediatorOnPage.getMessages()[12];if(currentContextDef['button-names']&&currentContextDef['button-names']['navi-detail']){buttonName=currentContextDef['button-names']['navi-detail']}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;if(isMasterDetail){masterContext=IMLibContextPool.getMasterContext();masterContext.setValue(keyField+'='+keyValue,'_im_button_master_id',thisId,thisId)}
if(isMasterDetail){moveToDetailFunc=IMLibPageNavigation.moveToDetail(keyField,keyValue,isHide,isHidePageNavi)}
if(isStep){moveToDetailFunc=IMLibPageNavigation.moveToNextStep(contextObj,keyField,keyValue)}
if(isTouchRepeater){for(i=0;i<repeaters.length;i++){var originalColor=repeaters[i].style.backgroundColor;INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchstart','todo':(function(){var targetNode=repeaters[i];return function(){IMLibEventResponder.touchEventCancel=!1;targetNode.style.backgroundColor=IMLibUI.mobileSelectionColor}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchend','todo':(function(){var targetNode=repeaters[i];var orgColor=originalColor;return function(){targetNode.style.backgroundColor=orgColor;if(!IMLibEventResponder.touchEventCancel){IMLibEventResponder.touchEventCancel=!1;moveToDetailFunc()}}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchmove','todo':(function(){return function(){IMLibEventResponder.touchEventCancel=!0}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchcancel','todo':(function(){return function(){IMLibEventResponder.touchEventCancel=!0}})()})}}else{IMLibMouseEventDispatch.setExecute(thisId,moveToDetailFunc);switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[0];firstInNode=tdNode.childNodes[0];if(firstInNode){tdNode.insertBefore(buttonNode,firstInNode)}else{tdNode.appendChild(buttonNode)}
break;case 'SELECT':break;default:firstInNode=repeaters[repeaters.length-1].childNodes[0];if(firstInNode){repeaters[repeaters.length-1].insertBefore(buttonNode,firstInNode)}else{repeaters[repeaters.length-1].appendChild(buttonNode)}
break}}},getStepLastSelectedRecord:function(){'use strict';var lastSelection=IMLibPageNavigation.stepNavigation[IMLibPageNavigation.stepNavigation.length-1];return lastSelection.context.store[lastSelection.key]},isNotExpandingContext:function(contextDef){'use strict';if(contextDef['navi-control']&&contextDef['navi-control'].match(/step/i)){return IMLibPageNavigation.stepCurrentContextName!==contextDef.name}
return!1},startStep:function(){'use strict';IMLibPageNavigation.initializeStepInfo(!0);INTERMediator.constructMain(IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName))},initializeStepInfo:function(includeHide){'use strict';var key,dataSrcs,cDef,judgeHide,isDetected=!1;IMLibPageNavigation.stepNavigation=[];IMLibPageNavigation.stepCurrentContextName=null;IMLibPageNavigation.stepStartContextName=null;IMLibPageNavigation.setupStepReturnButton('none');if(INTERMediatorOnPage.getDataSources){dataSrcs=INTERMediatorOnPage.getDataSources();for(key in dataSrcs){if(dataSrcs.hasOwnProperty(key)){cDef=dataSrcs[key];if(cDef['navi-control']){judgeHide=includeHide||(!includeHide&&!cDef['navi-control'].match(/hide/i));if(cDef['navi-control']&&cDef['navi-control'].match(/step/i)){if(judgeHide&&!isDetected){IMLibPageNavigation.stepCurrentContextName=cDef.name;IMLibPageNavigation.stepStartContextName=IMLibPageNavigation.stepCurrentContextName;isDetected=!0;if(cDef['navi-title']){IMLibLocalContext.setValue('navi_title',cDef['navi-title'],!0)}
if(INTERMediatorOnPage[cDef['just-move-thisstep']]){INTERMediatorOnPage[cDef['just-move-thisstep']]()}}}}}}}},setupStepReturnButton:function(style){'use strict';var nodes,i;nodes=document.getElementsByClassName('IM_Button_StepBack');for(i=0;i<nodes.length;i++){nodes[i].style.display=style;if(!INTERMediatorLib.isProcessed(nodes[i])){INTERMediatorLib.addEvent(nodes[i],'click',function(){IMLibPageNavigation.backToPreviousStep()});INTERMediatorLib.markProcessed(nodes[i])}}},moveToNextStep:function(contextObj,keyField,keyValue){'use strict';var context=contextObj,keying=keyField+'='+keyValue;return function(){IMLibQueue.setTask(function(complete){IMLibPageNavigation.moveToNextStepImpl(context,keying);complete()})}},moveNextStep:function(keying){'use strict';var context=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);IMLibPageNavigation.moveToNextStepImpl(context,keying)},moveToNextStepImpl:function(contextObj,keying){'use strict';var key,cDef,dataSrcs,contextDef,isAfterCurrent=!1,control=null,hasNextContext=!1,nextContext;contextDef=contextObj.getContextDef();IMLibPageNavigation.stepNavigation.push({context:contextObj,key:keying});if(INTERMediatorOnPage[contextDef['before-move-nextstep']]){control=INTERMediatorOnPage[contextDef['before-move-nextstep']]()}
if(control===!1){IMLibPageNavigation.stepNavigation.pop();return}else if(control){IMLibPageNavigation.stepCurrentContextName=control}else{dataSrcs=INTERMediatorOnPage.getDataSources();for(key in dataSrcs){if(dataSrcs.hasOwnProperty(key)){cDef=dataSrcs[key];if(cDef.name===contextDef.name){isAfterCurrent=!0}else if(isAfterCurrent&&cDef['navi-control'].match(/step/i)){IMLibPageNavigation.stepCurrentContextName=cDef.name;hasNextContext=!0;break}}}
if(!hasNextContext){return}}
if(INTERMediatorOnPage[contextDef['just-leave-thisstep']]){INTERMediatorOnPage[contextDef['just-leave-thisstep']]()}
if(contextObj.enclosureNode.tagName==='TBODY'){contextObj.enclosureNode.parentNode.style.display='none'}else{contextObj.enclosureNode.style.display='none'}
nextContext=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);contextDef=nextContext.getContextDef();if(nextContext.enclosureNode.tagName==='TBODY'){nextContext.enclosureNode.parentNode.style.display=''}else{nextContext.enclosureNode.style.display=''}
INTERMediator.constructMain(nextContext);IMLibPageNavigation.setupStepReturnButton('');if(contextDef['navi-title']){IMLibLocalContext.setValue('navi_title',contextDef['navi-title'],!0)}
if(INTERMediatorOnPage[contextDef['just-move-thisstep']]){INTERMediatorOnPage[contextDef['just-move-thisstep']]()}},backToPreviousStep:function(){'use strict';var currentContext,prevInfo,contextDef;currentContext=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);contextDef=currentContext.getContextDef();if(INTERMediatorOnPage[contextDef['just-leave-thisstep']]){INTERMediatorOnPage[contextDef['just-leave-thisstep']]()}
prevInfo=IMLibPageNavigation.stepNavigation.pop();IMLibPageNavigation.stepCurrentContextName=prevInfo.context.contextName;if(prevInfo.context.enclosureNode.tagName==='TBODY'){prevInfo.context.enclosureNode.parentNode.style.display=''}else{prevInfo.context.enclosureNode.style.display=''}
if(IMLibPageNavigation.stepStartContextName===IMLibPageNavigation.stepCurrentContextName){IMLibPageNavigation.setupStepReturnButton('none')}
INTERMediator.constructMain(currentContext);INTERMediator.constructMain(prevInfo.context);contextDef=prevInfo.context.getContextDef();if(contextDef['navi-title']){IMLibLocalContext.setValue('navi_title',contextDef['navi-title'],!0)}
if(INTERMediatorOnPage[contextDef['just-move-thisstep']]){INTERMediatorOnPage[contextDef['just-move-thisstep']]()}},moveToDetail:function(keyField,keyValue,isHide,isHidePageNavi){'use strict';var f=keyField,v=keyValue,mh=isHide,pnh=isHidePageNavi;return function(){return IMLibPageNavigation.moveToDetailImpl(f,v,mh,pnh)}},moveToDetailImpl:function(keyField,keyValue,isHide,isHidePageNavi){'use strict';var masterContext,detailContext,contextName,masterEnclosure,detailEnclosure,node,contextDef;IMLibPageNavigation.previousModeDetail={keyField:keyField,keyValue:keyValue,isHide:isHide,isHidePageNavi:isHidePageNavi};masterContext=IMLibContextPool.getMasterContext();detailContext=IMLibContextPool.getDetailContext();if(detailContext){if(INTERMediatorOnPage.naviBeforeMoveToDetail){INTERMediatorOnPage.naviBeforeMoveToDetail(masterContext,detailContext)}
contextDef=detailContext.getContextDef();contextName=contextDef.name;INTERMediator.clearCondition(contextName,'_imlabel_crosstable');INTERMediator.addCondition(contextName,{field:keyField,operator:'=',value:keyValue},undefined,'_imlabel_crosstable');INTERMediator.constructMain(detailContext);INTERMediator.clearCondition(contextName);if(isHide){INTERMediatorOnPage.masterScrollPosition={x:window.scrollX,y:window.scrollY};window.scrollTo(0,0);masterEnclosure=masterContext.enclosureNode;if(masterEnclosure.tagName==='TBODY'){masterEnclosure=masterEnclosure.parentNode}
INTERMediator.masterNodeOriginalDisplay=masterEnclosure.style.display;masterEnclosure.style.display='none';detailEnclosure=detailContext.enclosureNode;if(detailEnclosure.tagName==='TBODY'){detailEnclosure=detailEnclosure.parentNode}
detailEnclosure.style.display=INTERMediator.detailNodeOriginalDisplay}
if(isHidePageNavi){document.getElementById('IM_NAVIGATOR').style.display='none'}
if(IMLibUI.mobileNaviBackButtonId){node=document.getElementById(IMLibUI.mobileNaviBackButtonId);node.style.display='inline-block'}
if(INTERMediatorOnPage.naviAfterMoveToDetail){masterContext=IMLibContextPool.getMasterContext();detailContext=IMLibContextPool.getDetailContext();INTERMediatorOnPage.naviAfterMoveToDetail(masterContext,detailContext)}}},setupDetailAreaToFirstRecord:function(currentContextDef,masterContext){'use strict';var i,comp;if(currentContextDef['navi-control']&&currentContextDef['navi-control'].match(/master/i)){var contextDefs=INTERMediatorOnPage.getDataSources();for(i in contextDefs){if(contextDefs.hasOwnProperty(i)&&contextDefs[i]&&contextDefs[i].name&&contextDefs[i]['navi-control']&&contextDefs[i]['navi-control'].match(/detail/i)){if(Object.keys(masterContext.store).length>0){comp=Object.keys(masterContext.store)[0].split('=');if(comp.length>1){INTERMediator.clearCondition(contextDefs[i].name,'_imlabel_crosstable');INTERMediator.addCondition(contextDefs[i].name,{field:comp[0],operator:'=',value:comp[1]},undefined,'_imlabel_crosstable')}}}}}},moveDetailOnceAgain:function(){'use strict';var p=IMLibPageNavigation.previousModeDetail;IMLibPageNavigation.moveToDetailImpl(p.keyField,p.keyValue,p.isHide,p.isHidePageNavi)},setupBackNaviButton:function(currentContext,node){'use strict';var buttonNode,divNode,i,masterContext,naviControlValue,currentContextDef,showingNode,isHidePageNavi,isUpdateMaster,isTouchRepeater,aNode,nodes,isTop;currentContextDef=currentContext.getContextDef();if(!currentContextDef['navi-control']||!currentContextDef['navi-control'].match(/detail/i)){return}
masterContext=IMLibContextPool.getMasterContext();isHidePageNavi=!!masterContext.getContextDef().paging;if(masterContext.getContextDef().paging&&currentContextDef.paging){INTERMediatorLog.setErrorMessage('The datail context definition has the "paging" key. '+'This is not required and causes bad effect to the pagination.','Detected Error')}
naviControlValue=masterContext.getContextDef()['navi-control'];if(!naviControlValue||(!naviControlValue.match(/hide/i))){return}
isUpdateMaster=!!currentContextDef['navi-control'].match(/update/i);isTouchRepeater=INTERMediator.isMobile||INTERMediator.isTablet;isTop=!(currentContextDef['navi-control'].match(/bottom/i));showingNode=currentContext.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
if(INTERMediator.detailNodeOriginalDisplay){INTERMediator.detailNodeOriginalDisplay=showingNode.style.display}
showingNode.style.display='none';if(isTouchRepeater){nodes=document.getElementsByClassName('IM_Button_BackNavi');if(!nodes||nodes.length===0){aNode=createBackButton('DIV',currentContextDef);IMLibUI.mobileNaviBackButtonId=aNode.id;aNode.style.display='none';nodes=INTERMediatorLib.getElementsByAttributeValue(document.getElementsByTagName('BODY')[0],'data-role',isTop?'header':'footer');if(nodes&&nodes[0]){if(nodes[0].firstChild){nodes[0].insertBefore(aNode,nodes[0].firstChild)}else{nodes[0].appendChild(aNode)}}else{switch(node.tagName){case 'TBODY':tbodyTargetNode(node,isTop,aNode);break;case 'UL':case 'OL':genericTargetNode(node,isTop,'LI',aNode);break;case 'SELECT':break;default:genericTargetNode(node,isTop,'DIV',aNode);break}}
if(!aNode.id){aNode.id=INTERMediator.nextIdValue()}
INTERMediator.eventListenerPostAdding.push({'id':aNode.id,'event':'touchend','todo':moveToMaster(masterContext,currentContext,isHidePageNavi,isUpdateMaster)})}}else{buttonNode=createBackButton('BUTTON',currentContextDef);switch(node.tagName){case 'TBODY':tbodyTargetNode(node,isTop,buttonNode);break;case 'UL':case 'OL':genericTargetNode(node,isTop,'LI',buttonNode);break;case 'SELECT':break;default:genericTargetNode(node,isTop,'DIV',buttonNode);break}
INTERMediatorLib.addEvent(buttonNode,'click',moveToMaster(masterContext,currentContext,isHidePageNavi,isUpdateMaster))}
function createBackButton(tagName,currentContextDef){var buttonNode,buttonName;buttonNode=document.createElement(tagName);INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_BackNavi');buttonName=INTERMediatorOnPage.getMessages()[13];if(currentContextDef['button-names']&&currentContextDef['button-names']['navi-back']){buttonName=currentContextDef['button-names']['navi-back']}
buttonNode.appendChild(document.createTextNode(buttonName));setIdForIMButtons(buttonNode);return buttonNode}
function setIdForIMButtons(node){var thisId;thisId='IM_Button_'+INTERMediator.buttonIdNum;node.setAttribute('id',thisId);INTERMediator.buttonIdNum++}
function tbodyTargetNode(node,isTop,buttonNode){var targetNodeTag,enclosedNode,firstLevelNodes,targetNode,existingButtons,trNode,tdNode;targetNodeTag=isTop?'THEAD':'TFOOT';enclosedNode=node.parentNode;firstLevelNodes=enclosedNode.childNodes;targetNode=null;for(i=0;i<firstLevelNodes.length;i++){if(firstLevelNodes[i].tagName===targetNodeTag){targetNode=firstLevelNodes[i];break}}
if(targetNode===null){targetNode=document.createElement(targetNodeTag);INTERMediator.appendingNodesAtLast.push({targetNode:targetNode,parentNode:enclosedNode,siblingNode:(targetNodeTag==='THEAD')?enclosedNode.firstChild:null})}
existingButtons=INTERMediatorLib.getElementsByClassName(targetNode,'IM_Button_BackNavi');if(existingButtons.length===0){trNode=document.createElement('TR');INTERMediatorLib.setClassAttributeToNode(trNode,'IM_NaviBack_TR');tdNode=document.createElement('TD');tdNode.setAttribute('colspan',100);INTERMediatorLib.setClassAttributeToNode(tdNode,'IM_NaviBack_TD');INTERMediator.setIdValue(trNode);targetNode.appendChild(trNode);trNode.appendChild(tdNode);tdNode.appendChild(buttonNode)}}
function genericTargetNode(node,isTop,naviEncTag,buttonNode){var newNode,existingButtons;newNode=document.createElement(naviEncTag);existingButtons=INTERMediatorLib.getElementsByClassName(divNode,'IM_Button_BackNavi');if(existingButtons.length===0){newNode.appendChild(buttonNode);if(!isTop){node.appendChild(newNode)}else{node.insertBefore(newNode,node.firstChild)}}}
function moveToMaster(a,b,c,d){var masterContextCL=a,detailContextCL=b,pageNaviShow=c,masterUpdate=d,node;return function(event){var showingNode;if(INTERMediatorOnPage.naviBeforeMoveToMaster){INTERMediatorOnPage.naviBeforeMoveToMaster(masterContextCL,detailContextCL)}
showingNode=detailContextCL.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
showingNode.style.display='none';showingNode=masterContextCL.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
showingNode.style.display=INTERMediator.masterNodeOriginalDisplay;if(pageNaviShow){document.getElementById('IM_NAVIGATOR').style.display='block'}
if(masterUpdate){INTERMediator.constructMain(masterContextCL)}
if(IMLibUI.mobileNaviBackButtonId){node=document.getElementById(IMLibUI.mobileNaviBackButtonId);node.style.display='none'}
if(INTERMediatorOnPage.naviAfterMoveToMaster){masterContextCL=IMLibContextPool.getMasterContext();detailContextCL=IMLibContextPool.getDetailContext();INTERMediatorOnPage.naviAfterMoveToMaster(masterContextCL,detailContextCL)}
if(INTERMediatorOnPage.masterScrollPosition){window.scrollTo(INTERMediatorOnPage.masterScrollPosition.x,INTERMediatorOnPage.masterScrollPosition.y)}
event.preventDefault()}}}};var IMLibUI={mobileSelectionColor:'#BBBBBB',mobileNaviBackButtonId:null,mergedFieldSeparator:'\n',valueChange:function(idValue,validationOnly){'use strict';var changedObj,contextInfo,linkInfo,nodeInfo,returnValue=!0;changedObj=document.getElementById(idValue);if(!changedObj){return!1}
if(changedObj.readOnly){return!0}
if(!IMLibUI.validation(changedObj)){changedObj.focus();linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);window.setTimeout((function(){var originalObj=changedObj;var originalContextInfo=contextInfo;return function(){if(originalContextInfo){originalObj.value=originalContextInfo.context.getValue(originalContextInfo.record,originalContextInfo.field)}
originalObj.removeAttribute('data-im-validation-notification')}})(),0);return!1}
if(validationOnly===!0){return!0}
IMLibQueue.setTask(function(completeTask){returnValue=valueChangeImpl(idValue,completeTask)});return returnValue;function valueChangeImpl(idValue,completeTask){var changedObj,objType,i,newValue,result,linkInfo,nodeInfo,contextInfo,parentContext,targetField,targetNode,targetSpec,returnValue=!0;try{changedObj=document.getElementById(idValue);linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);if(!contextInfo){targetNode=document.getElementById(idValue);targetSpec=targetNode.getAttribute('data-im');if(targetSpec&&targetSpec.split(INTERMediator.separator)[0]===IMLibLocalContext.contextName){IMLibLocalContext.updateFromNodeValue(idValue);IMLibCalc.recalculation();completeTask();return!0}
throw 'unfinished'}
objType=changedObj.getAttribute('type');if(objType==='radio'&&!changedObj.checked){completeTask();return!0}
if(!contextInfo){throw 'unfinished'}
newValue=IMLibElement.getValueFromIMNode(changedObj);if(contextInfo.context.parentContext){parentContext=contextInfo.context.parentContext}else{parentContext=IMLibContextPool.getContextFromName(contextInfo.context.sourceName)[0]}
if(parentContext){result=parentContext.isValueUndefined(Object.keys(parentContext.store)[0],contextInfo.field,contextInfo.record)}else{result=contextInfo.context.isValueUndefined(contextInfo.record,contextInfo.field,!1)}
if(result){INTERMediatorLog.setErrorMessage('Error in updating.',INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1040],[contextInfo.context.contextName,contextInfo.field]));throw 'unfinished'}
if(INTERMediatorOnPage.getOptionsTransaction()==='none'){contextInfo.context.setValue(contextInfo.record,contextInfo.field,newValue);contextInfo.context.setModified(contextInfo.record,contextInfo.field,newValue);throw 'unfinished'}
if(INTERMediatorOnPage.doBeforeValueChange){INTERMediatorOnPage.doBeforeValueChange(idValue)}
INTERMediatorOnPage.showProgress();contextInfo.context.updateFieldValue(idValue,(function(){var idValueCapt2=idValue;var contextInfoCapt=contextInfo;var newValueCapt=newValue;var completeTaskCapt=completeTask;return function(result){var updateRequiredContext,currentValue,associatedNode,field,node,children,delNodes,recordObj,keepProp;var keyField=contextInfoCapt.context.getKeyField();if(result&&result.dbresult){recordObj=result.dbresult[0];keepProp=INTERMediator.partialConstructing;INTERMediator.partialConstructing=!1;for(field in recordObj){if(recordObj.hasOwnProperty(field)){contextInfoCapt.context.setValue(keyField+'='+recordObj[keyField],field,recordObj[field])}}}
INTERMediator.partialConstructing=keepProp;updateRequiredContext=IMLibContextPool.dependingObjects(idValueCapt2);for(i=0;i<updateRequiredContext.length;i++){updateRequiredContext[i].foreignValue={};updateRequiredContext[i].foreignValue[contextInfoCapt.field]=newValueCapt;if(updateRequiredContext[i]){INTERMediator.constructMain(updateRequiredContext[i]);associatedNode=updateRequiredContext[i].enclosureNode;if(INTERMediatorLib.isPopupMenu(associatedNode)){currentValue=contextInfo.context.getContextValue(associatedNode.id,'');IMLibElement.setValueToIMNode(associatedNode,'',currentValue,!1)}}}
node=document.getElementById(idValueCapt2);if(node&&node.tagName==='SELECT'){children=node.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(children[i].tagName==='OPTION'&&children[i].getAttribute('data-im-element')==='auto-generated'){delNodes=[];delNodes.push(children[i].getAttribute('id'));IMLibElement.deleteNodes(delNodes)}}}}
IMLibCalc.recalculation();if(INTERMediatorOnPage.doAfterValueChange){INTERMediatorOnPage.doAfterValueChange(idValueCapt2)}
INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage();if(completeTaskCapt){completeTaskCapt()}}})(),(function(){var targetFieldCapt=targetField;var completeTaskCapt=completeTask;return function(){window.alert(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1003],[targetFieldCapt]));INTERMediatorOnPage.hideProgress();if(completeTaskCapt){completeTaskCapt()}}})(),function(){var response=window.confirm(INTERMediatorOnPage.getMessages()[1024]);if(!response){INTERMediatorOnPage.hideProgress()}
if(completeTask){completeTask()}
return response},(function(){var changedObjectCapt=changedObj;var completeTaskCapt=completeTask;return function(initialvalue,newValue,currentFieldVal){if(completeTaskCapt){completeTaskCapt()}
if(!window.confirm(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1001],[initialvalue,newValue,currentFieldVal]))){window.setTimeout(function(){changedObjectCapt.focus()},0);INTERMediatorOnPage.hideProgress();return!1}
return!0}})())}catch(e){if(completeTask){completeTask()}
returnValue=!1}
return returnValue}},validation:function(changedObj){'use strict';var linkInfo,matched,context,i,index,didValidate,contextInfo,result,messageNodes=[],messageNode;if(messageNodes){while(messageNodes.length>0){messageNodes[0].parentNode.removeChild(messageNodes[0]);delete messageNodes[0]}}
if(!messageNodes){messageNodes=[]}
try{linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);didValidate=!1;result=!0;if(linkInfo.length>0){matched=linkInfo[0].match(/([^@]+)/);if(matched[1]!==IMLibLocalContext.contextName){context=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',matched[1]);if(context&&context.validation){for(i=0;i<linkInfo.length;i++){matched=linkInfo[i].match(/([^@]+)@([^@]+)/);for(index in context.validation){if(context.validation[index].field===matched[2]){didValidate=!0;result=Parser.evaluate(context.validation[index].rule,{'value':changedObj.value,'target':changedObj});if(!result){switch(context.validation[index].notify){case 'inline':INTERMediatorLib.clearErrorMessage(changedObj);messageNode=INTERMediatorLib.createErrorMessageNode('SPAN',context.validation[index].message);changedObj.parentNode.insertBefore(messageNode,changedObj.nextSibling);messageNodes.push(messageNode);break;case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(changedObj);messageNode=INTERMediatorLib.createErrorMessageNode('DIV',context.validation[index].message);changedObj.parentNode.appendChild(messageNode);messageNodes.push(messageNode);break;default:if(changedObj.getAttribute('data-im-validation-notification')!=='alert'){window.alert(context.validation[index].message);changedObj.setAttribute('data-im-validation-notification','alert')}
break}
contextInfo=IMLibContextPool.getContextInfoFromId(changedObj,'');if(contextInfo){changedObj.value=contextInfo.context.getValue(contextInfo.record,contextInfo.field);window.setTimeout(function(){changedObj.focus()},0);if(INTERMediatorOnPage.doAfterValidationFailure!==null){INTERMediatorOnPage.doAfterValidationFailure(changedObj,linkInfo[i])}}
return result}else{switch(context.validation[index].notify){case 'inline':case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(changedObj);break}}}}}}}
if(didValidate){if(INTERMediatorOnPage.doAfterValidationSucceed){result=INTERMediatorOnPage.doAfterValidationSucceed(changedObj,linkInfo[i])}}}
return result}catch(ex){if(ex==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-32: on the validation process.')}
return!1}},copyButton:function(contextObj,keyValue){'use strict';var contextDef=contextObj.getContextDef();if(contextDef['repeat-control'].match(/confirm-copy/)){if(!window.confirm(INTERMediatorOnPage.getMessages()[1041])){return}}
IMLibQueue.setTask((function(){var contextObjCapt=contextObj;var keyValueCapt=keyValue;return function(completeTask){var contextDef,assocDef,i,index,def,assocContexts,pStart,copyTerm;contextDef=contextObjCapt.getContextDef();INTERMediatorOnPage.showProgress();try{if(contextDef.relation){for(index in contextDef.relation){if(contextDef.relation[index].portal===!0){contextDef.portal=!0}}}
assocDef=[];if(contextDef['repeat-control'].match(/copy-/)){pStart=contextDef['repeat-control'].indexOf('copy-');copyTerm=contextDef['repeat-control'].substr(pStart+5);if((pStart=copyTerm.search(/\s/))>-1){copyTerm=copyTerm.substr(0,pStart)}
assocContexts=copyTerm.split(',');for(i=0;i<assocContexts.length;i++){def=IMLibContextPool.getContextDef(assocContexts[i]);if(def.relation[0]['foreign-key']){assocDef.push({name:def.name,field:def.relation[0]['foreign-key'],value:keyValueCapt})}}}
INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_copy_async({name:contextDef.name,conditions:[{field:contextDef.key,operator:'=',value:keyValueCapt}],associated:assocDef.length>0?assocDef:null},(function(){var contextDefCapt=contextDef;var contextObjCapt2=contextObjCapt;var completeTaskCapt=completeTask;return function(result){var restore,conditions,sameOriginContexts;var newId=result.newRecordKeyValue;if(newId>-1){restore=INTERMediator.additionalCondition;INTERMediator.startFrom=0;if(contextDefCapt.records<=1){conditions=INTERMediator.additionalCondition;conditions[contextDefCapt.name]={field:contextDefCapt.key,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}
INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(contextObjCapt2);sameOriginContexts=IMLibContextPool.getContextsWithSameOrigin(contextObjCapt2);for(i=0;i<sameOriginContexts.length;i++){INTERMediator.constructMain(sameOriginContexts[i],null)}
INTERMediator.additionalCondition=restore}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();completeTaskCapt();INTERMediatorLog.flushMessage()}})(),completeTask)}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-43')}}})())},deleteButton:function(currentContext,keyField,keyValue,isConfirm){'use strict';var dialogMessage;if(isConfirm){dialogMessage=INTERMediatorOnPage.getMessages()[1025];if(!window.confirm(dialogMessage)){return}}
IMLibQueue.setTask((function(){var currentContextCapt=currentContext;var keyFieldCapt=keyField;var keyValueCapt=keyValue;return function(completeTask){var i,parentKeyValue,deleteSuccessProc,targetRepeaters;INTERMediatorOnPage.showProgress();try{INTERMediatorOnPage.retrieveAuthInfo();deleteSuccessProc=(function(){var currentContextCapt2=currentContextCapt;var completeTaskCapt=completeTask;var keying=keyFieldCapt+'='+keyValueCapt;return function(){if(currentContextCapt2.relation===!0){INTERMediator.pagedAllCount--;if(INTERMediator.pagedAllCount-INTERMediator.startFrom<1){INTERMediator.startFrom=INTERMediator.startFrom-INTERMediator.pagedSize;if(INTERMediator.startFrom<0){INTERMediator.startFrom=0}}
if(INTERMediator.pagedAllCount>=INTERMediator.pagedSize){INTERMediator.construct()}}
IMLibPageNavigation.navigationSetup();targetRepeaters=currentContextCapt2.binding[keying]._im_repeater;for(i=0;i<targetRepeaters.length;i++){IMLibContextPool.removeRecordFromPool(targetRepeaters[i].id)}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();completeTaskCapt();INTERMediatorLog.flushMessage()}})();if(currentContextCapt.isPortal){if(currentContextCapt.potalContainingRecordKV===null){parentKeyValue=Object.keys(currentContextCapt.foreignValue);parentKeyValue[1]=currentContextCapt.foreignValue[parentKeyValue[0]]}else{parentKeyValue=currentContextCapt.potalContainingRecordKV.split('=')}
INTERMediator_DBAdapter.db_update_async({name:currentContextCapt.parentContext&&currentContextCapt.parentContext.contextName?currentContextCapt.parentContext.contextName:currentContextCapt.sourceName,conditions:[{field:parentKeyValue[0],operator:'=',value:parentKeyValue[1]}],dataset:[{field:INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'?'deleteRelated':'-delete.related',operator:'=',value:currentContextCapt.contextName+'.'+keyValue}]},deleteSuccessProc,completeTask)}else{INTERMediator_DBAdapter.db_delete_async({name:currentContextCapt.contextName,conditions:[{field:keyFieldCapt,operator:'=',value:keyValueCapt}]},deleteSuccessProc,function(){INTERMediatorLog.setErrorMessage('Delete Error','EXCEPTION-46');completeTask()})}}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibUI.deleteButton(currentContextCapt,keyFieldCapt,keyValueCapt,!1)});return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-3')}
completeTask()}}})())},insertButton:function(currentObj,keyValue,foreignValues,updateNodes,isConfirm){'use strict';if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1026])){return}}
IMLibQueue.setTask((function(){var currentContext,targetName,isPortal,parentContextName;var keyValueCapt=keyValue;var foreignValuesCapt=foreignValues;var updateNodesCapt=updateNodes;targetName=currentObj.contextName;currentContext=currentObj.getContextDef();isPortal=currentObj.isPortal;if(isPortal){parentContextName=currentObj.sourceName?currentObj.sourceName:null}else{parentContextName=currentObj.parentContext?currentObj.parentContext.contextName:null}
return function(completeTask){var targetRecord,portalField,recordSet,index,targetPortalField,targetPortalValue,existRelated=!1,relatedRecordSet;INTERMediatorOnPage.showProgress();recordSet=[];relatedRecordSet=[];if(foreignValuesCapt){for(index in currentContext.relation){if(currentContext.relation.hasOwnProperty(index)){recordSet.push({field:currentContext.relation[index]['foreign-key'],value:foreignValuesCapt[currentContext.relation[index]['join-field']]})}}}
INTERMediatorOnPage.retrieveAuthInfo();if(isPortal){relatedRecordSet=[];for(index in currentContext['default-values']){if(currentContext['default-values'].hasOwnProperty(index)){relatedRecordSet.push({field:targetName+'::'+currentContext['default-values'][index].field+'.0',value:currentContext['default-values'][index].value})}}
if(relatedRecordSet.length===0){targetPortalValue='';targetRecord=INTERMediator_DBAdapter.db_query({name:targetName,records:1,conditions:[{field:currentContext.key?currentContext.key:INTERMediatorOnPage.defaultKeyName,operator:'=',value:keyValueCapt}]});if(targetRecord.recordset&&targetRecord.recordset[0]&&targetRecord.recordset[0][0]){for(portalField in targetRecord.recordset[0][0]){if(portalField.indexOf(targetName+'::')>-1&&portalField!==targetName+'::'+INTERMediatorOnPage.defaultKeyName){existRelated=!0;targetPortalField=portalField;if(portalField===targetName+'::'+recordSet[0].field){targetPortalValue=recordSet[0].value;break}
if(portalField!==targetName+'::id'&&portalField!==targetName+'::'+recordSet[0].field){break}}}}
if(existRelated===!1){targetRecord=INTERMediator_DBAdapter.db_query({name:targetName,records:0,conditions:[{field:currentContext.key?currentContext.key:INTERMediatorOnPage.defaultKeyName,operator:'=',value:keyValueCapt}]});for(portalField in targetRecord.recordset){if(portalField.indexOf(targetName+'::')>-1&&portalField!==targetName+'::'+INTERMediatorOnPage.defaultKeyName){targetPortalField=portalField;if(portalField===targetName+'::'+recordSet[0].field){targetPortalValue=recordSet[0].value;break}
if(portalField!==targetName+'::id'&&portalField!==targetName+'::'+recordSet[0].field){break}}}}
if(foreignValuesCapt&&recordSet[0]){targetPortalField=targetName+'::'+recordSet[0].field;targetPortalValue=recordSet[0].value}else if(targetPortalField===undefined&&currentContext.relation&&currentContext.relation[0]&&currentContext.relation[0]['join-field']){targetPortalField=targetName+'::'+currentContext.relation[0]['join-field']}
relatedRecordSet.push({field:targetPortalField+'.0',value:targetPortalValue})}
completeTask();if(currentContext.relation&&currentContext.relation[0]&&currentContext.relation[0]['join-field']){INTERMediator_DBAdapter.db_update({name:parentContextName,conditions:[{field:currentContext.relation[0]['join-field'],operator:'=',value:foreignValuesCapt&&foreignValuesCapt.id?foreignValuesCapt.id:keyValueCapt}],dataset:relatedRecordSet});INTERMediator.constructMain()}else{INTERMediatorLog.setErrorMessage('Insert Error (Portal Access Mode)','EXCEPTION-4')}}else{INTERMediator_DBAdapter.db_createRecord_async({name:targetName,dataset:recordSet},(function(){var targetNameCapt=targetName;var currentContextCapt=currentContext;var updateNodesCapt2=updateNodesCapt;var foreignValuesCapt2=foreignValuesCapt;var existRelatedCapt=existRelated;var keyValueCapt2=keyValueCapt;return function(result){var keyField,newRecordId,associatedContext,conditions,createdRecord,i,sameOriginContexts;newRecordId=result.newRecordKeyValue;keyField=currentContextCapt.key?currentContextCapt.key:INTERMediatorOnPage.defaultKeyName;associatedContext=IMLibContextPool.contextFromEnclosureId(updateNodesCapt2);completeTask();if(associatedContext){associatedContext.foreignValue=foreignValuesCapt2;if(currentContextCapt.portal===!0&&existRelatedCapt===!1){conditions=INTERMediator.additionalCondition;conditions[targetNameCapt]={field:keyField,operator:'=',value:keyValueCapt2};INTERMediator.additionalCondition=conditions}
createdRecord=[{}];createdRecord[0][keyField]=newRecordId;INTERMediator.constructMain(associatedContext,result.dbresult);sameOriginContexts=IMLibContextPool.getContextsWithSameOrigin(associatedContext);for(i=0;i<sameOriginContexts.length;i++){INTERMediator.constructMain(sameOriginContexts[i],null)}}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),function(){INTERMediatorLog.setErrorMessage('Insert Error','EXCEPTION-4');completeTask()})}}})())},clickPostOnlyButton:function(node){'use strict';var i,j,fieldData,elementInfo,comp,contextCount,selectedContext,contextInfo,validationInfo;var mergedValues,inputNodes,typeAttr,k,messageNode,result,alertmessage;var linkedNodes,namedNodes,index,hasInvalid,isMerged,contextNodes;var targetNode=node.parentNode;while(!INTERMediatorLib.isEnclosure(targetNode,!0)){targetNode=targetNode.parentNode;if(!targetNode){return}}
if(INTERMediatorOnPage.processingBeforePostOnlyContext){if(!INTERMediatorOnPage.processingBeforePostOnlyContext(targetNode)){return}}
contextNodes=[];linkedNodes=[];namedNodes=[];for(i=0;i<targetNode.childNodes.length;i++){seekLinkedElementInThisContext(targetNode.childNodes[i]);seekLinkedElementInAllChildren(targetNode.childNodes[i])}
contextCount={};for(i=0;i<contextNodes.length;i++){elementInfo=INTERMediatorLib.getLinkedElementInfo(contextNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(!contextCount[comp[j]]){contextCount[comp[j]]=0}
contextCount[comp[j]]++}}
if(contextCount.length<1){return}
var maxCount=-100;for(var contextName in contextCount){if(maxCount<contextCount[contextName]){maxCount=contextCount[contextName];selectedContext=contextName;contextInfo=INTERMediatorOnPage.getContextInfo(contextName)}}
alertmessage='';fieldData=[];hasInvalid=!1;for(i=0;i<linkedNodes.length;i++){elementInfo=INTERMediatorLib.getLinkedElementInfo(linkedNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(comp[0]===selectedContext){if(contextInfo.validation){for(index in contextInfo.validation){if(contextInfo.validation.hasOwnProperty(index)){validationInfo=contextInfo.validation[index];if(validationInfo&&validationInfo.field===comp[1]){switch(validationInfo.notify){case 'inline':case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);break}}}}
for(index in contextInfo.validation){if(contextInfo.validation.hasOwnProperty(index)){validationInfo=contextInfo.validation[index];if(validationInfo.field===comp[1]){if(validationInfo){result=Parser.evaluate(validationInfo.rule,{'value':linkedNodes[i].value,'target':linkedNodes[i]});if(!result){hasInvalid=!0;switch(validationInfo.notify){case 'inline':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);messageNode=INTERMediatorLib.createErrorMessageNode('SPAN',validationInfo.message);linkedNodes[i].parentNode.insertBefore(messageNode,linkedNodes[i].nextSibling);break;case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);messageNode=INTERMediatorLib.createErrorMessageNode('DIV',validationInfo.message);linkedNodes[i].parentNode.appendChild(messageNode);break;default:alertmessage+=validationInfo.message+IMLib.nl_char}
if(INTERMediatorOnPage.doAfterValidationFailure){INTERMediatorOnPage.doAfterValidationFailure(linkedNodes[i])}}}}}}}
if(INTERMediatorLib.isWidgetElement(linkedNodes[i])){fieldData.push({field:comp[1],value:linkedNodes[i]._im_getValue()})}else if(linkedNodes[i].tagName==='SELECT'){fieldData.push({field:comp[1],value:linkedNodes[i].value})}else if(linkedNodes[i].tagName==='TEXTAREA'){fieldData.push({field:comp[1],value:linkedNodes[i].value})}else if(linkedNodes[i].tagName==='INPUT'){if((linkedNodes[i].getAttribute('type')==='radio')||(linkedNodes[i].getAttribute('type')==='checkbox')){if(linkedNodes[i].checked){fieldData.push({field:comp[1],value:linkedNodes[i].value})}}else{fieldData.push({field:comp[1],value:linkedNodes[i].value})}}}}}
for(i=0;i<namedNodes.length;i++){elementInfo=INTERMediatorLib.getNamedInfo(namedNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(comp[0]===selectedContext){mergedValues=[];if(namedNodes[i].tagName==='INPUT'){inputNodes=[namedNodes[i]]}else{inputNodes=namedNodes[i].getElementsByTagName('INPUT')}
for(k=0;k<inputNodes.length;k++){typeAttr=inputNodes[k].getAttribute('type');if(typeAttr==='radio'||typeAttr==='checkbox'){if(inputNodes[k].checked){mergedValues.push(inputNodes[k].value)}}else{mergedValues.push(inputNodes[k].value)}}
if(mergedValues.length>0){isMerged=!1;for(index=0;index<fieldData.length;index++){if(fieldData[index].field===comp[1]){fieldData[index].value+=IMLibUI.mergedFieldSeparator;fieldData[index].value+=mergedValues.join(IMLibUI.mergedFieldSeparator);isMerged=!0}}
if(!isMerged){fieldData.push({field:comp[1],value:mergedValues.join(IMLibUI.mergedFieldSeparator)})}}}}}
if(alertmessage.length>0){window.alert(alertmessage);return}
if(hasInvalid){return}
contextInfo=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',selectedContext);if(INTERMediatorOnPage.modifyPostOnlyContext){contextInfo=INTERMediatorOnPage.modifyPostOnlyContext(contextInfo)}
INTERMediator_DBAdapter.db_createRecord_async({name:selectedContext,dataset:fieldData},function(result){var newNode,parentOfTarget,targetNode=node,thisContext=contextInfo,isSetMsg=!1;INTERMediatorLog.flushMessage();if(INTERMediatorOnPage.processingAfterPostOnlyContext){INTERMediatorOnPage.processingAfterPostOnlyContext(targetNode,result.newRecordKeyValue)}
if(thisContext['post-dismiss-message']){parentOfTarget=targetNode.parentNode;parentOfTarget.removeChild(targetNode);newNode=document.createElement('SPAN');INTERMediatorLib.setClassAttributeToNode(newNode,'IM_POSTMESSAGE');newNode.appendChild(document.createTextNode(thisContext['post-dismiss-message']));parentOfTarget.appendChild(newNode);isSetMsg=!0}
if(thisContext['post-reconstruct']){setTimeout(function(){INTERMediator.construct(!0)},isSetMsg?INTERMediator.waitSecondsAfterPostMessage*1000:0)}
if(thisContext['post-move-url']){setTimeout(function(){location.href=thisContext['post-move-url']},isSetMsg?INTERMediator.waitSecondsAfterPostMessage*1000:0)}},null);function seekLinkedElementInThisContext(node){var children,i;if(node.nodeType===1){if(INTERMediatorLib.isLinkedElement(node)){contextNodes.push(node)}else if(INTERMediatorLib.isWidgetElement(node)){contextNodes.push(node)}else{if(INTERMediatorLib.isEnclosure(node)){return}
children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElementInThisContext(children[i])}}}}
function seekLinkedElementInAllChildren(node){var children,i;if(node.nodeType===1){if(INTERMediatorLib.isNamedElement(node)){namedNodes.push(node)}else if(INTERMediatorLib.isLinkedElement(node)){linkedNodes.push(node)}else if(INTERMediatorLib.isWidgetElement(node)){linkedNodes.push(node)}else{children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElementInAllChildren(children[i])}}}}},eventUpdateHandler:function(contextName){'use strict';IMLibLocalContext.updateAll();var context=IMLibContextPool.getContextFromName(contextName);INTERMediator.constructMain(context[0])},eventAddOrderHandler:function(e){'use strict';var targetKey,targetSplit,key,itemSplit,extValue;if(e.target){targetKey=e.target.getAttribute('data-im')}else{targetKey=e.srcElement.getAttribute('data-im')}
targetSplit=targetKey.split(':');if(targetSplit[0]!=='_@addorder'||targetSplit.length<3){return}
for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){itemSplit=key.split(':');if(itemSplit.length>3&&itemSplit[0]==='valueofaddorder'&&itemSplit[1]===targetSplit[1]){extValue=IMLibLocalContext.getValue(key);if(extValue){IMLibLocalContext.store[key]++}}}}
IMLibLocalContext.setValue('valueof'+targetKey.substring(2),1);IMLibUI.eventUpdateHandler(targetSplit[1])}};var INTERMediatorLog={debugMode:!1,suppressDebugMessageOnPage:!1,suppressErrorMessageOnPage:!1,errorMessages:[],debugMessages:[],errorMessageByAlert:!1,errorMessageOnAlert:null,setDebugMessage:function(message,level){'use strict';if(level===undefined){level=1}
if(INTERMediatorLog.debugMode>=level){INTERMediatorLog.debugMessages.push(message);if(typeof console!=='undefined'){console.log('INTER-Mediator[DEBUG:%s]: %s',new Date(),message)}}},setErrorMessage:function(ex,moreMessage){'use strict';moreMessage=moreMessage===undefined?'':(' - '+moreMessage);if(INTERMediatorLog.errorMessageByAlert){window.alert(INTERMediatorLog.errorMessageOnAlert===null?(ex+moreMessage):INTERMediatorLog.errorMessageOnAlert)}
if((typeof ex==='string'||ex instanceof String)){INTERMediatorLog.errorMessages.push(ex+moreMessage);if(typeof console!=='undefined'){console.error('INTER-Mediator[ERROR]: %s',ex+moreMessage)}}else{if(ex.message){INTERMediatorLog.errorMessages.push(ex.message+moreMessage);if(typeof console!=='undefined'){console.error('INTER-Mediator[ERROR]: %s',ex.message+moreMessage)}}
if(ex.stack&&typeof console!=='undefined'){console.error(ex.stack)}}},flushMessage:function(){'use strict';var debugNode,title,body,i,j,lines,clearButton,tNode;if(INTERMediatorLog.errorMessageByAlert){INTERMediatorLog.suppressErrorMessageOnPage=!0}
if(!INTERMediatorLog.suppressErrorMessageOnPage&&INTERMediatorLog.errorMessages.length>0){debugNode=document.getElementById('_im_error_panel_4873643897897');if(debugNode===null){debugNode=document.createElement('div');debugNode.setAttribute('id','_im_error_panel_4873643897897');debugNode.style.backgroundColor='#FFDDDD';title=document.createElement('h3');title.appendChild(document.createTextNode('Error Info from INTER-Mediator'));title.appendChild(document.createElement('hr'));debugNode.appendChild(title);body=document.getElementsByTagName('body')[0];body.insertBefore(debugNode,body.firstChild)}
debugNode.appendChild(document.createTextNode('============ERROR MESSAGE on '+new Date()+'============'));debugNode.appendChild(document.createElement('hr'));for(i=0;i<INTERMediatorLog.errorMessages.length;i++){lines=INTERMediatorLog.errorMessages[i].split(IMLib.nl_char);for(j=0;j<lines.length;j++){if(j>0){debugNode.appendChild(document.createElement('br'))}
debugNode.appendChild(document.createTextNode(lines[j]))}
debugNode.appendChild(document.createElement('hr'))}}
if(!INTERMediatorLog.suppressDebugMessageOnPage&&INTERMediatorLog.debugMode&&INTERMediatorLog.debugMessages.length>0){debugNode=document.getElementById('_im_debug_panel_4873643897897');if(debugNode===null){debugNode=document.createElement('div');debugNode.setAttribute('id','_im_debug_panel_4873643897897');debugNode.style.backgroundColor='#DDDDDD';clearButton=document.createElement('button');clearButton.setAttribute('title','clear');clearButton.id='_im_debug_panel_4873643897897_button';IMLibMouseEventDispatch.setExecute(clearButton.id,function(){var target;target=document.getElementById('_im_debug_panel_4873643897897');target.parentNode.removeChild(target)});tNode=document.createTextNode('clear');clearButton.appendChild(tNode);title=document.createElement('h3');title.appendChild(document.createTextNode('Debug Info from INTER-Mediator'));title.appendChild(clearButton);title.appendChild(document.createElement('hr'));debugNode.appendChild(title);body=document.getElementsByTagName('body')[0];if(body){if(body.firstChild){body.insertBefore(debugNode,body.firstChild)}else{body.appendChild(debugNode)}}}
debugNode.appendChild(document.createTextNode('============DEBUG INFO on '+new Date()+'============ '));if(INTERMediatorOnPage.getEditorPath()){var aLink=document.createElement('a');aLink.setAttribute('href',INTERMediatorOnPage.getEditorPath());aLink.appendChild(document.createTextNode('Definition File Editor'));debugNode.appendChild(aLink)}
debugNode.appendChild(document.createElement('hr'));for(i=0;i<INTERMediatorLog.debugMessages.length;i++){lines=INTERMediatorLog.debugMessages[i].split(IMLib.nl_char);for(j=0;j<lines.length;j++){if(j>0){debugNode.appendChild(document.createElement('br'))}
debugNode.appendChild(document.createTextNode(lines[j]))}
debugNode.appendChild(document.createElement('hr'))}}
INTERMediatorLog.errorMessages=[];INTERMediatorLog.debugMessages=[]}};var INTERMediator_DBAdapter={eliminateDuplicatedConditions:!1,debugMessage:!1,generate_authParams:function(){'use strict';var authParams='',shaObj,hmacValue,encrypted;var encrypt=new JSEncrypt();if(INTERMediatorOnPage.authUser.length>0){authParams='&clientid='+encodeURIComponent(INTERMediatorOnPage.clientId);authParams+='&authuser='+encodeURIComponent(INTERMediatorOnPage.authUser);if(INTERMediatorOnPage.isNativeAuth||INTERMediatorOnPage.isLDAP){if(INTERMediatorOnPage.authCryptedPassword&&INTERMediatorOnPage.authChallenge){encrypt.setPublicKey(INTERMediatorOnPage.publickey);encrypted=encrypt.encrypt(INTERMediatorOnPage.authCryptedPassword.substr(0,220)+IMLib.nl_char+INTERMediatorOnPage.authChallenge);authParams+='&cresponse='+encodeURIComponent(encrypted+IMLib.nl_char+INTERMediatorOnPage.authCryptedPassword.substr(220));if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('generate_authParams/authCryptedPassword='+INTERMediatorOnPage.authCryptedPassword);INTERMediatorLog.setDebugMessage('generate_authParams/authChallenge='+INTERMediatorOnPage.authChallenge)}}else{authParams+='&cresponse=dummy'}}
if(INTERMediatorOnPage.authHashedPassword&&INTERMediatorOnPage.authChallenge){shaObj=new jsSHA(INTERMediatorOnPage.authHashedPassword,'ASCII');hmacValue=shaObj.getHMAC(INTERMediatorOnPage.authChallenge,'ASCII','SHA-256','HEX');authParams+='&response='+encodeURIComponent(hmacValue);if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('generate_authParams/authHashedPassword='+INTERMediatorOnPage.authHashedPassword);INTERMediatorLog.setDebugMessage('generate_authParams/authChallenge='+INTERMediatorOnPage.authChallenge)}}else{authParams+='&response=dummy'}}
authParams+='&notifyid=';authParams+=encodeURIComponent(INTERMediatorOnPage.clientNotificationIdentifier());authParams+=('&pusher='+(INTERMediator.pusherAvailable?'yes':''));return authParams},store_challenge:function(challenge){'use strict';if(challenge!==null){INTERMediatorOnPage.authChallenge=challenge.substr(0,24);INTERMediatorOnPage.authUserHexSalt=challenge.substr(24,32);INTERMediatorOnPage.authUserSalt=String.fromCharCode(parseInt(challenge.substr(24,2),16),parseInt(challenge.substr(26,2),16),parseInt(challenge.substr(28,2),16),parseInt(challenge.substr(30,2),16));if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('store_challenge/authChallenge='+INTERMediatorOnPage.authChallenge);INTERMediatorLog.setDebugMessage('store_challenge/authUserHexSalt='+INTERMediatorOnPage.authUserHexSalt);INTERMediatorLog.setDebugMessage('store_challenge/authUserSalt='+INTERMediatorOnPage.authUserSalt)}}},logging_comAction:function(debugMessageNumber,appPath,accessURL,authParams){'use strict';INTERMediatorLog.setDebugMessage(INTERMediatorOnPage.getMessages()[debugMessageNumber]+'Accessing:'+decodeURI(appPath)+', Parameters:'+decodeURI(accessURL+authParams))},logging_comResult:function(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken){'use strict';var responseTextTrancated;if(INTERMediatorLog.debugMode>1){if(myRequest.responseText.length>1000){responseTextTrancated=myRequest.responseText.substr(0,1000)+' ...[trancated]'}else{responseTextTrancated=myRequest.responseText}
INTERMediatorLog.setDebugMessage('myRequest.responseText='+responseTextTrancated);INTERMediatorLog.setDebugMessage('Return: resultCount='+resultCount+', dbresult='+INTERMediatorLib.objectToString(dbresult)+IMLib.nl_char+'Return: requireAuth='+requireAuth+', challenge='+challenge+', clientid='+clientid+IMLib.nl_char+'Return: newRecordKeyValue='+newRecordKeyValue+', changePasswordResult='+changePasswordResult+', mediatoken='+mediatoken)}},server_access:function(accessURL,debugMessageNumber,errorMessageNumber){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,totalCount=null,challenge=null,clientid=null,requireAuth=!1,myRequest=null,changePasswordResult=null,mediatoken=null,appPath,authParams,jsonObject,i,notifySupport=!1,useNull=!1,registeredID='';appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();INTERMediator_DBAdapter.logging_comAction(debugMessageNumber,appPath,accessURL,authParams);INTERMediatorOnPage.notifySupport=notifySupport;try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!1,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');myRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');myRequest.setRequestHeader('X-Requested-With','XMLHttpRequest');myRequest.setRequestHeader('X-From',location.href);myRequest.send(accessURL+authParams);jsonObject=JSON.parse(myRequest.responseText);resultCount=jsonObject.resultCount?jsonObject.resultCount:0;totalCount=jsonObject.totalCount?jsonObject.totalCount:null;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;notifySupport=jsonObject.notifySupport;for(i=0;i<jsonObject.errorMessages.length;i++){INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
useNull=jsonObject.usenull;registeredID=jsonObject.hasOwnProperty('registeredid')?jsonObject.registeredid:'';INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(INTERMediatorOnPage.isLDAP===!0&&INTERMediatorOnPage.authUserHexSalt!==INTERMediatorOnPage.authHashedPassword.substr(-8,8)){if(accessURL!=='access=challenge'){requireAuth=!0}}}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorMessageNumber],[e,myRequest.responseText]))}
if(accessURL.indexOf('access=changepassword&newpass=')===0){return changePasswordResult}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();throw new Error('_im_requath_request_')}
if(!accessURL.match(/access=challenge/)){INTERMediatorOnPage.authCount=0}
INTERMediatorOnPage.storeCredentialsToCookieOrStorage();INTERMediatorOnPage.notifySupport=notifySupport;return{dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull}},server_access_async:function(accessURL,debugMessageNumber,errorMessageNumber,successProc,failedProc,authAgainProc){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,totalCount=null,challenge=null,clientid=null,requireAuth=!1,myRequest=null,changePasswordResult=null,mediatoken=null,appPath,authParams,jsonObject,i,notifySupport=!1,useNull=!1,registeredID='';appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();INTERMediator_DBAdapter.logging_comAction(debugMessageNumber,appPath,accessURL,authParams);INTERMediatorOnPage.notifySupport=notifySupport;try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!0,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');myRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');myRequest.setRequestHeader('X-Requested-With','XMLHttpRequest');myRequest.setRequestHeader('X-From',location.href);myRequest.onreadystatechange=function(){switch(myRequest.readyState){case 0:break;case 1:break;case 2:break;case 3:break;case 4:try{jsonObject=JSON.parse(myRequest.responseText)}catch(ex){INTERMediatorLog.setErrorMessage('Communication Error: '+myRequest.responseText);if(failedProc){failedProc(new Error('_im_communication_error_'))}
return}
resultCount=jsonObject.resultCount?jsonObject.resultCount:0;totalCount=jsonObject.totalCount?jsonObject.totalCount:null;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;notifySupport=jsonObject.notifySupport;for(i=0;i<jsonObject.errorMessages.length;i++){INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
useNull=jsonObject.usenull;registeredID=jsonObject.hasOwnProperty('registeredid')?jsonObject.registeredid:'';if(jsonObject.errorMessages.length>0){INTERMediatorLog.setErrorMessage('Communication Error: '+jsonObject.errorMessages);if(failedProc){failedProc()}
throw 'Communication Error'}
INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(INTERMediatorOnPage.isLDAP===!0&&INTERMediatorOnPage.authUserHexSalt!==INTERMediatorOnPage.authHashedPassword.substr(-8,8)){if(accessURL!=='access=challenge'){requireAuth=!0}}
if(accessURL.indexOf('access=changepassword&newpass=')===0){if(successProc){successProc({dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull})}
return}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();if(authAgainProc){authAgainProc(myRequest)}
return}
if(!accessURL.match(/access=challenge/)){INTERMediatorOnPage.authCount=0}
INTERMediatorOnPage.storeCredentialsToCookieOrStorage();INTERMediatorOnPage.notifySupport=notifySupport;if(successProc){successProc({dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull})}
break}};myRequest.send(accessURL+authParams)}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorMessageNumber],[e,myRequest.responseText]));if(failedProc){failedProc()}}},changePassword:function(username,oldpassword,newpassword){'use strict';var challengeResult,params,result,messageNode;var encrypt=new JSEncrypt();if(username&&oldpassword){INTERMediatorOnPage.authUser=username;if(username!==''&&(INTERMediatorOnPage.authChallenge===null||INTERMediatorOnPage.authChallenge.length<24)){INTERMediatorOnPage.authHashedPassword='need-hash-pls';challengeResult=INTERMediator_DBAdapter.getChallenge();if(!challengeResult){messageNode=document.getElementById('_im_newpass_message');if(messageNode){INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2008)))}else{window.alert(INTERMediatorLib.getInsertedStringFromErrorNumber(2008))}
INTERMediatorLog.flushMessage();return}}
INTERMediatorOnPage.authHashedPassword=SHA1(oldpassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt}else{INTERMediatorOnPage.retrieveAuthInfo()}
params='access=changepassword&newpass='+INTERMediatorLib.generatePasswordHash(newpassword);try{result=INTERMediator_DBAdapter.server_access(params,1029,1030);if(result){encrypt.setPublicKey(INTERMediatorOnPage.publickey);INTERMediatorOnPage.authCryptedPassword=encrypt.encrypt(newpassword);INTERMediatorOnPage.authHashedPassword=SHA1(newpassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt;INTERMediatorOnPage.storeCredentialsToCookieOrStorage()}}catch(e){return!1}
return result},getChallenge:function(){'use strict';try{this.server_access('access=challenge',1027,1028)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-19')}}
if(INTERMediatorOnPage.authChallenge===null){return!1}
return!0},uploadFile:function(parameters,uploadingFile,doItOnFinish,exceptionProc){'use strict';var myRequest=null,appPath,authParams,accessURL,i;appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();accessURL='access=uploadfile'+parameters;INTERMediator_DBAdapter.logging_comAction(1031,appPath,accessURL,authParams);try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!0,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');var params=(accessURL+authParams).split('&');var fd=new FormData();for(i=0;i<params.length;i++){var valueset=params[i].split('=');fd.append(valueset[0],decodeURIComponent(valueset[1]))}
fd.append('_im_uploadfile',uploadingFile.content);myRequest.onreadystatechange=function(){switch(myRequest.readyState){case 3:break;case 4:INTERMediator_DBAdapter.uploadFileAfterSucceed(myRequest,doItOnFinish,exceptionProc,!1);break}};myRequest.send(fd)}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1032],[e,myRequest.responseText]));exceptionProc()}},uploadFileAfterSucceed:function(myRequest,doItOnFinish,exceptionProc,isErrorDialog){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,challenge=null,clientid=null,requireAuth=!1,changePasswordResult=null,mediatoken=null,jsonObject,i,returnValue=!0;try{jsonObject=JSON.parse(myRequest.responseText)}catch(ex){INTERMediatorLog.setErrorMessage(ex,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1032],['','']));INTERMediatorLog.flushMessage();exceptionProc();return!1}
resultCount=jsonObject.resultCount?jsonObject.resultCount:0;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;for(i=0;i<jsonObject.errorMessages.length;i++){if(isErrorDialog){window.alert(jsonObject.errorMessages[i])}else{INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
returnValue=!1}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();exceptionProc()}
INTERMediatorOnPage.authCount=0;INTERMediatorOnPage.storeCredentialsToCookieOrStorage();doItOnFinish(dbresult);return returnValue},db_query:function(args){'use strict';var params,returnValue,result,contextDef;if(!INTERMediator_DBAdapter.db_queryChecking(args)){return}
params=INTERMediator_DBAdapter.db_queryParameters(args);returnValue={};try{result=this.server_access(params,1012,1004);returnValue.recordset=result.dbresult;returnValue.totalCount=result.resultCount;returnValue.count=0;returnValue.registeredId=result.registeredId;returnValue.nullAcceptable=result.nullAcceptable;returnValue.count=result.dbresult?Object.keys(result.dbresult).length:0;contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',args.name);if(!contextDef.relation&&args.paging&&Boolean(args.paging)===!0){INTERMediator.pagedAllCount=parseInt(result.resultCount,10);if(result.totalCount){INTERMediator.totalRecordCount=parseInt(result.totalCount,10)}}
if((args.paging!==null)&&(Boolean(args.paging)===!0)){INTERMediator.pagination=!0;if(!(Number(args.records)>=Number(INTERMediator.pagedSize)&&Number(INTERMediator.pagedSize)>0)){INTERMediator.pagedSize=parseInt(args.records,10)}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-17')}
returnValue.recordset=null;returnValue.totalCount=0;returnValue.count=0;returnValue.registeredid=null;returnValue.nullAcceptable=null}
return returnValue},db_queryWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_query(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_queryWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-16')}}
completion(returnValue)},db_query_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_queryChecking(args)){return}
params=INTERMediator_DBAdapter.db_queryParameters(args);try{this.server_access_async(params,1012,1004,(function(){var contextDef;var contextName=args.name;var recordsNumber=Number(args.records);var succesProcCapt=successProc;return function(result){result.count=result.dbresult?Object.keys(result.dbresult).length:0;contextDef=IMLibContextPool.getContextDef(contextName);if(!contextDef.relation&&args.paging&&Boolean(args.paging)===!0){INTERMediator.pagedAllCount=parseInt(result.resultCount,10);if(result.totalCount){INTERMediator.totalRecordCount=parseInt(result.totalCount,10)}}
if((args.paging!==null)&&(Boolean(args.paging)===!0)){INTERMediator.pagination=!0;if(!(recordsNumber>=Number(INTERMediator.pagedSize)&&Number(INTERMediator.pagedSize)>0)){INTERMediator.pagedSize=parseInt(recordsNumber,10)}}
succesProcCapt(result)}})(),failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_query_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-17')}},db_queryChecking:function(args){'use strict';var noError=!0;if(args.name===null||args.name===''){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1005));noError=!1}
return noError},db_queryParameters:function(args){'use strict';var i,index,params,counter,extCount,criteriaObject,sortkeyObject,extCountSort,recordLimit=10000000,conditions,conditionSign,modifyConditions,orderFields,key,keyParams,value,fields,operator,orderedKeys,removeIndice=[];if(args.records===null){params='access=read&name='+encodeURIComponent(args.name)}else{if(parseInt(args.records,10)===0&&(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI')){params='access=describe&name='+encodeURIComponent(args.name)}else{params='access=read&name='+encodeURIComponent(args.name)}
if(Boolean(args.uselimit)===!0&&parseInt(args.records,10)>=INTERMediator.pagedSize&&parseInt(INTERMediator.pagedSize,10)>0){recordLimit=INTERMediator.pagedSize}else{recordLimit=args.records}}
if(args.primaryKeyOnly){params+='&pkeyonly=true'}
if(args.fields){for(i=0;i<args.fields.length;i++){params+='&field_'+i+'='+encodeURIComponent(args.fields[i])}}
counter=0;if(args.parentkeyvalue){for(index in args.parentkeyvalue){if(args.parentkeyvalue.hasOwnProperty(index)){params+='&foreign'+counter+'field='+encodeURIComponent(index);params+='&foreign'+counter+'value='+encodeURIComponent(args.parentkeyvalue[index]);counter++}}}
if(args.useoffset&&INTERMediator.startFrom!==null){params+='&start='+encodeURIComponent(INTERMediator.startFrom)}
extCount=0;conditions=[];while(args.conditions&&args.conditions[extCount]){conditionSign=args.conditions[extCount].field+'#'+args.conditions[extCount].operator+'#'+args.conditions[extCount].value;if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount;params+='field='+encodeURIComponent(args.conditions[extCount].field);params+='&condition'+extCount;params+='operator='+encodeURIComponent(args.conditions[extCount].operator);params+='&condition'+extCount;params+='value='+encodeURIComponent(args.conditions[extCount].value);conditions.push(conditionSign)}
extCount++}
criteriaObject=INTERMediator.additionalCondition[args.name];if(criteriaObject){if(criteriaObject.field){criteriaObject=[criteriaObject]}
for(index=0;index<criteriaObject.length;index++){if(criteriaObject[index]&&criteriaObject[index].field){if(criteriaObject[index].value||criteriaObject[index].field==='__operation__'){conditionSign=criteriaObject[index].field+'#'+((criteriaObject[index].operator!==undefined)?criteriaObject[index].operator:'')+'#'+((criteriaObject[index].value!==undefined)?criteriaObject[index].value:'');if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount;params+='field='+encodeURIComponent(criteriaObject[index].field);if(criteriaObject[index].operator!==undefined){params+='&condition'+extCount;params+='operator='+encodeURIComponent(criteriaObject[index].operator)}
if(criteriaObject[index].value!==undefined){params+='&condition'+extCount;value=criteriaObject[index].value;if(Array.isArray(value)){value=JSON.stringify(value)}
params+='value='+encodeURIComponent(value)}
if(criteriaObject[index].field!=='__operation__'){conditions.push(conditionSign)}}
extCount++}}
if(criteriaObject[index]&&criteriaObject[index].onetime){removeIndice.push=index}}
if(removeIndice.length>0){modifyConditions=[];for(index=0;index<criteriaObject.length;index++){if(!(index in removeIndice)){modifyConditions.push(criteriaObject[index])}}
INTERMediator.additionalCondition[args.name]=modifyConditions;IMLibLocalContext.archive()}}
extCountSort=0;sortkeyObject=INTERMediator.additionalSortKey[args.name];if(sortkeyObject){if(sortkeyObject.field){sortkeyObject=[sortkeyObject]}
for(index=0;index<sortkeyObject.length;index++){params+='&sortkey'+extCountSort;params+='field='+encodeURIComponent(sortkeyObject[index].field);params+='&sortkey'+extCountSort;params+='direction='+encodeURIComponent(sortkeyObject[index].direction);extCountSort++}}
orderFields={};for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){value=String(IMLibLocalContext.store[key]);keyParams=key.split(':');if(keyParams&&keyParams.length>1&&keyParams[1].trim()===args.name&&value.length>0){if(keyParams[0].trim()==='condition'&&keyParams.length>=4){fields=keyParams[2].split(',');operator=keyParams[3].trim();if(fields.length>1){params+='&condition'+extCount+'field=__operation__';params+='&condition'+extCount+'operator=ex';extCount++}
for(index=0;index<fields.length;index++){conditionSign=fields[index].trim()+'#'+operator+'#'+value;if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount+'field='+encodeURIComponent(fields[index].replace(';;','::').trim());params+='&condition'+extCount+'operator='+encodeURIComponent(operator);params+='&condition'+extCount+'value='+encodeURIComponent(value);conditions.push(conditionSign)}
extCount++}}else if(keyParams[0].trim()==='valueofaddorder'&&keyParams.length>=4){orderFields[parseInt(value)]=[keyParams[2].trim(),keyParams[3].trim()]}}}}
params+='&records='+encodeURIComponent(recordLimit);orderedKeys=Object.keys(orderFields);for(i=0;i<orderedKeys.length;i++){params+='&sortkey'+extCountSort+'field='+encodeURIComponent(orderFields[orderedKeys[i]][0]);params+='&sortkey'+extCountSort+'direction='+encodeURIComponent(orderFields[orderedKeys[i]][1]);extCountSort++}
return params},db_update:function(args){'use strict';var params,result;if(!INTERMediator_DBAdapter.db_updateChecking(args)){return}
params=INTERMediator_DBAdapter.db_updateParameters(args);result=this.server_access(params,1013,1014);return result.dbresult},db_updateWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_update(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_updateWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-15')}}
completion(returnValue)},db_updateChecking:function(args){'use strict';var noError=!0,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1007));noError=!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));noError=!1}
if(args.dataset===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1011));noError=!1}
return noError},db_updateParameters:function(args){'use strict';var params,extCount,counter,index,addedObject;params='access=update&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnUpdate&&INTERMediator.additionalFieldValueOnUpdate[args.name]){addedObject=INTERMediator.additionalFieldValueOnUpdate[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
if(args.conditions){for(extCount=0;extCount<args.conditions.length;extCount++){params+='&condition'+extCount+'field=';params+=encodeURIComponent(args.conditions[extCount].field);params+='&condition'+extCount+'operator=';params+=encodeURIComponent(args.conditions[extCount].operator);if(args.conditions[extCount].value){params+='&condition'+extCount+'value=';params+=encodeURIComponent(args.conditions[extCount].value)}}}
for(extCount=0;extCount<args.dataset.length;extCount++){params+='&field_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].field);if(INTERMediator.isTrident&&INTERMediator.ieVersion===8){params+='&value_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].value.replace(/\n/g,''))}else{params+='&value_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].value)}}
return params},db_update_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_updateChecking(args)){return}
params=INTERMediator_DBAdapter.db_updateParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1013,1014,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_update_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_delete:function(args){'use strict';var params,result;if(!INTERMediator_DBAdapter.db_deleteChecking(args)){return}
params=INTERMediator_DBAdapter.db_deleteParameters(args);result=this.server_access(params,1017,1015);INTERMediatorLog.flushMessage();return result},db_deleteWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_delete(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_deleteWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-14')}}
completion(returnValue)},db_deleteChecking:function(args){'use strict';var noError=!0,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1019));noError=!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));noError=!1}
if(args.conditions===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1020));noError=!1}
return noError},db_deleteParameters:function(args){'use strict';var params,i,counter,index,addedObject;params='access=delete&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnDelete&&INTERMediator.additionalFieldValueOnDelete[args.name]){addedObject=INTERMediator.additionalFieldValueOnDelete[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
for(i=0;i<args.conditions.length;i++){params+='&condition'+i+'field='+encodeURIComponent(args.conditions[i].field);params+='&condition'+i+'operator='+encodeURIComponent(args.conditions[i].operator);params+='&condition'+i+'value='+encodeURIComponent(args.conditions[i].value)}
return params},db_delete_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_deleteChecking(args)){return}
params=INTERMediator_DBAdapter.db_deleteParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1017,1015,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_delete_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_createRecord:function(args){'use strict';var params,result;params=INTERMediator_DBAdapter.db_createParameters(args);if(params){result=INTERMediator_DBAdapter.server_access(params,1018,1016);INTERMediatorLog.flushMessage();return{newKeyValue:result.newRecordKeyValue,recordset:result.dbresult}}
return!1},db_createRecordWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_createRecord(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_createRecordWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-13')}}
if(completion){completion(returnValue.newKeyValue)}},db_createRecord_async:function(args,successProc,failedProc){'use strict';var params=INTERMediator_DBAdapter.db_createParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1018,1016,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_createRecord_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_createParameters:function(args){'use strict';var params,i,index,addedObject,counter,targetKey,ds,key,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1021));return!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));return!1}
ds=INTERMediatorOnPage.getDataSources();targetKey=null;for(key in ds){if(ds.hasOwnProperty(key)&&ds[key].name===args.name){targetKey=key;break}}
if(targetKey===null){INTERMediatorLog.setErrorMessage('no targetname :'+args.name);return!1}
params='access=create&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnNewRecord&&INTERMediator.additionalFieldValueOnNewRecord[args.name]){addedObject=INTERMediator.additionalFieldValueOnNewRecord[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
for(i=0;i<args.dataset.length;i++){params+='&field_'+counter+'='+encodeURIComponent(args.dataset[i].field);params+='&value_'+counter+'='+encodeURIComponent(args.dataset[i].value);counter++}
return params},db_copy:function(args){'use strict';var params,result;params=INTERMediator_DBAdapter.db_copyParameters(args);if(params){result=INTERMediator_DBAdapter.server_access(params,1017,1015);INTERMediatorLog.flushMessage();return{newKeyValue:result.newRecordKeyValue,recordset:result.dbresult}}
return!1},db_copyWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_copy(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_copyWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-14')}}
completion(returnValue)},db_copy_async:function(args,successProc,failedProc){'use strict';var params=INTERMediator_DBAdapter.db_copyParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1017,1015,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_copy_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_copyParameters:function(args){'use strict';var noError=!0,params,i;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1019));noError=!1}
if(args.conditions===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1020));noError=!1}
if(!noError){return!1}
params='access=copy&name='+encodeURIComponent(args.name);for(i=0;i<args.conditions.length;i++){params+='&condition'+i+'field='+encodeURIComponent(args.conditions[i].field);params+='&condition'+i+'operator='+encodeURIComponent(args.conditions[i].operator);params+='&condition'+i+'value='+encodeURIComponent(args.conditions[i].value)}
if(args.associated){for(i=0;i<args.associated.length;i++){params+='&assoc'+i+'='+encodeURIComponent(args.associated[i].name);params+='&asfield'+i+'='+encodeURIComponent(args.associated[i].field);params+='&asvalue'+i+'='+encodeURIComponent(args.associated[i].value)}}
return params},createExceptionFunc:function(errMessageNumber,AuthProc){'use strict';var errorNumCapt=errMessageNumber;return function(myRequest){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(AuthProc)}}else{INTERMediatorLog.setErrorMessage('Communication Error',INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorNumCapt],['Communication Error',myRequest.responseText]))}}},unregister:function(entityPkInfo){'use strict';var result=null,params;if(INTERMediatorOnPage.clientNotificationKey){var appKey=INTERMediatorOnPage.clientNotificationKey();if(appKey&&appKey!=='_im_key_isnt_supplied'){params='access=unregister';if(entityPkInfo){params+='&pks='+encodeURIComponent(JSON.stringify(entityPkInfo))}
result=this.server_access(params,1018,1016);return result}}}};var IMLibQueue={tasks:[],isExecute:!1,dataStore:{},dsLabel:0,readyTo:!1,getNewLabel:function(){'use strict';IMLibQueue.dsLabel++;return IMLibQueue.dsLabel},getDataStore:function(label,key){'use strict';if(!IMLibQueue.dataStore[label]){IMLibQueue.dataStore[label]={}}
return IMLibQueue.dataStore[label][key]},setDataStore:function(label,key,value){'use strict';if(!IMLibQueue.dataStore[label]){IMLibQueue.dataStore[label]={}}
IMLibQueue.dataStore[label][key]=value},setTask:function(aTask,startHere){'use strict';if(startHere){IMLibQueue.isExecute=!0;aTask(function(){});IMLibQueue.isExecute=!1}else{IMLibQueue.tasks.push(aTask);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}}},setPriorTask:function(aTask){'use strict';IMLibQueue.tasks.unshift(aTask);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},setSequentialTasks:function(tasksArray){'use strict';Array.prototype.push.apply(IMLibQueue.tasks,tasksArray);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},setSequentialPriorTasks:function(tasksArray){'use strict';Array.prototype.push.apply(tasksArray,IMLibQueue.tasks);IMLibQueue.tasks=tasksArray;if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},startNextTask:function(){'use strict';if(IMLibQueue.isExecute){if(IMLibQueue.tasks.length>0){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}
return}
if(IMLibQueue.tasks.length>0){var aTask=IMLibQueue.tasks.shift();IMLibQueue.isExecute=!0;IMLibQueue.readyTo=!1;aTask(function(){IMLibQueue.isExecute=!1;if(IMLibQueue.tasks.length>0){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}})}}};var IMLibChangeEventDispatch;var IMLibKeyDownEventDispatch;var IMLibKeyUpEventDispatch;var IMLibInputEventDispatch;var IMLibMouseEventDispatch;var IMLibBlurEventDispatch;function IMLibEventDispatch(){'use strict';this.dispatchTable={};this.dispatchTableTarget={}}
IMLibEventDispatch.prototype.clearAll=function(){'use strict';this.dispatchTable={};this.dispatchTableTarget={}};IMLibEventDispatch.prototype.setExecute=function(idValue,exec){'use strict';if(idValue&&exec){this.dispatchTable[idValue]=exec}};IMLibEventDispatch.prototype.setTargetExecute=function(targetValue,exec){'use strict';if(targetValue&&exec){this.dispatchTableTarget[targetValue]=exec}};IMLibEventDispatch.prototype.setExecuteByCode=function(idValue,keyCode,exec){'use strict';if(idValue&&keyCode){if(!this.dispatchTable[idValue]){this.dispatchTable[idValue]={}}
this.dispatchTable[idValue][keyCode]=exec}};var IMLibEventResponder={touchEventCancel:!1,isSetup:!1,setup:function(){'use strict';var body;if(IMLibEventResponder.isSetup){return}
IMLibEventResponder.isSetup=!0;IMLibChangeEventDispatch=new IMLibEventDispatch();IMLibKeyDownEventDispatch=new IMLibEventDispatch();IMLibKeyUpEventDispatch=new IMLibEventDispatch();IMLibMouseEventDispatch=new IMLibEventDispatch();IMLibBlurEventDispatch=new IMLibEventDispatch();IMLibInputEventDispatch=new IMLibEventDispatch();body=document.getElementsByTagName('BODY')[0];INTERMediatorLib.addEvent(body,'change',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibChangeEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'blur',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibBlurEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'input',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibInputEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'keydown',function(e){var event,target,idValue,keyCode;event=e?e:window.event;if(!event){return}
keyCode=(window.event)?e.which:e.keyCode;target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
if(!IMLibKeyDownEventDispatch.dispatchTable[idValue]){return}
var executable=IMLibKeyDownEventDispatch.dispatchTable[idValue][keyCode];if(!executable){return}
executable(event)});INTERMediatorLib.addEvent(body,'keyup',function(e){var event,charCode,target,idValue;event=e?e:window.event;if(event.charCode){charCode=event.charCode}else{charCode=event.keyCode}
if(!event){return}
target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
if(!IMLibKeyUpEventDispatch.dispatchTable[idValue]){return}
var executable=IMLibKeyUpEventDispatch.dispatchTable[idValue][charCode];if(!executable){return}
executable(event)});INTERMediatorLib.addEvent(body,'click',function(e){var event,target,idValue,executable,targetDefs,i,nodeInfo,value;event=e?e:window.event;if(!event){return}
target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
executable=IMLibMouseEventDispatch.dispatchTable[idValue];if(executable){executable(event);return}
targetDefs=INTERMediatorLib.getLinkedElementInfo(target);for(i=0;i<targetDefs.length;i++){executable=IMLibMouseEventDispatch.dispatchTableTarget[targetDefs[i]];if(executable){nodeInfo=INTERMediatorLib.getNodeInfoArray(targetDefs[i]);if(nodeInfo.target){value=target.getAttribute(nodeInfo.target)}else{value=IMLibElement.getValueFromIMNode(target)}
executable(value,target);return}}})}};INTERMediator.propertyIETridentSetup();INTERMediator.propertyW3CUserAgentSetup();if(INTERMediator.isIE&&INTERMediator.ieVersion<9){INTERMediator.startFrom=0;INTERMediator.pagedSize=0;INTERMediator.pagination=!1;INTERMediator.additionalCondition={};INTERMediator.additionalSortKey={};INTERMediator.recordLimit={};IMLibCalc.regexpForSeparator=INTERMediator.separator}else{Object.defineProperty(INTERMediator,'startFrom',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_startFrom',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_startFrom',value)}});Object.defineProperty(INTERMediator,'pagedSize',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_pagedSize',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_pagedSize',value)}});Object.defineProperty(INTERMediator,'pagination',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_pagination',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_pagination',value)}});Object.defineProperty(INTERMediator,'additionalCondition',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_additionalCondition',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_additionalCondition',value)}});Object.defineProperty(INTERMediator,'additionalSortKey',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_additionalSortKey',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_additionalSortKey',value)}});Object.defineProperty(INTERMediator,'recordLimit',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_recordLimit',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_recordLimit',value)}});Object.defineProperty(IMLibCalc,'regexpForSeparator',{get:function(){'use strict';if(INTERMediator){return new RegExp(INTERMediator.separator)}
return new RegExp('@')}})}
if(!INTERMediator.additionalCondition){INTERMediator.additionalCondition={}}
if(!INTERMediator.additionalSortKey){INTERMediator.additionalSortKey={}}
INTERMediatorLib.addEvent(window,'beforeunload',function(){if(IMLibQueue.tasks.length>0){var confirmationMessage='Some tasks are unfinished.';var ev=(e||window.event);ev.returnValue=confirmationMessage;return confirmationMessage}else{return undefined}});INTERMediatorLib.addEvent(window,'unload',function(){'use strict';INTERMediator_DBAdapter.unregister()});INTERMediatorLib.addEvent(window,'load',function(){'use strict';var key,errorNode;if(INTERMediatorOnPage.initLocalContext){for(key in INTERMediatorOnPage.initLocalContext){if(INTERMediatorOnPage.initLocalContext.hasOwnProperty(key)){IMLibLocalContext.setValue(key,INTERMediatorOnPage.initLocalContext[key],!0)}}}
errorNode=document.getElementById(INTERMediatorOnPage.nonSupportMessageId);if(INTERMediatorOnPage.isAutoConstruct){if(errorNode){if(INTERMediatorOnPage.INTERMediatorCheckBrowser(errorNode)){INTERMediator.construct(!0)}}else{INTERMediator.construct(!0)}}});

function SHA1(s){function U(a,b,c){while(0<c--)a.push(b)}function L(a,b){return(a<<b)|(a>>>(32-b))}function P(a,b,c){return a^b^c}function A(a,b){var c=(b&0xFFFF)+(a&0xFFFF),d=(b>>>16)+(a>>>16)+(c>>>16);return((d&0xFFFF)<<16)|(c&0xFFFF)}var B="0123456789abcdef";return(function(a){var c=[],d=a.length*4,e;for(var i=0;i<d;i++){e=a[i>>2]>>((3-(i%4))*8);c.push(B.charAt((e>>4)&0xF)+B.charAt(e&0xF))}return c.join('')}((function(a,b){var c,d,e,f,g,h=a.length,v=0x67452301,w=0xefcdab89,x=0x98badcfe,y=0x10325476,z=0xc3d2e1f0,M=[];U(M,0x5a827999,20);U(M,0x6ed9eba1,20);U(M,0x8f1bbcdc,20);U(M,0xca62c1d6,20);a[b>>5]|=0x80<<(24-(b%32));a[(((b+65)>>9)<<4)+15]=b;for(var i=0;i<h;i+=16){c=v;d=w;e=x;f=y;g=z;for(var j=0,O=[];j<80;j++){O[j]=j<16?a[j+i]:L(O[j-3]^O[j-8]^O[j-14]^O[j-16],1);var k=(function(a,b,c,d,e){var f=(e&0xFFFF)+(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF),g=(e>>>16)+(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(f>>>16);return((g&0xFFFF)<<16)|(f&0xFFFF)})(j<20?(function(t,a,b){return(t&a)^(~t&b)}(d,e,f)):j<40?P(d,e,f):j<60?(function(t,a,b){return(t&a)^(t&b)^(a&b)}(d,e,f)):P(d,e,f),g,M[j],O[j],L(c,5));g=f;f=e;e=L(d,30);d=c;c=k}v=A(v,c);w=A(w,d);x=A(x,e);y=A(y,f);z=A(z,g)}return[v,w,x,y,z]}((function(t){var a=[],b=255,c=t.length*8;for(var i=0;i<c;i+=8){a[i>>5]|=(t.charCodeAt(i/8)&b)<<(24-(i%32))}return a}(s)).slice(),s.length*8))))};
(function(){var charSize=8,b64pad="",hexCase=0,str2binb=function(a){var b=[],mask=(1<<charSize)-1,length=a.length*charSize,i;for(i=0;i<length;i+=charSize){b[i>>5]|=(a.charCodeAt(i/charSize)&mask)<<(32-charSize-(i%32))}return b},hex2binb=function(a){var b=[],length=a.length,i,num;for(i=0;i<length;i+=2){num=parseInt(a.substr(i,2),16);if(!isNaN(num)){b[i>>3]|=num<<(24-(4*(i%8)))}else{return"INVALID HEX STRING"}}return b},binb2hex=function(a){var b=(hexCase)?"0123456789ABCDEF":"0123456789abcdef",str="",length=a.length*4,i,srcByte;for(i=0;i<length;i+=1){srcByte=a[i>>2]>>((3-(i%4))*8);str+=b.charAt((srcByte>>4)&0xF)+b.charAt(srcByte&0xF)}return str},binb2b64=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+"0123456789+/",str="",length=a.length*4,i,j,triplet;for(i=0;i<length;i+=3){triplet=(((a[i>>2]>>8*(3-i%4))&0xFF)<<16)|(((a[i+1>>2]>>8*(3-(i+1)%4))&0xFF)<<8)|((a[i+2>>2]>>8*(3-(i+2)%4))&0xFF);for(j=0;j<4;j+=1){if(i*8+j*6<=a.length*32){str+=b.charAt((triplet>>6*(3-j))&0x3F)}else{str+=b64pad}}}return str},rotr=function(x,n){return(x>>>n)|(x<<(32-n))},shr=function(x,n){return x>>>n},ch=function(x,y,z){return(x&y)^(~x&z)},maj=function(x,y,z){return(x&y)^(x&z)^(y&z)},sigma0=function(x){return rotr(x,2)^rotr(x,13)^rotr(x,22)},sigma1=function(x){return rotr(x,6)^rotr(x,11)^rotr(x,25)},gamma0=function(x){return rotr(x,7)^rotr(x,18)^shr(x,3)},gamma1=function(x){return rotr(x,17)^rotr(x,19)^shr(x,10)},safeAdd_2=function(x,y){var a=(x&0xFFFF)+(y&0xFFFF),msw=(x>>>16)+(y>>>16)+(a>>>16);return((msw&0xFFFF)<<16)|(a&0xFFFF)},safeAdd_4=function(a,b,c,d){var e=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF),msw=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16);return((msw&0xFFFF)<<16)|(e&0xFFFF)},safeAdd_5=function(a,b,c,d,e){var f=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF),msw=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16)+(f>>>16);return((msw&0xFFFF)<<16)|(f&0xFFFF)},coreSHA2=function(j,k,l){var a,b,c,d,e,f,g,h,T1,T2,H,lengthPosition,i,t,K,W=[],appendedMessageLength;if(l==="SHA-224"||l==="SHA-256"){lengthPosition=(((k+65)>>9)<<4)+15;K=[0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B,0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01,0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7,0xC19BF174,0xE49B69C1,0xEFBE4786,0x0FC19DC6,0x240CA1CC,0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152,0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147,0x06CA6351,0x14292967,0x27B70A85,0x2E1B2138,0x4D2C6DFC,0x53380D13,0x650A7354,0x766A0ABB,0x81C2C92E,0x92722C85,0xA2BFE8A1,0xA81A664B,0xC24B8B70,0xC76C51A3,0xD192E819,0xD6990624,0xF40E3585,0x106AA070,0x19A4C116,0x1E376C08,0x2748774C,0x34B0BCB5,0x391C0CB3,0x4ED8AA4A,0x5B9CCA4F,0x682E6FF3,0x748F82EE,0x78A5636F,0x84C87814,0x8CC70208,0x90BEFFFA,0xA4506CEB,0xBEF9A3F7,0xC67178F2];if(l==="SHA-224"){H=[0xc1059ed8,0x367cd507,0x3070dd17,0xf70e5939,0xffc00b31,0x68581511,0x64f98fa7,0xbefa4fa4]}else{H=[0x6A09E667,0xBB67AE85,0x3C6EF372,0xA54FF53A,0x510E527F,0x9B05688C,0x1F83D9AB,0x5BE0CD19]}}j[k>>5]|=0x80<<(24-k%32);j[lengthPosition]=k;appendedMessageLength=j.length;for(i=0;i<appendedMessageLength;i+=16){a=H[0];b=H[1];c=H[2];d=H[3];e=H[4];f=H[5];g=H[6];h=H[7];for(t=0;t<64;t+=1){if(t<16){W[t]=j[t+i]}else{W[t]=safeAdd_4(gamma1(W[t-2]),W[t-7],gamma0(W[t-15]),W[t-16])}T1=safeAdd_5(h,sigma1(e),ch(e,f,g),K[t],W[t]);T2=safeAdd_2(sigma0(a),maj(a,b,c));h=g;g=f;f=e;e=safeAdd_2(d,T1);d=c;c=b;b=a;a=safeAdd_2(T1,T2)}H[0]=safeAdd_2(a,H[0]);H[1]=safeAdd_2(b,H[1]);H[2]=safeAdd_2(c,H[2]);H[3]=safeAdd_2(d,H[3]);H[4]=safeAdd_2(e,H[4]);H[5]=safeAdd_2(f,H[5]);H[6]=safeAdd_2(g,H[6]);H[7]=safeAdd_2(h,H[7])}switch(l){case"SHA-224":return[H[0],H[1],H[2],H[3],H[4],H[5],H[6]];case"SHA-256":return H;default:return[]}},jsSHA=function(a,b){this.sha224=null;this.sha256=null;this.strBinLen=null;this.strToHash=null;if("HEX"===b){if(0!==(a.length%2)){return"TEXT MUST BE IN BYTE INCREMENTS"}this.strBinLen=a.length*4;this.strToHash=hex2binb(a)}else if(("ASCII"===b)||('undefined'===typeof(b))){this.strBinLen=a.length*charSize;this.strToHash=str2binb(a)}else{return"UNKNOWN TEXT INPUT TYPE"}};jsSHA.prototype={getHash:function(a,b){var c=null,message=this.strToHash.slice();switch(b){case"HEX":c=binb2hex;break;case"B64":c=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}switch(a){case"SHA-224":if(null===this.sha224){this.sha224=coreSHA2(message,this.strBinLen,a)}return c(this.sha224);case"SHA-256":if(null===this.sha256){this.sha256=coreSHA2(message,this.strBinLen,a)}return c(this.sha256);default:return"HASH NOT RECOGNIZED"}},getHMAC:function(a,b,c,d){var e,keyToUse,i,retVal,keyBinLen,hashBitSize,keyWithIPad=[],keyWithOPad=[];switch(d){case"HEX":e=binb2hex;break;case"B64":e=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}switch(c){case"SHA-224":hashBitSize=224;break;case"SHA-256":hashBitSize=256;break;default:return"HASH NOT RECOGNIZED"}if("HEX"===b){if(0!==(a.length%2)){return"KEY MUST BE IN BYTE INCREMENTS"}keyToUse=hex2binb(a);keyBinLen=a.length*4}else if("ASCII"===b){keyToUse=str2binb(a);keyBinLen=a.length*charSize}else{return"UNKNOWN KEY INPUT TYPE"}if(64<(keyBinLen/8)){keyToUse=coreSHA2(keyToUse,keyBinLen,c);keyToUse[15]&=0xFFFFFF00}else if(64>(keyBinLen/8)){keyToUse[15]&=0xFFFFFF00}for(i=0;i<=15;i+=1){keyWithIPad[i]=keyToUse[i]^0x36363636;keyWithOPad[i]=keyToUse[i]^0x5C5C5C5C}retVal=coreSHA2(keyWithIPad.concat(this.strToHash),512+this.strBinLen,c);retVal=coreSHA2(keyWithOPad.concat(retVal),512+hashBitSize,c);return(e(retVal))}};window.jsSHA=jsSHA}());


/*! JSEncrypt v2.3.0 | https://npmcdn.com/jsencrypt@2.3.0/LICENSE.txt */
var JSEncryptExports={};!function(t){function e(t,e,i){null!=t&&("number"==typeof t?this.fromNumber(t,e,i):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function i(){return new e(null)}function r(t,e,i,r,s,n){for(;--n>=0;){var o=e*this[t++]+i[r]+s;s=Math.floor(o/67108864),i[r++]=67108863&o}return s}function s(t,e,i,r,s,n){for(var o=32767&e,h=e>>15;--n>=0;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;a=o*a+((32767&c)<<15)+i[r]+(1073741823&s),s=(a>>>30)+(c>>>15)+h*u+(s>>>30),i[r++]=1073741823&a}return s}function n(t,e,i,r,s,n){for(var o=16383&e,h=e>>14;--n>=0;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;a=o*a+((16383&c)<<14)+i[r]+s,s=(a>>28)+(c>>14)+h*u,i[r++]=268435455&a}return s}function o(t){return Be.charAt(t)}function h(t,e){var i=Ke[t.charCodeAt(e)];return null==i?-1:i}function a(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function u(t){this.t=1,this.s=0>t?-1:0,t>0?this[0]=t:-1>t?this[0]=t+this.DV:this.t=0}function c(t){var e=i();return e.fromInt(t),e}function f(t,i){var r;if(16==i)r=4;else if(8==i)r=3;else if(256==i)r=8;else if(2==i)r=1;else if(32==i)r=5;else{if(4!=i)return void this.fromRadix(t,i);r=2}this.t=0,this.s=0;for(var s=t.length,n=!1,o=0;--s>=0;){var a=8==r?255&t[s]:h(t,s);0>a?"-"==t.charAt(s)&&(n=!0):(n=!1,0==o?this[this.t++]=a:o+r>this.DB?(this[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this[this.t++]=a>>this.DB-o):this[this.t-1]|=a<<o,o+=r,o>=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),n&&e.ZERO.subTo(this,this)}function p(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function l(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<<e)-1,s=!1,n="",h=this.t,a=this.DB-h*this.DB%e;if(h-- >0)for(a<this.DB&&(i=this[h]>>a)>0&&(s=!0,n=o(i));h>=0;)e>a?(i=(this[h]&(1<<a)-1)<<e-a,i|=this[--h]>>(a+=this.DB-e)):(i=this[h]>>(a-=e)&r,0>=a&&(a+=this.DB,--h)),i>0&&(s=!0),s&&(n+=o(i));return s?n:"0"}function d(){var t=i();return e.ZERO.subTo(this,t),t}function g(){return this.s<0?this.negate():this}function m(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(e=i-t.t,0!=e)return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0}function y(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function b(){return this.t<=0?0:this.DB*(this.t-1)+y(this[this.t-1]^this.s&this.DM)}function T(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s}function S(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s}function R(t,e){var i,r=t%this.DB,s=this.DB-r,n=(1<<s)-1,o=Math.floor(t/this.DB),h=this.s<<r&this.DM;for(i=this.t-1;i>=0;--i)e[i+o+1]=this[i]>>s|h,h=(this[i]&n)<<r;for(i=o-1;i>=0;--i)e[i]=0;e[o]=h,e.t=this.t+o+1,e.s=this.s,e.clamp()}function E(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)return void(e.t=0);var r=t%this.DB,s=this.DB-r,n=(1<<r)-1;e[0]=this[i]>>r;for(var o=i+1;o<this.t;++o)e[o-i-1]|=(this[o]&n)<<s,e[o-i]=this[o]>>r;r>0&&(e[this.t-i-1]|=(this.s&n)<<s),e.t=this.t-i,e.clamp()}function D(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);s>i;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r-=t[i],e[i++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=0>r?-1:0,-1>r?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()}function w(t,i){var r=this.abs(),s=t.abs(),n=r.t;for(i.t=n+s.t;--n>=0;)i[n]=0;for(n=0;n<s.t;++n)i[n+r.t]=r.am(0,s[n],i,n,0,r.t);i.s=0,i.clamp(),this.s!=t.s&&e.ZERO.subTo(i,i)}function x(t){for(var e=this.abs(),i=t.t=2*e.t;--i>=0;)t[i]=0;for(i=0;i<e.t-1;++i){var r=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,r,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()}function B(t,r,s){var n=t.abs();if(!(n.t<=0)){var o=this.abs();if(o.t<n.t)return null!=r&&r.fromInt(0),void(null!=s&&this.copyTo(s));null==s&&(s=i());var h=i(),a=this.s,u=t.s,c=this.DB-y(n[n.t-1]);c>0?(n.lShiftTo(c,h),o.lShiftTo(c,s)):(n.copyTo(h),o.copyTo(s));var f=h.t,p=h[f-1];if(0!=p){var l=p*(1<<this.F1)+(f>1?h[f-2]>>this.F2:0),d=this.FV/l,g=(1<<this.F1)/l,m=1<<this.F2,v=s.t,b=v-f,T=null==r?i():r;for(h.dlShiftTo(b,T),s.compareTo(T)>=0&&(s[s.t++]=1,s.subTo(T,s)),e.ONE.dlShiftTo(f,T),T.subTo(h,h);h.t<f;)h[h.t++]=0;for(;--b>=0;){var S=s[--v]==p?this.DM:Math.floor(s[v]*d+(s[v-1]+m)*g);if((s[v]+=h.am(0,S,s,b,0,f))<S)for(h.dlShiftTo(b,T),s.subTo(T,s);s[v]<--S;)s.subTo(T,s)}null!=r&&(s.drShiftTo(f,r),a!=u&&e.ZERO.subTo(r,r)),s.t=f,s.clamp(),c>0&&s.rShiftTo(c,s),0>a&&e.ZERO.subTo(s,s)}}}function K(t){var r=i();return this.abs().divRemTo(t,null,r),this.s<0&&r.compareTo(e.ZERO)>0&&t.subTo(r,r),r}function A(t){this.m=t}function U(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function O(t){return t}function V(t){t.divRemTo(this.m,null,t)}function J(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function N(t,e){t.squareTo(e),this.reduce(e)}function I(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return e=e*(2-(15&t)*e)&15,e=e*(2-(255&t)*e)&255,e=e*(2-((65535&t)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function P(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function M(t){var r=i();return t.abs().dlShiftTo(this.m.t,r),r.divRemTo(this.m,null,r),t.s<0&&r.compareTo(e.ZERO)>0&&this.m.subTo(r,r),r}function L(t){var e=i();return t.copyTo(e),this.reduce(e),e}function q(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=32767&t[e],r=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(i=e+this.m.t,t[i]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function C(t,e){t.squareTo(e),this.reduce(e)}function H(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function j(){return 0==(this.t>0?1&this[0]:this.s)}function k(t,r){if(t>4294967295||1>t)return e.ONE;var s=i(),n=i(),o=r.convert(this),h=y(t)-1;for(o.copyTo(s);--h>=0;)if(r.sqrTo(s,n),(t&1<<h)>0)r.mulTo(n,o,s);else{var a=s;s=n,n=a}return r.revert(s)}function F(t,e){var i;return i=256>t||e.isEven()?new A(e):new P(e),this.exp(t,i)}
// Copyright (c) 2005-2009 Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.
function _(){var t=i();return this.copyTo(t),t}function z(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function Z(){return 0==this.t?this.s:this[0]<<24>>24}function G(){return 0==this.t?this.s:this[0]<<16>>16}function $(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function Y(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function W(t){if(null==t&&(t=10),0==this.signum()||2>t||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),s=c(r),n=i(),o=i(),h="";for(this.divRemTo(s,n,o);n.signum()>0;)h=(r+o.intValue()).toString(t).substr(1)+h,n.divRemTo(s,n,o);return o.intValue().toString(t)+h}function Q(t,i){this.fromInt(0),null==i&&(i=10);for(var r=this.chunkSize(i),s=Math.pow(i,r),n=!1,o=0,a=0,u=0;u<t.length;++u){var c=h(t,u);0>c?"-"==t.charAt(u)&&0==this.signum()&&(n=!0):(a=i*a+c,++o>=r&&(this.dMultiply(s),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(i,o)),this.dAddOffset(a,0)),n&&e.ZERO.subTo(this,this)}function X(t,i,r){if("number"==typeof i)if(2>t)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),ht,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(i);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(e.ONE.shiftLeft(t-1),this);else{var s=new Array,n=7&t;s.length=(t>>3)+1,i.nextBytes(s),n>0?s[0]&=(1<<n)-1:s[0]=0,this.fromString(s,256)}}function tt(){var t=this.t,e=new Array;e[0]=this.s;var i,r=this.DB-t*this.DB%8,s=0;if(t-- >0)for(r<this.DB&&(i=this[t]>>r)!=(this.s&this.DM)>>r&&(e[s++]=i|this.s<<this.DB-r);t>=0;)8>r?(i=(this[t]&(1<<r)-1)<<8-r,i|=this[--t]>>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,0>=r&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==s&&(128&this.s)!=(128&i)&&++s,(s>0||i!=this.s)&&(e[s++]=i);return e}function et(t){return 0==this.compareTo(t)}function it(t){return this.compareTo(t)<0?this:t}function rt(t){return this.compareTo(t)>0?this:t}function st(t,e,i){var r,s,n=Math.min(t.t,this.t);for(r=0;n>r;++r)i[r]=e(this[r],t[r]);if(t.t<this.t){for(s=t.s&this.DM,r=n;r<this.t;++r)i[r]=e(this[r],s);i.t=this.t}else{for(s=this.s&this.DM,r=n;r<t.t;++r)i[r]=e(s,t[r]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()}function nt(t,e){return t&e}function ot(t){var e=i();return this.bitwiseTo(t,nt,e),e}function ht(t,e){return t|e}function at(t){var e=i();return this.bitwiseTo(t,ht,e),e}function ut(t,e){return t^e}function ct(t){var e=i();return this.bitwiseTo(t,ut,e),e}function ft(t,e){return t&~e}function pt(t){var e=i();return this.bitwiseTo(t,ft,e),e}function lt(){for(var t=i(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}function dt(t){var e=i();return 0>t?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function gt(t){var e=i();return 0>t?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function mt(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function yt(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+mt(this[t]);return this.s<0?this.t*this.DB:-1}function vt(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function bt(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=vt(this[i]^e);return t}function Tt(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)}function St(t,i){var r=e.ONE.shiftLeft(t);return this.bitwiseTo(r,i,r),r}function Rt(t){return this.changeBit(t,ht)}function Et(t){return this.changeBit(t,ft)}function Dt(t){return this.changeBit(t,ut)}function wt(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);s>i;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r+=t[i],e[i++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=0>r?-1:0,r>0?e[i++]=r:-1>r&&(e[i++]=this.DV+r),e.t=i,e.clamp()}function xt(t){var e=i();return this.addTo(t,e),e}function Bt(t){var e=i();return this.subTo(t,e),e}function Kt(t){var e=i();return this.multiplyTo(t,e),e}function At(){var t=i();return this.squareTo(t),t}function Ut(t){var e=i();return this.divRemTo(t,e,null),e}function Ot(t){var e=i();return this.divRemTo(t,null,e),e}function Vt(t){var e=i(),r=i();return this.divRemTo(t,e,r),new Array(e,r)}function Jt(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function Nt(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function It(){}function Pt(t){return t}function Mt(t,e,i){t.multiplyTo(e,i)}function Lt(t,e){t.squareTo(e)}function qt(t){return this.exp(t,new It)}function Ct(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;var s;for(s=i.t-this.t;s>r;++r)i[r+this.t]=this.am(0,t[r],i,r,0,this.t);for(s=Math.min(t.t,e);s>r;++r)this.am(0,t[r],i,r,0,e-r);i.clamp()}function Ht(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;--r>=0;)i[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)i[this.t+r-e]=this.am(e-r,t[r],i,0,0,this.t+r-e);i.clamp(),i.drShiftTo(1,i)}function jt(t){this.r2=i(),this.q3=i(),e.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function kt(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=i();return t.copyTo(e),this.reduce(e),e}function Ft(t){return t}function _t(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function zt(t,e){t.squareTo(e),this.reduce(e)}function Zt(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function Gt(t,e){var r,s,n=t.bitLength(),o=c(1);if(0>=n)return o;r=18>n?1:48>n?3:144>n?4:768>n?5:6,s=8>n?new A(e):e.isEven()?new jt(e):new P(e);var h=new Array,a=3,u=r-1,f=(1<<r)-1;if(h[1]=s.convert(this),r>1){var p=i();for(s.sqrTo(h[1],p);f>=a;)h[a]=i(),s.mulTo(p,h[a-2],h[a]),a+=2}var l,d,g=t.t-1,m=!0,v=i();for(n=y(t[g])-1;g>=0;){for(n>=u?l=t[g]>>n-u&f:(l=(t[g]&(1<<n+1)-1)<<u-n,g>0&&(l|=t[g-1]>>this.DB+n-u)),a=r;0==(1&l);)l>>=1,--a;if((n-=a)<0&&(n+=this.DB,--g),m)h[l].copyTo(o),m=!1;else{for(;a>1;)s.sqrTo(o,v),s.sqrTo(v,o),a-=2;a>0?s.sqrTo(o,v):(d=o,o=v,v=d),s.mulTo(v,h[l],o)}for(;g>=0&&0==(t[g]&1<<n);)s.sqrTo(o,v),d=o,o=v,v=d,--n<0&&(n=this.DB-1,--g)}return s.revert(o)}function $t(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var r=e;e=i,i=r}var s=e.getLowestSetBit(),n=i.getLowestSetBit();if(0>n)return e;for(n>s&&(n=s),n>0&&(e.rShiftTo(n,e),i.rShiftTo(n,i));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return n>0&&i.lShiftTo(n,i),i}function Yt(t){if(0>=t)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i}function Wt(t){var i=t.isEven();if(this.isEven()&&i||0==t.signum())return e.ZERO;for(var r=t.clone(),s=this.clone(),n=c(1),o=c(0),h=c(0),a=c(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),i?(n.isEven()&&o.isEven()||(n.addTo(this,n),o.subTo(t,o)),n.rShiftTo(1,n)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;s.isEven();)s.rShiftTo(1,s),i?(h.isEven()&&a.isEven()||(h.addTo(this,h),a.subTo(t,a)),h.rShiftTo(1,h)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(s)>=0?(r.subTo(s,r),i&&n.subTo(h,n),o.subTo(a,o)):(s.subTo(r,s),i&&h.subTo(n,h),a.subTo(o,a))}return 0!=s.compareTo(e.ONE)?e.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}function Qt(t){var e,i=this.abs();if(1==i.t&&i[0]<=Ae[Ae.length-1]){for(e=0;e<Ae.length;++e)if(i[0]==Ae[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<Ae.length;){for(var r=Ae[e],s=e+1;s<Ae.length&&Ue>r;)r*=Ae[s++];for(r=i.modInt(r);s>e;)if(r%Ae[e++]==0)return!1}return i.millerRabin(t)}function Xt(t){var r=this.subtract(e.ONE),s=r.getLowestSetBit();if(0>=s)return!1;var n=r.shiftRight(s);t=t+1>>1,t>Ae.length&&(t=Ae.length);for(var o=i(),h=0;t>h;++h){o.fromInt(Ae[Math.floor(Math.random()*Ae.length)]);var a=o.modPow(n,this);if(0!=a.compareTo(e.ONE)&&0!=a.compareTo(r)){for(var u=1;u++<s&&0!=a.compareTo(r);)if(a=a.modPowInt(2,this),0==a.compareTo(e.ONE))return!1;if(0!=a.compareTo(r))return!1}}return!0}function te(){this.i=0,this.j=0,this.S=new Array}function ee(t){var e,i,r;for(e=0;256>e;++e)this.S[e]=e;for(i=0,e=0;256>e;++e)i=i+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[i],this.S[i]=r;this.i=0,this.j=0}function ie(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}function re(){return new te}function se(){if(null==Oe){for(Oe=re();Ne>Je;){var t=Math.floor(65536*Math.random());Ve[Je++]=255&t}for(Oe.init(Ve),Je=0;Je<Ve.length;++Je)Ve[Je]=0;Je=0}return Oe.next()}function ne(t){var e;for(e=0;e<t.length;++e)t[e]=se()}function oe(){}function he(t,i){return new e(t,i)}function ae(t,i){if(i<t.length+11)return console.error("Message too long for RSA"),null;for(var r=new Array,s=t.length-1;s>=0&&i>0;){var n=t.charCodeAt(s--);128>n?r[--i]=n:n>127&&2048>n?(r[--i]=63&n|128,r[--i]=n>>6|192):(r[--i]=63&n|128,r[--i]=n>>6&63|128,r[--i]=n>>12|224)}r[--i]=0;for(var o=new oe,h=new Array;i>2;){for(h[0]=0;0==h[0];)o.nextBytes(h);r[--i]=h[0]}return r[--i]=2,r[--i]=0,new e(r)}function ue(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function ce(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}function fe(t){return t.modPowInt(this.e,this.n)}function pe(t){var e=ae(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var r=i.toString(16);return 0==(1&r.length)?r:"0"+r}function le(t,e){for(var i=t.toByteArray(),r=0;r<i.length&&0==i[r];)++r;if(i.length-r!=e-1||2!=i[r])return null;for(++r;0!=i[r];)if(++r>=i.length)return null;for(var s="";++r<i.length;){var n=255&i[r];128>n?s+=String.fromCharCode(n):n>191&&224>n?(s+=String.fromCharCode((31&n)<<6|63&i[r+1]),++r):(s+=String.fromCharCode((15&n)<<12|(63&i[r+1])<<6|63&i[r+2]),r+=2)}return s}function de(t,e,i){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16),this.d=he(i,16)):console.error("Invalid RSA private key")}function ge(t,e,i,r,s,n,o,h){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16),this.d=he(i,16),this.p=he(r,16),this.q=he(s,16),this.dmp1=he(n,16),this.dmq1=he(o,16),this.coeff=he(h,16)):console.error("Invalid RSA private key")}function me(t,i){var r=new oe,s=t>>1;this.e=parseInt(i,16);for(var n=new e(i,16);;){for(;this.p=new e(t-s,1,r),0!=this.p.subtract(e.ONE).gcd(n).compareTo(e.ONE)||!this.p.isProbablePrime(10););for(;this.q=new e(s,1,r),0!=this.q.subtract(e.ONE).gcd(n).compareTo(e.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var h=this.p.subtract(e.ONE),a=this.q.subtract(e.ONE),u=h.multiply(a);if(0==u.gcd(n).compareTo(e.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(u),this.dmp1=this.d.mod(h),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}function ye(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)}function ve(t){var e=he(t,16),i=this.doPrivate(e);return null==i?null:le(i,this.n.bitLength()+7>>3)}function be(t){var e,i,r="";for(e=0;e+3<=t.length;e+=3)i=parseInt(t.substring(e,e+3),16),r+=Le.charAt(i>>6)+Le.charAt(63&i);for(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),r+=Le.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),r+=Le.charAt(i>>2)+Le.charAt((3&i)<<4));(3&r.length)>0;)r+=qe;return r}function Te(t){var e,i,r="",s=0;for(e=0;e<t.length&&t.charAt(e)!=qe;++e)v=Le.indexOf(t.charAt(e)),v<0||(0==s?(r+=o(v>>2),i=3&v,s=1):1==s?(r+=o(i<<2|v>>4),i=15&v,s=2):2==s?(r+=o(i),r+=o(v>>2),i=3&v,s=3):(r+=o(i<<2|v>>4),r+=o(15&v),s=0));return 1==s&&(r+=o(i<<2)),r}
// Copyright (c) 2005 Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.
var Se,Re=0xdeadbeefcafe,Ee=15715070==(16777215&Re);Ee&&"Microsoft Internet Explorer"==navigator.appName?(e.prototype.am=s,Se=30):Ee&&"Netscape"!=navigator.appName?(e.prototype.am=r,Se=26):(e.prototype.am=n,Se=28),e.prototype.DB=Se,e.prototype.DM=(1<<Se)-1,e.prototype.DV=1<<Se;var De=52;e.prototype.FV=Math.pow(2,De),e.prototype.F1=De-Se,e.prototype.F2=2*Se-De;var we,xe,Be="0123456789abcdefghijklmnopqrstuvwxyz",Ke=new Array;for(we="0".charCodeAt(0),xe=0;9>=xe;++xe)Ke[we++]=xe;for(we="a".charCodeAt(0),xe=10;36>xe;++xe)Ke[we++]=xe;for(we="A".charCodeAt(0),xe=10;36>xe;++xe)Ke[we++]=xe;A.prototype.convert=U,A.prototype.revert=O,A.prototype.reduce=V,A.prototype.mulTo=J,A.prototype.sqrTo=N,P.prototype.convert=M,P.prototype.revert=L,P.prototype.reduce=q,P.prototype.mulTo=H,P.prototype.sqrTo=C,e.prototype.copyTo=a,e.prototype.fromInt=u,e.prototype.fromString=f,e.prototype.clamp=p,e.prototype.dlShiftTo=T,e.prototype.drShiftTo=S,e.prototype.lShiftTo=R,e.prototype.rShiftTo=E,e.prototype.subTo=D,e.prototype.multiplyTo=w,e.prototype.squareTo=x,e.prototype.divRemTo=B,e.prototype.invDigit=I,e.prototype.isEven=j,e.prototype.exp=k,e.prototype.toString=l,e.prototype.negate=d,e.prototype.abs=g,e.prototype.compareTo=m,e.prototype.bitLength=b,e.prototype.mod=K,e.prototype.modPowInt=F,e.ZERO=c(0),e.ONE=c(1),It.prototype.convert=Pt,It.prototype.revert=Pt,It.prototype.mulTo=Mt,It.prototype.sqrTo=Lt,jt.prototype.convert=kt,jt.prototype.revert=Ft,jt.prototype.reduce=_t,jt.prototype.mulTo=Zt,jt.prototype.sqrTo=zt;var Ae=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Ue=(1<<26)/Ae[Ae.length-1];e.prototype.chunkSize=$,e.prototype.toRadix=W,e.prototype.fromRadix=Q,e.prototype.fromNumber=X,e.prototype.bitwiseTo=st,e.prototype.changeBit=St,e.prototype.addTo=wt,e.prototype.dMultiply=Jt,e.prototype.dAddOffset=Nt,e.prototype.multiplyLowerTo=Ct,e.prototype.multiplyUpperTo=Ht,e.prototype.modInt=Yt,e.prototype.millerRabin=Xt,e.prototype.clone=_,e.prototype.intValue=z,e.prototype.byteValue=Z,e.prototype.shortValue=G,e.prototype.signum=Y,e.prototype.toByteArray=tt,e.prototype.equals=et,e.prototype.min=it,e.prototype.max=rt,e.prototype.and=ot,e.prototype.or=at,e.prototype.xor=ct,e.prototype.andNot=pt,e.prototype.not=lt,e.prototype.shiftLeft=dt,e.prototype.shiftRight=gt,e.prototype.getLowestSetBit=yt,e.prototype.bitCount=bt,e.prototype.testBit=Tt,e.prototype.setBit=Rt,e.prototype.clearBit=Et,e.prototype.flipBit=Dt,e.prototype.add=xt,e.prototype.subtract=Bt,e.prototype.multiply=Kt,e.prototype.divide=Ut,e.prototype.remainder=Ot,e.prototype.divideAndRemainder=Vt,e.prototype.modPow=Gt,e.prototype.modInverse=Wt,e.prototype.pow=qt,e.prototype.gcd=$t,e.prototype.isProbablePrime=Qt,e.prototype.square=At,te.prototype.init=ee,te.prototype.next=ie;var Oe,Ve,Je,Ne=256;if(null==Ve){Ve=new Array,Je=0;var Ie;if(window.crypto&&window.crypto.getRandomValues){var Pe=new Uint32Array(256);for(window.crypto.getRandomValues(Pe),Ie=0;Ie<Pe.length;++Ie)Ve[Je++]=255&Pe[Ie]}var Me=function(t){if(this.count=this.count||0,this.count>=256||Je>=Ne)return void(window.removeEventListener?window.removeEventListener("mousemove",Me,!1):window.detachEvent&&window.detachEvent("onmousemove",Me));try{var e=t.x+t.y;Ve[Je++]=255&e,this.count+=1}catch(i){}};window.addEventListener?window.addEventListener("mousemove",Me,!1):window.attachEvent&&window.attachEvent("onmousemove",Me)}oe.prototype.nextBytes=ne,ue.prototype.doPublic=fe,ue.prototype.setPublic=ce,ue.prototype.encrypt=pe,ue.prototype.doPrivate=ye,ue.prototype.setPrivate=de,ue.prototype.setPrivateEx=ge,ue.prototype.generate=me,ue.prototype.decrypt=ve,
// Copyright (c) 2011 Kevin M Burns Jr.
// All Rights Reserved.
// See "LICENSE" for details.
//
// Extension to jsbn which adds facilities for asynchronous RSA key generation
// Primarily created to avoid execution timeout on mobile devices
//
// http://www-cs-students.stanford.edu/~tjw/jsbn/
//
// ---
function(){var t=function(t,r,s){var n=new oe,o=t>>1;this.e=parseInt(r,16);var h=new e(r,16),a=this,u=function(){var r=function(){if(a.p.compareTo(a.q)<=0){var t=a.p;a.p=a.q,a.q=t}var i=a.p.subtract(e.ONE),r=a.q.subtract(e.ONE),n=i.multiply(r);0==n.gcd(h).compareTo(e.ONE)?(a.n=a.p.multiply(a.q),a.d=h.modInverse(n),a.dmp1=a.d.mod(i),a.dmq1=a.d.mod(r),a.coeff=a.q.modInverse(a.p),setTimeout(function(){s()},0)):setTimeout(u,0)},c=function(){a.q=i(),a.q.fromNumberAsync(o,1,n,function(){a.q.subtract(e.ONE).gcda(h,function(t){0==t.compareTo(e.ONE)&&a.q.isProbablePrime(10)?setTimeout(r,0):setTimeout(c,0)})})},f=function(){a.p=i(),a.p.fromNumberAsync(t-o,1,n,function(){a.p.subtract(e.ONE).gcda(h,function(t){0==t.compareTo(e.ONE)&&a.p.isProbablePrime(10)?setTimeout(c,0):setTimeout(f,0)})})};setTimeout(f,0)};setTimeout(u,0)};ue.prototype.generateAsync=t;var r=function(t,e){var i=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(i.compareTo(r)<0){var s=i;i=r,r=s}var n=i.getLowestSetBit(),o=r.getLowestSetBit();if(0>o)return void e(i);o>n&&(o=n),o>0&&(i.rShiftTo(o,i),r.rShiftTo(o,r));var h=function(){(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),i.compareTo(r)>=0?(i.subTo(r,i),i.rShiftTo(1,i)):(r.subTo(i,r),r.rShiftTo(1,r)),i.signum()>0?setTimeout(h,0):(o>0&&r.lShiftTo(o,r),setTimeout(function(){e(r)},0))};setTimeout(h,10)};e.prototype.gcda=r;var s=function(t,i,r,s){if("number"==typeof i)if(2>t)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),ht,this),this.isEven()&&this.dAddOffset(1,0);var n=this,o=function(){n.dAddOffset(2,0),n.bitLength()>t&&n.subTo(e.ONE.shiftLeft(t-1),n),n.isProbablePrime(i)?setTimeout(function(){s()},0):setTimeout(o,0)};setTimeout(o,0)}else{var h=new Array,a=7&t;h.length=(t>>3)+1,i.nextBytes(h),a>0?h[0]&=(1<<a)-1:h[0]=0,this.fromString(h,256)}};e.prototype.fromNumberAsync=s}();var Le="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qe="=",Ce=Ce||{};Ce.env=Ce.env||{};var He=Ce,je=Object.prototype,ke="[object Function]",Fe=["toString","valueOf"];Ce.env.parseUA=function(t){var e,i=function(t){var e=0;return parseFloat(t.replace(/\./g,function(){return 1==e++?"":"."}))},r=navigator,s={ie:0,opera:0,gecko:0,webkit:0,chrome:0,mobile:null,air:0,ipad:0,iphone:0,ipod:0,ios:null,android:0,webos:0,caja:r&&r.cajaVersion,secure:!1,os:null},n=t||navigator&&navigator.userAgent,o=window&&window.location,h=o&&o.href;return s.secure=h&&0===h.toLowerCase().indexOf("https"),n&&(/windows|win32/i.test(n)?s.os="windows":/macintosh/i.test(n)?s.os="macintosh":/rhino/i.test(n)&&(s.os="rhino"),/KHTML/.test(n)&&(s.webkit=1),e=n.match(/AppleWebKit\/([^\s]*)/),e&&e[1]&&(s.webkit=i(e[1]),/ Mobile\//.test(n)?(s.mobile="Apple",e=n.match(/OS ([^\s]*)/),e&&e[1]&&(e=i(e[1].replace("_","."))),s.ios=e,s.ipad=s.ipod=s.iphone=0,e=n.match(/iPad|iPod|iPhone/),e&&e[0]&&(s[e[0].toLowerCase()]=s.ios)):(e=n.match(/NokiaN[^\/]*|Android \d\.\d|webOS\/\d\.\d/),e&&(s.mobile=e[0]),/webOS/.test(n)&&(s.mobile="WebOS",e=n.match(/webOS\/([^\s]*);/),e&&e[1]&&(s.webos=i(e[1]))),/ Android/.test(n)&&(s.mobile="Android",e=n.match(/Android ([^\s]*);/),e&&e[1]&&(s.android=i(e[1])))),e=n.match(/Chrome\/([^\s]*)/),e&&e[1]?s.chrome=i(e[1]):(e=n.match(/AdobeAIR\/([^\s]*)/),e&&(s.air=e[0]))),s.webkit||(e=n.match(/Opera[\s\/]([^\s]*)/),e&&e[1]?(s.opera=i(e[1]),e=n.match(/Version\/([^\s]*)/),e&&e[1]&&(s.opera=i(e[1])),e=n.match(/Opera Mini[^;]*/),e&&(s.mobile=e[0])):(e=n.match(/MSIE\s([^;]*)/),e&&e[1]?s.ie=i(e[1]):(e=n.match(/Gecko\/([^\s]*)/),e&&(s.gecko=1,e=n.match(/rv:([^\s\)]*)/),e&&e[1]&&(s.gecko=i(e[1]))))))),s},Ce.env.ua=Ce.env.parseUA(),Ce.isFunction=function(t){return"function"==typeof t||je.toString.apply(t)===ke},Ce._IEEnumFix=Ce.env.ua.ie?function(t,e){var i,r,s;for(i=0;i<Fe.length;i+=1)r=Fe[i],s=e[r],He.isFunction(s)&&s!=je[r]&&(t[r]=s)}:function(){},Ce.extend=function(t,e,i){if(!e||!t)throw new Error("extend failed, please check that all dependencies are included.");var r,s=function(){};if(s.prototype=e.prototype,t.prototype=new s,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==je.constructor&&(e.prototype.constructor=e),i){for(r in i)He.hasOwnProperty(i,r)&&(t.prototype[r]=i[r]);He._IEEnumFix(t.prototype,i)}},/*
* asn1.js - ASN.1 DER encoder classes
*
* Copyright (c) 2013 Kenji Urushima (kenji.urushima@gmail.com)
*
* This software is licensed under the terms of the MIT License.
* http://kjur.github.com/jsrsasign/license
*
* The above copyright and license notice shall be
* included in all copies or substantial portions of the Software.
*/
/**
* @fileOverview
* @name asn1-1.0.js
* @author Kenji Urushima kenji.urushima@gmail.com
* @version 1.0.2 (2013-May-30)
* @since 2.1
* @license <a href="http://kjur.github.io/jsrsasign/license/">MIT License</a>
*/
"undefined"!=typeof KJUR&&KJUR||(KJUR={}),"undefined"!=typeof KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var i=t.toString(16);if("-"!=i.substr(0,1))i.length%2==1?i="0"+i:i.match(/^[0-7]/)||(i="00"+i);else{var r=i.substr(1),s=r.length;s%2==1?s+=1:i.match(/^[0-7]/)||(s+=2);for(var n="",o=0;s>o;o++)n+="f";var h=new e(n,16),a=h.xor(t).add(e.ONE);i=a.toString(16).replace(/^-/,"")}return i},this.getPEMStringFromHex=function(t,e){var i=CryptoJS.enc.Hex.parse(t),r=CryptoJS.enc.Base64.stringify(i),s=r.replace(/(.{64})/g,"$1\r\n");return s=s.replace(/\r\n$/,""),"-----BEGIN "+e+"-----\r\n"+s+"\r\n-----END "+e+"-----\r\n"}},KJUR.asn1.ASN1Object=function(){var t="";this.getLengthHexFromValue=function(){if("undefined"==typeof this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+t.length+",v="+this.hV;var e=this.hV.length/2,i=e.toString(16);if(i.length%2==1&&(i="0"+i),128>e)return i;var r=i.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);var s=128+r;return s.toString(16)+i},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},KJUR.asn1.DERAbstractString=function(t){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex&&this.setStringHex(t.hex))},Ce.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractTime=function(t){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){utc=t.getTime()+6e4*t.getTimezoneOffset();var e=new Date(utc);return e},this.formatDate=function(t,e){var i=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var n=i(String(r.getMonth()+1),2),o=i(String(r.getDate()),2),h=i(String(r.getHours()),2),a=i(String(r.getMinutes()),2),u=i(String(r.getSeconds()),2);return s+n+o+h+a+u+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setByDateValue=function(t,e,i,r,s,n){var o=new Date(Date.UTC(t,e-1,i,r,s,n,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},Ce.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractStructured=function(t){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,"undefined"!=typeof t&&"undefined"!=typeof t.array&&(this.asn1Array=t.array)},Ce.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object),KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},Ce.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object),KJUR.asn1.DERInteger=function(t){KJUR.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var i=new e(String(t),10);this.setByBigInteger(i)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.bigint?this.setByBigInteger(t.bigint):"undefined"!=typeof t["int"]?this.setByInteger(t["int"]):"undefined"!=typeof t.hex&&this.setValueHex(t.hex))},Ce.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object),KJUR.asn1.DERBitString=function(t){KJUR.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(0>t||t>7)throw"unused bits shall be from 0 to 7: u = "+t;var i="0"+t;this.hTLV=null,this.isModified=!0,this.hV=i+e},this.setByBinaryString=function(t){t=t.replace(/0+$/,"");var e=8-t.length%8;8==e&&(e=0);for(var i=0;e>=i;i++)t+="0";for(var r="",i=0;i<t.length-1;i+=8){var s=t.substr(i,8),n=parseInt(s,2).toString(16);1==n.length&&(n="0"+n),r+=n}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",i=0;i<t.length;i++)e+=1==t[i]?"1":"0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),i=0;t>i;i++)e[i]=!1;return e},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.hex?this.setHexValueIncludingUnusedBits(t.hex):"undefined"!=typeof t.bin?this.setByBinaryString(t.bin):"undefined"!=typeof t.array&&this.setByBooleanArray(t.array))},Ce.extend(KJUR.asn1.DERBitString,KJUR.asn1.ASN1Object),KJUR.asn1.DEROctetString=function(t){KJUR.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Ce.extend(KJUR.asn1.DEROctetString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNull=function(){KJUR.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Ce.extend(KJUR.asn1.DERNull,KJUR.asn1.ASN1Object),KJUR.asn1.DERObjectIdentifier=function(t){var i=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",s=new e(t,10),n=s.toString(2),o=7-n.length%7;7==o&&(o=0);for(var h="",a=0;o>a;a++)h+="0";n=h+n;for(var a=0;a<n.length-1;a+=7){var u=n.substr(a,7);a!=n.length-7&&(u="1"+u),r+=i(parseInt(u,2))}return r};KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var e="",s=t.split("."),n=40*parseInt(s[0])+parseInt(s[1]);e+=i(n),s.splice(0,2);for(var o=0;o<s.length;o++)e+=r(s[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){if("undefined"==typeof KJUR.asn1.x509.OID.name2oidList[t])throw"DERObjectIdentifier oidName undefined: "+t;var e=KJUR.asn1.x509.OID.name2oidList[t];this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.oid?this.setValueOidString(t.oid):"undefined"!=typeof t.hex?this.setValueHex(t.hex):"undefined"!=typeof t.name&&this.setValueName(t.name))},Ce.extend(KJUR.asn1.DERObjectIdentifier,KJUR.asn1.ASN1Object),KJUR.asn1.DERUTF8String=function(t){KJUR.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Ce.extend(KJUR.asn1.DERUTF8String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNumericString=function(t){KJUR.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Ce.extend(KJUR.asn1.DERNumericString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERPrintableString=function(t){KJUR.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Ce.extend(KJUR.asn1.DERPrintableString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERTeletexString=function(t){KJUR.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Ce.extend(KJUR.asn1.DERTeletexString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERIA5String=function(t){KJUR.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Ce.extend(KJUR.asn1.DERIA5String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERUTCTime=function(t){KJUR.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex?this.setStringHex(t.hex):"undefined"!=typeof t.date&&this.setByDate(t.date))},Ce.extend(KJUR.asn1.DERUTCTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERGeneralizedTime=function(t){KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen"),this.hV=stohex(this.s)},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex?this.setStringHex(t.hex):"undefined"!=typeof t.date&&this.setByDate(t.date))},Ce.extend(KJUR.asn1.DERGeneralizedTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERSequence=function(t){KJUR.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t+=i.getEncodedHex()}return this.hV=t,this.hV}},Ce.extend(KJUR.asn1.DERSequence,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERSet=function(t){KJUR.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t.push(i.getEncodedHex())}return t.sort(),this.hV=t.join(""),this.hV}},Ce.extend(KJUR.asn1.DERSet,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERTaggedObject=function(t){KJUR.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,i){this.hT=e,this.isExplicit=t,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.tag&&(this.hT=t.tag),"undefined"!=typeof t.explicit&&(this.isExplicit=t.explicit),"undefined"!=typeof t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},Ce.extend(KJUR.asn1.DERTaggedObject,KJUR.asn1.ASN1Object),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";var e,i={};i.decode=function(i){var r;if(e===t){var s="0123456789ABCDEF",n=" \f\n\r  \u2028\u2029";for(e=[],r=0;16>r;++r)e[s.charAt(r)]=r;for(s=s.toLowerCase(),r=10;16>r;++r)e[s.charAt(r)]=r;for(r=0;r<n.length;++r)e[n.charAt(r)]=-1}var o=[],h=0,a=0;for(r=0;r<i.length;++r){var u=i.charAt(r);if("="==u)break;if(u=e[u],-1!=u){if(u===t)throw"Illegal character at offset "+r;h|=u,++a>=2?(o[o.length]=h,h=0,a=0):h<<=4}}if(a)throw"Hex encoding incomplete: 4 bits missing";return o},window.Hex=i}(),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";var e,i={};i.decode=function(i){var r;if(e===t){var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="= \f\n\r  \u2028\u2029";for(e=[],r=0;64>r;++r)e[s.charAt(r)]=r;for(r=0;r<n.length;++r)e[n.charAt(r)]=-1}var o=[],h=0,a=0;for(r=0;r<i.length;++r){var u=i.charAt(r);if("="==u)break;if(u=e[u],-1!=u){if(u===t)throw"Illegal character at offset "+r;h|=u,++a>=4?(o[o.length]=h>>16,o[o.length]=h>>8&255,o[o.length]=255&h,h=0,a=0):h<<=6}}switch(a){case 1:throw"Base64 encoding incomplete: at least 2 bits missing";case 2:o[o.length]=h>>10;break;case 3:o[o.length]=h>>16,o[o.length]=h>>8&255}return o},i.re=/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,i.unarmor=function(t){var e=i.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw"RegExp out of sync";t=e[2]}return i.decode(t)},window.Base64=i}(),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";function e(t,i){t instanceof e?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=i)}function i(t,e,i,r,s){this.stream=t,this.header=e,this.length=i,this.tag=r,this.sub=s}var r=100,s="…",n={tag:function(t,e){var i=document.createElement(t);return i.className=e,i},text:function(t){return document.createTextNode(t)}};e.prototype.get=function(e){if(e===t&&(e=this.pos++),e>=this.enc.length)throw"Requesting byte offset "+e+" on a stream of length "+this.enc.length;return this.enc[e]},e.prototype.hexDigits="0123456789ABCDEF",e.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},e.prototype.hexDump=function(t,e,i){for(var r="",s=t;e>s;++s)if(r+=this.hexByte(this.get(s)),i!==!0)switch(15&s){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r},e.prototype.parseStringISO=function(t,e){for(var i="",r=t;e>r;++r)i+=String.fromCharCode(this.get(r));return i},e.prototype.parseStringUTF=function(t,e){for(var i="",r=t;e>r;){var s=this.get(r++);i+=128>s?String.fromCharCode(s):s>191&&224>s?String.fromCharCode((31&s)<<6|63&this.get(r++)):String.fromCharCode((15&s)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return i},e.prototype.parseStringBMP=function(t,e){for(var i="",r=t;e>r;r+=2){var s=this.get(r),n=this.get(r+1);i+=String.fromCharCode((s<<8)+n)}return i},e.prototype.reTime=/^((?:1[89]|2\d)?\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,e.prototype.parseTime=function(t,e){var i=this.parseStringISO(t,e),r=this.reTime.exec(i);return r?(i=r[1]+"-"+r[2]+"-"+r[3]+" "+r[4],r[5]&&(i+=":"+r[5],r[6]&&(i+=":"+r[6],r[7]&&(i+="."+r[7]))),r[8]&&(i+=" UTC","Z"!=r[8]&&(i+=r[8],r[9]&&(i+=":"+r[9]))),i):"Unrecognized time: "+i},e.prototype.parseInteger=function(t,e){var i=e-t;if(i>4){i<<=3;var r=this.get(t);if(0===r)i-=8;else for(;128>r;)r<<=1,--i;return"("+i+" bit)"}for(var s=0,n=t;e>n;++n)s=s<<8|this.get(n);return s},e.prototype.parseBitString=function(t,e){var i=this.get(t),r=(e-t-1<<3)-i,s="("+r+" bit)";if(20>=r){var n=i;s+=" ";for(var o=e-1;o>t;--o){for(var h=this.get(o),a=n;8>a;++a)s+=h>>a&1?"1":"0";n=0}}return s},e.prototype.parseOctetString=function(t,e){var i=e-t,n="("+i+" byte) ";i>r&&(e=t+r);for(var o=t;e>o;++o)n+=this.hexByte(this.get(o));return i>r&&(n+=s),n},e.prototype.parseOID=function(t,e){for(var i="",r=0,s=0,n=t;e>n;++n){var o=this.get(n);if(r=r<<7|127&o,s+=7,!(128&o)){if(""===i){var h=80>r?40>r?0:1:2;i=h+"."+(r-40*h)}else i+="."+(s>=31?"bigint":r);r=s=0}}return i},i.prototype.typeName=function(){if(this.tag===t)return"unknown";var e=this.tag>>6,i=(this.tag>>5&1,31&this.tag);switch(e){case 0:switch(i){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString";default:return"Universal_"+i.toString(16)}case 1:return"Application_"+i.toString(16);case 2:return"["+i+"]";case 3:return"Private_"+i.toString(16)}},i.prototype.reSeemsASCII=/^[ -~]+$/,i.prototype.content=function(){if(this.tag===t)return null;var e=this.tag>>6,i=31&this.tag,n=this.posContent(),o=Math.abs(this.length);if(0!==e){if(null!==this.sub)return"("+this.sub.length+" elem)";var h=this.stream.parseStringISO(n,n+Math.min(o,r));return this.reSeemsASCII.test(h)?h.substring(0,2*r)+(h.length>2*r?s:""):this.stream.parseOctetString(n,n+o)}switch(i){case 1:return 0===this.stream.get(n)?"false":"true";case 2:return this.stream.parseInteger(n,n+o);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(n,n+o);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(n,n+o);case 6:return this.stream.parseOID(n,n+o);case 16:case 17:return"("+this.sub.length+" elem)";case 12:return this.stream.parseStringUTF(n,n+o);case 18:case 19:case 20:case 21:case 22:case 26:return this.stream.parseStringISO(n,n+o);case 30:return this.stream.parseStringBMP(n,n+o);case 23:case 24:return this.stream.parseTime(n,n+o)}return null},i.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},i.prototype.print=function(e){if(e===t&&(e=""),document.writeln(e+this),null!==this.sub){e+=" ";for(var i=0,r=this.sub.length;r>i;++i)this.sub[i].print(e)}},i.prototype.toPrettyString=function(e){e===t&&(e="");var i=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(i+="+"),i+=this.length,32&this.tag?i+=" (constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(i+=" (encapsulates)"),i+="\n",null!==this.sub){e+=" ";for(var r=0,s=this.sub.length;s>r;++r)i+=this.sub[r].toPrettyString(e)}return i},i.prototype.toDOM=function(){var t=n.tag("div","node");t.asn1=this;var e=n.tag("div","head"),i=this.typeName().replace(/_/g," ");e.innerHTML=i;var r=this.content();if(null!==r){r=String(r).replace(/</g,"&lt;");var s=n.tag("span","preview");s.appendChild(n.text(r)),e.appendChild(s)}t.appendChild(e),this.node=t,this.head=e;var o=n.tag("div","value");if(i="Offset: "+this.stream.pos+"<br/>",i+="Length: "+this.header+"+",i+=this.length>=0?this.length:-this.length+" (undefined)",32&this.tag?i+="<br/>(constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(i+="<br/>(encapsulates)"),null!==r&&(i+="<br/>Value:<br/><b>"+r+"</b>","object"==typeof oids&&6==this.tag)){var h=oids[r];h&&(h.d&&(i+="<br/>"+h.d),h.c&&(i+="<br/>"+h.c),h.w&&(i+="<br/>(warning!)"))}o.innerHTML=i,t.appendChild(o);var a=n.tag("div","sub");if(null!==this.sub)for(var u=0,c=this.sub.length;c>u;++u)a.appendChild(this.sub[u].toDOM());return t.appendChild(a),e.onclick=function(){t.className="node collapsed"==t.className?"node":"node collapsed"},t},i.prototype.posStart=function(){return this.stream.pos},i.prototype.posContent=function(){return this.stream.pos+this.header},i.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},i.prototype.fakeHover=function(t){this.node.className+=" hover",t&&(this.head.className+=" hover")},i.prototype.fakeOut=function(t){var e=/ ?hover/;this.node.className=this.node.className.replace(e,""),t&&(this.head.className=this.head.className.replace(e,""))},i.prototype.toHexDOM_sub=function(t,e,i,r,s){if(!(r>=s)){var o=n.tag("span",e);o.appendChild(n.text(i.hexDump(r,s))),t.appendChild(o)}},i.prototype.toHexDOM=function(e){var i=n.tag("span","hex");if(e===t&&(e=i),this.head.hexNode=i,this.head.onmouseover=function(){this.hexNode.className="hexCurrent"},this.head.onmouseout=function(){this.hexNode.className="hex"},i.asn1=this,i.onmouseover=function(){var t=!e.selected;t&&(e.selected=this.asn1,this.className="hexCurrent"),this.asn1.fakeHover(t)},i.onmouseout=function(){var t=e.selected==this.asn1;this.asn1.fakeOut(t),t&&(e.selected=null,this.className="hex")},this.toHexDOM_sub(i,"tag",this.stream,this.posStart(),this.posStart()+1),this.toHexDOM_sub(i,this.length>=0?"dlen":"ulen",this.stream,this.posStart()+1,this.posContent()),null===this.sub)i.appendChild(n.text(this.stream.hexDump(this.posContent(),this.posEnd())));else if(this.sub.length>0){var r=this.sub[0],s=this.sub[this.sub.length-1];this.toHexDOM_sub(i,"intro",this.stream,this.posContent(),r.posStart());for(var o=0,h=this.sub.length;h>o;++o)i.appendChild(this.sub[o].toHexDOM(e));this.toHexDOM_sub(i,"outro",this.stream,s.posEnd(),this.posEnd())}return i},i.prototype.toHexString=function(t){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},i.decodeLength=function(t){var e=t.get(),i=127&e;if(i==e)return i;if(i>3)throw"Length over 24 bits not supported at position "+(t.pos-1);if(0===i)return-1;e=0;for(var r=0;i>r;++r)e=e<<8|t.get();return e},i.hasContent=function(t,r,s){if(32&t)return!0;if(3>t||t>4)return!1;var n=new e(s);3==t&&n.get();var o=n.get();if(o>>6&1)return!1;try{var h=i.decodeLength(n);return n.pos-s.pos+h==r}catch(a){return!1}},i.decode=function(t){t instanceof e||(t=new e(t,0));var r=new e(t),s=t.get(),n=i.decodeLength(t),o=t.pos-r.pos,h=null;if(i.hasContent(s,n,t)){var a=t.pos;if(3==s&&t.get(),h=[],n>=0){for(var u=a+n;t.pos<u;)h[h.length]=i.decode(t);if(t.pos!=u)throw"Content size is not correct for container starting at offset "+a}else try{for(;;){var c=i.decode(t);if(0===c.tag)break;h[h.length]=c}n=a-t.pos}catch(f){throw"Exception while decoding undefined length content: "+f}}else t.pos+=n;return new i(r,o,n,s,h)},i.test=function(){for(var t=[{value:[39],expected:39},{value:[129,201],expected:201},{value:[131,254,220,186],expected:16702650}],r=0,s=t.length;s>r;++r){var n=new e(t[r].value,0),o=i.decodeLength(n);o!=t[r].expected&&document.write("In test["+r+"] expected "+t[r].expected+" got "+o+"\n")}},window.ASN1=i}(),ASN1.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,i=2*this.length;return t.substr(e,i)},ue.prototype.parseKey=function(t){try{var e=0,i=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,s=r.test(t)?Hex.decode(t):Base64.unarmor(t),n=ASN1.decode(s);if(3===n.sub.length&&(n=n.sub[2].sub[0]),9===n.sub.length){e=n.sub[1].getHexStringValue(),this.n=he(e,16),i=n.sub[2].getHexStringValue(),this.e=parseInt(i,16);var o=n.sub[3].getHexStringValue();this.d=he(o,16);var h=n.sub[4].getHexStringValue();this.p=he(h,16);var a=n.sub[5].getHexStringValue();this.q=he(a,16);var u=n.sub[6].getHexStringValue();this.dmp1=he(u,16);var c=n.sub[7].getHexStringValue();this.dmq1=he(c,16);var f=n.sub[8].getHexStringValue();this.coeff=he(f,16)}else{if(2!==n.sub.length)return!1;var p=n.sub[1],l=p.sub[0];e=l.sub[0].getHexStringValue(),this.n=he(e,16),i=l.sub[1].getHexStringValue(),this.e=parseInt(i,16)}return!0}catch(d){return!1}},ue.prototype.getPrivateBaseKey=function(){var t={array:[new KJUR.asn1.DERInteger({"int":0}),new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e}),new KJUR.asn1.DERInteger({bigint:this.d}),new KJUR.asn1.DERInteger({bigint:this.p}),new KJUR.asn1.DERInteger({bigint:this.q}),new KJUR.asn1.DERInteger({bigint:this.dmp1}),new KJUR.asn1.DERInteger({bigint:this.dmq1}),new KJUR.asn1.DERInteger({bigint:this.coeff})]},e=new KJUR.asn1.DERSequence(t);return e.getEncodedHex()},ue.prototype.getPrivateBaseKeyB64=function(){return be(this.getPrivateBaseKey())},ue.prototype.getPublicBaseKey=function(){var t={array:[new KJUR.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new KJUR.asn1.DERNull]},e=new KJUR.asn1.DERSequence(t);t={array:[new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e})]};var i=new KJUR.asn1.DERSequence(t);t={hex:"00"+i.getEncodedHex()};var r=new KJUR.asn1.DERBitString(t);t={array:[e,r]};var s=new KJUR.asn1.DERSequence(t);return s.getEncodedHex()},ue.prototype.getPublicBaseKeyB64=function(){return be(this.getPublicBaseKey())},ue.prototype.wordwrap=function(t,e){if(e=e||64,!t)return t;var i="(.{1,"+e+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(i,"g")).join("\n")},ue.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return t+=this.wordwrap(this.getPrivateBaseKeyB64())+"\n",t+="-----END RSA PRIVATE KEY-----"},ue.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return t+=this.wordwrap(this.getPublicBaseKeyB64())+"\n",t+="-----END PUBLIC KEY-----"},ue.prototype.hasPublicKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")},ue.prototype.hasPrivateKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},ue.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)};var _e=function(t){ue.call(this),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))};_e.prototype=new ue,_e.prototype.constructor=_e;var ze=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null};ze.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new _e(t)},ze.prototype.setPrivateKey=function(t){this.setKey(t)},ze.prototype.setPublicKey=function(t){this.setKey(t)},ze.prototype.decrypt=function(t){try{return this.getKey().decrypt(Te(t))}catch(e){return!1}},ze.prototype.encrypt=function(t){try{return be(this.getKey().encrypt(t))}catch(e){return!1}},ze.prototype.getKey=function(t){if(!this.key){if(this.key=new _e,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},ze.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},ze.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},ze.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},ze.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},ze.version="2.3.0",t.JSEncrypt=ze}(JSEncryptExports),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e:"function"==typeof define&&define.amd?define(e):t.JSEncrypt=e}(this,JSEncryptExports.JSEncrypt);
INTERMediatorOnPage.getEditorPath=function(){return '';};
INTERMediatorOnPage.getEntryPath=function(){return "/member/im_include_research.php";};
INTERMediatorOnPage.getTheme=function(){return "redb";};
INTERMediatorOnPage.getDataSources=function(){return {'0':{'records':'1','name':'staff','key':'id','query':{},'sort':{'0':{'field':'id','direction':'asc'}},'authentication':{'all':{'target':'field-user','field':'email'}}},'1':{'name':'management','key':'id'},'2':{'name':'gakubu','relation':{'0':{'foreign-key':'id','join-field':'gakubu_id','operator':'='}}},'3':{'name':'gakka','relation':{'0':{'foreign-key':'id','join-field':'gakka_id','operator':'='}}},'4':{'name':'title','relation':{'0':{'foreign-key':'id','join-field':'title_id','operator':'='}}},'5':{'name':'category','view':'research_category','table':'research_category','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}}},'6':{'name':'keyword','view':'research_keyword','table':'research_keyword','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'キーワードを追加'}},'7':{'name':'theme','view':'research_theme','table':'research_theme','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'テーマを追加'}},'8':{'name':'society','view':'academic_society','table':'academic_society','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'学会を追加'}},'9':{'records':'5','name':'paper','table':'book_paper','view':'book_paper','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','button-names':{'insert':'業績を追加'}},'10':{'records':'5','name':'exhibition_society','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','validation':{'0':{'field':'is_period','rule':'1'}},'post-repeater':'expandRecordHavingIsPeriod','button-names':{'insert':'業績を追加'}},'11':{'records':'5','name':'research_fund','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','validation':{'0':{'field':'fund','rule':'1','message':'半角数値で入力してください'},'1':{'field':'is_period','rule':'1'}},'post-repeater':'expandRecordHavingIsPeriod','button-names':{'insert':'業績を追加'}},'12':{'name':'patent','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','button-names':{'insert':'業績を追加'}}};};
INTERMediatorOnPage.getOptionsAliases=function(){return {};};
INTERMediatorOnPage.getOptionsTransaction=function(){return '';};
INTERMediatorOnPage.dbClassName="DB_PDO";
INTERMediatorOnPage.defaultKeyName="";
INTERMediatorOnPage.isEmailAsUsername=false;
INTERMediatorOnPage.getMessages=function(){return {'1':'Record #','2':'Refresh','3':'Add Record','4':'Delete Record','5':'Insert','6':'Delete','7':'Save','8':'Login as: ','9':'Logout','10':'Move to page:','11':'','12':'Detail','13':'Show List','14':'Copy','15':'Copy Record','1001':'Other people might be updated.\n\nInitially=@1@\nCurrent=@2@\nDatabase=@3@\n\nYou can overwrite with your data if you select OK.','1002':'Can\'t determine the Table Name: @1@','1003':'No information to update: field=@1@','1004':'Connection Error in db_query=@1@\/@2@','1005':'On calling db_query, Required parameter \'name\' doesn\'t specified','1006':'On calling db_query, Required parameter \'table\' doesn\'t specified','1007':'On calling db_update, Required parameter \'name\' doesn\'t specified','1008':'On calling db_update, Required parameter \'conditions\' doesn\'t specified','1009':'On calling db_update, Required parameter \'operator\' doesn\'t specified','1010':'On calling db_update, Required parameter \'value\' doesn\'t specified','1011':'On calling db_update, Required parameter \'dataset\' doesn\'t specified','1012':'Query Access: ','1013':'Update Access: ','1014':'Connection Error in db_update=@1@\/@2@','1015':'Connection Error in db_delete=@1@\/@2@','1016':'Connection Error in db_createRecord=@1@\/@2@','1017':'Delete Access: ','1018':'Create Record Access: ','1019':'On calling db_delete, Required parameter \'name\' doesn\'t specified','1020':'On calling db_delete, Required parameter \'conditions\' doesn\'t specified','1021':'On calling db_createRecord, Required parameter \'name\' doesn\'t specified','1022':'Using Unsupported Browser (Try not to use the compatibility mode of Internet Explorer)','1023':'[This site uses INTER-Mediator.]','1024':'Multiple records are going to be updated. The key field might be wrong. Are you sure?','1025':'Are you sure to delete?','1026':'Are you sure to create record?','1027':'Get Challenge: ','1028':'Connection Error in get_challenge=@1@\/@2@','1029':'Change Password Access: ','1030':'Connection Error on changing password=@1@\/@2@','1031':'Change File Uploading: ','1032':'Connection Error on uploading file=@1@\/@2@','1033':'The field name specified in the page file doesn\'t exist [folder=@1@]','1034':'Other people might be updated.\n\n@1@\n\nYou can overwrite with your data if you select OK.','1035':'field=@1@, initial value=@2@, current value=@3@\n','1036':'field=@1@, expression=@2@ happens a parse error.','1037':'A cyclic referencing is detected.','1038':'Preparing the Pusher, although the settings in the server side is available, the client library isn\'t included.','1039':'Preparing the Pusher, although the client library is included, the settings in the server side is not available.','1040':'The field \'@2@\' in the context \'@1@\' does not exist in the table.','1041':'Are you sure to copy this record?','1042':'The database class doesn\'t support aggregation-select\/from\/group-by.','1043':'Both aggregation-select and aggregation-from are required. One of them doesn\'t exist in the context definition.','1044':'The context having aggregation-select\/from\/group-by is read-only.','1045':'The \'key\' is required in the context definition if writing operations apply to the context \'@1@\'.','1046':'The context definition of the name \'@1@\' in target specifications of the page file is undefined in the definition file.','1047':'The context \'@1@\' was chosen for this context, and ignored target specifications were: @2@','2001':'Authentication Error!','2002':'User:','2003':'Password:','2004':'Login','2005':'Change Password','2006':'New Password:','2007':'Missing any of Username, old and new password.','2008':'Failure to get a challenge from server.','2009':'Succeed to change your password. Login with the new password.','2010':'Failure to change your password. Maybe the old password is not correct.','2011':'User(Mail Address):','2012':'Retry to login. You should clarify the user and the password.','2013':'You should input user and\/or password.','2014':'OAuth Login','2015':'Any alphabets have to contain in new password.','2016':'Any numbers have to contain in new password.','2017':'Any upper case alphabets have to contain in new password.','2018':'Any lower case alphabets have to contain in new password.','2019':'Any punctuations have to contain in new password.','2020':'New password have to differ from the user name.','2021':'New password have to contain more than @1@ characters.','2022':'Enrollment this site with email','2023':'Reset my password','2024':'You need to prepare your email address.','2025':'Require a 2048-bit private key at least for authentication','3101':'Drag Here.','3102':'Dragged File: ','3201':'Exceeded post size limit. Check the post_max_size in php.ini file.','3202':'No file wasn\'t uploaded. Possibly, exceeded file size limit.','3203':'Exceeded file size limit. Check the upload_max_filesize in php.ini file.','3204':'Partially uploaded.','3205':'Temporary directory doesn\'t exist.','3206':'Can\'t write to disk or file system.','3207':'Extension module prevents to upload.','3208':'Unknown error in file uploading.','3209':'Select File...','3210':'Selected File: ','3211':'Upload'};};
INTERMediatorOnPage.browserCompatibility=function(){return {'edge':'12+','trident':'4+','chrome':'1+','firefox':'2+','safari':'4+','opera':'1+','webkit':'1+'};};
INTERMediatorOnPage.clientNotificationIdentifier=function(){return '691702fed0565fd6aac03e53d2884c360b170b172eccb52da8ec18108b1d1cce';};
INTERMediatorOnPage.metadata={version:"5.12",releasedate:"2021-08-15"};
INTERMediatorLog.debugMode=false;
INTERMediatorOnPage.appLocale="ja_JP";
INTERMediatorOnPage.localeInfo=JSON.parse('{"decimal_point":".","thousands_sep":",","int_curr_symbol":"JPY ","currency_symbol":"\uffe5","mon_decimal_point":".","mon_thousands_sep":",","positive_sign":"","negative_sign":"-","int_frac_digits":0,"frac_digits":0,"p_cs_precedes":1,"p_sep_by_space":0,"n_cs_precedes":1,"n_sep_by_space":0,"p_sign_posn":1,"n_sign_posn":1,"grouping":[3],"mon_grouping":[3],"DAY":["\u65e5\u66dc\u65e5","\u6708\u66dc\u65e5","\u706b\u66dc\u65e5","\u6c34\u66dc\u65e5","\u6728\u66dc\u65e5","\u91d1\u66dc\u65e5","\u571f\u66dc\u65e5"],"ABDAY":["\u65e5","\u6708","\u706b","\u6c34","\u6728","\u91d1","\u571f"],"MON":["\u7766\u6708","\u5982\u6708","\u5f25\u751f","\u536f\u6708","\u7690\u6708","\u6c34\u7121\u6708","\u6587\u6708","\u8449\u6708","\u9577\u6708","\u795e\u7121\u6708","\u971c\u6708","\u5e2b\u8d70"],"ABMON":["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"],"AM_STR":"\u5348\u524d","PM_STR":"\u5348\u5f8c","D_FMT_LONG":"%Y\u5e74%M\u6708%D\u65e5 %W","T_FMT_LONG":"%H\u6642%I\u5206%S\u79d2","D_FMT_MIDDLE":"%Y\/%M\/%D(%w)","T_FMT_MIDDLE":"%H:%I:%S","D_FMT_SHORT":"%Y\/%m\/%d","T_FMT_SHORT":"%H:%I"}');
INTERMediatorOnPage.appCurrency="JP";
INTERMediatorOnPage.requireAuthentication=true;
INTERMediatorOnPage.authRequiredContext={'0':'staff'};
INTERMediatorOnPage.isLDAP=false;
INTERMediatorOnPage.isOAuthAvailable=false;
INTERMediatorOnPage.isNativeAuth=false;
INTERMediatorOnPage.authStoring="cookie-domainwide";
INTERMediatorOnPage.authExpired=3600;
INTERMediatorOnPage.realm="";
INTERMediatorOnPage.publickey='-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnEpCZny+NQy+aCVGivertUIt9OrI/aDpAjT7s1UYLEERFXcfFs1A9VdIowUeg3NyJxAOxbLk6RXczoVoULEte2HB/roFg7V/sVG9rjx5F4im0JLqEyvuSLTeSx3TGkIr0NHmNAO/SQrfnBiUjdkugn2WCuvQHe06wfHXWg3Pck4JS0Y6vNQz//Ny7nZVfAWRkiFtb7ZilvSWXmmFuoG3xH6IeFBMaJBcFENK58bGQaQTcfg9qzpHhzCQwqbURYSH8WzAZlPRUo1lBZ4WEpMqGWYOiiiqOlc0v+2pW5BNvu3fk8DQbGwJIywC12nfhFKZH2txv0o0hx2ukXA+nBMQLQIDAQAB-----END PUBLIC KEY-----';
INTERMediatorOnPage.publickeysize=2048;

Unexpected token '/', "/*
* INTE"... is not valid JSON - Connection Error in db_query=SyntaxError: Unexpected token '/', "/*
* INTE"... is not valid JSON//*
* INTER-Mediator
* Copyright (c) INTER-Mediator Directive Committee (http://inter-mediator.org)
* This project started at the end of 2009 by Masayuki Nii msyk@msyk.net.
*
* INTER-Mediator is supplied under MIT License.
* Please see the full license for details:
* https://github.com/INTER-Mediator/INTER-Mediator/blob/master/dist-docs/License.txt
*/
var INTERMediator={separator:'@',defDivider:'|',defaultTargetInnerHTML:!1,navigationLabel:null,elementIds:[],dontSelectRadioCheck:!1,ignoreOptimisticLocking:!1,additionalFieldValueOnNewRecord:{},additionalFieldValueOnUpdate:{},additionalFieldValueOnDelete:{},waitSecondsAfterPostMessage:4,pagedAllCount:0,totalRecordCount:null,currentEncNumber:0,isIE:!1,isTrident:!1,isEdge:!1,ieVersion:-1,titleAsLinkInfo:!0,classAsLinkInfo:!0,isDBDataPreferable:!1,noRecordClassName:'_im_for_noresult_',rootEnclosure:null,useSessionStorage:!0,partialConstructing:!0,linkedElmCounter:0,pusherObject:null,buttonIdNum:0,masterNodeOriginalDisplay:'block',detailNodeOriginalDisplay:'none',pusherAvailable:!1,dateTimeFunction:!1,postOnlyNumber:1,isTablet:!1,isMobile:!1,crossTableStage:0,eventListenerPostAdding:null,appendingNodesAtLast:null,propertyIETridentSetup:function(){'use strict';var ua,position,c,i;ua=navigator.userAgent;position=ua.toLocaleUpperCase().indexOf('MSIE');if(position>=0){INTERMediator.isIE=!0;for(i=position+4;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+4,i));break}}}
position=ua.indexOf('; Trident/');if(position>=0){INTERMediator.isTrident=!0;for(i=position+10;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+10,i))+4;if(INTERMediator.ieVersion===11){INTERMediator.isIE=!0}
break}}}
position=ua.indexOf(' Edge/');if(position>=0){INTERMediator.isEdge=!0;for(i=position+6;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))||i===ua.length-1){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+6,i));break}}}},propertyW3CUserAgentSetup:function(){'use strict';var u=window.navigator.userAgent.toLowerCase();INTERMediator.isTablet=(u.indexOf('windows')>-1&&u.indexOf('touch')>-1&&u.indexOf('tablet pc')===-1)||u.indexOf('ipad')>-1||(u.indexOf('android')>-1&&u.indexOf('mobile')===-1)||(u.indexOf('firefox')>-1&&u.indexOf('tablet')>-1)||u.indexOf('kindle')>-1||u.indexOf('silk')>-1||u.indexOf('playbook')>-1;INTERMediator.isMobile=(u.indexOf('windows')>-1&&u.indexOf('phone')>-1)||u.indexOf('iphone')>-1||u.indexOf('ipod')>-1||(u.indexOf('android')>-1&&u.indexOf('mobile')>-1)||(u.indexOf('firefox')>-1&&u.indexOf('mobile')>-1)||u.indexOf('blackberry')>-1},initialize:function(){'use strict';INTERMediatorOnPage.removeCookie('_im_localcontext');INTERMediator.additionalCondition={};INTERMediator.additionalSortKey={};INTERMediator.startFrom=0;IMLibLocalContext.archive()},construct:function(indexOfKeyFieldObject){'use strict';var timerTask;if(indexOfKeyFieldObject===!0||indexOfKeyFieldObject===undefined){if(INTERMediatorOnPage.isFinishToConstruct){return}
INTERMediatorOnPage.isFinishToConstruct=!0;timerTask=function(){INTERMediator.constructMain(!0)}}else{timerTask=function(){INTERMediator.constructMain(indexOfKeyFieldObject)}}
setTimeout(timerTask,0)},constructMain:function(updateRequiredContext,recordset){'use strict';var i,theNode,postSetFields=[],radioName={},nameSerial=1,nameAttrCounter=1,imPartsShouldFinished=[],isAcceptNotify=!1,originalNodes,parentNode,sybilingNode;INTERMediator.eventListenerPostAdding=[];if(INTERMediatorOnPage.doBeforeConstruct){INTERMediatorOnPage.doBeforeConstruct()}
if(!INTERMediatorOnPage.isAutoConstruct){return}
INTERMediatorOnPage.showProgress();INTERMediator.crossTableStage=0;INTERMediator.appendingNodesAtLast=[];IMLibEventResponder.setup();INTERMediatorOnPage.retrieveAuthInfo();try{if(Pusher.VERSION){INTERMediator.pusherAvailable=!0;if(!INTERMediatorOnPage.clientNotificationKey){INTERMediatorLog.setErrorMessage(Error('Pusher Configuration Error'),INTERMediatorOnPage.getMessages()[1039]);INTERMediator.pusherAvailable=!1}}}catch(ex){INTERMediator.pusherAvailable=!1;if(INTERMediatorOnPage.clientNotificationKey){INTERMediatorLog.setErrorMessage(Error('Pusher Configuration Error'),INTERMediatorOnPage.getMessages()[1038])}}
try{if(updateRequiredContext===!0||updateRequiredContext===undefined){IMLibPageNavigation.deleteInsertOnNavi=[];INTERMediator.partialConstructing=!1;INTERMediator.buttonIdNum=1;IMLibContextPool.clearAll();pageConstruct()}else{IMLibPageNavigation.deleteInsertOnNavi=[];INTERMediator.partialConstructing=!0;postSetFields=[];try{if(!recordset){updateRequiredContext.removeContext();originalNodes=updateRequiredContext.original;for(i=0;i<originalNodes.length;i++){updateRequiredContext.enclosureNode.appendChild(originalNodes[i].cloneNode(!0))}
seekEnclosureNode(updateRequiredContext.enclosureNode,updateRequiredContext.foreignValue,updateRequiredContext.dependingParentObjectInfo,updateRequiredContext)}else{expandRepeaters(updateRequiredContext,updateRequiredContext.enclosureNode,{recordset:recordset,targetTotalCount:1,targetCount:1})}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-8')}}
for(i=0;i<postSetFields.length;i++){if(postSetFields[i].id&&document.getElementById(postSetFields[i].id)){document.getElementById(postSetFields[i].id).value=postSetFields[i].value}}
IMLibCalc.updateCalculationFields()}}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.hideProgress();INTERMediatorOnPage.authenticating(function(){INTERMediator.constructMain(updateRequiredContext)});INTERMediator.partialConstructing=!0;return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-7');INTERMediator.partialConstructing=!0}}
for(i=0;i<imPartsShouldFinished.length;i++){imPartsShouldFinished[i].finish()}
for(i=0;i<INTERMediator.appendingNodesAtLast.length;i++){theNode=INTERMediator.appendingNodesAtLast[i].targetNode;parentNode=INTERMediator.appendingNodesAtLast[i].parentNode;sybilingNode=INTERMediator.appendingNodesAtLast[i].siblingNode;if(theNode&&parentNode){if(sybilingNode){parentNode.insertBefore(theNode,sybilingNode)}else{parentNode.appendChild(theNode)}}}
for(i=0;i<INTERMediator.eventListenerPostAdding.length;i++){theNode=document.getElementById(INTERMediator.eventListenerPostAdding[i].id);if(theNode){INTERMediatorLib.addEvent(theNode,INTERMediator.eventListenerPostAdding[i].event,INTERMediator.eventListenerPostAdding[i].todo)}}
if(INTERMediatorOnPage.doAfterConstruct){INTERMediatorOnPage.doAfterConstruct()}
IMLibPageNavigation.navigationSetup();INTERMediatorOnPage.isFinishToConstruct=!1;INTERMediator.partialConstructing=!0;INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage();function pageConstruct(){var i,bodyNode,emptyElement;IMLibCalc.calculateRequiredObject={};INTERMediator.currentEncNumber=1;INTERMediator.elementIds=[];bodyNode=document.getElementsByTagName('BODY')[0];if(!INTERMediator.rootEnclosure){INTERMediator.rootEnclosure=bodyNode.innerHTML}else{bodyNode.innerHTML=INTERMediator.rootEnclosure}
postSetFields=[];INTERMediatorOnPage.setReferenceToTheme();IMLibPageNavigation.initializeStepInfo(!1);IMLibLocalContext.bindingDescendant(document.documentElement);try{seekEnclosureNode(bodyNode,null,null,null)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-9')}}
for(i=0;i<postSetFields.length;i++){if(postSetFields[i].value===''&&document.getElementById(postSetFields[i].id).tagName==='SELECT'){emptyElement=document.createElement('option');emptyElement.setAttribute('id',INTERMediator.nextIdValue());emptyElement.setAttribute('value','');emptyElement.setAttribute('data-im-element','auto-generated');document.getElementById(postSetFields[i].id).insertBefore(emptyElement,document.getElementById(postSetFields[i].id).firstChild)}
document.getElementById(postSetFields[i].id).value=postSetFields[i].value}
IMLibCalc.updateCalculationFields();if(isAcceptNotify&&INTERMediator.pusherAvailable){var channelName=INTERMediatorOnPage.clientNotificationIdentifier();var appKey=INTERMediatorOnPage.clientNotificationKey();if(appKey&&appKey!=='_im_key_isnt_supplied'&&!INTERMediator.pusherObject){try{Pusher.log=function(message){if(window.console&&window.console.log){window.console.log(message)}};INTERMediator.pusherObject=new Pusher(appKey);INTERMediator.pusherChannel=INTERMediator.pusherObject.subscribe(channelName);INTERMediator.pusherChannel.bind('update',function(data){IMLibContextPool.updateOnAnotherClient('update',data)});INTERMediator.pusherChannel.bind('create',function(data){IMLibContextPool.updateOnAnotherClient('create',data)});INTERMediator.pusherChannel.bind('delete',function(data){IMLibContextPool.updateOnAnotherClient('delete',data)})}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-47')}}}
appendCredit()}
function seekEnclosureNode(node,currentRecord,parentObjectInfo,currentContextObj){var children,className,i,attr;if(node.nodeType===1){try{if(INTERMediatorLib.isEnclosure(node,!1)){className=INTERMediatorLib.getClassAttributeFromNode(node);attr=node.getAttribute('data-im-control');if((className&&className.match(/_im_post/))||(attr&&attr.indexOf('post')>=0)){setupPostOnlyEnclosure(node)}else{if(INTERMediator.isIE){try{expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}}}else{expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}}}else{children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){seekEnclosureNode(children[i],currentRecord,parentObjectInfo,currentContextObj)}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-10')}}}}
function setupPostOnlyEnclosure(node){var nodes,postNodes;postNodes=INTERMediatorLib.getElementsByClassNameOrDataAttr(node,'_im_post');for(i=0;i<postNodes.length;i++){if(postNodes[i].tagName==='BUTTON'||(postNodes[i].tagName==='INPUT'&&(postNodes[i].getAttribute('type').toLowerCase()==='button'||postNodes[i].getAttribute('type').toLowerCase()==='submit'))){if(!postNodes[i].id){postNodes[i].id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(postNodes[i].id,(function(){var targetNode=postNodes[i];return function(){IMLibUI.clickPostOnlyButton(targetNode)}})())}}
nodes=node.childNodes;for(i=0;i<nodes.length;i++){seekEnclosureInPostOnly(nodes[i])}
function seekEnclosureInPostOnly(node){var children,wInfo,i,target;if(node.nodeType===1){try{target=node.getAttribute('data-im');if(!target){target=node.getAttribute('data-im-group')}
if(target){if(!node.id){node.id='IMPOST-'+INTERMediator.postOnlyNumber;INTERMediator.postOnlyNumber++}
INTERMediatorLib.addEvent(node,'blur',function(){var idValue=node.id;IMLibUI.valueChange(idValue,!0)});if(node.tagName==='INPUT'&&node.getAttribute('type')==='radio'){if(!radioName[target]){radioName[target]='Name-'+nameSerial;nameSerial++}
node.setAttribute('name',radioName[target])}}
if(INTERMediatorLib.isWidgetElement(node)){wInfo=INTERMediatorLib.getWidgetInfo(node);if(wInfo[0]){IMParts_Catalog[wInfo[0]].instanciate(node);if(imPartsShouldFinished.indexOf(IMParts_Catalog[wInfo[0]])<0){imPartsShouldFinished.push(IMParts_Catalog[wInfo[0]])}}}else if(INTERMediatorLib.isEnclosure(node,!1)){expandEnclosure(node,null,null,null)}else{children=node.childNodes;for(i=0;i<children.length;i++){seekEnclosureInPostOnly(children[i])}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-11')}}}}}
function expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj){var recId,repNodeTag,repeatersOriginal;var imControl=node.getAttribute('data-im-control');if(currentContextObj&&currentContextObj.contextName&&currentRecord&&currentRecord[currentContextObj.contextName]&&currentRecord[currentContextObj.contextName][currentContextObj.contextName+'::'+INTERMediatorOnPage.defaultKeyName]){recId=currentRecord[currentContextObj.contextName][currentContextObj.contextName+'::'+INTERMediatorOnPage.defaultKeyName];currentRecord=currentRecord[currentContextObj.contextName][recId]}
if(imControl&&imControl.match(/cross-table/)){expandCrossTableEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}else{repNodeTag=INTERMediatorLib.repeaterTagFromEncTag(node.tagName);repeatersOriginal=collectRepeatersOriginal(node,repNodeTag);enclosureProcessing(node,repeatersOriginal,currentRecord,parentObjectInfo,currentContextObj)}
IMLibLocalContext.bindingDescendant(node);function enclosureProcessing(enclosureNode,repeatersOriginal,currentRecord,parentObjectInfo,currentContextObj,procBeforeRetrieve,customExpandRepeater){var linkedNodes,repeaters,linkDefs,voteResult,currentContextDef,fieldList,i,targetRecords,newNode,keyValue,selectedNode,isExpanding,calcFields,contextObj=null,targetRecordset,ix,keyingValue,footerNodes,headerNodes,nInfo;var tempObj={};repeaters=collectRepeaters(repeatersOriginal);linkedNodes=INTERMediatorLib.seekLinkedAndWidgetNodes(repeaters,!0).linkedNode;linkDefs=collectLinkDefinitions(linkedNodes);voteResult=tableVoting(linkDefs);currentContextDef=voteResult.targettable;INTERMediator.currentEncNumber++;if(!enclosureNode.getAttribute('id')){enclosureNode.setAttribute('id',INTERMediator.nextIdValue())}
if(!currentContextDef){for(i=0;i<repeatersOriginal.length;i++){newNode=enclosureNode.appendChild(repeatersOriginal[i]);if(repeatersOriginal[i].getAttribute('selected')){selectedNode=newNode}
if(selectedNode!==undefined){selectedNode.selected=!0}
seekEnclosureNode(newNode,null,enclosureNode,currentContextObj)}}else{isExpanding=!IMLibPageNavigation.isNotExpandingContext(currentContextDef);contextObj=IMLibContextPool.generateContextObject(currentContextDef,enclosureNode,repeaters,repeatersOriginal);calcFields=contextObj.getCalculationFields();fieldList=voteResult.fieldlist.map(function(elm){if(!calcFields[elm]){calcFields.push(elm)}
return elm});if(currentContextDef.relation&&currentContextDef.relation[0]&&Boolean(currentContextDef.relation[0].portal)===!0){contextObj.isPortal=!0;if(!currentRecord){tempObj=IMLibContextPool.generateContextObject({'name':contextObj.sourceName},enclosureNode,repeaters,repeatersOriginal);if(targetRecords===undefined){targetRecords=retrieveDataForEnclosure(tempObj,fieldList,contextObj.foreignValue)}
recId=targetRecords.recordset[0][INTERMediatorOnPage.defaultKeyName];currentRecord=targetRecords.recordset[0]}}
contextObj.setRelationWithParent(currentRecord,parentObjectInfo,currentContextObj);if(contextObj.isPortal===!0){if(currentRecord){currentContextDef.currentrecord=currentRecord;keyValue=currentRecord[currentContextDef.relation[0]['join-field']]}}
if(procBeforeRetrieve){procBeforeRetrieve(contextObj)}
if(isExpanding){targetRecords=retrieveDataForEnclosure(contextObj,fieldList,contextObj.foreignValue)}else{targetRecords=[];if(enclosureNode.tagName==='TBODY'){enclosureNode.parentNode.style.display='none'}else{enclosureNode.style.display='none'}}
contextObj.storeRecords(targetRecords);callbackForAfterQueryStored(currentContextDef,contextObj);if(customExpandRepeater===undefined){contextObj.registeredId=targetRecords.registeredId;contextObj.nullAcceptable=targetRecords.nullAcceptable;isAcceptNotify|=!(INTERMediatorOnPage.notifySupport===!1);expandRepeaters(contextObj,enclosureNode,targetRecords);IMLibPageNavigation.setupInsertButton(contextObj,keyValue,enclosureNode,contextObj.foreignValue);IMLibPageNavigation.setupBackNaviButton(contextObj,enclosureNode);callbackForEnclosure(currentContextDef,enclosureNode)}else{customExpandRepeater(contextObj,targetRecords)}
contextObj.sequencing=!1;if(enclosureNode.tagName==='TBODY'){footerNodes=enclosureNode.parentNode.getElementsByTagName('TFOOT');linkedNodes=seekWithAttribute(footerNodes[0],'data-im');if(linkedNodes){INTERMediator.setIdValue(footerNodes[0]);targetRecordset={};ix=null;keyingValue='_im_footer';for(i=0;i<linkedNodes.length;i++){nInfo=INTERMediatorLib.getNodeInfoArray(INTERMediatorLib.getLinkedElementInfo(linkedNodes[i])[0]);if(linkedNodes[i]&&currentContextDef.name===nInfo.table){INTERMediator.setIdValue(linkedNodes[i])}
IMLibCalc.updateCalculationInfo(contextObj,keyingValue,linkedNodes[i].id,nInfo,targetRecordset);if(contextObj.binding._im_footer){contextObj.binding._im_footer._im_repeater=footerNodes}}}
headerNodes=enclosureNode.parentNode.getElementsByTagName('THEAD');linkedNodes=seekWithAttribute(headerNodes[0],'data-im');if(linkedNodes){INTERMediator.setIdValue(headerNodes[0]);targetRecordset={};ix=null;keyingValue='_im_header';for(i=0;i<linkedNodes.length;i++){INTERMediator.setIdValue(linkedNodes[i]);nInfo=INTERMediatorLib.getNodeInfoArray(INTERMediatorLib.getLinkedElementInfo(linkedNodes[i])[0]);IMLibCalc.updateCalculationInfo(contextObj,keyingValue,linkedNodes[i].id,nInfo,targetRecordset);if(contextObj.binding._im_header){contextObj.binding._im_header._im_repeater=headerNodes}}}}}
return contextObj}
function seekWithAttribute(node,attrName){if(!node||node.nodeType!==1){return null}
var result=seekWithAttributeImpl(node,attrName);return result}
function seekWithAttributeImpl(node,attrName){var ix,adding,result=[];if(node&&node.nodeType===1){if(node.getAttribute(attrName)){result.push(node)}
if(node.childNodes){for(ix=0;ix<node.childNodes.length;ix++){adding=seekWithAttributeImpl(node.childNodes[ix],attrName);if(adding.length>0){[].push.apply(result,adding)}}}}
return result}
function expandCrossTableEnclosure(node,currentRecord,parentObjectInfo,currentContextObj){var i,j,colArray,rowArray,nodeForKeyValues,record,targetRepeater,lineNode,colContext,rowContext,appendingNode,trNodes,repeaters,linkedNodes,linkDefs,crossCellContext,labelKeyColumn,labelKeyRow;var ctComponentNodes=crossTableComponents(node);if(ctComponentNodes.length!==4){throw 'Exception-xx: Cross Table Components aren\'t prepared.'}
while(node.childNodes.length>0){node.removeChild(node.childNodes[0])}
repeaters=collectRepeaters([ctComponentNodes[3].cloneNode(!0)]);linkedNodes=INTERMediatorLib.seekLinkedAndWidgetNodes(repeaters,!0).linkedNode;linkDefs=collectLinkDefinitions(linkedNodes);crossCellContext=tableVoting(linkDefs).targettable;labelKeyColumn=crossCellContext.relation[0]['join-field'];labelKeyRow=crossCellContext.relation[1]['join-field'];INTERMediator.crossTableStage=1;lineNode=document.createElement('TR');targetRepeater=ctComponentNodes[0].cloneNode(!0);lineNode.appendChild(targetRepeater);node.appendChild(lineNode);targetRepeater=ctComponentNodes[1].cloneNode(!0);colContext=enclosureProcessing(lineNode,[targetRepeater],null,parentObjectInfo,currentContextObj);colArray=colContext.indexingArray(labelKeyColumn);INTERMediator.crossTableStage=2;targetRepeater=ctComponentNodes[2].cloneNode(!0);lineNode=document.createElement('TR');lineNode.appendChild(targetRepeater);rowContext=enclosureProcessing(node,[lineNode],null,parentObjectInfo,currentContextObj);rowArray=rowContext.indexingArray(labelKeyRow);INTERMediator.crossTableStage=3;targetRepeater=ctComponentNodes[3].cloneNode(!0);nodeForKeyValues={};trNodes=node.getElementsByTagName('TR');for(i=1;i<trNodes.length;i+=1){for(j=0;j<colArray.length;j+=1){appendingNode=targetRepeater.cloneNode(!0);trNodes[i].appendChild(appendingNode);INTERMediator.setIdValue(appendingNode);if(!nodeForKeyValues[colArray[j]]){nodeForKeyValues[colArray[j]]={}}
nodeForKeyValues[colArray[j]][rowArray[i-1]]=appendingNode}}
INTERMediator.setIdValue(node);enclosureProcessing(node,[targetRepeater],null,parentObjectInfo,currentContextObj,function(context){var currentContextDef=context.getContextDef();INTERMediator.clearCondition(currentContextDef.name,'_imlabel_crosstable');INTERMediator.addCondition(currentContextDef.name,{field:currentContextDef.relation[0]['foreign-key'],operator:'IN',value:colArray,onetime:!0},undefined,'_imlabel_crosstable');INTERMediator.addCondition(currentContextDef.name,{field:currentContextDef.relation[1]['foreign-key'],operator:'IN',value:rowArray,onetime:!0},undefined,'_imlabel_crosstable')},function(contextObj,targetRecords){var dataKeyColumn,dataKeyRow,currentContextDef,ix,linkedElements,targetNode,keyField,keyValue,keyingValue;currentContextDef=contextObj.getContextDef();keyField=contextObj.getKeyField();dataKeyColumn=currentContextDef.relation[0]['foreign-key'];dataKeyRow=currentContextDef.relation[1]['foreign-key'];if(targetRecords.recordset){for(ix=0;ix<targetRecords.recordset.length;ix++){record=targetRecords.recordset[ix];if(nodeForKeyValues[record[dataKeyColumn]]&&nodeForKeyValues[record[dataKeyColumn]][record[dataKeyRow]]){targetNode=nodeForKeyValues[record[dataKeyColumn]][record[dataKeyRow]];if(targetNode){linkedElements=INTERMediatorLib.seekLinkedAndWidgetNodes([targetNode],!1);keyValue=record[keyField];if(keyField&&!keyValue&&keyValue!==0){keyValue=ix}
keyingValue=keyField+'='+keyValue}
setupLinkedNode(linkedElements,contextObj,targetRecords.recordset,ix,keyingValue)}}}})}
function crossTableComponents(node){var components=[],count=0;repeatCTComponents(node.childNodes);return components;function repeatCTComponents(nodes){var childNodes,i;for(i=0;i<nodes.length;i++){if(nodes[i].nodeType===1&&(nodes[i].tagName==='TH'||nodes[i].tagName==='TD')){components[count]=nodes[i];count+=1}else{childNodes=nodes[i].childNodes;if(childNodes){repeatCTComponents(childNodes)}}}}}}
function setupLinkedNode(linkedElements,contextObj,targetRecordset,ix,keyingValue){var currentWidgetNodes,currentLinkedNodes,nInfo,currentContextDef,j,keyField,k,nodeId,curVal,replacedNode,typeAttr,children,wInfo,nameTable,idValuesForFieldName={},linkInfoArray,nameTableKey,nameNumber,nameAttr,curTarget;currentContextDef=contextObj.getContextDef();try{currentWidgetNodes=linkedElements.widgetNode;currentLinkedNodes=linkedElements.linkedNode;keyField=contextObj.getKeyField();if(targetRecordset[ix]&&(targetRecordset[ix][keyField]||targetRecordset[ix][keyField]===0)){for(k=0;k<currentLinkedNodes.length;k++){nodeId=currentLinkedNodes[k].getAttribute('id');replacedNode=INTERMediator.setIdValue(currentLinkedNodes[k]);typeAttr=replacedNode.getAttribute('type');if(typeAttr==='checkbox'||typeAttr==='radio'){children=replacedNode.parentNode.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1&&children[i].tagName==='LABEL'&&nodeId===children[i].getAttribute('for')){children[i].setAttribute('for',replacedNode.getAttribute('id'));break}}}}
for(k=0;k<currentWidgetNodes.length;k++){wInfo=INTERMediatorLib.getWidgetInfo(currentWidgetNodes[k]);if(wInfo[0]){IMParts_Catalog[wInfo[0]].instanciate(currentWidgetNodes[k]);if(imPartsShouldFinished.indexOf(IMParts_Catalog[wInfo[0]])<0){imPartsShouldFinished.push(IMParts_Catalog[wInfo[0]])}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-101')}}
nameTable={};for(k=0;k<currentLinkedNodes.length;k++){try{nodeId=currentLinkedNodes[k].getAttribute('id');if(INTERMediatorLib.isWidgetElement(currentLinkedNodes[k])){nodeId=currentLinkedNodes[k]._im_getComponentId()}
typeAttr=currentLinkedNodes[k].getAttribute('type');linkInfoArray=INTERMediatorLib.getLinkedElementInfo(currentLinkedNodes[k]);if(typeAttr==='radio'){nameTableKey=linkInfoArray.join('|');if(!nameTable[nameTableKey]){nameTable[nameTableKey]=nameAttrCounter;nameAttrCounter++}
nameNumber=nameTable[nameTableKey];nameAttr=currentLinkedNodes[k].getAttribute('name');if(nameAttr){currentLinkedNodes[k].setAttribute('name',nameAttr+'-'+nameNumber)}else{currentLinkedNodes[k].setAttribute('name','IM-R-'+nameNumber)}}
for(j=0;j<linkInfoArray.length;j++){nInfo=INTERMediatorLib.getNodeInfoArray(linkInfoArray[j]);curVal=targetRecordset[ix][nInfo.field];if(!INTERMediator.isDBDataPreferable||curVal){IMLibCalc.updateCalculationInfo(contextObj,keyingValue,nodeId,nInfo,targetRecordset[ix])}
if(nInfo.table===currentContextDef.name){curTarget=nInfo.target;if(IMLibElement.setValueToIMNode(currentLinkedNodes[k],curTarget,curVal)){postSetFields.push({'id':nodeId,'value':curVal})}
contextObj.setValue(keyingValue,nInfo.field,curVal,nodeId,curTarget);if(idValuesForFieldName[nInfo.field]===undefined){idValuesForFieldName[nInfo.field]=[]}
idValuesForFieldName[nInfo.field].push(nodeId)}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-27')}}}
return idValuesForFieldName}
function expandRepeaters(contextObj,node,targetRecords){var newNode,nodeClass,dataAttr,repeatersOneRec,newlyAddedNodes,encNodeTag,repNodeTag,ix,repeatersOriginal,targetRecordset,targetTotalCount,i,currentContextDef,indexContext,insertNode,countRecord,linkedElements,keyingValue,keyField,keyValue,idValuesForFieldName;encNodeTag=node.tagName;repNodeTag=INTERMediatorLib.repeaterTagFromEncTag(encNodeTag);repeatersOriginal=contextObj.original;currentContextDef=contextObj.getContextDef();targetRecordset=targetRecords.recordset;targetTotalCount=targetRecords.totalCount;repeatersOneRec=cloneEveryNodes(repeatersOriginal);for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}}}
if(targetRecords.count===0){for(i=0;i<repeatersOriginal.length;i++){newNode=repeatersOriginal[i].cloneNode(!0);nodeClass=INTERMediatorLib.getClassAttributeFromNode(newNode);dataAttr=newNode.getAttribute('data-im-control');if((nodeClass&&nodeClass.indexOf(INTERMediator.noRecordClassName)>-1)||(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>-1)){node.appendChild(newNode);INTERMediator.setIdValue(newNode);seekEnclosureNode(newNode,null,null,null)}}}
countRecord=targetRecordset?targetRecordset.length:0;for(ix=0;ix<countRecord;ix++){repeatersOneRec=cloneEveryNodes(repeatersOriginal);linkedElements=INTERMediatorLib.seekLinkedAndWidgetNodes(repeatersOneRec,!0);keyField=contextObj.getKeyField();for(i=0;i<repeatersOneRec.length;i++){INTERMediator.setIdValue(repeatersOneRec[i])}
if(targetRecordset[ix]&&(targetRecordset[ix][keyField]||targetRecordset[ix][keyField]===0)){keyValue=targetRecordset[ix][keyField];if(keyField&&!keyValue&&keyValue!==0){INTERMediatorLog.setErrorMessage('The value of the key field is null.','This No.['+ix+'] record should be ignored.');keyValue=ix}
keyingValue=keyField+'='+keyValue}
idValuesForFieldName=setupLinkedNode(linkedElements,contextObj,targetRecordset,ix,keyingValue);IMLibPageNavigation.setupDeleteButton(encNodeTag,repeatersOneRec,contextObj,keyField,keyValue);IMLibPageNavigation.setupNavigationButton(encNodeTag,repeatersOneRec,currentContextDef,keyField,keyValue,contextObj);IMLibPageNavigation.setupCopyButton(encNodeTag,repNodeTag,repeatersOneRec,contextObj,targetRecordset[ix]);if(!currentContextDef.portal||(!!currentContextDef.portal&&targetTotalCount>0)){newlyAddedNodes=[];insertNode=null;if(!contextObj.sequencing){indexContext=contextObj.checkOrder(targetRecordset[ix]);insertNode=contextObj.getRepeaterEndNode(indexContext+1)}
for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];nodeClass=INTERMediatorLib.getClassAttributeFromNode(newNode);dataAttr=newNode.getAttribute('data-im-control');if(!(nodeClass&&nodeClass.indexOf(INTERMediator.noRecordClassName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)){if(!insertNode){node.appendChild(newNode)}else{insertNode.parentNode.insertBefore(newNode,insertNode)}
newlyAddedNodes.push(newNode);if(!newNode.id){INTERMediator.setIdValue(newNode)}
contextObj.setValue(keyingValue,'_im_repeater','',newNode.id,'',currentContextDef.portal);seekEnclosureNode(newNode,targetRecordset[ix],idValuesForFieldName,contextObj)}}
if((ix+1)!==countRecord){for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}else{insertNode.parentNode.insertBefore(newNode,insertNode)}}}}
callbackForRepeaters(currentContextDef,node,newlyAddedNodes)}
contextObj.rearrangePendingOrder()}
IMLibPageNavigation.setupDetailAreaToFirstRecord(currentContextDef,contextObj);repeatersOneRec=cloneEveryNodes(repeatersOriginal);for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}}}}
function retrieveDataForEnclosure(contextObj,fieldList,relationValue){var targetRecords,recordNumber,useLimit,key,recordset=[];if(Boolean(contextObj.contextDefinition.cache)===!0){targetRecords=retrieveDataFromCache(contextObj.contextDefinition,relationValue)}else if(contextObj.contextDefinition.data){for(key in contextObj.contextDefinition.data){if(contextObj.contextDefinition.data.hasOwnProperty(key)){recordset.push(contextObj.contextDefinition.data[key])}}
targetRecords={'recordset':recordset,'count':recordset.length,'totalCount':recordset.length,'nullAcceptable':!0}}else{try{targetRecords=contextObj.getPortalRecords();if(!targetRecords){useLimit=contextObj.isUseLimit();recordNumber=contextObj.getRecordNumber();targetRecords=INTERMediator_DBAdapter.db_query({'name':contextObj.contextDefinition.name,'records':isNaN(recordNumber)?100000000:recordNumber,'paging':contextObj.contextDefinition.paging,'fields':fieldList,'parentkeyvalue':relationValue,'conditions':null,'useoffset':!0,'uselimit':useLimit})}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-12')}}}
if(contextObj.contextDefinition['appending-data']){for(key in contextObj.contextDefinition['appending-data']){if(contextObj.contextDefinition['appending-data'].hasOwnProperty(key)){targetRecords.recordset.push(contextObj.contextDefinition['appending-data'][key])}}}
return targetRecords}
function retrieveDataFromCache(currentContextDef,relationValue){var targetRecords=null,pagingValue,counter,ix,oneRecord,isMatch,index,keyField,fieldName,recordsValue;try{if(!INTERMediatorOnPage.dbCache[currentContextDef.name]){INTERMediatorOnPage.dbCache[currentContextDef.name]=INTERMediator_DBAdapter.db_query({name:currentContextDef.name,records:null,paging:null,fields:null,parentkeyvalue:null,conditions:null,useoffset:!1})}
if(relationValue===null){targetRecords=INTERMediatorOnPage.dbCache[currentContextDef.name]}else{targetRecords={recordset:[],count:0};counter=0;for(ix in INTERMediatorOnPage.dbCache[currentContextDef.name].recordset){if(INTERMediatorOnPage.dbCache[currentContextDef.name].recordset.hasOwnProperty(ix)){oneRecord=INTERMediatorOnPage.dbCache[currentContextDef.name].recordset[ix];isMatch=!0;index=0;for(keyField in relationValue){if(relationValue.hasOwnProperty(keyField)){fieldName=currentContextDef.relation[index]['foreign-key'];if(oneRecord[fieldName]!==relationValue[keyField]){isMatch=!1;break}
index++}}
if(isMatch){pagingValue=currentContextDef.paging?currentContextDef.paging:!1;recordsValue=currentContextDef.records?currentContextDef.records:10000000000;if(!pagingValue||(pagingValue&&(counter>=INTERMediator.startFrom))){targetRecords.recordset.push(oneRecord);targetRecords.count++;if(recordsValue<=targetRecords.count){break}}
counter++}}}
return targetRecords}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-24')}}}
function callbackForRepeaters(currentContextDef,node,newlyAddedNodes){try{if(INTERMediatorOnPage.additionalExpandingRecordFinish[currentContextDef.name]){INTERMediatorOnPage.additionalExpandingRecordFinish[currentContextDef.name](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.additionalExpandingRecordFinish['+currentContextDef.name+'] with the context.',2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-33: hint: post-repeater of '+currentContextDef.name)}}
try{if(INTERMediatorOnPage.expandingRecordFinish){INTERMediatorOnPage.expandingRecordFinish(currentContextDef.name,newlyAddedNodes);INTERMediatorLog.setDebugMessage('Call INTERMediatorOnPage.expandingRecordFinish with the context: '+currentContextDef.name,2)}
if(currentContextDef['post-repeater']){INTERMediatorOnPage[currentContextDef['post-repeater']](newlyAddedNodes);INTERMediatorLog.setDebugMessage('Call the post repeater method INTERMediatorOnPage.'+currentContextDef['post-repeater']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-23')}}}
function callbackForEnclosure(currentContextDef,node){try{if(INTERMediatorOnPage.additionalExpandingEnclosureFinish[currentContextDef.name]){INTERMediatorOnPage.additionalExpandingEnclosureFinish[currentContextDef.name](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.additionalExpandingEnclosureFinish['+currentContextDef.name+'] with the context.',2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-32: hint: post-enclosure of '+currentContextDef.name)}}
try{if(INTERMediatorOnPage.expandingEnclosureFinish){INTERMediatorOnPage.expandingEnclosureFinish(currentContextDef.name,node);INTERMediatorLog.setDebugMessage('Call INTERMediatorOnPage.expandingEnclosureFinish with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-21')}}
try{if(currentContextDef['post-enclosure']){INTERMediatorOnPage[currentContextDef['post-enclosure']](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.'+currentContextDef['post-enclosure']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-22: hint: post-enclosure of '+currentContextDef.name)}}}
function callbackForAfterQueryStored(currentContextDef,context){try{if(currentContextDef['post-query-stored']){INTERMediatorOnPage[currentContextDef['post-query-stored']](context);INTERMediatorLog.setDebugMessage('Call the post query stored method INTERMediatorOnPage.'+currentContextDef['post-enclosure']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-41: hint: post-query-stored of '+currentContextDef.name)}}}
function collectRepeatersOriginal(node,repNodeTag){var i,repeatersOriginal=[],children,imControl;children=node.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(children[i].tagName===repNodeTag){repeatersOriginal.push(children[i])}else if(!repNodeTag&&(children[i].getAttribute('data-im-control'))){imControl=children[i].getAttribute('data-im-control');if(imControl.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>-1){repeatersOriginal.push(children[i])}}else if(!repNodeTag&&INTERMediatorLib.getClassAttributeFromNode(children[i])&&INTERMediatorLib.getClassAttributeFromNode(children[i]).match(/_im_repeater/)){imControl=INTERMediatorLib.getClassAttributeFromNode(children[i]);if(imControl.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>-1){repeatersOriginal.push(children[i])}}}}
return repeatersOriginal}
function collectRepeaters(repeatersOriginal){var i,repeaters=[],inDocNode,parentOfRep,cloneNode;for(i=0;i<repeatersOriginal.length;i++){inDocNode=repeatersOriginal[i];parentOfRep=repeatersOriginal[i].parentNode;cloneNode=repeatersOriginal[i].cloneNode(!0);repeaters.push(cloneNode);cloneNode.setAttribute('id',INTERMediator.nextIdValue());if(parentOfRep){parentOfRep.removeChild(inDocNode)}}
return repeaters}
function collectLinkDefinitions(linkedNodes){var linkDefs=[],nodeDefs,j,k;for(j=0;j<linkedNodes.length;j++){nodeDefs=INTERMediatorLib.getLinkedElementInfo(linkedNodes[j]);if(nodeDefs){for(k=0;k<nodeDefs.length;k++){linkDefs.push(nodeDefs[k])}}}
return linkDefs}
function tableVoting(linkDefs){var j,nodeInfoArray,nodeInfoField,nodeInfoTable,maxVoted,maxTableName,tableName,nodeInfoTableIndex,context,restDefs=[],tableVote=[],fieldList=[];for(j=0;j<linkDefs.length;j++){nodeInfoArray=INTERMediatorLib.getNodeInfoArray(linkDefs[j]);nodeInfoField=nodeInfoArray.field;nodeInfoTable=nodeInfoArray.table;nodeInfoTableIndex=nodeInfoArray.tableindex;if(nodeInfoTable!=IMLibLocalContext.contextName){if(nodeInfoField&&nodeInfoField.length!==0&&nodeInfoTable&&nodeInfoTable.length!==0){if(!fieldList[nodeInfoTableIndex]){fieldList[nodeInfoTableIndex]=[]}
fieldList[nodeInfoTableIndex].push(nodeInfoField);if(!tableVote[nodeInfoTableIndex]){tableVote[nodeInfoTableIndex]=1}else{++tableVote[nodeInfoTableIndex]}}else{INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1006,[linkDefs[j]]))}}}
maxVoted=-1;maxTableName='';for(tableName in tableVote){if(tableVote.hasOwnProperty(tableName)){if(maxVoted<tableVote[tableName]){maxVoted=tableVote[tableName];maxTableName=tableName.substring(10)}}}
context=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',maxTableName);if(linkDefs.length>0&&!context){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1046,[maxTableName]))}
for(j=0;j<linkDefs.length;j++){if(linkDefs[j].indexOf(maxTableName)!==0&&linkDefs[j].indexOf('_@')!==0){restDefs.push(linkDefs[j])}}
if(linkDefs.length>0&&context&&restDefs.length>0){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1047,[maxTableName,restDefs.toString()]))}
return{targettable:context,fieldlist:fieldList['_im_index_'+maxTableName]}}
function cloneEveryNodes(originalNodes){var i,clonedNodes=[];for(i=0;i<originalNodes.length;i++){clonedNodes.push(originalNodes[i].cloneNode(!0))}
return clonedNodes}
function getEnclosedNode(rootNode,tableName,fieldName){var i,j,nodeInfo,nInfo,children,r;if(rootNode.nodeType===1){nodeInfo=INTERMediatorLib.getLinkedElementInfo(rootNode);for(j=0;j<nodeInfo.length;j++){nInfo=INTERMediatorLib.getNodeInfoArray(nodeInfo[j]);if(nInfo.table===tableName&&nInfo.field===fieldName){return rootNode}}}
children=rootNode.childNodes;for(i=0;i<children.length;i++){r=getEnclosedNode(children[i],tableName,fieldName);if(r){return r}}
return null}
function appendCredit(){var bodyNode,creditNode,cNode,spNode,aNode,versionString;if(document.getElementById('IM_CREDIT')===null){if(INTERMediatorOnPage.creditIncluding){bodyNode=document.getElementById(INTERMediatorOnPage.creditIncluding)}
if(!bodyNode){bodyNode=document.getElementsByTagName('BODY')[0]}
creditNode=document.createElement('div');bodyNode.appendChild(creditNode);creditNode.setAttribute('id','IM_CREDIT');creditNode.setAttribute('class','IM_CREDIT');cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#F6F7FF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#EBF1FF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#E1EAFF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.setAttribute('align','right');cNode.style.backgroundColor='#D7E4FF';cNode.style.padding='2px';cNode.style.margin='0';cNode.style.padding='0';spNode=document.createElement('span');cNode.appendChild(spNode);cNode.style.color='#666666';cNode.style.fontSize='7pt';aNode=document.createElement('a');aNode.appendChild(document.createTextNode('INTER-Mediator'));aNode.setAttribute('href','http://inter-mediator.com/');aNode.setAttribute('target','_href');spNode.appendChild(document.createTextNode('Generated by '));spNode.appendChild(aNode);if(INTERMediatorOnPage.metadata){versionString=' Ver.'+INTERMediatorOnPage.metadata.version+'('+INTERMediatorOnPage.metadata.releasedate+')'}else{versionString=' Ver. Development Now!'}
spNode.appendChild(document.createTextNode(versionString))}}},setIdValue:function(node){'use strict';var i,elementInfo,comp,overwrite=!0;if(node.getAttribute('id')===null){node.setAttribute('id',INTERMediator.nextIdValue())}else{if(INTERMediator.elementIds.indexOf(node.getAttribute('id'))>=0){elementInfo=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<elementInfo.length;i++){comp=elementInfo[i].split(INTERMediator.separator);if(comp[2]==='#id'){overwrite=!1}}
if(overwrite){node.setAttribute('id',INTERMediator.nextIdValue())}}
INTERMediator.elementIds.push(node.getAttribute('id'))}
return node},nextIdValue:function(){'use strict';INTERMediator.linkedElmCounter++;return currentIdValue();function currentIdValue(){return'IM'+INTERMediator.currentEncNumber+'-'+INTERMediator.linkedElmCounter}},getLocalProperty:function(localKey,defaultValue){'use strict';var value;value=IMLibLocalContext.getValue(localKey);return value===null?defaultValue:value},setLocalProperty:function(localKey,value){'use strict';IMLibLocalContext.setValue(localKey,value,!0)},addCondition:function(contextName,condition,notMatching,label){'use strict';var value,i,hasIdentical;if(notMatching){condition.matching=!notMatching}else{condition.matching=INTERMediator_DBAdapter.eliminateDuplicatedConditions}
if(label){condition.label=label}
if(INTERMediator.additionalCondition){value=INTERMediator.additionalCondition;if(condition){if(!value[contextName]){value[contextName]=[]}
if(!condition.matching){value[contextName].push(condition)}else{hasIdentical=!1;for(i=0;i<value[contextName].length;i++){if(value[contextName][i].field===condition.field&&value[contextName][i].operator===condition.operator){hasIdentical=!0;value[contextName][i].value=condition.value;break}}
if(!hasIdentical){value[contextName].push(condition)}}}
INTERMediator.additionalCondition=value}
IMLibLocalContext.archive()},clearCondition:function(contextName,label){'use strict';var i,value=INTERMediator.additionalCondition;if(label===undefined){if(value[contextName]){delete value[contextName];INTERMediator.additionalCondition=value;IMLibLocalContext.archive()}}else{if(value[contextName]){for(i=0;i<value[contextName].length;i++){if(value[contextName][i].label===label){value[contextName].splice(i,1);i--}}
INTERMediator.additionalCondition=value;IMLibLocalContext.archive()}}},addSortKey:function(contextName,sortKey){'use strict';var value=INTERMediator.additionalSortKey;if(value[contextName]){value[contextName].push(sortKey)}else{value[contextName]=[sortKey]}
INTERMediator.additionalSortKey=value;IMLibLocalContext.archive()},clearSortKey:function(contextName){'use strict';var value=INTERMediator.additionalSortKey;if(value[contextName]){delete value[contextName];INTERMediator.additionalSortKey=value;IMLibLocalContext.archive()}},setRecordLimit:function(contextName,limit){'use strict';var value=INTERMediator.recordLimit;value[contextName]=limit;INTERMediator.recordLimit=value;IMLibLocalContext.archive()},clearRecordLimit:function(contextName){'use strict';var value=INTERMediator.recordLimit;if(value[contextName]){delete value[contextName];INTERMediator.recordLimit=value;IMLibLocalContext.archive()}},flushMessage:function(){'use strict';INTERMediatorLog.flushMessage()},setErrorMessage:function(ex,moreMessage){'use strict';INTERMediatorLog.setErrorMessage(ex,moreMessage)},setDebugMessage:function(message,level){'use strict';INTERMediatorLog.setDebugMessage(message,level)}};if(!Object.keys){Object.keys=function(obj){'use strict';var results=[],prop;if(obj!==Object(obj)){throw new TypeError('Object.keys called on a non-object')}
for(prop in obj){if(Object.prototype.hasOwnProperty.call(obj,prop)){results.push(prop)}}
return results}}
if(!Array.indexOf){var isWebkit='WebkitAppearance' in document.documentElement.style;if(!isWebkit){Array.prototype.indexOf=function(target){'use strict';var i;for(i=0;i<this.length;i++){if(this[i]===target){return i}}
return-1}}}
if(typeof String.prototype.trim!=='function'){String.prototype.trim=function(){'use strict';return this.replace(/^\s+|\s+$/g,'')}}
var INTERMediatorOnPage={authCountLimit:4,authCount:0,authUser:'',authHashedPassword:'',authCryptedPassword:'',authUserSalt:'',authUserHexSalt:'',authChallenge:'',requireAuthentication:!1,clientId:null,authRequiredContext:null,authStoring:'cookie',authExpired:3600,isOnceAtStarting:!0,publickey:null,isNativeAuth:!1,httpuser:null,httppasswd:null,mediaToken:null,realm:'',dbCache:{},isEmailAsUsername:!1,passwordPolicy:null,creditIncluding:null,masterScrollPosition:null,nonSupportMessageId:'nonsupportmessage',isFinishToConstruct:!1,isAutoConstruct:!0,isShowChangePassword:!0,isSetDefaultStyle:!1,authPanelTitle:null,isOAuthAvailable:!1,oAuthClientID:null,oAuthClientSecret:null,oAuthBaseURL:null,oAuthRedirect:null,oAuthScope:null,additionalExpandingEnclosureFinish:{},additionalExpandingRecordFinish:{},getEditorPath:null,getEntryPath:null,getIMRootPath:null,getDataSources:null,getOptionsAliases:null,getOptionsTransaction:null,dbClassName:null,defaultKeyName:null,browserCompatibility:null,clientNotificationIdentifier:null,metadata:null,isLDAP:null,appLocale:null,localeInfo:{mon_decimal_point:'.',mon_thousands_sep:',',currency_symbol:'¥'},appCurrency:null,isShowProgress:!0,clearCredentials:function(){'use strict';INTERMediatorOnPage.authChallenge=null;INTERMediatorOnPage.authHashedPassword=null;INTERMediatorOnPage.authCryptedPassword=null},getMessages:function(){'use strict';return null},getURLParametersAsArray:function(){'use strict';var i,params,eqPos,result,key,value;result={};params=location.search.substring(1).split('&');for(i=0;i<params.length;i++){eqPos=params[i].indexOf('=');if(eqPos>0){key=params[i].substring(0,eqPos);value=params[i].substring(eqPos+1);result[key]=decodeURIComponent(value)}}
return result},getContextInfo:function(contextName){'use strict';var dataSources,index;dataSources=INTERMediatorOnPage.getDataSources();for(index in dataSources){if(dataSources.hasOwnProperty(index)&&dataSources[index].name===contextName){return dataSources[index]}}
return null},isComplementAuthData:function(){'use strict';return INTERMediatorOnPage.authUser!==null&&INTERMediatorOnPage.authUser.length>0&&INTERMediatorOnPage.authHashedPassword!==null&&INTERMediatorOnPage.authHashedPassword.length>0&&INTERMediatorOnPage.authUserSalt!==null&&INTERMediatorOnPage.authUserSalt.length>0&&INTERMediatorOnPage.authChallenge!==null&&INTERMediatorOnPage.authChallenge.length>0},retrieveAuthInfo:function(){'use strict';if(INTERMediatorOnPage.requireAuthentication){if(INTERMediatorOnPage.isOnceAtStarting){switch(INTERMediatorOnPage.authStoring){case 'cookie':case 'cookie-domainwide':INTERMediatorOnPage.authUser=INTERMediatorOnPage.getCookie('_im_username');INTERMediatorOnPage.authHashedPassword=INTERMediatorOnPage.getCookie('_im_credential');INTERMediatorOnPage.mediaToken=INTERMediatorOnPage.getCookie('_im_mediatoken');INTERMediatorOnPage.authCryptedPassword=INTERMediatorOnPage.getCookie('_im_crypted');break;case 'session-storage':INTERMediatorOnPage.authUser=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_username');INTERMediatorOnPage.authHashedPassword=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_credential');INTERMediatorOnPage.mediaToken=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_mediatoken');INTERMediatorOnPage.authCryptedPassword=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_crypted');break;default:INTERMediatorOnPage.removeCookie('_im_username');INTERMediatorOnPage.removeCookie('_im_credential');INTERMediatorOnPage.removeCookie('_im_mediatoken');INTERMediatorOnPage.removeCookie('_im_crypted');break}
INTERMediatorOnPage.isOnceAtStarting=!1}
if(INTERMediatorOnPage.authUser.length>0){if(!INTERMediator_DBAdapter.getChallenge()){INTERMediatorLog.flushMessage()}}}},logout:function(){'use strict';INTERMediatorOnPage.authUser='';INTERMediatorOnPage.authHashedPassword='';INTERMediatorOnPage.authCryptedPassword='';INTERMediatorOnPage.authUserSalt='';INTERMediatorOnPage.authChallenge='';INTERMediatorOnPage.clientId='';INTERMediatorOnPage.removeCredencialsFromCookieOrStorage();INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_localcontext')},storeSessionStorageWithFallDown:function(key,value){'use strict';if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{sessionStorage.setItem(INTERMediatorOnPage.getKeyWithRealm(key),value)}catch(ex){INTERMediatorOnPage.setCookie(key,value)}}else{INTERMediatorOnPage.setCookie(key,value)}},getSessionStorageWithFallDown:function(key){'use strict';var value;if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{value=sessionStorage.getItem(INTERMediatorOnPage.getKeyWithRealm(key));value=value?value:''}catch(ex){value=INTERMediatorOnPage.getCookie(key)}}else{value=INTERMediatorOnPage.getCookie(key)}
return value},removeFromSessionStorageWithFallDown:function(key){'use strict';if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{sessionStorage.removeItem(INTERMediatorOnPage.getKeyWithRealm(key))}catch(ex){INTERMediatorOnPage.removeCookie(key)}}else{INTERMediatorOnPage.removeCookie(key)}},removeCredencialsFromCookieOrStorage:function(){'use strict';switch(INTERMediatorOnPage.authStoring){case 'cookie':case 'cookie-domainwide':INTERMediatorOnPage.removeCookie('_im_username');INTERMediatorOnPage.removeCookie('_im_credential');INTERMediatorOnPage.removeCookie('_im_mediatoken');INTERMediatorOnPage.removeCookie('_im_crypted');break;case 'session-storage':INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_username');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_credential');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_mediatoken');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_crypted');break}},storeCredentialsToCookieOrStorage:function(){'use strict';switch(INTERMediatorOnPage.authStoring){case 'cookie':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.setCookie('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.setCookie('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.setCookie('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.setCookie('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break;case 'cookie-domainwide':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.setCookieDomainWide('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.setCookieDomainWide('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.setCookieDomainWide('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.setCookieDomainWide('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break;case 'session-storage':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break}},loginPanelHTML:null,authenticating:function(doAfterAuth,doTest){'use strict';var bodyNode,backBox,frontPanel,labelWidth,userLabel,userSpan,userBox,msgNumber,passwordLabel,passwordSpan,passwordBox,breakLine,chgpwButton,authButton,panelTitle,newPasswordLabel,newPasswordSpan,newPasswordBox,newPasswordMessage,realmBox,keyCode,messageNode,oAuthButton,addingButton,resetMessage;var encrypt=new JSEncrypt();this.checkPasswordPolicy=function(newPassword,userName,policyString){var terms,i,message=[],minLen;if(!policyString){return message}
terms=policyString.split(/[\s,]/);for(i=0;i<terms.length;i++){switch(terms[i].toUpperCase()){case 'USEALPHABET':if(!newPassword.match(/[A-Za-z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2015))}
break;case 'USENUMBER':if(!newPassword.match(/[0-9]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2016))}
break;case 'USEUPPER':if(!newPassword.match(/[A-Z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2017))}
break;case 'USELOWER':if(!newPassword.match(/[a-z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2018))}
break;case 'USEPUNCTUATION':if(!newPassword.match(/[^A-Za-z0-9]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2019))}
break;case 'NOTUSERNAME':if(newPassword===userName){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2020))}
break;default:if(terms[i].toUpperCase().indexOf('LENGTH')===0){minLen=terms[i].match(/[0-9]+/)[0];if(newPassword.length<minLen){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2021,[minLen]))}}}}
return message};if(doTest){return}
if(INTERMediatorOnPage.authCount>INTERMediatorOnPage.authCountLimit){INTERMediatorOnPage.authenticationError();INTERMediatorOnPage.logout();INTERMediatorLog.flushMessage();return}
bodyNode=document.getElementsByTagName('BODY')[0];backBox=document.createElement('div');backBox.id='_im_authpback';bodyNode.insertBefore(backBox,bodyNode.childNodes[0]);if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.height='100%';backBox.style.width='100%';backBox.style.backgroundImage='url('+INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=background.gif)';backBox.style.position='absolute';backBox.style.padding=' 50px 0 0 0';backBox.style.top='0';backBox.style.left='0';backBox.style.zIndex='999998'}
if(INTERMediatorOnPage.loginPanelHTML){backBox.innerHTML=INTERMediatorOnPage.loginPanelHTML;passwordBox=document.getElementById('_im_password');userBox=document.getElementById('_im_username');authButton=document.getElementById('_im_authbutton');chgpwButton=document.getElementById('_im_changebutton');oAuthButton=document.getElementById('_im_oauthbutton')}else{frontPanel=document.createElement('div');if(INTERMediatorOnPage.isSetDefaultStyle){frontPanel.style.width='450px';frontPanel.style.backgroundColor='#333333';frontPanel.style.color='#DDDDAA';frontPanel.style.margin='50px auto 0 auto';frontPanel.style.padding='20px';frontPanel.style.borderRadius='10px';frontPanel.style.position='relative'}
frontPanel.id='_im_authpanel';backBox.appendChild(frontPanel);panelTitle='';if(INTERMediatorOnPage.authPanelTitle&&INTERMediatorOnPage.authPanelTitle.length>0){panelTitle=INTERMediatorOnPage.authPanelTitle}else if(INTERMediatorOnPage.realm&&INTERMediatorOnPage.realm.length>0){panelTitle=INTERMediatorOnPage.realm}
if(panelTitle&&panelTitle.length>0){realmBox=document.createElement('DIV');realmBox.appendChild(document.createTextNode(panelTitle));realmBox.id='_im_authrealm';frontPanel.appendChild(realmBox);breakLine=document.createElement('HR');frontPanel.appendChild(breakLine)}
labelWidth='100px';userLabel=document.createElement('LABEL');frontPanel.appendChild(userLabel);userSpan=document.createElement('span');if(INTERMediatorOnPage.isSetDefaultStyle){userSpan.style.minWidth=labelWidth;userSpan.style.textAlign='right';userSpan.style.cssFloat='left'}
INTERMediatorLib.setClassAttributeToNode(userSpan,'_im_authlabel');userLabel.appendChild(userSpan);msgNumber=INTERMediatorOnPage.isEmailAsUsername?2011:2002;userSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(msgNumber)));userBox=document.createElement('INPUT');userBox.type='text';userBox.id='_im_username';userBox.size='20';userBox.setAttribute('autocapitalize','off');userLabel.appendChild(userBox);breakLine=document.createElement('BR');breakLine.clear='all';frontPanel.appendChild(breakLine);passwordLabel=document.createElement('LABEL');frontPanel.appendChild(passwordLabel);passwordSpan=document.createElement('SPAN');if(INTERMediatorOnPage.isSetDefaultStyle){passwordSpan.style.minWidth=labelWidth;passwordSpan.style.textAlign='right';passwordSpan.style.cssFloat='left'}
INTERMediatorLib.setClassAttributeToNode(passwordSpan,'_im_authlabel');passwordLabel.appendChild(passwordSpan);passwordSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2003)));passwordBox=document.createElement('INPUT');passwordBox.type='password';passwordBox.id='_im_password';passwordBox.size='20';passwordLabel.appendChild(passwordBox);authButton=document.createElement('BUTTON');authButton.id='_im_authbutton';authButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2004)));frontPanel.appendChild(authButton);breakLine=document.createElement('BR');breakLine.clear='all';frontPanel.appendChild(breakLine);newPasswordMessage=document.createElement('DIV');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordMessage.style.textAlign='center';newPasswordMessage.style.textSize='10pt';newPasswordMessage.style.color='#994433'}
newPasswordMessage.id='_im_login_message';frontPanel.appendChild(newPasswordMessage);if(this.isShowChangePassword&&!INTERMediatorOnPage.isNativeAuth){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);newPasswordLabel=document.createElement('LABEL');frontPanel.appendChild(newPasswordLabel);newPasswordSpan=document.createElement('SPAN');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordSpan.style.minWidth=labelWidth;newPasswordSpan.style.textAlign='right';newPasswordSpan.style.cssFloat='left';newPasswordSpan.style.fontSize='0.7em';newPasswordSpan.style.paddingTop='4px'}
INTERMediatorLib.setClassAttributeToNode(newPasswordSpan,'_im_authlabel_pwchange');newPasswordLabel.appendChild(newPasswordSpan);newPasswordSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2006)));newPasswordBox=document.createElement('INPUT');newPasswordBox.type='password';newPasswordBox.id='_im_newpassword';newPasswordBox.size='12';newPasswordLabel.appendChild(newPasswordBox);chgpwButton=document.createElement('BUTTON');chgpwButton.id='_im_changebutton';chgpwButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2005)));frontPanel.appendChild(chgpwButton);newPasswordMessage=document.createElement('DIV');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordMessage.style.textAlign='center';newPasswordMessage.style.textSize='10pt';newPasswordMessage.style.color='#994433'}
newPasswordMessage.id='_im_newpass_message';frontPanel.appendChild(newPasswordMessage)}
if(this.isOAuthAvailable){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);oAuthButton=document.createElement('BUTTON');oAuthButton.id='_im_oauthbutton';oAuthButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2014)));frontPanel.appendChild(oAuthButton)}
if(INTERMediatorOnPage.enrollPageURL){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);addingButton=document.createElement('BUTTON');addingButton.id='_im_enrollbutton';addingButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2022)));addingButton.onclick=function(){location.href=INTERMediatorOnPage.enrollPageURL};frontPanel.appendChild(addingButton)}
if(INTERMediatorOnPage.resetPageURL){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);addingButton=document.createElement('BUTTON');addingButton.id='_im_resetbutton';addingButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2023)));addingButton.onclick=function(){location.href=INTERMediatorOnPage.resetPageURL};frontPanel.appendChild(addingButton);resetMessage=document.createElement('div');resetMessage.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2024)));frontPanel.appendChild(resetMessage)}}
passwordBox.onkeydown=function(event){keyCode=(window.event)?window.event.which:event.keyCode;if(keyCode===13){authButton.onclick()}};userBox.value=INTERMediatorOnPage.authUser;userBox.onkeydown=function(event){keyCode=(window.event)?window.event.which:event.keyCode;if(keyCode===13){passwordBox.focus()}};authButton.onclick=function(){var inputUsername,inputPassword,challengeResult,messageNode;messageNode=document.getElementById('_im_newpass_message');if(messageNode){INTERMediatorLib.removeChildNodes(messageNode)}
inputUsername=document.getElementById('_im_username').value;inputPassword=document.getElementById('_im_password').value;if(inputUsername===''||inputPassword===''){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2013)));return}
INTERMediatorOnPage.authUser=inputUsername;bodyNode.removeChild(backBox);if(inputUsername!==''&&(INTERMediatorOnPage.authChallenge===null||INTERMediatorOnPage.authChallenge.length<24)){INTERMediatorOnPage.authHashedPassword='need-hash-pls';challengeResult=INTERMediator_DBAdapter.getChallenge();if(!challengeResult){INTERMediatorLog.flushMessage();return}}
encrypt.setPublicKey(INTERMediatorOnPage.publickey);INTERMediatorOnPage.authCryptedPassword=encrypt.encrypt(inputPassword);INTERMediatorOnPage.authHashedPassword=SHA1(inputPassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt;if(INTERMediatorOnPage.authUser.length>0){INTERMediatorOnPage.storeCredentialsToCookieOrStorage()}
doAfterAuth();INTERMediatorLog.flushMessage()};if(chgpwButton){var checkPolicyMethod=this.checkPasswordPolicy;chgpwButton.onclick=function(){var inputUsername,inputPassword,inputNewPassword,result,messageNode,message;messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode=document.getElementById('_im_newpass_message');INTERMediatorLib.removeChildNodes(messageNode);inputUsername=document.getElementById('_im_username').value;inputPassword=document.getElementById('_im_password').value;inputNewPassword=document.getElementById('_im_newpassword').value;if(inputUsername===''||inputPassword===''||inputNewPassword===''){messageNode=document.getElementById('_im_newpass_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2007)));return}
message=checkPolicyMethod(inputNewPassword,inputUsername,INTERMediatorOnPage.passwordPolicy);if(message.length>0){messageNode.appendChild(document.createTextNode(message.join(', ')));return}
result=INTERMediator_DBAdapter.changePassword(inputUsername,inputPassword,inputNewPassword);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(result?2009:2010)));INTERMediatorLog.flushMessage()}}
if(this.isOAuthAvailable&&oAuthButton){oAuthButton.onclick=function(){var authURL;INTERMediatorOnPage.setCookieDomainWide('_im_oauth_backurl',location.href,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_realm',INTERMediatorOnPage.realm,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_expired',INTERMediatorOnPage.authExpired,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_storing',INTERMediatorOnPage.authStoring,!0);authURL=INTERMediatorOnPage.oAuthBaseURL+'?scope='+encodeURIComponent(INTERMediatorOnPage.oAuthScope)+'&redirect_uri='+encodeURIComponent(INTERMediatorOnPage.oAuthRedirect)+'&response_type=code'+'&client_id='+encodeURIComponent(INTERMediatorOnPage.oAuthClientID);location.href=authURL}}
if(INTERMediatorOnPage.publickeysize<2048){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2025)))}else if(INTERMediatorOnPage.authCount>0){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2012)))}
window.scroll(0,0);userBox.focus();INTERMediatorOnPage.authCount++},authenticationError:function(){'use strict';var bodyNode,backBox,frontPanel;INTERMediatorOnPage.hideProgress();bodyNode=document.getElementsByTagName('BODY')[0];backBox=document.createElement('div');backBox.id='_im_autherrorback';bodyNode.insertBefore(backBox,bodyNode.childNodes[0]);if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.height='100%';backBox.style.width='100%';if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.backgroundImage='url('+INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=background-error.gif)'}
backBox.style.position='absolute';backBox.style.padding=' 50px 0 0 0';backBox.style.top='0';backBox.style.left='0';backBox.style.zIndex='999999'}
frontPanel=document.createElement('div');frontPanel.id='_im_autherrormessage';if(INTERMediatorOnPage.isSetDefaultStyle){frontPanel.style.width='240px';frontPanel.style.backgroundColor='#333333';frontPanel.style.color='#DD6666';frontPanel.style.fontSize='16pt';frontPanel.style.margin='50px auto 0 auto';frontPanel.style.padding='20px 4px 20px 4px';frontPanel.style.borderRadius='10px';frontPanel.style.position='relatvie';frontPanel.style.textAlign='Center'}
frontPanel.onclick=function(){bodyNode.removeChild(backBox)};backBox.appendChild(frontPanel);frontPanel.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2001)))},INTERMediatorCheckBrowser:function(deleteNode){'use strict';var positiveList,matchAgent,matchOS,versionStr,agent,os,judge=!1,specifiedVersion,versionNum,agentPos=-1,dotPos,bodyNode,elm,childElm,grandChildElm,i;positiveList=INTERMediatorOnPage.browserCompatibility();matchAgent=!1;matchOS=!1;if(positiveList.edge&&navigator.userAgent.indexOf('Edge/')>-1){positiveList={'edge':positiveList.edge}}else if(positiveList.trident&&navigator.userAgent.indexOf('Trident/')>-1){positiveList={'trident':positiveList.trident}}else if(positiveList.msie&&navigator.userAgent.indexOf('MSIE ')>-1){positiveList={'msie':positiveList.msie}}else if(positiveList.opera&&(navigator.userAgent.indexOf('Opera/')>-1||navigator.userAgent.indexOf('OPR/')>-1)){positiveList={'opera':positiveList.opera,'opr':positiveList.opera}}
for(agent in positiveList){if(positiveList.hasOwnProperty(agent)){if(navigator.userAgent.toUpperCase().indexOf(agent.toUpperCase())>-1){matchAgent=!0;if(positiveList[agent]instanceof Object){for(os in positiveList[agent]){if(positiveList[agent].hasOwnProperty(os)&&navigator.platform.toUpperCase().indexOf(os.toUpperCase())>-1){matchOS=!0;versionStr=positiveList[agent][os];break}}}else{matchOS=!0;versionStr=positiveList[agent];break}}}}
if(matchAgent&&matchOS){specifiedVersion=parseInt(versionStr,10);if(navigator.appVersion.indexOf('Edge/')>-1){agentPos=navigator.appVersion.indexOf('Edge/')+5}else if(navigator.appVersion.indexOf('Trident/')>-1){agentPos=navigator.appVersion.indexOf('Trident/')+8}else if(navigator.appVersion.indexOf('MSIE ')>-1){agentPos=navigator.appVersion.indexOf('MSIE ')+5}else if(navigator.appVersion.indexOf('OPR/')>-1){agentPos=navigator.appVersion.indexOf('OPR/')+4}else if(navigator.appVersion.indexOf('Opera/')>-1){agentPos=navigator.appVersion.indexOf('Opera/')+6}else if(navigator.appVersion.indexOf('Chrome/')>-1){agentPos=navigator.appVersion.indexOf('Chrome/')+7}else if(navigator.appVersion.indexOf('Safari/')>-1&&navigator.appVersion.indexOf('Version/')>-1){agentPos=navigator.appVersion.indexOf('Version/')+8}else if(navigator.userAgent.indexOf('Firefox/')>-1){agentPos=navigator.userAgent.indexOf('Firefox/')+8}else if(navigator.appVersion.indexOf('WebKit/')>-1){agentPos=navigator.appVersion.indexOf('WebKit/')+7}
if(agentPos>-1){if(navigator.userAgent.indexOf('Firefox/')>-1){dotPos=navigator.userAgent.indexOf('.',agentPos);versionNum=parseInt(navigator.userAgent.substring(agentPos,dotPos),10)}else{dotPos=navigator.appVersion.indexOf('.',agentPos);versionNum=parseInt(navigator.appVersion.substring(agentPos,dotPos),10)}}else{dotPos=navigator.appVersion.indexOf('.');versionNum=parseInt(navigator.appVersion.substring(0,dotPos),10)}
if(INTERMediator.isTrident){specifiedVersion=specifiedVersion+4}
if(versionStr.indexOf('-')>-1){judge=(specifiedVersion>=versionNum);if(document.documentMode){judge=(specifiedVersion>=document.documentMode)}}else if(versionStr.indexOf('+')>-1){judge=(specifiedVersion<=versionNum);if(document.documentMode){judge=(specifiedVersion<=document.documentMode)}}else{judge=(specifiedVersion===versionNum);if(document.documentMode){judge=(specifiedVersion===document.documentMode)}}}
if(judge===!0){if(deleteNode){deleteNode.parentNode.removeChild(deleteNode)}}else{bodyNode=document.getElementsByTagName('BODY')[0];elm=document.createElement('div');elm.setAttribute('align','center');childElm=document.createElement('font');childElm.setAttribute('color','gray');grandChildElm=document.createElement('font');grandChildElm.setAttribute('size','+2');grandChildElm.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[1022]));childElm.appendChild(grandChildElm);childElm.appendChild(document.createElement('br'));childElm.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[1023]));childElm.appendChild(document.createElement('br'));childElm.appendChild(document.createTextNode(navigator.userAgent));elm.appendChild(childElm);for(i=bodyNode.childNodes.length-1;i>=0;i--){bodyNode.removeChild(bodyNode.childNodes[i])}
bodyNode.appendChild(elm)}
return judge},getNodeIdFromIMDefinition:function(imDefinition,fromNode,justFromNode){'use strict';console.error('INTERMediatorOnPage.getNodeIdFromIMDefinition method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'The alternative method is getNodeIdsHavingTargetFromNode or getNodeIdsHavingTargetFromRepeater.');var repeaterNode;if(justFromNode){repeaterNode=fromNode}else{repeaterNode=INTERMediatorLib.getParentRepeater(fromNode)}
return seekNode(repeaterNode,imDefinition);function seekNode(node,imDefinition){var children,i,nodeDefs,returnValue;if(node.nodeType!==1){return null}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[i])){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs.indexOf(imDefinition)>-1){returnValue=children[i].getAttribute('id');return returnValue}}
returnValue=seekNode(children[i],imDefinition);if(returnValue!==null){return returnValue}}}}
return null}},getNodeIdFromIMDefinitionOnEnclosure:function(imDefinition,fromNode){'use strict';console.error('INTERMediatorOnPage.getNodeIdFromIMDefinitionOnEnclosure method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'The alternative method is getNodeIdsHavingTargetFromEnclosure.');var repeaterNode;repeaterNode=INTERMediatorLib.getParentEnclosure(fromNode);return seekNode(repeaterNode,imDefinition);function seekNode(node,imDefinition){var children,i,nodeDefs,returnValue;if(node.nodeType!==1){return null}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[i])){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs.indexOf(imDefinition)>-1&&children[i].getAttribute){returnValue=children[i].getAttribute('id');return returnValue}}
returnValue=seekNode(children[i],imDefinition);if(returnValue!==null){return returnValue}}}}
return null}},getNodeIdsFromIMDefinition:function(imDefinition,fromNode,justFromNode){'use strict';var enclosureNode,nodeIds=[],i,j;if(justFromNode===!0){enclosureNode=[fromNode]}else if(justFromNode===!1){enclosureNode=[INTERMediatorLib.getParentEnclosure(fromNode)]}else{enclosureNode=INTERMediatorLib.getParentRepeaters(fromNode)}
if(!enclosureNode){return[]}
for(i=0;i<enclosureNode.length;i+=1){if(enclosureNode[i]!==null){if(Array.isArray(enclosureNode[i])){for(j=0;j<enclosureNode[i].length;j++){seekNode(enclosureNode[i][j],imDefinition)}}else{seekNode(enclosureNode[i],imDefinition)}}}
return nodeIds;function seekNode(node,imDefinition){var children,i,nodeDefs;if(node.nodeType!==1){return}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs&&nodeDefs.indexOf(imDefinition)>-1){if(children[i].getAttribute('id')){nodeIds.push(children[i].getAttribute('id'))}else{nodeIds.push(children[i])}}}
seekNode(children[i],imDefinition)}}}},getNodeIdsHavingTargetFromNode:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,!0)},getNodeIdsHavingTargetFromRepeater:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,'others')},getNodeIdsHavingTargetFromEnclosure:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,!1)},getKeyWithRealm:function(str){'use strict';if(INTERMediatorOnPage.realm.length>0){return str+'_'+INTERMediatorOnPage.realm}
return str},getCookie:function(key){'use strict';var s,i,targetKey;s=document.cookie.split('; ');targetKey=this.getKeyWithRealm(key);for(i=0;i<s.length;i++){if(s[i].indexOf(targetKey+'=')===0){return decodeURIComponent(s[i].substring(s[i].indexOf('=')+1))}}
return''},removeCookie:function(key){'use strict';document.cookie=this.getKeyWithRealm(key)+'=; path=/; max-age=0; expires=Thu, 1-Jan-1900 00:00:00 GMT;';document.cookie=this.getKeyWithRealm(key)+'=; max-age=0; expires=Thu, 1-Jan-1900 00:00:00 GMT;'},setCookie:function(key,val){'use strict';this.setCookieWorker(this.getKeyWithRealm(key),val,!1,INTERMediatorOnPage.authExpired)},setCookieDomainWide:function(key,val,noRealm){'use strict';var realKey;realKey=(noRealm===!0)?key:this.getKeyWithRealm(key);this.setCookieWorker(realKey,val,!0,INTERMediatorOnPage.authExpired)},setCookieWorker:function(key,val,isDomain,expired){'use strict';var cookieString;var d=new Date();d.setTime(d.getTime()+expired*1000);cookieString=key+'='+encodeURIComponent(val)+(isDomain?';path=/':'')+';';if(expired>0){cookieString+='max-age='+expired+';expires='+d.toUTCString()+';'}
if(document.URL.substring(0,8)==='https://'){cookieString+='secure;'}
document.cookie=cookieString},hideProgress:function(){'use strict';if(!INTERMediatorOnPage.isShowProgress){return}
var frontPanel,themeName;frontPanel=document.getElementById('_im_progress');if(frontPanel){themeName=INTERMediatorOnPage.getTheme().toLowerCase();if(themeName==='least'||themeName==='thosedays'){frontPanel.style.display='none'}else{frontPanel.style.transitionDuration='0.3s';frontPanel.style.opacity=0;frontPanel.style.zIndex=-9999}}},showProgress:function(){'use strict';if(!INTERMediatorOnPage.isShowProgress){return}
var brNode,bodyNode,frontPanel,imageProgress,imageIM,themeName=INTERMediatorOnPage.getTheme().toLowerCase();frontPanel=document.getElementById('_im_progress');if(!frontPanel){frontPanel=document.createElement('div');frontPanel.setAttribute('id','_im_progress');bodyNode=document.getElementsByTagName('BODY')[0];if(bodyNode.firstChild){bodyNode.insertBefore(frontPanel,bodyNode.firstChild)}else{bodyNode.appendChild(frontPanel)}
if(themeName==='least'||themeName==='thosedays'){imageIM=document.createElement('img');imageIM.setAttribute('id','_im_logo');imageIM.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=logo.gif');frontPanel.appendChild(imageIM);imageProgress=document.createElement('img');imageProgress.setAttribute('id','_im_animatedimage');imageProgress.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=inprogress.gif');frontPanel.appendChild(imageProgress);brNode=document.createElement('BR');brNode.setAttribute('clear','all');frontPanel.appendChild(brNode);frontPanel.appendChild(document.createTextNode('INTER-Mediator working'))}else{imageIM=document.createElement('img');imageIM.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=gears.svg');frontPanel.appendChild(imageIM)}}
if(themeName!=='least'&&themeName!=='thosedays'){frontPanel.style.transitionDuration='0';frontPanel.style.opacity=1.0;frontPanel.style.display='flex';frontPanel.style.zIndex=9999}},setReferenceToTheme:function(){'use strict';var headNode,linkElement,i,styleIndex=-1;headNode=document.getElementsByTagName('HEAD')[0];linkElement=document.createElement('link');linkElement.setAttribute('href',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=css');linkElement.setAttribute('rel','stylesheet');linkElement.setAttribute('type','text/css');for(i=0;i<headNode.childNodes.length;i++){if(headNode.childNodes[i]&&headNode.childNodes[i].nodeType===1&&headNode.childNodes[i].tagName==='LINK'&&headNode.childNodes[i].rel==='stylesheet'){styleIndex=i;break}}
if(styleIndex>-1){headNode.insertBefore(linkElement,headNode.childNodes[styleIndex])}else{headNode.appendChild(linkElement)}}};var IMLibContextPool={poolingContexts:null,clearAll:function(){'use strict';this.poolingContexts=null},registerContext:function(context){'use strict';if(this.poolingContexts===null){this.poolingContexts=[context]}else{this.poolingContexts.push(context)}},excludingNode:null,synchronize:function(context,recKey,key,value,target,portal){'use strict';var i,j,viewName,refNode,targetNodes,result=[],calcKey;viewName=context.viewName;if(this.poolingContexts===null){return null}
if(portal){for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].viewName===viewName&&this.poolingContexts[i].binding[recKey]!==undefined&&this.poolingContexts[i].binding[recKey][key]!==undefined&&this.poolingContexts[i].binding[recKey][key][portal]!==undefined&&this.poolingContexts[i].store[recKey]!==undefined&&this.poolingContexts[i].store[recKey][key]!==undefined&&this.poolingContexts[i].store[recKey][key][portal]!==undefined){this.poolingContexts[i].store[recKey][key][portal]=value;targetNodes=this.poolingContexts[i].binding[recKey][key][portal];for(j=0;j<targetNodes.length;j++){refNode=document.getElementById(targetNodes[j].id);if(refNode){IMLibElement.setValueToIMNode(refNode,targetNodes[j].target,value,!0);result.push(targetNodes[j].id)}}}}}else{for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].viewName===viewName&&this.poolingContexts[i].binding[recKey]!==undefined&&this.poolingContexts[i].binding[recKey][key]!==undefined&&this.poolingContexts[i].store[recKey]!==undefined&&this.poolingContexts[i].store[recKey][key]!==undefined){this.poolingContexts[i].store[recKey][key]=value;targetNodes=this.poolingContexts[i].binding[recKey][key];for(j=0;j<targetNodes.length;j++){refNode=document.getElementById(targetNodes[j].id);calcKey=targetNodes[j].id;if(targetNodes[j].target&&targetNodes[j].target.length>0){calcKey+=INTERMediator.separator+targetNodes[j].target}
if(refNode&&!(calcKey in IMLibCalc.calculateRequiredObject)){IMLibElement.setValueToIMNode(refNode,targetNodes[j].target,value,!0);result.push(targetNodes[j].id)}}}}}
return result},getContextInfoFromId:function(idValue,target){'use strict';var i,targetContext,element,linkInfo,nodeInfo,targetName,result=null;if(!idValue){return result}
element=document.getElementById(idValue);if(!element){return result}
linkInfo=INTERMediatorLib.getLinkedElementInfo(element);if(!linkInfo&&INTERMediatorLib.isWidgetElement(element.parentNode)){linkInfo=INTERMediatorLib.getLinkedElementInfo(element.parentNode)}
nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);targetName=target?target:'_im_no_target';if(this.poolingContexts===null){return null}
for(i=0;i<this.poolingContexts.length;i++){targetContext=this.poolingContexts[i];if(targetContext.contextInfo[idValue]&&targetContext.contextInfo[idValue][targetName]&&targetContext.contextInfo[idValue][targetName].context.contextName===nodeInfo.table){result=targetContext.contextInfo[idValue][targetName];return result}}
return null},getKeyFieldValueFromId:function(idValue,target){'use strict';var contextInfo=this.getContextInfoFromId(idValue,target);if(!contextInfo){return null}
var contextName=contextInfo.context.contextName;var contextDef=IMLibContextPool.getContextDef(contextName);if(!contextDef){return null}
var keyField=contextDef.key?contextDef.key:'id';return contextInfo.record.substr(keyField.length+1)},updateContext:function(idValue,target){'use strict';var contextInfo,value;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,target);value=IMLibElement.getValueFromIMNode(document.getElementById(idValue));if(contextInfo){contextInfo.context.setValue(contextInfo.record,contextInfo.field,value,!1,target,contextInfo.portal)}},getContextFromEnclosure:function(enclosureNode){'use strict';var i;for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].enclosureNode===enclosureNode){return this.poolingContexts[i]}}},contextFromEnclosureId:function(idValue){'use strict';var i,enclosure;if(!idValue){return!1}
for(i=0;i<this.poolingContexts.length;i++){enclosure=this.poolingContexts[i].enclosureNode;if(enclosure.getAttribute('id')===idValue){return this.poolingContexts[i]}}
return null},contextFromName:function(cName){'use strict';var i;if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName){return this.poolingContexts[i]}}
return null},getContextFromName:function(cName){'use strict';var i,result=[];if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName){result.push(this.poolingContexts[i])}}
return result},getContextsFromNameAndForeignValue:function(cName,fValue,parentKeyField){'use strict';var i,result=[];if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName&&this.poolingContexts[i].foreignValue[parentKeyField]===fValue){result.push(this.poolingContexts[i])}}
return result},dependingObjects:function(idValue){'use strict';var i,j,result=[];if(!idValue){return!1}
for(i=0;i<this.poolingContexts.length;i++){for(j=0;j<this.poolingContexts[i].dependingObject.length;j++){if(this.poolingContexts[i].dependingObject[j]===idValue){result.push(this.poolingContexts[i])}}}
return result.length===0?!1:result},getChildContexts:function(parentContext){'use strict';var i,childContexts=[];for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].parentContext===parentContext){childContexts.push(this.poolingContexts[i])}}
return childContexts},childContexts:null,removeContextsFromPool:function(contexts){'use strict';var i,regIds=[],delIds=[];for(i=0;i<this.poolingContexts.length;i++){if(contexts.indexOf(this.poolingContexts[i])>-1){regIds.push(this.poolingContexts[i].registeredId);delIds.push(i)}}
for(i=delIds.length-1;i>-1;i--){this.poolingContexts.splice(delIds[i],1)}
return regIds},removeRecordFromPool:function(repeaterIdValue){'use strict';var i,j,field,nodeIds=[],targetKeying,targetKeyingObj,parentKeying,relatedId,idValue,delNodes,contextAndKey,sameOriginContexts,countDeleteNodes;contextAndKey=getContextAndKeyFromId(repeaterIdValue);if(contextAndKey===null){return}
sameOriginContexts=this.getContextsWithSameOrigin(contextAndKey.context);targetKeying=contextAndKey.key;for(i=0;i<sameOriginContexts.length;i++){targetKeyingObj=sameOriginContexts[i].binding[targetKeying];for(field in targetKeyingObj){if(targetKeyingObj.hasOwnProperty(field)){for(j=0;j<targetKeyingObj[field].length;j++){if(nodeIds.indexOf(targetKeyingObj[field][j].id)<0){nodeIds.push(targetKeyingObj[field][j].id)}}}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){parentKeying=Object.keys(contextAndKey.context.binding)[0];relatedId=targetKeying.split('=')[1];if(sameOriginContexts[i].binding[parentKeying]&&sameOriginContexts[i].binding[parentKeying]._im_repeater&&sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId]&&sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId][0]){nodeIds.push(sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId][0].id)}}}
delNodes=[];for(i=0;i<sameOriginContexts.length;i++){for(idValue in sameOriginContexts[i].contextInfo){if(sameOriginContexts[i].contextInfo.hasOwnProperty(idValue)){if(nodeIds.indexOf(idValue)>=0){delete contextAndKey.context.contextInfo[idValue];delNodes.push(idValue)}}}
delete sameOriginContexts[i].binding[targetKeying];delete sameOriginContexts[i].store[targetKeying]}
countDeleteNodes=delNodes.length;IMLibElement.deleteNodes(delNodes);this.poolingContexts=this.poolingContexts.filter(function(context){return nodeIds.indexOf(context.enclosureNode.id)<0});return countDeleteNodes;function getContextAndKeyFromId(repeaterIdValue){var i,field,j,keying,foreignKey;for(i=0;i<IMLibContextPool.poolingContexts.length;i++){for(keying in IMLibContextPool.poolingContexts[i].binding){if(IMLibContextPool.poolingContexts[i].binding.hasOwnProperty(keying)){for(field in IMLibContextPool.poolingContexts[i].binding[keying]){if(IMLibContextPool.poolingContexts[i].binding[keying].hasOwnProperty(field)&&field==='_im_repeater'){for(j=0;j<IMLibContextPool.poolingContexts[i].binding[keying][field].length;j++){if(repeaterIdValue===IMLibContextPool.poolingContexts[i].binding[keying][field][j].id){return({context:IMLibContextPool.poolingContexts[i],key:keying})}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){for(foreignKey in IMLibContextPool.poolingContexts[i].binding[keying][field]){if(IMLibContextPool.poolingContexts[i].binding[keying][field].hasOwnProperty(foreignKey)){for(j=0;j<IMLibContextPool.poolingContexts[i].binding[keying][field][foreignKey].length;j++){if(repeaterIdValue===IMLibContextPool.poolingContexts[i].binding[keying][field][foreignKey][j].id){return({context:IMLibContextPool.poolingContexts[i],key:INTERMediatorOnPage.defaultKeyName+'='+foreignKey})}}}}}}}}}}
return null}},getContextsWithSameOrigin:function(originalContext){'use strict';var i,contexts=[],contextDef,isPortal=!1;contextDef=IMLibContextPool.getContextDef(originalContext.contextName);if(contextDef&&contextDef.relation){for(i in contextDef.relation){if(contextDef.relation.hasOwnProperty(i)&&contextDef.relation[i].portal){isPortal=!0;break}}}
for(i=0;i<IMLibContextPool.poolingContexts.length;i++){if(IMLibContextPool.poolingContexts[i].sourceName===originalContext.sourceName){if(!isPortal||originalContext.parentContext!==IMLibContextPool.poolingContexts[i]){contexts.push(IMLibContextPool.poolingContexts[i])}}}
return contexts},updateOnAnotherClient:function(eventName,info){'use strict';var i,j,k,entityName=info.entity,contextDef,contextView,keyField,recKey;if(eventName==='update'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){keyField=contextDef.key;recKey=keyField+'='+info.pkvalue;this.poolingContexts[i].setValue(recKey,info.field[0],info.value[0]);var bindingInfo=this.poolingContexts[i].binding[recKey][info.field[0]];for(j=0;j<bindingInfo.length;j++){var updateRequiredContext=IMLibContextPool.dependingObjects(bindingInfo[j].id);for(k=0;k<updateRequiredContext.length;k++){updateRequiredContext[k].foreignValue={};updateRequiredContext[k].foreignValue[info.field[0]]=info.value[0];if(updateRequiredContext[k]){INTERMediator.constructMain(updateRequiredContext[k])}}}}}
IMLibCalc.recalculation()}else if(eventName==='create'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){if(this.poolingContexts[i].isContaining(info.value[0])){INTERMediator.constructMain(this.poolingContexts[i],info.value)}}}
IMLibCalc.recalculation()}else if(eventName==='delete'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){this.poolingContexts[i].removeEntry(info.pkvalue)}}
IMLibCalc.recalculation()}},getMasterContext:function(){'use strict';var i,contextDef;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){contextDef=this.poolingContexts[i].getContextDef();if(contextDef['navi-control']&&contextDef['navi-control'].match(/master/)){return this.poolingContexts[i]}}
return null},getDetailContext:function(){'use strict';var i,contextDef;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){contextDef=this.poolingContexts[i].getContextDef();if(contextDef['navi-control']&&contextDef['navi-control'].match(/detail/)){return this.poolingContexts[i]}}
return null},getContextDef:function(contextName){'use strict';return INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',contextName)},getContextFromNodeId:function(nodeId){'use strict';var i,context,contextDef,rKey,fKey,pKey,isPortal,bindInfo;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];contextDef=context.getContextDef();isPortal=!1;if(contextDef.relation){for(rKey in contextDef.relation){if(contextDef.relation[rKey].portal){isPortal=!0}}}
for(rKey in context.binding){if(context.binding.hasOwnProperty(rKey)){for(fKey in context.binding[rKey]){if(isPortal){for(pKey in context.binding[rKey][fKey]){if(context.binding[rKey][fKey].hasOwnProperty(pKey)){bindInfo=context.binding[rKey][fKey][pKey];if(bindInfo.nodeId===nodeId){return context}}}}else{bindInfo=context.binding[rKey][fKey];if(bindInfo.nodeId===nodeId){return context}}}}}}
return null},getContextFromEnclosureNode:function(enclosureNode){'use strict';var i,context;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];if(context.enclosureNode===enclosureNode){return context}}
return null},generateContextObject:function(contextDef,enclosure,repeaters,repeatersOriginal){'use strict';var contextObj=new IMLibContext(contextDef.name);contextObj.contextDefinition=contextDef;contextObj.enclosureNode=enclosure;contextObj.repeaterNodes=repeaters;contextObj.original=repeatersOriginal;contextObj.sequencing=!0;return contextObj},getPagingContext:function(){'use strict';var i,context,contextDef;if(this.poolingContexts){for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];contextDef=context.getContextDef();if(contextDef.paging){return context}}}
return null}};var IMLibContext=function(contextName){'use strict';this.contextName=contextName;this.tableName=null;this.viewName=null;this.sourceName=null;this.contextDefinition=null;this.store={};this.binding={};this.contextInfo={};this.modified={};this.recordOrder=[];this.pendingOrder=[];IMLibContextPool.registerContext(this);this.foreignValue={};this.enclosureNode=null;this.repeaterNodes=null;this.dependingObject=[];this.original=null;this.nullAcceptable=!0;this.parentContext=null;this.registeredId=null;this.sequencing=!1;this.dependingParentObjectInfo=null;this.isPortal=!1;this.potalContainingRecordKV=null;this.setTable(this)};IMLibContext.prototype.updateFieldValue=function(idValue,succeedProc,errorProc,warnMultipleRecProc,warnOthersModifyProc){'use strict';var nodeInfo,contextInfo,linkInfo,changedObj,criteria,newValue;changedObj=document.getElementById(idValue);linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);if(INTERMediator.ignoreOptimisticLocking){IMLibContextPool.updateContext(idValue,nodeInfo.target);newValue=IMLibElement.getValueFromIMNode(changedObj);if(newValue!==null){criteria=contextInfo.record.split('=');INTERMediatorOnPage.retrieveAuthInfo();if(contextInfo.context.isPortal){criteria=contextInfo.context.potalContainingRecordKV.split('=');INTERMediator_DBAdapter.db_update_async({name:contextInfo.context.parentContext.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field+'.'+contextInfo.record.split('=')[1],value:newValue}]},succeedProc,errorProc)}else{criteria=contextInfo.record.split('=');INTERMediator_DBAdapter.db_update_async({name:contextInfo.context.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field,value:newValue}]},succeedProc,errorProc)}}}else{var targetContext=contextInfo.context;var parentContext,keyingComp;if(targetContext.isPortal===!0){parentContext=IMLibContextPool.getContextFromName(targetContext.sourceName)[0]}else{parentContext=targetContext.parentContext}
var targetField=contextInfo.field;if(targetContext.isPortal===!0){keyingComp=Object.keys(parentContext.store)[0].split('=')}else{keyingComp=(targetContext.isPortal?targetContext.potalContainingRecordKV:contextInfo.record).split('=')}
var keyingField=keyingComp[0];keyingComp.shift();var keyingValue=keyingComp.join('=');INTERMediator_DBAdapter.db_query_async({name:targetContext.isPortal?parentContext.contextName:targetContext.contextName,records:1,paging:!1,fields:[contextInfo.field],parentkeyvalue:null,conditions:[{field:keyingField,operator:'=',value:keyingValue}],useoffset:!1,primaryKeyOnly:!0},(function(){var targetFieldCapt=targetField;var contextInfoCapt=contextInfo;var targetContextCapt=targetContext;var changedObjectCapt=changedObj;var nodeInfoCapt=nodeInfo;var idValueCapt=idValue;return function(result){var initialvalue,newValue,isOthersModified,currentFieldVal,recordset=[],portalRecords,index,keyField,keyingComp,criteria;if(targetContextCapt.isPortal){portalRecords=targetContextCapt.getPortalRecordsetImpl(result.dbresult[0],targetContextCapt.contextName);keyField=targetContextCapt.getKeyField();keyingComp=contextInfoCapt.record.split('=');for(index=0;index<portalRecords.length;index++){if(portalRecords[index][keyField]===keyingComp[1]){recordset.push(portalRecords[index]);break}}}else{recordset=result.dbresult}
if(!recordset||!recordset[0]||recordset[0][targetFieldCapt]===undefined){errorProc();return}
if(result.resultCount>1){if(!warnMultipleRecProc()){return}}
if(targetContextCapt.isPortal){for(var i=0;i<recordset.length;i++){if(recordset[i][INTERMediatorOnPage.defaultKeyName]===contextInfo.record.split('=')[1]){currentFieldVal=recordset[i][targetFieldCapt];break}}
initialvalue=targetContextCapt.getValue(Object.keys(parentContext.store)[0],targetFieldCapt,INTERMediatorOnPage.defaultKeyName+'='+recordset[i][INTERMediatorOnPage.defaultKeyName])}else{currentFieldVal=recordset[0][targetFieldCapt];initialvalue=targetContextCapt.getValue(contextInfoCapt.record,targetFieldCapt)}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){if(typeof(initialvalue)==='number'&&typeof(currentFieldVal)==='string'){initialvalue=initialvalue.toString()}}
isOthersModified=checkSameValue(initialvalue,currentFieldVal);if(changedObjectCapt.tagName==='INPUT'&&changedObjectCapt.getAttribute('type')==='checkbox'){if(initialvalue===changedObjectCapt.value){isOthersModified=!1}else if(!parseInt(currentFieldVal)){isOthersModified=!1}else{isOthersModified=!0}}
if(isOthersModified){newValue=IMLibElement.getValueFromIMNode(changedObjectCapt);if(!warnOthersModifyProc(initialvalue,newValue,currentFieldVal)){return}
INTERMediatorOnPage.retrieveAuthInfo()}
IMLibContextPool.updateContext(idValueCapt,nodeInfoCapt.target);newValue=IMLibElement.getValueFromIMNode(changedObjectCapt);if(newValue!==null){if(targetContextCapt.isPortal){if(targetContextCapt.potalContainingRecordKV==null){criteria=Object.keys(targetContextCapt.foreignValue);criteria[1]=targetContextCapt.foreignValue[criteria[0]]}else{criteria=targetContextCapt.potalContainingRecordKV.split('=')}
INTERMediator_DBAdapter.db_update_async({name:targetContextCapt.isPortal?targetContextCapt.sourceName:targetContextCapt.parentContext.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfoCapt.field+'.'+contextInfoCapt.record.split('=')[1],value:newValue}]},succeedProc,errorProc)}else{criteria=contextInfoCapt.record.split('=');INTERMediator_DBAdapter.db_update_async({name:targetContextCapt.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field,value:newValue}]},succeedProc,errorProc)}}}})(),function(){INTERMediatorOnPage.hideProgress();INTERMediatorLog.setErrorMessage('Error in valueChange method.','EXCEPTION-1')})}
var handleAsNullValue=['0000-00-00','0000-00-00 00:00:00'];function checkSameValue(initialValue,currentFieldVal){if(handleAsNullValue.indexOf(initialValue)>=0){initialValue=''}
if(handleAsNullValue.indexOf(currentFieldVal)>=0){currentFieldVal=''}
return initialValue!==currentFieldVal}};IMLibContext.prototype.getKeyField=function(){'use strict';var keyField;if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){if(this.isPortal){keyField=INTERMediatorOnPage.defaultKeyName}else{keyField=this.contextDefinition.key?this.contextDefinition.key:INTERMediatorOnPage.defaultKeyName}}else{keyField=this.contextDefinition.key?this.contextDefinition.key:'id'}
return keyField};IMLibContext.prototype.getCalculationFields=function(){'use strict';var calcDef=this.contextDefinition.calculation;var calcFields=[],ix;for(ix in calcDef){if(calcDef.hasOwnProperty(ix)){calcFields.push(calcDef[ix].field)}}
return calcFields};IMLibContext.prototype.isUseLimit=function(){'use strict';var useLimit=!1;if(this.contextDefinition.records&&this.contextDefinition.paging){useLimit=!0}
return useLimit};IMLibContext.prototype.getPortalRecords=function(){'use strict';var targetRecords={};if(!this.isPortal){return null}
if(this.contextDefinition&&this.contextDefinition.currentrecord){targetRecords.recordset=this.getPortalRecordsetImpl(this.contextDefinition.currentrecord,this.contextName)}else{targetRecords.recordset=this.getPortalRecordsetImpl(this.parentContext.store[this.potalContainingRecordKV],this.contextName)}
return targetRecords};IMLibContext.prototype.getPortalRecordsetImpl=function(store,contextName){'use strict';var result,recId,recordset,key,contextDef;recordset=[];if(store[0]){if(!store[0][contextName]){for(key in store[0]){if(store[0].hasOwnProperty(key)){contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',key);if(contextName===contextDef.view&&!store[0][contextName]){contextName=key;break}}}}
if(store[0][contextName]){result=store[0][contextName];for(recId in result){if(result.hasOwnProperty(recId)&&isFinite(recId)){recordset.push(result[recId])}}}}
return recordset};IMLibContext.prototype.getRecordNumber=function(){'use strict';var recordNumber,key,value,keyParams;if(this.contextDefinition['navi-control']&&this.contextDefinition['navi-control']==='detail'){recordNumber=1}else{recordNumber=parseInt(this.contextDefinition.records,10);for(key in INTERMediator.recordLimit){if(INTERMediator.recordLimit.hasOwnProperty(key)){value=String(INTERMediator.recordLimit[key]);if(key===this.contextDefinition.name&&value.length>0){recordNumber=parseInt(value);INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}}}
if(parseInt(INTERMediator.pagedSize,10)>0){recordNumber=INTERMediator.pagedSize;INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}
for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){value=String(IMLibLocalContext.store[key]);keyParams=key.split(':');if(keyParams&&keyParams.length>1&&keyParams[1].trim()===this.contextDefinition.name&&value.length>0&&keyParams[0].trim()==='limitnumber'){recordNumber=parseInt(value);INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}}}
if(!this.contextDefinition.relation&&this.contextDefinition.paging&&Boolean(this.contextDefinition.paging)===!0){INTERMediator.setLocalProperty('_im_pagedSize',recordNumber);INTERMediator.pagedSize=recordNumber}}
return recordNumber};IMLibContext.prototype.setRelationWithParent=function(currentRecord,parentObjectInfo,parentContext){'use strict';var relationDef,index,joinField,fieldName,i;this.parentContext=parentContext;if(currentRecord){try{relationDef=this.contextDefinition.relation;if(relationDef){for(index in relationDef){if(relationDef.hasOwnProperty(index)){if(Boolean(relationDef[index].portal)===!0){this.isPortal=!0;this.potalContainingRecordKV=INTERMediatorOnPage.defaultKeyName+'='+currentRecord[INTERMediatorOnPage.defaultKeyName]}
joinField=relationDef[index]['join-field'];this.addForeignValue(joinField,currentRecord[joinField]);for(fieldName in parentObjectInfo){if(fieldName===relationDef[index]['join-field']){for(i=0;i<parentObjectInfo[fieldName].length;i++){this.addDependingObject(parentObjectInfo[fieldName][i])}
this.dependingParentObjectInfo=JSON.parse(JSON.stringify(parentObjectInfo))}}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-25')}}}};IMLibContext.prototype.getInsertOrder=function(){'use strict';var cName,sortKeys=[],contextDef,i,sortFields=[],sortDirections=[];for(cName in INTERMediator.additionalSortKey){if(cName===this.contextName){sortKeys.push(INTERMediator.additionalSortKey[cName])}}
contextDef=this.getContextDef();if(contextDef.sort){sortKeys.push(contextDef.sort)}
for(i=0;i<sortKeys.length;i++){if(sortFields.indexOf(sortKeys[i].field)<0){sortFields.push(sortKeys[i].field);sortDirections.push(sortKeys[i].direction)}}};IMLibContext.prototype.indexingArray=function(keyField){'use strict';var ar=[],key,counter=0;for(key in this.store){if(this.store.hasOwnProperty(key)){ar[counter]=this.store[key][keyField];counter+=1}}
return ar};IMLibContext.prototype.clearAll=function(){'use strict';this.store={};this.binding={}};IMLibContext.prototype.setContextName=function(name){'use strict';this.contextName=name};IMLibContext.prototype.getContextDef=function(){'use strict';return INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName)};IMLibContext.prototype.setTableName=function(name){'use strict';this.tableName=name};IMLibContext.prototype.setViewName=function(name){'use strict';this.viewName=name};IMLibContext.prototype.addDependingObject=function(idNumber){'use strict';this.dependingObject.push(idNumber)};IMLibContext.prototype.addForeignValue=function(field,value){'use strict';this.foreignValue[field]=value};IMLibContext.prototype.setOriginal=function(repeaters){'use strict';var i;this.original=[];for(i=0;i<repeaters.length;i++){this.original.push(repeaters[i].cloneNode(!0))}};IMLibContext.prototype.setTable=function(context){'use strict';var contextDef;if(!context||!INTERMediatorOnPage.getDataSources){this.tableName=this.contextName;this.viewName=this.contextName;this.sourceName=this.contextName;return}
contextDef=this.getContextDef();if(contextDef){this.viewName=contextDef.view?contextDef.view:contextDef.name;this.tableName=contextDef.table?contextDef.table:contextDef.name;this.sourceName=(contextDef.source?contextDef.source:(contextDef.table?contextDef.table:(contextDef.view?contextDef.view:contextDef.name)))}};IMLibContext.prototype.removeContext=function(){'use strict';var regIds=[],childContexts=[];seekRemovingContext(this);regIds=IMLibContextPool.removeContextsFromPool(childContexts);while(this.enclosureNode.firstChild){this.enclosureNode.removeChild(this.enclosureNode.firstChild)}
INTERMediator_DBAdapter.unregister(regIds);function seekRemovingContext(context){var i,myChildren;childContexts.push(context);regIds.push(context.registeredId);myChildren=IMLibContextPool.getChildContexts(context);for(i=0;i<myChildren.length;i++){seekRemovingContext(myChildren[i])}}};IMLibContext.prototype.setModified=function(recKey,key,value){'use strict';if(this.modified[recKey]===undefined){this.modified[recKey]={}}
this.modified[recKey][key]=value};IMLibContext.prototype.getModified=function(){'use strict';return this.modified};IMLibContext.prototype.clearModified=function(){'use strict';this.modified={}};IMLibContext.prototype.getContextDef=function(){'use strict';var contextDef;contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName);return contextDef};IMLibContext.prototype.checkOrder=function(oneRecord,isDebug){'use strict';var i,fields=[],directions=[],oneSortKey,condtextDef,lower,upper,index,targetRecord,contextValue,checkingValue,stop;if(isDebug!==!0){if(INTERMediator&&INTERMediator.additionalSortKey[this.contextName]){for(i=0;i<INTERMediator.additionalSortKey[this.contextName].length;i++){oneSortKey=INTERMediator.additionalSortKey[this.contextName][i];if(!(oneSortKey.field in fields)){fields.push(oneSortKey.field);directions.push(oneSortKey.direction)}}}
condtextDef=this.getContextDef();if(condtextDef&&condtextDef.sort){for(i=0;i<condtextDef.sort.length;i++){oneSortKey=condtextDef.sort[i];if(!(oneSortKey.field in fields)){fields.push(oneSortKey.field);directions.push(oneSortKey.direction)}}}}else{fields=['field1','field2']}
lower=0;upper=this.recordOrder.length;for(i=0;i<fields.length;i++){if(oneRecord[fields[i]]){index=parseInt((upper+lower)/2);do{targetRecord=this.store[this.recordOrder[index]];contextValue=targetRecord[fields[i]];checkingValue=oneRecord[fields[i]];if(contextValue<checkingValue){lower=index}else if(contextValue>checkingValue){upper=index}else{lower=upper=index}
index=parseInt((upper+lower)/2)}while(upper-lower>1);targetRecord=this.store[this.recordOrder[index]];contextValue=targetRecord[fields[i]];if(contextValue===checkingValue){lower=upper=index;stop=!1;do{targetRecord=this.store[this.recordOrder[lower-1]];if(targetRecord&&targetRecord[fields[i]]&&targetRecord[fields[i]]===checkingValue){lower--}else{stop=!0}}while(!stop);stop=!1;do{targetRecord=this.store[this.recordOrder[upper+1]];if(targetRecord&&targetRecord[fields[i]]&&targetRecord[fields[i]]===checkingValue){upper++}else{stop=!0}}while(!stop);if(lower===upper){break}
upper++}else if(contextValue<checkingValue){break}else if(contextValue>checkingValue){index--;break}}}
return index};IMLibContext.prototype.rearrangePendingOrder=function(isDebug){'use strict';var i,index,targetRecord;for(i=0;i<this.pendingOrder.length;i++){targetRecord=this.store[this.pendingOrder[i]];index=this.checkOrder(targetRecord,isDebug);if(index>=-1){this.recordOrder.splice(index+1,0,this.pendingOrder[i])}}
this.pendingOrder=[]};IMLibContext.prototype.getRepeaterEndNode=function(index){'use strict';var nodeId,field,repeaters=[],repeater,node,i,enclosure,children;var recKey=this.recordOrder[index];for(field in this.binding[recKey]){if(this.binding[recKey].hasOwnProperty(field)){nodeId=this.binding[recKey][field].nodeId;repeater=INTERMediatorLib.getParentRepeaters(document.getElementById(nodeId));for(i=0;i<repeater.length;i+=1){if(!(repeater[i]in repeaters)){repeaters.push(repeater[i])}}}}
if(repeaters.length<1){return null}
node=repeaters[0];enclosure=INTERMediatorLib.getParentEnclosure(node);children=enclosure.childNodes;for(i=0;i<children.length;i++){if(children[i]in repeaters){node=repeaters[i];break}}
return node};IMLibContext.prototype.storeRecords=function(records){'use strict';var ix,record,field,keyField,keyValue;var contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName);keyField=contextDef.key?contextDef.key:'id';if(records.recordset){for(ix=0;ix<records.recordset.length;ix++){record=records.recordset[ix];for(field in record){if(record.hasOwnProperty(field)){keyValue=record[keyField]?record[keyField]:ix;this.setValue(keyField+'='+keyValue,field,record[field])}}}}};IMLibContext.prototype.getDataAtLastRecord=function(key){'use strict';var lastKey;var storekeys=Object.keys(this.store);if(storekeys.length>0){lastKey=storekeys[storekeys.length-1];return this.getValue(lastKey,key)}
return undefined};IMLibContext.prototype.setDataAtLastRecord=function(key,value){'use strict';var lastKey,keyAndValue,contextName;var storekeys=Object.keys(this.store);if(storekeys.length>0){lastKey=storekeys[storekeys.length-1];this.setValue(lastKey,key,value);contextName=this.contextName;keyAndValue=lastKey.split('=');IMLibQueue.setTask((function(){var params={name:contextName,conditions:[{field:keyAndValue[0],operator:'=',value:keyAndValue[1]}],dataset:[{field:key,value:value}]};return function(completeTask){INTERMediator_DBAdapter.db_update(params);IMLibCalc.recalculation();INTERMediatorLog.flushMessage();completeTask()}})())}};IMLibContext.prototype.setDataWithKey=function(pkValue,key,value){'use strict';var targetKey,contextDef,storeElements,contextName;contextDef=this.getContextDef();if(!contextDef){return}
targetKey=contextDef.key+'='+pkValue;storeElements=this.store[targetKey];if(storeElements){this.setValue(targetKey,key,value);contextName=this.contextName;IMLibQueue.setTask((function(){var params={name:contextName,conditions:[{field:contextDef.key,operator:'=',value:pkValue}],dataset:[{field:key,value:value}]};return function(completeTask){INTERMediator_DBAdapter.db_update(params);INTERMediatorLog.flushMessage();completeTask()}})())}};IMLibContext.prototype.setValue=function(recKey,key,value,nodeId,target,portal){'use strict';var updatedNodeIds=null;if(portal){console.error('Using the portal parameter in IMLibContext.setValue')}
if(recKey){if(this.store[recKey]===undefined){this.store[recKey]={}}
if(portal&&this.store[recKey][key]===undefined){this.store[recKey][key]={}}
if(this.binding[recKey]===undefined){this.binding[recKey]={};if(this.sequencing){this.recordOrder.push(recKey)}else{this.pendingOrder.push(recKey)}}
if(this.binding[recKey][key]===undefined){this.binding[recKey][key]=[]}
if(portal&&this.binding[recKey][key][portal]===undefined){if(this.binding[recKey][key].length<1){this.binding[recKey][key]={}}
this.binding[recKey][key][portal]=[]}
if(key){if(portal){this.store[recKey][key]=value}else{this.store[recKey][key]=value}
if(nodeId){if(portal){this.binding[recKey][key].push({id:nodeId,target:target})}else{this.binding[recKey][key].push({id:nodeId,target:target})}
if(this.contextInfo[nodeId]===undefined){this.contextInfo[nodeId]={}}
this.contextInfo[nodeId][target?target:'_im_no_target']={context:this,record:recKey,field:key};if(portal){this.contextInfo[nodeId][target?target:'_im_no_target'].portal=portal}}else{if(INTERMediator.partialConstructing){updatedNodeIds=IMLibContextPool.synchronize(this,recKey,key,value,target,portal)}}}}
return updatedNodeIds};IMLibContext.prototype.getValue=function(recKey,key,portal){'use strict';var value;try{if(portal){value=this.store[portal][key]}else{value=this.store[recKey][key]}
if(Array.isArray(value)){value=value.join()}
return value===undefined?null:value}catch(ex){return null}};IMLibContext.prototype.isValueUndefined=function(recKey,key,portal){'use strict';var value,tableOccurence,relatedRecId;try{if(portal){tableOccurence=key.split('::')[0];relatedRecId=portal.split('=')[1];value=this.store[recKey][0][tableOccurence][relatedRecId][key]}else{value=this.store[recKey][key]}
return value===undefined?!0:!1}catch(ex){return null}};IMLibContext.prototype.getContextInfo=function(nodeId,target){'use strict';try{var info=this.contextInfo[nodeId][target?target:'_im_no_target'];return info===undefined?null:info}catch(ex){return null}};IMLibContext.prototype.getContextValue=function(nodeId,target){'use strict';try{var info=this.contextInfo[nodeId][target?target:'_im_no_target'];var value=info.context.getValue(info.record,info.field);return value===undefined?null:value}catch(ex){return null}};IMLibContext.prototype.getContextRecord=function(nodeId){'use strict';var infos,keys,i;try{infos=this.contextInfo[nodeId];keys=Object.keys(infos);for(i=0;i<keys.length;i++){if(infos[keys[i]]){return this.store[infos[keys[i]].record]}}
return null}catch(ex){return null}};IMLibContext.prototype.removeEntry=function(pkvalue){'use strict';var keyField,keying,bindingInfo,contextDef,targetNode,repeaterNodes,i,removingNodeIds=[];contextDef=this.getContextDef();keyField=contextDef.key;keying=keyField+'='+pkvalue;bindingInfo=this.binding[keying];if(bindingInfo){repeaterNodes=bindingInfo._im_repeater;if(repeaterNodes){for(i=0;i<repeaterNodes.length;i++){removingNodeIds.push(repeaterNodes[i].id)}}}
if(removingNodeIds.length>0){for(i=0;i<removingNodeIds.length;i++){IMLibContextPool.removeRecordFromPool(removingNodeIds[i])}
for(i=0;i<removingNodeIds.length;i++){targetNode=document.getElementById(removingNodeIds[i]);if(targetNode){targetNode.parentNode.removeChild(targetNode)}}}};IMLibContext.prototype.isContaining=function(value){'use strict';var contextDef,contextName,checkResult=[],i,fieldName,result,opePosition,leftHand,rightHand,leftResult,rightResult;contextDef=this.getContextDef();contextName=contextDef.name;if(contextDef.query){for(i in contextDef.query){if(contextDef.query.hasOwnProperty(i)){checkResult.push(checkCondition(contextDef.query[i],value))}}}
if(INTERMediator.additionalCondition[contextName]){for(i=0;i<INTERMediator.additionalCondition[contextName].length;i++){checkResult.push(checkCondition(INTERMediator.additionalCondition[contextName][i],value))}}
result=!0;if(checkResult.length!==0){opePosition=checkResult.indexOf('D');if(opePosition>-1){leftHand=checkResult.slice(0,opePosition);rightHand=opePosition.slice(opePosition+1);if(rightHand.length===0){result=(leftHand.indexOf(!1)<0)}else{leftResult=(leftHand.indexOf(!1)<0);rightResult=(rightHand.indexOf(!1)<0);result=leftResult||rightResult}}else{opePosition=checkResult.indexOf('EX');if(opePosition>-1){leftHand=checkResult.slice(0,opePosition);rightHand=opePosition.slice(opePosition+1);if(rightHand.length===0){result=(leftHand.indexOf(!0)>-1)}else{leftResult=(leftHand.indexOf(!0)>-1);rightResult=(rightHand.indexOf(!0)>-1);result=leftResult&&rightResult}}else{opePosition=checkResult.indexOf(!1);if(opePosition>-1){result=(checkResult.indexOf(!1)<0)}}}
if(result===!1){return!1}}
if(this.foreignValue){for(fieldName in this.foreignValue){if(contextDef.relation){for(i in contextDef.relation){if(contextDef.relation[i]['join-field']===fieldName){result&=(checkCondition({field:contextDef.relation[i]['foreign-key'],operator:'=',value:this.foreignValue[fieldName]},value))}}}}}
return result;function checkCondition(conditionDef,oneRecord){var realValue;if(conditionDef.field==='__operation__'){return conditionDef.operator==='ex'?'EX':'D'}
realValue=oneRecord[conditionDef.field];if(!realValue){return!1}
switch(conditionDef.operator){case '=':case 'eq':return String(realValue)===String(conditionDef.value);case '>':case 'gt':return realValue>conditionDef.value;case '<':case 'lt':return realValue<conditionDef.value;case '>=':case 'gte':return realValue>=conditionDef.value;case '<=':case 'lte':return realValue<=conditionDef.value;case '!=':case 'neq':return String(realValue)!==String(conditionDef.value);default:return!1}}};IMLibContext.prototype.insertEntry=function(pkvalue,fields,values){'use strict';var i,field,value;for(i=0;i<fields.length;i++){field=fields[i];value=values[i];this.setValue(pkvalue,field,value)}};var IMLibLocalContext={contextName:'_',store:{},binding:{},clearAll:function(){'use strict';this.store={}},setValue:function(key,value,withoutArchive){'use strict';var i,hasUpdated,refIds,node;hasUpdated=!1;if(key){if(value===undefined||value===null){delete this.store[key]}else{this.store[key]=value;hasUpdated=!0;refIds=this.binding[key];if(refIds){for(i=0;i<refIds.length;i++){node=document.getElementById(refIds[i]);IMLibElement.setValueToIMNode(node,'',value,!0)}}}}
if(hasUpdated&&withoutArchive!==!0){this.archive()}},getValue:function(key){'use strict';var value=this.store[key];return value===undefined?null:value},archive:function(){'use strict';var jsonString,key,searchLen,hashLen,trailLen;INTERMediatorOnPage.removeCookie('_im_localcontext');if(INTERMediator.isIE&&INTERMediator.ieVersion<9){this.store._im_additionalCondition=INTERMediator.additionalCondition;this.store._im_additionalSortKey=INTERMediator.additionalSortKey;this.store._im_startFrom=INTERMediator.startFrom;this.store._im_pagedSize=INTERMediator.pagedSize;jsonString=JSON.stringify(this.store,function(k,v){return v===''?'':v})}else{jsonString=JSON.stringify(this.store)}
if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{searchLen=location.search?location.search.length:0;hashLen=location.hash?location.hash.length:0;trailLen=searchLen+hashLen;key='_im_localcontext'+document.URL.toString();key=(trailLen>0)?key.slice(0,-trailLen):key;sessionStorage.setItem(key,jsonString)}catch(ex){INTERMediatorOnPage.setCookieWorker('_im_localcontext',jsonString,!1,0)}}else{INTERMediatorOnPage.setCookieWorker('_im_localcontext',jsonString,!1,0)}},unarchive:function(){'use strict';var localContext='',searchLen,hashLen,key,trailLen;if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{searchLen=location.search?location.search.length:0;hashLen=location.hash?location.hash.length:0;trailLen=searchLen+hashLen;key='_im_localcontext'+document.URL.toString();key=(trailLen>0)?key.slice(0,-trailLen):key;localContext=sessionStorage.getItem(key)}catch(ex){localContext=INTERMediatorOnPage.getCookie('_im_localcontext')}}else{localContext=INTERMediatorOnPage.getCookie('_im_localcontext')}
if(localContext&&localContext.length>0){this.store=JSON.parse(localContext);if(INTERMediator.isIE&&INTERMediator.ieVersion<9){if(this.store._im_additionalCondition){INTERMediator.additionalCondition=this.store._im_additionalCondition}
if(this.store._im_additionalSortKey){INTERMediator.additionalSortKey=this.store._im_additionalSortKey}
if(this.store._im_startFrom){INTERMediator.startFrom=this.store._im_startFrom}
if(this.store._im_pagedSize){INTERMediator.pagedSize=this.store._im_pagedSize}}
this.updateAll(!0)}},bindingNode:function(node){'use strict';var linkInfos,nodeInfo,idValue,i,j,value,params,unbinding,unexistId,dataImControl;if(node.nodeType!==1){return}
linkInfos=INTERMediatorLib.getLinkedElementInfo(node);dataImControl=node.getAttribute('data-im-control');unbinding=(dataImControl&&dataImControl==='unbind');for(i=0;i<linkInfos.length;i++){nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===this.contextName){if(!node.id){node.id=INTERMediator.nextIdValue()}
idValue=node.id;if(!this.binding[nodeInfo.field]){this.binding[nodeInfo.field]=[]}
if(this.binding[nodeInfo.field].indexOf(idValue)<0&&!unbinding){this.binding[nodeInfo.field].push(idValue)}
unexistId=-1;while(unexistId>=0){for(j=0;j<this.binding[nodeInfo.field].length;j++){if(!document.getElementById(this.binding[nodeInfo.field][j])){unexistId=j}}
if(unexistId>=0){delete this.binding[nodeInfo.field][unexistId]}}
value=this.store[nodeInfo.field];IMLibElement.setValueToIMNode(node,nodeInfo.target,value,!0);params=nodeInfo.field.split(':');switch(params[0]){case 'addorder':IMLibMouseEventDispatch.setExecute(idValue,IMLibUI.eventAddOrderHandler);break;case 'update':IMLibMouseEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})());break;case 'condition':var attrType=node.getAttribute('type');if(attrType&&attrType==='text'){IMLibKeyDownEventDispatch.setExecuteByCode(idValue,13,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})())}else if(attrType&&(attrType==='checkbox'||attrType==='radio')){IMLibChangeEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})())}
break;case 'limitnumber':if(node.value){this.store[nodeInfo.field]=node.value}
IMLibChangeEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})());node.setAttribute('data-imchangeadded','set');break;default:IMLibChangeEventDispatch.setExecute(idValue,IMLibLocalContext.update);break}}}},update:function(idValue){'use strict';IMLibLocalContext.updateFromNodeValue(idValue)},updateFromNodeValue:function(idValue){'use strict';var node,nodeValue,linkInfos,nodeInfo,i;node=document.getElementById(idValue);nodeValue=IMLibElement.getValueFromIMNode(node);linkInfos=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<linkInfos.length;i++){IMLibLocalContext.store[linkInfos[i]]=nodeValue;nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===IMLibLocalContext.contextName){IMLibLocalContext.setValue(nodeInfo.field,nodeValue)}}},updateFromStore:function(idValue){'use strict';var node,nodeValue,linkInfos,nodeInfo,i,target,comp;node=document.getElementById(idValue);target=node.getAttribute('data-im');comp=target.split(INTERMediator.separator);if(comp[1]){nodeValue=IMLibLocalContext.store[comp[1]];linkInfos=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<linkInfos.length;i++){IMLibLocalContext.store[linkInfos[i]]=nodeValue;nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===IMLibLocalContext.contextName){IMLibLocalContext.setValue(nodeInfo.field,nodeValue)}}}},updateAll:function(isStore){'use strict';var index,key,nodeIds,idValue,targetNode;for(key in IMLibLocalContext.binding){if(IMLibLocalContext.binding.hasOwnProperty(key)){nodeIds=IMLibLocalContext.binding[key];for(index=0;index<nodeIds.length;index++){idValue=nodeIds[index];targetNode=document.getElementById(idValue);if(targetNode&&(targetNode.tagName==='INPUT'||targetNode.tagName==='TEXTAREA'||targetNode.tagName==='SELECT')){if(isStore===!0){IMLibLocalContext.updateFromStore(idValue)}else{IMLibLocalContext.updateFromNodeValue(idValue)}
break}}}}},checkedBinding:[],bindingDescendant:function(rootNode){'use strict';var self=this;seek(rootNode);IMLibLocalContext.checkedBinding.push(rootNode);function seek(node){var children,i;if(node!==rootNode&&IMLibLocalContext.checkedBinding.indexOf(node)>-1){return}
if(node.nodeType===1){try{self.bindingNode(node);children=node.childNodes;if(children){for(i=0;i<children.length;i++){seek(children[i])}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-31')}}}}}};var IMLib={nl_char:'\n',cr_char:'\r',tab_char:'\t',singleQuote_char:'\'',doubleQuote_char:'"',backSlash_char:'\\',get zerolength_str(){'use strict';return''},set zerolength_str(value){},get crlf_str(){'use strict';return'\r\n'},set crlf_str(value){}};var INTERMediatorLib={ignoreEnclosureRepeaterClassName:'_im_ignore_enc_rep',ignoreEnclosureRepeaterControlName:'ignore_enc_rep',roleAsRepeaterClassName:'_im_repeater',roleAsEnclosureClassName:'_im_enclosure',roleAsRepeaterDataControlName:'repeater',roleAsEnclosureDataControlName:'enclosure',roleAsSeparatorDataControlName:'separator',roleAsHeaderDataControlName:'header',roleAsFooterDataControlName:'footer',roleAsNoResultDataControlName:'noresult',initialize:function(){'use strict';IMLibLocalContext.unarchive();return null},setup:function(){'use strict';if(window.addEventListener){window.addEventListener('load',this.initialize,!1)}else if(window.attachEvent){window.attachEvent('onload',this.initialize)}else{window.onload=this.initialize}
return null},markProcessed:function(node){'use strict';node.setAttribute('data-im-element','processed')},isProcessed:function(node){'use strict';return node.getAttribute('data-im-element')==='processed'},generatePasswordHash:function(password){'use strict';var numToHex,salt,saltHex,code,lowCode,highCode,i;numToHex=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];salt='';saltHex='';for(i=0;i<4;i++){code=Math.floor(Math.random()*(128-32)+32);lowCode=code&0xF;highCode=(code>>4)&0xF;salt+=String.fromCharCode(code);saltHex+=numToHex[highCode]+numToHex[lowCode]}
return encodeURIComponent(SHA1(password+salt)+saltHex)},getParentRepeater:function(node){console.error('INTERMediatorLib.getParentRepeater method in INTER-Mediator-Lib.js will be removed in Ver.6.0. '+'The alternative method is getParentRepeaters.');'use strict';var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null},getParentRepeaters:function(node){'use strict';var i,target='',linkInfo,result=[],linkComp,nInfos,repeaters;if(!node){return null}
linkInfo=INTERMediatorLib.getLinkedElementInfo(node);if(linkInfo){linkComp=linkInfo[0].split('@');if(linkComp.length>2){target=linkComp[2]}
nInfos=IMLibContextPool.getContextInfoFromId(node.id,target);if(nInfos){repeaters=nInfos.context.binding[nInfos.record]._im_repeater}else{repeaters=seekFromContextPool(node)}}else{repeaters=seekFromContextPool(node)}
if(repeaters){for(i=0;i<repeaters.length;i+=1){result.push(document.getElementById(repeaters[i].id))}}
return result;function seekFromContextPool(node){var i,j,k,currentNode,repeaters;if(!node){return null}
currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){for(i=0;i<IMLibContextPool.poolingContexts.length;i++){for(j in IMLibContextPool.poolingContexts[i].binding){if(IMLibContextPool.poolingContexts[i].binding.hasOwnProperty(j)&&IMLibContextPool.poolingContexts[i].binding[j].hasOwnProperty('_im_repeater')){for(k=0;k<IMLibContextPool.poolingContexts[i].binding[j]._im_repeater.length;k++){if(IMLibContextPool.poolingContexts[i].binding[j]._im_repeater[k].id===currentNode.id){repeaters=IMLibContextPool.poolingContexts[i].binding[j]._im_repeater;return repeaters}}}}}}
currentNode=currentNode.parentNode}
return null}},getParentEnclosure:function(node){'use strict';var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isEnclosure(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null},isEnclosure:function(node,nodeOnly){'use strict';var tagName,className,children,k,controlAttr;if(!node||node.nodeType!==1){return!1}
className=INTERMediatorLib.getClassAttributeFromNode(node);if(className&&className.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterClassName)>=0){return!1}
controlAttr=node.getAttribute('data-im-control');if(controlAttr&&controlAttr.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterControlName)>=0){return!1}
tagName=node.tagName;if((tagName==='TBODY')||(tagName==='UL')||(tagName==='OL')||(tagName==='SELECT')||((tagName==='DIV'||tagName==='SPAN')&&className&&className.indexOf(INTERMediatorLib.roleAsEnclosureClassName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsEnclosureDataControlName)>=0)){if(nodeOnly){return!0}else{children=node.childNodes;for(k=0;k<children.length;k++){if(INTERMediatorLib.isRepeater(children[k],!0)){return!0}}}}
return!1},isRepeater:function(node,nodeOnly){'use strict';var tagName,className,children,k,controlAttr;if(!node||node.nodeType!==1){return!1}
className=INTERMediatorLib.getClassAttributeFromNode(node);if(className&&className.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterClassName)>=0){return!1}
controlAttr=node.getAttribute('data-im-control');if(controlAttr&&controlAttr.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterControlName)>=0){return!1}
tagName=node.tagName;if((tagName==='TR')||(tagName==='LI')||(tagName==='OPTION')||(className&&className.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)){if(nodeOnly){return!0}else{return searchLinkedElement(node)}}
return!1;function searchLinkedElement(node){if(INTERMediatorLib.isLinkedElement(node)){return!0}
children=node.childNodes;for(k=0;k<children.length;k++){if(children[k].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[k])){return!0}else if(searchLinkedElement(children[k])){return!0}}}
return!1}},isLinkedElement:function(node){'use strict';var classInfo,matched,attr;if(node!==null&&node.getAttribute){attr=node.getAttribute('data-im');if(attr){return!0}
if(INTERMediator.titleAsLinkInfo){if(node.getAttribute('TITLE')!==null&&node.getAttribute('TITLE').length>0){return!0}}
if(INTERMediator.classAsLinkInfo){classInfo=INTERMediatorLib.getClassAttributeFromNode(node);if(classInfo!==null){matched=classInfo.match(/IM\[.*\]/);if(matched){return!0}}}}
return!1},isWidgetElement:function(node){'use strict';var classInfo,matched,attr,parentNode;if(!node){return!1}
if(INTERMediatorLib.getLinkedElementInfo(node)){attr=node.getAttribute('data-im-widget');if(attr){return!0}
classInfo=INTERMediatorLib.getClassAttributeFromNode(node);if(classInfo!==null){matched=classInfo.match(/IM_WIDGET\[.*\]/);if(matched){return!0}}}else{parentNode=node.parentNode;if(!parentNode&&INTERMediatorLib.getLinkedElementInfoImpl(parentNode)){attr=parentNode.getAttribute('data-im-widget');if(attr){return!0}
classInfo=INTERMediatorLib.getClassAttributeFromNode(parentNode);if(classInfo!==null){matched=classInfo.match(/IM_WIDGET\[.*\]/);if(matched){return!0}}}}
return!1},isNamedElement:function(node){'use strict';var nameInfo,matched;if(node!==null){nameInfo=node.getAttribute('data-im-group');if(nameInfo){return!0}
nameInfo=node.getAttribute('name');if(nameInfo){matched=nameInfo.match(/IM\[.*\]/);if(matched){return!0}}}
return!1},getEnclosureSimple:function(node){'use strict';if(INTERMediatorLib.isEnclosure(node,!0)){return node}
return INTERMediatorLib.getEnclosureSimple(node.parentNode)},getEnclosure:function(node){'use strict';var currentNode,detectedRepeater;currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){detectedRepeater=currentNode}else if(isRepeaterOfEnclosure(detectedRepeater,currentNode)){detectedRepeater=null;return currentNode}
currentNode=currentNode.parentNode}
return null;function isRepeaterOfEnclosure(repeater,enclosure){var repeaterTag,enclosureTag,enclosureClass,repeaterClass,enclosureDataAttr,repeaterDataAttr,repeaterType;if(!repeater||!enclosure){return!1}
repeaterTag=repeater.tagName;enclosureTag=enclosure.tagName;if((repeaterTag==='TR'&&enclosureTag==='TBODY')||(repeaterTag==='OPTION'&&enclosureTag==='SELECT')||(repeaterTag==='LI'&&enclosureTag==='OL')||(repeaterTag==='LI'&&enclosureTag==='UL')){return!0}
enclosureClass=INTERMediatorLib.getClassAttributeFromNode(enclosure);enclosureDataAttr=enclosure.getAttribute('data-im-control');if((enclosureClass&&enclosureClass.indexOf(INTERMediatorLib.roleAsEnclosureClassName)>=0)||(enclosureDataAttr&&enclosureDataAttr.indexOf('enclosure')>=0)){repeaterClass=INTERMediatorLib.getClassAttributeFromNode(repeater);repeaterDataAttr=repeater.getAttribute('data-im-control');if((repeaterClass&&repeaterClass.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)){return!0}else if(repeaterTag==='INPUT'){repeaterType=repeater.getAttribute('type');if(repeaterType&&((repeaterType.indexOf('radio')>=0||repeaterType.indexOf('check')>=0))){return!0}}}
return!1}},getLinkedElementInfo:function(node){'use strict';var result=INTERMediatorLib.getLinkedElementInfoImpl(node);if(result!==!1){return result}
if(INTERMediatorLib.isWidgetElement(node.parentNode)){return INTERMediatorLib.getLinkedElementInfo(node.parentNode)}
return!1},getLinkedElementInfoImpl:function(node){'use strict';var defs=[],eachDefs,reg,i,attr,matched;if(INTERMediatorLib.isLinkedElement(node)){attr=node.getAttribute('data-im');if(attr!==null&&attr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=attr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(resolveAlias(eachDefs[i]))}}
return defs}
if(INTERMediator.titleAsLinkInfo&&node.getAttribute('TITLE')){eachDefs=node.getAttribute('TITLE').split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(resolveAlias(eachDefs[i]))}
return defs}
if(INTERMediator.classAsLinkInfo){attr=INTERMediatorLib.getClassAttributeFromNode(node);if(attr!==null&&attr.length>0){matched=attr.match(/IM\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(resolveAlias(eachDefs[i]))}}
return defs}}
return!1;function resolveAlias(def){var aliases=INTERMediatorOnPage.getOptionsAliases();if(aliases&&aliases[def]){return aliases[def]}
return def}},getWidgetInfo:function(node){'use strict';var defs=[],eachDefs,i,classAttr,matched,reg;if(INTERMediatorLib.isWidgetElement(node)){classAttr=node.getAttribute('data-im-widget');if(classAttr&&classAttr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=classAttr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(eachDefs[i])}}
return defs}
classAttr=INTERMediatorLib.getClassAttributeFromNode(node);if(classAttr&&classAttr.length>0){matched=classAttr.match(/IM_WIDGET\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(eachDefs[i])}
return defs}}
return!1},getNamedInfo:function(node){'use strict';var defs=[],eachDefs,i,nameAttr,matched,reg;if(INTERMediatorLib.isNamedElement(node)){nameAttr=node.getAttribute('data-im-group');if(nameAttr&&nameAttr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=nameAttr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(eachDefs[i])}}
return defs}
nameAttr=node.getAttribute('name');if(nameAttr&&nameAttr.length>0){matched=nameAttr.match(/IM\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(eachDefs[i])}
return defs}}
return!1},repeaterTagFromEncTag:function(tag){'use strict';if(tag==='TBODY'){return'TR'}else if(tag==='SELECT'){return'OPTION'}else if(tag==='UL'){return'LI'}else if(tag==='OL'){return'LI'}
return null},getNodeInfoArray:function(nodeInfo){'use strict';var comps,tableName,fieldName,targetName;if(!nodeInfo||!nodeInfo.split){return{'table':null,'field':null,'target':null,'tableindex':null,'crossTable':!1}}
comps=nodeInfo.split(INTERMediator.separator);tableName='';fieldName='';targetName='';if(comps.length===3){tableName=comps[0];fieldName=comps[1];targetName=comps[2]}else if(comps.length===2){tableName=comps[0];fieldName=comps[1]}else{fieldName=nodeInfo}
return{'table':tableName,'field':fieldName,'target':targetName,'tableindex':'_im_index_'+tableName,'crossTable':INTERMediator.crossTableStage===3}},getCalcNodeInfoArray:function(idValue){'use strict';console.error('INTERMediatorLib.getCalcNodeInfoArray method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'Here is no alternative method.');var comps,tableName,fieldName,targetName,node,attribute;if(!idValue){return null}
node=document.getElementById(idValue);if(!node){return null}
attribute=node.getAttribute('data-im');if(!attribute){return null}
comps=attribute.split(INTERMediator.separator);tableName='';fieldName='';targetName='';if(comps.length===3){tableName=comps[0];fieldName=comps[1];targetName=comps[2]}else if(comps.length===2){fieldName=comps[0];targetName=comps[1]}else{fieldName=attribute}
return{'table':tableName,'field':fieldName,'target':targetName,'tableindex':'_im_index_'+tableName}},getClassAttributeFromNode:function(node){'use strict';var str='';if(node===null){return''}
if(INTERMediator.isIE&&INTERMediator.ieVersion<8){str=node.getAttribute('className')}else{str=node.getAttribute('class')}
return str},setClassAttributeToNode:function(node,className){'use strict';if(node===null){return}
if(INTERMediator.isIE&&INTERMediator.ieVersion<8){node.setAttribute('className',className)}else{node.setAttribute('class',className)}},eventInfos:[],addEvent:function(node,evt,func){'use strict';if(node.addEventListener){node.addEventListener(evt,func,!1);this.eventInfos.push({'node':node,'event':evt,'function':func});return this.eventInfos.length-1}else if(node.attachEvent){node.attachEvent('on'+evt,func);this.eventInfos.push({'node':node,'event':evt,'function':func});return this.eventInfos.length-1}
return-1},removeEvent:function(serialId){'use strict';if(this.eventInfos[serialId].node.removeEventListener){this.eventInfos[serialId].node.removeEventListener(this.eventInfos[serialId].evt,this.eventInfos[serialId].func,!1)}else if(this.eventInfos[serialId].node.detachEvent){this.eventInfos[serialId].node.detachEvent('on'+this.eventInfos[serialId].evt,this.eventInfos[serialId].func)}},toNumber:function(str){'use strict';var s='',i,c;str=str.toString();for(i=0;i<str.length;i++){c=str.charAt(i);if((c>='0'&&c<='9')||c==='.'||c==='-'||c===INTERMediatorOnPage.localeInfo.mon_decimal_point){s+=c}else if(c>='0'&&c<='9'){s+=String.fromCharCode(c.charCodeAt(0)-'0'.charCodeAt(0)+'0'.charCodeAt(0))}}
return parseFloat(s)},RoundHalfToEven:function(value,digit){'use strict';throw 'RoundHalfToEven method is NOT implemented.'},Round:function(value,digit){'use strict';var powers=Math.pow(10,digit);return Math.round(value*powers)/powers},normalizeNumerics:function(value){'use strict';var i;var punc=INTERMediatorOnPage.localeInfo.decimal_point?INTERMediatorOnPage.localeInfo.decimal_point:'.';var mpunc=INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.';var rule='0123456789';if(punc){rule+='\\'+punc}
if(mpunc&&mpunc!==punc){rule+='\\'+mpunc}
rule='[^'+rule+']';value=String(value);if(value&&value.match(/[0123456789]/)){for(i=0;i<10;i++){value=value.split(String.fromCharCode(65296+i)).join(String(i))}
value=value.replace('.','.')}
return value?parseFloat(value.replace(new RegExp(rule,'g'),'')):''},objectToString:function(obj){'use strict';var str,i,key,sq=String.fromCharCode(39);if(obj===null){return'null'}
if(typeof obj==='object'){str='';if(obj.constructor===Array){for(i=0;i<obj.length;i++){str+=INTERMediatorLib.objectToString(obj[i])+', '}
return'['+str+']'}else{for(key in obj){if(obj.hasOwnProperty(key)){str+=sq+key+sq+':'+INTERMediatorLib.objectToString(obj[key])+', '}}
return'{'+str+'}'}}else{return sq+obj+sq}},numberFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormat(str,digit,flags)},getTargetTableForRetrieve:function(element){'use strict';if(element.view!==null){return element.view}
return element.name},getTargetTableForUpdate:function(element){'use strict';if(element.table!==null){return element.table}
return element.name},getInsertedString:function(tmpStr,dataArray){'use strict';var resultStr,counter;resultStr=tmpStr;if(dataArray!==null){for(counter=1;counter<=dataArray.length;counter++){resultStr=resultStr.replace('@'+counter+'@',dataArray[counter-1])}}
return resultStr},getInsertedStringFromErrorNumber:function(errNum,dataArray){'use strict';var resultStr,counter,messageArray;messageArray=INTERMediatorOnPage.getMessages();resultStr=messageArray?messageArray[errNum]:'Error:'+errNum;if(dataArray){for(counter=1;counter<=dataArray.length;counter++){resultStr=resultStr.replace('@'+counter+'@',dataArray[counter-1])}}
return resultStr},getNamedObject:function(obj,key,named){'use strict';var index;for(index in obj){if(obj[index][key]===named){return obj[index]}}
return null},getNamedObjectInObjectArray:function(ar,key,named){'use strict';var i;for(i=0;i<ar.length;i++){if(ar[i][key]===named){return ar[i]}}
return null},getNamedValueInObject:function(ar,key,named,retrieveKey){var result=[],index;for(index in ar){if(ar[index][key]===named){result.push(ar[index][retrieveKey])}}
if(result.length===0){return null}else if(result.length===1){return result[0]}else{return result}},is_array:function(target){'use strict';return target&&typeof target==='object'&&typeof target.length==='number'&&typeof target.splice==='function'&&!(target.propertyIsEnumerable('length'))},getNamedValuesInObject:function(ar,key1,named1,key2,named2,retrieveKey){'use strict';var result=[],index;for(index in ar){if(ar.hasOwnProperty(index)&&ar[index][key1]===named1&&ar[index][key2]===named2){result.push(ar[index][retrieveKey])}}
if(result.length===0){return null}else if(result.length===1){return result[0]}else{return result}},getRecordsetFromFieldValueObject:function(obj){'use strict';var recordset={},index;for(index in obj){if(obj.hasOwnProperty(index)){recordset[obj[index].field]=obj[index].value}}
return recordset},getNodePath:function(node){'use strict';if(node.tagName===null){return''}else{return INTERMediatorLib.getNodePath(node.parentNode)+'/'+node.tagName}},isPopupMenu:function(element){'use strict';if(!element||!element.tagName){return!1}
if(element.tagName==='SELECT'){return!0}
return!1},getElementsByClassNameOrDataAttr:function(node,cName){'use strict';var nodes=[],attrValue;attrValue=(cName.match(/^_im_/))?cName.substr(4):cName;if(attrValue){checkNode(node)}
return nodes;function checkNode(target){var value,i,items;if(target===undefined||target.nodeType!==1){return}
value=INTERMediatorLib.getClassAttributeFromNode(target);if(value){items=value.split('|');for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
value=target.getAttribute('data-im-control');if(value){items=value.split(/[| ]/);for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
value=target.getAttribute('data-im');if(value){items=value.split(/[| ]/);for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByAttributeValue:function(node,attribute,value){'use strict';var nodes=[];var reg=new RegExp(value);checkNode(node);return nodes;function checkNode(target){var aValue,i;if(target===undefined||target.nodeType!==1){return}
aValue=target.getAttribute(attribute);if(aValue&&aValue.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByClassName:function(node,cName){'use strict';var nodes=[];var reg=new RegExp(cName);checkNode(node);return nodes;function checkNode(target){var className,i;if(target===undefined||target.nodeType!==1){return}
className=INTERMediatorLib.getClassAttributeFromNode(target);if(className&&className.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByIMManaged:function(node){'use strict';var nodes=[];var reg=new RegExp(/^IM/);checkNode(node);return nodes;function checkNode(target){var nodeId,i;if(target===undefined||target.nodeType!==1){return}
nodeId=target.getAttribute('id');if(nodeId&&nodeId.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},seekLinkedAndWidgetNodes:function(nodes,ignoreEnclosureCheck){'use strict';var linkedNodesCollection=[];var widgetNodesCollection=[];var i,doEncCheck=ignoreEnclosureCheck;if(ignoreEnclosureCheck===undefined||ignoreEnclosureCheck===null){doEncCheck=!1}
for(i=0;i<nodes.length;i++){seekLinkedElement(nodes[i])}
return{linkedNode:linkedNodesCollection,widgetNode:widgetNodesCollection};function seekLinkedElement(node){var nType,currentEnclosure,children,i;nType=node.nodeType;if(nType===1){if(INTERMediatorLib.isLinkedElement(node)){currentEnclosure=doEncCheck?INTERMediatorLib.getEnclosure(node):null;if(currentEnclosure===null){linkedNodesCollection.push(node)}else{return currentEnclosure}}
if(INTERMediatorLib.isWidgetElement(node)){currentEnclosure=doEncCheck?INTERMediatorLib.getEnclosure(node):null;if(currentEnclosure===null){widgetNodesCollection.push(node)}else{return currentEnclosure}}
children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElement(children[i])}}
return null}},createErrorMessageNode:function(tag,message){'use strict';var messageNode;messageNode=document.createElement(tag);INTERMediatorLib.setClassAttributeToNode(messageNode,'_im_alertmessage');messageNode.appendChild(document.createTextNode(message));return messageNode},removeChildNodes:function(node){'use strict';if(node){while(node.childNodes.length>0){node.removeChild(node.childNodes[0])}}},clearErrorMessage:function(node){'use strict';var errorMsgs,j;if(node){errorMsgs=INTERMediatorLib.getElementsByClassName(node.parentNode,'_im_alertmessage');for(j=0;j<errorMsgs.length;j++){errorMsgs[j].parentNode.removeChild(errorMsgs[j])}}},dateTimeStringISO:function(dt){'use strict';dt=(!dt)?new Date():dt;return dt.getFullYear()+'-'+('0'+(dt.getMonth()+1)).substr(-2,2)+'-'+('0'+dt.getDate()).substr(-2,2)+' '+('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)},dateTimeStringFileMaker:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+(dt.getMonth()+1)).substr(-2,2)+'/'+('0'+dt.getDate()).substr(-2,2)+'/'+dt.getFullYear()+' '+('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)},dateStringISO:function(dt){'use strict';dt=(!dt)?new Date():dt;return dt.getFullYear()+'-'+('0'+(dt.getMonth()+1)).substr(-2,2)+'-'+('0'+dt.getDate()).substr(-2,2)},dateStringFileMaker:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+(dt.getMonth()+1)).substr(-2,2)+'/'+('0'+dt.getDate()).substr(-2,2)+'/'+dt.getFullYear()},timeString:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)}};INTERMediatorLib.initialize();var IMLibNodeGraph={nodes:[],edges:[],clear:function(){'use strict';this.nodes=[];this.edges=[]},addNode:function(node){'use strict';if(this.nodes.indexOf(node)<0){this.nodes.push(node)}},addEdge:function(fromNode,toNode){'use strict';if(this.nodes.indexOf(fromNode)<0){this.addNode(fromNode)}
if(this.nodes.indexOf(toNode)<0){this.addNode(toNode)}
this.edges.push({from:fromNode,to:toNode})},getAllNodesInEdge:function(){'use strict';var i,nodes=[];for(i=0;i<this.edges.length;i++){if(nodes.indexOf(this.edges[i].from)<0){nodes.push(this.edges[i].from)}
if(nodes.indexOf(this.edges[i].to)<0){nodes.push(this.edges[i].to)}}
return nodes},getLeafNodes:function(){'use strict';var i,srcs=[],dests=[],srcAndDests=this.getAllNodesInEdge();for(i=0;i<this.edges.length;i++){srcs.push(this.edges[i].from)}
for(i=0;i<this.edges.length;i++){if(srcs.indexOf(this.edges[i].to)<0&&dests.indexOf(this.edges[i].to)<0){dests.push(this.edges[i].to)}}
for(i=0;i<this.nodes.length;i++){if(srcAndDests.indexOf(this.nodes[i])<0){dests.push(this.nodes[i])}}
return dests},getLeafNodesWithRemoving:function(){'use strict';var i,newEdges=[],dests=this.getLeafNodes();for(i=0;i<this.edges.length;i++){if(dests.indexOf(this.edges[i].to)<0){newEdges.push(this.edges[i])}}
this.edges=newEdges;for(i=0;i<dests.length;i++){this.nodes.splice(this.nodes.indexOf(dests[i]),1)}
return dests},removeNode:function(node){'use strict';var i,newEdges=[];for(i=0;i<this.edges.length;i++){if(this.edges[i].to!=node){newEdges.push(this.edges[i])}}
this.edges=newEdges;this.nodes.splice(this.nodes.indexOf(node),1)},applyToAllNodes:function(f){'use strict';var i;for(i=0;i<this.nodes.length;i++){f(this.nodes[i])}},};var IMLibFormat={numberFormatImpl:function(str,digit,decimalPoint,thousandsSep,currencySymbol,flags){'use strict';var s,n,prefix,i,sign,tailSign='',power,underDot,underNumStr,pstr,roundedNum,underDecimalNum,integerNum,formatted,numStr,j,isMinusValue,numerals,numbers;if(str===''||str===null||str===undefined){return''}
prefix=(String(str).substring(0,1)==='-')?'-':'';if(String(str).match(/[-]/)){str=prefix+String(str).split('-').join('')}
n=INTERMediatorLib.toNumber(str);if(isNaN(n)){return''}
if(flags===undefined){flags={}}
sign=INTERMediatorOnPage.localeInfo.positive_sign;isMinusValue=!1;if(n<0){sign=INTERMediatorOnPage.localeInfo.negative_sign;if(flags.negativeStyle===0||flags.negativeStyle===1){sign='-'}else if(flags.negativeStyle===2){sign='(';tailSign=')'}else if(flags.negativeStyle===3){sign='<';tailSign='>'}else if(flags.negativeStyle===4){sign=' CR'}else if(flags.negativeStyle===5){sign='▲'}
n=-n;isMinusValue=!0}
if(flags.blankIfZero===!0&&n===0){return''}
if(flags.usePercentNotation){n=n*100}
underDot=(digit===undefined)?INTERMediatorOnPage.localeInfo.frac_digits:INTERMediatorLib.toNumber(digit);power=Math.pow(10,underDot);roundedNum=Math.round(n*power);underDecimalNum=(underDot>0)?roundedNum%power:0;integerNum=(roundedNum-underDecimalNum)/power;underNumStr=(underDot>0)?String(underDecimalNum):'';while(underNumStr.length<underDot){underNumStr='0'+underNumStr}
if(flags.useSeparator===!0){if(n===0){formatted='0'}else{n=integerNum;s=[];if(flags.kanjiSeparator===1||flags.kanjiSeparator===2){numerals=['万','億','兆','京','垓','𥝱','穣','溝','澗','正','載','極','恒河沙','阿僧祇','那由他','不可思議','無量大数'];i=0;formatted='';for(n=Math.floor(n);n>0;n=Math.floor(n/10000)){if(n>=10000){pstr='0000'+(n%10000).toString()}else{pstr=(n%10000).toString()}
if(flags.kanjiSeparator===1){if(n>=10000){if(pstr.substr(pstr.length-4)!=='0000'){formatted=numerals[i]+Number(pstr.substr(pstr.length-4))+formatted}else{if(numerals[i-1]!==formatted.charAt(0)){formatted=numerals[i]+formatted}else{formatted=numerals[i]+formatted.slice(1)}}}else{formatted=n+formatted}}else if(flags.kanjiSeparator===2){numStr=pstr.substr(pstr.length-4);pstr='';if(numStr==='0001'){pstr='1'}else if(numStr!=='0000'){for(j=0;j<numStr.length;j++){if(numStr.charAt(j)>1){pstr=pstr+numStr.charAt(j)}
if(numStr.charAt(j)>0){if(numStr.length-j===4){pstr=pstr+'千'}else if(numStr.length-j===3){pstr=pstr+'百'}else if(numStr.length-j===2){pstr=pstr+'十'}}}}
if(n>=10000){if(pstr.length>0){formatted=numerals[i]+pstr+formatted}else{if(numerals[i-1]!==formatted.charAt(0)){formatted=numerals[i]+formatted}else{formatted=numerals[i]+formatted.slice(1)}}}else{if(numStr.length===1){formatted=n+formatted}else{formatted=pstr+formatted}}}
i++}
formatted=formatted+(underNumStr===''?'':decimalPoint+underNumStr)}else{for(n=Math.floor(n);n>0;n=Math.floor(n/1000)){if(n>=1000){pstr='000'+(n%1000).toString();s.push(pstr.substr(pstr.length-3))}else{s.push(n)}}
formatted=s.reverse().join(thousandsSep)+(underNumStr===''?'':decimalPoint+underNumStr)}
if(flags.negativeStyle===0||flags.negativeStyle===5){formatted=sign+formatted}else if(flags.negativeStyle===1||flags.negativeStyle===4){formatted=formatted+sign}else if(flags.negativeStyle===2||flags.negativeStyle===3){formatted=sign+formatted+tailSign}else{formatted=sign+formatted}}}else{formatted=integerNum+(underNumStr===''?'':decimalPoint+underNumStr);if(flags.negativeStyle===0||flags.negativeStyle===5){formatted=sign+formatted}else if(flags.negativeStyle===1||flags.negativeStyle===4){formatted=formatted+sign}else if(flags.negativeStyle===2||flags.negativeStyle===3){formatted=sign+formatted+tailSign}else{formatted=sign+formatted}}
if(currencySymbol){if(!isMinusValue){if(parseInt(INTERMediatorOnPage.localeInfo.p_cs_precedes)===1){if(parseInt(INTERMediatorOnPage.localeInfo.p_sep_by_space)===1){formatted=currencySymbol+' '+formatted}else{formatted=currencySymbol+formatted}}else{if(parseInt(INTERMediatorOnPage.localeInfo.p_sep_by_space)===1){formatted=formatted+' '+currencySymbol}else{formatted=formatted+currencySymbol}}}else{if(parseInt(INTERMediatorOnPage.localeInfo.n_cs_precedes)===1){if(parseInt(INTERMediatorOnPage.localeInfo.n_sep_by_space)===1){formatted=currencySymbol+' '+formatted}else{formatted=currencySymbol+formatted}}else{if(parseInt(INTERMediatorOnPage.localeInfo.n_sep_by_space)===1){formatted=formatted+' '+currencySymbol}else{formatted=formatted+currencySymbol}}}}
if(flags.charStyle){if(flags.charStyle===1){for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String.fromCharCode(65296+i))}}else if(flags.charStyle===2){numbers={0:'〇',1:'一',2:'二',3:'三',4:'四',5:'五',6:'六',7:'七',8:'八',9:'九'};for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String(numbers[i]))}}else if(flags.charStyle===3){numbers={0:'〇',1:'壱',2:'弐',3:'参',4:'四',5:'伍',6:'六',7:'七',8:'八',9:'九'};for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String(numbers[i]))}}}
if(flags.usePercentNotation===!0&&formatted!==''){formatted=formatted+'%'}
return formatted},getKanjiNumber:function(n){'use strict';var s=[],count=0;String(n).split('').reverse().forEach(function(c){s.push(IMLibFormat.kanjiDigit[count]);count++;s.push(IMLibFormat.kanjiNumbers[parseInt(c)])});return s.reverse().join('')},numberFormat:function(str,digit,flags){'use strict';if(flags===undefined){flags={}}
flags.useSeparator=!0;return this.decimalFormat(str,digit,flags)},percentFormat:function(str,digit,flags){'use strict';if(typeof flags!=='object'){flags={}}
flags.usePercentNotation=!0;return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',!1,flags)},decimalFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',!1,flags)},currencyFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',INTERMediatorOnPage.localeInfo.currency_symbol?INTERMediatorOnPage.localeInfo.currency_symbol:'¥',flags)},booleanFormat:function(str,forms){'use strict';var trueString='true',falseString='false',fmtStr;var params=forms.split(',');if(params[0]){fmtStr=params[0].trim();if(fmtStr.length>0){trueString=fmtStr}}
if(params[1]){fmtStr=params[1].trim();if(fmtStr.length>0){falseString=fmtStr}}
if(str===''||str===null){return''}else{if(parseInt(str,10)!==0){return trueString}else{return falseString}}},datetimeFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'datetime')},dateFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'date')},timeFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'time')},placeHolder:{'%Y':Date.prototype.getFullYear,'%y':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getFullYear())},'%g':function(){'use strict';return IMLibFormat.getLocalYear(this,1)},'%G':function(){'use strict';return IMLibFormat.getLocalYear(this,2)},'%M':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getMonth()+1)},'%m':function(){'use strict';return this.getMonth()+1},'%b':function(){'use strict';return INTERMediatorOnPage.localeInfo.ABMON[this.getMonth()]},'%B':function(){'use strict';return INTERMediatorOnPage.localeInfo.MON[this.getMonth()]},'%t':function(){'use strict';return IMLibFormat.eMonAbbr[this.getMonth()]},'%T':function(){'use strict';return IMLibFormat.eMonName[this.getMonth()]},'%D':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getDate())},'%d':Date.prototype.getDate,'%a':function(){'use strict';return IMLibFormat.eDayAbbr[this.getDay()]},'%A':function(){'use strict';return IMLibFormat.eDayName[this.getDay()]},'%w':function(){'use strict';return INTERMediatorOnPage.localeInfo.ABDAY[this.getDay()]},'%W':function(){'use strict';return INTERMediatorOnPage.localeInfo.DAY[this.getDay()]},'%H':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getHours())},'%h':Date.prototype.getHours,'%J':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getHours()%12)},'%j':function(){'use strict';return this.getHours()%12},'%K':function(){'use strict';var n=this.getHours()%12;return IMLibFormat.tweDigitsNumber(n===0?12:n)},'%k':function(){'use strict';var n=this.getHours()%12;return n===0?12:n},'%I':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getMinutes())},'%i':Date.prototype.getMinutes,'%S':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getSeconds())},'%s':Date.prototype.getSeconds,'%P':function(){'use strict';return Math.floor(this.getHours()/12)===0?'AM':'PM'},'%p':function(){'use strict';return Math.floor(this.getHours()/12)===0?'am':'pm'},'%N':function(){'use strict';return Math.floor(this.getHours()/12)===0?INTERMediatorOnPage.localeInfo.AM_STR:INTERMediatorOnPage.localeInfo.PM_STR},'%%':function(){'use strict';return'%'}},tweDigitsNumber:function(n){'use strict';var v=parseInt(n);return('0'+v.toString()).substr(-2,2)},jYearStartDate:{'2019/5/1':'令和','1989/1/8':'平成','1926/12/25':'昭和','1912/7/30':'大正','1868/1/25':'明治'},eDayName:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],eDayAbbr:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],eMonName:['January','February','March','April','May','June','July','August','September','October','November','December'],eMonAbbr:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],kanjiNumbers:['〇','一','二','三','四','五','六','七','八','九'],kanjiDigit:['','十','百','千','万'],getLocalYear:function(dt,fmt){'use strict';var gengoName,gengoYear,startDateStr,dtStart;if(!dt){return''}
gengoName='';gengoYear=0;for(startDateStr in IMLibFormat.jYearStartDate){if(IMLibFormat.jYearStartDate.hasOwnProperty(startDateStr)){dtStart=new Date(startDateStr);if(dt>=dtStart){gengoName=IMLibFormat.jYearStartDate[startDateStr];gengoYear=dt.getFullYear()-dtStart.getFullYear()+1;gengoYear=((gengoYear===1)?'元':(fmt===2?IMLibFormat.getKanjiNumber(gengoYear):gengoYear));break}}}
return gengoName+gengoYear+'年'},datetimeFormatImpl:function(str,params,flags){'use strict';var dt,c,result='',replaced,hasColon,hasSlash,hasDash;str=(Object.prototype.toString.call(str)==='[object Array]')?str.join():str;var paramStr=params.trim().toUpperCase();var kind=flags.trim().toUpperCase();var key=kind.substr(0,1)+'_FMT_'+paramStr;if(INTERMediatorOnPage.localeInfo[key]){params=INTERMediatorOnPage.localeInfo[key];if(kind==='DATETIME'){params+=' '+INTERMediatorOnPage.localeInfo['T_FMT_'+paramStr]}}
hasColon=str.indexOf(':')>-1;hasSlash=str.indexOf('/')>-1;hasDash=str.indexOf('-')>-1;if(!hasColon&&(hasSlash||hasDash)){str+=' 00:00:00'}else if(hasColon&&!hasSlash&&!hasDash){str='1970/01/01 '+str}
dt=new Date(str);if(dt.toString()==='Invalid Date'){dt=new Date(str.replace(/-/g,'/'))}
if(dt.toString()==='Invalid Date'){return''}
for(c=0;c<params.length;c++){if((c+1)<params.length&&IMLibFormat.placeHolder[params.substr(c,2)]){replaced=(IMLibFormat.placeHolder[params.substr(c,2)]).apply(dt);result+=replaced;c++}else{result+=params.substr(c,1)}}
return result},convertNumeric:function(value){'use strict';value=value.replace(new RegExp(INTERMediatorOnPage.localeInfo.mon_thousands_sep,'g'),'');value=INTERMediatorLib.normalizeNumerics(value);if(value!==''){value=parseFloat(value)}
return value},convertBoolean:function(value,forms){'use strict';var trueString='true',falseString='false',fmtStr;value=value.trim();var params=forms.split(',');if(params[0]){fmtStr=params[0].trim();if(fmtStr.length>0){trueString=fmtStr}}
if(params[1]){fmtStr=params[1].trim();if(fmtStr.length>0){falseString=fmtStr}}
if(value===trueString){return!0}else if(value===falseString){return!1}
return null},convertPercent:function(value){'use strict';value=value.replace(new RegExp(INTERMediatorOnPage.localeInfo.mon_thousands_sep,'g'),'');value=value.replace('%','');value=INTERMediatorLib.normalizeNumerics(value);if(value!==''){value=parseFloat(value)/100}
return value},convertDate:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'date')},convertTime:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'time')},convertDateTime:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'datetime')},convertDateTimeImpl:function(value,params,flags){'use strict';var c,result,replacement=[],regexp='';var r,matched,y,m,d,h,i,s,paramStr,kind,key,mon;paramStr=params.trim().toUpperCase();kind=flags.trim().toUpperCase();key=kind.substr(0,1)+'_FMT_'+paramStr;if(INTERMediatorOnPage.localeInfo[key]){params=INTERMediatorOnPage.localeInfo[key];if(kind==='DATETIME'){params+=' '+INTERMediatorOnPage.localeInfo['T_FMT_'+paramStr]}}
params=params.replace(/([\(\)])/g,'\\$1');for(c=0;c<params.length;c++){if((c+1)<params.length&&IMLibFormat.reverseRegExp[params.substr(c,2)]){regexp+=IMLibFormat.reverseRegExp[params.substr(c,2)];replacement.push(params.substr(c,2));c++}else{regexp+=params.substr(c,1)}}
r=new RegExp(regexp);matched=r.exec(value);result=value;if(matched){for(c=0;c<replacement.length;c++){switch(replacement[c]){case '%Y':case '%y':y=matched[c+1];break;case '%M':case '%m':m=matched[c+1];break;case '%T':case '%t':mon=matched[c+1];m=IMLibFormat.eMonAbbr.indexOf(mon.substr(0,1).toUpperCase()+mon.substr(1,2).toLowerCase());m++;break;case '%D':case '%d':d=matched[c+1];break;case '%H':case '%h':h=matched[c+1];break;case '%I':case '%i':i=matched[c+1];break;case '%S':case '%s':s=matched[c+1];break}}
if(y&&m&&d&&h&&i&&s){result=y+'-'+m+'-'+d+' '+h+':'+i+':'+s}else if(y&&m&&d){result=y+'-'+m+'-'+d}else if(h&&i&&s){result=h+':'+i+':'+s}}
return result},reverseRegExp:{'%Y':'([\\d]{4})','%y':'([\\d]{2})','%g':'(明治|大正|昭和|平成|令和)(元|[\\d]{1,2})年','%G':'(明治|大正|昭和|平成|令和)(.+)年','%M':'([\\d]{1,2})','%m':'([\\d]{1,2})','%b':'(.+)','%B':'(.+)','%t':'(.+)','%T':'(.+)','%D':'([\\d]{1,2})','%d':'([\\d]{1,2})','%a':'(.+)','%A':'(.+)','%w':'(.+)','%W':'(.+)','%H':'([\\d]{1,2})','%h':'([\\d]{1,2})','%J':'([\\d]{1,2})','%j':'([\\d]{1,2})','%K':'([\\d]{1,2})','%k':'([\\d]{1,2})','%I':'([\\d]{1,2})','%i':'([\\d]{1,2})','%S':'([\\d]{1,2})','%s':'([\\d]{1,2})','%P':'(AM|PM)','%p':'(am|pm)','%N':'('+INTERMediatorOnPage.localeInfo.AM_STR+'|'+INTERMediatorOnPage.localeInfo.PM_STR+')','%%':'[\%]'}};var IMLibElement={formatters:{number:IMLibFormat.decimalFormat,currency:IMLibFormat.currencyFormat,boolean:IMLibFormat.booleanFormat,percent:IMLibFormat.percentFormat,date:IMLibFormat.dateFormat,datetime:IMLibFormat.datetimeFormat,time:IMLibFormat.timeFormat},unformatters:{number:IMLibFormat.convertNumeric,currency:IMLibFormat.convertNumeric,boolean:IMLibFormat.convertBoolean,percent:IMLibFormat.convertPercent,date:IMLibFormat.convertDate,datetime:IMLibFormat.convertDateTime,time:IMLibFormat.convertTime},formatOptions:{'useseparator':{useSeparator:!0},'blankifzero':{blankIfZero:!0}},formatNegativeStyle:{leadingminus:{negativeStyle:0},'leading-minus':{negativeStyle:0},trailingminus:{negativeStyle:1},'trailing-minus':{negativeStyle:1},parenthesis:{negativeStyle:2},angle:{negativeStyle:3},credit:{negativeStyle:4},triangle:{negativeStyle:5}},formatNumeralType:{'half-width':{charStyle:0},'full-width':{charStyle:1},'kanji-numeral-modern':{charStyle:2},'kanji-numeral':{charStyle:3}},formatKanjiSeparator:{'every-4th-place':{kanjiSeparator:1,useSeparator:!0},'full-notation':{kanjiSeparator:2,useSeparator:!0}},appendObject:function(obj,adding){'use strict';var result=obj;if(adding){for(var key in adding){if(adding.hasOwnProperty(key)){result[key]=adding[key]}}}
return result},initilaizeFlags:function(element){'use strict';var flags,formatOption,negativeStyle,charStyle,kanjiSeparator;flags={useSeparator:!1,blankIfZero:!1,negativeStyle:0,charStyle:0,kanjiSeparator:0};formatOption=element.getAttribute('data-im-format-options');flags=IMLibElement.appendObject(flags,IMLibElement.formatOptions[formatOption]);negativeStyle=element.getAttribute('data-im-format-negative-style');flags=IMLibElement.appendObject(flags,IMLibElement.formatNegativeStyle[negativeStyle]);charStyle=element.getAttribute('data-im-format-numeral-type');flags=IMLibElement.appendObject(flags,IMLibElement.formatNumeralType[charStyle]);kanjiSeparator=element.getAttribute('data-im-format-kanji-separator');flags=IMLibElement.appendObject(flags,IMLibElement.formatKanjiSeparator[kanjiSeparator]);return flags},getFormattedValue:function(element,curVal){'use strict';var flags,formatSpec,parsed,formattedValue=null,params,formatFunc,firstParen,lastParen;formatSpec=element.getAttribute('data-im-format');if(!formatSpec){return null}
flags=IMLibElement.initilaizeFlags(element);params=0;formatFunc=IMLibElement.formatters[formatSpec.trim().toLocaleLowerCase()];if(!formatFunc){firstParen=formatSpec.indexOf('(');lastParen=formatSpec.lastIndexOf(')');parsed=formatSpec.substr(0,firstParen).match(/[^a-zA-Z]*([a-zA-Z]+).*/);formatFunc=IMLibElement.formatters[parsed[1].toLocaleLowerCase()];params=formatSpec.substring(firstParen+1,lastParen);if(params.length===0){params=0}}
if(formatFunc){formattedValue=formatFunc(curVal,params,flags)}
return formattedValue},getUnformattedValue:function(element,value){'use strict';var formatSpec,unformatFunc,parsed,params,convertedValue,flags,firstParen,lastParen;formatSpec=element.getAttribute('data-im-format');if(!formatSpec){return null}
flags=IMLibElement.initilaizeFlags(element);unformatFunc=IMLibElement.unformatters[formatSpec.trim().toLocaleLowerCase()];if(!unformatFunc){firstParen=formatSpec.indexOf('(');lastParen=formatSpec.lastIndexOf(')');parsed=formatSpec.substr(0,firstParen).match(/[^a-zA-Z]*([a-zA-Z]+).*/);unformatFunc=IMLibElement.unformatters[parsed[1].toLocaleLowerCase()];params=formatSpec.substring(firstParen+1,lastParen)}
if(unformatFunc){convertedValue=unformatFunc(value,params,flags)}
return convertedValue},setValueToIMNode:function(element,curTarget,curVal,clearField){'use strict';var styleName,currentValue,scriptNode,typeAttr,valueAttr,textNode,formatSpec,formattedValue,needPostValueSet=!1,curValues,i,isReplaceOrAppend=!1,imControl,negativeColor,originalValue,negativeSign,negativeTailSign,flags;if(curVal===undefined){return!1}
if(!element){return!1}
if(curVal===null||curVal===!1){curVal=''}
if(typeof curVal==='object'&&curVal.constructor===Array&&curVal.length>0){curVal=curVal[0]}
imControl=element.getAttribute('data-im-control');if(clearField&&curTarget===''){switch(element.tagName){case 'INPUT':switch(element.getAttribute('type')){case 'text':element.value='';break}
break;case 'SELECT':break;default:while(element.childNodes.length>0){if(element.parentNode.getAttribute('data-im-element')==='processed'||INTERMediatorLib.isWidgetElement(element.parentNode)){return!1}
element.removeChild(element.childNodes[0])}
break}}
formattedValue=IMLibElement.getFormattedValue(element,curVal);if(element.getAttribute('data-im-format')){if(formattedValue===null){INTERMediatorLog.setErrorMessage('The \'data-im-format\' attribute is not valid: '+formatSpec)}else{curVal=formattedValue}}
curVal=String(curVal);negativeColor=element.getAttribute('data-im-format-negative-color');if(curTarget!==null&&curTarget.length>0){if(curTarget.charAt(0)==='#'){curTarget=curTarget.substring(1);originalValue=element.getAttribute('data-im-original-'+curTarget);if(curTarget==='innerHTML'){currentValue=originalValue?originalValue:element.innerHTML;element.innerHTML=currentValue+curVal}else if(curTarget==='textNode'||curTarget==='script'){currentValue=originalValue?originalValue:element.textContent;element.textContent=currentValue+curVal}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);currentValue=originalValue?originalValue:element.style[styleName];if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=currentValue+curVal}}else{currentValue=originalValue?originalValue:element.getAttribute(curTarget);if(curVal.indexOf('/fmi/xml/cnt/')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal}else if(curVal.indexOf('https://'+location.hostname+'/Streaming_SSL/MainDB')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+encodeURIComponent(curVal.replace('https://'+location.hostname,''))}
element.setAttribute(curTarget,currentValue+curVal)}
isReplaceOrAppend=!0;if(!originalValue){element.setAttribute('data-im-original-'+curTarget,currentValue)}}else if(curTarget.charAt(0)==='){curTarget=curTarget.substring(1);originalValue=element.getAttribute('data-im-original-'+curTarget);if(curTarget==='innerHTML'){currentValue=element.innerHTML;curVal=currentValue.replace(',curVal);if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else if(curTarget==='textNode'||curTarget==='script'){currentValue=element.textContent;element.textContent=currentValue.replace(',curVal)}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);currentValue=element.style[styleName];if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=currentValue.replace(',curVal)}}else{currentValue=element.getAttribute(curTarget);if(curVal.indexOf('/fmi/xml/cnt/')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal}else if(curVal.indexOf('https://'+location.hostname+'/Streaming_SSL/MainDB')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal.replace('https://'+location.hostname,'')}
element.setAttribute(curTarget,currentValue.replace(',curVal))}
isReplaceOrAppend=!0;if(!originalValue){element.setAttribute('data-im-original-'+curTarget,currentValue)}}else{if(INTERMediatorLib.isWidgetElement(element)){if(element._im_setValue){element._im_setValue(curVal)}}else if(curTarget==='innerHTML'){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else if(curTarget==='textNode'){textNode=document.createTextNode(curVal);element.appendChild(textNode)}else if(curTarget==='script'){textNode=document.createTextNode(curVal);if(element.tagName==='SCRIPT'){element.appendChild(textNode)}else{scriptNode=document.createElement('script');scriptNode.type='text/javascript';scriptNode.appendChild(textNode);element.appendChild(scriptNode)}}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=curVal}}else{if(INTERMediator.isIE&&INTERMediator.ieVersion<10&&element.tagName==='TEXTAREA'){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.setAttribute(curTarget,curVal)}}}else{if(INTERMediatorLib.isWidgetElement(element)){if(element._im_setValue){element._im_setValue(curVal)}}else if(element.tagName==='INPUT'){typeAttr=element.getAttribute('type');if(typeAttr==='checkbox'||typeAttr==='radio'){valueAttr=element.value;if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){curValues=curVal.split(IMLib.cr_char)}else{curValues=curVal.split(IMLib.nl_char)}
if(typeAttr==='checkbox'&&curValues.length>1){for(i=0;i<curValues.length;i++){if(valueAttr===curValues[i]&&!INTERMediator.dontSelectRadioCheck){if(INTERMediator.isIE){element.setAttribute('checked','checked')}else{element.checked=!0}}}}else{if(valueAttr===curVal&&!INTERMediator.dontSelectRadioCheck){if(INTERMediator.isIE){element.setAttribute('checked','checked')}else{element.checked=!0}}else{element.checked=!1}}}else{element.value=curVal}}else if(element.tagName==='SELECT'){needPostValueSet=!0;element.value=curVal}else if(element.tagName==='TEXTAREA'){if(INTERMediator.defaultTargetInnerHTML){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else{element.value=curVal}}else{if(INTERMediator.defaultTargetInnerHTML){element.innerHTML=curVal}else{element.appendChild(document.createTextNode(curVal))}}}
if(formatSpec&&negativeColor){negativeSign=INTERMediatorOnPage.localeInfo.negative_sign;negativeTailSign='';flags=IMLibElement.initilaizeFlags(element);if(flags.negativeStyle===0||flags.negativeStyle===1){negativeSign='-'}else if(flags.negativeStyle===2){negativeSign='(';negativeTailSign=')'}else if(flags.negativeStyle===3){negativeSign='<';negativeTailSign='>'}else if(flags.negativeStyle===4){negativeSign=' CR'}else if(flags.negativeStyle===5){negativeSign='▲'}
if(flags.negativeStyle===0||flags.negativeStyle===5){if(curVal.indexOf(negativeSign)===0){element.style.color=negativeColor}}else if(flags.negativeStyle===1||flags.negativeStyle===4){if(curVal.indexOf(negativeSign)>-1&&curVal.indexOf(negativeSign)===curVal.length-negativeSign.length){element.style.color=negativeColor}}else if(flags.negativeStyle===2||flags.negativeStyle===3){if(curVal.indexOf(negativeSign)===0){if(curVal.indexOf(negativeTailSign)>-1&&curVal.indexOf(negativeTailSign)===curVal.length-1){element.style.color=negativeColor}}}}
if((element.tagName==='INPUT'||element.tagName==='SELECT'||element.tagName==='TEXTAREA')&&!isReplaceOrAppend&&(!imControl||imControl.indexOf('unbind')>0)){if(!element.getAttribute('data-imbluradded')){INTERMediatorLib.addEvent(element,'blur',(function(){var idValue=element.id;var elementCapt=element;return function(){if(!IMLibUI.valueChange(idValue,!0)){elementCapt.focus()}}})());element.setAttribute('data-imbluradded','set')}
if(!element.getAttribute('data-imchangeadded')){IMLibChangeEventDispatch.setExecute(element.id,(function(){var idValue=element.id;var elementCapt=element;return function(){if(!IMLibUI.valueChange(idValue,!1)){elementCapt.focus()}}})());element.setAttribute('data-imchangeadded','set')}
if((INTERMediator.isTrident||INTERMediator.isEdge)&&!element.getAttribute('data-iminputadded')){IMLibInputEventDispatch.setExecute(element.id,(function(){var idValue=element.id;var elementCapt=element;return function(){if(document.getElementById(idValue).value===''){if(!IMLibUI.valueChange(idValue,!1)){elementCapt.focus()}}}})());element.setAttribute('data-iminputadded','set')}}
element.setAttribute('data-im-element','processed');return needPostValueSet},getValueFromIMNode:function(element){'use strict';var nodeTag,typeAttr,newValue,mergedValues,targetNodes,k,valueAttr,convertedValue;if(element){nodeTag=element.tagName;typeAttr=element.getAttribute('type')}else{return''}
if(INTERMediatorLib.isWidgetElement(element)||(INTERMediatorLib.isWidgetElement(element.parentNode))){newValue=element._im_getValue()}else if(nodeTag==='INPUT'){if(typeAttr==='checkbox'){if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){mergedValues=[];targetNodes=element.parentNode.getElementsByTagName('INPUT');for(k=0;k<targetNodes.length;k++){if(targetNodes[k].checked){mergedValues.push(targetNodes[k].getAttribute('value'))}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){newValue=mergedValues.join(IMLib.cr_char)}else{newValue=mergedValues.join(IMLib.nl_char)}}else{valueAttr=element.getAttribute('value');if(element.checked){newValue=valueAttr}else{newValue=''}}}else if(typeAttr==='radio'){newValue=element.value}else{newValue=element.value}}else if(nodeTag==='SELECT'){newValue=element.value}else if(nodeTag==='TEXTAREA'){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){newValue=element.innerHTML.replace(/<br[\/]{0,1}>/g,'\n')}else{newValue=element.value}}else{newValue=element.innerHTML}
convertedValue=IMLibElement.getUnformattedValue(element,newValue);newValue=convertedValue?convertedValue:newValue;return newValue},deleteNodes:function(removeNodes){'use strict';var removeNode,removingNodes,i,j,k,removeNodeId,nodeId,calcObject,referes,values,key;for(key=0;key<removeNodes.length;key++){removeNode=document.getElementById(removeNodes[key]);if(removeNode){removingNodes=INTERMediatorLib.getElementsByIMManaged(removeNode);if(removingNodes){for(i=0;i<removingNodes.length;i++){removeNodeId=removingNodes[i].id;if(removeNodeId in IMLibCalc.calculateRequiredObject){delete IMLibCalc.calculateRequiredObject[removeNodeId]}}
for(i=0;i<removingNodes.length;i++){removeNodeId=removingNodes[i].id;for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];referes={};values={};for(j in calcObject.referes){if(calcObject.referes.hasOwnProperty(j)){referes[j]=[];values[j]=[];for(k=0;k<calcObject.referes[j].length;k++){if(removeNodeId!==calcObject.referes[j][k]){referes[j].push(calcObject.referes[j][k]);values[j].push(calcObject.values[j][k])}}}}
calcObject.referes=referes;calcObject.values=values}}}}
try{removeNode.parentNode.removeChild(removeNode)}catch(ex){}}}}};var Parser=(function(scope){var TNUMBER=0;var TOP1=1;var TOP2=2;var TOP3=5;var SEP=65;var TVAR=3;var TFUNCALL=4;Parser.regFirstVarChar=new RegExp('[\u00A0-\u1FFF\u2C00-\uDFFFa-zA-Z@_]');Parser.regRestVarChar=new RegExp('[\u00A0-\u1FFF\u2C00-\uDFFFa-zA-Z@_:0-9]');function Token(type_,index_,prio_,number_){this.type_=type_;this.index_=index_||0;this.prio_=prio_||0;this.number_=(number_!==undefined&&number_!==null)?number_:0;this.toString=function(){switch(this.type_){case TNUMBER:return this.number_;case TOP1:case TOP2:case TOP3:case TVAR:return this.index_;case TFUNCALL:return'CALL';case SEP:return'SEPARATOR';default:return'Invalid Token'}}}
function Expression(tokens,ops1,ops2,functions,ops3,ops3Trail){this.tokens=tokens}
var escapable=/[\\\'\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;var meta={'\b':IMLib.backSlash_char+'b','\t':IMLib.backSlash_char+'t','\n':IMLib.backSlash_char+'n','\f':IMLib.backSlash_char+'f','\r':IMLib.backSlash_char+'r','\'':IMLib.backSlash_char+IMLib.singleQuote_char,'\\':IMLib.backSlash_char+IMLib.backSlash_char};function escapeValue(v){if(typeof v==='string'){escapable.lastIndex=0;return escapable.test(v)?IMLib.singleQuote_char+v.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})+IMLib.singleQuote_char:IMLib.singleQuote_char+v+IMLib.singleQuote_char}
return v}
Expression.prototype={simplify:function(values){values=values||{};var nstack=[];var newexpression=[];var n1;var n2;var n3;var f;var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TNUMBER){nstack.push(item)}else if(type_===TVAR&&(item.index_ in values)){item=new Token(TNUMBER,0,0,values[item.index_]);nstack.push(item)}else if(type_===TOP3&&nstack.length>2){n3=nstack.pop();n2=nstack.pop();n1=nstack.pop();f=Parser.ops3[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_,n2.number_,n3.number_));nstack.push(item)}else if(type_===TOP2&&nstack.length>1){n2=nstack.pop();n1=nstack.pop();f=Parser.ops2[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_,n2.number_));nstack.push(item)}else if(type_===TOP1&&nstack.length>0){n1=nstack.pop();f=Parser.ops1[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_));nstack.push(item)}else{while(nstack.length>0){newexpression.push(nstack.shift())}
newexpression.push(item)}}
while(nstack.length>0){newexpression.push(nstack.shift())}
return new Expression(newexpression)},substitute:function(variable,expr){if(!(expr instanceof Expression)){expr=new Parser().parse(String(expr))}
var newexpression=[];var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TVAR&&item.index_===variable){for(var j=0;j<expr.tokens.length;j++){var expritem=expr.tokens[j];var replitem=new Token(expritem.type_,expritem.index_,expritem.prio_,expritem.number_);newexpression.push(replitem)}}else{newexpression.push(item)}}
return new Expression(newexpression)},evaluate:function(values){values=values||{};var nstack=[];var n1;var n2;var n3;var f;var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TNUMBER){nstack.push(item.number_)}else if(type_===TOP3){n3=nstack.pop();n2=nstack.pop();n1=nstack.pop();f=Parser.ops3Trail[item.index_];nstack.push(f(n1,n2,n3))}else if(type_===TOP2){n2=nstack.pop();n1=nstack.pop();f=Parser.ops2[item.index_];nstack.push(f(n1,n2))}else if(type_===TVAR){if(item.index_ in values){nstack.push(values[item.index_])}else if(item.index_ in Parser.functions){nstack.push(Parser.functions[item.index_])}else{throw new Error('undefined variable: '+item.index_)}}else if(type_===TOP1){n1=nstack.pop();f=Parser.ops1[item.index_];nstack.push(f(n1))}else if(type_===SEP){n2=nstack.pop();n1=nstack.pop();nstack.push([n1,n2])}else if(type_===TFUNCALL){n1=nstack.pop();f=nstack.pop();if(f.apply&&f.call){if(Object.prototype.toString.call(n1)=='[object Array]'){nstack.push(f.apply(undefined,n1))}else{nstack.push(f.call(undefined,n1))}}else{throw new Error(f+' is not a function')}}else{throw new Error('invalid Expression')}}
if(nstack.length>1){throw new Error('invalid Expression (parity)')}
return nstack[0]},variables:function(){var L=this.tokens.length;var vars=[];for(var i=0;i<L;i++){var item=this.tokens[i];if(item.type_===TVAR&&(vars.indexOf(item.index_)==-1)&&!(item.index_ in Parser.functions)){vars.push(item.index_)}}
return vars}};function iff(a,b,c){var vala,valb,valc;vala=(a instanceof Array)?arguments[0][0]:arguments[0];valb=(b instanceof Array)?arguments[1][0]:arguments[1];valc=(c instanceof Array)?arguments[2][0]:arguments[2];return vala?valb:valc}
function greaterthan(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)>Number(numb)}
return a>b}
function lessthan(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)<Number(numb)}
return a<b}
function greaterequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)>=Number(numb)}
return a>=b}
function lessequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)<=Number(numb)}
return a<=b}
function equal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)==Number(numb)}
return a==b}
function notequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)!=Number(numb)}
return a!=b}
function isReallyNaN(x){return x!==x}
function add(a,b){var numa,numb;if((typeof a)=="string"||(typeof b)=="string"){return addstring(a,b)}
if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numb)){return Number(numa)+Number(numb)}
return a+b}
function addstring(a,b){return String(a)+String(b)}
function sub(a,b){var numa,numb,str,pos;if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numb)){return numa-numb}
str=String(a);do{pos=str.indexOf(b);if(pos>-1){str=str.substr(0,pos)+str.substr(pos+b.length)}}while(pos>-1);return str}
function mul(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a*b}
function div(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a/b}
function mod(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a%b}
function neg(a){if(isReallyNaN(a)){return NaN}
a=toNumber(a);return-a}
function random(a){a=toNumber(a);return Math.random()*(a||1)}
function fac(a){if(isReallyNaN(a)){return NaN}
a=toNumber(a);a=Math.floor(a);var b=a;while(a>1){b=b*(--a)}
return b}
function logicalnot(a){a=toNumber(a);return!a}
function logicaland(a,b){a=toNumber(a);b=toNumber(b);return a&&b}
function logicalor(a,b){a=toNumber(a);b=toNumber(b);return a||b}
function sumfunc(){var result=0,i;for(i=0;i<arguments.length;i++){result+=toNumber(arguments[i])}
return result}
function averagefunc(){var result=0,i,count=0;for(i=0;i<arguments.length;i++){result+=toNumber(arguments[i]);count++}
return result/count}
function countElements(){var i,count=0;for(i=0;i<arguments.length;i++){count+=Array.isArray(arguments[i])?arguments[i].length:1}
return count}
function listfunc(){var result=IMLib.zerolength_str,i;for(i=0;i<arguments.length;i++){result+=String(arguments[i]);result+=IMLib.nl_char}
return result}
function roundfunc(a,b){if(b==undefined){return Math.round(a)}else{a=(a instanceof Array)?a.join():a;b=(b instanceof Array)?b.join():b;return INTERMediatorLib.Round(a,b)}}
function length(a){if(a==undefined||a==null){return 0}else{a=(a instanceof Array)?a.join():a;return(new String(a)).length}}
function toNumber(str){var value;if(str===undefined){return NaN}
if(str===!0){return!0}
if(str===!1){return!1}
if(str==IMLib.zerolength_str){return 0}
value=str;if(INTERMediatorLib.is_array(str)){if(str.length<1){return 0}else{value=str[0]}}
value=unformat(value);return value}
function pyt(a,b){return Math.sqrt(a*a+b*b)}
function append(a,b){if(Object.prototype.toString.call(a)!='[object Array]'){return[a,b]}
a=a.slice();a.push(b);return a}
function charsetand(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<stra.length;i++){if(strb.indexOf(stra.substr(i,1))>-1){result+=stra.substr(i,1)}}
return result}
function charsetor(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<strb.length;i++){if(stra.indexOf(strb.substr(i,1))<0){result+=strb.substr(i,1)}}
return stra+result}
function charsetnoother(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<stra.length;i++){if(strb.indexOf(stra.substr(i,1))<0){result+=stra.substr(i,1)}}
return result}
function parametersOfMultiline(a,b){var stra,strb,arraya,arrayb,i,nls,nl=IMLib.nl_char;stra=(a instanceof Array)?a.join():a;nls=[stra.indexOf(IMLib.crlf_str),stra.indexOf(IMLib.cr_char),stra.indexOf(IMLib.nl_char)];for(i=0;i<nls.length;i++){nls[i]=(nls[i]<0)?stra.length:nls[i]}
if(nls[0]<stra.length&&nls[0]<=nls[1]&&nls[0]<nls[2]){nl=IMLib.crlf_str}else if(nls[1]<stra.length&&nls[1]<nls[0]&&nls[1]<nls[2]){nl=IMLib.cr_char}
arraya=stra.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char).split(IMLib.nl_char);strb=(b instanceof Array)?b.join():b;arrayb=strb.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char).split(IMLib.nl_char);return[arraya,arrayb,nl]}
function itemsetand(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arrayb.indexOf(arraya[i])>-1&&arraya[i].length>0){result+=arraya[i]+nl}}
return result}
function itemsetor(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arraya[i].length>0){result+=arraya[i]+nl}}
for(i=0;i<arrayb.length;i++){if(arraya.indexOf(arrayb[i])<0&&arrayb[i].length>0){result+=arrayb[i]+nl}}
return result}
function itemsetnoother(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arrayb.indexOf(arraya[i])<0&&arraya[i].length>0){result+=arraya[i]+nl}}
return result}
function itematindex(a,start,end){var params,arraya,nl,i,result='';params=parametersOfMultiline(a,'');arraya=params[0];nl=params[2];end=(end==undefined)?arraya.length:end;for(i=start;(i<start+end)&&(i<arraya.length);i++){result+=arraya[i]+nl}
return result}
function itemIndexOfFunc(list,str){if(!list){return-1}
var a=list.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char);var ix=0;var item,pos;while(a.length>0){pos=a.indexOf(IMLib.nl_char);if(pos>-1){item=a.substr(0,pos);a=a.substr(pos+1)}else{item=a;a=IMLib.zerolength_str}
if(item==str){return ix}
ix++}
return-1}
function numberformat(val,digit){var stra,strb;stra=(val instanceof Array)?val.join():val;strb=(digit instanceof Array)?digit.join():digit;return IMLibFormat.numberFormat(stra,strb,{useSeparator:!0})}
function currencyformat(val,digit){var stra,strb;stra=(val instanceof Array)?val.join():val;strb=(digit instanceof Array)?digit.join():digit;return IMLibFormat.currencyFormat(stra,strb,{useSeparator:!0})}
function substr(str,pos,len){var stra,p,l;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;p=(pos instanceof Array)?pos.join():pos;l=(len instanceof Array)?len.join():len;return stra.substr(p,l)}
function substring(str,start,end){var stra,s,e;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(start instanceof Array)?start.join():start;e=(end instanceof Array)?end.join():end;return stra.substring(s,e)}
function leftstring(str,start){var stra,s;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);return stra.substring(0,s)}
function midstring(str,start,end){var stra,s,e;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);e=parseInt((end instanceof Array)?end.join():end);return stra.substr(s,e)}
function rightstring(str,start){var stra,s;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);return stra.substring(stra.length-s)}
function indexof(str,search,from){var stra,s;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;if(from==undefined){return stra.indexOf(s)}
return stra.indexOf(s,from)}
function lastindexof(str,search,from){var stra,s;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;if(from==undefined){return stra.lastIndexOf(s)}
return stra.lastIndexOf(s,from)}
function replace(str,start,end,rep){var stra,s,e,r;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(start instanceof Array)?start.join():start;e=(end instanceof Array)?end.join():end;r=(rep instanceof Array)?rep.join():rep;return stra.substr(0,s)+r+stra.substr(e)}
function substitute(str,search,rep){var stra,s,r,reg;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;r=(rep instanceof Array)?rep.join():rep;reg=new RegExp(s,'g');return stra.replace(reg,r)}
function match(str,pattern){var stra,p;stra=(str instanceof Array)?str.join():str;p=(pattern instanceof Array)?pattern.join():pattern;return stra.match(new RegExp(p))}
function test(str,pattern){var stra,p;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;p=(pattern instanceof Array)?pattern.join():pattern;return(new RegExp(p)).test(stra)}
Parser.timeOffset=(new Date()).getTimezoneOffset();function DateInt(str){var theDate;if(str===undefined){theDate=Date.now()}else{theDate=Date.parse(str.replace(/-/g,'/'));theDate-=Parser.timeOffset*60000}
return parseInt(theDate/86400000)}
function SecondInt(str){var theDate;if(str===undefined){theDate=Date.now()}else{theDate=Date.parse(str.replace(/-/g,'/'))}
return parseInt(theDate/1000)}
function dvalue(s){if(parseInt(s).length==s.length){return s}else{return DateInt(s)}}
function dtvalue(s){if(parseInt(s).length==s.length){return s}else{return SecondInt(s)}}
function calcDateComponent(d,a,index){var dtComp=[];dtComp.push(yeard(d));dtComp.push(monthd(d));dtComp.push(dayd(d));dtComp[index]+=a;return datecomponents(dtComp[0],dtComp[1],dtComp[2])}
function calcDateTimeComponent(dt,a,index){var dtComp=[];dtComp.push(yeardt(dt));dtComp.push(monthdt(dt));dtComp.push(daydt(dt));dtComp.push(hourdt(dt));dtComp.push(minutedt(dt));dtComp.push(seconddt(dt));dtComp[index]+=a;return datetimecomponents(dtComp[0],dtComp[1],dtComp[2],dtComp[3],dtComp[4],dtComp[5])}
function datecomponents(y,m,d){var m0=m-1;if(m0<0||m0>11){y+=parseInt(m0/12);m=m0%12+1}
return parseInt(Date.UTC(y,m-1,d,0,0,0)/86400000)}
function datetimecomponents(y,m,d,h,i,s){if(s<0||s>59){i+=parseInt(s/60);s=s%60}
if(i<0||i>59){h+=parseInt(i/60);i=i%60}
if(h<0||h>23){d+=parseInt(h/24);h=h%24}
var m0=m-1;if(m0<0||m0>11){y+=parseInt(m0/12);m=m0%12+1}
return Date.UTC(y,m-1,d,h,i,s)/1000}
function yearAlt(d){return INTERMediator.dateTimeFunction?yeardt(d):yeard(d)}
function monthAlt(d){return INTERMediator.dateTimeFunction?monthdt(d):monthd(d)}
function dayAlt(d){return INTERMediator.dateTimeFunction?daydt(d):dayd(d)}
function weekdayAlt(d){return INTERMediator.dateTimeFunction?weekdaydt(d):weekdayd(d)}
function hourAlt(d){return INTERMediator.dateTimeFunction?hourdt(d):0}
function minuteAlt(d){return INTERMediator.dateTimeFunction?minutedt(d):0}
function secondAlt(d){return INTERMediator.dateTimeFunction?seconddt(d):0}
function yeard(d){return new Date(dvalue(d)*86400000).getFullYear()}
function monthd(d){return new Date(dvalue(d)*86400000).getMonth()+1}
function dayd(d){return new Date(dvalue(d)*86400000).getDate()}
function weekdayd(d){return new Date(dvalue(d)*86400000).getDay()}
function yeardt(dt){return new Date(dtvalue(dt)*1000).getFullYear()}
function monthdt(dt){return new Date(dtvalue(dt)*1000).getMonth()+1}
function daydt(dt){return new Date(dtvalue(dt)*1000).getDate()}
function weekdaydt(dt){return new Date(dtvalue(dt)*1000).getDay()}
function hourdt(dt){return new Date(dtvalue(dt)*1000).getHours()}
function minutedt(dt){return new Date(dtvalue(dt)*1000).getMinutes()}
function seconddt(dt){return new Date(dtvalue(dt)*1000).getSeconds()}
function addyear(d,a){return INTERMediator.dateTimeFunction?addyeardt(d,a):addyeard(d,a)}
function addmonth(d,a){return INTERMediator.dateTimeFunction?addmonthdt(d,a):addmonthd(d,a)}
function addday(d,a){return INTERMediator.dateTimeFunction?adddaydt(d,a):adddayd(d,a)}
function addhour(d,a){return INTERMediator.dateTimeFunction?addhourdt(d,a):NaN}
function addminute(d,a){return INTERMediator.dateTimeFunction?addminutedt(d,a):NaN}
function addsecond(d,a){return INTERMediator.dateTimeFunction?addseconddt(d,a):NaN}
function addyeard(d,a){return calcDateComponent(d,a,0)}
function addmonthd(d,a){return calcDateComponent(d,a,1)}
function adddayd(d,a){return calcDateComponent(d,a,2)}
function addyeardt(dt,a){return calcDateTimeComponent(dt,a,0)}
function addmonthdt(dt,a){return calcDateTimeComponent(dt,a,1)}
function adddaydt(dt,a){return calcDateTimeComponent(dt,a,2)}
function addhourdt(dt,a){return calcDateTimeComponent(dt,a,3)}
function addminutedt(dt,a){return calcDateTimeComponent(dt,a,4)}
function addseconddt(dt,a){return calcDateTimeComponent(dt,a,5)}
function endofmonth(d){return INTERMediator.dateTimeFunction?endofmonthdt(d):endofmonthd(d)}
function endofmonthd(d){return adddayd(addmonthd(startofmonthd(d),1),-1)}
function endofmonthdt(dt){return addseconddt(addmonthdt(startofmonthdt(dt),1),-1)}
function startofmonth(d){return INTERMediator.dateTimeFunction?startofmonthdt(d):startofmonthd(d)}
function startofmonthd(d){var str=yeard(d)+'/'+('0'+monthd(d)).substr(-2,2)+'/01';return DateInt(str)}
function startofmonthdt(dt){var str=yeardt(dt)+'/'+('0'+monthdt(dt)).substr(-2,2)+'/01 00:00:00';return SecondInt(str)}
function today(){return parseInt(Date.now()/86400)}
function nowFunction(){return parseInt(Date.now()/1000)}
function unformat(value){var valueString,numberString,i,c;valueString=String(value);numberString=IMLib.zerolength_str;for(i=0;i<valueString.length;i++){c=valueString.substr(i,1);if(c>='0'&&c<='9'){numberString+=c}else if(c>='0'&&c<='9'){numberString+=String.fromCharCode('0'.charCodeAt(0)+c.charCodeAt(0)-'0'.charCodeAt(0))}else if(c=='.'||c=='-'){numberString+=c}}
return parseFloat(numberString)}
function choiceFunc(){var index;if(arguments[0]==null||arguments[0]==undefined){return arguments[0]}
index=parseInt(arguments[0]);if(index<0||index>=(arguments.length-1)){return undefined}
return arguments[index+1]}
function conditionFunc(){var index;for(index=0;index<arguments.length;index+=2){if(arguments[index]==!0&&index+1<arguments.length){return arguments[index+1]}}
return undefined}
function accumulateFunc(){var index,c='';for(index=0;index<arguments.length;index+=2){if(arguments[index]==!0&&index+1<arguments.length){c=c+arguments[index+1]+'\n'}}
return c}
function Parser(){this.success=!1;this.errormsg=IMLib.zerolength_str;this.expression=IMLib.zerolength_str;this.pos=0;this.tokennumber=0;this.tokenprio=0;this.tokenindex=0;this.tmpprio=0;Parser.functions={'count':countElements,'random':random,'fac':fac,'min':Math.min,'max':Math.max,'pyt':pyt,'pow':Math.pow,'atan2':Math.atan2,'if':iff,'sum':sumfunc,'average':averagefunc,'list':listfunc,'format':numberformat,'currency':currencyformat,'substr':substr,'substring':substring,'indexof':indexof,'lastindexof':lastindexof,'replace':replace,'substitute':substitute,'match':match,'test':test,'sin':Math.sin,'cos':Math.cos,'tan':Math.tan,'asin':Math.asin,'acos':Math.acos,'atan':Math.atan,'sqrt':Math.sqrt,'log':Math.log,'abs':Math.abs,'ceil':Math.ceil,'floor':Math.floor,'round':roundfunc,'exp':Math.exp,'items':itematindex,'length':length,'datetime':SecondInt,'date':DateInt,'datecomponents':datecomponents,'datetimecomponents':datetimecomponents,'year':yearAlt,'month':monthAlt,'day':dayAlt,'weekday':weekdayAlt,'hour':hourAlt,'minute':minuteAlt,'second':secondAlt,'yeard':yeard,'monthd':monthd,'dayd':dayd,'weekdayd':weekdayd,'yeardt':yeardt,'monthdt':monthdt,'daydt':daydt,'weekdaydt':weekdaydt,'hourdt':hourdt,'minutedt':minutedt,'seconddt':seconddt,'addyear':addyear,'addmonth':addmonth,'addday':addday,'addhour':addhour,'addminute':addminute,'addsecond':addsecond,'addyeard':addyeard,'addmonthd':addmonthd,'adddayd':adddayd,'addyeardt':addyeardt,'addmonthdt':addmonthdt,'adddaydt':adddaydt,'addhourdt':addhourdt,'addminutedt':addminutedt,'addseconddt':addseconddt,'endofmonth':endofmonth,'startofmonth':startofmonth,'endofmonthd':endofmonthd,'startofmonthd':startofmonthd,'endofmonthdt':endofmonthdt,'startofmonthdt':startofmonthdt,'today':today,'now':nowFunction,'right':rightstring,'mid':midstring,'left':leftstring,'itemIndexOf':itemIndexOfFunc,'choice':choiceFunc,'condition':conditionFunc,'accumulate':accumulateFunc};this.consts={'E':Math.E,'PI':Math.PI};Parser.operators={'!':[1,logicalnot,2],'+':[2,add,4],'⊕':[2,addstring,4],'-':[2,sub,4],'*':[2,mul,3],'/':[2,div,3],'%':[2,mod,3],'^':[2,Math.pow,1],',':[2,append,15],'>':[2,greaterthan,6],'<':[2,lessthan,6],'>=':[2,greaterequal,6],'<=':[2,lessequal,6],'==':[2,equal,7],'=':[2,equal,7],'!=':[2,notequal,7],'<>':[2,notequal,7],'&&':[2,logicaland,11],'||':[2,logicalor,12],'∩':[2,charsetand,3],'∪':[2,charsetor,4],'⊁':[2,charsetnoother,4],'⋀':[2,itemsetand,3],'⋁':[2,itemsetor,4],'⊬':[2,itemsetnoother,4],'?':[2,iff,13],':':[4,iff,13]};Parser.ops1={'-':neg};Parser.ops2={};Parser.ops3={};Parser.ops3Trail={};for(var op in Parser.operators){if(Parser.operators.hasOwnProperty(op)){switch(Parser.operators[op][0]){case 1:Parser.ops1[op]=Parser.operators[op][1];break;case 2:Parser.ops2[op]=Parser.operators[op][1];break;case 3:Parser.ops3[op]=Parser.operators[op][1];break;case 4:Parser.ops3Trail[op]=Parser.operators[op][1];break}}}}
Parser.parse=function(expr){return new Parser().parse(expr)};Parser.evaluate=function(expr,variables){var result;result=Parser.parse(expr).evaluate(variables);return result};Parser.Expression=Expression;var PRIMARY=1<<0;var OPERATOR=1<<1;var FUNCTION=1<<2;var LPAREN=1<<3;var RPAREN=1<<4;var COMMA=1<<5;var SIGN=1<<6;var CALL=1<<7;var NULLARY_CALL=1<<8;Parser.prototype={parse:function(expr){this.errormsg=IMLib.zerolength_str;this.success=!0;var operstack=[];var tokenstack=[];this.tmpprio=0;var expected=(PRIMARY|LPAREN|FUNCTION|SIGN);var noperators=0;this.expression=expr;this.pos=0;var funcstack=[],token;while(this.pos<this.expression.length){if(this.isOperator()){if(this.isSign()&&(expected&SIGN)){if(this.isNegativeSign()){this.tokenprio=2;this.tokenindex='-';noperators++;this.addfunc(tokenstack,operstack,TOP1)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN)}else if(this.isComment()){}else{if((expected&OPERATOR)===0){this.error_parsing(this.pos,'unexpected operator')}
if(this.tokenindex=='?'){this.tmpprio-=40;this.tokenindex='if';this.addfunc(tokenstack,operstack,TOP2);this.tmpprio+=40;this.tokenindex=',';noperators+=3;this.addfunc(tokenstack,operstack,TOP2)}else if(this.tokenindex==':'){this.tokenindex=',';noperators+=2;this.addfunc(tokenstack,operstack,TOP2)}else{noperators+=2;this.addfunc(tokenstack,operstack,TOP2)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN)}}else if(this.isNumber()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected number')}
token=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(token);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isString()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected string')}
token=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(token);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isLeftParenth()){if((expected&LPAREN)===0){this.error_parsing(this.pos,'unexpected \'(\"')}
if(expected&CALL){funcstack.push(!0)}else{funcstack.push(!1)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN|NULLARY_CALL)}else if(this.isRightParenth()){var isFunc=funcstack.pop();if(isFunc){noperators+=2;this.tokenprio=-2;this.tokenindex=-1;this.addfunc(tokenstack,operstack,TFUNCALL)}
if(expected&NULLARY_CALL){token=new Token(TNUMBER,0,0,[]);tokenstack.push(token)}else if((expected&RPAREN)===0){this.error_parsing(this.pos,'unexpected \")\"')}
expected=(OPERATOR|RPAREN|COMMA|LPAREN|CALL)}else if(this.isConst()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected constant')}
var consttoken=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(consttoken);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isVar()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected variable')}
var vartoken=new Token(TVAR,this.tokenindex,0,0);tokenstack.push(vartoken);expected=(OPERATOR|RPAREN|COMMA|LPAREN|CALL)}else if(this.isWhite()){}else{if(this.errormsg===IMLib.zerolength_str){this.error_parsing(this.pos,'unknown character')}else{this.error_parsing(this.pos,this.errormsg)}}}
if(this.tmpprio<0||this.tmpprio>=10){this.error_parsing(this.pos,'unmatched \"()\"')}
while(operstack.length>0){var tmp=operstack.pop();tokenstack.push(tmp)}
return new Expression(tokenstack)},evaluate:function(expr,variables){var result;this.parse(expr).evaluate(variables);return result},error_parsing:function(column,msg){this.success=!1;this.errormsg='parse error [column '+(column)+']: '+msg;throw new Error(this.errormsg)},addfunc:function(tokenstack,operstack,type_){var operator=new Token(type_,this.tokenindex,this.tokenprio+this.tmpprio,0);while(operstack.length>0){if(operator.prio_>=operstack[operstack.length-1].prio_){tokenstack.push(operstack.pop())}else{break}}
operstack.push(operator)},isNumber:function(){var r=!1;var str=IMLib.zerolength_str;while(this.pos<this.expression.length){var code=this.expression.charCodeAt(this.pos);if((code>=48&&code<=57)||code===46){str+=this.expression.charAt(this.pos);this.pos++;this.tokennumber=parseFloat(str);r=!0}else{break}}
return r},unescape:function(v,pos){var buffer=[];var escaping=!1;for(var i=0;i<v.length;i++){var c=v.charAt(i);if(escaping){switch(c){case IMLib.singleQuote_char:buffer.push(IMLib.singleQuote_char);break;case IMLib.backSlash_char:buffer.push(IMLib.backSlash_char);break;case '/':buffer.push('/');break;case 'b':buffer.push('\b');break;case 'f':buffer.push('\f');break;case 'n':buffer.push(IMLib.nl_char);break;case 'r':buffer.push(IMLib.cr_char);break;case 't':buffer.push(IMLib.tab_char);break;case 'u':var codePoint=parseInt(v.substring(i+1,i+5),16);buffer.push(String.fromCharCode(codePoint));i+=4;break;default:throw this.error_parsing(pos+i,'Illegal escape sequence: \'\\'+c+IMLib.singleQuote_char)}
escaping=!1}else{if(c==IMLib.backSlash_char){escaping=!0}else{buffer.push(c)}}}
return buffer.join('')},isString:function(){var r=!1;var str=IMLib.zerolength_str;var startpos=this.pos;if(this.pos<this.expression.length&&this.expression.charAt(this.pos)==IMLib.singleQuote_char){this.pos++;while(this.pos<this.expression.length){var code=this.expression.charAt(this.pos);if(code!=IMLib.singleQuote_char||str.slice(-1)==IMLib.backSlash_char){str+=this.expression.charAt(this.pos);this.pos++}else{this.pos++;this.tokennumber=this.unescape(str,startpos);r=!0;break}}}
return r},isConst:function(){var str,i;for(i in this.consts){if(this.consts.hasOwnProperty(i)){var L=i.length;str=this.expression.substr(this.pos,L);if(i===str){this.tokennumber=this.consts[i];this.pos+=L;return!0}}}
return!1},isOperator:function(){var code;if(this.pos+1<this.expression.length){code=this.expression.substr(this.pos,2);if(Parser.operators[code]){this.tokenprio=Parser.operators[code][2];this.tokenindex=code;this.pos+=2;return!0}}
code=this.expression.substr(this.pos,1);if(Parser.operators[code]){this.tokenprio=Parser.operators[code][2];this.tokenindex=code;this.pos++;return!0}
return!1},isSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===45||code===43){return!0}
return!1},isPositiveSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===43){return!0}
return!1},isNegativeSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===45){return!0}
return!1},isLeftParenth:function(){var code=this.expression.charCodeAt(this.pos);if(code===40){this.pos++;this.tmpprio-=20;return!0}
return!1},isRightParenth:function(){var code=this.expression.charCodeAt(this.pos);if(code===41){this.pos++;this.tmpprio+=20;return!0}
return!1},isComma:function(){var code=this.expression.charCodeAt(this.pos);if(code===44){this.pos++;this.tokenprio=15;this.tokenindex=',';return!0}
return!1},isWhite:function(){var code=this.expression.charCodeAt(this.pos);if(code===32||code===9||code===10||code===13){this.pos++;return!0}
return!1},isVar:function(){var str=IMLib.zerolength_str;for(var i=this.pos;i<this.expression.length;i++){var c=this.expression.charAt(i);if(i===this.pos){if(!c.match(Parser.regFirstVarChar)){break}}else{if(!c.match(Parser.regRestVarChar)){break}}
str+=c}
if(str.length>0){this.tokenindex=str;this.tokenprio=0;this.pos+=str.length;return!0}
return!1},isComment:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===47&&this.expression.charCodeAt(this.pos)===42){this.pos=this.expression.indexOf('*/',this.pos)+2;if(this.pos===1){this.pos=this.expression.length}
return!0}
return!1}};scope.Parser=Parser;return Parser})(typeof exports==='undefined'?{}:exports);var IMLibCalc={calculateRequiredObject:null,updateCalculationInfo:function(contextObj,keyingValue,nodeId,nInfo,currentRecord){'use strict';var calcDef,exp,field,elements,i,index,objectKey,itemIndex,values,referes,calcDefField,atPos,fieldLength;calcDef=contextObj.getContextDef().calculation;for(index in calcDef){if(calcDef.hasOwnProperty(index)){atPos=calcDef[index].field.indexOf(INTERMediator.separator);fieldLength=calcDef[index].field.length;calcDefField=calcDef[index].field.substring(0,atPos>=0?atPos:fieldLength);if(calcDefField===nInfo.field){try{exp=calcDef[index].expression;field=calcDef[index].field;elements=Parser.parse(exp).variables();objectKey=nodeId+(nInfo.target.length>0?(INTERMediator.separator+nInfo.target):'')}catch(ex){INTERMediatorLog.setErrorMessage(ex,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1036],[field,exp]))}
if(elements&&objectKey){values={};referes={};for(i=0;i<elements.length;i++){itemIndex=elements[i];if(itemIndex){values[itemIndex]=currentRecord[itemIndex];referes[itemIndex]=undefined}
contextObj.setValue(keyingValue,itemIndex,currentRecord[itemIndex],nodeId,nInfo.target,null)}
IMLibCalc.calculateRequiredObject[objectKey]={'field':field,'expression':exp,'nodeInfo':nInfo,'values':values,'referes':referes}}}}}},updateCalculationFields:function(){'use strict';var nodeId,exp,nInfo,valuesArray,leafNodes,calcObject,ix,refersArray,key,fName,vArray;var targetNode,field,valueSeries,targetElement,i,hasReferes,contextInfo,idValue,record,val;IMLibCalc.setUndefinedToAllValues();IMLibNodeGraph.clear();for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];if(calcObject){hasReferes=!1;for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){IMLibNodeGraph.addEdge(nodeId,calcObject.referes[field][ix]);hasReferes=!1}}}
if(!hasReferes){IMLibNodeGraph.addEdge(nodeId)}}}}
do{leafNodes=IMLibNodeGraph.getLeafNodesWithRemoving();for(i=0;i<leafNodes.length;i++){calcObject=IMLibCalc.calculateRequiredObject[leafNodes[i]];if(calcObject){idValue=leafNodes[i].match(IMLibCalc.regexpForSeparator)?leafNodes[i].split(IMLibCalc.regexpForSeparator)[0]:leafNodes[i];targetNode=document.getElementById(idValue);exp=calcObject.expression;nInfo=calcObject.nodeInfo;valuesArray=calcObject.values;refersArray=calcObject.referes;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nInfo.target);if(contextInfo&&contextInfo.context){record=contextInfo.context.getContextRecord(idValue)}else{record=null}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){if(field.indexOf(nInfo.table+'@')===0){fName=field.substr(field.indexOf('@')+1);vArray=[];for(key in contextInfo.context.store){if(contextInfo.context.store.hasOwnProperty(key)&&contextInfo.context.store[key][fName]){vArray.push(contextInfo.context.store[key][fName])}}
valuesArray[field]=vArray}}}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){valueSeries=[];for(ix=0;ix<valuesArray[field].length;ix++){if(valuesArray[field][ix]===undefined){if(record[field]){valueSeries.push(record[field])}else if(refersArray[field][ix]){targetElement=document.getElementById(refersArray[field][ix]);valueSeries.push(IMLibElement.getValueFromIMNode(targetElement))}}else{valueSeries.push(valuesArray[field][ix])}}
calcObject.values[field]=valueSeries}}
val=Parser.evaluate(exp,valuesArray);IMLibElement.setValueToIMNode(targetNode,nInfo.target,val,!0);contextInfo.context.setValue(contextInfo.record,contextInfo.field,val,nodeId,targetNode,!1)}}}while(leafNodes.length>0);if(IMLibNodeGraph.nodes.length>0){INTERMediatorLog.setErrorMessage(new Error('Expressons are cyclic.'),INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1037],[]))}},recalculation:function(updatedNodeId){'use strict';var nodeId,newValueAdded,leafNodes,calcObject,ix,updatedValue,isRecalcAll=!1,targetNode;var newValue,field,i,updatedNodeIds,updateNodeValues,cachedIndex,nInfo,valuesArray;var refersArray,valueSeries,targetElement,contextInfo,record,idValue,key,fName,vArray;if(updatedNodeId===undefined){isRecalcAll=!0;updatedNodeIds=[];updateNodeValues=[]}else{newValue=IMLibElement.getValueFromIMNode(document.getElementById(updatedNodeId));updatedNodeIds=[updatedNodeId];updateNodeValues=[newValue]}
IMLibCalc.setUndefinedToAllValues();IMLibNodeGraph.clear();for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){IMLibNodeGraph.addEdge(nodeId,calcObject.referes[field][ix])}}}}}
do{leafNodes=IMLibNodeGraph.getLeafNodesWithRemoving();for(i=0;i<leafNodes.length;i++){calcObject=IMLibCalc.calculateRequiredObject[leafNodes[i]];if(calcObject){idValue=leafNodes[i].match(IMLibCalc.regexpForSeparator)?leafNodes[i].split(IMLibCalc.regexpForSeparator)[0]:leafNodes[i];targetNode=document.getElementById(idValue);nInfo=calcObject.nodeInfo;valuesArray=calcObject.values;refersArray=calcObject.referes;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nInfo.target);if(contextInfo&&contextInfo.context){record=contextInfo.context.getContextRecord(idValue)}else{record=null}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){if(field.indexOf(nInfo.table+'@')===0){fName=field.substr(field.indexOf('@')+1);vArray=[];for(key in contextInfo.context.store){if(contextInfo.context.store.hasOwnProperty(key)&&contextInfo.context.store[key][fName]){vArray.push(contextInfo.context.store[key][fName])}}
valuesArray[field]=vArray}}}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){valueSeries=[];for(ix=0;ix<valuesArray[field].length;ix++){if(valuesArray[field][ix]===undefined){if(record[field]){valueSeries.push(record[field])}else if(refersArray[field][ix]){targetElement=document.getElementById(refersArray[field][ix]);valueSeries.push(IMLibElement.getValueFromIMNode(targetElement))}}else{valueSeries.push(valuesArray[field][ix])}}
calcObject.values[field]=valueSeries}}
if(isRecalcAll){newValueAdded=!0}else{newValueAdded=!1;for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){cachedIndex=updatedNodeIds.indexOf(calcObject.referes[field][ix]);if(cachedIndex>=0){calcObject.values[field][ix]=updateNodeValues[cachedIndex];newValueAdded=!0}}}}}
if(newValueAdded){updatedValue=Parser.evaluate(calcObject.expression,calcObject.values);IMLibElement.setValueToIMNode(document.getElementById(idValue),nInfo.target,updatedValue,!0);updatedNodeIds.push(idValue);updateNodeValues.push(updatedValue);contextInfo.context.setValue(contextInfo.record,contextInfo.field,updatedValue,idValue,targetNode,!1)}}}}while(leafNodes.length>0);if(IMLibNodeGraph.nodes.length>0){INTERMediatorLog.setErrorMessage(new Error('Expressons are cyclic.'),INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1037],[]))}},setUndefinedToAllValues:function(){'use strict';var nodeId,calcObject,ix,targetNode,field,targetExp,targetIds,isContextName,isRemoved,idValue,repeaterTop,checkRepeater,nodeInfo,linkInfos;do{isRemoved=!1;for(nodeId in IMLibCalc.calculateRequiredObject){idValue=nodeId.match(IMLibCalc.regexpForSeparator)?nodeId.split(IMLibCalc.regexpForSeparator)[0]:nodeId;if(!document.getElementById(idValue)){delete IMLibCalc.calculateRequiredObject[nodeId];isRemoved=!0;break}}}while(isRemoved);for(nodeId in IMLibCalc.calculateRequiredObject){calcObject=IMLibCalc.calculateRequiredObject[nodeId];idValue=nodeId.match(IMLibCalc.regexpForSeparator)?nodeId.split(IMLibCalc.regexpForSeparator)[0]:nodeId;targetNode=document.getElementById(idValue);linkInfos=INTERMediatorLib.getLinkedElementInfo(targetNode);if(INTERMediatorLib.is_array(linkInfos)){linkInfos=linkInfos[0]}
nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos);for(field in calcObject.values){if(field.indexOf(INTERMediator.separator)>-1){targetExp=field;isContextName=!0}else{targetExp=calcObject.nodeInfo.table+INTERMediator.separator+field;isContextName=!1}
if(nodeInfo&&nodeInfo.crossTable){repeaterTop=targetNode;while(repeaterTop.tagName!=='TD'&&repeaterTop.tagName!=='TH'){repeaterTop=repeaterTop.parentNode}
do{targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromNode(repeaterTop,targetExp);if(targetIds&&targetIds.length>0){break}
repeaterTop=getParentRepeater(INTERMediatorLib.getParentEnclosure(repeaterTop))}while(repeaterTop);}else{checkRepeater=targetNode;do{targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromRepeater(checkRepeater,targetExp);if(targetIds&&targetIds.length>0){break}
if(isContextName){targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromEnclosure(checkRepeater,targetExp);if(targetIds&&targetIds.length>0){break}}
checkRepeater=getParentRepeater(INTERMediatorLib.getParentEnclosure(checkRepeater))}while(checkRepeater);}
if(INTERMediatorLib.is_array(targetIds)&&targetIds.length>0){calcObject.referes[field]=[];calcObject.values[field]=[];for(ix=0;ix<targetIds.length;ix++){calcObject.referes[field].push(targetIds[ix]);calcObject.values[field].push(undefined)}}else{calcObject.referes[field]=[undefined];calcObject.values[field]=[undefined]}}}
function getParentRepeater(node){var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null}}};var IMParts_Catalog={};IMParts_Catalog.fileupload={html5DDSuported:!1,progressSupported:!1,forceOldStyleForm:!1,uploadButtonLabel:'送信',uploadCancelButtonLabel:'キャンセル',uploadId:'sign'+Math.random(),instanciate:function(parentNode){'use strict';var inputNode,formNode,buttonNode,hasTapEvent;var newId=parentNode.getAttribute('id')+'-e';var newNode=document.createElement('DIV');IMLibLocalContext.setValue('uploadFileSelect','false');INTERMediatorLib.setClassAttributeToNode(newNode,'_im_fileupload');newNode.setAttribute('id',newId);this.ids.push(newId);if(this.forceOldStyleForm||(INTERMediator.isEdge&&INTERMediator.ieVersion<14)){this.html5DDSuported=!1}else{if(window.FileReader&&window.FormData){this.html5DDSuported=!0}else{this.html5DDSuported=!1}}
hasTapEvent=('ontouchstart' in window);if(hasTapEvent){this.html5DDSuported=!1}
var autoReload=(parentNode.getAttribute('data-im-widget-reload')!==null)?parentNode.getAttribute('data-im-widget-reload'):!1;newNode.setAttribute('data-im-widget-reload',autoReload);if(this.html5DDSuported){newNode.dropzone='copy';var widgetStyle=(parentNode.getAttribute('data-im-widget-style')==='false')?!1:!0;if(widgetStyle){newNode.style.width='200px';newNode.style.height='100px';newNode.style.paddingTop='20px';newNode.style.backgroundColor='#AAAAAA';newNode.style.border='3px dotted #808080';newNode.style.textAlign='center';newNode.style.fontSize='75%';var eachLine=INTERMediatorOnPage.getMessages()[3101].split(/\n/);for(var i=0;i<eachLine.length;i++){if(i>0){newNode.appendChild(document.createElement('BR'))}
newNode.appendChild(document.createTextNode(eachLine[i]))}}}else{formNode=document.createElement('FORM');formNode.className='_im_fileupload_form';formNode.setAttribute('method','post');formNode.setAttribute('action',INTERMediatorOnPage.getEntryPath()+'?access=uploadfile');formNode.setAttribute('enctype','multipart/form-data');var divNode=document.createElement('DIV');divNode.className='_im_fileupload_form_wrapper form-wrapper';divNode.appendChild(formNode);newNode.appendChild(divNode);if(this.progressSupported){inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','APC_UPLOAD_PROGRESS');inputNode.setAttribute('id','progress_key');inputNode.setAttribute('value',this.uploadId+(this.ids.length-1));formNode.appendChild(inputNode)}
inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_redirect');inputNode.setAttribute('value',location.href);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_contextnewrecord');inputNode.setAttribute('value','uploadfile');formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','access');inputNode.setAttribute('value','uploadfile');formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','file');inputNode.setAttribute('accept','*/*');inputNode.setAttribute('name','_im_uploadfile');inputNode.className='_im_uploadfile';inputNode.addEventListener('change',function(){if(this.files[0].size>0){this.nextSibling.removeAttribute('disabled')}},!1);formNode.appendChild(inputNode);var cancelButtonWrapper,cancelButton;cancelButtonWrapper=document.createElement('DIV');cancelButtonWrapper.className='_im_fileupload_cancel_button_wrapper';cancelButton=document.createElement('BUTTON');cancelButton.className='_im_fileupload_cancel_button';cancelButton.appendChild(document.createTextNode(this.uploadCancelButtonLabel));cancelButtonWrapper.appendChild(cancelButton);buttonNode=document.createElement('BUTTON');buttonNode.className='_im_fileupload_button';buttonNode.setAttribute('type','submit');buttonNode.setAttribute('disabled','');buttonNode.appendChild(document.createTextNode(this.uploadButtonLabel));if(!newNode.id){newNode.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(newNode.id,function(){var node=document.getElementById(newNode.id);if(node!==null&&node.children.length>0){if(node.children[0].style.display==='none'||node.children[0].style.display===''){node.children[0].style.display='flex';node.children[0].style.display='-webkit-flex'}}},!0);if(!cancelButtonWrapper.id){cancelButtonWrapper.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(cancelButtonWrapper.id,function(){this.parentNode.style.display='none'});divNode.appendChild(cancelButtonWrapper);formNode.appendChild(buttonNode);this.formFromId[newId]=formNode}
if(parentNode.getAttribute('data-im-widget-inner')==='true'){var children=parentNode.children;for(var c=children.length-1;c>=0;c--){newNode.appendChild(children[c])}}
parentNode.appendChild(newNode);newNode._im_getValue=function(){var targetNode=newNode;return targetNode.value};parentNode._im_getValue=function(){var targetNode=newNode;return targetNode.value};parentNode._im_getComponentId=function(){var theId=newId;return theId}},ids:[],formFromId:{},finish:function(){'use strict';var shaObj,hmacValue,targetNode,formNode,i,tagetIdLocal,isProgressingLocal,serialIdLocal,uploadIdLocal;var encrypt=new JSEncrypt();if(this.html5DDSuported){for(i=0;i<this.ids.length;i++){tagetIdLocal=this.ids[i];targetNode=document.getElementById(tagetIdLocal);if(targetNode){INTERMediatorLib.addEvent(targetNode,'dragleave',function(event){event.preventDefault();event.target.style.backgroundColor='#AAAAAA'});INTERMediatorLib.addEvent(targetNode,'dragover',function(event){event.preventDefault();event.target.style.backgroundColor='#AADDFF'});isProgressingLocal=this.progressSupported;serialIdLocal=this.ids.length;uploadIdLocal=this.uploadId;INTERMediatorLib.addEvent(targetNode,'drop',(function(){var iframeId=i;var isProgressing=isProgressingLocal;var serialId=serialIdLocal;var uploadId=uploadIdLocal;var tagetId=tagetIdLocal;return function(event){var file,fileNameNode,i,updateInfo,infoFrame;event.preventDefault();var eventTarget=event.currentTarget;if(isProgressing){infoFrame=document.createElement('iframe');infoFrame.setAttribute('id','upload_frame'+serialId);infoFrame.setAttribute('name','upload_frame');infoFrame.setAttribute('frameborder','0');infoFrame.setAttribute('border','0');infoFrame.setAttribute('scrolling','no');infoFrame.setAttribute('scrollbar','no');infoFrame.style.width='100%';infoFrame.style.height='24px';eventTarget.appendChild(infoFrame)}
for(i=0;i<event.dataTransfer.files.length;i++){file=event.dataTransfer.files[i];fileNameNode=document.createElement('DIV');fileNameNode.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[3102]+file.name));fileNameNode.style.marginTop='20px';fileNameNode.style.backgroundColor='#FFFFFF';fileNameNode.style.textAlign='center';event.target.appendChild(fileNameNode)}
updateInfo=IMLibContextPool.getContextInfoFromId(eventTarget.getAttribute('id'),'');if(isProgressing){if(infoFrame){infoFrame.style.display='block'}
setTimeout((function(){var frameNode=infoFrame;var param=uploadId+iframeId;return function(){if(frameNode){frameNode.setAttribute('src','upload_frame.php?up_id='+param)}}})())}
IMLibQueue.setTask((function(){var uploadData='&_im_contextname='+encodeURIComponent(updateInfo.context.contextName)+'&_im_field='+encodeURIComponent(updateInfo.field)+'&_im_keyfield='+encodeURIComponent(updateInfo.record.split('=')[0])+'&_im_keyvalue='+encodeURIComponent(updateInfo.record.split('=')[1])+'&_im_contextnewrecord='+encodeURIComponent('uploadfile')+(isProgressing?('&APC_UPLOAD_PROGRESS='+encodeURIComponent(uploadId+iframeId)):'');var uploadSpec={fileName:file.name,content:file};var contextName=updateInfo.context.contextName;var updateField=updateInfo.field;var targetIdCapt=tagetId;var targetNodeCapt=targetNode;var finishFunc=(function(){var infoFrameCapt=infoFrame;var fileNameNodeCapt=fileNameNode;return function(){if(infoFrameCapt){infoFrameCapt.setAttribute('src','')}
if(fileNameNodeCapt){fileNameNodeCapt.parentNode.removeChild(fileNameNodeCapt)}}})();return function(completeTask){INTERMediator_DBAdapter.uploadFile(uploadData,uploadSpec,function(dbresult){var contextObj,contextInfo,contextObjects=null,fvalue,i,context,relatedContextName='',index;context=IMLibContextPool.getContextDef(contextName);if(context['file-upload']){for(index in context['file-upload']){if(context['file-upload'][index].field===updateField){relatedContextName=context['file-upload'][index].context;break}}
fvalue=IMLibContextPool.getKeyFieldValueFromId(targetIdCapt,'');contextObjects=IMLibContextPool.getContextsFromNameAndForeignValue(relatedContextName,fvalue,context.key)}else{contextObjects=IMLibContextPool.getContextFromName(contextName)}
contextInfo=IMLibContextPool.getContextInfoFromId(targetIdCapt,'');contextInfo.context.setValue(contextInfo.record,contextInfo.field,dbresult);if(contextObjects){for(i=0;i<contextObjects.length;i++){contextObj=contextObjects[i];INTERMediator.construct(contextObj)}}
INTERMediatorLog.flushMessage();if(targetNodeCapt.getAttribute('data-im-widget-reload')==='true'){INTERMediator.construct()}
event.target.style.backgroundColor='#AAAAAA';finishFunc();completeTask()},function(){event.target.style.backgroundColor='#AAAAAA';finishFunc();completeTask()})}})())}})())}}}else{for(i=0;i<this.ids.length;i++){targetNode=document.getElementById(this.ids[i]);formNode=targetNode.getElementsByTagName('FORM')[0];if(targetNode&&formNode){var updateInfo=IMLibContextPool.getContextInfoFromId(this.ids[i],'');var inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_contextname');inputNode.setAttribute('value',updateInfo.context.contextName);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_field');inputNode.setAttribute('value',updateInfo.field);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_keyfield');inputNode.setAttribute('value',updateInfo.record.split('=')[0]);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_keyvalue');inputNode.setAttribute('value',updateInfo.record.split('=')[1]);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','clientid');if(INTERMediatorOnPage.authUser.length>0){inputNode.value=INTERMediatorOnPage.clientId}
formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','authuser');if(INTERMediatorOnPage.authUser.length>0){inputNode.value=INTERMediatorOnPage.authUser}
formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','response');if(INTERMediatorOnPage.authUser.length>0){if(INTERMediatorOnPage.authHashedPassword&&INTERMediatorOnPage.authChallenge){shaObj=new jsSHA(INTERMediatorOnPage.authHashedPassword,'ASCII');hmacValue=shaObj.getHMAC(INTERMediatorOnPage.authChallenge,'ASCII','SHA-256','HEX');inputNode.value=hmacValue}else{inputNode.value='dummy'}}
formNode.appendChild(inputNode);if(INTERMediatorOnPage.authUser.length>0){encrypt.setPublicKey(INTERMediatorOnPage.publickey);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','cresponse');inputNode.setAttribute('value',encrypt.encrypt(INTERMediatorOnPage.authCryptedPassword.substr(0,220)+IMLib.nl_char+INTERMediatorOnPage.authChallenge)+IMLib.nl_char+INTERMediatorOnPage.authCryptedPassword.substr(220));formNode.appendChild(inputNode)}
if(this.progressSupported){inputNode=document.createElement('iframe');inputNode.setAttribute('id','upload_frame'+i);inputNode.setAttribute('name','upload_frame');inputNode.setAttribute('frameborder','0');inputNode.setAttribute('border','0');inputNode.setAttribute('scrolling','no');inputNode.setAttribute('scrollbar','no');formNode.appendChild(inputNode);INTERMediatorLib.addEvent(formNode,'submit',(function(){var iframeId=i;return function(){var iframeNode=document.getElementById('upload_frame'+iframeId);iframeNode.style.display='block';setTimeout(function(){var infoURL=selfURL()+'?uploadprocess='+this.uploadId+iframeId;iframeNode.setAttribute('src',infoURL)});return!0}})())}}}}
this.ids=[];this.formFromId={};function selfURL(){var nodes=document.getElementsByTagName('SCRIPT');for(var i=0;i<nodes.length;i++){var srcAttr=nodes[i].getAttribute('src');if(srcAttr.match(/\.php/)){return srcAttr}}
return null}}};IMParts_Catalog.jsonformat={instanciate:function(parentNode){'use strict';var newId=parentNode.getAttribute('id')+'-jsonf';var newNode=document.createElement('pre');newNode.setAttribute('id',newId);parentNode.appendChild(newNode);IMParts_Catalog.jsonformat.ids.push(newId);parentNode._im_getComponentId=(function(){var theId=newId;return function(){return theId}})();parentNode._im_setValue=(function(){var theId=newId;return function(str){IMParts_Catalog.jsonformat.initialValues[theId]=str?JSON.stringify(JSON.parse(str),null,' '):''}})()},ids:[],initialValues:{},finish:function(){'use strict';for(var i=0;i<IMParts_Catalog.jsonformat.ids.length;i++){var targetId=IMParts_Catalog.jsonformat.ids[i];var targetNode=document.getElementById(targetId);if(targetNode){targetNode.appendChild(document.createTextNode(IMParts_Catalog.jsonformat.initialValues[targetId]))}}
IMParts_Catalog.jsonformat.ids=[];IMParts_Catalog.jsonformat.initialValues={}}};IMParts_Catalog.popupselector={instanciate:function(parentNode){'use strict';var widgetId,node,inNode,valueNode;if(parentNode.getAttribute('class')!=='_im_widget_popup'){parentNode.setAttribute('class','_im_widget_popup');parentNode.style.zIndex=(IMParts_Catalog.popupselector.zIndex--);node=document.createElement('SPAN');node.setAttribute('data-im-control','enclosure');node.setAttribute('class','_im_widget_popup_panel');parentNode.appendChild(node);IMParts_Catalog.popupselector.selectionRoots.push(node);inNode=document.createElement('SPAN');inNode.setAttribute('data-im-control','repeater');inNode.setAttribute('data-im',parentNode.getAttribute('data-im-popup'));node.appendChild(inNode);inNode=document.createElement('DIV');inNode.setAttribute('class','_im_widget_popup_close');inNode.appendChild(document.createTextNode('×'));node.appendChild(inNode);INTERMediatorLib.addEvent(inNode,'click',(function(){return function(){IMParts_Catalog.popupselector.clearSelection()}})());widgetId=parentNode.getAttribute('id');IMParts_Catalog.popupselector.ids.push(widgetId);valueNode=document.createElement('span');valueNode.setAttribute('class','_im_widget_popup_value');INTERMediatorLib.addEvent(valueNode,'click',(function(){var selRoot=node;return function(){IMParts_Catalog.popupselector.clearSelection();IMParts_Catalog.popupselector.clickValue(selRoot)}})());parentNode.appendChild(valueNode);parentNode._im_getComponentId=(function(){var theId=widgetId;return function(){return theId}})();parentNode._im_setValue=(function(){var theId=widgetId;return function(str){IMParts_Catalog.popupselector.initialValues[theId]=str}})()}},ids:[],selectionRoots:[],initialValues:{},zIndex:9000,finish:function(){'use strict';var i,targetId,targetNode,j,nodes,selectionRoot,nodeValue,displayValue,innodes,k;for(i=0;i<IMParts_Catalog.popupselector.ids.length;i++){targetId=IMParts_Catalog.popupselector.ids[i];targetNode=document.getElementById(targetId);selectionRoot=IMParts_Catalog.popupselector.selectionRoots[i];nodeValue=IMParts_Catalog.popupselector.initialValues[targetId];if(selectionRoot){displayValue=null;nodes=selectionRoot.childNodes;for(j=0;j<nodes.length;j++){if(nodes[j]&&nodes[j].nodeType===1&&nodes[j].getAttribute('data-im-control')==='repeater'){nodes[j].setAttribute('class','_im_widget_popup_selection');if(nodeValue===nodes[j].getAttribute('data-im-value')){displayValue=nodes[j].innerHTML;nodes[j].setAttribute('class','_im_widget_popup_selection _im_widget_popup_selected')}
IMLibMouseEventDispatch.setExecute(nodes[j].id,(function(){var node=nodes[j];return function(){IMParts_Catalog.popupselector.clearSelection();IMParts_Catalog.popupselector.setData(node)}})())}}
if(targetNode){innodes=targetNode.getElementsByClassName('_im_widget_popup_value');for(k=0;k<innodes.length;k++){innodes[k].innerHTML=displayValue?displayValue:'[Not selected]'}}}}},clickValue:function(selectionRoot){'use strict';var body,panelBack;selectionRoot.style.display='block';body=document.getElementsByTagName('BODY')[0];panelBack=document.createElement('DIV');body.appendChild(panelBack);panelBack.setAttribute('class','_im_widget_popup_panelback');panelBack.setAttribute('id','_im_widget_popup_panelback');panelBack.style.width=body.clientWidth+'px';panelBack.style.height=body.clientHeight+'px';IMLibMouseEventDispatch.setExecute('_im_widget_popup_panelback',function(){IMParts_Catalog.popupselector.clearSelection()})},clearSelection:function(){'use strict';var i,body,targetNode,selectionRoot;body=document.getElementsByTagName('BODY')[0];targetNode=document.getElementById('_im_widget_popup_panelback');if(targetNode){body.removeChild(targetNode)}
for(i=0;i<IMParts_Catalog.popupselector.ids.length;i++){selectionRoot=IMParts_Catalog.popupselector.selectionRoots[i];if(selectionRoot){selectionRoot.style.display='none'}}},setData:function(node){'use strict';var i,selectedData,target,targetField,bindingId,keyRec,nodes,contextInfo;selectedData=node.getAttribute('data-im-value');target=node.parentNode.parentNode.getAttribute('data-im').split(' ')[0].split('@');targetField=target[1];bindingId=node.parentNode.parentNode.id;contextInfo=IMLibContextPool.getContextInfoFromId(bindingId,target[2]);keyRec=contextInfo.record.split('=');contextInfo.context.setDataWithKey(keyRec[1],targetField,selectedData);nodes=node.parentNode.parentNode.getElementsByClassName('_im_widget_popup_value');for(i=0;i<nodes.length;i++){nodes[i].innerHTML=node.innerHTML}
nodes=node.parentNode.getElementsByClassName('_im_widget_popup_selection');for(i=0;i<nodes.length;i++){if(node.getAttribute('data-im-value')===nodes[i].getAttribute('data-im-value')){nodes[i].setAttribute('class','_im_widget_popup_selection _im_widget_popup_selected')}else{nodes[i].setAttribute('class','_im_widget_popup_selection')}}}};var IMLibPageNavigation={deleteInsertOnNavi:[],previousModeDetail:null,stepNavigation:[],stepCurrentContextName:null,stepStartContextName:null,navigationSetup:function(){'use strict';var navigation,i,insideNav,navLabel,node,start,pageSize,allCount,dataSources,disableClass,c_node,prevPageCount,nextPageCount,endPageCount,contextName,contextDef,buttonLabel,dataSource;navigation=document.getElementById('IM_NAVIGATOR');if(navigation!==null){if(!IMLibContextPool.getPagingContext()){navigation.style.display='none';return}
insideNav=navigation.childNodes;for(i=0;i<insideNav.length;i++){navigation.removeChild(insideNav[i])}
navigation.innerHTML='';navigation.setAttribute('class','IM_NAV_panel');navLabel=INTERMediator.navigationLabel;if(navLabel===null||navLabel[8]!==!1){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(((navLabel===null||navLabel[8]===null)?INTERMediatorOnPage.getMessages()[2]:navLabel[8])));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){INTERMediator.initialize();IMLibLocalContext.archive();location.reload()})}
if(navLabel===null||navLabel[4]!==!1){start=Number(INTERMediator.startFrom);dataSource=IMLibContextPool.getPagingContext().getContextDef();if(dataSource&&dataSource.maxrecords&&dataSource.maxrecords<parseInt(INTERMediator.pagedSize,10)){INTERMediator.pagedSize=dataSource.maxrecords}
pageSize=Number(INTERMediator.pagedSize);allCount=Number(INTERMediator.pagedAllCount);disableClass=' IM_NAV_disabled';node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(((navLabel===null||navLabel[4]===null)?INTERMediatorOnPage.getMessages()[1]:navLabel[4])+(allCount===0?0:start+1)+((Math.min(start+pageSize,allCount)-start>1)?(((navLabel===null||navLabel[5]===null)?'-':navLabel[5])+Math.min(start+pageSize,allCount)):'')+((navLabel===null||navLabel[6]===null)?' / ':navLabel[6])+(allCount)+((navLabel===null||navLabel[7]===null)?'':navLabel[7])));node.setAttribute('class','IM_NAV_info')}
if((navLabel===null||navLabel[0]!==!1)&&INTERMediator.pagination===!0){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[0]===null)?'<<':navLabel[0]));node.setAttribute('class','IM_NAV_button'+(start===0?disableClass:''));if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',0)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[1]===null)?'<':navLabel[1]));node.setAttribute('class','IM_NAV_button'+(start===0?disableClass:''));prevPageCount=(start-pageSize>0)?start-pageSize:0;if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',prevPageCount)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[2]===null)?'>':navLabel[2]));node.setAttribute('class','IM_NAV_button'+(start+pageSize>=allCount?disableClass:''));nextPageCount=(start+pageSize<allCount)?start+pageSize:((allCount-pageSize>0)?start:0);if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',nextPageCount)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[3]===null)?'>>':navLabel[3]));node.setAttribute('class','IM_NAV_button'+(start+pageSize>=allCount?disableClass:''));if(allCount%pageSize===0){endPageCount=allCount-(allCount%pageSize)-pageSize}else{endPageCount=allCount-(allCount%pageSize)}
if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',(endPageCount>0)?endPageCount:0)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[10]));c_node=document.createElement('INPUT');c_node.setAttribute('class','IM_NAV_JUMP');c_node.setAttribute('type','text');if(!c_node.id){c_node.id=INTERMediator.nextIdValue()}
c_node.setAttribute('value',String(Math.ceil(INTERMediator.startFrom/pageSize+1)));node.appendChild(c_node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[11]));IMLibChangeEventDispatch.setExecute(c_node.id,function(){var moveTo,max_page;moveTo=INTERMediatorLib.toNumber(c_node.value);if(moveTo<1){moveTo=1}
max_page=Math.ceil(allCount/pageSize);if(max_page<moveTo){moveTo=max_page}
INTERMediator.startFrom=(moveTo-1)*pageSize;INTERMediator.constructMain(!0)})}
if(navLabel===null||navLabel[9]!==!1){for(i=0;i<IMLibPageNavigation.deleteInsertOnNavi.length;i++){switch(IMLibPageNavigation.deleteInsertOnNavi[i].kind){case 'INSERT':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].insert){buttonLabel=contextDef['button-names'].insert}else{buttonLabel=INTERMediatorOnPage.getMessages()[3]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextName=obj.name,keyValue=obj.key,confirming=obj.confirm;return function(){IMLibPageNavigation.insertRecordFromNavi(contextName,keyValue,confirming)}})());break;case 'DELETE':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].delete){buttonLabel=contextDef['button-names'].delete}else{buttonLabel=INTERMediatorOnPage.getMessages()[4]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');INTERMediatorLib.addEvent(node,'click',(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextName=obj.name,keyName=obj.key,keyValue=obj.value,confirming=obj.confirm;return function(){IMLibPageNavigation.deleteRecordFromNavi(contextName,keyName,keyValue,confirming)}})());break;case 'COPY':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].copy){buttonLabel=contextDef['button-names'].copy}else{buttonLabel=INTERMediatorOnPage.getMessages()[15]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextDef=obj.contextDef,record=obj.keyValue;return function(){IMLibPageNavigation.copyRecordFromNavi(contextDef,record)}})());break}}}
if(navLabel===null||navLabel[10]!==!1){if(INTERMediatorOnPage.getOptionsTransaction()==='none'){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[10]===null)?INTERMediatorOnPage.getMessages()[7]:navLabel[10]));node.setAttribute('class','IM_NAV_button');INTERMediatorLib.addEvent(node,'click',IMLibPageNavigation.saveRecordFromNavi)}}
if(navLabel===null||navLabel[11]!==!1){if(INTERMediatorOnPage.requireAuthentication){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[8]+INTERMediatorOnPage.authUser));node.setAttribute('class','IM_NAV_info');node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[11]===null)?INTERMediatorOnPage.getMessages()[9]:navLabel[11]));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){INTERMediatorOnPage.logout();location.reload()})}}}},moveRecordFromNavi:function(targetName,page){'use strict';INTERMediator_DBAdapter.unregister();INTERMediator.startFrom=page;INTERMediator.constructMain(!0)},insertRecordFromNavi:function(targetName,keyField,isConfirm){'use strict';var contextDef;if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1026])){return}}
INTERMediatorOnPage.showProgress();contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',targetName);if(contextDef===null){window.alert('no targetname :'+targetName);INTERMediatorOnPage.hideProgress();return}
IMLibQueue.setTask((function(){var conditions,restore;var contextDefCapt=contextDef;var targetNameCapt=targetName;var keyFieldCapt=keyField;var isConfirmCapt=isConfirm;return function(completeTask){try{INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_createRecord_async({name:targetNameCapt,dataset:[]},function(response){var newId=response.newRecordKeyValue;if(newId>-1){restore=INTERMediator.additionalCondition;if(contextDefCapt.records<=1){INTERMediator.startFrom=0;INTERMediator.pagedAllCount=1;conditions=INTERMediator.additionalCondition;conditions[targetNameCapt]={field:keyFieldCapt,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}else{INTERMediator.pagedAllCount++}
completeTask();INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(!0);INTERMediator.additionalCondition=restore;IMLibPageNavigation.navigationSetup()}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()},completeTask)}catch(ex){completeTask();if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibPageNavigation.insertRecordFromNavi(targetNameCapt,keyFieldCapt,isConfirmCapt)});INTERMediatorLog.flushMessage()}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-5')}}}})())},deleteRecordFromNavi:function(targetName,keyField,keyValue,isConfirm){'use strict';if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1025])){return}}
IMLibQueue.setTask((function(){var deleteArgs={name:targetName,conditions:[{field:keyField,operator:'=',value:keyValue}]};return function(completeTask){INTERMediatorOnPage.showProgress();try{INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_delete_async(deleteArgs,(function(){return function(){INTERMediator.pagedAllCount--;INTERMediator.totalRecordCount--;if(INTERMediator.pagedAllCount-INTERMediator.startFrom<1){INTERMediator.startFrom--;if(INTERMediator.startFrom<0){INTERMediator.startFrom=0}}
completeTask();INTERMediator.constructMain(!0);INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),completeTask())}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-6');completeTask()}}})())},copyRecordFromNavi:function(contextDef,keyValue){'use strict';if(contextDef['repeat-control'].match(/confirm-copy/)){if(!window.confirm(INTERMediatorOnPage.getMessages()[1041])){return}}
IMLibQueue.setTask((function(){var contextDefCapt=contextDef;var keyValueCapt=keyValue;return function(completeTask){var assocDef,i,def,assocContexts,pStart,copyTerm,index;INTERMediatorOnPage.showProgress();try{if(contextDefCapt.relation){for(index in contextDefCapt.relation){if(contextDefCapt.relation[index].portal===!0){contextDefCapt.portal=!0}}}
assocDef=[];if(contextDefCapt['repeat-control'].match(/copy-/)){pStart=contextDefCapt['repeat-control'].indexOf('copy-');copyTerm=contextDefCapt['repeat-control'].substr(pStart+5);if((pStart=copyTerm.search(/\s/))>-1){copyTerm=copyTerm.substr(0,pStart)}
assocContexts=copyTerm.split(',');for(i=0;i<assocContexts.length;i++){def=IMLibContextPool.getContextDef(assocContexts[i]);if(def.relation[0]['foreign-key']){assocDef.push({name:def.name,field:def.relation[0]['foreign-key'],value:keyValueCapt})}}}
INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_copy_async({name:contextDefCapt.name,conditions:[{field:contextDefCapt.key,operator:'=',value:keyValueCapt}],associated:assocDef.length>0?assocDef:null},(function(){var contextDefCapt2=contextDefCapt;return function(result){var restore,conditions;var newId=result.newRecordKeyValue;completeTask();if(newId>-1){restore=INTERMediator.additionalCondition;INTERMediator.startFrom=0;if(contextDefCapt2.records<=1){conditions=INTERMediator.additionalCondition;conditions[contextDefCapt2.name]={field:contextDefCapt2.key,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}
INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(!0);INTERMediator.additionalCondition=restore}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),completeTask)}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-43');completeTask()}}})())},saveRecordFromNavi:function(dontUpdate){'use strict';var keying,field,keyingComp,keyingField,keyingValue,checkQueryParameter,i,initialValue,currentVal,fieldArray,valueArray,difference,needUpdate=!0,context,updateData,response;INTERMediatorOnPage.showProgress();INTERMediatorOnPage.retrieveAuthInfo();for(i=0;i<IMLibContextPool.poolingContexts.length;i++){context=IMLibContextPool.poolingContexts[i];updateData=context.getModified();for(keying in updateData){if(updateData.hasOwnProperty(keying)){fieldArray=[];valueArray=[];for(field in updateData[keying]){if(updateData[keying].hasOwnProperty(field)){fieldArray.push(field);valueArray.push({field:field,value:updateData[keying][field]})}}
keyingComp=keying.split('=');keyingField=keyingComp[0];keyingComp.shift();keyingValue=keyingComp.join('=');if(!INTERMediator.ignoreOptimisticLocking){checkQueryParameter={name:context.contextName,records:1,paging:!1,fields:fieldArray,parentkeyvalue:null,conditions:[{field:keyingField,operator:'=',value:keyingValue}],useoffset:!1,primaryKeyOnly:!0};try{currentVal=INTERMediator_DBAdapter.db_query(checkQueryParameter)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating((function(){var qParam=checkQueryParameter;return function(){INTERMediator.db_query(qParam)}})());return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-28')}}
if(currentVal.recordset===null||currentVal.recordset[0]===null){window.alert(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1003],[fieldArray.join(',')]));return}
if(currentVal.count>1){response=window.confirm(INTERMediatorOnPage.getMessages()[1024]);if(!response){return}}
difference=!1;for(field in updateData[keying]){if(updateData[keying].hasOwnProperty(field)){initialValue=context.getValue(keying,field);if(initialValue!==currentVal.recordset[0][field]){difference+=INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1035],[field,currentVal.recordset[0][field],updateData[keying][field]])}}}
if(difference!==!1){if(!window.confirm(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1034],[difference]))){return}
INTERMediatorOnPage.retrieveAuthInfo()}}
try{INTERMediator_DBAdapter.db_update({name:context.contextName,conditions:[{field:keyingField,operator:'=',value:keyingValue}],dataset:valueArray})}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibPageNavigation.saveRecordFromNavi(dontUpdate)});return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-29')}}
context.clearModified()}}}
if(needUpdate&&(dontUpdate!==!0)){INTERMediator.constructMain(!0)}
INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()},setupCopyButton:function(encNodeTag,repNodeTag,repeaters,currentContext,currentRecord){'use strict';var buttonNode,thisId,tdNodes,tdNode,buttonName,currentContextDef;currentContextDef=currentContext.getContextDef();if(!currentContextDef['repeat-control']||!currentContextDef['repeat-control'].match(/copy/i)){return}
if(currentContextDef.relation||currentContextDef.records===undefined||!currentContextDef.paging||(currentContextDef.records>1&&Number(INTERMediator.pagedSize)!==1)){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Copy');buttonName=INTERMediatorOnPage.getMessages()[14];if(currentContextDef['button-names']&&currentContextDef['button-names'].copy){buttonName=currentContextDef['button-names'].copy}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;IMLibMouseEventDispatch.setExecute(thisId,(function(){var currentContextCapt=currentContext,currentRecordCapt=currentRecord[currentContextDef.key];return function(){IMLibUI.copyButton(currentContextCapt,currentRecordCapt)}})());switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[tdNodes.length-1];tdNode.appendChild(buttonNode);break;case 'SELECT':break;default:if(repeaters[0]&&repeaters[0].childNodes){repeaters[repeaters.length-1].appendChild(buttonNode)}else{repeaters.push(buttonNode)}
break}}else{IMLibPageNavigation.deleteInsertOnNavi.push({kind:'COPY',name:currentContextDef.name,contextDef:currentContextDef,keyValue:currentRecord[currentContextDef.key]})}},setupDeleteButton:function(encNodeTag,repeaters,currentContext,keyField,keyValue){'use strict';var buttonNode,thisId,tdNodes,tdNode,buttonName,currentContextDef;currentContextDef=currentContext.contextDefinition;if(!currentContextDef['repeat-control']||!currentContextDef['repeat-control'].match(/delete/i)){return}
if(currentContextDef.relation||currentContextDef.records===undefined||!currentContextDef.paging||(currentContextDef.records>1&&Number(INTERMediator.pagedSize)!==1)){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Delete');buttonName=INTERMediatorOnPage.getMessages()[6];if(currentContextDef['button-names']&&currentContextDef['button-names'].delete){buttonName=currentContextDef['button-names'].delete}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;IMLibMouseEventDispatch.setExecute(thisId,(function(){var currentContextCapt=currentContext,keyFieldCapt=keyField,keyValueCapt=keyValue,confirmingCapt=!!currentContextDef['repeat-control'].match(/confirm-delete/i);return function(){IMLibUI.deleteButton(currentContextCapt,keyFieldCapt,keyValueCapt,confirmingCapt)}})());switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[tdNodes.length-1];tdNode.appendChild(buttonNode);break;case 'SELECT':break;default:if(repeaters[0]&&repeaters[0].childNodes){repeaters[repeaters.length-1].appendChild(buttonNode)}else{repeaters.push(buttonNode)}
break}}else{IMLibPageNavigation.deleteInsertOnNavi.push({kind:'DELETE',name:currentContextDef.name,key:keyField,value:keyValue,confirm:currentContextDef['repeat-control'].match(/confirm-delete/i)})}},setupInsertButton:function(currentContext,keyValue,node,relationValue){'use strict';var buttonNode,enclosedNode,footNode,trNode,tdNode,liNode,divNode,i,firstLevelNodes,targetNodeTag,existingButtons,keyField,thisId,encNodeTag,buttonName,setTop,currentContextDef;encNodeTag=node.tagName;currentContextDef=currentContext.getContextDef();if(currentContextDef['repeat-control']&&currentContextDef['repeat-control'].match(/insert/i)){if(relationValue.length>0||!currentContextDef.paging||currentContextDef.paging===!1){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Insert');buttonName=INTERMediatorOnPage.getMessages()[5];if(currentContextDef['button-names']&&currentContextDef['button-names'].insert){buttonName=currentContextDef['button-names'].insert}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;switch(encNodeTag){case 'TBODY':setTop=!1;targetNodeTag='TFOOT';if(currentContextDef['repeat-control'].match(/top/i)){targetNodeTag='THEAD';setTop=!0}
enclosedNode=node.parentNode;firstLevelNodes=enclosedNode.childNodes;footNode=null;for(i=0;i<firstLevelNodes.length;i++){if(firstLevelNodes[i].tagName===targetNodeTag){footNode=firstLevelNodes[i];break}}
if(footNode===null){footNode=document.createElement(targetNodeTag);enclosedNode.appendChild(footNode)}
existingButtons=INTERMediatorLib.getElementsByClassName(footNode,'IM_Button_Insert');if(existingButtons.length===0){trNode=document.createElement('TR');INTERMediatorLib.setClassAttributeToNode(trNode,'IM_Insert_TR');tdNode=document.createElement('TD');tdNode.setAttribute('colspan',100);INTERMediatorLib.setClassAttributeToNode(tdNode,'IM_Insert_TD');INTERMediator.setIdValue(trNode);if(setTop&&footNode.childNodes){footNode.insertBefore(trNode,footNode.childNodes[0])}else{footNode.appendChild(trNode)}
trNode.appendChild(tdNode);tdNode.appendChild(buttonNode)}
break;case 'UL':case 'OL':liNode=document.createElement('LI');existingButtons=INTERMediatorLib.getElementsByClassName(liNode,'IM_Button_Insert');if(existingButtons.length===0){liNode.appendChild(buttonNode);if(currentContextDef['repeat-control'].match(/top/i)){node.insertBefore(liNode,node.firstChild)}else{node.appendChild(liNode)}}
break;case 'SELECT':break;default:divNode=document.createElement('DIV');existingButtons=INTERMediatorLib.getElementsByClassName(divNode,'IM_Button_Insert');if(existingButtons.length===0){divNode.appendChild(buttonNode);if(currentContextDef['repeat-control'].match(/top/i)){node.insertBefore(divNode,node.firstChild)}else{node.appendChild(divNode)}}
break}
IMLibMouseEventDispatch.setExecute(buttonNode.id,(function(){var context=currentContext,keyValueCapt=keyValue,relationValueCapt=relationValue,nodeId=node.getAttribute('id'),confirming=!!currentContextDef['repeat-control'].match(/confirm-insert/i);return function(){IMLibUI.insertButton(context,keyValueCapt,relationValueCapt,nodeId,confirming)}})())}else{if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){keyField=currentContextDef.key?currentContextDef.key:INTERMediatorOnPage.defaultKeyName}else{keyField=currentContextDef.key?currentContextDef.key:'id'}
IMLibPageNavigation.deleteInsertOnNavi.push({kind:'INSERT',name:currentContextDef.name,key:keyField,confirm:currentContextDef['repeat-control'].match(/confirm-insert/i)})}}},setupNavigationButton:function(encNodeTag,repeaters,currentContextDef,keyField,keyValue,contextObj){'use strict';var buttonNode,thisId,tdNodes,tdNode,firstInNode,isMasterDetail,isStep,isHide,masterContext,detailContext,showingNode,isHidePageNavi,buttonName,i,isTouchRepeater,moveToDetailFunc;if(!currentContextDef['navi-control']||(!currentContextDef['navi-control'].match(/master/i)&&!currentContextDef['navi-control'].match(/step/i))||encNodeTag==='SELECT'){return}
isTouchRepeater=INTERMediator.isMobile||INTERMediator.isTablet;isHide=!!currentContextDef['navi-control'].match(/hide/i);isHidePageNavi=isHide&&!!currentContextDef.paging;isMasterDetail=!!currentContextDef['navi-control'].match(/master/i);isStep=!!currentContextDef['navi-control'].match(/step/i);if(isMasterDetail&&INTERMediator.detailNodeOriginalDisplay){detailContext=IMLibContextPool.getDetailContext();if(detailContext){showingNode=detailContext.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
INTERMediator.detailNodeOriginalDisplay=showingNode.style.display}}
buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Master');buttonName=INTERMediatorOnPage.getMessages()[12];if(currentContextDef['button-names']&&currentContextDef['button-names']['navi-detail']){buttonName=currentContextDef['button-names']['navi-detail']}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;if(isMasterDetail){masterContext=IMLibContextPool.getMasterContext();masterContext.setValue(keyField+'='+keyValue,'_im_button_master_id',thisId,thisId)}
if(isMasterDetail){moveToDetailFunc=IMLibPageNavigation.moveToDetail(keyField,keyValue,isHide,isHidePageNavi)}
if(isStep){moveToDetailFunc=IMLibPageNavigation.moveToNextStep(contextObj,keyField,keyValue)}
if(isTouchRepeater){for(i=0;i<repeaters.length;i++){var originalColor=repeaters[i].style.backgroundColor;INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchstart','todo':(function(){var targetNode=repeaters[i];return function(){IMLibEventResponder.touchEventCancel=!1;targetNode.style.backgroundColor=IMLibUI.mobileSelectionColor}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchend','todo':(function(){var targetNode=repeaters[i];var orgColor=originalColor;return function(){targetNode.style.backgroundColor=orgColor;if(!IMLibEventResponder.touchEventCancel){IMLibEventResponder.touchEventCancel=!1;moveToDetailFunc()}}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchmove','todo':(function(){return function(){IMLibEventResponder.touchEventCancel=!0}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchcancel','todo':(function(){return function(){IMLibEventResponder.touchEventCancel=!0}})()})}}else{IMLibMouseEventDispatch.setExecute(thisId,moveToDetailFunc);switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[0];firstInNode=tdNode.childNodes[0];if(firstInNode){tdNode.insertBefore(buttonNode,firstInNode)}else{tdNode.appendChild(buttonNode)}
break;case 'SELECT':break;default:firstInNode=repeaters[repeaters.length-1].childNodes[0];if(firstInNode){repeaters[repeaters.length-1].insertBefore(buttonNode,firstInNode)}else{repeaters[repeaters.length-1].appendChild(buttonNode)}
break}}},getStepLastSelectedRecord:function(){'use strict';var lastSelection=IMLibPageNavigation.stepNavigation[IMLibPageNavigation.stepNavigation.length-1];return lastSelection.context.store[lastSelection.key]},isNotExpandingContext:function(contextDef){'use strict';if(contextDef['navi-control']&&contextDef['navi-control'].match(/step/i)){return IMLibPageNavigation.stepCurrentContextName!==contextDef.name}
return!1},startStep:function(){'use strict';IMLibPageNavigation.initializeStepInfo(!0);INTERMediator.constructMain(IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName))},initializeStepInfo:function(includeHide){'use strict';var key,dataSrcs,cDef,judgeHide,isDetected=!1;IMLibPageNavigation.stepNavigation=[];IMLibPageNavigation.stepCurrentContextName=null;IMLibPageNavigation.stepStartContextName=null;IMLibPageNavigation.setupStepReturnButton('none');if(INTERMediatorOnPage.getDataSources){dataSrcs=INTERMediatorOnPage.getDataSources();for(key in dataSrcs){if(dataSrcs.hasOwnProperty(key)){cDef=dataSrcs[key];if(cDef['navi-control']){judgeHide=includeHide||(!includeHide&&!cDef['navi-control'].match(/hide/i));if(cDef['navi-control']&&cDef['navi-control'].match(/step/i)){if(judgeHide&&!isDetected){IMLibPageNavigation.stepCurrentContextName=cDef.name;IMLibPageNavigation.stepStartContextName=IMLibPageNavigation.stepCurrentContextName;isDetected=!0;if(cDef['navi-title']){IMLibLocalContext.setValue('navi_title',cDef['navi-title'],!0)}
if(INTERMediatorOnPage[cDef['just-move-thisstep']]){INTERMediatorOnPage[cDef['just-move-thisstep']]()}}}}}}}},setupStepReturnButton:function(style){'use strict';var nodes,i;nodes=document.getElementsByClassName('IM_Button_StepBack');for(i=0;i<nodes.length;i++){nodes[i].style.display=style;if(!INTERMediatorLib.isProcessed(nodes[i])){INTERMediatorLib.addEvent(nodes[i],'click',function(){IMLibPageNavigation.backToPreviousStep()});INTERMediatorLib.markProcessed(nodes[i])}}},moveToNextStep:function(contextObj,keyField,keyValue){'use strict';var context=contextObj,keying=keyField+'='+keyValue;return function(){IMLibQueue.setTask(function(complete){IMLibPageNavigation.moveToNextStepImpl(context,keying);complete()})}},moveNextStep:function(keying){'use strict';var context=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);IMLibPageNavigation.moveToNextStepImpl(context,keying)},moveToNextStepImpl:function(contextObj,keying){'use strict';var key,cDef,dataSrcs,contextDef,isAfterCurrent=!1,control=null,hasNextContext=!1,nextContext;contextDef=contextObj.getContextDef();IMLibPageNavigation.stepNavigation.push({context:contextObj,key:keying});if(INTERMediatorOnPage[contextDef['before-move-nextstep']]){control=INTERMediatorOnPage[contextDef['before-move-nextstep']]()}
if(control===!1){IMLibPageNavigation.stepNavigation.pop();return}else if(control){IMLibPageNavigation.stepCurrentContextName=control}else{dataSrcs=INTERMediatorOnPage.getDataSources();for(key in dataSrcs){if(dataSrcs.hasOwnProperty(key)){cDef=dataSrcs[key];if(cDef.name===contextDef.name){isAfterCurrent=!0}else if(isAfterCurrent&&cDef['navi-control'].match(/step/i)){IMLibPageNavigation.stepCurrentContextName=cDef.name;hasNextContext=!0;break}}}
if(!hasNextContext){return}}
if(INTERMediatorOnPage[contextDef['just-leave-thisstep']]){INTERMediatorOnPage[contextDef['just-leave-thisstep']]()}
if(contextObj.enclosureNode.tagName==='TBODY'){contextObj.enclosureNode.parentNode.style.display='none'}else{contextObj.enclosureNode.style.display='none'}
nextContext=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);contextDef=nextContext.getContextDef();if(nextContext.enclosureNode.tagName==='TBODY'){nextContext.enclosureNode.parentNode.style.display=''}else{nextContext.enclosureNode.style.display=''}
INTERMediator.constructMain(nextContext);IMLibPageNavigation.setupStepReturnButton('');if(contextDef['navi-title']){IMLibLocalContext.setValue('navi_title',contextDef['navi-title'],!0)}
if(INTERMediatorOnPage[contextDef['just-move-thisstep']]){INTERMediatorOnPage[contextDef['just-move-thisstep']]()}},backToPreviousStep:function(){'use strict';var currentContext,prevInfo,contextDef;currentContext=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);contextDef=currentContext.getContextDef();if(INTERMediatorOnPage[contextDef['just-leave-thisstep']]){INTERMediatorOnPage[contextDef['just-leave-thisstep']]()}
prevInfo=IMLibPageNavigation.stepNavigation.pop();IMLibPageNavigation.stepCurrentContextName=prevInfo.context.contextName;if(prevInfo.context.enclosureNode.tagName==='TBODY'){prevInfo.context.enclosureNode.parentNode.style.display=''}else{prevInfo.context.enclosureNode.style.display=''}
if(IMLibPageNavigation.stepStartContextName===IMLibPageNavigation.stepCurrentContextName){IMLibPageNavigation.setupStepReturnButton('none')}
INTERMediator.constructMain(currentContext);INTERMediator.constructMain(prevInfo.context);contextDef=prevInfo.context.getContextDef();if(contextDef['navi-title']){IMLibLocalContext.setValue('navi_title',contextDef['navi-title'],!0)}
if(INTERMediatorOnPage[contextDef['just-move-thisstep']]){INTERMediatorOnPage[contextDef['just-move-thisstep']]()}},moveToDetail:function(keyField,keyValue,isHide,isHidePageNavi){'use strict';var f=keyField,v=keyValue,mh=isHide,pnh=isHidePageNavi;return function(){return IMLibPageNavigation.moveToDetailImpl(f,v,mh,pnh)}},moveToDetailImpl:function(keyField,keyValue,isHide,isHidePageNavi){'use strict';var masterContext,detailContext,contextName,masterEnclosure,detailEnclosure,node,contextDef;IMLibPageNavigation.previousModeDetail={keyField:keyField,keyValue:keyValue,isHide:isHide,isHidePageNavi:isHidePageNavi};masterContext=IMLibContextPool.getMasterContext();detailContext=IMLibContextPool.getDetailContext();if(detailContext){if(INTERMediatorOnPage.naviBeforeMoveToDetail){INTERMediatorOnPage.naviBeforeMoveToDetail(masterContext,detailContext)}
contextDef=detailContext.getContextDef();contextName=contextDef.name;INTERMediator.clearCondition(contextName,'_imlabel_crosstable');INTERMediator.addCondition(contextName,{field:keyField,operator:'=',value:keyValue},undefined,'_imlabel_crosstable');INTERMediator.constructMain(detailContext);INTERMediator.clearCondition(contextName);if(isHide){INTERMediatorOnPage.masterScrollPosition={x:window.scrollX,y:window.scrollY};window.scrollTo(0,0);masterEnclosure=masterContext.enclosureNode;if(masterEnclosure.tagName==='TBODY'){masterEnclosure=masterEnclosure.parentNode}
INTERMediator.masterNodeOriginalDisplay=masterEnclosure.style.display;masterEnclosure.style.display='none';detailEnclosure=detailContext.enclosureNode;if(detailEnclosure.tagName==='TBODY'){detailEnclosure=detailEnclosure.parentNode}
detailEnclosure.style.display=INTERMediator.detailNodeOriginalDisplay}
if(isHidePageNavi){document.getElementById('IM_NAVIGATOR').style.display='none'}
if(IMLibUI.mobileNaviBackButtonId){node=document.getElementById(IMLibUI.mobileNaviBackButtonId);node.style.display='inline-block'}
if(INTERMediatorOnPage.naviAfterMoveToDetail){masterContext=IMLibContextPool.getMasterContext();detailContext=IMLibContextPool.getDetailContext();INTERMediatorOnPage.naviAfterMoveToDetail(masterContext,detailContext)}}},setupDetailAreaToFirstRecord:function(currentContextDef,masterContext){'use strict';var i,comp;if(currentContextDef['navi-control']&&currentContextDef['navi-control'].match(/master/i)){var contextDefs=INTERMediatorOnPage.getDataSources();for(i in contextDefs){if(contextDefs.hasOwnProperty(i)&&contextDefs[i]&&contextDefs[i].name&&contextDefs[i]['navi-control']&&contextDefs[i]['navi-control'].match(/detail/i)){if(Object.keys(masterContext.store).length>0){comp=Object.keys(masterContext.store)[0].split('=');if(comp.length>1){INTERMediator.clearCondition(contextDefs[i].name,'_imlabel_crosstable');INTERMediator.addCondition(contextDefs[i].name,{field:comp[0],operator:'=',value:comp[1]},undefined,'_imlabel_crosstable')}}}}}},moveDetailOnceAgain:function(){'use strict';var p=IMLibPageNavigation.previousModeDetail;IMLibPageNavigation.moveToDetailImpl(p.keyField,p.keyValue,p.isHide,p.isHidePageNavi)},setupBackNaviButton:function(currentContext,node){'use strict';var buttonNode,divNode,i,masterContext,naviControlValue,currentContextDef,showingNode,isHidePageNavi,isUpdateMaster,isTouchRepeater,aNode,nodes,isTop;currentContextDef=currentContext.getContextDef();if(!currentContextDef['navi-control']||!currentContextDef['navi-control'].match(/detail/i)){return}
masterContext=IMLibContextPool.getMasterContext();isHidePageNavi=!!masterContext.getContextDef().paging;if(masterContext.getContextDef().paging&&currentContextDef.paging){INTERMediatorLog.setErrorMessage('The datail context definition has the "paging" key. '+'This is not required and causes bad effect to the pagination.','Detected Error')}
naviControlValue=masterContext.getContextDef()['navi-control'];if(!naviControlValue||(!naviControlValue.match(/hide/i))){return}
isUpdateMaster=!!currentContextDef['navi-control'].match(/update/i);isTouchRepeater=INTERMediator.isMobile||INTERMediator.isTablet;isTop=!(currentContextDef['navi-control'].match(/bottom/i));showingNode=currentContext.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
if(INTERMediator.detailNodeOriginalDisplay){INTERMediator.detailNodeOriginalDisplay=showingNode.style.display}
showingNode.style.display='none';if(isTouchRepeater){nodes=document.getElementsByClassName('IM_Button_BackNavi');if(!nodes||nodes.length===0){aNode=createBackButton('DIV',currentContextDef);IMLibUI.mobileNaviBackButtonId=aNode.id;aNode.style.display='none';nodes=INTERMediatorLib.getElementsByAttributeValue(document.getElementsByTagName('BODY')[0],'data-role',isTop?'header':'footer');if(nodes&&nodes[0]){if(nodes[0].firstChild){nodes[0].insertBefore(aNode,nodes[0].firstChild)}else{nodes[0].appendChild(aNode)}}else{switch(node.tagName){case 'TBODY':tbodyTargetNode(node,isTop,aNode);break;case 'UL':case 'OL':genericTargetNode(node,isTop,'LI',aNode);break;case 'SELECT':break;default:genericTargetNode(node,isTop,'DIV',aNode);break}}
if(!aNode.id){aNode.id=INTERMediator.nextIdValue()}
INTERMediator.eventListenerPostAdding.push({'id':aNode.id,'event':'touchend','todo':moveToMaster(masterContext,currentContext,isHidePageNavi,isUpdateMaster)})}}else{buttonNode=createBackButton('BUTTON',currentContextDef);switch(node.tagName){case 'TBODY':tbodyTargetNode(node,isTop,buttonNode);break;case 'UL':case 'OL':genericTargetNode(node,isTop,'LI',buttonNode);break;case 'SELECT':break;default:genericTargetNode(node,isTop,'DIV',buttonNode);break}
INTERMediatorLib.addEvent(buttonNode,'click',moveToMaster(masterContext,currentContext,isHidePageNavi,isUpdateMaster))}
function createBackButton(tagName,currentContextDef){var buttonNode,buttonName;buttonNode=document.createElement(tagName);INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_BackNavi');buttonName=INTERMediatorOnPage.getMessages()[13];if(currentContextDef['button-names']&&currentContextDef['button-names']['navi-back']){buttonName=currentContextDef['button-names']['navi-back']}
buttonNode.appendChild(document.createTextNode(buttonName));setIdForIMButtons(buttonNode);return buttonNode}
function setIdForIMButtons(node){var thisId;thisId='IM_Button_'+INTERMediator.buttonIdNum;node.setAttribute('id',thisId);INTERMediator.buttonIdNum++}
function tbodyTargetNode(node,isTop,buttonNode){var targetNodeTag,enclosedNode,firstLevelNodes,targetNode,existingButtons,trNode,tdNode;targetNodeTag=isTop?'THEAD':'TFOOT';enclosedNode=node.parentNode;firstLevelNodes=enclosedNode.childNodes;targetNode=null;for(i=0;i<firstLevelNodes.length;i++){if(firstLevelNodes[i].tagName===targetNodeTag){targetNode=firstLevelNodes[i];break}}
if(targetNode===null){targetNode=document.createElement(targetNodeTag);INTERMediator.appendingNodesAtLast.push({targetNode:targetNode,parentNode:enclosedNode,siblingNode:(targetNodeTag==='THEAD')?enclosedNode.firstChild:null})}
existingButtons=INTERMediatorLib.getElementsByClassName(targetNode,'IM_Button_BackNavi');if(existingButtons.length===0){trNode=document.createElement('TR');INTERMediatorLib.setClassAttributeToNode(trNode,'IM_NaviBack_TR');tdNode=document.createElement('TD');tdNode.setAttribute('colspan',100);INTERMediatorLib.setClassAttributeToNode(tdNode,'IM_NaviBack_TD');INTERMediator.setIdValue(trNode);targetNode.appendChild(trNode);trNode.appendChild(tdNode);tdNode.appendChild(buttonNode)}}
function genericTargetNode(node,isTop,naviEncTag,buttonNode){var newNode,existingButtons;newNode=document.createElement(naviEncTag);existingButtons=INTERMediatorLib.getElementsByClassName(divNode,'IM_Button_BackNavi');if(existingButtons.length===0){newNode.appendChild(buttonNode);if(!isTop){node.appendChild(newNode)}else{node.insertBefore(newNode,node.firstChild)}}}
function moveToMaster(a,b,c,d){var masterContextCL=a,detailContextCL=b,pageNaviShow=c,masterUpdate=d,node;return function(event){var showingNode;if(INTERMediatorOnPage.naviBeforeMoveToMaster){INTERMediatorOnPage.naviBeforeMoveToMaster(masterContextCL,detailContextCL)}
showingNode=detailContextCL.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
showingNode.style.display='none';showingNode=masterContextCL.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
showingNode.style.display=INTERMediator.masterNodeOriginalDisplay;if(pageNaviShow){document.getElementById('IM_NAVIGATOR').style.display='block'}
if(masterUpdate){INTERMediator.constructMain(masterContextCL)}
if(IMLibUI.mobileNaviBackButtonId){node=document.getElementById(IMLibUI.mobileNaviBackButtonId);node.style.display='none'}
if(INTERMediatorOnPage.naviAfterMoveToMaster){masterContextCL=IMLibContextPool.getMasterContext();detailContextCL=IMLibContextPool.getDetailContext();INTERMediatorOnPage.naviAfterMoveToMaster(masterContextCL,detailContextCL)}
if(INTERMediatorOnPage.masterScrollPosition){window.scrollTo(INTERMediatorOnPage.masterScrollPosition.x,INTERMediatorOnPage.masterScrollPosition.y)}
event.preventDefault()}}}};var IMLibUI={mobileSelectionColor:'#BBBBBB',mobileNaviBackButtonId:null,mergedFieldSeparator:'\n',valueChange:function(idValue,validationOnly){'use strict';var changedObj,contextInfo,linkInfo,nodeInfo,returnValue=!0;changedObj=document.getElementById(idValue);if(!changedObj){return!1}
if(changedObj.readOnly){return!0}
if(!IMLibUI.validation(changedObj)){changedObj.focus();linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);window.setTimeout((function(){var originalObj=changedObj;var originalContextInfo=contextInfo;return function(){if(originalContextInfo){originalObj.value=originalContextInfo.context.getValue(originalContextInfo.record,originalContextInfo.field)}
originalObj.removeAttribute('data-im-validation-notification')}})(),0);return!1}
if(validationOnly===!0){return!0}
IMLibQueue.setTask(function(completeTask){returnValue=valueChangeImpl(idValue,completeTask)});return returnValue;function valueChangeImpl(idValue,completeTask){var changedObj,objType,i,newValue,result,linkInfo,nodeInfo,contextInfo,parentContext,targetField,targetNode,targetSpec,returnValue=!0;try{changedObj=document.getElementById(idValue);linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);if(!contextInfo){targetNode=document.getElementById(idValue);targetSpec=targetNode.getAttribute('data-im');if(targetSpec&&targetSpec.split(INTERMediator.separator)[0]===IMLibLocalContext.contextName){IMLibLocalContext.updateFromNodeValue(idValue);IMLibCalc.recalculation();completeTask();return!0}
throw 'unfinished'}
objType=changedObj.getAttribute('type');if(objType==='radio'&&!changedObj.checked){completeTask();return!0}
if(!contextInfo){throw 'unfinished'}
newValue=IMLibElement.getValueFromIMNode(changedObj);if(contextInfo.context.parentContext){parentContext=contextInfo.context.parentContext}else{parentContext=IMLibContextPool.getContextFromName(contextInfo.context.sourceName)[0]}
if(parentContext){result=parentContext.isValueUndefined(Object.keys(parentContext.store)[0],contextInfo.field,contextInfo.record)}else{result=contextInfo.context.isValueUndefined(contextInfo.record,contextInfo.field,!1)}
if(result){INTERMediatorLog.setErrorMessage('Error in updating.',INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1040],[contextInfo.context.contextName,contextInfo.field]));throw 'unfinished'}
if(INTERMediatorOnPage.getOptionsTransaction()==='none'){contextInfo.context.setValue(contextInfo.record,contextInfo.field,newValue);contextInfo.context.setModified(contextInfo.record,contextInfo.field,newValue);throw 'unfinished'}
if(INTERMediatorOnPage.doBeforeValueChange){INTERMediatorOnPage.doBeforeValueChange(idValue)}
INTERMediatorOnPage.showProgress();contextInfo.context.updateFieldValue(idValue,(function(){var idValueCapt2=idValue;var contextInfoCapt=contextInfo;var newValueCapt=newValue;var completeTaskCapt=completeTask;return function(result){var updateRequiredContext,currentValue,associatedNode,field,node,children,delNodes,recordObj,keepProp;var keyField=contextInfoCapt.context.getKeyField();if(result&&result.dbresult){recordObj=result.dbresult[0];keepProp=INTERMediator.partialConstructing;INTERMediator.partialConstructing=!1;for(field in recordObj){if(recordObj.hasOwnProperty(field)){contextInfoCapt.context.setValue(keyField+'='+recordObj[keyField],field,recordObj[field])}}}
INTERMediator.partialConstructing=keepProp;updateRequiredContext=IMLibContextPool.dependingObjects(idValueCapt2);for(i=0;i<updateRequiredContext.length;i++){updateRequiredContext[i].foreignValue={};updateRequiredContext[i].foreignValue[contextInfoCapt.field]=newValueCapt;if(updateRequiredContext[i]){INTERMediator.constructMain(updateRequiredContext[i]);associatedNode=updateRequiredContext[i].enclosureNode;if(INTERMediatorLib.isPopupMenu(associatedNode)){currentValue=contextInfo.context.getContextValue(associatedNode.id,'');IMLibElement.setValueToIMNode(associatedNode,'',currentValue,!1)}}}
node=document.getElementById(idValueCapt2);if(node&&node.tagName==='SELECT'){children=node.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(children[i].tagName==='OPTION'&&children[i].getAttribute('data-im-element')==='auto-generated'){delNodes=[];delNodes.push(children[i].getAttribute('id'));IMLibElement.deleteNodes(delNodes)}}}}
IMLibCalc.recalculation();if(INTERMediatorOnPage.doAfterValueChange){INTERMediatorOnPage.doAfterValueChange(idValueCapt2)}
INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage();if(completeTaskCapt){completeTaskCapt()}}})(),(function(){var targetFieldCapt=targetField;var completeTaskCapt=completeTask;return function(){window.alert(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1003],[targetFieldCapt]));INTERMediatorOnPage.hideProgress();if(completeTaskCapt){completeTaskCapt()}}})(),function(){var response=window.confirm(INTERMediatorOnPage.getMessages()[1024]);if(!response){INTERMediatorOnPage.hideProgress()}
if(completeTask){completeTask()}
return response},(function(){var changedObjectCapt=changedObj;var completeTaskCapt=completeTask;return function(initialvalue,newValue,currentFieldVal){if(completeTaskCapt){completeTaskCapt()}
if(!window.confirm(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1001],[initialvalue,newValue,currentFieldVal]))){window.setTimeout(function(){changedObjectCapt.focus()},0);INTERMediatorOnPage.hideProgress();return!1}
return!0}})())}catch(e){if(completeTask){completeTask()}
returnValue=!1}
return returnValue}},validation:function(changedObj){'use strict';var linkInfo,matched,context,i,index,didValidate,contextInfo,result,messageNodes=[],messageNode;if(messageNodes){while(messageNodes.length>0){messageNodes[0].parentNode.removeChild(messageNodes[0]);delete messageNodes[0]}}
if(!messageNodes){messageNodes=[]}
try{linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);didValidate=!1;result=!0;if(linkInfo.length>0){matched=linkInfo[0].match(/([^@]+)/);if(matched[1]!==IMLibLocalContext.contextName){context=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',matched[1]);if(context&&context.validation){for(i=0;i<linkInfo.length;i++){matched=linkInfo[i].match(/([^@]+)@([^@]+)/);for(index in context.validation){if(context.validation[index].field===matched[2]){didValidate=!0;result=Parser.evaluate(context.validation[index].rule,{'value':changedObj.value,'target':changedObj});if(!result){switch(context.validation[index].notify){case 'inline':INTERMediatorLib.clearErrorMessage(changedObj);messageNode=INTERMediatorLib.createErrorMessageNode('SPAN',context.validation[index].message);changedObj.parentNode.insertBefore(messageNode,changedObj.nextSibling);messageNodes.push(messageNode);break;case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(changedObj);messageNode=INTERMediatorLib.createErrorMessageNode('DIV',context.validation[index].message);changedObj.parentNode.appendChild(messageNode);messageNodes.push(messageNode);break;default:if(changedObj.getAttribute('data-im-validation-notification')!=='alert'){window.alert(context.validation[index].message);changedObj.setAttribute('data-im-validation-notification','alert')}
break}
contextInfo=IMLibContextPool.getContextInfoFromId(changedObj,'');if(contextInfo){changedObj.value=contextInfo.context.getValue(contextInfo.record,contextInfo.field);window.setTimeout(function(){changedObj.focus()},0);if(INTERMediatorOnPage.doAfterValidationFailure!==null){INTERMediatorOnPage.doAfterValidationFailure(changedObj,linkInfo[i])}}
return result}else{switch(context.validation[index].notify){case 'inline':case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(changedObj);break}}}}}}}
if(didValidate){if(INTERMediatorOnPage.doAfterValidationSucceed){result=INTERMediatorOnPage.doAfterValidationSucceed(changedObj,linkInfo[i])}}}
return result}catch(ex){if(ex==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-32: on the validation process.')}
return!1}},copyButton:function(contextObj,keyValue){'use strict';var contextDef=contextObj.getContextDef();if(contextDef['repeat-control'].match(/confirm-copy/)){if(!window.confirm(INTERMediatorOnPage.getMessages()[1041])){return}}
IMLibQueue.setTask((function(){var contextObjCapt=contextObj;var keyValueCapt=keyValue;return function(completeTask){var contextDef,assocDef,i,index,def,assocContexts,pStart,copyTerm;contextDef=contextObjCapt.getContextDef();INTERMediatorOnPage.showProgress();try{if(contextDef.relation){for(index in contextDef.relation){if(contextDef.relation[index].portal===!0){contextDef.portal=!0}}}
assocDef=[];if(contextDef['repeat-control'].match(/copy-/)){pStart=contextDef['repeat-control'].indexOf('copy-');copyTerm=contextDef['repeat-control'].substr(pStart+5);if((pStart=copyTerm.search(/\s/))>-1){copyTerm=copyTerm.substr(0,pStart)}
assocContexts=copyTerm.split(',');for(i=0;i<assocContexts.length;i++){def=IMLibContextPool.getContextDef(assocContexts[i]);if(def.relation[0]['foreign-key']){assocDef.push({name:def.name,field:def.relation[0]['foreign-key'],value:keyValueCapt})}}}
INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_copy_async({name:contextDef.name,conditions:[{field:contextDef.key,operator:'=',value:keyValueCapt}],associated:assocDef.length>0?assocDef:null},(function(){var contextDefCapt=contextDef;var contextObjCapt2=contextObjCapt;var completeTaskCapt=completeTask;return function(result){var restore,conditions,sameOriginContexts;var newId=result.newRecordKeyValue;if(newId>-1){restore=INTERMediator.additionalCondition;INTERMediator.startFrom=0;if(contextDefCapt.records<=1){conditions=INTERMediator.additionalCondition;conditions[contextDefCapt.name]={field:contextDefCapt.key,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}
INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(contextObjCapt2);sameOriginContexts=IMLibContextPool.getContextsWithSameOrigin(contextObjCapt2);for(i=0;i<sameOriginContexts.length;i++){INTERMediator.constructMain(sameOriginContexts[i],null)}
INTERMediator.additionalCondition=restore}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();completeTaskCapt();INTERMediatorLog.flushMessage()}})(),completeTask)}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-43')}}})())},deleteButton:function(currentContext,keyField,keyValue,isConfirm){'use strict';var dialogMessage;if(isConfirm){dialogMessage=INTERMediatorOnPage.getMessages()[1025];if(!window.confirm(dialogMessage)){return}}
IMLibQueue.setTask((function(){var currentContextCapt=currentContext;var keyFieldCapt=keyField;var keyValueCapt=keyValue;return function(completeTask){var i,parentKeyValue,deleteSuccessProc,targetRepeaters;INTERMediatorOnPage.showProgress();try{INTERMediatorOnPage.retrieveAuthInfo();deleteSuccessProc=(function(){var currentContextCapt2=currentContextCapt;var completeTaskCapt=completeTask;var keying=keyFieldCapt+'='+keyValueCapt;return function(){if(currentContextCapt2.relation===!0){INTERMediator.pagedAllCount--;if(INTERMediator.pagedAllCount-INTERMediator.startFrom<1){INTERMediator.startFrom=INTERMediator.startFrom-INTERMediator.pagedSize;if(INTERMediator.startFrom<0){INTERMediator.startFrom=0}}
if(INTERMediator.pagedAllCount>=INTERMediator.pagedSize){INTERMediator.construct()}}
IMLibPageNavigation.navigationSetup();targetRepeaters=currentContextCapt2.binding[keying]._im_repeater;for(i=0;i<targetRepeaters.length;i++){IMLibContextPool.removeRecordFromPool(targetRepeaters[i].id)}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();completeTaskCapt();INTERMediatorLog.flushMessage()}})();if(currentContextCapt.isPortal){if(currentContextCapt.potalContainingRecordKV===null){parentKeyValue=Object.keys(currentContextCapt.foreignValue);parentKeyValue[1]=currentContextCapt.foreignValue[parentKeyValue[0]]}else{parentKeyValue=currentContextCapt.potalContainingRecordKV.split('=')}
INTERMediator_DBAdapter.db_update_async({name:currentContextCapt.parentContext&&currentContextCapt.parentContext.contextName?currentContextCapt.parentContext.contextName:currentContextCapt.sourceName,conditions:[{field:parentKeyValue[0],operator:'=',value:parentKeyValue[1]}],dataset:[{field:INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'?'deleteRelated':'-delete.related',operator:'=',value:currentContextCapt.contextName+'.'+keyValue}]},deleteSuccessProc,completeTask)}else{INTERMediator_DBAdapter.db_delete_async({name:currentContextCapt.contextName,conditions:[{field:keyFieldCapt,operator:'=',value:keyValueCapt}]},deleteSuccessProc,function(){INTERMediatorLog.setErrorMessage('Delete Error','EXCEPTION-46');completeTask()})}}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibUI.deleteButton(currentContextCapt,keyFieldCapt,keyValueCapt,!1)});return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-3')}
completeTask()}}})())},insertButton:function(currentObj,keyValue,foreignValues,updateNodes,isConfirm){'use strict';if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1026])){return}}
IMLibQueue.setTask((function(){var currentContext,targetName,isPortal,parentContextName;var keyValueCapt=keyValue;var foreignValuesCapt=foreignValues;var updateNodesCapt=updateNodes;targetName=currentObj.contextName;currentContext=currentObj.getContextDef();isPortal=currentObj.isPortal;if(isPortal){parentContextName=currentObj.sourceName?currentObj.sourceName:null}else{parentContextName=currentObj.parentContext?currentObj.parentContext.contextName:null}
return function(completeTask){var targetRecord,portalField,recordSet,index,targetPortalField,targetPortalValue,existRelated=!1,relatedRecordSet;INTERMediatorOnPage.showProgress();recordSet=[];relatedRecordSet=[];if(foreignValuesCapt){for(index in currentContext.relation){if(currentContext.relation.hasOwnProperty(index)){recordSet.push({field:currentContext.relation[index]['foreign-key'],value:foreignValuesCapt[currentContext.relation[index]['join-field']]})}}}
INTERMediatorOnPage.retrieveAuthInfo();if(isPortal){relatedRecordSet=[];for(index in currentContext['default-values']){if(currentContext['default-values'].hasOwnProperty(index)){relatedRecordSet.push({field:targetName+'::'+currentContext['default-values'][index].field+'.0',value:currentContext['default-values'][index].value})}}
if(relatedRecordSet.length===0){targetPortalValue='';targetRecord=INTERMediator_DBAdapter.db_query({name:targetName,records:1,conditions:[{field:currentContext.key?currentContext.key:INTERMediatorOnPage.defaultKeyName,operator:'=',value:keyValueCapt}]});if(targetRecord.recordset&&targetRecord.recordset[0]&&targetRecord.recordset[0][0]){for(portalField in targetRecord.recordset[0][0]){if(portalField.indexOf(targetName+'::')>-1&&portalField!==targetName+'::'+INTERMediatorOnPage.defaultKeyName){existRelated=!0;targetPortalField=portalField;if(portalField===targetName+'::'+recordSet[0].field){targetPortalValue=recordSet[0].value;break}
if(portalField!==targetName+'::id'&&portalField!==targetName+'::'+recordSet[0].field){break}}}}
if(existRelated===!1){targetRecord=INTERMediator_DBAdapter.db_query({name:targetName,records:0,conditions:[{field:currentContext.key?currentContext.key:INTERMediatorOnPage.defaultKeyName,operator:'=',value:keyValueCapt}]});for(portalField in targetRecord.recordset){if(portalField.indexOf(targetName+'::')>-1&&portalField!==targetName+'::'+INTERMediatorOnPage.defaultKeyName){targetPortalField=portalField;if(portalField===targetName+'::'+recordSet[0].field){targetPortalValue=recordSet[0].value;break}
if(portalField!==targetName+'::id'&&portalField!==targetName+'::'+recordSet[0].field){break}}}}
if(foreignValuesCapt&&recordSet[0]){targetPortalField=targetName+'::'+recordSet[0].field;targetPortalValue=recordSet[0].value}else if(targetPortalField===undefined&&currentContext.relation&&currentContext.relation[0]&&currentContext.relation[0]['join-field']){targetPortalField=targetName+'::'+currentContext.relation[0]['join-field']}
relatedRecordSet.push({field:targetPortalField+'.0',value:targetPortalValue})}
completeTask();if(currentContext.relation&&currentContext.relation[0]&&currentContext.relation[0]['join-field']){INTERMediator_DBAdapter.db_update({name:parentContextName,conditions:[{field:currentContext.relation[0]['join-field'],operator:'=',value:foreignValuesCapt&&foreignValuesCapt.id?foreignValuesCapt.id:keyValueCapt}],dataset:relatedRecordSet});INTERMediator.constructMain()}else{INTERMediatorLog.setErrorMessage('Insert Error (Portal Access Mode)','EXCEPTION-4')}}else{INTERMediator_DBAdapter.db_createRecord_async({name:targetName,dataset:recordSet},(function(){var targetNameCapt=targetName;var currentContextCapt=currentContext;var updateNodesCapt2=updateNodesCapt;var foreignValuesCapt2=foreignValuesCapt;var existRelatedCapt=existRelated;var keyValueCapt2=keyValueCapt;return function(result){var keyField,newRecordId,associatedContext,conditions,createdRecord,i,sameOriginContexts;newRecordId=result.newRecordKeyValue;keyField=currentContextCapt.key?currentContextCapt.key:INTERMediatorOnPage.defaultKeyName;associatedContext=IMLibContextPool.contextFromEnclosureId(updateNodesCapt2);completeTask();if(associatedContext){associatedContext.foreignValue=foreignValuesCapt2;if(currentContextCapt.portal===!0&&existRelatedCapt===!1){conditions=INTERMediator.additionalCondition;conditions[targetNameCapt]={field:keyField,operator:'=',value:keyValueCapt2};INTERMediator.additionalCondition=conditions}
createdRecord=[{}];createdRecord[0][keyField]=newRecordId;INTERMediator.constructMain(associatedContext,result.dbresult);sameOriginContexts=IMLibContextPool.getContextsWithSameOrigin(associatedContext);for(i=0;i<sameOriginContexts.length;i++){INTERMediator.constructMain(sameOriginContexts[i],null)}}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),function(){INTERMediatorLog.setErrorMessage('Insert Error','EXCEPTION-4');completeTask()})}}})())},clickPostOnlyButton:function(node){'use strict';var i,j,fieldData,elementInfo,comp,contextCount,selectedContext,contextInfo,validationInfo;var mergedValues,inputNodes,typeAttr,k,messageNode,result,alertmessage;var linkedNodes,namedNodes,index,hasInvalid,isMerged,contextNodes;var targetNode=node.parentNode;while(!INTERMediatorLib.isEnclosure(targetNode,!0)){targetNode=targetNode.parentNode;if(!targetNode){return}}
if(INTERMediatorOnPage.processingBeforePostOnlyContext){if(!INTERMediatorOnPage.processingBeforePostOnlyContext(targetNode)){return}}
contextNodes=[];linkedNodes=[];namedNodes=[];for(i=0;i<targetNode.childNodes.length;i++){seekLinkedElementInThisContext(targetNode.childNodes[i]);seekLinkedElementInAllChildren(targetNode.childNodes[i])}
contextCount={};for(i=0;i<contextNodes.length;i++){elementInfo=INTERMediatorLib.getLinkedElementInfo(contextNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(!contextCount[comp[j]]){contextCount[comp[j]]=0}
contextCount[comp[j]]++}}
if(contextCount.length<1){return}
var maxCount=-100;for(var contextName in contextCount){if(maxCount<contextCount[contextName]){maxCount=contextCount[contextName];selectedContext=contextName;contextInfo=INTERMediatorOnPage.getContextInfo(contextName)}}
alertmessage='';fieldData=[];hasInvalid=!1;for(i=0;i<linkedNodes.length;i++){elementInfo=INTERMediatorLib.getLinkedElementInfo(linkedNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(comp[0]===selectedContext){if(contextInfo.validation){for(index in contextInfo.validation){if(contextInfo.validation.hasOwnProperty(index)){validationInfo=contextInfo.validation[index];if(validationInfo&&validationInfo.field===comp[1]){switch(validationInfo.notify){case 'inline':case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);break}}}}
for(index in contextInfo.validation){if(contextInfo.validation.hasOwnProperty(index)){validationInfo=contextInfo.validation[index];if(validationInfo.field===comp[1]){if(validationInfo){result=Parser.evaluate(validationInfo.rule,{'value':linkedNodes[i].value,'target':linkedNodes[i]});if(!result){hasInvalid=!0;switch(validationInfo.notify){case 'inline':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);messageNode=INTERMediatorLib.createErrorMessageNode('SPAN',validationInfo.message);linkedNodes[i].parentNode.insertBefore(messageNode,linkedNodes[i].nextSibling);break;case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);messageNode=INTERMediatorLib.createErrorMessageNode('DIV',validationInfo.message);linkedNodes[i].parentNode.appendChild(messageNode);break;default:alertmessage+=validationInfo.message+IMLib.nl_char}
if(INTERMediatorOnPage.doAfterValidationFailure){INTERMediatorOnPage.doAfterValidationFailure(linkedNodes[i])}}}}}}}
if(INTERMediatorLib.isWidgetElement(linkedNodes[i])){fieldData.push({field:comp[1],value:linkedNodes[i]._im_getValue()})}else if(linkedNodes[i].tagName==='SELECT'){fieldData.push({field:comp[1],value:linkedNodes[i].value})}else if(linkedNodes[i].tagName==='TEXTAREA'){fieldData.push({field:comp[1],value:linkedNodes[i].value})}else if(linkedNodes[i].tagName==='INPUT'){if((linkedNodes[i].getAttribute('type')==='radio')||(linkedNodes[i].getAttribute('type')==='checkbox')){if(linkedNodes[i].checked){fieldData.push({field:comp[1],value:linkedNodes[i].value})}}else{fieldData.push({field:comp[1],value:linkedNodes[i].value})}}}}}
for(i=0;i<namedNodes.length;i++){elementInfo=INTERMediatorLib.getNamedInfo(namedNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(comp[0]===selectedContext){mergedValues=[];if(namedNodes[i].tagName==='INPUT'){inputNodes=[namedNodes[i]]}else{inputNodes=namedNodes[i].getElementsByTagName('INPUT')}
for(k=0;k<inputNodes.length;k++){typeAttr=inputNodes[k].getAttribute('type');if(typeAttr==='radio'||typeAttr==='checkbox'){if(inputNodes[k].checked){mergedValues.push(inputNodes[k].value)}}else{mergedValues.push(inputNodes[k].value)}}
if(mergedValues.length>0){isMerged=!1;for(index=0;index<fieldData.length;index++){if(fieldData[index].field===comp[1]){fieldData[index].value+=IMLibUI.mergedFieldSeparator;fieldData[index].value+=mergedValues.join(IMLibUI.mergedFieldSeparator);isMerged=!0}}
if(!isMerged){fieldData.push({field:comp[1],value:mergedValues.join(IMLibUI.mergedFieldSeparator)})}}}}}
if(alertmessage.length>0){window.alert(alertmessage);return}
if(hasInvalid){return}
contextInfo=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',selectedContext);if(INTERMediatorOnPage.modifyPostOnlyContext){contextInfo=INTERMediatorOnPage.modifyPostOnlyContext(contextInfo)}
INTERMediator_DBAdapter.db_createRecord_async({name:selectedContext,dataset:fieldData},function(result){var newNode,parentOfTarget,targetNode=node,thisContext=contextInfo,isSetMsg=!1;INTERMediatorLog.flushMessage();if(INTERMediatorOnPage.processingAfterPostOnlyContext){INTERMediatorOnPage.processingAfterPostOnlyContext(targetNode,result.newRecordKeyValue)}
if(thisContext['post-dismiss-message']){parentOfTarget=targetNode.parentNode;parentOfTarget.removeChild(targetNode);newNode=document.createElement('SPAN');INTERMediatorLib.setClassAttributeToNode(newNode,'IM_POSTMESSAGE');newNode.appendChild(document.createTextNode(thisContext['post-dismiss-message']));parentOfTarget.appendChild(newNode);isSetMsg=!0}
if(thisContext['post-reconstruct']){setTimeout(function(){INTERMediator.construct(!0)},isSetMsg?INTERMediator.waitSecondsAfterPostMessage*1000:0)}
if(thisContext['post-move-url']){setTimeout(function(){location.href=thisContext['post-move-url']},isSetMsg?INTERMediator.waitSecondsAfterPostMessage*1000:0)}},null);function seekLinkedElementInThisContext(node){var children,i;if(node.nodeType===1){if(INTERMediatorLib.isLinkedElement(node)){contextNodes.push(node)}else if(INTERMediatorLib.isWidgetElement(node)){contextNodes.push(node)}else{if(INTERMediatorLib.isEnclosure(node)){return}
children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElementInThisContext(children[i])}}}}
function seekLinkedElementInAllChildren(node){var children,i;if(node.nodeType===1){if(INTERMediatorLib.isNamedElement(node)){namedNodes.push(node)}else if(INTERMediatorLib.isLinkedElement(node)){linkedNodes.push(node)}else if(INTERMediatorLib.isWidgetElement(node)){linkedNodes.push(node)}else{children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElementInAllChildren(children[i])}}}}},eventUpdateHandler:function(contextName){'use strict';IMLibLocalContext.updateAll();var context=IMLibContextPool.getContextFromName(contextName);INTERMediator.constructMain(context[0])},eventAddOrderHandler:function(e){'use strict';var targetKey,targetSplit,key,itemSplit,extValue;if(e.target){targetKey=e.target.getAttribute('data-im')}else{targetKey=e.srcElement.getAttribute('data-im')}
targetSplit=targetKey.split(':');if(targetSplit[0]!=='_@addorder'||targetSplit.length<3){return}
for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){itemSplit=key.split(':');if(itemSplit.length>3&&itemSplit[0]==='valueofaddorder'&&itemSplit[1]===targetSplit[1]){extValue=IMLibLocalContext.getValue(key);if(extValue){IMLibLocalContext.store[key]++}}}}
IMLibLocalContext.setValue('valueof'+targetKey.substring(2),1);IMLibUI.eventUpdateHandler(targetSplit[1])}};var INTERMediatorLog={debugMode:!1,suppressDebugMessageOnPage:!1,suppressErrorMessageOnPage:!1,errorMessages:[],debugMessages:[],errorMessageByAlert:!1,errorMessageOnAlert:null,setDebugMessage:function(message,level){'use strict';if(level===undefined){level=1}
if(INTERMediatorLog.debugMode>=level){INTERMediatorLog.debugMessages.push(message);if(typeof console!=='undefined'){console.log('INTER-Mediator[DEBUG:%s]: %s',new Date(),message)}}},setErrorMessage:function(ex,moreMessage){'use strict';moreMessage=moreMessage===undefined?'':(' - '+moreMessage);if(INTERMediatorLog.errorMessageByAlert){window.alert(INTERMediatorLog.errorMessageOnAlert===null?(ex+moreMessage):INTERMediatorLog.errorMessageOnAlert)}
if((typeof ex==='string'||ex instanceof String)){INTERMediatorLog.errorMessages.push(ex+moreMessage);if(typeof console!=='undefined'){console.error('INTER-Mediator[ERROR]: %s',ex+moreMessage)}}else{if(ex.message){INTERMediatorLog.errorMessages.push(ex.message+moreMessage);if(typeof console!=='undefined'){console.error('INTER-Mediator[ERROR]: %s',ex.message+moreMessage)}}
if(ex.stack&&typeof console!=='undefined'){console.error(ex.stack)}}},flushMessage:function(){'use strict';var debugNode,title,body,i,j,lines,clearButton,tNode;if(INTERMediatorLog.errorMessageByAlert){INTERMediatorLog.suppressErrorMessageOnPage=!0}
if(!INTERMediatorLog.suppressErrorMessageOnPage&&INTERMediatorLog.errorMessages.length>0){debugNode=document.getElementById('_im_error_panel_4873643897897');if(debugNode===null){debugNode=document.createElement('div');debugNode.setAttribute('id','_im_error_panel_4873643897897');debugNode.style.backgroundColor='#FFDDDD';title=document.createElement('h3');title.appendChild(document.createTextNode('Error Info from INTER-Mediator'));title.appendChild(document.createElement('hr'));debugNode.appendChild(title);body=document.getElementsByTagName('body')[0];body.insertBefore(debugNode,body.firstChild)}
debugNode.appendChild(document.createTextNode('============ERROR MESSAGE on '+new Date()+'============'));debugNode.appendChild(document.createElement('hr'));for(i=0;i<INTERMediatorLog.errorMessages.length;i++){lines=INTERMediatorLog.errorMessages[i].split(IMLib.nl_char);for(j=0;j<lines.length;j++){if(j>0){debugNode.appendChild(document.createElement('br'))}
debugNode.appendChild(document.createTextNode(lines[j]))}
debugNode.appendChild(document.createElement('hr'))}}
if(!INTERMediatorLog.suppressDebugMessageOnPage&&INTERMediatorLog.debugMode&&INTERMediatorLog.debugMessages.length>0){debugNode=document.getElementById('_im_debug_panel_4873643897897');if(debugNode===null){debugNode=document.createElement('div');debugNode.setAttribute('id','_im_debug_panel_4873643897897');debugNode.style.backgroundColor='#DDDDDD';clearButton=document.createElement('button');clearButton.setAttribute('title','clear');clearButton.id='_im_debug_panel_4873643897897_button';IMLibMouseEventDispatch.setExecute(clearButton.id,function(){var target;target=document.getElementById('_im_debug_panel_4873643897897');target.parentNode.removeChild(target)});tNode=document.createTextNode('clear');clearButton.appendChild(tNode);title=document.createElement('h3');title.appendChild(document.createTextNode('Debug Info from INTER-Mediator'));title.appendChild(clearButton);title.appendChild(document.createElement('hr'));debugNode.appendChild(title);body=document.getElementsByTagName('body')[0];if(body){if(body.firstChild){body.insertBefore(debugNode,body.firstChild)}else{body.appendChild(debugNode)}}}
debugNode.appendChild(document.createTextNode('============DEBUG INFO on '+new Date()+'============ '));if(INTERMediatorOnPage.getEditorPath()){var aLink=document.createElement('a');aLink.setAttribute('href',INTERMediatorOnPage.getEditorPath());aLink.appendChild(document.createTextNode('Definition File Editor'));debugNode.appendChild(aLink)}
debugNode.appendChild(document.createElement('hr'));for(i=0;i<INTERMediatorLog.debugMessages.length;i++){lines=INTERMediatorLog.debugMessages[i].split(IMLib.nl_char);for(j=0;j<lines.length;j++){if(j>0){debugNode.appendChild(document.createElement('br'))}
debugNode.appendChild(document.createTextNode(lines[j]))}
debugNode.appendChild(document.createElement('hr'))}}
INTERMediatorLog.errorMessages=[];INTERMediatorLog.debugMessages=[]}};var INTERMediator_DBAdapter={eliminateDuplicatedConditions:!1,debugMessage:!1,generate_authParams:function(){'use strict';var authParams='',shaObj,hmacValue,encrypted;var encrypt=new JSEncrypt();if(INTERMediatorOnPage.authUser.length>0){authParams='&clientid='+encodeURIComponent(INTERMediatorOnPage.clientId);authParams+='&authuser='+encodeURIComponent(INTERMediatorOnPage.authUser);if(INTERMediatorOnPage.isNativeAuth||INTERMediatorOnPage.isLDAP){if(INTERMediatorOnPage.authCryptedPassword&&INTERMediatorOnPage.authChallenge){encrypt.setPublicKey(INTERMediatorOnPage.publickey);encrypted=encrypt.encrypt(INTERMediatorOnPage.authCryptedPassword.substr(0,220)+IMLib.nl_char+INTERMediatorOnPage.authChallenge);authParams+='&cresponse='+encodeURIComponent(encrypted+IMLib.nl_char+INTERMediatorOnPage.authCryptedPassword.substr(220));if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('generate_authParams/authCryptedPassword='+INTERMediatorOnPage.authCryptedPassword);INTERMediatorLog.setDebugMessage('generate_authParams/authChallenge='+INTERMediatorOnPage.authChallenge)}}else{authParams+='&cresponse=dummy'}}
if(INTERMediatorOnPage.authHashedPassword&&INTERMediatorOnPage.authChallenge){shaObj=new jsSHA(INTERMediatorOnPage.authHashedPassword,'ASCII');hmacValue=shaObj.getHMAC(INTERMediatorOnPage.authChallenge,'ASCII','SHA-256','HEX');authParams+='&response='+encodeURIComponent(hmacValue);if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('generate_authParams/authHashedPassword='+INTERMediatorOnPage.authHashedPassword);INTERMediatorLog.setDebugMessage('generate_authParams/authChallenge='+INTERMediatorOnPage.authChallenge)}}else{authParams+='&response=dummy'}}
authParams+='&notifyid=';authParams+=encodeURIComponent(INTERMediatorOnPage.clientNotificationIdentifier());authParams+=('&pusher='+(INTERMediator.pusherAvailable?'yes':''));return authParams},store_challenge:function(challenge){'use strict';if(challenge!==null){INTERMediatorOnPage.authChallenge=challenge.substr(0,24);INTERMediatorOnPage.authUserHexSalt=challenge.substr(24,32);INTERMediatorOnPage.authUserSalt=String.fromCharCode(parseInt(challenge.substr(24,2),16),parseInt(challenge.substr(26,2),16),parseInt(challenge.substr(28,2),16),parseInt(challenge.substr(30,2),16));if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('store_challenge/authChallenge='+INTERMediatorOnPage.authChallenge);INTERMediatorLog.setDebugMessage('store_challenge/authUserHexSalt='+INTERMediatorOnPage.authUserHexSalt);INTERMediatorLog.setDebugMessage('store_challenge/authUserSalt='+INTERMediatorOnPage.authUserSalt)}}},logging_comAction:function(debugMessageNumber,appPath,accessURL,authParams){'use strict';INTERMediatorLog.setDebugMessage(INTERMediatorOnPage.getMessages()[debugMessageNumber]+'Accessing:'+decodeURI(appPath)+', Parameters:'+decodeURI(accessURL+authParams))},logging_comResult:function(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken){'use strict';var responseTextTrancated;if(INTERMediatorLog.debugMode>1){if(myRequest.responseText.length>1000){responseTextTrancated=myRequest.responseText.substr(0,1000)+' ...[trancated]'}else{responseTextTrancated=myRequest.responseText}
INTERMediatorLog.setDebugMessage('myRequest.responseText='+responseTextTrancated);INTERMediatorLog.setDebugMessage('Return: resultCount='+resultCount+', dbresult='+INTERMediatorLib.objectToString(dbresult)+IMLib.nl_char+'Return: requireAuth='+requireAuth+', challenge='+challenge+', clientid='+clientid+IMLib.nl_char+'Return: newRecordKeyValue='+newRecordKeyValue+', changePasswordResult='+changePasswordResult+', mediatoken='+mediatoken)}},server_access:function(accessURL,debugMessageNumber,errorMessageNumber){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,totalCount=null,challenge=null,clientid=null,requireAuth=!1,myRequest=null,changePasswordResult=null,mediatoken=null,appPath,authParams,jsonObject,i,notifySupport=!1,useNull=!1,registeredID='';appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();INTERMediator_DBAdapter.logging_comAction(debugMessageNumber,appPath,accessURL,authParams);INTERMediatorOnPage.notifySupport=notifySupport;try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!1,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');myRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');myRequest.setRequestHeader('X-Requested-With','XMLHttpRequest');myRequest.setRequestHeader('X-From',location.href);myRequest.send(accessURL+authParams);jsonObject=JSON.parse(myRequest.responseText);resultCount=jsonObject.resultCount?jsonObject.resultCount:0;totalCount=jsonObject.totalCount?jsonObject.totalCount:null;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;notifySupport=jsonObject.notifySupport;for(i=0;i<jsonObject.errorMessages.length;i++){INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
useNull=jsonObject.usenull;registeredID=jsonObject.hasOwnProperty('registeredid')?jsonObject.registeredid:'';INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(INTERMediatorOnPage.isLDAP===!0&&INTERMediatorOnPage.authUserHexSalt!==INTERMediatorOnPage.authHashedPassword.substr(-8,8)){if(accessURL!=='access=challenge'){requireAuth=!0}}}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorMessageNumber],[e,myRequest.responseText]))}
if(accessURL.indexOf('access=changepassword&newpass=')===0){return changePasswordResult}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();throw new Error('_im_requath_request_')}
if(!accessURL.match(/access=challenge/)){INTERMediatorOnPage.authCount=0}
INTERMediatorOnPage.storeCredentialsToCookieOrStorage();INTERMediatorOnPage.notifySupport=notifySupport;return{dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull}},server_access_async:function(accessURL,debugMessageNumber,errorMessageNumber,successProc,failedProc,authAgainProc){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,totalCount=null,challenge=null,clientid=null,requireAuth=!1,myRequest=null,changePasswordResult=null,mediatoken=null,appPath,authParams,jsonObject,i,notifySupport=!1,useNull=!1,registeredID='';appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();INTERMediator_DBAdapter.logging_comAction(debugMessageNumber,appPath,accessURL,authParams);INTERMediatorOnPage.notifySupport=notifySupport;try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!0,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');myRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');myRequest.setRequestHeader('X-Requested-With','XMLHttpRequest');myRequest.setRequestHeader('X-From',location.href);myRequest.onreadystatechange=function(){switch(myRequest.readyState){case 0:break;case 1:break;case 2:break;case 3:break;case 4:try{jsonObject=JSON.parse(myRequest.responseText)}catch(ex){INTERMediatorLog.setErrorMessage('Communication Error: '+myRequest.responseText);if(failedProc){failedProc(new Error('_im_communication_error_'))}
return}
resultCount=jsonObject.resultCount?jsonObject.resultCount:0;totalCount=jsonObject.totalCount?jsonObject.totalCount:null;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;notifySupport=jsonObject.notifySupport;for(i=0;i<jsonObject.errorMessages.length;i++){INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
useNull=jsonObject.usenull;registeredID=jsonObject.hasOwnProperty('registeredid')?jsonObject.registeredid:'';if(jsonObject.errorMessages.length>0){INTERMediatorLog.setErrorMessage('Communication Error: '+jsonObject.errorMessages);if(failedProc){failedProc()}
throw 'Communication Error'}
INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(INTERMediatorOnPage.isLDAP===!0&&INTERMediatorOnPage.authUserHexSalt!==INTERMediatorOnPage.authHashedPassword.substr(-8,8)){if(accessURL!=='access=challenge'){requireAuth=!0}}
if(accessURL.indexOf('access=changepassword&newpass=')===0){if(successProc){successProc({dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull})}
return}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();if(authAgainProc){authAgainProc(myRequest)}
return}
if(!accessURL.match(/access=challenge/)){INTERMediatorOnPage.authCount=0}
INTERMediatorOnPage.storeCredentialsToCookieOrStorage();INTERMediatorOnPage.notifySupport=notifySupport;if(successProc){successProc({dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull})}
break}};myRequest.send(accessURL+authParams)}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorMessageNumber],[e,myRequest.responseText]));if(failedProc){failedProc()}}},changePassword:function(username,oldpassword,newpassword){'use strict';var challengeResult,params,result,messageNode;var encrypt=new JSEncrypt();if(username&&oldpassword){INTERMediatorOnPage.authUser=username;if(username!==''&&(INTERMediatorOnPage.authChallenge===null||INTERMediatorOnPage.authChallenge.length<24)){INTERMediatorOnPage.authHashedPassword='need-hash-pls';challengeResult=INTERMediator_DBAdapter.getChallenge();if(!challengeResult){messageNode=document.getElementById('_im_newpass_message');if(messageNode){INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2008)))}else{window.alert(INTERMediatorLib.getInsertedStringFromErrorNumber(2008))}
INTERMediatorLog.flushMessage();return}}
INTERMediatorOnPage.authHashedPassword=SHA1(oldpassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt}else{INTERMediatorOnPage.retrieveAuthInfo()}
params='access=changepassword&newpass='+INTERMediatorLib.generatePasswordHash(newpassword);try{result=INTERMediator_DBAdapter.server_access(params,1029,1030);if(result){encrypt.setPublicKey(INTERMediatorOnPage.publickey);INTERMediatorOnPage.authCryptedPassword=encrypt.encrypt(newpassword);INTERMediatorOnPage.authHashedPassword=SHA1(newpassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt;INTERMediatorOnPage.storeCredentialsToCookieOrStorage()}}catch(e){return!1}
return result},getChallenge:function(){'use strict';try{this.server_access('access=challenge',1027,1028)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-19')}}
if(INTERMediatorOnPage.authChallenge===null){return!1}
return!0},uploadFile:function(parameters,uploadingFile,doItOnFinish,exceptionProc){'use strict';var myRequest=null,appPath,authParams,accessURL,i;appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();accessURL='access=uploadfile'+parameters;INTERMediator_DBAdapter.logging_comAction(1031,appPath,accessURL,authParams);try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!0,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');var params=(accessURL+authParams).split('&');var fd=new FormData();for(i=0;i<params.length;i++){var valueset=params[i].split('=');fd.append(valueset[0],decodeURIComponent(valueset[1]))}
fd.append('_im_uploadfile',uploadingFile.content);myRequest.onreadystatechange=function(){switch(myRequest.readyState){case 3:break;case 4:INTERMediator_DBAdapter.uploadFileAfterSucceed(myRequest,doItOnFinish,exceptionProc,!1);break}};myRequest.send(fd)}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1032],[e,myRequest.responseText]));exceptionProc()}},uploadFileAfterSucceed:function(myRequest,doItOnFinish,exceptionProc,isErrorDialog){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,challenge=null,clientid=null,requireAuth=!1,changePasswordResult=null,mediatoken=null,jsonObject,i,returnValue=!0;try{jsonObject=JSON.parse(myRequest.responseText)}catch(ex){INTERMediatorLog.setErrorMessage(ex,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1032],['','']));INTERMediatorLog.flushMessage();exceptionProc();return!1}
resultCount=jsonObject.resultCount?jsonObject.resultCount:0;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;for(i=0;i<jsonObject.errorMessages.length;i++){if(isErrorDialog){window.alert(jsonObject.errorMessages[i])}else{INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
returnValue=!1}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();exceptionProc()}
INTERMediatorOnPage.authCount=0;INTERMediatorOnPage.storeCredentialsToCookieOrStorage();doItOnFinish(dbresult);return returnValue},db_query:function(args){'use strict';var params,returnValue,result,contextDef;if(!INTERMediator_DBAdapter.db_queryChecking(args)){return}
params=INTERMediator_DBAdapter.db_queryParameters(args);returnValue={};try{result=this.server_access(params,1012,1004);returnValue.recordset=result.dbresult;returnValue.totalCount=result.resultCount;returnValue.count=0;returnValue.registeredId=result.registeredId;returnValue.nullAcceptable=result.nullAcceptable;returnValue.count=result.dbresult?Object.keys(result.dbresult).length:0;contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',args.name);if(!contextDef.relation&&args.paging&&Boolean(args.paging)===!0){INTERMediator.pagedAllCount=parseInt(result.resultCount,10);if(result.totalCount){INTERMediator.totalRecordCount=parseInt(result.totalCount,10)}}
if((args.paging!==null)&&(Boolean(args.paging)===!0)){INTERMediator.pagination=!0;if(!(Number(args.records)>=Number(INTERMediator.pagedSize)&&Number(INTERMediator.pagedSize)>0)){INTERMediator.pagedSize=parseInt(args.records,10)}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-17')}
returnValue.recordset=null;returnValue.totalCount=0;returnValue.count=0;returnValue.registeredid=null;returnValue.nullAcceptable=null}
return returnValue},db_queryWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_query(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_queryWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-16')}}
completion(returnValue)},db_query_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_queryChecking(args)){return}
params=INTERMediator_DBAdapter.db_queryParameters(args);try{this.server_access_async(params,1012,1004,(function(){var contextDef;var contextName=args.name;var recordsNumber=Number(args.records);var succesProcCapt=successProc;return function(result){result.count=result.dbresult?Object.keys(result.dbresult).length:0;contextDef=IMLibContextPool.getContextDef(contextName);if(!contextDef.relation&&args.paging&&Boolean(args.paging)===!0){INTERMediator.pagedAllCount=parseInt(result.resultCount,10);if(result.totalCount){INTERMediator.totalRecordCount=parseInt(result.totalCount,10)}}
if((args.paging!==null)&&(Boolean(args.paging)===!0)){INTERMediator.pagination=!0;if(!(recordsNumber>=Number(INTERMediator.pagedSize)&&Number(INTERMediator.pagedSize)>0)){INTERMediator.pagedSize=parseInt(recordsNumber,10)}}
succesProcCapt(result)}})(),failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_query_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-17')}},db_queryChecking:function(args){'use strict';var noError=!0;if(args.name===null||args.name===''){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1005));noError=!1}
return noError},db_queryParameters:function(args){'use strict';var i,index,params,counter,extCount,criteriaObject,sortkeyObject,extCountSort,recordLimit=10000000,conditions,conditionSign,modifyConditions,orderFields,key,keyParams,value,fields,operator,orderedKeys,removeIndice=[];if(args.records===null){params='access=read&name='+encodeURIComponent(args.name)}else{if(parseInt(args.records,10)===0&&(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI')){params='access=describe&name='+encodeURIComponent(args.name)}else{params='access=read&name='+encodeURIComponent(args.name)}
if(Boolean(args.uselimit)===!0&&parseInt(args.records,10)>=INTERMediator.pagedSize&&parseInt(INTERMediator.pagedSize,10)>0){recordLimit=INTERMediator.pagedSize}else{recordLimit=args.records}}
if(args.primaryKeyOnly){params+='&pkeyonly=true'}
if(args.fields){for(i=0;i<args.fields.length;i++){params+='&field_'+i+'='+encodeURIComponent(args.fields[i])}}
counter=0;if(args.parentkeyvalue){for(index in args.parentkeyvalue){if(args.parentkeyvalue.hasOwnProperty(index)){params+='&foreign'+counter+'field='+encodeURIComponent(index);params+='&foreign'+counter+'value='+encodeURIComponent(args.parentkeyvalue[index]);counter++}}}
if(args.useoffset&&INTERMediator.startFrom!==null){params+='&start='+encodeURIComponent(INTERMediator.startFrom)}
extCount=0;conditions=[];while(args.conditions&&args.conditions[extCount]){conditionSign=args.conditions[extCount].field+'#'+args.conditions[extCount].operator+'#'+args.conditions[extCount].value;if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount;params+='field='+encodeURIComponent(args.conditions[extCount].field);params+='&condition'+extCount;params+='operator='+encodeURIComponent(args.conditions[extCount].operator);params+='&condition'+extCount;params+='value='+encodeURIComponent(args.conditions[extCount].value);conditions.push(conditionSign)}
extCount++}
criteriaObject=INTERMediator.additionalCondition[args.name];if(criteriaObject){if(criteriaObject.field){criteriaObject=[criteriaObject]}
for(index=0;index<criteriaObject.length;index++){if(criteriaObject[index]&&criteriaObject[index].field){if(criteriaObject[index].value||criteriaObject[index].field==='__operation__'){conditionSign=criteriaObject[index].field+'#'+((criteriaObject[index].operator!==undefined)?criteriaObject[index].operator:'')+'#'+((criteriaObject[index].value!==undefined)?criteriaObject[index].value:'');if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount;params+='field='+encodeURIComponent(criteriaObject[index].field);if(criteriaObject[index].operator!==undefined){params+='&condition'+extCount;params+='operator='+encodeURIComponent(criteriaObject[index].operator)}
if(criteriaObject[index].value!==undefined){params+='&condition'+extCount;value=criteriaObject[index].value;if(Array.isArray(value)){value=JSON.stringify(value)}
params+='value='+encodeURIComponent(value)}
if(criteriaObject[index].field!=='__operation__'){conditions.push(conditionSign)}}
extCount++}}
if(criteriaObject[index]&&criteriaObject[index].onetime){removeIndice.push=index}}
if(removeIndice.length>0){modifyConditions=[];for(index=0;index<criteriaObject.length;index++){if(!(index in removeIndice)){modifyConditions.push(criteriaObject[index])}}
INTERMediator.additionalCondition[args.name]=modifyConditions;IMLibLocalContext.archive()}}
extCountSort=0;sortkeyObject=INTERMediator.additionalSortKey[args.name];if(sortkeyObject){if(sortkeyObject.field){sortkeyObject=[sortkeyObject]}
for(index=0;index<sortkeyObject.length;index++){params+='&sortkey'+extCountSort;params+='field='+encodeURIComponent(sortkeyObject[index].field);params+='&sortkey'+extCountSort;params+='direction='+encodeURIComponent(sortkeyObject[index].direction);extCountSort++}}
orderFields={};for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){value=String(IMLibLocalContext.store[key]);keyParams=key.split(':');if(keyParams&&keyParams.length>1&&keyParams[1].trim()===args.name&&value.length>0){if(keyParams[0].trim()==='condition'&&keyParams.length>=4){fields=keyParams[2].split(',');operator=keyParams[3].trim();if(fields.length>1){params+='&condition'+extCount+'field=__operation__';params+='&condition'+extCount+'operator=ex';extCount++}
for(index=0;index<fields.length;index++){conditionSign=fields[index].trim()+'#'+operator+'#'+value;if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount+'field='+encodeURIComponent(fields[index].replace(';;','::').trim());params+='&condition'+extCount+'operator='+encodeURIComponent(operator);params+='&condition'+extCount+'value='+encodeURIComponent(value);conditions.push(conditionSign)}
extCount++}}else if(keyParams[0].trim()==='valueofaddorder'&&keyParams.length>=4){orderFields[parseInt(value)]=[keyParams[2].trim(),keyParams[3].trim()]}}}}
params+='&records='+encodeURIComponent(recordLimit);orderedKeys=Object.keys(orderFields);for(i=0;i<orderedKeys.length;i++){params+='&sortkey'+extCountSort+'field='+encodeURIComponent(orderFields[orderedKeys[i]][0]);params+='&sortkey'+extCountSort+'direction='+encodeURIComponent(orderFields[orderedKeys[i]][1]);extCountSort++}
return params},db_update:function(args){'use strict';var params,result;if(!INTERMediator_DBAdapter.db_updateChecking(args)){return}
params=INTERMediator_DBAdapter.db_updateParameters(args);result=this.server_access(params,1013,1014);return result.dbresult},db_updateWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_update(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_updateWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-15')}}
completion(returnValue)},db_updateChecking:function(args){'use strict';var noError=!0,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1007));noError=!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));noError=!1}
if(args.dataset===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1011));noError=!1}
return noError},db_updateParameters:function(args){'use strict';var params,extCount,counter,index,addedObject;params='access=update&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnUpdate&&INTERMediator.additionalFieldValueOnUpdate[args.name]){addedObject=INTERMediator.additionalFieldValueOnUpdate[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
if(args.conditions){for(extCount=0;extCount<args.conditions.length;extCount++){params+='&condition'+extCount+'field=';params+=encodeURIComponent(args.conditions[extCount].field);params+='&condition'+extCount+'operator=';params+=encodeURIComponent(args.conditions[extCount].operator);if(args.conditions[extCount].value){params+='&condition'+extCount+'value=';params+=encodeURIComponent(args.conditions[extCount].value)}}}
for(extCount=0;extCount<args.dataset.length;extCount++){params+='&field_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].field);if(INTERMediator.isTrident&&INTERMediator.ieVersion===8){params+='&value_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].value.replace(/\n/g,''))}else{params+='&value_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].value)}}
return params},db_update_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_updateChecking(args)){return}
params=INTERMediator_DBAdapter.db_updateParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1013,1014,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_update_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_delete:function(args){'use strict';var params,result;if(!INTERMediator_DBAdapter.db_deleteChecking(args)){return}
params=INTERMediator_DBAdapter.db_deleteParameters(args);result=this.server_access(params,1017,1015);INTERMediatorLog.flushMessage();return result},db_deleteWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_delete(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_deleteWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-14')}}
completion(returnValue)},db_deleteChecking:function(args){'use strict';var noError=!0,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1019));noError=!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));noError=!1}
if(args.conditions===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1020));noError=!1}
return noError},db_deleteParameters:function(args){'use strict';var params,i,counter,index,addedObject;params='access=delete&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnDelete&&INTERMediator.additionalFieldValueOnDelete[args.name]){addedObject=INTERMediator.additionalFieldValueOnDelete[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
for(i=0;i<args.conditions.length;i++){params+='&condition'+i+'field='+encodeURIComponent(args.conditions[i].field);params+='&condition'+i+'operator='+encodeURIComponent(args.conditions[i].operator);params+='&condition'+i+'value='+encodeURIComponent(args.conditions[i].value)}
return params},db_delete_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_deleteChecking(args)){return}
params=INTERMediator_DBAdapter.db_deleteParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1017,1015,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_delete_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_createRecord:function(args){'use strict';var params,result;params=INTERMediator_DBAdapter.db_createParameters(args);if(params){result=INTERMediator_DBAdapter.server_access(params,1018,1016);INTERMediatorLog.flushMessage();return{newKeyValue:result.newRecordKeyValue,recordset:result.dbresult}}
return!1},db_createRecordWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_createRecord(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_createRecordWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-13')}}
if(completion){completion(returnValue.newKeyValue)}},db_createRecord_async:function(args,successProc,failedProc){'use strict';var params=INTERMediator_DBAdapter.db_createParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1018,1016,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_createRecord_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_createParameters:function(args){'use strict';var params,i,index,addedObject,counter,targetKey,ds,key,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1021));return!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));return!1}
ds=INTERMediatorOnPage.getDataSources();targetKey=null;for(key in ds){if(ds.hasOwnProperty(key)&&ds[key].name===args.name){targetKey=key;break}}
if(targetKey===null){INTERMediatorLog.setErrorMessage('no targetname :'+args.name);return!1}
params='access=create&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnNewRecord&&INTERMediator.additionalFieldValueOnNewRecord[args.name]){addedObject=INTERMediator.additionalFieldValueOnNewRecord[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
for(i=0;i<args.dataset.length;i++){params+='&field_'+counter+'='+encodeURIComponent(args.dataset[i].field);params+='&value_'+counter+'='+encodeURIComponent(args.dataset[i].value);counter++}
return params},db_copy:function(args){'use strict';var params,result;params=INTERMediator_DBAdapter.db_copyParameters(args);if(params){result=INTERMediator_DBAdapter.server_access(params,1017,1015);INTERMediatorLog.flushMessage();return{newKeyValue:result.newRecordKeyValue,recordset:result.dbresult}}
return!1},db_copyWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_copy(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_copyWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-14')}}
completion(returnValue)},db_copy_async:function(args,successProc,failedProc){'use strict';var params=INTERMediator_DBAdapter.db_copyParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1017,1015,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_copy_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_copyParameters:function(args){'use strict';var noError=!0,params,i;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1019));noError=!1}
if(args.conditions===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1020));noError=!1}
if(!noError){return!1}
params='access=copy&name='+encodeURIComponent(args.name);for(i=0;i<args.conditions.length;i++){params+='&condition'+i+'field='+encodeURIComponent(args.conditions[i].field);params+='&condition'+i+'operator='+encodeURIComponent(args.conditions[i].operator);params+='&condition'+i+'value='+encodeURIComponent(args.conditions[i].value)}
if(args.associated){for(i=0;i<args.associated.length;i++){params+='&assoc'+i+'='+encodeURIComponent(args.associated[i].name);params+='&asfield'+i+'='+encodeURIComponent(args.associated[i].field);params+='&asvalue'+i+'='+encodeURIComponent(args.associated[i].value)}}
return params},createExceptionFunc:function(errMessageNumber,AuthProc){'use strict';var errorNumCapt=errMessageNumber;return function(myRequest){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(AuthProc)}}else{INTERMediatorLog.setErrorMessage('Communication Error',INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorNumCapt],['Communication Error',myRequest.responseText]))}}},unregister:function(entityPkInfo){'use strict';var result=null,params;if(INTERMediatorOnPage.clientNotificationKey){var appKey=INTERMediatorOnPage.clientNotificationKey();if(appKey&&appKey!=='_im_key_isnt_supplied'){params='access=unregister';if(entityPkInfo){params+='&pks='+encodeURIComponent(JSON.stringify(entityPkInfo))}
result=this.server_access(params,1018,1016);return result}}}};var IMLibQueue={tasks:[],isExecute:!1,dataStore:{},dsLabel:0,readyTo:!1,getNewLabel:function(){'use strict';IMLibQueue.dsLabel++;return IMLibQueue.dsLabel},getDataStore:function(label,key){'use strict';if(!IMLibQueue.dataStore[label]){IMLibQueue.dataStore[label]={}}
return IMLibQueue.dataStore[label][key]},setDataStore:function(label,key,value){'use strict';if(!IMLibQueue.dataStore[label]){IMLibQueue.dataStore[label]={}}
IMLibQueue.dataStore[label][key]=value},setTask:function(aTask,startHere){'use strict';if(startHere){IMLibQueue.isExecute=!0;aTask(function(){});IMLibQueue.isExecute=!1}else{IMLibQueue.tasks.push(aTask);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}}},setPriorTask:function(aTask){'use strict';IMLibQueue.tasks.unshift(aTask);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},setSequentialTasks:function(tasksArray){'use strict';Array.prototype.push.apply(IMLibQueue.tasks,tasksArray);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},setSequentialPriorTasks:function(tasksArray){'use strict';Array.prototype.push.apply(tasksArray,IMLibQueue.tasks);IMLibQueue.tasks=tasksArray;if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},startNextTask:function(){'use strict';if(IMLibQueue.isExecute){if(IMLibQueue.tasks.length>0){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}
return}
if(IMLibQueue.tasks.length>0){var aTask=IMLibQueue.tasks.shift();IMLibQueue.isExecute=!0;IMLibQueue.readyTo=!1;aTask(function(){IMLibQueue.isExecute=!1;if(IMLibQueue.tasks.length>0){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}})}}};var IMLibChangeEventDispatch;var IMLibKeyDownEventDispatch;var IMLibKeyUpEventDispatch;var IMLibInputEventDispatch;var IMLibMouseEventDispatch;var IMLibBlurEventDispatch;function IMLibEventDispatch(){'use strict';this.dispatchTable={};this.dispatchTableTarget={}}
IMLibEventDispatch.prototype.clearAll=function(){'use strict';this.dispatchTable={};this.dispatchTableTarget={}};IMLibEventDispatch.prototype.setExecute=function(idValue,exec){'use strict';if(idValue&&exec){this.dispatchTable[idValue]=exec}};IMLibEventDispatch.prototype.setTargetExecute=function(targetValue,exec){'use strict';if(targetValue&&exec){this.dispatchTableTarget[targetValue]=exec}};IMLibEventDispatch.prototype.setExecuteByCode=function(idValue,keyCode,exec){'use strict';if(idValue&&keyCode){if(!this.dispatchTable[idValue]){this.dispatchTable[idValue]={}}
this.dispatchTable[idValue][keyCode]=exec}};var IMLibEventResponder={touchEventCancel:!1,isSetup:!1,setup:function(){'use strict';var body;if(IMLibEventResponder.isSetup){return}
IMLibEventResponder.isSetup=!0;IMLibChangeEventDispatch=new IMLibEventDispatch();IMLibKeyDownEventDispatch=new IMLibEventDispatch();IMLibKeyUpEventDispatch=new IMLibEventDispatch();IMLibMouseEventDispatch=new IMLibEventDispatch();IMLibBlurEventDispatch=new IMLibEventDispatch();IMLibInputEventDispatch=new IMLibEventDispatch();body=document.getElementsByTagName('BODY')[0];INTERMediatorLib.addEvent(body,'change',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibChangeEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'blur',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibBlurEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'input',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibInputEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'keydown',function(e){var event,target,idValue,keyCode;event=e?e:window.event;if(!event){return}
keyCode=(window.event)?e.which:e.keyCode;target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
if(!IMLibKeyDownEventDispatch.dispatchTable[idValue]){return}
var executable=IMLibKeyDownEventDispatch.dispatchTable[idValue][keyCode];if(!executable){return}
executable(event)});INTERMediatorLib.addEvent(body,'keyup',function(e){var event,charCode,target,idValue;event=e?e:window.event;if(event.charCode){charCode=event.charCode}else{charCode=event.keyCode}
if(!event){return}
target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
if(!IMLibKeyUpEventDispatch.dispatchTable[idValue]){return}
var executable=IMLibKeyUpEventDispatch.dispatchTable[idValue][charCode];if(!executable){return}
executable(event)});INTERMediatorLib.addEvent(body,'click',function(e){var event,target,idValue,executable,targetDefs,i,nodeInfo,value;event=e?e:window.event;if(!event){return}
target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
executable=IMLibMouseEventDispatch.dispatchTable[idValue];if(executable){executable(event);return}
targetDefs=INTERMediatorLib.getLinkedElementInfo(target);for(i=0;i<targetDefs.length;i++){executable=IMLibMouseEventDispatch.dispatchTableTarget[targetDefs[i]];if(executable){nodeInfo=INTERMediatorLib.getNodeInfoArray(targetDefs[i]);if(nodeInfo.target){value=target.getAttribute(nodeInfo.target)}else{value=IMLibElement.getValueFromIMNode(target)}
executable(value,target);return}}})}};INTERMediator.propertyIETridentSetup();INTERMediator.propertyW3CUserAgentSetup();if(INTERMediator.isIE&&INTERMediator.ieVersion<9){INTERMediator.startFrom=0;INTERMediator.pagedSize=0;INTERMediator.pagination=!1;INTERMediator.additionalCondition={};INTERMediator.additionalSortKey={};INTERMediator.recordLimit={};IMLibCalc.regexpForSeparator=INTERMediator.separator}else{Object.defineProperty(INTERMediator,'startFrom',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_startFrom',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_startFrom',value)}});Object.defineProperty(INTERMediator,'pagedSize',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_pagedSize',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_pagedSize',value)}});Object.defineProperty(INTERMediator,'pagination',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_pagination',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_pagination',value)}});Object.defineProperty(INTERMediator,'additionalCondition',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_additionalCondition',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_additionalCondition',value)}});Object.defineProperty(INTERMediator,'additionalSortKey',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_additionalSortKey',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_additionalSortKey',value)}});Object.defineProperty(INTERMediator,'recordLimit',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_recordLimit',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_recordLimit',value)}});Object.defineProperty(IMLibCalc,'regexpForSeparator',{get:function(){'use strict';if(INTERMediator){return new RegExp(INTERMediator.separator)}
return new RegExp('@')}})}
if(!INTERMediator.additionalCondition){INTERMediator.additionalCondition={}}
if(!INTERMediator.additionalSortKey){INTERMediator.additionalSortKey={}}
INTERMediatorLib.addEvent(window,'beforeunload',function(){if(IMLibQueue.tasks.length>0){var confirmationMessage='Some tasks are unfinished.';var ev=(e||window.event);ev.returnValue=confirmationMessage;return confirmationMessage}else{return undefined}});INTERMediatorLib.addEvent(window,'unload',function(){'use strict';INTERMediator_DBAdapter.unregister()});INTERMediatorLib.addEvent(window,'load',function(){'use strict';var key,errorNode;if(INTERMediatorOnPage.initLocalContext){for(key in INTERMediatorOnPage.initLocalContext){if(INTERMediatorOnPage.initLocalContext.hasOwnProperty(key)){IMLibLocalContext.setValue(key,INTERMediatorOnPage.initLocalContext[key],!0)}}}
errorNode=document.getElementById(INTERMediatorOnPage.nonSupportMessageId);if(INTERMediatorOnPage.isAutoConstruct){if(errorNode){if(INTERMediatorOnPage.INTERMediatorCheckBrowser(errorNode)){INTERMediator.construct(!0)}}else{INTERMediator.construct(!0)}}});

function SHA1(s){function U(a,b,c){while(0<c--)a.push(b)}function L(a,b){return(a<<b)|(a>>>(32-b))}function P(a,b,c){return a^b^c}function A(a,b){var c=(b&0xFFFF)+(a&0xFFFF),d=(b>>>16)+(a>>>16)+(c>>>16);return((d&0xFFFF)<<16)|(c&0xFFFF)}var B="0123456789abcdef";return(function(a){var c=[],d=a.length*4,e;for(var i=0;i<d;i++){e=a[i>>2]>>((3-(i%4))*8);c.push(B.charAt((e>>4)&0xF)+B.charAt(e&0xF))}return c.join('')}((function(a,b){var c,d,e,f,g,h=a.length,v=0x67452301,w=0xefcdab89,x=0x98badcfe,y=0x10325476,z=0xc3d2e1f0,M=[];U(M,0x5a827999,20);U(M,0x6ed9eba1,20);U(M,0x8f1bbcdc,20);U(M,0xca62c1d6,20);a[b>>5]|=0x80<<(24-(b%32));a[(((b+65)>>9)<<4)+15]=b;for(var i=0;i<h;i+=16){c=v;d=w;e=x;f=y;g=z;for(var j=0,O=[];j<80;j++){O[j]=j<16?a[j+i]:L(O[j-3]^O[j-8]^O[j-14]^O[j-16],1);var k=(function(a,b,c,d,e){var f=(e&0xFFFF)+(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF),g=(e>>>16)+(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(f>>>16);return((g&0xFFFF)<<16)|(f&0xFFFF)})(j<20?(function(t,a,b){return(t&a)^(~t&b)}(d,e,f)):j<40?P(d,e,f):j<60?(function(t,a,b){return(t&a)^(t&b)^(a&b)}(d,e,f)):P(d,e,f),g,M[j],O[j],L(c,5));g=f;f=e;e=L(d,30);d=c;c=k}v=A(v,c);w=A(w,d);x=A(x,e);y=A(y,f);z=A(z,g)}return[v,w,x,y,z]}((function(t){var a=[],b=255,c=t.length*8;for(var i=0;i<c;i+=8){a[i>>5]|=(t.charCodeAt(i/8)&b)<<(24-(i%32))}return a}(s)).slice(),s.length*8))))};
(function(){var charSize=8,b64pad="",hexCase=0,str2binb=function(a){var b=[],mask=(1<<charSize)-1,length=a.length*charSize,i;for(i=0;i<length;i+=charSize){b[i>>5]|=(a.charCodeAt(i/charSize)&mask)<<(32-charSize-(i%32))}return b},hex2binb=function(a){var b=[],length=a.length,i,num;for(i=0;i<length;i+=2){num=parseInt(a.substr(i,2),16);if(!isNaN(num)){b[i>>3]|=num<<(24-(4*(i%8)))}else{return"INVALID HEX STRING"}}return b},binb2hex=function(a){var b=(hexCase)?"0123456789ABCDEF":"0123456789abcdef",str="",length=a.length*4,i,srcByte;for(i=0;i<length;i+=1){srcByte=a[i>>2]>>((3-(i%4))*8);str+=b.charAt((srcByte>>4)&0xF)+b.charAt(srcByte&0xF)}return str},binb2b64=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+"0123456789+/",str="",length=a.length*4,i,j,triplet;for(i=0;i<length;i+=3){triplet=(((a[i>>2]>>8*(3-i%4))&0xFF)<<16)|(((a[i+1>>2]>>8*(3-(i+1)%4))&0xFF)<<8)|((a[i+2>>2]>>8*(3-(i+2)%4))&0xFF);for(j=0;j<4;j+=1){if(i*8+j*6<=a.length*32){str+=b.charAt((triplet>>6*(3-j))&0x3F)}else{str+=b64pad}}}return str},rotr=function(x,n){return(x>>>n)|(x<<(32-n))},shr=function(x,n){return x>>>n},ch=function(x,y,z){return(x&y)^(~x&z)},maj=function(x,y,z){return(x&y)^(x&z)^(y&z)},sigma0=function(x){return rotr(x,2)^rotr(x,13)^rotr(x,22)},sigma1=function(x){return rotr(x,6)^rotr(x,11)^rotr(x,25)},gamma0=function(x){return rotr(x,7)^rotr(x,18)^shr(x,3)},gamma1=function(x){return rotr(x,17)^rotr(x,19)^shr(x,10)},safeAdd_2=function(x,y){var a=(x&0xFFFF)+(y&0xFFFF),msw=(x>>>16)+(y>>>16)+(a>>>16);return((msw&0xFFFF)<<16)|(a&0xFFFF)},safeAdd_4=function(a,b,c,d){var e=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF),msw=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16);return((msw&0xFFFF)<<16)|(e&0xFFFF)},safeAdd_5=function(a,b,c,d,e){var f=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF),msw=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16)+(f>>>16);return((msw&0xFFFF)<<16)|(f&0xFFFF)},coreSHA2=function(j,k,l){var a,b,c,d,e,f,g,h,T1,T2,H,lengthPosition,i,t,K,W=[],appendedMessageLength;if(l==="SHA-224"||l==="SHA-256"){lengthPosition=(((k+65)>>9)<<4)+15;K=[0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B,0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01,0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7,0xC19BF174,0xE49B69C1,0xEFBE4786,0x0FC19DC6,0x240CA1CC,0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152,0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147,0x06CA6351,0x14292967,0x27B70A85,0x2E1B2138,0x4D2C6DFC,0x53380D13,0x650A7354,0x766A0ABB,0x81C2C92E,0x92722C85,0xA2BFE8A1,0xA81A664B,0xC24B8B70,0xC76C51A3,0xD192E819,0xD6990624,0xF40E3585,0x106AA070,0x19A4C116,0x1E376C08,0x2748774C,0x34B0BCB5,0x391C0CB3,0x4ED8AA4A,0x5B9CCA4F,0x682E6FF3,0x748F82EE,0x78A5636F,0x84C87814,0x8CC70208,0x90BEFFFA,0xA4506CEB,0xBEF9A3F7,0xC67178F2];if(l==="SHA-224"){H=[0xc1059ed8,0x367cd507,0x3070dd17,0xf70e5939,0xffc00b31,0x68581511,0x64f98fa7,0xbefa4fa4]}else{H=[0x6A09E667,0xBB67AE85,0x3C6EF372,0xA54FF53A,0x510E527F,0x9B05688C,0x1F83D9AB,0x5BE0CD19]}}j[k>>5]|=0x80<<(24-k%32);j[lengthPosition]=k;appendedMessageLength=j.length;for(i=0;i<appendedMessageLength;i+=16){a=H[0];b=H[1];c=H[2];d=H[3];e=H[4];f=H[5];g=H[6];h=H[7];for(t=0;t<64;t+=1){if(t<16){W[t]=j[t+i]}else{W[t]=safeAdd_4(gamma1(W[t-2]),W[t-7],gamma0(W[t-15]),W[t-16])}T1=safeAdd_5(h,sigma1(e),ch(e,f,g),K[t],W[t]);T2=safeAdd_2(sigma0(a),maj(a,b,c));h=g;g=f;f=e;e=safeAdd_2(d,T1);d=c;c=b;b=a;a=safeAdd_2(T1,T2)}H[0]=safeAdd_2(a,H[0]);H[1]=safeAdd_2(b,H[1]);H[2]=safeAdd_2(c,H[2]);H[3]=safeAdd_2(d,H[3]);H[4]=safeAdd_2(e,H[4]);H[5]=safeAdd_2(f,H[5]);H[6]=safeAdd_2(g,H[6]);H[7]=safeAdd_2(h,H[7])}switch(l){case"SHA-224":return[H[0],H[1],H[2],H[3],H[4],H[5],H[6]];case"SHA-256":return H;default:return[]}},jsSHA=function(a,b){this.sha224=null;this.sha256=null;this.strBinLen=null;this.strToHash=null;if("HEX"===b){if(0!==(a.length%2)){return"TEXT MUST BE IN BYTE INCREMENTS"}this.strBinLen=a.length*4;this.strToHash=hex2binb(a)}else if(("ASCII"===b)||('undefined'===typeof(b))){this.strBinLen=a.length*charSize;this.strToHash=str2binb(a)}else{return"UNKNOWN TEXT INPUT TYPE"}};jsSHA.prototype={getHash:function(a,b){var c=null,message=this.strToHash.slice();switch(b){case"HEX":c=binb2hex;break;case"B64":c=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}switch(a){case"SHA-224":if(null===this.sha224){this.sha224=coreSHA2(message,this.strBinLen,a)}return c(this.sha224);case"SHA-256":if(null===this.sha256){this.sha256=coreSHA2(message,this.strBinLen,a)}return c(this.sha256);default:return"HASH NOT RECOGNIZED"}},getHMAC:function(a,b,c,d){var e,keyToUse,i,retVal,keyBinLen,hashBitSize,keyWithIPad=[],keyWithOPad=[];switch(d){case"HEX":e=binb2hex;break;case"B64":e=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}switch(c){case"SHA-224":hashBitSize=224;break;case"SHA-256":hashBitSize=256;break;default:return"HASH NOT RECOGNIZED"}if("HEX"===b){if(0!==(a.length%2)){return"KEY MUST BE IN BYTE INCREMENTS"}keyToUse=hex2binb(a);keyBinLen=a.length*4}else if("ASCII"===b){keyToUse=str2binb(a);keyBinLen=a.length*charSize}else{return"UNKNOWN KEY INPUT TYPE"}if(64<(keyBinLen/8)){keyToUse=coreSHA2(keyToUse,keyBinLen,c);keyToUse[15]&=0xFFFFFF00}else if(64>(keyBinLen/8)){keyToUse[15]&=0xFFFFFF00}for(i=0;i<=15;i+=1){keyWithIPad[i]=keyToUse[i]^0x36363636;keyWithOPad[i]=keyToUse[i]^0x5C5C5C5C}retVal=coreSHA2(keyWithIPad.concat(this.strToHash),512+this.strBinLen,c);retVal=coreSHA2(keyWithOPad.concat(retVal),512+hashBitSize,c);return(e(retVal))}};window.jsSHA=jsSHA}());


/*! JSEncrypt v2.3.0 | https://npmcdn.com/jsencrypt@2.3.0/LICENSE.txt */
var JSEncryptExports={};!function(t){function e(t,e,i){null!=t&&("number"==typeof t?this.fromNumber(t,e,i):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function i(){return new e(null)}function r(t,e,i,r,s,n){for(;--n>=0;){var o=e*this[t++]+i[r]+s;s=Math.floor(o/67108864),i[r++]=67108863&o}return s}function s(t,e,i,r,s,n){for(var o=32767&e,h=e>>15;--n>=0;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;a=o*a+((32767&c)<<15)+i[r]+(1073741823&s),s=(a>>>30)+(c>>>15)+h*u+(s>>>30),i[r++]=1073741823&a}return s}function n(t,e,i,r,s,n){for(var o=16383&e,h=e>>14;--n>=0;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;a=o*a+((16383&c)<<14)+i[r]+s,s=(a>>28)+(c>>14)+h*u,i[r++]=268435455&a}return s}function o(t){return Be.charAt(t)}function h(t,e){var i=Ke[t.charCodeAt(e)];return null==i?-1:i}function a(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function u(t){this.t=1,this.s=0>t?-1:0,t>0?this[0]=t:-1>t?this[0]=t+this.DV:this.t=0}function c(t){var e=i();return e.fromInt(t),e}function f(t,i){var r;if(16==i)r=4;else if(8==i)r=3;else if(256==i)r=8;else if(2==i)r=1;else if(32==i)r=5;else{if(4!=i)return void this.fromRadix(t,i);r=2}this.t=0,this.s=0;for(var s=t.length,n=!1,o=0;--s>=0;){var a=8==r?255&t[s]:h(t,s);0>a?"-"==t.charAt(s)&&(n=!0):(n=!1,0==o?this[this.t++]=a:o+r>this.DB?(this[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this[this.t++]=a>>this.DB-o):this[this.t-1]|=a<<o,o+=r,o>=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),n&&e.ZERO.subTo(this,this)}function p(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function l(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<<e)-1,s=!1,n="",h=this.t,a=this.DB-h*this.DB%e;if(h-- >0)for(a<this.DB&&(i=this[h]>>a)>0&&(s=!0,n=o(i));h>=0;)e>a?(i=(this[h]&(1<<a)-1)<<e-a,i|=this[--h]>>(a+=this.DB-e)):(i=this[h]>>(a-=e)&r,0>=a&&(a+=this.DB,--h)),i>0&&(s=!0),s&&(n+=o(i));return s?n:"0"}function d(){var t=i();return e.ZERO.subTo(this,t),t}function g(){return this.s<0?this.negate():this}function m(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(e=i-t.t,0!=e)return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0}function y(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function b(){return this.t<=0?0:this.DB*(this.t-1)+y(this[this.t-1]^this.s&this.DM)}function T(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s}function S(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s}function R(t,e){var i,r=t%this.DB,s=this.DB-r,n=(1<<s)-1,o=Math.floor(t/this.DB),h=this.s<<r&this.DM;for(i=this.t-1;i>=0;--i)e[i+o+1]=this[i]>>s|h,h=(this[i]&n)<<r;for(i=o-1;i>=0;--i)e[i]=0;e[o]=h,e.t=this.t+o+1,e.s=this.s,e.clamp()}function E(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)return void(e.t=0);var r=t%this.DB,s=this.DB-r,n=(1<<r)-1;e[0]=this[i]>>r;for(var o=i+1;o<this.t;++o)e[o-i-1]|=(this[o]&n)<<s,e[o-i]=this[o]>>r;r>0&&(e[this.t-i-1]|=(this.s&n)<<s),e.t=this.t-i,e.clamp()}function D(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);s>i;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r-=t[i],e[i++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=0>r?-1:0,-1>r?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()}function w(t,i){var r=this.abs(),s=t.abs(),n=r.t;for(i.t=n+s.t;--n>=0;)i[n]=0;for(n=0;n<s.t;++n)i[n+r.t]=r.am(0,s[n],i,n,0,r.t);i.s=0,i.clamp(),this.s!=t.s&&e.ZERO.subTo(i,i)}function x(t){for(var e=this.abs(),i=t.t=2*e.t;--i>=0;)t[i]=0;for(i=0;i<e.t-1;++i){var r=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,r,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()}function B(t,r,s){var n=t.abs();if(!(n.t<=0)){var o=this.abs();if(o.t<n.t)return null!=r&&r.fromInt(0),void(null!=s&&this.copyTo(s));null==s&&(s=i());var h=i(),a=this.s,u=t.s,c=this.DB-y(n[n.t-1]);c>0?(n.lShiftTo(c,h),o.lShiftTo(c,s)):(n.copyTo(h),o.copyTo(s));var f=h.t,p=h[f-1];if(0!=p){var l=p*(1<<this.F1)+(f>1?h[f-2]>>this.F2:0),d=this.FV/l,g=(1<<this.F1)/l,m=1<<this.F2,v=s.t,b=v-f,T=null==r?i():r;for(h.dlShiftTo(b,T),s.compareTo(T)>=0&&(s[s.t++]=1,s.subTo(T,s)),e.ONE.dlShiftTo(f,T),T.subTo(h,h);h.t<f;)h[h.t++]=0;for(;--b>=0;){var S=s[--v]==p?this.DM:Math.floor(s[v]*d+(s[v-1]+m)*g);if((s[v]+=h.am(0,S,s,b,0,f))<S)for(h.dlShiftTo(b,T),s.subTo(T,s);s[v]<--S;)s.subTo(T,s)}null!=r&&(s.drShiftTo(f,r),a!=u&&e.ZERO.subTo(r,r)),s.t=f,s.clamp(),c>0&&s.rShiftTo(c,s),0>a&&e.ZERO.subTo(s,s)}}}function K(t){var r=i();return this.abs().divRemTo(t,null,r),this.s<0&&r.compareTo(e.ZERO)>0&&t.subTo(r,r),r}function A(t){this.m=t}function U(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function O(t){return t}function V(t){t.divRemTo(this.m,null,t)}function J(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function N(t,e){t.squareTo(e),this.reduce(e)}function I(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return e=e*(2-(15&t)*e)&15,e=e*(2-(255&t)*e)&255,e=e*(2-((65535&t)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function P(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function M(t){var r=i();return t.abs().dlShiftTo(this.m.t,r),r.divRemTo(this.m,null,r),t.s<0&&r.compareTo(e.ZERO)>0&&this.m.subTo(r,r),r}function L(t){var e=i();return t.copyTo(e),this.reduce(e),e}function q(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=32767&t[e],r=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(i=e+this.m.t,t[i]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function C(t,e){t.squareTo(e),this.reduce(e)}function H(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function j(){return 0==(this.t>0?1&this[0]:this.s)}function k(t,r){if(t>4294967295||1>t)return e.ONE;var s=i(),n=i(),o=r.convert(this),h=y(t)-1;for(o.copyTo(s);--h>=0;)if(r.sqrTo(s,n),(t&1<<h)>0)r.mulTo(n,o,s);else{var a=s;s=n,n=a}return r.revert(s)}function F(t,e){var i;return i=256>t||e.isEven()?new A(e):new P(e),this.exp(t,i)}
// Copyright (c) 2005-2009 Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.
function _(){var t=i();return this.copyTo(t),t}function z(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function Z(){return 0==this.t?this.s:this[0]<<24>>24}function G(){return 0==this.t?this.s:this[0]<<16>>16}function $(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function Y(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function W(t){if(null==t&&(t=10),0==this.signum()||2>t||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),s=c(r),n=i(),o=i(),h="";for(this.divRemTo(s,n,o);n.signum()>0;)h=(r+o.intValue()).toString(t).substr(1)+h,n.divRemTo(s,n,o);return o.intValue().toString(t)+h}function Q(t,i){this.fromInt(0),null==i&&(i=10);for(var r=this.chunkSize(i),s=Math.pow(i,r),n=!1,o=0,a=0,u=0;u<t.length;++u){var c=h(t,u);0>c?"-"==t.charAt(u)&&0==this.signum()&&(n=!0):(a=i*a+c,++o>=r&&(this.dMultiply(s),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(i,o)),this.dAddOffset(a,0)),n&&e.ZERO.subTo(this,this)}function X(t,i,r){if("number"==typeof i)if(2>t)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),ht,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(i);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(e.ONE.shiftLeft(t-1),this);else{var s=new Array,n=7&t;s.length=(t>>3)+1,i.nextBytes(s),n>0?s[0]&=(1<<n)-1:s[0]=0,this.fromString(s,256)}}function tt(){var t=this.t,e=new Array;e[0]=this.s;var i,r=this.DB-t*this.DB%8,s=0;if(t-- >0)for(r<this.DB&&(i=this[t]>>r)!=(this.s&this.DM)>>r&&(e[s++]=i|this.s<<this.DB-r);t>=0;)8>r?(i=(this[t]&(1<<r)-1)<<8-r,i|=this[--t]>>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,0>=r&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==s&&(128&this.s)!=(128&i)&&++s,(s>0||i!=this.s)&&(e[s++]=i);return e}function et(t){return 0==this.compareTo(t)}function it(t){return this.compareTo(t)<0?this:t}function rt(t){return this.compareTo(t)>0?this:t}function st(t,e,i){var r,s,n=Math.min(t.t,this.t);for(r=0;n>r;++r)i[r]=e(this[r],t[r]);if(t.t<this.t){for(s=t.s&this.DM,r=n;r<this.t;++r)i[r]=e(this[r],s);i.t=this.t}else{for(s=this.s&this.DM,r=n;r<t.t;++r)i[r]=e(s,t[r]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()}function nt(t,e){return t&e}function ot(t){var e=i();return this.bitwiseTo(t,nt,e),e}function ht(t,e){return t|e}function at(t){var e=i();return this.bitwiseTo(t,ht,e),e}function ut(t,e){return t^e}function ct(t){var e=i();return this.bitwiseTo(t,ut,e),e}function ft(t,e){return t&~e}function pt(t){var e=i();return this.bitwiseTo(t,ft,e),e}function lt(){for(var t=i(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}function dt(t){var e=i();return 0>t?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function gt(t){var e=i();return 0>t?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function mt(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function yt(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+mt(this[t]);return this.s<0?this.t*this.DB:-1}function vt(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function bt(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=vt(this[i]^e);return t}function Tt(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)}function St(t,i){var r=e.ONE.shiftLeft(t);return this.bitwiseTo(r,i,r),r}function Rt(t){return this.changeBit(t,ht)}function Et(t){return this.changeBit(t,ft)}function Dt(t){return this.changeBit(t,ut)}function wt(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);s>i;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r+=t[i],e[i++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=0>r?-1:0,r>0?e[i++]=r:-1>r&&(e[i++]=this.DV+r),e.t=i,e.clamp()}function xt(t){var e=i();return this.addTo(t,e),e}function Bt(t){var e=i();return this.subTo(t,e),e}function Kt(t){var e=i();return this.multiplyTo(t,e),e}function At(){var t=i();return this.squareTo(t),t}function Ut(t){var e=i();return this.divRemTo(t,e,null),e}function Ot(t){var e=i();return this.divRemTo(t,null,e),e}function Vt(t){var e=i(),r=i();return this.divRemTo(t,e,r),new Array(e,r)}function Jt(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function Nt(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function It(){}function Pt(t){return t}function Mt(t,e,i){t.multiplyTo(e,i)}function Lt(t,e){t.squareTo(e)}function qt(t){return this.exp(t,new It)}function Ct(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;var s;for(s=i.t-this.t;s>r;++r)i[r+this.t]=this.am(0,t[r],i,r,0,this.t);for(s=Math.min(t.t,e);s>r;++r)this.am(0,t[r],i,r,0,e-r);i.clamp()}function Ht(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;--r>=0;)i[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)i[this.t+r-e]=this.am(e-r,t[r],i,0,0,this.t+r-e);i.clamp(),i.drShiftTo(1,i)}function jt(t){this.r2=i(),this.q3=i(),e.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function kt(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=i();return t.copyTo(e),this.reduce(e),e}function Ft(t){return t}function _t(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function zt(t,e){t.squareTo(e),this.reduce(e)}function Zt(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function Gt(t,e){var r,s,n=t.bitLength(),o=c(1);if(0>=n)return o;r=18>n?1:48>n?3:144>n?4:768>n?5:6,s=8>n?new A(e):e.isEven()?new jt(e):new P(e);var h=new Array,a=3,u=r-1,f=(1<<r)-1;if(h[1]=s.convert(this),r>1){var p=i();for(s.sqrTo(h[1],p);f>=a;)h[a]=i(),s.mulTo(p,h[a-2],h[a]),a+=2}var l,d,g=t.t-1,m=!0,v=i();for(n=y(t[g])-1;g>=0;){for(n>=u?l=t[g]>>n-u&f:(l=(t[g]&(1<<n+1)-1)<<u-n,g>0&&(l|=t[g-1]>>this.DB+n-u)),a=r;0==(1&l);)l>>=1,--a;if((n-=a)<0&&(n+=this.DB,--g),m)h[l].copyTo(o),m=!1;else{for(;a>1;)s.sqrTo(o,v),s.sqrTo(v,o),a-=2;a>0?s.sqrTo(o,v):(d=o,o=v,v=d),s.mulTo(v,h[l],o)}for(;g>=0&&0==(t[g]&1<<n);)s.sqrTo(o,v),d=o,o=v,v=d,--n<0&&(n=this.DB-1,--g)}return s.revert(o)}function $t(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var r=e;e=i,i=r}var s=e.getLowestSetBit(),n=i.getLowestSetBit();if(0>n)return e;for(n>s&&(n=s),n>0&&(e.rShiftTo(n,e),i.rShiftTo(n,i));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return n>0&&i.lShiftTo(n,i),i}function Yt(t){if(0>=t)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i}function Wt(t){var i=t.isEven();if(this.isEven()&&i||0==t.signum())return e.ZERO;for(var r=t.clone(),s=this.clone(),n=c(1),o=c(0),h=c(0),a=c(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),i?(n.isEven()&&o.isEven()||(n.addTo(this,n),o.subTo(t,o)),n.rShiftTo(1,n)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;s.isEven();)s.rShiftTo(1,s),i?(h.isEven()&&a.isEven()||(h.addTo(this,h),a.subTo(t,a)),h.rShiftTo(1,h)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(s)>=0?(r.subTo(s,r),i&&n.subTo(h,n),o.subTo(a,o)):(s.subTo(r,s),i&&h.subTo(n,h),a.subTo(o,a))}return 0!=s.compareTo(e.ONE)?e.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}function Qt(t){var e,i=this.abs();if(1==i.t&&i[0]<=Ae[Ae.length-1]){for(e=0;e<Ae.length;++e)if(i[0]==Ae[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<Ae.length;){for(var r=Ae[e],s=e+1;s<Ae.length&&Ue>r;)r*=Ae[s++];for(r=i.modInt(r);s>e;)if(r%Ae[e++]==0)return!1}return i.millerRabin(t)}function Xt(t){var r=this.subtract(e.ONE),s=r.getLowestSetBit();if(0>=s)return!1;var n=r.shiftRight(s);t=t+1>>1,t>Ae.length&&(t=Ae.length);for(var o=i(),h=0;t>h;++h){o.fromInt(Ae[Math.floor(Math.random()*Ae.length)]);var a=o.modPow(n,this);if(0!=a.compareTo(e.ONE)&&0!=a.compareTo(r)){for(var u=1;u++<s&&0!=a.compareTo(r);)if(a=a.modPowInt(2,this),0==a.compareTo(e.ONE))return!1;if(0!=a.compareTo(r))return!1}}return!0}function te(){this.i=0,this.j=0,this.S=new Array}function ee(t){var e,i,r;for(e=0;256>e;++e)this.S[e]=e;for(i=0,e=0;256>e;++e)i=i+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[i],this.S[i]=r;this.i=0,this.j=0}function ie(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}function re(){return new te}function se(){if(null==Oe){for(Oe=re();Ne>Je;){var t=Math.floor(65536*Math.random());Ve[Je++]=255&t}for(Oe.init(Ve),Je=0;Je<Ve.length;++Je)Ve[Je]=0;Je=0}return Oe.next()}function ne(t){var e;for(e=0;e<t.length;++e)t[e]=se()}function oe(){}function he(t,i){return new e(t,i)}function ae(t,i){if(i<t.length+11)return console.error("Message too long for RSA"),null;for(var r=new Array,s=t.length-1;s>=0&&i>0;){var n=t.charCodeAt(s--);128>n?r[--i]=n:n>127&&2048>n?(r[--i]=63&n|128,r[--i]=n>>6|192):(r[--i]=63&n|128,r[--i]=n>>6&63|128,r[--i]=n>>12|224)}r[--i]=0;for(var o=new oe,h=new Array;i>2;){for(h[0]=0;0==h[0];)o.nextBytes(h);r[--i]=h[0]}return r[--i]=2,r[--i]=0,new e(r)}function ue(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function ce(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}function fe(t){return t.modPowInt(this.e,this.n)}function pe(t){var e=ae(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var r=i.toString(16);return 0==(1&r.length)?r:"0"+r}function le(t,e){for(var i=t.toByteArray(),r=0;r<i.length&&0==i[r];)++r;if(i.length-r!=e-1||2!=i[r])return null;for(++r;0!=i[r];)if(++r>=i.length)return null;for(var s="";++r<i.length;){var n=255&i[r];128>n?s+=String.fromCharCode(n):n>191&&224>n?(s+=String.fromCharCode((31&n)<<6|63&i[r+1]),++r):(s+=String.fromCharCode((15&n)<<12|(63&i[r+1])<<6|63&i[r+2]),r+=2)}return s}function de(t,e,i){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16),this.d=he(i,16)):console.error("Invalid RSA private key")}function ge(t,e,i,r,s,n,o,h){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16),this.d=he(i,16),this.p=he(r,16),this.q=he(s,16),this.dmp1=he(n,16),this.dmq1=he(o,16),this.coeff=he(h,16)):console.error("Invalid RSA private key")}function me(t,i){var r=new oe,s=t>>1;this.e=parseInt(i,16);for(var n=new e(i,16);;){for(;this.p=new e(t-s,1,r),0!=this.p.subtract(e.ONE).gcd(n).compareTo(e.ONE)||!this.p.isProbablePrime(10););for(;this.q=new e(s,1,r),0!=this.q.subtract(e.ONE).gcd(n).compareTo(e.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var h=this.p.subtract(e.ONE),a=this.q.subtract(e.ONE),u=h.multiply(a);if(0==u.gcd(n).compareTo(e.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(u),this.dmp1=this.d.mod(h),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}function ye(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)}function ve(t){var e=he(t,16),i=this.doPrivate(e);return null==i?null:le(i,this.n.bitLength()+7>>3)}function be(t){var e,i,r="";for(e=0;e+3<=t.length;e+=3)i=parseInt(t.substring(e,e+3),16),r+=Le.charAt(i>>6)+Le.charAt(63&i);for(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),r+=Le.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),r+=Le.charAt(i>>2)+Le.charAt((3&i)<<4));(3&r.length)>0;)r+=qe;return r}function Te(t){var e,i,r="",s=0;for(e=0;e<t.length&&t.charAt(e)!=qe;++e)v=Le.indexOf(t.charAt(e)),v<0||(0==s?(r+=o(v>>2),i=3&v,s=1):1==s?(r+=o(i<<2|v>>4),i=15&v,s=2):2==s?(r+=o(i),r+=o(v>>2),i=3&v,s=3):(r+=o(i<<2|v>>4),r+=o(15&v),s=0));return 1==s&&(r+=o(i<<2)),r}
// Copyright (c) 2005 Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.
var Se,Re=0xdeadbeefcafe,Ee=15715070==(16777215&Re);Ee&&"Microsoft Internet Explorer"==navigator.appName?(e.prototype.am=s,Se=30):Ee&&"Netscape"!=navigator.appName?(e.prototype.am=r,Se=26):(e.prototype.am=n,Se=28),e.prototype.DB=Se,e.prototype.DM=(1<<Se)-1,e.prototype.DV=1<<Se;var De=52;e.prototype.FV=Math.pow(2,De),e.prototype.F1=De-Se,e.prototype.F2=2*Se-De;var we,xe,Be="0123456789abcdefghijklmnopqrstuvwxyz",Ke=new Array;for(we="0".charCodeAt(0),xe=0;9>=xe;++xe)Ke[we++]=xe;for(we="a".charCodeAt(0),xe=10;36>xe;++xe)Ke[we++]=xe;for(we="A".charCodeAt(0),xe=10;36>xe;++xe)Ke[we++]=xe;A.prototype.convert=U,A.prototype.revert=O,A.prototype.reduce=V,A.prototype.mulTo=J,A.prototype.sqrTo=N,P.prototype.convert=M,P.prototype.revert=L,P.prototype.reduce=q,P.prototype.mulTo=H,P.prototype.sqrTo=C,e.prototype.copyTo=a,e.prototype.fromInt=u,e.prototype.fromString=f,e.prototype.clamp=p,e.prototype.dlShiftTo=T,e.prototype.drShiftTo=S,e.prototype.lShiftTo=R,e.prototype.rShiftTo=E,e.prototype.subTo=D,e.prototype.multiplyTo=w,e.prototype.squareTo=x,e.prototype.divRemTo=B,e.prototype.invDigit=I,e.prototype.isEven=j,e.prototype.exp=k,e.prototype.toString=l,e.prototype.negate=d,e.prototype.abs=g,e.prototype.compareTo=m,e.prototype.bitLength=b,e.prototype.mod=K,e.prototype.modPowInt=F,e.ZERO=c(0),e.ONE=c(1),It.prototype.convert=Pt,It.prototype.revert=Pt,It.prototype.mulTo=Mt,It.prototype.sqrTo=Lt,jt.prototype.convert=kt,jt.prototype.revert=Ft,jt.prototype.reduce=_t,jt.prototype.mulTo=Zt,jt.prototype.sqrTo=zt;var Ae=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Ue=(1<<26)/Ae[Ae.length-1];e.prototype.chunkSize=$,e.prototype.toRadix=W,e.prototype.fromRadix=Q,e.prototype.fromNumber=X,e.prototype.bitwiseTo=st,e.prototype.changeBit=St,e.prototype.addTo=wt,e.prototype.dMultiply=Jt,e.prototype.dAddOffset=Nt,e.prototype.multiplyLowerTo=Ct,e.prototype.multiplyUpperTo=Ht,e.prototype.modInt=Yt,e.prototype.millerRabin=Xt,e.prototype.clone=_,e.prototype.intValue=z,e.prototype.byteValue=Z,e.prototype.shortValue=G,e.prototype.signum=Y,e.prototype.toByteArray=tt,e.prototype.equals=et,e.prototype.min=it,e.prototype.max=rt,e.prototype.and=ot,e.prototype.or=at,e.prototype.xor=ct,e.prototype.andNot=pt,e.prototype.not=lt,e.prototype.shiftLeft=dt,e.prototype.shiftRight=gt,e.prototype.getLowestSetBit=yt,e.prototype.bitCount=bt,e.prototype.testBit=Tt,e.prototype.setBit=Rt,e.prototype.clearBit=Et,e.prototype.flipBit=Dt,e.prototype.add=xt,e.prototype.subtract=Bt,e.prototype.multiply=Kt,e.prototype.divide=Ut,e.prototype.remainder=Ot,e.prototype.divideAndRemainder=Vt,e.prototype.modPow=Gt,e.prototype.modInverse=Wt,e.prototype.pow=qt,e.prototype.gcd=$t,e.prototype.isProbablePrime=Qt,e.prototype.square=At,te.prototype.init=ee,te.prototype.next=ie;var Oe,Ve,Je,Ne=256;if(null==Ve){Ve=new Array,Je=0;var Ie;if(window.crypto&&window.crypto.getRandomValues){var Pe=new Uint32Array(256);for(window.crypto.getRandomValues(Pe),Ie=0;Ie<Pe.length;++Ie)Ve[Je++]=255&Pe[Ie]}var Me=function(t){if(this.count=this.count||0,this.count>=256||Je>=Ne)return void(window.removeEventListener?window.removeEventListener("mousemove",Me,!1):window.detachEvent&&window.detachEvent("onmousemove",Me));try{var e=t.x+t.y;Ve[Je++]=255&e,this.count+=1}catch(i){}};window.addEventListener?window.addEventListener("mousemove",Me,!1):window.attachEvent&&window.attachEvent("onmousemove",Me)}oe.prototype.nextBytes=ne,ue.prototype.doPublic=fe,ue.prototype.setPublic=ce,ue.prototype.encrypt=pe,ue.prototype.doPrivate=ye,ue.prototype.setPrivate=de,ue.prototype.setPrivateEx=ge,ue.prototype.generate=me,ue.prototype.decrypt=ve,
// Copyright (c) 2011 Kevin M Burns Jr.
// All Rights Reserved.
// See "LICENSE" for details.
//
// Extension to jsbn which adds facilities for asynchronous RSA key generation
// Primarily created to avoid execution timeout on mobile devices
//
// http://www-cs-students.stanford.edu/~tjw/jsbn/
//
// ---
function(){var t=function(t,r,s){var n=new oe,o=t>>1;this.e=parseInt(r,16);var h=new e(r,16),a=this,u=function(){var r=function(){if(a.p.compareTo(a.q)<=0){var t=a.p;a.p=a.q,a.q=t}var i=a.p.subtract(e.ONE),r=a.q.subtract(e.ONE),n=i.multiply(r);0==n.gcd(h).compareTo(e.ONE)?(a.n=a.p.multiply(a.q),a.d=h.modInverse(n),a.dmp1=a.d.mod(i),a.dmq1=a.d.mod(r),a.coeff=a.q.modInverse(a.p),setTimeout(function(){s()},0)):setTimeout(u,0)},c=function(){a.q=i(),a.q.fromNumberAsync(o,1,n,function(){a.q.subtract(e.ONE).gcda(h,function(t){0==t.compareTo(e.ONE)&&a.q.isProbablePrime(10)?setTimeout(r,0):setTimeout(c,0)})})},f=function(){a.p=i(),a.p.fromNumberAsync(t-o,1,n,function(){a.p.subtract(e.ONE).gcda(h,function(t){0==t.compareTo(e.ONE)&&a.p.isProbablePrime(10)?setTimeout(c,0):setTimeout(f,0)})})};setTimeout(f,0)};setTimeout(u,0)};ue.prototype.generateAsync=t;var r=function(t,e){var i=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(i.compareTo(r)<0){var s=i;i=r,r=s}var n=i.getLowestSetBit(),o=r.getLowestSetBit();if(0>o)return void e(i);o>n&&(o=n),o>0&&(i.rShiftTo(o,i),r.rShiftTo(o,r));var h=function(){(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),i.compareTo(r)>=0?(i.subTo(r,i),i.rShiftTo(1,i)):(r.subTo(i,r),r.rShiftTo(1,r)),i.signum()>0?setTimeout(h,0):(o>0&&r.lShiftTo(o,r),setTimeout(function(){e(r)},0))};setTimeout(h,10)};e.prototype.gcda=r;var s=function(t,i,r,s){if("number"==typeof i)if(2>t)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),ht,this),this.isEven()&&this.dAddOffset(1,0);var n=this,o=function(){n.dAddOffset(2,0),n.bitLength()>t&&n.subTo(e.ONE.shiftLeft(t-1),n),n.isProbablePrime(i)?setTimeout(function(){s()},0):setTimeout(o,0)};setTimeout(o,0)}else{var h=new Array,a=7&t;h.length=(t>>3)+1,i.nextBytes(h),a>0?h[0]&=(1<<a)-1:h[0]=0,this.fromString(h,256)}};e.prototype.fromNumberAsync=s}();var Le="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qe="=",Ce=Ce||{};Ce.env=Ce.env||{};var He=Ce,je=Object.prototype,ke="[object Function]",Fe=["toString","valueOf"];Ce.env.parseUA=function(t){var e,i=function(t){var e=0;return parseFloat(t.replace(/\./g,function(){return 1==e++?"":"."}))},r=navigator,s={ie:0,opera:0,gecko:0,webkit:0,chrome:0,mobile:null,air:0,ipad:0,iphone:0,ipod:0,ios:null,android:0,webos:0,caja:r&&r.cajaVersion,secure:!1,os:null},n=t||navigator&&navigator.userAgent,o=window&&window.location,h=o&&o.href;return s.secure=h&&0===h.toLowerCase().indexOf("https"),n&&(/windows|win32/i.test(n)?s.os="windows":/macintosh/i.test(n)?s.os="macintosh":/rhino/i.test(n)&&(s.os="rhino"),/KHTML/.test(n)&&(s.webkit=1),e=n.match(/AppleWebKit\/([^\s]*)/),e&&e[1]&&(s.webkit=i(e[1]),/ Mobile\//.test(n)?(s.mobile="Apple",e=n.match(/OS ([^\s]*)/),e&&e[1]&&(e=i(e[1].replace("_","."))),s.ios=e,s.ipad=s.ipod=s.iphone=0,e=n.match(/iPad|iPod|iPhone/),e&&e[0]&&(s[e[0].toLowerCase()]=s.ios)):(e=n.match(/NokiaN[^\/]*|Android \d\.\d|webOS\/\d\.\d/),e&&(s.mobile=e[0]),/webOS/.test(n)&&(s.mobile="WebOS",e=n.match(/webOS\/([^\s]*);/),e&&e[1]&&(s.webos=i(e[1]))),/ Android/.test(n)&&(s.mobile="Android",e=n.match(/Android ([^\s]*);/),e&&e[1]&&(s.android=i(e[1])))),e=n.match(/Chrome\/([^\s]*)/),e&&e[1]?s.chrome=i(e[1]):(e=n.match(/AdobeAIR\/([^\s]*)/),e&&(s.air=e[0]))),s.webkit||(e=n.match(/Opera[\s\/]([^\s]*)/),e&&e[1]?(s.opera=i(e[1]),e=n.match(/Version\/([^\s]*)/),e&&e[1]&&(s.opera=i(e[1])),e=n.match(/Opera Mini[^;]*/),e&&(s.mobile=e[0])):(e=n.match(/MSIE\s([^;]*)/),e&&e[1]?s.ie=i(e[1]):(e=n.match(/Gecko\/([^\s]*)/),e&&(s.gecko=1,e=n.match(/rv:([^\s\)]*)/),e&&e[1]&&(s.gecko=i(e[1]))))))),s},Ce.env.ua=Ce.env.parseUA(),Ce.isFunction=function(t){return"function"==typeof t||je.toString.apply(t)===ke},Ce._IEEnumFix=Ce.env.ua.ie?function(t,e){var i,r,s;for(i=0;i<Fe.length;i+=1)r=Fe[i],s=e[r],He.isFunction(s)&&s!=je[r]&&(t[r]=s)}:function(){},Ce.extend=function(t,e,i){if(!e||!t)throw new Error("extend failed, please check that all dependencies are included.");var r,s=function(){};if(s.prototype=e.prototype,t.prototype=new s,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==je.constructor&&(e.prototype.constructor=e),i){for(r in i)He.hasOwnProperty(i,r)&&(t.prototype[r]=i[r]);He._IEEnumFix(t.prototype,i)}},/*
* asn1.js - ASN.1 DER encoder classes
*
* Copyright (c) 2013 Kenji Urushima (kenji.urushima@gmail.com)
*
* This software is licensed under the terms of the MIT License.
* http://kjur.github.com/jsrsasign/license
*
* The above copyright and license notice shall be
* included in all copies or substantial portions of the Software.
*/
/**
* @fileOverview
* @name asn1-1.0.js
* @author Kenji Urushima kenji.urushima@gmail.com
* @version 1.0.2 (2013-May-30)
* @since 2.1
* @license <a href="http://kjur.github.io/jsrsasign/license/">MIT License</a>
*/
"undefined"!=typeof KJUR&&KJUR||(KJUR={}),"undefined"!=typeof KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var i=t.toString(16);if("-"!=i.substr(0,1))i.length%2==1?i="0"+i:i.match(/^[0-7]/)||(i="00"+i);else{var r=i.substr(1),s=r.length;s%2==1?s+=1:i.match(/^[0-7]/)||(s+=2);for(var n="",o=0;s>o;o++)n+="f";var h=new e(n,16),a=h.xor(t).add(e.ONE);i=a.toString(16).replace(/^-/,"")}return i},this.getPEMStringFromHex=function(t,e){var i=CryptoJS.enc.Hex.parse(t),r=CryptoJS.enc.Base64.stringify(i),s=r.replace(/(.{64})/g,"$1\r\n");return s=s.replace(/\r\n$/,""),"-----BEGIN "+e+"-----\r\n"+s+"\r\n-----END "+e+"-----\r\n"}},KJUR.asn1.ASN1Object=function(){var t="";this.getLengthHexFromValue=function(){if("undefined"==typeof this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+t.length+",v="+this.hV;var e=this.hV.length/2,i=e.toString(16);if(i.length%2==1&&(i="0"+i),128>e)return i;var r=i.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);var s=128+r;return s.toString(16)+i},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},KJUR.asn1.DERAbstractString=function(t){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex&&this.setStringHex(t.hex))},Ce.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractTime=function(t){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){utc=t.getTime()+6e4*t.getTimezoneOffset();var e=new Date(utc);return e},this.formatDate=function(t,e){var i=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var n=i(String(r.getMonth()+1),2),o=i(String(r.getDate()),2),h=i(String(r.getHours()),2),a=i(String(r.getMinutes()),2),u=i(String(r.getSeconds()),2);return s+n+o+h+a+u+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setByDateValue=function(t,e,i,r,s,n){var o=new Date(Date.UTC(t,e-1,i,r,s,n,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},Ce.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractStructured=function(t){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,"undefined"!=typeof t&&"undefined"!=typeof t.array&&(this.asn1Array=t.array)},Ce.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object),KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},Ce.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object),KJUR.asn1.DERInteger=function(t){KJUR.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var i=new e(String(t),10);this.setByBigInteger(i)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.bigint?this.setByBigInteger(t.bigint):"undefined"!=typeof t["int"]?this.setByInteger(t["int"]):"undefined"!=typeof t.hex&&this.setValueHex(t.hex))},Ce.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object),KJUR.asn1.DERBitString=function(t){KJUR.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(0>t||t>7)throw"unused bits shall be from 0 to 7: u = "+t;var i="0"+t;this.hTLV=null,this.isModified=!0,this.hV=i+e},this.setByBinaryString=function(t){t=t.replace(/0+$/,"");var e=8-t.length%8;8==e&&(e=0);for(var i=0;e>=i;i++)t+="0";for(var r="",i=0;i<t.length-1;i+=8){var s=t.substr(i,8),n=parseInt(s,2).toString(16);1==n.length&&(n="0"+n),r+=n}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",i=0;i<t.length;i++)e+=1==t[i]?"1":"0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),i=0;t>i;i++)e[i]=!1;return e},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.hex?this.setHexValueIncludingUnusedBits(t.hex):"undefined"!=typeof t.bin?this.setByBinaryString(t.bin):"undefined"!=typeof t.array&&this.setByBooleanArray(t.array))},Ce.extend(KJUR.asn1.DERBitString,KJUR.asn1.ASN1Object),KJUR.asn1.DEROctetString=function(t){KJUR.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Ce.extend(KJUR.asn1.DEROctetString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNull=function(){KJUR.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Ce.extend(KJUR.asn1.DERNull,KJUR.asn1.ASN1Object),KJUR.asn1.DERObjectIdentifier=function(t){var i=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",s=new e(t,10),n=s.toString(2),o=7-n.length%7;7==o&&(o=0);for(var h="",a=0;o>a;a++)h+="0";n=h+n;for(var a=0;a<n.length-1;a+=7){var u=n.substr(a,7);a!=n.length-7&&(u="1"+u),r+=i(parseInt(u,2))}return r};KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var e="",s=t.split("."),n=40*parseInt(s[0])+parseInt(s[1]);e+=i(n),s.splice(0,2);for(var o=0;o<s.length;o++)e+=r(s[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){if("undefined"==typeof KJUR.asn1.x509.OID.name2oidList[t])throw"DERObjectIdentifier oidName undefined: "+t;var e=KJUR.asn1.x509.OID.name2oidList[t];this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.oid?this.setValueOidString(t.oid):"undefined"!=typeof t.hex?this.setValueHex(t.hex):"undefined"!=typeof t.name&&this.setValueName(t.name))},Ce.extend(KJUR.asn1.DERObjectIdentifier,KJUR.asn1.ASN1Object),KJUR.asn1.DERUTF8String=function(t){KJUR.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Ce.extend(KJUR.asn1.DERUTF8String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNumericString=function(t){KJUR.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Ce.extend(KJUR.asn1.DERNumericString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERPrintableString=function(t){KJUR.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Ce.extend(KJUR.asn1.DERPrintableString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERTeletexString=function(t){KJUR.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Ce.extend(KJUR.asn1.DERTeletexString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERIA5String=function(t){KJUR.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Ce.extend(KJUR.asn1.DERIA5String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERUTCTime=function(t){KJUR.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex?this.setStringHex(t.hex):"undefined"!=typeof t.date&&this.setByDate(t.date))},Ce.extend(KJUR.asn1.DERUTCTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERGeneralizedTime=function(t){KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen"),this.hV=stohex(this.s)},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex?this.setStringHex(t.hex):"undefined"!=typeof t.date&&this.setByDate(t.date))},Ce.extend(KJUR.asn1.DERGeneralizedTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERSequence=function(t){KJUR.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t+=i.getEncodedHex()}return this.hV=t,this.hV}},Ce.extend(KJUR.asn1.DERSequence,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERSet=function(t){KJUR.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t.push(i.getEncodedHex())}return t.sort(),this.hV=t.join(""),this.hV}},Ce.extend(KJUR.asn1.DERSet,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERTaggedObject=function(t){KJUR.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,i){this.hT=e,this.isExplicit=t,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.tag&&(this.hT=t.tag),"undefined"!=typeof t.explicit&&(this.isExplicit=t.explicit),"undefined"!=typeof t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},Ce.extend(KJUR.asn1.DERTaggedObject,KJUR.asn1.ASN1Object),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";var e,i={};i.decode=function(i){var r;if(e===t){var s="0123456789ABCDEF",n=" \f\n\r  \u2028\u2029";for(e=[],r=0;16>r;++r)e[s.charAt(r)]=r;for(s=s.toLowerCase(),r=10;16>r;++r)e[s.charAt(r)]=r;for(r=0;r<n.length;++r)e[n.charAt(r)]=-1}var o=[],h=0,a=0;for(r=0;r<i.length;++r){var u=i.charAt(r);if("="==u)break;if(u=e[u],-1!=u){if(u===t)throw"Illegal character at offset "+r;h|=u,++a>=2?(o[o.length]=h,h=0,a=0):h<<=4}}if(a)throw"Hex encoding incomplete: 4 bits missing";return o},window.Hex=i}(),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";var e,i={};i.decode=function(i){var r;if(e===t){var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="= \f\n\r  \u2028\u2029";for(e=[],r=0;64>r;++r)e[s.charAt(r)]=r;for(r=0;r<n.length;++r)e[n.charAt(r)]=-1}var o=[],h=0,a=0;for(r=0;r<i.length;++r){var u=i.charAt(r);if("="==u)break;if(u=e[u],-1!=u){if(u===t)throw"Illegal character at offset "+r;h|=u,++a>=4?(o[o.length]=h>>16,o[o.length]=h>>8&255,o[o.length]=255&h,h=0,a=0):h<<=6}}switch(a){case 1:throw"Base64 encoding incomplete: at least 2 bits missing";case 2:o[o.length]=h>>10;break;case 3:o[o.length]=h>>16,o[o.length]=h>>8&255}return o},i.re=/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,i.unarmor=function(t){var e=i.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw"RegExp out of sync";t=e[2]}return i.decode(t)},window.Base64=i}(),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";function e(t,i){t instanceof e?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=i)}function i(t,e,i,r,s){this.stream=t,this.header=e,this.length=i,this.tag=r,this.sub=s}var r=100,s="…",n={tag:function(t,e){var i=document.createElement(t);return i.className=e,i},text:function(t){return document.createTextNode(t)}};e.prototype.get=function(e){if(e===t&&(e=this.pos++),e>=this.enc.length)throw"Requesting byte offset "+e+" on a stream of length "+this.enc.length;return this.enc[e]},e.prototype.hexDigits="0123456789ABCDEF",e.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},e.prototype.hexDump=function(t,e,i){for(var r="",s=t;e>s;++s)if(r+=this.hexByte(this.get(s)),i!==!0)switch(15&s){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r},e.prototype.parseStringISO=function(t,e){for(var i="",r=t;e>r;++r)i+=String.fromCharCode(this.get(r));return i},e.prototype.parseStringUTF=function(t,e){for(var i="",r=t;e>r;){var s=this.get(r++);i+=128>s?String.fromCharCode(s):s>191&&224>s?String.fromCharCode((31&s)<<6|63&this.get(r++)):String.fromCharCode((15&s)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return i},e.prototype.parseStringBMP=function(t,e){for(var i="",r=t;e>r;r+=2){var s=this.get(r),n=this.get(r+1);i+=String.fromCharCode((s<<8)+n)}return i},e.prototype.reTime=/^((?:1[89]|2\d)?\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,e.prototype.parseTime=function(t,e){var i=this.parseStringISO(t,e),r=this.reTime.exec(i);return r?(i=r[1]+"-"+r[2]+"-"+r[3]+" "+r[4],r[5]&&(i+=":"+r[5],r[6]&&(i+=":"+r[6],r[7]&&(i+="."+r[7]))),r[8]&&(i+=" UTC","Z"!=r[8]&&(i+=r[8],r[9]&&(i+=":"+r[9]))),i):"Unrecognized time: "+i},e.prototype.parseInteger=function(t,e){var i=e-t;if(i>4){i<<=3;var r=this.get(t);if(0===r)i-=8;else for(;128>r;)r<<=1,--i;return"("+i+" bit)"}for(var s=0,n=t;e>n;++n)s=s<<8|this.get(n);return s},e.prototype.parseBitString=function(t,e){var i=this.get(t),r=(e-t-1<<3)-i,s="("+r+" bit)";if(20>=r){var n=i;s+=" ";for(var o=e-1;o>t;--o){for(var h=this.get(o),a=n;8>a;++a)s+=h>>a&1?"1":"0";n=0}}return s},e.prototype.parseOctetString=function(t,e){var i=e-t,n="("+i+" byte) ";i>r&&(e=t+r);for(var o=t;e>o;++o)n+=this.hexByte(this.get(o));return i>r&&(n+=s),n},e.prototype.parseOID=function(t,e){for(var i="",r=0,s=0,n=t;e>n;++n){var o=this.get(n);if(r=r<<7|127&o,s+=7,!(128&o)){if(""===i){var h=80>r?40>r?0:1:2;i=h+"."+(r-40*h)}else i+="."+(s>=31?"bigint":r);r=s=0}}return i},i.prototype.typeName=function(){if(this.tag===t)return"unknown";var e=this.tag>>6,i=(this.tag>>5&1,31&this.tag);switch(e){case 0:switch(i){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString";default:return"Universal_"+i.toString(16)}case 1:return"Application_"+i.toString(16);case 2:return"["+i+"]";case 3:return"Private_"+i.toString(16)}},i.prototype.reSeemsASCII=/^[ -~]+$/,i.prototype.content=function(){if(this.tag===t)return null;var e=this.tag>>6,i=31&this.tag,n=this.posContent(),o=Math.abs(this.length);if(0!==e){if(null!==this.sub)return"("+this.sub.length+" elem)";var h=this.stream.parseStringISO(n,n+Math.min(o,r));return this.reSeemsASCII.test(h)?h.substring(0,2*r)+(h.length>2*r?s:""):this.stream.parseOctetString(n,n+o)}switch(i){case 1:return 0===this.stream.get(n)?"false":"true";case 2:return this.stream.parseInteger(n,n+o);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(n,n+o);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(n,n+o);case 6:return this.stream.parseOID(n,n+o);case 16:case 17:return"("+this.sub.length+" elem)";case 12:return this.stream.parseStringUTF(n,n+o);case 18:case 19:case 20:case 21:case 22:case 26:return this.stream.parseStringISO(n,n+o);case 30:return this.stream.parseStringBMP(n,n+o);case 23:case 24:return this.stream.parseTime(n,n+o)}return null},i.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},i.prototype.print=function(e){if(e===t&&(e=""),document.writeln(e+this),null!==this.sub){e+=" ";for(var i=0,r=this.sub.length;r>i;++i)this.sub[i].print(e)}},i.prototype.toPrettyString=function(e){e===t&&(e="");var i=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(i+="+"),i+=this.length,32&this.tag?i+=" (constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(i+=" (encapsulates)"),i+="\n",null!==this.sub){e+=" ";for(var r=0,s=this.sub.length;s>r;++r)i+=this.sub[r].toPrettyString(e)}return i},i.prototype.toDOM=function(){var t=n.tag("div","node");t.asn1=this;var e=n.tag("div","head"),i=this.typeName().replace(/_/g," ");e.innerHTML=i;var r=this.content();if(null!==r){r=String(r).replace(/</g,"&lt;");var s=n.tag("span","preview");s.appendChild(n.text(r)),e.appendChild(s)}t.appendChild(e),this.node=t,this.head=e;var o=n.tag("div","value");if(i="Offset: "+this.stream.pos+"<br/>",i+="Length: "+this.header+"+",i+=this.length>=0?this.length:-this.length+" (undefined)",32&this.tag?i+="<br/>(constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(i+="<br/>(encapsulates)"),null!==r&&(i+="<br/>Value:<br/><b>"+r+"</b>","object"==typeof oids&&6==this.tag)){var h=oids[r];h&&(h.d&&(i+="<br/>"+h.d),h.c&&(i+="<br/>"+h.c),h.w&&(i+="<br/>(warning!)"))}o.innerHTML=i,t.appendChild(o);var a=n.tag("div","sub");if(null!==this.sub)for(var u=0,c=this.sub.length;c>u;++u)a.appendChild(this.sub[u].toDOM());return t.appendChild(a),e.onclick=function(){t.className="node collapsed"==t.className?"node":"node collapsed"},t},i.prototype.posStart=function(){return this.stream.pos},i.prototype.posContent=function(){return this.stream.pos+this.header},i.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},i.prototype.fakeHover=function(t){this.node.className+=" hover",t&&(this.head.className+=" hover")},i.prototype.fakeOut=function(t){var e=/ ?hover/;this.node.className=this.node.className.replace(e,""),t&&(this.head.className=this.head.className.replace(e,""))},i.prototype.toHexDOM_sub=function(t,e,i,r,s){if(!(r>=s)){var o=n.tag("span",e);o.appendChild(n.text(i.hexDump(r,s))),t.appendChild(o)}},i.prototype.toHexDOM=function(e){var i=n.tag("span","hex");if(e===t&&(e=i),this.head.hexNode=i,this.head.onmouseover=function(){this.hexNode.className="hexCurrent"},this.head.onmouseout=function(){this.hexNode.className="hex"},i.asn1=this,i.onmouseover=function(){var t=!e.selected;t&&(e.selected=this.asn1,this.className="hexCurrent"),this.asn1.fakeHover(t)},i.onmouseout=function(){var t=e.selected==this.asn1;this.asn1.fakeOut(t),t&&(e.selected=null,this.className="hex")},this.toHexDOM_sub(i,"tag",this.stream,this.posStart(),this.posStart()+1),this.toHexDOM_sub(i,this.length>=0?"dlen":"ulen",this.stream,this.posStart()+1,this.posContent()),null===this.sub)i.appendChild(n.text(this.stream.hexDump(this.posContent(),this.posEnd())));else if(this.sub.length>0){var r=this.sub[0],s=this.sub[this.sub.length-1];this.toHexDOM_sub(i,"intro",this.stream,this.posContent(),r.posStart());for(var o=0,h=this.sub.length;h>o;++o)i.appendChild(this.sub[o].toHexDOM(e));this.toHexDOM_sub(i,"outro",this.stream,s.posEnd(),this.posEnd())}return i},i.prototype.toHexString=function(t){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},i.decodeLength=function(t){var e=t.get(),i=127&e;if(i==e)return i;if(i>3)throw"Length over 24 bits not supported at position "+(t.pos-1);if(0===i)return-1;e=0;for(var r=0;i>r;++r)e=e<<8|t.get();return e},i.hasContent=function(t,r,s){if(32&t)return!0;if(3>t||t>4)return!1;var n=new e(s);3==t&&n.get();var o=n.get();if(o>>6&1)return!1;try{var h=i.decodeLength(n);return n.pos-s.pos+h==r}catch(a){return!1}},i.decode=function(t){t instanceof e||(t=new e(t,0));var r=new e(t),s=t.get(),n=i.decodeLength(t),o=t.pos-r.pos,h=null;if(i.hasContent(s,n,t)){var a=t.pos;if(3==s&&t.get(),h=[],n>=0){for(var u=a+n;t.pos<u;)h[h.length]=i.decode(t);if(t.pos!=u)throw"Content size is not correct for container starting at offset "+a}else try{for(;;){var c=i.decode(t);if(0===c.tag)break;h[h.length]=c}n=a-t.pos}catch(f){throw"Exception while decoding undefined length content: "+f}}else t.pos+=n;return new i(r,o,n,s,h)},i.test=function(){for(var t=[{value:[39],expected:39},{value:[129,201],expected:201},{value:[131,254,220,186],expected:16702650}],r=0,s=t.length;s>r;++r){var n=new e(t[r].value,0),o=i.decodeLength(n);o!=t[r].expected&&document.write("In test["+r+"] expected "+t[r].expected+" got "+o+"\n")}},window.ASN1=i}(),ASN1.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,i=2*this.length;return t.substr(e,i)},ue.prototype.parseKey=function(t){try{var e=0,i=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,s=r.test(t)?Hex.decode(t):Base64.unarmor(t),n=ASN1.decode(s);if(3===n.sub.length&&(n=n.sub[2].sub[0]),9===n.sub.length){e=n.sub[1].getHexStringValue(),this.n=he(e,16),i=n.sub[2].getHexStringValue(),this.e=parseInt(i,16);var o=n.sub[3].getHexStringValue();this.d=he(o,16);var h=n.sub[4].getHexStringValue();this.p=he(h,16);var a=n.sub[5].getHexStringValue();this.q=he(a,16);var u=n.sub[6].getHexStringValue();this.dmp1=he(u,16);var c=n.sub[7].getHexStringValue();this.dmq1=he(c,16);var f=n.sub[8].getHexStringValue();this.coeff=he(f,16)}else{if(2!==n.sub.length)return!1;var p=n.sub[1],l=p.sub[0];e=l.sub[0].getHexStringValue(),this.n=he(e,16),i=l.sub[1].getHexStringValue(),this.e=parseInt(i,16)}return!0}catch(d){return!1}},ue.prototype.getPrivateBaseKey=function(){var t={array:[new KJUR.asn1.DERInteger({"int":0}),new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e}),new KJUR.asn1.DERInteger({bigint:this.d}),new KJUR.asn1.DERInteger({bigint:this.p}),new KJUR.asn1.DERInteger({bigint:this.q}),new KJUR.asn1.DERInteger({bigint:this.dmp1}),new KJUR.asn1.DERInteger({bigint:this.dmq1}),new KJUR.asn1.DERInteger({bigint:this.coeff})]},e=new KJUR.asn1.DERSequence(t);return e.getEncodedHex()},ue.prototype.getPrivateBaseKeyB64=function(){return be(this.getPrivateBaseKey())},ue.prototype.getPublicBaseKey=function(){var t={array:[new KJUR.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new KJUR.asn1.DERNull]},e=new KJUR.asn1.DERSequence(t);t={array:[new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e})]};var i=new KJUR.asn1.DERSequence(t);t={hex:"00"+i.getEncodedHex()};var r=new KJUR.asn1.DERBitString(t);t={array:[e,r]};var s=new KJUR.asn1.DERSequence(t);return s.getEncodedHex()},ue.prototype.getPublicBaseKeyB64=function(){return be(this.getPublicBaseKey())},ue.prototype.wordwrap=function(t,e){if(e=e||64,!t)return t;var i="(.{1,"+e+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(i,"g")).join("\n")},ue.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return t+=this.wordwrap(this.getPrivateBaseKeyB64())+"\n",t+="-----END RSA PRIVATE KEY-----"},ue.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return t+=this.wordwrap(this.getPublicBaseKeyB64())+"\n",t+="-----END PUBLIC KEY-----"},ue.prototype.hasPublicKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")},ue.prototype.hasPrivateKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},ue.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)};var _e=function(t){ue.call(this),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))};_e.prototype=new ue,_e.prototype.constructor=_e;var ze=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null};ze.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new _e(t)},ze.prototype.setPrivateKey=function(t){this.setKey(t)},ze.prototype.setPublicKey=function(t){this.setKey(t)},ze.prototype.decrypt=function(t){try{return this.getKey().decrypt(Te(t))}catch(e){return!1}},ze.prototype.encrypt=function(t){try{return be(this.getKey().encrypt(t))}catch(e){return!1}},ze.prototype.getKey=function(t){if(!this.key){if(this.key=new _e,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},ze.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},ze.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},ze.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},ze.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},ze.version="2.3.0",t.JSEncrypt=ze}(JSEncryptExports),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e:"function"==typeof define&&define.amd?define(e):t.JSEncrypt=e}(this,JSEncryptExports.JSEncrypt);
INTERMediatorOnPage.getEditorPath=function(){return '';};
INTERMediatorOnPage.getEntryPath=function(){return "/member/im_include_research.php";};
INTERMediatorOnPage.getTheme=function(){return "redb";};
INTERMediatorOnPage.getDataSources=function(){return {'0':{'records':'1','name':'staff','key':'id','query':{},'sort':{'0':{'field':'id','direction':'asc'}},'authentication':{'all':{'target':'field-user','field':'email'}}},'1':{'name':'management','key':'id'},'2':{'name':'gakubu','relation':{'0':{'foreign-key':'id','join-field':'gakubu_id','operator':'='}}},'3':{'name':'gakka','relation':{'0':{'foreign-key':'id','join-field':'gakka_id','operator':'='}}},'4':{'name':'title','relation':{'0':{'foreign-key':'id','join-field':'title_id','operator':'='}}},'5':{'name':'category','view':'research_category','table':'research_category','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}}},'6':{'name':'keyword','view':'research_keyword','table':'research_keyword','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'キーワードを追加'}},'7':{'name':'theme','view':'research_theme','table':'research_theme','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'テーマを追加'}},'8':{'name':'society','view':'academic_society','table':'academic_society','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'学会を追加'}},'9':{'records':'5','name':'paper','table':'book_paper','view':'book_paper','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','button-names':{'insert':'業績を追加'}},'10':{'records':'5','name':'exhibition_society','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','validation':{'0':{'field':'is_period','rule':'1'}},'post-repeater':'expandRecordHavingIsPeriod','button-names':{'insert':'業績を追加'}},'11':{'records':'5','name':'research_fund','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','validation':{'0':{'field':'fund','rule':'1','message':'半角数値で入力してください'},'1':{'field':'is_period','rule':'1'}},'post-repeater':'expandRecordHavingIsPeriod','button-names':{'insert':'業績を追加'}},'12':{'name':'patent','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','button-names':{'insert':'業績を追加'}}};};
INTERMediatorOnPage.getOptionsAliases=function(){return {};};
INTERMediatorOnPage.getOptionsTransaction=function(){return '';};
INTERMediatorOnPage.dbClassName="DB_PDO";
INTERMediatorOnPage.defaultKeyName="";
INTERMediatorOnPage.isEmailAsUsername=false;
INTERMediatorOnPage.getMessages=function(){return {'1':'Record #','2':'Refresh','3':'Add Record','4':'Delete Record','5':'Insert','6':'Delete','7':'Save','8':'Login as: ','9':'Logout','10':'Move to page:','11':'','12':'Detail','13':'Show List','14':'Copy','15':'Copy Record','1001':'Other people might be updated.\n\nInitially=@1@\nCurrent=@2@\nDatabase=@3@\n\nYou can overwrite with your data if you select OK.','1002':'Can\'t determine the Table Name: @1@','1003':'No information to update: field=@1@','1004':'Connection Error in db_query=@1@\/@2@','1005':'On calling db_query, Required parameter \'name\' doesn\'t specified','1006':'On calling db_query, Required parameter \'table\' doesn\'t specified','1007':'On calling db_update, Required parameter \'name\' doesn\'t specified','1008':'On calling db_update, Required parameter \'conditions\' doesn\'t specified','1009':'On calling db_update, Required parameter \'operator\' doesn\'t specified','1010':'On calling db_update, Required parameter \'value\' doesn\'t specified','1011':'On calling db_update, Required parameter \'dataset\' doesn\'t specified','1012':'Query Access: ','1013':'Update Access: ','1014':'Connection Error in db_update=@1@\/@2@','1015':'Connection Error in db_delete=@1@\/@2@','1016':'Connection Error in db_createRecord=@1@\/@2@','1017':'Delete Access: ','1018':'Create Record Access: ','1019':'On calling db_delete, Required parameter \'name\' doesn\'t specified','1020':'On calling db_delete, Required parameter \'conditions\' doesn\'t specified','1021':'On calling db_createRecord, Required parameter \'name\' doesn\'t specified','1022':'Using Unsupported Browser (Try not to use the compatibility mode of Internet Explorer)','1023':'[This site uses INTER-Mediator.]','1024':'Multiple records are going to be updated. The key field might be wrong. Are you sure?','1025':'Are you sure to delete?','1026':'Are you sure to create record?','1027':'Get Challenge: ','1028':'Connection Error in get_challenge=@1@\/@2@','1029':'Change Password Access: ','1030':'Connection Error on changing password=@1@\/@2@','1031':'Change File Uploading: ','1032':'Connection Error on uploading file=@1@\/@2@','1033':'The field name specified in the page file doesn\'t exist [folder=@1@]','1034':'Other people might be updated.\n\n@1@\n\nYou can overwrite with your data if you select OK.','1035':'field=@1@, initial value=@2@, current value=@3@\n','1036':'field=@1@, expression=@2@ happens a parse error.','1037':'A cyclic referencing is detected.','1038':'Preparing the Pusher, although the settings in the server side is available, the client library isn\'t included.','1039':'Preparing the Pusher, although the client library is included, the settings in the server side is not available.','1040':'The field \'@2@\' in the context \'@1@\' does not exist in the table.','1041':'Are you sure to copy this record?','1042':'The database class doesn\'t support aggregation-select\/from\/group-by.','1043':'Both aggregation-select and aggregation-from are required. One of them doesn\'t exist in the context definition.','1044':'The context having aggregation-select\/from\/group-by is read-only.','1045':'The \'key\' is required in the context definition if writing operations apply to the context \'@1@\'.','1046':'The context definition of the name \'@1@\' in target specifications of the page file is undefined in the definition file.','1047':'The context \'@1@\' was chosen for this context, and ignored target specifications were: @2@','2001':'Authentication Error!','2002':'User:','2003':'Password:','2004':'Login','2005':'Change Password','2006':'New Password:','2007':'Missing any of Username, old and new password.','2008':'Failure to get a challenge from server.','2009':'Succeed to change your password. Login with the new password.','2010':'Failure to change your password. Maybe the old password is not correct.','2011':'User(Mail Address):','2012':'Retry to login. You should clarify the user and the password.','2013':'You should input user and\/or password.','2014':'OAuth Login','2015':'Any alphabets have to contain in new password.','2016':'Any numbers have to contain in new password.','2017':'Any upper case alphabets have to contain in new password.','2018':'Any lower case alphabets have to contain in new password.','2019':'Any punctuations have to contain in new password.','2020':'New password have to differ from the user name.','2021':'New password have to contain more than @1@ characters.','2022':'Enrollment this site with email','2023':'Reset my password','2024':'You need to prepare your email address.','2025':'Require a 2048-bit private key at least for authentication','3101':'Drag Here.','3102':'Dragged File: ','3201':'Exceeded post size limit. Check the post_max_size in php.ini file.','3202':'No file wasn\'t uploaded. Possibly, exceeded file size limit.','3203':'Exceeded file size limit. Check the upload_max_filesize in php.ini file.','3204':'Partially uploaded.','3205':'Temporary directory doesn\'t exist.','3206':'Can\'t write to disk or file system.','3207':'Extension module prevents to upload.','3208':'Unknown error in file uploading.','3209':'Select File...','3210':'Selected File: ','3211':'Upload'};};
INTERMediatorOnPage.browserCompatibility=function(){return {'edge':'12+','trident':'4+','chrome':'1+','firefox':'2+','safari':'4+','opera':'1+','webkit':'1+'};};
INTERMediatorOnPage.clientNotificationIdentifier=function(){return '691702fed0565fd6aac03e53d2884c360b170b172eccb52da8ec18108b1d1cce';};
INTERMediatorOnPage.metadata={version:"5.12",releasedate:"2021-08-15"};
INTERMediatorLog.debugMode=false;
INTERMediatorOnPage.appLocale="ja_JP";
INTERMediatorOnPage.localeInfo=JSON.parse('{"decimal_point":".","thousands_sep":",","int_curr_symbol":"JPY ","currency_symbol":"\uffe5","mon_decimal_point":".","mon_thousands_sep":",","positive_sign":"","negative_sign":"-","int_frac_digits":0,"frac_digits":0,"p_cs_precedes":1,"p_sep_by_space":0,"n_cs_precedes":1,"n_sep_by_space":0,"p_sign_posn":1,"n_sign_posn":1,"grouping":[3],"mon_grouping":[3],"DAY":["\u65e5\u66dc\u65e5","\u6708\u66dc\u65e5","\u706b\u66dc\u65e5","\u6c34\u66dc\u65e5","\u6728\u66dc\u65e5","\u91d1\u66dc\u65e5","\u571f\u66dc\u65e5"],"ABDAY":["\u65e5","\u6708","\u706b","\u6c34","\u6728","\u91d1","\u571f"],"MON":["\u7766\u6708","\u5982\u6708","\u5f25\u751f","\u536f\u6708","\u7690\u6708","\u6c34\u7121\u6708","\u6587\u6708","\u8449\u6708","\u9577\u6708","\u795e\u7121\u6708","\u971c\u6708","\u5e2b\u8d70"],"ABMON":["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"],"AM_STR":"\u5348\u524d","PM_STR":"\u5348\u5f8c","D_FMT_LONG":"%Y\u5e74%M\u6708%D\u65e5 %W","T_FMT_LONG":"%H\u6642%I\u5206%S\u79d2","D_FMT_MIDDLE":"%Y\/%M\/%D(%w)","T_FMT_MIDDLE":"%H:%I:%S","D_FMT_SHORT":"%Y\/%m\/%d","T_FMT_SHORT":"%H:%I"}');
INTERMediatorOnPage.appCurrency="JP";
INTERMediatorOnPage.requireAuthentication=true;
INTERMediatorOnPage.authRequiredContext={'0':'staff'};
INTERMediatorOnPage.isLDAP=false;
INTERMediatorOnPage.isOAuthAvailable=false;
INTERMediatorOnPage.isNativeAuth=false;
INTERMediatorOnPage.authStoring="cookie-domainwide";
INTERMediatorOnPage.authExpired=3600;
INTERMediatorOnPage.realm="";
INTERMediatorOnPage.publickey='-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnEpCZny+NQy+aCVGivertUIt9OrI/aDpAjT7s1UYLEERFXcfFs1A9VdIowUeg3NyJxAOxbLk6RXczoVoULEte2HB/roFg7V/sVG9rjx5F4im0JLqEyvuSLTeSx3TGkIr0NHmNAO/SQrfnBiUjdkugn2WCuvQHe06wfHXWg3Pck4JS0Y6vNQz//Ny7nZVfAWRkiFtb7ZilvSWXmmFuoG3xH6IeFBMaJBcFENK58bGQaQTcfg9qzpHhzCQwqbURYSH8WzAZlPRUo1lBZ4WEpMqGWYOiiiqOlc0v+2pW5BNvu3fk8DQbGwJIywC12nfhFKZH2txv0o0hx2ukXA+nBMQLQIDAQAB-----END PUBLIC KEY-----';
INTERMediatorOnPage.publickeysize=2048;

Unexpected token '/', "/*
* INTE"... is not valid JSON - Connection Error in db_query=SyntaxError: Unexpected token '/', "/*
* INTE"... is not valid JSON//*
* INTER-Mediator
* Copyright (c) INTER-Mediator Directive Committee (http://inter-mediator.org)
* This project started at the end of 2009 by Masayuki Nii msyk@msyk.net.
*
* INTER-Mediator is supplied under MIT License.
* Please see the full license for details:
* https://github.com/INTER-Mediator/INTER-Mediator/blob/master/dist-docs/License.txt
*/
var INTERMediator={separator:'@',defDivider:'|',defaultTargetInnerHTML:!1,navigationLabel:null,elementIds:[],dontSelectRadioCheck:!1,ignoreOptimisticLocking:!1,additionalFieldValueOnNewRecord:{},additionalFieldValueOnUpdate:{},additionalFieldValueOnDelete:{},waitSecondsAfterPostMessage:4,pagedAllCount:0,totalRecordCount:null,currentEncNumber:0,isIE:!1,isTrident:!1,isEdge:!1,ieVersion:-1,titleAsLinkInfo:!0,classAsLinkInfo:!0,isDBDataPreferable:!1,noRecordClassName:'_im_for_noresult_',rootEnclosure:null,useSessionStorage:!0,partialConstructing:!0,linkedElmCounter:0,pusherObject:null,buttonIdNum:0,masterNodeOriginalDisplay:'block',detailNodeOriginalDisplay:'none',pusherAvailable:!1,dateTimeFunction:!1,postOnlyNumber:1,isTablet:!1,isMobile:!1,crossTableStage:0,eventListenerPostAdding:null,appendingNodesAtLast:null,propertyIETridentSetup:function(){'use strict';var ua,position,c,i;ua=navigator.userAgent;position=ua.toLocaleUpperCase().indexOf('MSIE');if(position>=0){INTERMediator.isIE=!0;for(i=position+4;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+4,i));break}}}
position=ua.indexOf('; Trident/');if(position>=0){INTERMediator.isTrident=!0;for(i=position+10;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+10,i))+4;if(INTERMediator.ieVersion===11){INTERMediator.isIE=!0}
break}}}
position=ua.indexOf(' Edge/');if(position>=0){INTERMediator.isEdge=!0;for(i=position+6;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))||i===ua.length-1){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+6,i));break}}}},propertyW3CUserAgentSetup:function(){'use strict';var u=window.navigator.userAgent.toLowerCase();INTERMediator.isTablet=(u.indexOf('windows')>-1&&u.indexOf('touch')>-1&&u.indexOf('tablet pc')===-1)||u.indexOf('ipad')>-1||(u.indexOf('android')>-1&&u.indexOf('mobile')===-1)||(u.indexOf('firefox')>-1&&u.indexOf('tablet')>-1)||u.indexOf('kindle')>-1||u.indexOf('silk')>-1||u.indexOf('playbook')>-1;INTERMediator.isMobile=(u.indexOf('windows')>-1&&u.indexOf('phone')>-1)||u.indexOf('iphone')>-1||u.indexOf('ipod')>-1||(u.indexOf('android')>-1&&u.indexOf('mobile')>-1)||(u.indexOf('firefox')>-1&&u.indexOf('mobile')>-1)||u.indexOf('blackberry')>-1},initialize:function(){'use strict';INTERMediatorOnPage.removeCookie('_im_localcontext');INTERMediator.additionalCondition={};INTERMediator.additionalSortKey={};INTERMediator.startFrom=0;IMLibLocalContext.archive()},construct:function(indexOfKeyFieldObject){'use strict';var timerTask;if(indexOfKeyFieldObject===!0||indexOfKeyFieldObject===undefined){if(INTERMediatorOnPage.isFinishToConstruct){return}
INTERMediatorOnPage.isFinishToConstruct=!0;timerTask=function(){INTERMediator.constructMain(!0)}}else{timerTask=function(){INTERMediator.constructMain(indexOfKeyFieldObject)}}
setTimeout(timerTask,0)},constructMain:function(updateRequiredContext,recordset){'use strict';var i,theNode,postSetFields=[],radioName={},nameSerial=1,nameAttrCounter=1,imPartsShouldFinished=[],isAcceptNotify=!1,originalNodes,parentNode,sybilingNode;INTERMediator.eventListenerPostAdding=[];if(INTERMediatorOnPage.doBeforeConstruct){INTERMediatorOnPage.doBeforeConstruct()}
if(!INTERMediatorOnPage.isAutoConstruct){return}
INTERMediatorOnPage.showProgress();INTERMediator.crossTableStage=0;INTERMediator.appendingNodesAtLast=[];IMLibEventResponder.setup();INTERMediatorOnPage.retrieveAuthInfo();try{if(Pusher.VERSION){INTERMediator.pusherAvailable=!0;if(!INTERMediatorOnPage.clientNotificationKey){INTERMediatorLog.setErrorMessage(Error('Pusher Configuration Error'),INTERMediatorOnPage.getMessages()[1039]);INTERMediator.pusherAvailable=!1}}}catch(ex){INTERMediator.pusherAvailable=!1;if(INTERMediatorOnPage.clientNotificationKey){INTERMediatorLog.setErrorMessage(Error('Pusher Configuration Error'),INTERMediatorOnPage.getMessages()[1038])}}
try{if(updateRequiredContext===!0||updateRequiredContext===undefined){IMLibPageNavigation.deleteInsertOnNavi=[];INTERMediator.partialConstructing=!1;INTERMediator.buttonIdNum=1;IMLibContextPool.clearAll();pageConstruct()}else{IMLibPageNavigation.deleteInsertOnNavi=[];INTERMediator.partialConstructing=!0;postSetFields=[];try{if(!recordset){updateRequiredContext.removeContext();originalNodes=updateRequiredContext.original;for(i=0;i<originalNodes.length;i++){updateRequiredContext.enclosureNode.appendChild(originalNodes[i].cloneNode(!0))}
seekEnclosureNode(updateRequiredContext.enclosureNode,updateRequiredContext.foreignValue,updateRequiredContext.dependingParentObjectInfo,updateRequiredContext)}else{expandRepeaters(updateRequiredContext,updateRequiredContext.enclosureNode,{recordset:recordset,targetTotalCount:1,targetCount:1})}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-8')}}
for(i=0;i<postSetFields.length;i++){if(postSetFields[i].id&&document.getElementById(postSetFields[i].id)){document.getElementById(postSetFields[i].id).value=postSetFields[i].value}}
IMLibCalc.updateCalculationFields()}}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.hideProgress();INTERMediatorOnPage.authenticating(function(){INTERMediator.constructMain(updateRequiredContext)});INTERMediator.partialConstructing=!0;return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-7');INTERMediator.partialConstructing=!0}}
for(i=0;i<imPartsShouldFinished.length;i++){imPartsShouldFinished[i].finish()}
for(i=0;i<INTERMediator.appendingNodesAtLast.length;i++){theNode=INTERMediator.appendingNodesAtLast[i].targetNode;parentNode=INTERMediator.appendingNodesAtLast[i].parentNode;sybilingNode=INTERMediator.appendingNodesAtLast[i].siblingNode;if(theNode&&parentNode){if(sybilingNode){parentNode.insertBefore(theNode,sybilingNode)}else{parentNode.appendChild(theNode)}}}
for(i=0;i<INTERMediator.eventListenerPostAdding.length;i++){theNode=document.getElementById(INTERMediator.eventListenerPostAdding[i].id);if(theNode){INTERMediatorLib.addEvent(theNode,INTERMediator.eventListenerPostAdding[i].event,INTERMediator.eventListenerPostAdding[i].todo)}}
if(INTERMediatorOnPage.doAfterConstruct){INTERMediatorOnPage.doAfterConstruct()}
IMLibPageNavigation.navigationSetup();INTERMediatorOnPage.isFinishToConstruct=!1;INTERMediator.partialConstructing=!0;INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage();function pageConstruct(){var i,bodyNode,emptyElement;IMLibCalc.calculateRequiredObject={};INTERMediator.currentEncNumber=1;INTERMediator.elementIds=[];bodyNode=document.getElementsByTagName('BODY')[0];if(!INTERMediator.rootEnclosure){INTERMediator.rootEnclosure=bodyNode.innerHTML}else{bodyNode.innerHTML=INTERMediator.rootEnclosure}
postSetFields=[];INTERMediatorOnPage.setReferenceToTheme();IMLibPageNavigation.initializeStepInfo(!1);IMLibLocalContext.bindingDescendant(document.documentElement);try{seekEnclosureNode(bodyNode,null,null,null)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-9')}}
for(i=0;i<postSetFields.length;i++){if(postSetFields[i].value===''&&document.getElementById(postSetFields[i].id).tagName==='SELECT'){emptyElement=document.createElement('option');emptyElement.setAttribute('id',INTERMediator.nextIdValue());emptyElement.setAttribute('value','');emptyElement.setAttribute('data-im-element','auto-generated');document.getElementById(postSetFields[i].id).insertBefore(emptyElement,document.getElementById(postSetFields[i].id).firstChild)}
document.getElementById(postSetFields[i].id).value=postSetFields[i].value}
IMLibCalc.updateCalculationFields();if(isAcceptNotify&&INTERMediator.pusherAvailable){var channelName=INTERMediatorOnPage.clientNotificationIdentifier();var appKey=INTERMediatorOnPage.clientNotificationKey();if(appKey&&appKey!=='_im_key_isnt_supplied'&&!INTERMediator.pusherObject){try{Pusher.log=function(message){if(window.console&&window.console.log){window.console.log(message)}};INTERMediator.pusherObject=new Pusher(appKey);INTERMediator.pusherChannel=INTERMediator.pusherObject.subscribe(channelName);INTERMediator.pusherChannel.bind('update',function(data){IMLibContextPool.updateOnAnotherClient('update',data)});INTERMediator.pusherChannel.bind('create',function(data){IMLibContextPool.updateOnAnotherClient('create',data)});INTERMediator.pusherChannel.bind('delete',function(data){IMLibContextPool.updateOnAnotherClient('delete',data)})}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-47')}}}
appendCredit()}
function seekEnclosureNode(node,currentRecord,parentObjectInfo,currentContextObj){var children,className,i,attr;if(node.nodeType===1){try{if(INTERMediatorLib.isEnclosure(node,!1)){className=INTERMediatorLib.getClassAttributeFromNode(node);attr=node.getAttribute('data-im-control');if((className&&className.match(/_im_post/))||(attr&&attr.indexOf('post')>=0)){setupPostOnlyEnclosure(node)}else{if(INTERMediator.isIE){try{expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}}}else{expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}}}else{children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){seekEnclosureNode(children[i],currentRecord,parentObjectInfo,currentContextObj)}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-10')}}}}
function setupPostOnlyEnclosure(node){var nodes,postNodes;postNodes=INTERMediatorLib.getElementsByClassNameOrDataAttr(node,'_im_post');for(i=0;i<postNodes.length;i++){if(postNodes[i].tagName==='BUTTON'||(postNodes[i].tagName==='INPUT'&&(postNodes[i].getAttribute('type').toLowerCase()==='button'||postNodes[i].getAttribute('type').toLowerCase()==='submit'))){if(!postNodes[i].id){postNodes[i].id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(postNodes[i].id,(function(){var targetNode=postNodes[i];return function(){IMLibUI.clickPostOnlyButton(targetNode)}})())}}
nodes=node.childNodes;for(i=0;i<nodes.length;i++){seekEnclosureInPostOnly(nodes[i])}
function seekEnclosureInPostOnly(node){var children,wInfo,i,target;if(node.nodeType===1){try{target=node.getAttribute('data-im');if(!target){target=node.getAttribute('data-im-group')}
if(target){if(!node.id){node.id='IMPOST-'+INTERMediator.postOnlyNumber;INTERMediator.postOnlyNumber++}
INTERMediatorLib.addEvent(node,'blur',function(){var idValue=node.id;IMLibUI.valueChange(idValue,!0)});if(node.tagName==='INPUT'&&node.getAttribute('type')==='radio'){if(!radioName[target]){radioName[target]='Name-'+nameSerial;nameSerial++}
node.setAttribute('name',radioName[target])}}
if(INTERMediatorLib.isWidgetElement(node)){wInfo=INTERMediatorLib.getWidgetInfo(node);if(wInfo[0]){IMParts_Catalog[wInfo[0]].instanciate(node);if(imPartsShouldFinished.indexOf(IMParts_Catalog[wInfo[0]])<0){imPartsShouldFinished.push(IMParts_Catalog[wInfo[0]])}}}else if(INTERMediatorLib.isEnclosure(node,!1)){expandEnclosure(node,null,null,null)}else{children=node.childNodes;for(i=0;i<children.length;i++){seekEnclosureInPostOnly(children[i])}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-11')}}}}}
function expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj){var recId,repNodeTag,repeatersOriginal;var imControl=node.getAttribute('data-im-control');if(currentContextObj&&currentContextObj.contextName&&currentRecord&&currentRecord[currentContextObj.contextName]&&currentRecord[currentContextObj.contextName][currentContextObj.contextName+'::'+INTERMediatorOnPage.defaultKeyName]){recId=currentRecord[currentContextObj.contextName][currentContextObj.contextName+'::'+INTERMediatorOnPage.defaultKeyName];currentRecord=currentRecord[currentContextObj.contextName][recId]}
if(imControl&&imControl.match(/cross-table/)){expandCrossTableEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}else{repNodeTag=INTERMediatorLib.repeaterTagFromEncTag(node.tagName);repeatersOriginal=collectRepeatersOriginal(node,repNodeTag);enclosureProcessing(node,repeatersOriginal,currentRecord,parentObjectInfo,currentContextObj)}
IMLibLocalContext.bindingDescendant(node);function enclosureProcessing(enclosureNode,repeatersOriginal,currentRecord,parentObjectInfo,currentContextObj,procBeforeRetrieve,customExpandRepeater){var linkedNodes,repeaters,linkDefs,voteResult,currentContextDef,fieldList,i,targetRecords,newNode,keyValue,selectedNode,isExpanding,calcFields,contextObj=null,targetRecordset,ix,keyingValue,footerNodes,headerNodes,nInfo;var tempObj={};repeaters=collectRepeaters(repeatersOriginal);linkedNodes=INTERMediatorLib.seekLinkedAndWidgetNodes(repeaters,!0).linkedNode;linkDefs=collectLinkDefinitions(linkedNodes);voteResult=tableVoting(linkDefs);currentContextDef=voteResult.targettable;INTERMediator.currentEncNumber++;if(!enclosureNode.getAttribute('id')){enclosureNode.setAttribute('id',INTERMediator.nextIdValue())}
if(!currentContextDef){for(i=0;i<repeatersOriginal.length;i++){newNode=enclosureNode.appendChild(repeatersOriginal[i]);if(repeatersOriginal[i].getAttribute('selected')){selectedNode=newNode}
if(selectedNode!==undefined){selectedNode.selected=!0}
seekEnclosureNode(newNode,null,enclosureNode,currentContextObj)}}else{isExpanding=!IMLibPageNavigation.isNotExpandingContext(currentContextDef);contextObj=IMLibContextPool.generateContextObject(currentContextDef,enclosureNode,repeaters,repeatersOriginal);calcFields=contextObj.getCalculationFields();fieldList=voteResult.fieldlist.map(function(elm){if(!calcFields[elm]){calcFields.push(elm)}
return elm});if(currentContextDef.relation&&currentContextDef.relation[0]&&Boolean(currentContextDef.relation[0].portal)===!0){contextObj.isPortal=!0;if(!currentRecord){tempObj=IMLibContextPool.generateContextObject({'name':contextObj.sourceName},enclosureNode,repeaters,repeatersOriginal);if(targetRecords===undefined){targetRecords=retrieveDataForEnclosure(tempObj,fieldList,contextObj.foreignValue)}
recId=targetRecords.recordset[0][INTERMediatorOnPage.defaultKeyName];currentRecord=targetRecords.recordset[0]}}
contextObj.setRelationWithParent(currentRecord,parentObjectInfo,currentContextObj);if(contextObj.isPortal===!0){if(currentRecord){currentContextDef.currentrecord=currentRecord;keyValue=currentRecord[currentContextDef.relation[0]['join-field']]}}
if(procBeforeRetrieve){procBeforeRetrieve(contextObj)}
if(isExpanding){targetRecords=retrieveDataForEnclosure(contextObj,fieldList,contextObj.foreignValue)}else{targetRecords=[];if(enclosureNode.tagName==='TBODY'){enclosureNode.parentNode.style.display='none'}else{enclosureNode.style.display='none'}}
contextObj.storeRecords(targetRecords);callbackForAfterQueryStored(currentContextDef,contextObj);if(customExpandRepeater===undefined){contextObj.registeredId=targetRecords.registeredId;contextObj.nullAcceptable=targetRecords.nullAcceptable;isAcceptNotify|=!(INTERMediatorOnPage.notifySupport===!1);expandRepeaters(contextObj,enclosureNode,targetRecords);IMLibPageNavigation.setupInsertButton(contextObj,keyValue,enclosureNode,contextObj.foreignValue);IMLibPageNavigation.setupBackNaviButton(contextObj,enclosureNode);callbackForEnclosure(currentContextDef,enclosureNode)}else{customExpandRepeater(contextObj,targetRecords)}
contextObj.sequencing=!1;if(enclosureNode.tagName==='TBODY'){footerNodes=enclosureNode.parentNode.getElementsByTagName('TFOOT');linkedNodes=seekWithAttribute(footerNodes[0],'data-im');if(linkedNodes){INTERMediator.setIdValue(footerNodes[0]);targetRecordset={};ix=null;keyingValue='_im_footer';for(i=0;i<linkedNodes.length;i++){nInfo=INTERMediatorLib.getNodeInfoArray(INTERMediatorLib.getLinkedElementInfo(linkedNodes[i])[0]);if(linkedNodes[i]&&currentContextDef.name===nInfo.table){INTERMediator.setIdValue(linkedNodes[i])}
IMLibCalc.updateCalculationInfo(contextObj,keyingValue,linkedNodes[i].id,nInfo,targetRecordset);if(contextObj.binding._im_footer){contextObj.binding._im_footer._im_repeater=footerNodes}}}
headerNodes=enclosureNode.parentNode.getElementsByTagName('THEAD');linkedNodes=seekWithAttribute(headerNodes[0],'data-im');if(linkedNodes){INTERMediator.setIdValue(headerNodes[0]);targetRecordset={};ix=null;keyingValue='_im_header';for(i=0;i<linkedNodes.length;i++){INTERMediator.setIdValue(linkedNodes[i]);nInfo=INTERMediatorLib.getNodeInfoArray(INTERMediatorLib.getLinkedElementInfo(linkedNodes[i])[0]);IMLibCalc.updateCalculationInfo(contextObj,keyingValue,linkedNodes[i].id,nInfo,targetRecordset);if(contextObj.binding._im_header){contextObj.binding._im_header._im_repeater=headerNodes}}}}}
return contextObj}
function seekWithAttribute(node,attrName){if(!node||node.nodeType!==1){return null}
var result=seekWithAttributeImpl(node,attrName);return result}
function seekWithAttributeImpl(node,attrName){var ix,adding,result=[];if(node&&node.nodeType===1){if(node.getAttribute(attrName)){result.push(node)}
if(node.childNodes){for(ix=0;ix<node.childNodes.length;ix++){adding=seekWithAttributeImpl(node.childNodes[ix],attrName);if(adding.length>0){[].push.apply(result,adding)}}}}
return result}
function expandCrossTableEnclosure(node,currentRecord,parentObjectInfo,currentContextObj){var i,j,colArray,rowArray,nodeForKeyValues,record,targetRepeater,lineNode,colContext,rowContext,appendingNode,trNodes,repeaters,linkedNodes,linkDefs,crossCellContext,labelKeyColumn,labelKeyRow;var ctComponentNodes=crossTableComponents(node);if(ctComponentNodes.length!==4){throw 'Exception-xx: Cross Table Components aren\'t prepared.'}
while(node.childNodes.length>0){node.removeChild(node.childNodes[0])}
repeaters=collectRepeaters([ctComponentNodes[3].cloneNode(!0)]);linkedNodes=INTERMediatorLib.seekLinkedAndWidgetNodes(repeaters,!0).linkedNode;linkDefs=collectLinkDefinitions(linkedNodes);crossCellContext=tableVoting(linkDefs).targettable;labelKeyColumn=crossCellContext.relation[0]['join-field'];labelKeyRow=crossCellContext.relation[1]['join-field'];INTERMediator.crossTableStage=1;lineNode=document.createElement('TR');targetRepeater=ctComponentNodes[0].cloneNode(!0);lineNode.appendChild(targetRepeater);node.appendChild(lineNode);targetRepeater=ctComponentNodes[1].cloneNode(!0);colContext=enclosureProcessing(lineNode,[targetRepeater],null,parentObjectInfo,currentContextObj);colArray=colContext.indexingArray(labelKeyColumn);INTERMediator.crossTableStage=2;targetRepeater=ctComponentNodes[2].cloneNode(!0);lineNode=document.createElement('TR');lineNode.appendChild(targetRepeater);rowContext=enclosureProcessing(node,[lineNode],null,parentObjectInfo,currentContextObj);rowArray=rowContext.indexingArray(labelKeyRow);INTERMediator.crossTableStage=3;targetRepeater=ctComponentNodes[3].cloneNode(!0);nodeForKeyValues={};trNodes=node.getElementsByTagName('TR');for(i=1;i<trNodes.length;i+=1){for(j=0;j<colArray.length;j+=1){appendingNode=targetRepeater.cloneNode(!0);trNodes[i].appendChild(appendingNode);INTERMediator.setIdValue(appendingNode);if(!nodeForKeyValues[colArray[j]]){nodeForKeyValues[colArray[j]]={}}
nodeForKeyValues[colArray[j]][rowArray[i-1]]=appendingNode}}
INTERMediator.setIdValue(node);enclosureProcessing(node,[targetRepeater],null,parentObjectInfo,currentContextObj,function(context){var currentContextDef=context.getContextDef();INTERMediator.clearCondition(currentContextDef.name,'_imlabel_crosstable');INTERMediator.addCondition(currentContextDef.name,{field:currentContextDef.relation[0]['foreign-key'],operator:'IN',value:colArray,onetime:!0},undefined,'_imlabel_crosstable');INTERMediator.addCondition(currentContextDef.name,{field:currentContextDef.relation[1]['foreign-key'],operator:'IN',value:rowArray,onetime:!0},undefined,'_imlabel_crosstable')},function(contextObj,targetRecords){var dataKeyColumn,dataKeyRow,currentContextDef,ix,linkedElements,targetNode,keyField,keyValue,keyingValue;currentContextDef=contextObj.getContextDef();keyField=contextObj.getKeyField();dataKeyColumn=currentContextDef.relation[0]['foreign-key'];dataKeyRow=currentContextDef.relation[1]['foreign-key'];if(targetRecords.recordset){for(ix=0;ix<targetRecords.recordset.length;ix++){record=targetRecords.recordset[ix];if(nodeForKeyValues[record[dataKeyColumn]]&&nodeForKeyValues[record[dataKeyColumn]][record[dataKeyRow]]){targetNode=nodeForKeyValues[record[dataKeyColumn]][record[dataKeyRow]];if(targetNode){linkedElements=INTERMediatorLib.seekLinkedAndWidgetNodes([targetNode],!1);keyValue=record[keyField];if(keyField&&!keyValue&&keyValue!==0){keyValue=ix}
keyingValue=keyField+'='+keyValue}
setupLinkedNode(linkedElements,contextObj,targetRecords.recordset,ix,keyingValue)}}}})}
function crossTableComponents(node){var components=[],count=0;repeatCTComponents(node.childNodes);return components;function repeatCTComponents(nodes){var childNodes,i;for(i=0;i<nodes.length;i++){if(nodes[i].nodeType===1&&(nodes[i].tagName==='TH'||nodes[i].tagName==='TD')){components[count]=nodes[i];count+=1}else{childNodes=nodes[i].childNodes;if(childNodes){repeatCTComponents(childNodes)}}}}}}
function setupLinkedNode(linkedElements,contextObj,targetRecordset,ix,keyingValue){var currentWidgetNodes,currentLinkedNodes,nInfo,currentContextDef,j,keyField,k,nodeId,curVal,replacedNode,typeAttr,children,wInfo,nameTable,idValuesForFieldName={},linkInfoArray,nameTableKey,nameNumber,nameAttr,curTarget;currentContextDef=contextObj.getContextDef();try{currentWidgetNodes=linkedElements.widgetNode;currentLinkedNodes=linkedElements.linkedNode;keyField=contextObj.getKeyField();if(targetRecordset[ix]&&(targetRecordset[ix][keyField]||targetRecordset[ix][keyField]===0)){for(k=0;k<currentLinkedNodes.length;k++){nodeId=currentLinkedNodes[k].getAttribute('id');replacedNode=INTERMediator.setIdValue(currentLinkedNodes[k]);typeAttr=replacedNode.getAttribute('type');if(typeAttr==='checkbox'||typeAttr==='radio'){children=replacedNode.parentNode.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1&&children[i].tagName==='LABEL'&&nodeId===children[i].getAttribute('for')){children[i].setAttribute('for',replacedNode.getAttribute('id'));break}}}}
for(k=0;k<currentWidgetNodes.length;k++){wInfo=INTERMediatorLib.getWidgetInfo(currentWidgetNodes[k]);if(wInfo[0]){IMParts_Catalog[wInfo[0]].instanciate(currentWidgetNodes[k]);if(imPartsShouldFinished.indexOf(IMParts_Catalog[wInfo[0]])<0){imPartsShouldFinished.push(IMParts_Catalog[wInfo[0]])}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-101')}}
nameTable={};for(k=0;k<currentLinkedNodes.length;k++){try{nodeId=currentLinkedNodes[k].getAttribute('id');if(INTERMediatorLib.isWidgetElement(currentLinkedNodes[k])){nodeId=currentLinkedNodes[k]._im_getComponentId()}
typeAttr=currentLinkedNodes[k].getAttribute('type');linkInfoArray=INTERMediatorLib.getLinkedElementInfo(currentLinkedNodes[k]);if(typeAttr==='radio'){nameTableKey=linkInfoArray.join('|');if(!nameTable[nameTableKey]){nameTable[nameTableKey]=nameAttrCounter;nameAttrCounter++}
nameNumber=nameTable[nameTableKey];nameAttr=currentLinkedNodes[k].getAttribute('name');if(nameAttr){currentLinkedNodes[k].setAttribute('name',nameAttr+'-'+nameNumber)}else{currentLinkedNodes[k].setAttribute('name','IM-R-'+nameNumber)}}
for(j=0;j<linkInfoArray.length;j++){nInfo=INTERMediatorLib.getNodeInfoArray(linkInfoArray[j]);curVal=targetRecordset[ix][nInfo.field];if(!INTERMediator.isDBDataPreferable||curVal){IMLibCalc.updateCalculationInfo(contextObj,keyingValue,nodeId,nInfo,targetRecordset[ix])}
if(nInfo.table===currentContextDef.name){curTarget=nInfo.target;if(IMLibElement.setValueToIMNode(currentLinkedNodes[k],curTarget,curVal)){postSetFields.push({'id':nodeId,'value':curVal})}
contextObj.setValue(keyingValue,nInfo.field,curVal,nodeId,curTarget);if(idValuesForFieldName[nInfo.field]===undefined){idValuesForFieldName[nInfo.field]=[]}
idValuesForFieldName[nInfo.field].push(nodeId)}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-27')}}}
return idValuesForFieldName}
function expandRepeaters(contextObj,node,targetRecords){var newNode,nodeClass,dataAttr,repeatersOneRec,newlyAddedNodes,encNodeTag,repNodeTag,ix,repeatersOriginal,targetRecordset,targetTotalCount,i,currentContextDef,indexContext,insertNode,countRecord,linkedElements,keyingValue,keyField,keyValue,idValuesForFieldName;encNodeTag=node.tagName;repNodeTag=INTERMediatorLib.repeaterTagFromEncTag(encNodeTag);repeatersOriginal=contextObj.original;currentContextDef=contextObj.getContextDef();targetRecordset=targetRecords.recordset;targetTotalCount=targetRecords.totalCount;repeatersOneRec=cloneEveryNodes(repeatersOriginal);for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}}}
if(targetRecords.count===0){for(i=0;i<repeatersOriginal.length;i++){newNode=repeatersOriginal[i].cloneNode(!0);nodeClass=INTERMediatorLib.getClassAttributeFromNode(newNode);dataAttr=newNode.getAttribute('data-im-control');if((nodeClass&&nodeClass.indexOf(INTERMediator.noRecordClassName)>-1)||(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>-1)){node.appendChild(newNode);INTERMediator.setIdValue(newNode);seekEnclosureNode(newNode,null,null,null)}}}
countRecord=targetRecordset?targetRecordset.length:0;for(ix=0;ix<countRecord;ix++){repeatersOneRec=cloneEveryNodes(repeatersOriginal);linkedElements=INTERMediatorLib.seekLinkedAndWidgetNodes(repeatersOneRec,!0);keyField=contextObj.getKeyField();for(i=0;i<repeatersOneRec.length;i++){INTERMediator.setIdValue(repeatersOneRec[i])}
if(targetRecordset[ix]&&(targetRecordset[ix][keyField]||targetRecordset[ix][keyField]===0)){keyValue=targetRecordset[ix][keyField];if(keyField&&!keyValue&&keyValue!==0){INTERMediatorLog.setErrorMessage('The value of the key field is null.','This No.['+ix+'] record should be ignored.');keyValue=ix}
keyingValue=keyField+'='+keyValue}
idValuesForFieldName=setupLinkedNode(linkedElements,contextObj,targetRecordset,ix,keyingValue);IMLibPageNavigation.setupDeleteButton(encNodeTag,repeatersOneRec,contextObj,keyField,keyValue);IMLibPageNavigation.setupNavigationButton(encNodeTag,repeatersOneRec,currentContextDef,keyField,keyValue,contextObj);IMLibPageNavigation.setupCopyButton(encNodeTag,repNodeTag,repeatersOneRec,contextObj,targetRecordset[ix]);if(!currentContextDef.portal||(!!currentContextDef.portal&&targetTotalCount>0)){newlyAddedNodes=[];insertNode=null;if(!contextObj.sequencing){indexContext=contextObj.checkOrder(targetRecordset[ix]);insertNode=contextObj.getRepeaterEndNode(indexContext+1)}
for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];nodeClass=INTERMediatorLib.getClassAttributeFromNode(newNode);dataAttr=newNode.getAttribute('data-im-control');if(!(nodeClass&&nodeClass.indexOf(INTERMediator.noRecordClassName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)){if(!insertNode){node.appendChild(newNode)}else{insertNode.parentNode.insertBefore(newNode,insertNode)}
newlyAddedNodes.push(newNode);if(!newNode.id){INTERMediator.setIdValue(newNode)}
contextObj.setValue(keyingValue,'_im_repeater','',newNode.id,'',currentContextDef.portal);seekEnclosureNode(newNode,targetRecordset[ix],idValuesForFieldName,contextObj)}}
if((ix+1)!==countRecord){for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}else{insertNode.parentNode.insertBefore(newNode,insertNode)}}}}
callbackForRepeaters(currentContextDef,node,newlyAddedNodes)}
contextObj.rearrangePendingOrder()}
IMLibPageNavigation.setupDetailAreaToFirstRecord(currentContextDef,contextObj);repeatersOneRec=cloneEveryNodes(repeatersOriginal);for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}}}}
function retrieveDataForEnclosure(contextObj,fieldList,relationValue){var targetRecords,recordNumber,useLimit,key,recordset=[];if(Boolean(contextObj.contextDefinition.cache)===!0){targetRecords=retrieveDataFromCache(contextObj.contextDefinition,relationValue)}else if(contextObj.contextDefinition.data){for(key in contextObj.contextDefinition.data){if(contextObj.contextDefinition.data.hasOwnProperty(key)){recordset.push(contextObj.contextDefinition.data[key])}}
targetRecords={'recordset':recordset,'count':recordset.length,'totalCount':recordset.length,'nullAcceptable':!0}}else{try{targetRecords=contextObj.getPortalRecords();if(!targetRecords){useLimit=contextObj.isUseLimit();recordNumber=contextObj.getRecordNumber();targetRecords=INTERMediator_DBAdapter.db_query({'name':contextObj.contextDefinition.name,'records':isNaN(recordNumber)?100000000:recordNumber,'paging':contextObj.contextDefinition.paging,'fields':fieldList,'parentkeyvalue':relationValue,'conditions':null,'useoffset':!0,'uselimit':useLimit})}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-12')}}}
if(contextObj.contextDefinition['appending-data']){for(key in contextObj.contextDefinition['appending-data']){if(contextObj.contextDefinition['appending-data'].hasOwnProperty(key)){targetRecords.recordset.push(contextObj.contextDefinition['appending-data'][key])}}}
return targetRecords}
function retrieveDataFromCache(currentContextDef,relationValue){var targetRecords=null,pagingValue,counter,ix,oneRecord,isMatch,index,keyField,fieldName,recordsValue;try{if(!INTERMediatorOnPage.dbCache[currentContextDef.name]){INTERMediatorOnPage.dbCache[currentContextDef.name]=INTERMediator_DBAdapter.db_query({name:currentContextDef.name,records:null,paging:null,fields:null,parentkeyvalue:null,conditions:null,useoffset:!1})}
if(relationValue===null){targetRecords=INTERMediatorOnPage.dbCache[currentContextDef.name]}else{targetRecords={recordset:[],count:0};counter=0;for(ix in INTERMediatorOnPage.dbCache[currentContextDef.name].recordset){if(INTERMediatorOnPage.dbCache[currentContextDef.name].recordset.hasOwnProperty(ix)){oneRecord=INTERMediatorOnPage.dbCache[currentContextDef.name].recordset[ix];isMatch=!0;index=0;for(keyField in relationValue){if(relationValue.hasOwnProperty(keyField)){fieldName=currentContextDef.relation[index]['foreign-key'];if(oneRecord[fieldName]!==relationValue[keyField]){isMatch=!1;break}
index++}}
if(isMatch){pagingValue=currentContextDef.paging?currentContextDef.paging:!1;recordsValue=currentContextDef.records?currentContextDef.records:10000000000;if(!pagingValue||(pagingValue&&(counter>=INTERMediator.startFrom))){targetRecords.recordset.push(oneRecord);targetRecords.count++;if(recordsValue<=targetRecords.count){break}}
counter++}}}
return targetRecords}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-24')}}}
function callbackForRepeaters(currentContextDef,node,newlyAddedNodes){try{if(INTERMediatorOnPage.additionalExpandingRecordFinish[currentContextDef.name]){INTERMediatorOnPage.additionalExpandingRecordFinish[currentContextDef.name](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.additionalExpandingRecordFinish['+currentContextDef.name+'] with the context.',2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-33: hint: post-repeater of '+currentContextDef.name)}}
try{if(INTERMediatorOnPage.expandingRecordFinish){INTERMediatorOnPage.expandingRecordFinish(currentContextDef.name,newlyAddedNodes);INTERMediatorLog.setDebugMessage('Call INTERMediatorOnPage.expandingRecordFinish with the context: '+currentContextDef.name,2)}
if(currentContextDef['post-repeater']){INTERMediatorOnPage[currentContextDef['post-repeater']](newlyAddedNodes);INTERMediatorLog.setDebugMessage('Call the post repeater method INTERMediatorOnPage.'+currentContextDef['post-repeater']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-23')}}}
function callbackForEnclosure(currentContextDef,node){try{if(INTERMediatorOnPage.additionalExpandingEnclosureFinish[currentContextDef.name]){INTERMediatorOnPage.additionalExpandingEnclosureFinish[currentContextDef.name](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.additionalExpandingEnclosureFinish['+currentContextDef.name+'] with the context.',2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-32: hint: post-enclosure of '+currentContextDef.name)}}
try{if(INTERMediatorOnPage.expandingEnclosureFinish){INTERMediatorOnPage.expandingEnclosureFinish(currentContextDef.name,node);INTERMediatorLog.setDebugMessage('Call INTERMediatorOnPage.expandingEnclosureFinish with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-21')}}
try{if(currentContextDef['post-enclosure']){INTERMediatorOnPage[currentContextDef['post-enclosure']](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.'+currentContextDef['post-enclosure']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-22: hint: post-enclosure of '+currentContextDef.name)}}}
function callbackForAfterQueryStored(currentContextDef,context){try{if(currentContextDef['post-query-stored']){INTERMediatorOnPage[currentContextDef['post-query-stored']](context);INTERMediatorLog.setDebugMessage('Call the post query stored method INTERMediatorOnPage.'+currentContextDef['post-enclosure']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-41: hint: post-query-stored of '+currentContextDef.name)}}}
function collectRepeatersOriginal(node,repNodeTag){var i,repeatersOriginal=[],children,imControl;children=node.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(children[i].tagName===repNodeTag){repeatersOriginal.push(children[i])}else if(!repNodeTag&&(children[i].getAttribute('data-im-control'))){imControl=children[i].getAttribute('data-im-control');if(imControl.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>-1){repeatersOriginal.push(children[i])}}else if(!repNodeTag&&INTERMediatorLib.getClassAttributeFromNode(children[i])&&INTERMediatorLib.getClassAttributeFromNode(children[i]).match(/_im_repeater/)){imControl=INTERMediatorLib.getClassAttributeFromNode(children[i]);if(imControl.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>-1){repeatersOriginal.push(children[i])}}}}
return repeatersOriginal}
function collectRepeaters(repeatersOriginal){var i,repeaters=[],inDocNode,parentOfRep,cloneNode;for(i=0;i<repeatersOriginal.length;i++){inDocNode=repeatersOriginal[i];parentOfRep=repeatersOriginal[i].parentNode;cloneNode=repeatersOriginal[i].cloneNode(!0);repeaters.push(cloneNode);cloneNode.setAttribute('id',INTERMediator.nextIdValue());if(parentOfRep){parentOfRep.removeChild(inDocNode)}}
return repeaters}
function collectLinkDefinitions(linkedNodes){var linkDefs=[],nodeDefs,j,k;for(j=0;j<linkedNodes.length;j++){nodeDefs=INTERMediatorLib.getLinkedElementInfo(linkedNodes[j]);if(nodeDefs){for(k=0;k<nodeDefs.length;k++){linkDefs.push(nodeDefs[k])}}}
return linkDefs}
function tableVoting(linkDefs){var j,nodeInfoArray,nodeInfoField,nodeInfoTable,maxVoted,maxTableName,tableName,nodeInfoTableIndex,context,restDefs=[],tableVote=[],fieldList=[];for(j=0;j<linkDefs.length;j++){nodeInfoArray=INTERMediatorLib.getNodeInfoArray(linkDefs[j]);nodeInfoField=nodeInfoArray.field;nodeInfoTable=nodeInfoArray.table;nodeInfoTableIndex=nodeInfoArray.tableindex;if(nodeInfoTable!=IMLibLocalContext.contextName){if(nodeInfoField&&nodeInfoField.length!==0&&nodeInfoTable&&nodeInfoTable.length!==0){if(!fieldList[nodeInfoTableIndex]){fieldList[nodeInfoTableIndex]=[]}
fieldList[nodeInfoTableIndex].push(nodeInfoField);if(!tableVote[nodeInfoTableIndex]){tableVote[nodeInfoTableIndex]=1}else{++tableVote[nodeInfoTableIndex]}}else{INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1006,[linkDefs[j]]))}}}
maxVoted=-1;maxTableName='';for(tableName in tableVote){if(tableVote.hasOwnProperty(tableName)){if(maxVoted<tableVote[tableName]){maxVoted=tableVote[tableName];maxTableName=tableName.substring(10)}}}
context=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',maxTableName);if(linkDefs.length>0&&!context){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1046,[maxTableName]))}
for(j=0;j<linkDefs.length;j++){if(linkDefs[j].indexOf(maxTableName)!==0&&linkDefs[j].indexOf('_@')!==0){restDefs.push(linkDefs[j])}}
if(linkDefs.length>0&&context&&restDefs.length>0){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1047,[maxTableName,restDefs.toString()]))}
return{targettable:context,fieldlist:fieldList['_im_index_'+maxTableName]}}
function cloneEveryNodes(originalNodes){var i,clonedNodes=[];for(i=0;i<originalNodes.length;i++){clonedNodes.push(originalNodes[i].cloneNode(!0))}
return clonedNodes}
function getEnclosedNode(rootNode,tableName,fieldName){var i,j,nodeInfo,nInfo,children,r;if(rootNode.nodeType===1){nodeInfo=INTERMediatorLib.getLinkedElementInfo(rootNode);for(j=0;j<nodeInfo.length;j++){nInfo=INTERMediatorLib.getNodeInfoArray(nodeInfo[j]);if(nInfo.table===tableName&&nInfo.field===fieldName){return rootNode}}}
children=rootNode.childNodes;for(i=0;i<children.length;i++){r=getEnclosedNode(children[i],tableName,fieldName);if(r){return r}}
return null}
function appendCredit(){var bodyNode,creditNode,cNode,spNode,aNode,versionString;if(document.getElementById('IM_CREDIT')===null){if(INTERMediatorOnPage.creditIncluding){bodyNode=document.getElementById(INTERMediatorOnPage.creditIncluding)}
if(!bodyNode){bodyNode=document.getElementsByTagName('BODY')[0]}
creditNode=document.createElement('div');bodyNode.appendChild(creditNode);creditNode.setAttribute('id','IM_CREDIT');creditNode.setAttribute('class','IM_CREDIT');cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#F6F7FF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#EBF1FF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#E1EAFF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.setAttribute('align','right');cNode.style.backgroundColor='#D7E4FF';cNode.style.padding='2px';cNode.style.margin='0';cNode.style.padding='0';spNode=document.createElement('span');cNode.appendChild(spNode);cNode.style.color='#666666';cNode.style.fontSize='7pt';aNode=document.createElement('a');aNode.appendChild(document.createTextNode('INTER-Mediator'));aNode.setAttribute('href','http://inter-mediator.com/');aNode.setAttribute('target','_href');spNode.appendChild(document.createTextNode('Generated by '));spNode.appendChild(aNode);if(INTERMediatorOnPage.metadata){versionString=' Ver.'+INTERMediatorOnPage.metadata.version+'('+INTERMediatorOnPage.metadata.releasedate+')'}else{versionString=' Ver. Development Now!'}
spNode.appendChild(document.createTextNode(versionString))}}},setIdValue:function(node){'use strict';var i,elementInfo,comp,overwrite=!0;if(node.getAttribute('id')===null){node.setAttribute('id',INTERMediator.nextIdValue())}else{if(INTERMediator.elementIds.indexOf(node.getAttribute('id'))>=0){elementInfo=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<elementInfo.length;i++){comp=elementInfo[i].split(INTERMediator.separator);if(comp[2]==='#id'){overwrite=!1}}
if(overwrite){node.setAttribute('id',INTERMediator.nextIdValue())}}
INTERMediator.elementIds.push(node.getAttribute('id'))}
return node},nextIdValue:function(){'use strict';INTERMediator.linkedElmCounter++;return currentIdValue();function currentIdValue(){return'IM'+INTERMediator.currentEncNumber+'-'+INTERMediator.linkedElmCounter}},getLocalProperty:function(localKey,defaultValue){'use strict';var value;value=IMLibLocalContext.getValue(localKey);return value===null?defaultValue:value},setLocalProperty:function(localKey,value){'use strict';IMLibLocalContext.setValue(localKey,value,!0)},addCondition:function(contextName,condition,notMatching,label){'use strict';var value,i,hasIdentical;if(notMatching){condition.matching=!notMatching}else{condition.matching=INTERMediator_DBAdapter.eliminateDuplicatedConditions}
if(label){condition.label=label}
if(INTERMediator.additionalCondition){value=INTERMediator.additionalCondition;if(condition){if(!value[contextName]){value[contextName]=[]}
if(!condition.matching){value[contextName].push(condition)}else{hasIdentical=!1;for(i=0;i<value[contextName].length;i++){if(value[contextName][i].field===condition.field&&value[contextName][i].operator===condition.operator){hasIdentical=!0;value[contextName][i].value=condition.value;break}}
if(!hasIdentical){value[contextName].push(condition)}}}
INTERMediator.additionalCondition=value}
IMLibLocalContext.archive()},clearCondition:function(contextName,label){'use strict';var i,value=INTERMediator.additionalCondition;if(label===undefined){if(value[contextName]){delete value[contextName];INTERMediator.additionalCondition=value;IMLibLocalContext.archive()}}else{if(value[contextName]){for(i=0;i<value[contextName].length;i++){if(value[contextName][i].label===label){value[contextName].splice(i,1);i--}}
INTERMediator.additionalCondition=value;IMLibLocalContext.archive()}}},addSortKey:function(contextName,sortKey){'use strict';var value=INTERMediator.additionalSortKey;if(value[contextName]){value[contextName].push(sortKey)}else{value[contextName]=[sortKey]}
INTERMediator.additionalSortKey=value;IMLibLocalContext.archive()},clearSortKey:function(contextName){'use strict';var value=INTERMediator.additionalSortKey;if(value[contextName]){delete value[contextName];INTERMediator.additionalSortKey=value;IMLibLocalContext.archive()}},setRecordLimit:function(contextName,limit){'use strict';var value=INTERMediator.recordLimit;value[contextName]=limit;INTERMediator.recordLimit=value;IMLibLocalContext.archive()},clearRecordLimit:function(contextName){'use strict';var value=INTERMediator.recordLimit;if(value[contextName]){delete value[contextName];INTERMediator.recordLimit=value;IMLibLocalContext.archive()}},flushMessage:function(){'use strict';INTERMediatorLog.flushMessage()},setErrorMessage:function(ex,moreMessage){'use strict';INTERMediatorLog.setErrorMessage(ex,moreMessage)},setDebugMessage:function(message,level){'use strict';INTERMediatorLog.setDebugMessage(message,level)}};if(!Object.keys){Object.keys=function(obj){'use strict';var results=[],prop;if(obj!==Object(obj)){throw new TypeError('Object.keys called on a non-object')}
for(prop in obj){if(Object.prototype.hasOwnProperty.call(obj,prop)){results.push(prop)}}
return results}}
if(!Array.indexOf){var isWebkit='WebkitAppearance' in document.documentElement.style;if(!isWebkit){Array.prototype.indexOf=function(target){'use strict';var i;for(i=0;i<this.length;i++){if(this[i]===target){return i}}
return-1}}}
if(typeof String.prototype.trim!=='function'){String.prototype.trim=function(){'use strict';return this.replace(/^\s+|\s+$/g,'')}}
var INTERMediatorOnPage={authCountLimit:4,authCount:0,authUser:'',authHashedPassword:'',authCryptedPassword:'',authUserSalt:'',authUserHexSalt:'',authChallenge:'',requireAuthentication:!1,clientId:null,authRequiredContext:null,authStoring:'cookie',authExpired:3600,isOnceAtStarting:!0,publickey:null,isNativeAuth:!1,httpuser:null,httppasswd:null,mediaToken:null,realm:'',dbCache:{},isEmailAsUsername:!1,passwordPolicy:null,creditIncluding:null,masterScrollPosition:null,nonSupportMessageId:'nonsupportmessage',isFinishToConstruct:!1,isAutoConstruct:!0,isShowChangePassword:!0,isSetDefaultStyle:!1,authPanelTitle:null,isOAuthAvailable:!1,oAuthClientID:null,oAuthClientSecret:null,oAuthBaseURL:null,oAuthRedirect:null,oAuthScope:null,additionalExpandingEnclosureFinish:{},additionalExpandingRecordFinish:{},getEditorPath:null,getEntryPath:null,getIMRootPath:null,getDataSources:null,getOptionsAliases:null,getOptionsTransaction:null,dbClassName:null,defaultKeyName:null,browserCompatibility:null,clientNotificationIdentifier:null,metadata:null,isLDAP:null,appLocale:null,localeInfo:{mon_decimal_point:'.',mon_thousands_sep:',',currency_symbol:'¥'},appCurrency:null,isShowProgress:!0,clearCredentials:function(){'use strict';INTERMediatorOnPage.authChallenge=null;INTERMediatorOnPage.authHashedPassword=null;INTERMediatorOnPage.authCryptedPassword=null},getMessages:function(){'use strict';return null},getURLParametersAsArray:function(){'use strict';var i,params,eqPos,result,key,value;result={};params=location.search.substring(1).split('&');for(i=0;i<params.length;i++){eqPos=params[i].indexOf('=');if(eqPos>0){key=params[i].substring(0,eqPos);value=params[i].substring(eqPos+1);result[key]=decodeURIComponent(value)}}
return result},getContextInfo:function(contextName){'use strict';var dataSources,index;dataSources=INTERMediatorOnPage.getDataSources();for(index in dataSources){if(dataSources.hasOwnProperty(index)&&dataSources[index].name===contextName){return dataSources[index]}}
return null},isComplementAuthData:function(){'use strict';return INTERMediatorOnPage.authUser!==null&&INTERMediatorOnPage.authUser.length>0&&INTERMediatorOnPage.authHashedPassword!==null&&INTERMediatorOnPage.authHashedPassword.length>0&&INTERMediatorOnPage.authUserSalt!==null&&INTERMediatorOnPage.authUserSalt.length>0&&INTERMediatorOnPage.authChallenge!==null&&INTERMediatorOnPage.authChallenge.length>0},retrieveAuthInfo:function(){'use strict';if(INTERMediatorOnPage.requireAuthentication){if(INTERMediatorOnPage.isOnceAtStarting){switch(INTERMediatorOnPage.authStoring){case 'cookie':case 'cookie-domainwide':INTERMediatorOnPage.authUser=INTERMediatorOnPage.getCookie('_im_username');INTERMediatorOnPage.authHashedPassword=INTERMediatorOnPage.getCookie('_im_credential');INTERMediatorOnPage.mediaToken=INTERMediatorOnPage.getCookie('_im_mediatoken');INTERMediatorOnPage.authCryptedPassword=INTERMediatorOnPage.getCookie('_im_crypted');break;case 'session-storage':INTERMediatorOnPage.authUser=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_username');INTERMediatorOnPage.authHashedPassword=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_credential');INTERMediatorOnPage.mediaToken=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_mediatoken');INTERMediatorOnPage.authCryptedPassword=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_crypted');break;default:INTERMediatorOnPage.removeCookie('_im_username');INTERMediatorOnPage.removeCookie('_im_credential');INTERMediatorOnPage.removeCookie('_im_mediatoken');INTERMediatorOnPage.removeCookie('_im_crypted');break}
INTERMediatorOnPage.isOnceAtStarting=!1}
if(INTERMediatorOnPage.authUser.length>0){if(!INTERMediator_DBAdapter.getChallenge()){INTERMediatorLog.flushMessage()}}}},logout:function(){'use strict';INTERMediatorOnPage.authUser='';INTERMediatorOnPage.authHashedPassword='';INTERMediatorOnPage.authCryptedPassword='';INTERMediatorOnPage.authUserSalt='';INTERMediatorOnPage.authChallenge='';INTERMediatorOnPage.clientId='';INTERMediatorOnPage.removeCredencialsFromCookieOrStorage();INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_localcontext')},storeSessionStorageWithFallDown:function(key,value){'use strict';if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{sessionStorage.setItem(INTERMediatorOnPage.getKeyWithRealm(key),value)}catch(ex){INTERMediatorOnPage.setCookie(key,value)}}else{INTERMediatorOnPage.setCookie(key,value)}},getSessionStorageWithFallDown:function(key){'use strict';var value;if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{value=sessionStorage.getItem(INTERMediatorOnPage.getKeyWithRealm(key));value=value?value:''}catch(ex){value=INTERMediatorOnPage.getCookie(key)}}else{value=INTERMediatorOnPage.getCookie(key)}
return value},removeFromSessionStorageWithFallDown:function(key){'use strict';if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{sessionStorage.removeItem(INTERMediatorOnPage.getKeyWithRealm(key))}catch(ex){INTERMediatorOnPage.removeCookie(key)}}else{INTERMediatorOnPage.removeCookie(key)}},removeCredencialsFromCookieOrStorage:function(){'use strict';switch(INTERMediatorOnPage.authStoring){case 'cookie':case 'cookie-domainwide':INTERMediatorOnPage.removeCookie('_im_username');INTERMediatorOnPage.removeCookie('_im_credential');INTERMediatorOnPage.removeCookie('_im_mediatoken');INTERMediatorOnPage.removeCookie('_im_crypted');break;case 'session-storage':INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_username');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_credential');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_mediatoken');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_crypted');break}},storeCredentialsToCookieOrStorage:function(){'use strict';switch(INTERMediatorOnPage.authStoring){case 'cookie':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.setCookie('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.setCookie('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.setCookie('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.setCookie('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break;case 'cookie-domainwide':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.setCookieDomainWide('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.setCookieDomainWide('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.setCookieDomainWide('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.setCookieDomainWide('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break;case 'session-storage':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break}},loginPanelHTML:null,authenticating:function(doAfterAuth,doTest){'use strict';var bodyNode,backBox,frontPanel,labelWidth,userLabel,userSpan,userBox,msgNumber,passwordLabel,passwordSpan,passwordBox,breakLine,chgpwButton,authButton,panelTitle,newPasswordLabel,newPasswordSpan,newPasswordBox,newPasswordMessage,realmBox,keyCode,messageNode,oAuthButton,addingButton,resetMessage;var encrypt=new JSEncrypt();this.checkPasswordPolicy=function(newPassword,userName,policyString){var terms,i,message=[],minLen;if(!policyString){return message}
terms=policyString.split(/[\s,]/);for(i=0;i<terms.length;i++){switch(terms[i].toUpperCase()){case 'USEALPHABET':if(!newPassword.match(/[A-Za-z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2015))}
break;case 'USENUMBER':if(!newPassword.match(/[0-9]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2016))}
break;case 'USEUPPER':if(!newPassword.match(/[A-Z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2017))}
break;case 'USELOWER':if(!newPassword.match(/[a-z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2018))}
break;case 'USEPUNCTUATION':if(!newPassword.match(/[^A-Za-z0-9]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2019))}
break;case 'NOTUSERNAME':if(newPassword===userName){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2020))}
break;default:if(terms[i].toUpperCase().indexOf('LENGTH')===0){minLen=terms[i].match(/[0-9]+/)[0];if(newPassword.length<minLen){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2021,[minLen]))}}}}
return message};if(doTest){return}
if(INTERMediatorOnPage.authCount>INTERMediatorOnPage.authCountLimit){INTERMediatorOnPage.authenticationError();INTERMediatorOnPage.logout();INTERMediatorLog.flushMessage();return}
bodyNode=document.getElementsByTagName('BODY')[0];backBox=document.createElement('div');backBox.id='_im_authpback';bodyNode.insertBefore(backBox,bodyNode.childNodes[0]);if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.height='100%';backBox.style.width='100%';backBox.style.backgroundImage='url('+INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=background.gif)';backBox.style.position='absolute';backBox.style.padding=' 50px 0 0 0';backBox.style.top='0';backBox.style.left='0';backBox.style.zIndex='999998'}
if(INTERMediatorOnPage.loginPanelHTML){backBox.innerHTML=INTERMediatorOnPage.loginPanelHTML;passwordBox=document.getElementById('_im_password');userBox=document.getElementById('_im_username');authButton=document.getElementById('_im_authbutton');chgpwButton=document.getElementById('_im_changebutton');oAuthButton=document.getElementById('_im_oauthbutton')}else{frontPanel=document.createElement('div');if(INTERMediatorOnPage.isSetDefaultStyle){frontPanel.style.width='450px';frontPanel.style.backgroundColor='#333333';frontPanel.style.color='#DDDDAA';frontPanel.style.margin='50px auto 0 auto';frontPanel.style.padding='20px';frontPanel.style.borderRadius='10px';frontPanel.style.position='relative'}
frontPanel.id='_im_authpanel';backBox.appendChild(frontPanel);panelTitle='';if(INTERMediatorOnPage.authPanelTitle&&INTERMediatorOnPage.authPanelTitle.length>0){panelTitle=INTERMediatorOnPage.authPanelTitle}else if(INTERMediatorOnPage.realm&&INTERMediatorOnPage.realm.length>0){panelTitle=INTERMediatorOnPage.realm}
if(panelTitle&&panelTitle.length>0){realmBox=document.createElement('DIV');realmBox.appendChild(document.createTextNode(panelTitle));realmBox.id='_im_authrealm';frontPanel.appendChild(realmBox);breakLine=document.createElement('HR');frontPanel.appendChild(breakLine)}
labelWidth='100px';userLabel=document.createElement('LABEL');frontPanel.appendChild(userLabel);userSpan=document.createElement('span');if(INTERMediatorOnPage.isSetDefaultStyle){userSpan.style.minWidth=labelWidth;userSpan.style.textAlign='right';userSpan.style.cssFloat='left'}
INTERMediatorLib.setClassAttributeToNode(userSpan,'_im_authlabel');userLabel.appendChild(userSpan);msgNumber=INTERMediatorOnPage.isEmailAsUsername?2011:2002;userSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(msgNumber)));userBox=document.createElement('INPUT');userBox.type='text';userBox.id='_im_username';userBox.size='20';userBox.setAttribute('autocapitalize','off');userLabel.appendChild(userBox);breakLine=document.createElement('BR');breakLine.clear='all';frontPanel.appendChild(breakLine);passwordLabel=document.createElement('LABEL');frontPanel.appendChild(passwordLabel);passwordSpan=document.createElement('SPAN');if(INTERMediatorOnPage.isSetDefaultStyle){passwordSpan.style.minWidth=labelWidth;passwordSpan.style.textAlign='right';passwordSpan.style.cssFloat='left'}
INTERMediatorLib.setClassAttributeToNode(passwordSpan,'_im_authlabel');passwordLabel.appendChild(passwordSpan);passwordSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2003)));passwordBox=document.createElement('INPUT');passwordBox.type='password';passwordBox.id='_im_password';passwordBox.size='20';passwordLabel.appendChild(passwordBox);authButton=document.createElement('BUTTON');authButton.id='_im_authbutton';authButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2004)));frontPanel.appendChild(authButton);breakLine=document.createElement('BR');breakLine.clear='all';frontPanel.appendChild(breakLine);newPasswordMessage=document.createElement('DIV');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordMessage.style.textAlign='center';newPasswordMessage.style.textSize='10pt';newPasswordMessage.style.color='#994433'}
newPasswordMessage.id='_im_login_message';frontPanel.appendChild(newPasswordMessage);if(this.isShowChangePassword&&!INTERMediatorOnPage.isNativeAuth){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);newPasswordLabel=document.createElement('LABEL');frontPanel.appendChild(newPasswordLabel);newPasswordSpan=document.createElement('SPAN');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordSpan.style.minWidth=labelWidth;newPasswordSpan.style.textAlign='right';newPasswordSpan.style.cssFloat='left';newPasswordSpan.style.fontSize='0.7em';newPasswordSpan.style.paddingTop='4px'}
INTERMediatorLib.setClassAttributeToNode(newPasswordSpan,'_im_authlabel_pwchange');newPasswordLabel.appendChild(newPasswordSpan);newPasswordSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2006)));newPasswordBox=document.createElement('INPUT');newPasswordBox.type='password';newPasswordBox.id='_im_newpassword';newPasswordBox.size='12';newPasswordLabel.appendChild(newPasswordBox);chgpwButton=document.createElement('BUTTON');chgpwButton.id='_im_changebutton';chgpwButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2005)));frontPanel.appendChild(chgpwButton);newPasswordMessage=document.createElement('DIV');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordMessage.style.textAlign='center';newPasswordMessage.style.textSize='10pt';newPasswordMessage.style.color='#994433'}
newPasswordMessage.id='_im_newpass_message';frontPanel.appendChild(newPasswordMessage)}
if(this.isOAuthAvailable){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);oAuthButton=document.createElement('BUTTON');oAuthButton.id='_im_oauthbutton';oAuthButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2014)));frontPanel.appendChild(oAuthButton)}
if(INTERMediatorOnPage.enrollPageURL){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);addingButton=document.createElement('BUTTON');addingButton.id='_im_enrollbutton';addingButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2022)));addingButton.onclick=function(){location.href=INTERMediatorOnPage.enrollPageURL};frontPanel.appendChild(addingButton)}
if(INTERMediatorOnPage.resetPageURL){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);addingButton=document.createElement('BUTTON');addingButton.id='_im_resetbutton';addingButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2023)));addingButton.onclick=function(){location.href=INTERMediatorOnPage.resetPageURL};frontPanel.appendChild(addingButton);resetMessage=document.createElement('div');resetMessage.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2024)));frontPanel.appendChild(resetMessage)}}
passwordBox.onkeydown=function(event){keyCode=(window.event)?window.event.which:event.keyCode;if(keyCode===13){authButton.onclick()}};userBox.value=INTERMediatorOnPage.authUser;userBox.onkeydown=function(event){keyCode=(window.event)?window.event.which:event.keyCode;if(keyCode===13){passwordBox.focus()}};authButton.onclick=function(){var inputUsername,inputPassword,challengeResult,messageNode;messageNode=document.getElementById('_im_newpass_message');if(messageNode){INTERMediatorLib.removeChildNodes(messageNode)}
inputUsername=document.getElementById('_im_username').value;inputPassword=document.getElementById('_im_password').value;if(inputUsername===''||inputPassword===''){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2013)));return}
INTERMediatorOnPage.authUser=inputUsername;bodyNode.removeChild(backBox);if(inputUsername!==''&&(INTERMediatorOnPage.authChallenge===null||INTERMediatorOnPage.authChallenge.length<24)){INTERMediatorOnPage.authHashedPassword='need-hash-pls';challengeResult=INTERMediator_DBAdapter.getChallenge();if(!challengeResult){INTERMediatorLog.flushMessage();return}}
encrypt.setPublicKey(INTERMediatorOnPage.publickey);INTERMediatorOnPage.authCryptedPassword=encrypt.encrypt(inputPassword);INTERMediatorOnPage.authHashedPassword=SHA1(inputPassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt;if(INTERMediatorOnPage.authUser.length>0){INTERMediatorOnPage.storeCredentialsToCookieOrStorage()}
doAfterAuth();INTERMediatorLog.flushMessage()};if(chgpwButton){var checkPolicyMethod=this.checkPasswordPolicy;chgpwButton.onclick=function(){var inputUsername,inputPassword,inputNewPassword,result,messageNode,message;messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode=document.getElementById('_im_newpass_message');INTERMediatorLib.removeChildNodes(messageNode);inputUsername=document.getElementById('_im_username').value;inputPassword=document.getElementById('_im_password').value;inputNewPassword=document.getElementById('_im_newpassword').value;if(inputUsername===''||inputPassword===''||inputNewPassword===''){messageNode=document.getElementById('_im_newpass_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2007)));return}
message=checkPolicyMethod(inputNewPassword,inputUsername,INTERMediatorOnPage.passwordPolicy);if(message.length>0){messageNode.appendChild(document.createTextNode(message.join(', ')));return}
result=INTERMediator_DBAdapter.changePassword(inputUsername,inputPassword,inputNewPassword);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(result?2009:2010)));INTERMediatorLog.flushMessage()}}
if(this.isOAuthAvailable&&oAuthButton){oAuthButton.onclick=function(){var authURL;INTERMediatorOnPage.setCookieDomainWide('_im_oauth_backurl',location.href,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_realm',INTERMediatorOnPage.realm,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_expired',INTERMediatorOnPage.authExpired,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_storing',INTERMediatorOnPage.authStoring,!0);authURL=INTERMediatorOnPage.oAuthBaseURL+'?scope='+encodeURIComponent(INTERMediatorOnPage.oAuthScope)+'&redirect_uri='+encodeURIComponent(INTERMediatorOnPage.oAuthRedirect)+'&response_type=code'+'&client_id='+encodeURIComponent(INTERMediatorOnPage.oAuthClientID);location.href=authURL}}
if(INTERMediatorOnPage.publickeysize<2048){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2025)))}else if(INTERMediatorOnPage.authCount>0){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2012)))}
window.scroll(0,0);userBox.focus();INTERMediatorOnPage.authCount++},authenticationError:function(){'use strict';var bodyNode,backBox,frontPanel;INTERMediatorOnPage.hideProgress();bodyNode=document.getElementsByTagName('BODY')[0];backBox=document.createElement('div');backBox.id='_im_autherrorback';bodyNode.insertBefore(backBox,bodyNode.childNodes[0]);if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.height='100%';backBox.style.width='100%';if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.backgroundImage='url('+INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=background-error.gif)'}
backBox.style.position='absolute';backBox.style.padding=' 50px 0 0 0';backBox.style.top='0';backBox.style.left='0';backBox.style.zIndex='999999'}
frontPanel=document.createElement('div');frontPanel.id='_im_autherrormessage';if(INTERMediatorOnPage.isSetDefaultStyle){frontPanel.style.width='240px';frontPanel.style.backgroundColor='#333333';frontPanel.style.color='#DD6666';frontPanel.style.fontSize='16pt';frontPanel.style.margin='50px auto 0 auto';frontPanel.style.padding='20px 4px 20px 4px';frontPanel.style.borderRadius='10px';frontPanel.style.position='relatvie';frontPanel.style.textAlign='Center'}
frontPanel.onclick=function(){bodyNode.removeChild(backBox)};backBox.appendChild(frontPanel);frontPanel.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2001)))},INTERMediatorCheckBrowser:function(deleteNode){'use strict';var positiveList,matchAgent,matchOS,versionStr,agent,os,judge=!1,specifiedVersion,versionNum,agentPos=-1,dotPos,bodyNode,elm,childElm,grandChildElm,i;positiveList=INTERMediatorOnPage.browserCompatibility();matchAgent=!1;matchOS=!1;if(positiveList.edge&&navigator.userAgent.indexOf('Edge/')>-1){positiveList={'edge':positiveList.edge}}else if(positiveList.trident&&navigator.userAgent.indexOf('Trident/')>-1){positiveList={'trident':positiveList.trident}}else if(positiveList.msie&&navigator.userAgent.indexOf('MSIE ')>-1){positiveList={'msie':positiveList.msie}}else if(positiveList.opera&&(navigator.userAgent.indexOf('Opera/')>-1||navigator.userAgent.indexOf('OPR/')>-1)){positiveList={'opera':positiveList.opera,'opr':positiveList.opera}}
for(agent in positiveList){if(positiveList.hasOwnProperty(agent)){if(navigator.userAgent.toUpperCase().indexOf(agent.toUpperCase())>-1){matchAgent=!0;if(positiveList[agent]instanceof Object){for(os in positiveList[agent]){if(positiveList[agent].hasOwnProperty(os)&&navigator.platform.toUpperCase().indexOf(os.toUpperCase())>-1){matchOS=!0;versionStr=positiveList[agent][os];break}}}else{matchOS=!0;versionStr=positiveList[agent];break}}}}
if(matchAgent&&matchOS){specifiedVersion=parseInt(versionStr,10);if(navigator.appVersion.indexOf('Edge/')>-1){agentPos=navigator.appVersion.indexOf('Edge/')+5}else if(navigator.appVersion.indexOf('Trident/')>-1){agentPos=navigator.appVersion.indexOf('Trident/')+8}else if(navigator.appVersion.indexOf('MSIE ')>-1){agentPos=navigator.appVersion.indexOf('MSIE ')+5}else if(navigator.appVersion.indexOf('OPR/')>-1){agentPos=navigator.appVersion.indexOf('OPR/')+4}else if(navigator.appVersion.indexOf('Opera/')>-1){agentPos=navigator.appVersion.indexOf('Opera/')+6}else if(navigator.appVersion.indexOf('Chrome/')>-1){agentPos=navigator.appVersion.indexOf('Chrome/')+7}else if(navigator.appVersion.indexOf('Safari/')>-1&&navigator.appVersion.indexOf('Version/')>-1){agentPos=navigator.appVersion.indexOf('Version/')+8}else if(navigator.userAgent.indexOf('Firefox/')>-1){agentPos=navigator.userAgent.indexOf('Firefox/')+8}else if(navigator.appVersion.indexOf('WebKit/')>-1){agentPos=navigator.appVersion.indexOf('WebKit/')+7}
if(agentPos>-1){if(navigator.userAgent.indexOf('Firefox/')>-1){dotPos=navigator.userAgent.indexOf('.',agentPos);versionNum=parseInt(navigator.userAgent.substring(agentPos,dotPos),10)}else{dotPos=navigator.appVersion.indexOf('.',agentPos);versionNum=parseInt(navigator.appVersion.substring(agentPos,dotPos),10)}}else{dotPos=navigator.appVersion.indexOf('.');versionNum=parseInt(navigator.appVersion.substring(0,dotPos),10)}
if(INTERMediator.isTrident){specifiedVersion=specifiedVersion+4}
if(versionStr.indexOf('-')>-1){judge=(specifiedVersion>=versionNum);if(document.documentMode){judge=(specifiedVersion>=document.documentMode)}}else if(versionStr.indexOf('+')>-1){judge=(specifiedVersion<=versionNum);if(document.documentMode){judge=(specifiedVersion<=document.documentMode)}}else{judge=(specifiedVersion===versionNum);if(document.documentMode){judge=(specifiedVersion===document.documentMode)}}}
if(judge===!0){if(deleteNode){deleteNode.parentNode.removeChild(deleteNode)}}else{bodyNode=document.getElementsByTagName('BODY')[0];elm=document.createElement('div');elm.setAttribute('align','center');childElm=document.createElement('font');childElm.setAttribute('color','gray');grandChildElm=document.createElement('font');grandChildElm.setAttribute('size','+2');grandChildElm.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[1022]));childElm.appendChild(grandChildElm);childElm.appendChild(document.createElement('br'));childElm.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[1023]));childElm.appendChild(document.createElement('br'));childElm.appendChild(document.createTextNode(navigator.userAgent));elm.appendChild(childElm);for(i=bodyNode.childNodes.length-1;i>=0;i--){bodyNode.removeChild(bodyNode.childNodes[i])}
bodyNode.appendChild(elm)}
return judge},getNodeIdFromIMDefinition:function(imDefinition,fromNode,justFromNode){'use strict';console.error('INTERMediatorOnPage.getNodeIdFromIMDefinition method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'The alternative method is getNodeIdsHavingTargetFromNode or getNodeIdsHavingTargetFromRepeater.');var repeaterNode;if(justFromNode){repeaterNode=fromNode}else{repeaterNode=INTERMediatorLib.getParentRepeater(fromNode)}
return seekNode(repeaterNode,imDefinition);function seekNode(node,imDefinition){var children,i,nodeDefs,returnValue;if(node.nodeType!==1){return null}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[i])){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs.indexOf(imDefinition)>-1){returnValue=children[i].getAttribute('id');return returnValue}}
returnValue=seekNode(children[i],imDefinition);if(returnValue!==null){return returnValue}}}}
return null}},getNodeIdFromIMDefinitionOnEnclosure:function(imDefinition,fromNode){'use strict';console.error('INTERMediatorOnPage.getNodeIdFromIMDefinitionOnEnclosure method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'The alternative method is getNodeIdsHavingTargetFromEnclosure.');var repeaterNode;repeaterNode=INTERMediatorLib.getParentEnclosure(fromNode);return seekNode(repeaterNode,imDefinition);function seekNode(node,imDefinition){var children,i,nodeDefs,returnValue;if(node.nodeType!==1){return null}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[i])){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs.indexOf(imDefinition)>-1&&children[i].getAttribute){returnValue=children[i].getAttribute('id');return returnValue}}
returnValue=seekNode(children[i],imDefinition);if(returnValue!==null){return returnValue}}}}
return null}},getNodeIdsFromIMDefinition:function(imDefinition,fromNode,justFromNode){'use strict';var enclosureNode,nodeIds=[],i,j;if(justFromNode===!0){enclosureNode=[fromNode]}else if(justFromNode===!1){enclosureNode=[INTERMediatorLib.getParentEnclosure(fromNode)]}else{enclosureNode=INTERMediatorLib.getParentRepeaters(fromNode)}
if(!enclosureNode){return[]}
for(i=0;i<enclosureNode.length;i+=1){if(enclosureNode[i]!==null){if(Array.isArray(enclosureNode[i])){for(j=0;j<enclosureNode[i].length;j++){seekNode(enclosureNode[i][j],imDefinition)}}else{seekNode(enclosureNode[i],imDefinition)}}}
return nodeIds;function seekNode(node,imDefinition){var children,i,nodeDefs;if(node.nodeType!==1){return}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs&&nodeDefs.indexOf(imDefinition)>-1){if(children[i].getAttribute('id')){nodeIds.push(children[i].getAttribute('id'))}else{nodeIds.push(children[i])}}}
seekNode(children[i],imDefinition)}}}},getNodeIdsHavingTargetFromNode:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,!0)},getNodeIdsHavingTargetFromRepeater:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,'others')},getNodeIdsHavingTargetFromEnclosure:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,!1)},getKeyWithRealm:function(str){'use strict';if(INTERMediatorOnPage.realm.length>0){return str+'_'+INTERMediatorOnPage.realm}
return str},getCookie:function(key){'use strict';var s,i,targetKey;s=document.cookie.split('; ');targetKey=this.getKeyWithRealm(key);for(i=0;i<s.length;i++){if(s[i].indexOf(targetKey+'=')===0){return decodeURIComponent(s[i].substring(s[i].indexOf('=')+1))}}
return''},removeCookie:function(key){'use strict';document.cookie=this.getKeyWithRealm(key)+'=; path=/; max-age=0; expires=Thu, 1-Jan-1900 00:00:00 GMT;';document.cookie=this.getKeyWithRealm(key)+'=; max-age=0; expires=Thu, 1-Jan-1900 00:00:00 GMT;'},setCookie:function(key,val){'use strict';this.setCookieWorker(this.getKeyWithRealm(key),val,!1,INTERMediatorOnPage.authExpired)},setCookieDomainWide:function(key,val,noRealm){'use strict';var realKey;realKey=(noRealm===!0)?key:this.getKeyWithRealm(key);this.setCookieWorker(realKey,val,!0,INTERMediatorOnPage.authExpired)},setCookieWorker:function(key,val,isDomain,expired){'use strict';var cookieString;var d=new Date();d.setTime(d.getTime()+expired*1000);cookieString=key+'='+encodeURIComponent(val)+(isDomain?';path=/':'')+';';if(expired>0){cookieString+='max-age='+expired+';expires='+d.toUTCString()+';'}
if(document.URL.substring(0,8)==='https://'){cookieString+='secure;'}
document.cookie=cookieString},hideProgress:function(){'use strict';if(!INTERMediatorOnPage.isShowProgress){return}
var frontPanel,themeName;frontPanel=document.getElementById('_im_progress');if(frontPanel){themeName=INTERMediatorOnPage.getTheme().toLowerCase();if(themeName==='least'||themeName==='thosedays'){frontPanel.style.display='none'}else{frontPanel.style.transitionDuration='0.3s';frontPanel.style.opacity=0;frontPanel.style.zIndex=-9999}}},showProgress:function(){'use strict';if(!INTERMediatorOnPage.isShowProgress){return}
var brNode,bodyNode,frontPanel,imageProgress,imageIM,themeName=INTERMediatorOnPage.getTheme().toLowerCase();frontPanel=document.getElementById('_im_progress');if(!frontPanel){frontPanel=document.createElement('div');frontPanel.setAttribute('id','_im_progress');bodyNode=document.getElementsByTagName('BODY')[0];if(bodyNode.firstChild){bodyNode.insertBefore(frontPanel,bodyNode.firstChild)}else{bodyNode.appendChild(frontPanel)}
if(themeName==='least'||themeName==='thosedays'){imageIM=document.createElement('img');imageIM.setAttribute('id','_im_logo');imageIM.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=logo.gif');frontPanel.appendChild(imageIM);imageProgress=document.createElement('img');imageProgress.setAttribute('id','_im_animatedimage');imageProgress.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=inprogress.gif');frontPanel.appendChild(imageProgress);brNode=document.createElement('BR');brNode.setAttribute('clear','all');frontPanel.appendChild(brNode);frontPanel.appendChild(document.createTextNode('INTER-Mediator working'))}else{imageIM=document.createElement('img');imageIM.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=gears.svg');frontPanel.appendChild(imageIM)}}
if(themeName!=='least'&&themeName!=='thosedays'){frontPanel.style.transitionDuration='0';frontPanel.style.opacity=1.0;frontPanel.style.display='flex';frontPanel.style.zIndex=9999}},setReferenceToTheme:function(){'use strict';var headNode,linkElement,i,styleIndex=-1;headNode=document.getElementsByTagName('HEAD')[0];linkElement=document.createElement('link');linkElement.setAttribute('href',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=css');linkElement.setAttribute('rel','stylesheet');linkElement.setAttribute('type','text/css');for(i=0;i<headNode.childNodes.length;i++){if(headNode.childNodes[i]&&headNode.childNodes[i].nodeType===1&&headNode.childNodes[i].tagName==='LINK'&&headNode.childNodes[i].rel==='stylesheet'){styleIndex=i;break}}
if(styleIndex>-1){headNode.insertBefore(linkElement,headNode.childNodes[styleIndex])}else{headNode.appendChild(linkElement)}}};var IMLibContextPool={poolingContexts:null,clearAll:function(){'use strict';this.poolingContexts=null},registerContext:function(context){'use strict';if(this.poolingContexts===null){this.poolingContexts=[context]}else{this.poolingContexts.push(context)}},excludingNode:null,synchronize:function(context,recKey,key,value,target,portal){'use strict';var i,j,viewName,refNode,targetNodes,result=[],calcKey;viewName=context.viewName;if(this.poolingContexts===null){return null}
if(portal){for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].viewName===viewName&&this.poolingContexts[i].binding[recKey]!==undefined&&this.poolingContexts[i].binding[recKey][key]!==undefined&&this.poolingContexts[i].binding[recKey][key][portal]!==undefined&&this.poolingContexts[i].store[recKey]!==undefined&&this.poolingContexts[i].store[recKey][key]!==undefined&&this.poolingContexts[i].store[recKey][key][portal]!==undefined){this.poolingContexts[i].store[recKey][key][portal]=value;targetNodes=this.poolingContexts[i].binding[recKey][key][portal];for(j=0;j<targetNodes.length;j++){refNode=document.getElementById(targetNodes[j].id);if(refNode){IMLibElement.setValueToIMNode(refNode,targetNodes[j].target,value,!0);result.push(targetNodes[j].id)}}}}}else{for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].viewName===viewName&&this.poolingContexts[i].binding[recKey]!==undefined&&this.poolingContexts[i].binding[recKey][key]!==undefined&&this.poolingContexts[i].store[recKey]!==undefined&&this.poolingContexts[i].store[recKey][key]!==undefined){this.poolingContexts[i].store[recKey][key]=value;targetNodes=this.poolingContexts[i].binding[recKey][key];for(j=0;j<targetNodes.length;j++){refNode=document.getElementById(targetNodes[j].id);calcKey=targetNodes[j].id;if(targetNodes[j].target&&targetNodes[j].target.length>0){calcKey+=INTERMediator.separator+targetNodes[j].target}
if(refNode&&!(calcKey in IMLibCalc.calculateRequiredObject)){IMLibElement.setValueToIMNode(refNode,targetNodes[j].target,value,!0);result.push(targetNodes[j].id)}}}}}
return result},getContextInfoFromId:function(idValue,target){'use strict';var i,targetContext,element,linkInfo,nodeInfo,targetName,result=null;if(!idValue){return result}
element=document.getElementById(idValue);if(!element){return result}
linkInfo=INTERMediatorLib.getLinkedElementInfo(element);if(!linkInfo&&INTERMediatorLib.isWidgetElement(element.parentNode)){linkInfo=INTERMediatorLib.getLinkedElementInfo(element.parentNode)}
nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);targetName=target?target:'_im_no_target';if(this.poolingContexts===null){return null}
for(i=0;i<this.poolingContexts.length;i++){targetContext=this.poolingContexts[i];if(targetContext.contextInfo[idValue]&&targetContext.contextInfo[idValue][targetName]&&targetContext.contextInfo[idValue][targetName].context.contextName===nodeInfo.table){result=targetContext.contextInfo[idValue][targetName];return result}}
return null},getKeyFieldValueFromId:function(idValue,target){'use strict';var contextInfo=this.getContextInfoFromId(idValue,target);if(!contextInfo){return null}
var contextName=contextInfo.context.contextName;var contextDef=IMLibContextPool.getContextDef(contextName);if(!contextDef){return null}
var keyField=contextDef.key?contextDef.key:'id';return contextInfo.record.substr(keyField.length+1)},updateContext:function(idValue,target){'use strict';var contextInfo,value;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,target);value=IMLibElement.getValueFromIMNode(document.getElementById(idValue));if(contextInfo){contextInfo.context.setValue(contextInfo.record,contextInfo.field,value,!1,target,contextInfo.portal)}},getContextFromEnclosure:function(enclosureNode){'use strict';var i;for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].enclosureNode===enclosureNode){return this.poolingContexts[i]}}},contextFromEnclosureId:function(idValue){'use strict';var i,enclosure;if(!idValue){return!1}
for(i=0;i<this.poolingContexts.length;i++){enclosure=this.poolingContexts[i].enclosureNode;if(enclosure.getAttribute('id')===idValue){return this.poolingContexts[i]}}
return null},contextFromName:function(cName){'use strict';var i;if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName){return this.poolingContexts[i]}}
return null},getContextFromName:function(cName){'use strict';var i,result=[];if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName){result.push(this.poolingContexts[i])}}
return result},getContextsFromNameAndForeignValue:function(cName,fValue,parentKeyField){'use strict';var i,result=[];if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName&&this.poolingContexts[i].foreignValue[parentKeyField]===fValue){result.push(this.poolingContexts[i])}}
return result},dependingObjects:function(idValue){'use strict';var i,j,result=[];if(!idValue){return!1}
for(i=0;i<this.poolingContexts.length;i++){for(j=0;j<this.poolingContexts[i].dependingObject.length;j++){if(this.poolingContexts[i].dependingObject[j]===idValue){result.push(this.poolingContexts[i])}}}
return result.length===0?!1:result},getChildContexts:function(parentContext){'use strict';var i,childContexts=[];for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].parentContext===parentContext){childContexts.push(this.poolingContexts[i])}}
return childContexts},childContexts:null,removeContextsFromPool:function(contexts){'use strict';var i,regIds=[],delIds=[];for(i=0;i<this.poolingContexts.length;i++){if(contexts.indexOf(this.poolingContexts[i])>-1){regIds.push(this.poolingContexts[i].registeredId);delIds.push(i)}}
for(i=delIds.length-1;i>-1;i--){this.poolingContexts.splice(delIds[i],1)}
return regIds},removeRecordFromPool:function(repeaterIdValue){'use strict';var i,j,field,nodeIds=[],targetKeying,targetKeyingObj,parentKeying,relatedId,idValue,delNodes,contextAndKey,sameOriginContexts,countDeleteNodes;contextAndKey=getContextAndKeyFromId(repeaterIdValue);if(contextAndKey===null){return}
sameOriginContexts=this.getContextsWithSameOrigin(contextAndKey.context);targetKeying=contextAndKey.key;for(i=0;i<sameOriginContexts.length;i++){targetKeyingObj=sameOriginContexts[i].binding[targetKeying];for(field in targetKeyingObj){if(targetKeyingObj.hasOwnProperty(field)){for(j=0;j<targetKeyingObj[field].length;j++){if(nodeIds.indexOf(targetKeyingObj[field][j].id)<0){nodeIds.push(targetKeyingObj[field][j].id)}}}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){parentKeying=Object.keys(contextAndKey.context.binding)[0];relatedId=targetKeying.split('=')[1];if(sameOriginContexts[i].binding[parentKeying]&&sameOriginContexts[i].binding[parentKeying]._im_repeater&&sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId]&&sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId][0]){nodeIds.push(sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId][0].id)}}}
delNodes=[];for(i=0;i<sameOriginContexts.length;i++){for(idValue in sameOriginContexts[i].contextInfo){if(sameOriginContexts[i].contextInfo.hasOwnProperty(idValue)){if(nodeIds.indexOf(idValue)>=0){delete contextAndKey.context.contextInfo[idValue];delNodes.push(idValue)}}}
delete sameOriginContexts[i].binding[targetKeying];delete sameOriginContexts[i].store[targetKeying]}
countDeleteNodes=delNodes.length;IMLibElement.deleteNodes(delNodes);this.poolingContexts=this.poolingContexts.filter(function(context){return nodeIds.indexOf(context.enclosureNode.id)<0});return countDeleteNodes;function getContextAndKeyFromId(repeaterIdValue){var i,field,j,keying,foreignKey;for(i=0;i<IMLibContextPool.poolingContexts.length;i++){for(keying in IMLibContextPool.poolingContexts[i].binding){if(IMLibContextPool.poolingContexts[i].binding.hasOwnProperty(keying)){for(field in IMLibContextPool.poolingContexts[i].binding[keying]){if(IMLibContextPool.poolingContexts[i].binding[keying].hasOwnProperty(field)&&field==='_im_repeater'){for(j=0;j<IMLibContextPool.poolingContexts[i].binding[keying][field].length;j++){if(repeaterIdValue===IMLibContextPool.poolingContexts[i].binding[keying][field][j].id){return({context:IMLibContextPool.poolingContexts[i],key:keying})}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){for(foreignKey in IMLibContextPool.poolingContexts[i].binding[keying][field]){if(IMLibContextPool.poolingContexts[i].binding[keying][field].hasOwnProperty(foreignKey)){for(j=0;j<IMLibContextPool.poolingContexts[i].binding[keying][field][foreignKey].length;j++){if(repeaterIdValue===IMLibContextPool.poolingContexts[i].binding[keying][field][foreignKey][j].id){return({context:IMLibContextPool.poolingContexts[i],key:INTERMediatorOnPage.defaultKeyName+'='+foreignKey})}}}}}}}}}}
return null}},getContextsWithSameOrigin:function(originalContext){'use strict';var i,contexts=[],contextDef,isPortal=!1;contextDef=IMLibContextPool.getContextDef(originalContext.contextName);if(contextDef&&contextDef.relation){for(i in contextDef.relation){if(contextDef.relation.hasOwnProperty(i)&&contextDef.relation[i].portal){isPortal=!0;break}}}
for(i=0;i<IMLibContextPool.poolingContexts.length;i++){if(IMLibContextPool.poolingContexts[i].sourceName===originalContext.sourceName){if(!isPortal||originalContext.parentContext!==IMLibContextPool.poolingContexts[i]){contexts.push(IMLibContextPool.poolingContexts[i])}}}
return contexts},updateOnAnotherClient:function(eventName,info){'use strict';var i,j,k,entityName=info.entity,contextDef,contextView,keyField,recKey;if(eventName==='update'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){keyField=contextDef.key;recKey=keyField+'='+info.pkvalue;this.poolingContexts[i].setValue(recKey,info.field[0],info.value[0]);var bindingInfo=this.poolingContexts[i].binding[recKey][info.field[0]];for(j=0;j<bindingInfo.length;j++){var updateRequiredContext=IMLibContextPool.dependingObjects(bindingInfo[j].id);for(k=0;k<updateRequiredContext.length;k++){updateRequiredContext[k].foreignValue={};updateRequiredContext[k].foreignValue[info.field[0]]=info.value[0];if(updateRequiredContext[k]){INTERMediator.constructMain(updateRequiredContext[k])}}}}}
IMLibCalc.recalculation()}else if(eventName==='create'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){if(this.poolingContexts[i].isContaining(info.value[0])){INTERMediator.constructMain(this.poolingContexts[i],info.value)}}}
IMLibCalc.recalculation()}else if(eventName==='delete'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){this.poolingContexts[i].removeEntry(info.pkvalue)}}
IMLibCalc.recalculation()}},getMasterContext:function(){'use strict';var i,contextDef;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){contextDef=this.poolingContexts[i].getContextDef();if(contextDef['navi-control']&&contextDef['navi-control'].match(/master/)){return this.poolingContexts[i]}}
return null},getDetailContext:function(){'use strict';var i,contextDef;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){contextDef=this.poolingContexts[i].getContextDef();if(contextDef['navi-control']&&contextDef['navi-control'].match(/detail/)){return this.poolingContexts[i]}}
return null},getContextDef:function(contextName){'use strict';return INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',contextName)},getContextFromNodeId:function(nodeId){'use strict';var i,context,contextDef,rKey,fKey,pKey,isPortal,bindInfo;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];contextDef=context.getContextDef();isPortal=!1;if(contextDef.relation){for(rKey in contextDef.relation){if(contextDef.relation[rKey].portal){isPortal=!0}}}
for(rKey in context.binding){if(context.binding.hasOwnProperty(rKey)){for(fKey in context.binding[rKey]){if(isPortal){for(pKey in context.binding[rKey][fKey]){if(context.binding[rKey][fKey].hasOwnProperty(pKey)){bindInfo=context.binding[rKey][fKey][pKey];if(bindInfo.nodeId===nodeId){return context}}}}else{bindInfo=context.binding[rKey][fKey];if(bindInfo.nodeId===nodeId){return context}}}}}}
return null},getContextFromEnclosureNode:function(enclosureNode){'use strict';var i,context;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];if(context.enclosureNode===enclosureNode){return context}}
return null},generateContextObject:function(contextDef,enclosure,repeaters,repeatersOriginal){'use strict';var contextObj=new IMLibContext(contextDef.name);contextObj.contextDefinition=contextDef;contextObj.enclosureNode=enclosure;contextObj.repeaterNodes=repeaters;contextObj.original=repeatersOriginal;contextObj.sequencing=!0;return contextObj},getPagingContext:function(){'use strict';var i,context,contextDef;if(this.poolingContexts){for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];contextDef=context.getContextDef();if(contextDef.paging){return context}}}
return null}};var IMLibContext=function(contextName){'use strict';this.contextName=contextName;this.tableName=null;this.viewName=null;this.sourceName=null;this.contextDefinition=null;this.store={};this.binding={};this.contextInfo={};this.modified={};this.recordOrder=[];this.pendingOrder=[];IMLibContextPool.registerContext(this);this.foreignValue={};this.enclosureNode=null;this.repeaterNodes=null;this.dependingObject=[];this.original=null;this.nullAcceptable=!0;this.parentContext=null;this.registeredId=null;this.sequencing=!1;this.dependingParentObjectInfo=null;this.isPortal=!1;this.potalContainingRecordKV=null;this.setTable(this)};IMLibContext.prototype.updateFieldValue=function(idValue,succeedProc,errorProc,warnMultipleRecProc,warnOthersModifyProc){'use strict';var nodeInfo,contextInfo,linkInfo,changedObj,criteria,newValue;changedObj=document.getElementById(idValue);linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);if(INTERMediator.ignoreOptimisticLocking){IMLibContextPool.updateContext(idValue,nodeInfo.target);newValue=IMLibElement.getValueFromIMNode(changedObj);if(newValue!==null){criteria=contextInfo.record.split('=');INTERMediatorOnPage.retrieveAuthInfo();if(contextInfo.context.isPortal){criteria=contextInfo.context.potalContainingRecordKV.split('=');INTERMediator_DBAdapter.db_update_async({name:contextInfo.context.parentContext.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field+'.'+contextInfo.record.split('=')[1],value:newValue}]},succeedProc,errorProc)}else{criteria=contextInfo.record.split('=');INTERMediator_DBAdapter.db_update_async({name:contextInfo.context.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field,value:newValue}]},succeedProc,errorProc)}}}else{var targetContext=contextInfo.context;var parentContext,keyingComp;if(targetContext.isPortal===!0){parentContext=IMLibContextPool.getContextFromName(targetContext.sourceName)[0]}else{parentContext=targetContext.parentContext}
var targetField=contextInfo.field;if(targetContext.isPortal===!0){keyingComp=Object.keys(parentContext.store)[0].split('=')}else{keyingComp=(targetContext.isPortal?targetContext.potalContainingRecordKV:contextInfo.record).split('=')}
var keyingField=keyingComp[0];keyingComp.shift();var keyingValue=keyingComp.join('=');INTERMediator_DBAdapter.db_query_async({name:targetContext.isPortal?parentContext.contextName:targetContext.contextName,records:1,paging:!1,fields:[contextInfo.field],parentkeyvalue:null,conditions:[{field:keyingField,operator:'=',value:keyingValue}],useoffset:!1,primaryKeyOnly:!0},(function(){var targetFieldCapt=targetField;var contextInfoCapt=contextInfo;var targetContextCapt=targetContext;var changedObjectCapt=changedObj;var nodeInfoCapt=nodeInfo;var idValueCapt=idValue;return function(result){var initialvalue,newValue,isOthersModified,currentFieldVal,recordset=[],portalRecords,index,keyField,keyingComp,criteria;if(targetContextCapt.isPortal){portalRecords=targetContextCapt.getPortalRecordsetImpl(result.dbresult[0],targetContextCapt.contextName);keyField=targetContextCapt.getKeyField();keyingComp=contextInfoCapt.record.split('=');for(index=0;index<portalRecords.length;index++){if(portalRecords[index][keyField]===keyingComp[1]){recordset.push(portalRecords[index]);break}}}else{recordset=result.dbresult}
if(!recordset||!recordset[0]||recordset[0][targetFieldCapt]===undefined){errorProc();return}
if(result.resultCount>1){if(!warnMultipleRecProc()){return}}
if(targetContextCapt.isPortal){for(var i=0;i<recordset.length;i++){if(recordset[i][INTERMediatorOnPage.defaultKeyName]===contextInfo.record.split('=')[1]){currentFieldVal=recordset[i][targetFieldCapt];break}}
initialvalue=targetContextCapt.getValue(Object.keys(parentContext.store)[0],targetFieldCapt,INTERMediatorOnPage.defaultKeyName+'='+recordset[i][INTERMediatorOnPage.defaultKeyName])}else{currentFieldVal=recordset[0][targetFieldCapt];initialvalue=targetContextCapt.getValue(contextInfoCapt.record,targetFieldCapt)}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){if(typeof(initialvalue)==='number'&&typeof(currentFieldVal)==='string'){initialvalue=initialvalue.toString()}}
isOthersModified=checkSameValue(initialvalue,currentFieldVal);if(changedObjectCapt.tagName==='INPUT'&&changedObjectCapt.getAttribute('type')==='checkbox'){if(initialvalue===changedObjectCapt.value){isOthersModified=!1}else if(!parseInt(currentFieldVal)){isOthersModified=!1}else{isOthersModified=!0}}
if(isOthersModified){newValue=IMLibElement.getValueFromIMNode(changedObjectCapt);if(!warnOthersModifyProc(initialvalue,newValue,currentFieldVal)){return}
INTERMediatorOnPage.retrieveAuthInfo()}
IMLibContextPool.updateContext(idValueCapt,nodeInfoCapt.target);newValue=IMLibElement.getValueFromIMNode(changedObjectCapt);if(newValue!==null){if(targetContextCapt.isPortal){if(targetContextCapt.potalContainingRecordKV==null){criteria=Object.keys(targetContextCapt.foreignValue);criteria[1]=targetContextCapt.foreignValue[criteria[0]]}else{criteria=targetContextCapt.potalContainingRecordKV.split('=')}
INTERMediator_DBAdapter.db_update_async({name:targetContextCapt.isPortal?targetContextCapt.sourceName:targetContextCapt.parentContext.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfoCapt.field+'.'+contextInfoCapt.record.split('=')[1],value:newValue}]},succeedProc,errorProc)}else{criteria=contextInfoCapt.record.split('=');INTERMediator_DBAdapter.db_update_async({name:targetContextCapt.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field,value:newValue}]},succeedProc,errorProc)}}}})(),function(){INTERMediatorOnPage.hideProgress();INTERMediatorLog.setErrorMessage('Error in valueChange method.','EXCEPTION-1')})}
var handleAsNullValue=['0000-00-00','0000-00-00 00:00:00'];function checkSameValue(initialValue,currentFieldVal){if(handleAsNullValue.indexOf(initialValue)>=0){initialValue=''}
if(handleAsNullValue.indexOf(currentFieldVal)>=0){currentFieldVal=''}
return initialValue!==currentFieldVal}};IMLibContext.prototype.getKeyField=function(){'use strict';var keyField;if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){if(this.isPortal){keyField=INTERMediatorOnPage.defaultKeyName}else{keyField=this.contextDefinition.key?this.contextDefinition.key:INTERMediatorOnPage.defaultKeyName}}else{keyField=this.contextDefinition.key?this.contextDefinition.key:'id'}
return keyField};IMLibContext.prototype.getCalculationFields=function(){'use strict';var calcDef=this.contextDefinition.calculation;var calcFields=[],ix;for(ix in calcDef){if(calcDef.hasOwnProperty(ix)){calcFields.push(calcDef[ix].field)}}
return calcFields};IMLibContext.prototype.isUseLimit=function(){'use strict';var useLimit=!1;if(this.contextDefinition.records&&this.contextDefinition.paging){useLimit=!0}
return useLimit};IMLibContext.prototype.getPortalRecords=function(){'use strict';var targetRecords={};if(!this.isPortal){return null}
if(this.contextDefinition&&this.contextDefinition.currentrecord){targetRecords.recordset=this.getPortalRecordsetImpl(this.contextDefinition.currentrecord,this.contextName)}else{targetRecords.recordset=this.getPortalRecordsetImpl(this.parentContext.store[this.potalContainingRecordKV],this.contextName)}
return targetRecords};IMLibContext.prototype.getPortalRecordsetImpl=function(store,contextName){'use strict';var result,recId,recordset,key,contextDef;recordset=[];if(store[0]){if(!store[0][contextName]){for(key in store[0]){if(store[0].hasOwnProperty(key)){contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',key);if(contextName===contextDef.view&&!store[0][contextName]){contextName=key;break}}}}
if(store[0][contextName]){result=store[0][contextName];for(recId in result){if(result.hasOwnProperty(recId)&&isFinite(recId)){recordset.push(result[recId])}}}}
return recordset};IMLibContext.prototype.getRecordNumber=function(){'use strict';var recordNumber,key,value,keyParams;if(this.contextDefinition['navi-control']&&this.contextDefinition['navi-control']==='detail'){recordNumber=1}else{recordNumber=parseInt(this.contextDefinition.records,10);for(key in INTERMediator.recordLimit){if(INTERMediator.recordLimit.hasOwnProperty(key)){value=String(INTERMediator.recordLimit[key]);if(key===this.contextDefinition.name&&value.length>0){recordNumber=parseInt(value);INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}}}
if(parseInt(INTERMediator.pagedSize,10)>0){recordNumber=INTERMediator.pagedSize;INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}
for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){value=String(IMLibLocalContext.store[key]);keyParams=key.split(':');if(keyParams&&keyParams.length>1&&keyParams[1].trim()===this.contextDefinition.name&&value.length>0&&keyParams[0].trim()==='limitnumber'){recordNumber=parseInt(value);INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}}}
if(!this.contextDefinition.relation&&this.contextDefinition.paging&&Boolean(this.contextDefinition.paging)===!0){INTERMediator.setLocalProperty('_im_pagedSize',recordNumber);INTERMediator.pagedSize=recordNumber}}
return recordNumber};IMLibContext.prototype.setRelationWithParent=function(currentRecord,parentObjectInfo,parentContext){'use strict';var relationDef,index,joinField,fieldName,i;this.parentContext=parentContext;if(currentRecord){try{relationDef=this.contextDefinition.relation;if(relationDef){for(index in relationDef){if(relationDef.hasOwnProperty(index)){if(Boolean(relationDef[index].portal)===!0){this.isPortal=!0;this.potalContainingRecordKV=INTERMediatorOnPage.defaultKeyName+'='+currentRecord[INTERMediatorOnPage.defaultKeyName]}
joinField=relationDef[index]['join-field'];this.addForeignValue(joinField,currentRecord[joinField]);for(fieldName in parentObjectInfo){if(fieldName===relationDef[index]['join-field']){for(i=0;i<parentObjectInfo[fieldName].length;i++){this.addDependingObject(parentObjectInfo[fieldName][i])}
this.dependingParentObjectInfo=JSON.parse(JSON.stringify(parentObjectInfo))}}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-25')}}}};IMLibContext.prototype.getInsertOrder=function(){'use strict';var cName,sortKeys=[],contextDef,i,sortFields=[],sortDirections=[];for(cName in INTERMediator.additionalSortKey){if(cName===this.contextName){sortKeys.push(INTERMediator.additionalSortKey[cName])}}
contextDef=this.getContextDef();if(contextDef.sort){sortKeys.push(contextDef.sort)}
for(i=0;i<sortKeys.length;i++){if(sortFields.indexOf(sortKeys[i].field)<0){sortFields.push(sortKeys[i].field);sortDirections.push(sortKeys[i].direction)}}};IMLibContext.prototype.indexingArray=function(keyField){'use strict';var ar=[],key,counter=0;for(key in this.store){if(this.store.hasOwnProperty(key)){ar[counter]=this.store[key][keyField];counter+=1}}
return ar};IMLibContext.prototype.clearAll=function(){'use strict';this.store={};this.binding={}};IMLibContext.prototype.setContextName=function(name){'use strict';this.contextName=name};IMLibContext.prototype.getContextDef=function(){'use strict';return INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName)};IMLibContext.prototype.setTableName=function(name){'use strict';this.tableName=name};IMLibContext.prototype.setViewName=function(name){'use strict';this.viewName=name};IMLibContext.prototype.addDependingObject=function(idNumber){'use strict';this.dependingObject.push(idNumber)};IMLibContext.prototype.addForeignValue=function(field,value){'use strict';this.foreignValue[field]=value};IMLibContext.prototype.setOriginal=function(repeaters){'use strict';var i;this.original=[];for(i=0;i<repeaters.length;i++){this.original.push(repeaters[i].cloneNode(!0))}};IMLibContext.prototype.setTable=function(context){'use strict';var contextDef;if(!context||!INTERMediatorOnPage.getDataSources){this.tableName=this.contextName;this.viewName=this.contextName;this.sourceName=this.contextName;return}
contextDef=this.getContextDef();if(contextDef){this.viewName=contextDef.view?contextDef.view:contextDef.name;this.tableName=contextDef.table?contextDef.table:contextDef.name;this.sourceName=(contextDef.source?contextDef.source:(contextDef.table?contextDef.table:(contextDef.view?contextDef.view:contextDef.name)))}};IMLibContext.prototype.removeContext=function(){'use strict';var regIds=[],childContexts=[];seekRemovingContext(this);regIds=IMLibContextPool.removeContextsFromPool(childContexts);while(this.enclosureNode.firstChild){this.enclosureNode.removeChild(this.enclosureNode.firstChild)}
INTERMediator_DBAdapter.unregister(regIds);function seekRemovingContext(context){var i,myChildren;childContexts.push(context);regIds.push(context.registeredId);myChildren=IMLibContextPool.getChildContexts(context);for(i=0;i<myChildren.length;i++){seekRemovingContext(myChildren[i])}}};IMLibContext.prototype.setModified=function(recKey,key,value){'use strict';if(this.modified[recKey]===undefined){this.modified[recKey]={}}
this.modified[recKey][key]=value};IMLibContext.prototype.getModified=function(){'use strict';return this.modified};IMLibContext.prototype.clearModified=function(){'use strict';this.modified={}};IMLibContext.prototype.getContextDef=function(){'use strict';var contextDef;contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName);return contextDef};IMLibContext.prototype.checkOrder=function(oneRecord,isDebug){'use strict';var i,fields=[],directions=[],oneSortKey,condtextDef,lower,upper,index,targetRecord,contextValue,checkingValue,stop;if(isDebug!==!0){if(INTERMediator&&INTERMediator.additionalSortKey[this.contextName]){for(i=0;i<INTERMediator.additionalSortKey[this.contextName].length;i++){oneSortKey=INTERMediator.additionalSortKey[this.contextName][i];if(!(oneSortKey.field in fields)){fields.push(oneSortKey.field);directions.push(oneSortKey.direction)}}}
condtextDef=this.getContextDef();if(condtextDef&&condtextDef.sort){for(i=0;i<condtextDef.sort.length;i++){oneSortKey=condtextDef.sort[i];if(!(oneSortKey.field in fields)){fields.push(oneSortKey.field);directions.push(oneSortKey.direction)}}}}else{fields=['field1','field2']}
lower=0;upper=this.recordOrder.length;for(i=0;i<fields.length;i++){if(oneRecord[fields[i]]){index=parseInt((upper+lower)/2);do{targetRecord=this.store[this.recordOrder[index]];contextValue=targetRecord[fields[i]];checkingValue=oneRecord[fields[i]];if(contextValue<checkingValue){lower=index}else if(contextValue>checkingValue){upper=index}else{lower=upper=index}
index=parseInt((upper+lower)/2)}while(upper-lower>1);targetRecord=this.store[this.recordOrder[index]];contextValue=targetRecord[fields[i]];if(contextValue===checkingValue){lower=upper=index;stop=!1;do{targetRecord=this.store[this.recordOrder[lower-1]];if(targetRecord&&targetRecord[fields[i]]&&targetRecord[fields[i]]===checkingValue){lower--}else{stop=!0}}while(!stop);stop=!1;do{targetRecord=this.store[this.recordOrder[upper+1]];if(targetRecord&&targetRecord[fields[i]]&&targetRecord[fields[i]]===checkingValue){upper++}else{stop=!0}}while(!stop);if(lower===upper){break}
upper++}else if(contextValue<checkingValue){break}else if(contextValue>checkingValue){index--;break}}}
return index};IMLibContext.prototype.rearrangePendingOrder=function(isDebug){'use strict';var i,index,targetRecord;for(i=0;i<this.pendingOrder.length;i++){targetRecord=this.store[this.pendingOrder[i]];index=this.checkOrder(targetRecord,isDebug);if(index>=-1){this.recordOrder.splice(index+1,0,this.pendingOrder[i])}}
this.pendingOrder=[]};IMLibContext.prototype.getRepeaterEndNode=function(index){'use strict';var nodeId,field,repeaters=[],repeater,node,i,enclosure,children;var recKey=this.recordOrder[index];for(field in this.binding[recKey]){if(this.binding[recKey].hasOwnProperty(field)){nodeId=this.binding[recKey][field].nodeId;repeater=INTERMediatorLib.getParentRepeaters(document.getElementById(nodeId));for(i=0;i<repeater.length;i+=1){if(!(repeater[i]in repeaters)){repeaters.push(repeater[i])}}}}
if(repeaters.length<1){return null}
node=repeaters[0];enclosure=INTERMediatorLib.getParentEnclosure(node);children=enclosure.childNodes;for(i=0;i<children.length;i++){if(children[i]in repeaters){node=repeaters[i];break}}
return node};IMLibContext.prototype.storeRecords=function(records){'use strict';var ix,record,field,keyField,keyValue;var contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName);keyField=contextDef.key?contextDef.key:'id';if(records.recordset){for(ix=0;ix<records.recordset.length;ix++){record=records.recordset[ix];for(field in record){if(record.hasOwnProperty(field)){keyValue=record[keyField]?record[keyField]:ix;this.setValue(keyField+'='+keyValue,field,record[field])}}}}};IMLibContext.prototype.getDataAtLastRecord=function(key){'use strict';var lastKey;var storekeys=Object.keys(this.store);if(storekeys.length>0){lastKey=storekeys[storekeys.length-1];return this.getValue(lastKey,key)}
return undefined};IMLibContext.prototype.setDataAtLastRecord=function(key,value){'use strict';var lastKey,keyAndValue,contextName;var storekeys=Object.keys(this.store);if(storekeys.length>0){lastKey=storekeys[storekeys.length-1];this.setValue(lastKey,key,value);contextName=this.contextName;keyAndValue=lastKey.split('=');IMLibQueue.setTask((function(){var params={name:contextName,conditions:[{field:keyAndValue[0],operator:'=',value:keyAndValue[1]}],dataset:[{field:key,value:value}]};return function(completeTask){INTERMediator_DBAdapter.db_update(params);IMLibCalc.recalculation();INTERMediatorLog.flushMessage();completeTask()}})())}};IMLibContext.prototype.setDataWithKey=function(pkValue,key,value){'use strict';var targetKey,contextDef,storeElements,contextName;contextDef=this.getContextDef();if(!contextDef){return}
targetKey=contextDef.key+'='+pkValue;storeElements=this.store[targetKey];if(storeElements){this.setValue(targetKey,key,value);contextName=this.contextName;IMLibQueue.setTask((function(){var params={name:contextName,conditions:[{field:contextDef.key,operator:'=',value:pkValue}],dataset:[{field:key,value:value}]};return function(completeTask){INTERMediator_DBAdapter.db_update(params);INTERMediatorLog.flushMessage();completeTask()}})())}};IMLibContext.prototype.setValue=function(recKey,key,value,nodeId,target,portal){'use strict';var updatedNodeIds=null;if(portal){console.error('Using the portal parameter in IMLibContext.setValue')}
if(recKey){if(this.store[recKey]===undefined){this.store[recKey]={}}
if(portal&&this.store[recKey][key]===undefined){this.store[recKey][key]={}}
if(this.binding[recKey]===undefined){this.binding[recKey]={};if(this.sequencing){this.recordOrder.push(recKey)}else{this.pendingOrder.push(recKey)}}
if(this.binding[recKey][key]===undefined){this.binding[recKey][key]=[]}
if(portal&&this.binding[recKey][key][portal]===undefined){if(this.binding[recKey][key].length<1){this.binding[recKey][key]={}}
this.binding[recKey][key][portal]=[]}
if(key){if(portal){this.store[recKey][key]=value}else{this.store[recKey][key]=value}
if(nodeId){if(portal){this.binding[recKey][key].push({id:nodeId,target:target})}else{this.binding[recKey][key].push({id:nodeId,target:target})}
if(this.contextInfo[nodeId]===undefined){this.contextInfo[nodeId]={}}
this.contextInfo[nodeId][target?target:'_im_no_target']={context:this,record:recKey,field:key};if(portal){this.contextInfo[nodeId][target?target:'_im_no_target'].portal=portal}}else{if(INTERMediator.partialConstructing){updatedNodeIds=IMLibContextPool.synchronize(this,recKey,key,value,target,portal)}}}}
return updatedNodeIds};IMLibContext.prototype.getValue=function(recKey,key,portal){'use strict';var value;try{if(portal){value=this.store[portal][key]}else{value=this.store[recKey][key]}
if(Array.isArray(value)){value=value.join()}
return value===undefined?null:value}catch(ex){return null}};IMLibContext.prototype.isValueUndefined=function(recKey,key,portal){'use strict';var value,tableOccurence,relatedRecId;try{if(portal){tableOccurence=key.split('::')[0];relatedRecId=portal.split('=')[1];value=this.store[recKey][0][tableOccurence][relatedRecId][key]}else{value=this.store[recKey][key]}
return value===undefined?!0:!1}catch(ex){return null}};IMLibContext.prototype.getContextInfo=function(nodeId,target){'use strict';try{var info=this.contextInfo[nodeId][target?target:'_im_no_target'];return info===undefined?null:info}catch(ex){return null}};IMLibContext.prototype.getContextValue=function(nodeId,target){'use strict';try{var info=this.contextInfo[nodeId][target?target:'_im_no_target'];var value=info.context.getValue(info.record,info.field);return value===undefined?null:value}catch(ex){return null}};IMLibContext.prototype.getContextRecord=function(nodeId){'use strict';var infos,keys,i;try{infos=this.contextInfo[nodeId];keys=Object.keys(infos);for(i=0;i<keys.length;i++){if(infos[keys[i]]){return this.store[infos[keys[i]].record]}}
return null}catch(ex){return null}};IMLibContext.prototype.removeEntry=function(pkvalue){'use strict';var keyField,keying,bindingInfo,contextDef,targetNode,repeaterNodes,i,removingNodeIds=[];contextDef=this.getContextDef();keyField=contextDef.key;keying=keyField+'='+pkvalue;bindingInfo=this.binding[keying];if(bindingInfo){repeaterNodes=bindingInfo._im_repeater;if(repeaterNodes){for(i=0;i<repeaterNodes.length;i++){removingNodeIds.push(repeaterNodes[i].id)}}}
if(removingNodeIds.length>0){for(i=0;i<removingNodeIds.length;i++){IMLibContextPool.removeRecordFromPool(removingNodeIds[i])}
for(i=0;i<removingNodeIds.length;i++){targetNode=document.getElementById(removingNodeIds[i]);if(targetNode){targetNode.parentNode.removeChild(targetNode)}}}};IMLibContext.prototype.isContaining=function(value){'use strict';var contextDef,contextName,checkResult=[],i,fieldName,result,opePosition,leftHand,rightHand,leftResult,rightResult;contextDef=this.getContextDef();contextName=contextDef.name;if(contextDef.query){for(i in contextDef.query){if(contextDef.query.hasOwnProperty(i)){checkResult.push(checkCondition(contextDef.query[i],value))}}}
if(INTERMediator.additionalCondition[contextName]){for(i=0;i<INTERMediator.additionalCondition[contextName].length;i++){checkResult.push(checkCondition(INTERMediator.additionalCondition[contextName][i],value))}}
result=!0;if(checkResult.length!==0){opePosition=checkResult.indexOf('D');if(opePosition>-1){leftHand=checkResult.slice(0,opePosition);rightHand=opePosition.slice(opePosition+1);if(rightHand.length===0){result=(leftHand.indexOf(!1)<0)}else{leftResult=(leftHand.indexOf(!1)<0);rightResult=(rightHand.indexOf(!1)<0);result=leftResult||rightResult}}else{opePosition=checkResult.indexOf('EX');if(opePosition>-1){leftHand=checkResult.slice(0,opePosition);rightHand=opePosition.slice(opePosition+1);if(rightHand.length===0){result=(leftHand.indexOf(!0)>-1)}else{leftResult=(leftHand.indexOf(!0)>-1);rightResult=(rightHand.indexOf(!0)>-1);result=leftResult&&rightResult}}else{opePosition=checkResult.indexOf(!1);if(opePosition>-1){result=(checkResult.indexOf(!1)<0)}}}
if(result===!1){return!1}}
if(this.foreignValue){for(fieldName in this.foreignValue){if(contextDef.relation){for(i in contextDef.relation){if(contextDef.relation[i]['join-field']===fieldName){result&=(checkCondition({field:contextDef.relation[i]['foreign-key'],operator:'=',value:this.foreignValue[fieldName]},value))}}}}}
return result;function checkCondition(conditionDef,oneRecord){var realValue;if(conditionDef.field==='__operation__'){return conditionDef.operator==='ex'?'EX':'D'}
realValue=oneRecord[conditionDef.field];if(!realValue){return!1}
switch(conditionDef.operator){case '=':case 'eq':return String(realValue)===String(conditionDef.value);case '>':case 'gt':return realValue>conditionDef.value;case '<':case 'lt':return realValue<conditionDef.value;case '>=':case 'gte':return realValue>=conditionDef.value;case '<=':case 'lte':return realValue<=conditionDef.value;case '!=':case 'neq':return String(realValue)!==String(conditionDef.value);default:return!1}}};IMLibContext.prototype.insertEntry=function(pkvalue,fields,values){'use strict';var i,field,value;for(i=0;i<fields.length;i++){field=fields[i];value=values[i];this.setValue(pkvalue,field,value)}};var IMLibLocalContext={contextName:'_',store:{},binding:{},clearAll:function(){'use strict';this.store={}},setValue:function(key,value,withoutArchive){'use strict';var i,hasUpdated,refIds,node;hasUpdated=!1;if(key){if(value===undefined||value===null){delete this.store[key]}else{this.store[key]=value;hasUpdated=!0;refIds=this.binding[key];if(refIds){for(i=0;i<refIds.length;i++){node=document.getElementById(refIds[i]);IMLibElement.setValueToIMNode(node,'',value,!0)}}}}
if(hasUpdated&&withoutArchive!==!0){this.archive()}},getValue:function(key){'use strict';var value=this.store[key];return value===undefined?null:value},archive:function(){'use strict';var jsonString,key,searchLen,hashLen,trailLen;INTERMediatorOnPage.removeCookie('_im_localcontext');if(INTERMediator.isIE&&INTERMediator.ieVersion<9){this.store._im_additionalCondition=INTERMediator.additionalCondition;this.store._im_additionalSortKey=INTERMediator.additionalSortKey;this.store._im_startFrom=INTERMediator.startFrom;this.store._im_pagedSize=INTERMediator.pagedSize;jsonString=JSON.stringify(this.store,function(k,v){return v===''?'':v})}else{jsonString=JSON.stringify(this.store)}
if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{searchLen=location.search?location.search.length:0;hashLen=location.hash?location.hash.length:0;trailLen=searchLen+hashLen;key='_im_localcontext'+document.URL.toString();key=(trailLen>0)?key.slice(0,-trailLen):key;sessionStorage.setItem(key,jsonString)}catch(ex){INTERMediatorOnPage.setCookieWorker('_im_localcontext',jsonString,!1,0)}}else{INTERMediatorOnPage.setCookieWorker('_im_localcontext',jsonString,!1,0)}},unarchive:function(){'use strict';var localContext='',searchLen,hashLen,key,trailLen;if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{searchLen=location.search?location.search.length:0;hashLen=location.hash?location.hash.length:0;trailLen=searchLen+hashLen;key='_im_localcontext'+document.URL.toString();key=(trailLen>0)?key.slice(0,-trailLen):key;localContext=sessionStorage.getItem(key)}catch(ex){localContext=INTERMediatorOnPage.getCookie('_im_localcontext')}}else{localContext=INTERMediatorOnPage.getCookie('_im_localcontext')}
if(localContext&&localContext.length>0){this.store=JSON.parse(localContext);if(INTERMediator.isIE&&INTERMediator.ieVersion<9){if(this.store._im_additionalCondition){INTERMediator.additionalCondition=this.store._im_additionalCondition}
if(this.store._im_additionalSortKey){INTERMediator.additionalSortKey=this.store._im_additionalSortKey}
if(this.store._im_startFrom){INTERMediator.startFrom=this.store._im_startFrom}
if(this.store._im_pagedSize){INTERMediator.pagedSize=this.store._im_pagedSize}}
this.updateAll(!0)}},bindingNode:function(node){'use strict';var linkInfos,nodeInfo,idValue,i,j,value,params,unbinding,unexistId,dataImControl;if(node.nodeType!==1){return}
linkInfos=INTERMediatorLib.getLinkedElementInfo(node);dataImControl=node.getAttribute('data-im-control');unbinding=(dataImControl&&dataImControl==='unbind');for(i=0;i<linkInfos.length;i++){nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===this.contextName){if(!node.id){node.id=INTERMediator.nextIdValue()}
idValue=node.id;if(!this.binding[nodeInfo.field]){this.binding[nodeInfo.field]=[]}
if(this.binding[nodeInfo.field].indexOf(idValue)<0&&!unbinding){this.binding[nodeInfo.field].push(idValue)}
unexistId=-1;while(unexistId>=0){for(j=0;j<this.binding[nodeInfo.field].length;j++){if(!document.getElementById(this.binding[nodeInfo.field][j])){unexistId=j}}
if(unexistId>=0){delete this.binding[nodeInfo.field][unexistId]}}
value=this.store[nodeInfo.field];IMLibElement.setValueToIMNode(node,nodeInfo.target,value,!0);params=nodeInfo.field.split(':');switch(params[0]){case 'addorder':IMLibMouseEventDispatch.setExecute(idValue,IMLibUI.eventAddOrderHandler);break;case 'update':IMLibMouseEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})());break;case 'condition':var attrType=node.getAttribute('type');if(attrType&&attrType==='text'){IMLibKeyDownEventDispatch.setExecuteByCode(idValue,13,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})())}else if(attrType&&(attrType==='checkbox'||attrType==='radio')){IMLibChangeEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})())}
break;case 'limitnumber':if(node.value){this.store[nodeInfo.field]=node.value}
IMLibChangeEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})());node.setAttribute('data-imchangeadded','set');break;default:IMLibChangeEventDispatch.setExecute(idValue,IMLibLocalContext.update);break}}}},update:function(idValue){'use strict';IMLibLocalContext.updateFromNodeValue(idValue)},updateFromNodeValue:function(idValue){'use strict';var node,nodeValue,linkInfos,nodeInfo,i;node=document.getElementById(idValue);nodeValue=IMLibElement.getValueFromIMNode(node);linkInfos=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<linkInfos.length;i++){IMLibLocalContext.store[linkInfos[i]]=nodeValue;nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===IMLibLocalContext.contextName){IMLibLocalContext.setValue(nodeInfo.field,nodeValue)}}},updateFromStore:function(idValue){'use strict';var node,nodeValue,linkInfos,nodeInfo,i,target,comp;node=document.getElementById(idValue);target=node.getAttribute('data-im');comp=target.split(INTERMediator.separator);if(comp[1]){nodeValue=IMLibLocalContext.store[comp[1]];linkInfos=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<linkInfos.length;i++){IMLibLocalContext.store[linkInfos[i]]=nodeValue;nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===IMLibLocalContext.contextName){IMLibLocalContext.setValue(nodeInfo.field,nodeValue)}}}},updateAll:function(isStore){'use strict';var index,key,nodeIds,idValue,targetNode;for(key in IMLibLocalContext.binding){if(IMLibLocalContext.binding.hasOwnProperty(key)){nodeIds=IMLibLocalContext.binding[key];for(index=0;index<nodeIds.length;index++){idValue=nodeIds[index];targetNode=document.getElementById(idValue);if(targetNode&&(targetNode.tagName==='INPUT'||targetNode.tagName==='TEXTAREA'||targetNode.tagName==='SELECT')){if(isStore===!0){IMLibLocalContext.updateFromStore(idValue)}else{IMLibLocalContext.updateFromNodeValue(idValue)}
break}}}}},checkedBinding:[],bindingDescendant:function(rootNode){'use strict';var self=this;seek(rootNode);IMLibLocalContext.checkedBinding.push(rootNode);function seek(node){var children,i;if(node!==rootNode&&IMLibLocalContext.checkedBinding.indexOf(node)>-1){return}
if(node.nodeType===1){try{self.bindingNode(node);children=node.childNodes;if(children){for(i=0;i<children.length;i++){seek(children[i])}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-31')}}}}}};var IMLib={nl_char:'\n',cr_char:'\r',tab_char:'\t',singleQuote_char:'\'',doubleQuote_char:'"',backSlash_char:'\\',get zerolength_str(){'use strict';return''},set zerolength_str(value){},get crlf_str(){'use strict';return'\r\n'},set crlf_str(value){}};var INTERMediatorLib={ignoreEnclosureRepeaterClassName:'_im_ignore_enc_rep',ignoreEnclosureRepeaterControlName:'ignore_enc_rep',roleAsRepeaterClassName:'_im_repeater',roleAsEnclosureClassName:'_im_enclosure',roleAsRepeaterDataControlName:'repeater',roleAsEnclosureDataControlName:'enclosure',roleAsSeparatorDataControlName:'separator',roleAsHeaderDataControlName:'header',roleAsFooterDataControlName:'footer',roleAsNoResultDataControlName:'noresult',initialize:function(){'use strict';IMLibLocalContext.unarchive();return null},setup:function(){'use strict';if(window.addEventListener){window.addEventListener('load',this.initialize,!1)}else if(window.attachEvent){window.attachEvent('onload',this.initialize)}else{window.onload=this.initialize}
return null},markProcessed:function(node){'use strict';node.setAttribute('data-im-element','processed')},isProcessed:function(node){'use strict';return node.getAttribute('data-im-element')==='processed'},generatePasswordHash:function(password){'use strict';var numToHex,salt,saltHex,code,lowCode,highCode,i;numToHex=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];salt='';saltHex='';for(i=0;i<4;i++){code=Math.floor(Math.random()*(128-32)+32);lowCode=code&0xF;highCode=(code>>4)&0xF;salt+=String.fromCharCode(code);saltHex+=numToHex[highCode]+numToHex[lowCode]}
return encodeURIComponent(SHA1(password+salt)+saltHex)},getParentRepeater:function(node){console.error('INTERMediatorLib.getParentRepeater method in INTER-Mediator-Lib.js will be removed in Ver.6.0. '+'The alternative method is getParentRepeaters.');'use strict';var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null},getParentRepeaters:function(node){'use strict';var i,target='',linkInfo,result=[],linkComp,nInfos,repeaters;if(!node){return null}
linkInfo=INTERMediatorLib.getLinkedElementInfo(node);if(linkInfo){linkComp=linkInfo[0].split('@');if(linkComp.length>2){target=linkComp[2]}
nInfos=IMLibContextPool.getContextInfoFromId(node.id,target);if(nInfos){repeaters=nInfos.context.binding[nInfos.record]._im_repeater}else{repeaters=seekFromContextPool(node)}}else{repeaters=seekFromContextPool(node)}
if(repeaters){for(i=0;i<repeaters.length;i+=1){result.push(document.getElementById(repeaters[i].id))}}
return result;function seekFromContextPool(node){var i,j,k,currentNode,repeaters;if(!node){return null}
currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){for(i=0;i<IMLibContextPool.poolingContexts.length;i++){for(j in IMLibContextPool.poolingContexts[i].binding){if(IMLibContextPool.poolingContexts[i].binding.hasOwnProperty(j)&&IMLibContextPool.poolingContexts[i].binding[j].hasOwnProperty('_im_repeater')){for(k=0;k<IMLibContextPool.poolingContexts[i].binding[j]._im_repeater.length;k++){if(IMLibContextPool.poolingContexts[i].binding[j]._im_repeater[k].id===currentNode.id){repeaters=IMLibContextPool.poolingContexts[i].binding[j]._im_repeater;return repeaters}}}}}}
currentNode=currentNode.parentNode}
return null}},getParentEnclosure:function(node){'use strict';var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isEnclosure(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null},isEnclosure:function(node,nodeOnly){'use strict';var tagName,className,children,k,controlAttr;if(!node||node.nodeType!==1){return!1}
className=INTERMediatorLib.getClassAttributeFromNode(node);if(className&&className.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterClassName)>=0){return!1}
controlAttr=node.getAttribute('data-im-control');if(controlAttr&&controlAttr.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterControlName)>=0){return!1}
tagName=node.tagName;if((tagName==='TBODY')||(tagName==='UL')||(tagName==='OL')||(tagName==='SELECT')||((tagName==='DIV'||tagName==='SPAN')&&className&&className.indexOf(INTERMediatorLib.roleAsEnclosureClassName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsEnclosureDataControlName)>=0)){if(nodeOnly){return!0}else{children=node.childNodes;for(k=0;k<children.length;k++){if(INTERMediatorLib.isRepeater(children[k],!0)){return!0}}}}
return!1},isRepeater:function(node,nodeOnly){'use strict';var tagName,className,children,k,controlAttr;if(!node||node.nodeType!==1){return!1}
className=INTERMediatorLib.getClassAttributeFromNode(node);if(className&&className.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterClassName)>=0){return!1}
controlAttr=node.getAttribute('data-im-control');if(controlAttr&&controlAttr.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterControlName)>=0){return!1}
tagName=node.tagName;if((tagName==='TR')||(tagName==='LI')||(tagName==='OPTION')||(className&&className.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)){if(nodeOnly){return!0}else{return searchLinkedElement(node)}}
return!1;function searchLinkedElement(node){if(INTERMediatorLib.isLinkedElement(node)){return!0}
children=node.childNodes;for(k=0;k<children.length;k++){if(children[k].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[k])){return!0}else if(searchLinkedElement(children[k])){return!0}}}
return!1}},isLinkedElement:function(node){'use strict';var classInfo,matched,attr;if(node!==null&&node.getAttribute){attr=node.getAttribute('data-im');if(attr){return!0}
if(INTERMediator.titleAsLinkInfo){if(node.getAttribute('TITLE')!==null&&node.getAttribute('TITLE').length>0){return!0}}
if(INTERMediator.classAsLinkInfo){classInfo=INTERMediatorLib.getClassAttributeFromNode(node);if(classInfo!==null){matched=classInfo.match(/IM\[.*\]/);if(matched){return!0}}}}
return!1},isWidgetElement:function(node){'use strict';var classInfo,matched,attr,parentNode;if(!node){return!1}
if(INTERMediatorLib.getLinkedElementInfo(node)){attr=node.getAttribute('data-im-widget');if(attr){return!0}
classInfo=INTERMediatorLib.getClassAttributeFromNode(node);if(classInfo!==null){matched=classInfo.match(/IM_WIDGET\[.*\]/);if(matched){return!0}}}else{parentNode=node.parentNode;if(!parentNode&&INTERMediatorLib.getLinkedElementInfoImpl(parentNode)){attr=parentNode.getAttribute('data-im-widget');if(attr){return!0}
classInfo=INTERMediatorLib.getClassAttributeFromNode(parentNode);if(classInfo!==null){matched=classInfo.match(/IM_WIDGET\[.*\]/);if(matched){return!0}}}}
return!1},isNamedElement:function(node){'use strict';var nameInfo,matched;if(node!==null){nameInfo=node.getAttribute('data-im-group');if(nameInfo){return!0}
nameInfo=node.getAttribute('name');if(nameInfo){matched=nameInfo.match(/IM\[.*\]/);if(matched){return!0}}}
return!1},getEnclosureSimple:function(node){'use strict';if(INTERMediatorLib.isEnclosure(node,!0)){return node}
return INTERMediatorLib.getEnclosureSimple(node.parentNode)},getEnclosure:function(node){'use strict';var currentNode,detectedRepeater;currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){detectedRepeater=currentNode}else if(isRepeaterOfEnclosure(detectedRepeater,currentNode)){detectedRepeater=null;return currentNode}
currentNode=currentNode.parentNode}
return null;function isRepeaterOfEnclosure(repeater,enclosure){var repeaterTag,enclosureTag,enclosureClass,repeaterClass,enclosureDataAttr,repeaterDataAttr,repeaterType;if(!repeater||!enclosure){return!1}
repeaterTag=repeater.tagName;enclosureTag=enclosure.tagName;if((repeaterTag==='TR'&&enclosureTag==='TBODY')||(repeaterTag==='OPTION'&&enclosureTag==='SELECT')||(repeaterTag==='LI'&&enclosureTag==='OL')||(repeaterTag==='LI'&&enclosureTag==='UL')){return!0}
enclosureClass=INTERMediatorLib.getClassAttributeFromNode(enclosure);enclosureDataAttr=enclosure.getAttribute('data-im-control');if((enclosureClass&&enclosureClass.indexOf(INTERMediatorLib.roleAsEnclosureClassName)>=0)||(enclosureDataAttr&&enclosureDataAttr.indexOf('enclosure')>=0)){repeaterClass=INTERMediatorLib.getClassAttributeFromNode(repeater);repeaterDataAttr=repeater.getAttribute('data-im-control');if((repeaterClass&&repeaterClass.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)){return!0}else if(repeaterTag==='INPUT'){repeaterType=repeater.getAttribute('type');if(repeaterType&&((repeaterType.indexOf('radio')>=0||repeaterType.indexOf('check')>=0))){return!0}}}
return!1}},getLinkedElementInfo:function(node){'use strict';var result=INTERMediatorLib.getLinkedElementInfoImpl(node);if(result!==!1){return result}
if(INTERMediatorLib.isWidgetElement(node.parentNode)){return INTERMediatorLib.getLinkedElementInfo(node.parentNode)}
return!1},getLinkedElementInfoImpl:function(node){'use strict';var defs=[],eachDefs,reg,i,attr,matched;if(INTERMediatorLib.isLinkedElement(node)){attr=node.getAttribute('data-im');if(attr!==null&&attr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=attr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(resolveAlias(eachDefs[i]))}}
return defs}
if(INTERMediator.titleAsLinkInfo&&node.getAttribute('TITLE')){eachDefs=node.getAttribute('TITLE').split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(resolveAlias(eachDefs[i]))}
return defs}
if(INTERMediator.classAsLinkInfo){attr=INTERMediatorLib.getClassAttributeFromNode(node);if(attr!==null&&attr.length>0){matched=attr.match(/IM\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(resolveAlias(eachDefs[i]))}}
return defs}}
return!1;function resolveAlias(def){var aliases=INTERMediatorOnPage.getOptionsAliases();if(aliases&&aliases[def]){return aliases[def]}
return def}},getWidgetInfo:function(node){'use strict';var defs=[],eachDefs,i,classAttr,matched,reg;if(INTERMediatorLib.isWidgetElement(node)){classAttr=node.getAttribute('data-im-widget');if(classAttr&&classAttr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=classAttr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(eachDefs[i])}}
return defs}
classAttr=INTERMediatorLib.getClassAttributeFromNode(node);if(classAttr&&classAttr.length>0){matched=classAttr.match(/IM_WIDGET\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(eachDefs[i])}
return defs}}
return!1},getNamedInfo:function(node){'use strict';var defs=[],eachDefs,i,nameAttr,matched,reg;if(INTERMediatorLib.isNamedElement(node)){nameAttr=node.getAttribute('data-im-group');if(nameAttr&&nameAttr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=nameAttr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(eachDefs[i])}}
return defs}
nameAttr=node.getAttribute('name');if(nameAttr&&nameAttr.length>0){matched=nameAttr.match(/IM\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(eachDefs[i])}
return defs}}
return!1},repeaterTagFromEncTag:function(tag){'use strict';if(tag==='TBODY'){return'TR'}else if(tag==='SELECT'){return'OPTION'}else if(tag==='UL'){return'LI'}else if(tag==='OL'){return'LI'}
return null},getNodeInfoArray:function(nodeInfo){'use strict';var comps,tableName,fieldName,targetName;if(!nodeInfo||!nodeInfo.split){return{'table':null,'field':null,'target':null,'tableindex':null,'crossTable':!1}}
comps=nodeInfo.split(INTERMediator.separator);tableName='';fieldName='';targetName='';if(comps.length===3){tableName=comps[0];fieldName=comps[1];targetName=comps[2]}else if(comps.length===2){tableName=comps[0];fieldName=comps[1]}else{fieldName=nodeInfo}
return{'table':tableName,'field':fieldName,'target':targetName,'tableindex':'_im_index_'+tableName,'crossTable':INTERMediator.crossTableStage===3}},getCalcNodeInfoArray:function(idValue){'use strict';console.error('INTERMediatorLib.getCalcNodeInfoArray method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'Here is no alternative method.');var comps,tableName,fieldName,targetName,node,attribute;if(!idValue){return null}
node=document.getElementById(idValue);if(!node){return null}
attribute=node.getAttribute('data-im');if(!attribute){return null}
comps=attribute.split(INTERMediator.separator);tableName='';fieldName='';targetName='';if(comps.length===3){tableName=comps[0];fieldName=comps[1];targetName=comps[2]}else if(comps.length===2){fieldName=comps[0];targetName=comps[1]}else{fieldName=attribute}
return{'table':tableName,'field':fieldName,'target':targetName,'tableindex':'_im_index_'+tableName}},getClassAttributeFromNode:function(node){'use strict';var str='';if(node===null){return''}
if(INTERMediator.isIE&&INTERMediator.ieVersion<8){str=node.getAttribute('className')}else{str=node.getAttribute('class')}
return str},setClassAttributeToNode:function(node,className){'use strict';if(node===null){return}
if(INTERMediator.isIE&&INTERMediator.ieVersion<8){node.setAttribute('className',className)}else{node.setAttribute('class',className)}},eventInfos:[],addEvent:function(node,evt,func){'use strict';if(node.addEventListener){node.addEventListener(evt,func,!1);this.eventInfos.push({'node':node,'event':evt,'function':func});return this.eventInfos.length-1}else if(node.attachEvent){node.attachEvent('on'+evt,func);this.eventInfos.push({'node':node,'event':evt,'function':func});return this.eventInfos.length-1}
return-1},removeEvent:function(serialId){'use strict';if(this.eventInfos[serialId].node.removeEventListener){this.eventInfos[serialId].node.removeEventListener(this.eventInfos[serialId].evt,this.eventInfos[serialId].func,!1)}else if(this.eventInfos[serialId].node.detachEvent){this.eventInfos[serialId].node.detachEvent('on'+this.eventInfos[serialId].evt,this.eventInfos[serialId].func)}},toNumber:function(str){'use strict';var s='',i,c;str=str.toString();for(i=0;i<str.length;i++){c=str.charAt(i);if((c>='0'&&c<='9')||c==='.'||c==='-'||c===INTERMediatorOnPage.localeInfo.mon_decimal_point){s+=c}else if(c>='0'&&c<='9'){s+=String.fromCharCode(c.charCodeAt(0)-'0'.charCodeAt(0)+'0'.charCodeAt(0))}}
return parseFloat(s)},RoundHalfToEven:function(value,digit){'use strict';throw 'RoundHalfToEven method is NOT implemented.'},Round:function(value,digit){'use strict';var powers=Math.pow(10,digit);return Math.round(value*powers)/powers},normalizeNumerics:function(value){'use strict';var i;var punc=INTERMediatorOnPage.localeInfo.decimal_point?INTERMediatorOnPage.localeInfo.decimal_point:'.';var mpunc=INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.';var rule='0123456789';if(punc){rule+='\\'+punc}
if(mpunc&&mpunc!==punc){rule+='\\'+mpunc}
rule='[^'+rule+']';value=String(value);if(value&&value.match(/[0123456789]/)){for(i=0;i<10;i++){value=value.split(String.fromCharCode(65296+i)).join(String(i))}
value=value.replace('.','.')}
return value?parseFloat(value.replace(new RegExp(rule,'g'),'')):''},objectToString:function(obj){'use strict';var str,i,key,sq=String.fromCharCode(39);if(obj===null){return'null'}
if(typeof obj==='object'){str='';if(obj.constructor===Array){for(i=0;i<obj.length;i++){str+=INTERMediatorLib.objectToString(obj[i])+', '}
return'['+str+']'}else{for(key in obj){if(obj.hasOwnProperty(key)){str+=sq+key+sq+':'+INTERMediatorLib.objectToString(obj[key])+', '}}
return'{'+str+'}'}}else{return sq+obj+sq}},numberFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormat(str,digit,flags)},getTargetTableForRetrieve:function(element){'use strict';if(element.view!==null){return element.view}
return element.name},getTargetTableForUpdate:function(element){'use strict';if(element.table!==null){return element.table}
return element.name},getInsertedString:function(tmpStr,dataArray){'use strict';var resultStr,counter;resultStr=tmpStr;if(dataArray!==null){for(counter=1;counter<=dataArray.length;counter++){resultStr=resultStr.replace('@'+counter+'@',dataArray[counter-1])}}
return resultStr},getInsertedStringFromErrorNumber:function(errNum,dataArray){'use strict';var resultStr,counter,messageArray;messageArray=INTERMediatorOnPage.getMessages();resultStr=messageArray?messageArray[errNum]:'Error:'+errNum;if(dataArray){for(counter=1;counter<=dataArray.length;counter++){resultStr=resultStr.replace('@'+counter+'@',dataArray[counter-1])}}
return resultStr},getNamedObject:function(obj,key,named){'use strict';var index;for(index in obj){if(obj[index][key]===named){return obj[index]}}
return null},getNamedObjectInObjectArray:function(ar,key,named){'use strict';var i;for(i=0;i<ar.length;i++){if(ar[i][key]===named){return ar[i]}}
return null},getNamedValueInObject:function(ar,key,named,retrieveKey){var result=[],index;for(index in ar){if(ar[index][key]===named){result.push(ar[index][retrieveKey])}}
if(result.length===0){return null}else if(result.length===1){return result[0]}else{return result}},is_array:function(target){'use strict';return target&&typeof target==='object'&&typeof target.length==='number'&&typeof target.splice==='function'&&!(target.propertyIsEnumerable('length'))},getNamedValuesInObject:function(ar,key1,named1,key2,named2,retrieveKey){'use strict';var result=[],index;for(index in ar){if(ar.hasOwnProperty(index)&&ar[index][key1]===named1&&ar[index][key2]===named2){result.push(ar[index][retrieveKey])}}
if(result.length===0){return null}else if(result.length===1){return result[0]}else{return result}},getRecordsetFromFieldValueObject:function(obj){'use strict';var recordset={},index;for(index in obj){if(obj.hasOwnProperty(index)){recordset[obj[index].field]=obj[index].value}}
return recordset},getNodePath:function(node){'use strict';if(node.tagName===null){return''}else{return INTERMediatorLib.getNodePath(node.parentNode)+'/'+node.tagName}},isPopupMenu:function(element){'use strict';if(!element||!element.tagName){return!1}
if(element.tagName==='SELECT'){return!0}
return!1},getElementsByClassNameOrDataAttr:function(node,cName){'use strict';var nodes=[],attrValue;attrValue=(cName.match(/^_im_/))?cName.substr(4):cName;if(attrValue){checkNode(node)}
return nodes;function checkNode(target){var value,i,items;if(target===undefined||target.nodeType!==1){return}
value=INTERMediatorLib.getClassAttributeFromNode(target);if(value){items=value.split('|');for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
value=target.getAttribute('data-im-control');if(value){items=value.split(/[| ]/);for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
value=target.getAttribute('data-im');if(value){items=value.split(/[| ]/);for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByAttributeValue:function(node,attribute,value){'use strict';var nodes=[];var reg=new RegExp(value);checkNode(node);return nodes;function checkNode(target){var aValue,i;if(target===undefined||target.nodeType!==1){return}
aValue=target.getAttribute(attribute);if(aValue&&aValue.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByClassName:function(node,cName){'use strict';var nodes=[];var reg=new RegExp(cName);checkNode(node);return nodes;function checkNode(target){var className,i;if(target===undefined||target.nodeType!==1){return}
className=INTERMediatorLib.getClassAttributeFromNode(target);if(className&&className.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByIMManaged:function(node){'use strict';var nodes=[];var reg=new RegExp(/^IM/);checkNode(node);return nodes;function checkNode(target){var nodeId,i;if(target===undefined||target.nodeType!==1){return}
nodeId=target.getAttribute('id');if(nodeId&&nodeId.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},seekLinkedAndWidgetNodes:function(nodes,ignoreEnclosureCheck){'use strict';var linkedNodesCollection=[];var widgetNodesCollection=[];var i,doEncCheck=ignoreEnclosureCheck;if(ignoreEnclosureCheck===undefined||ignoreEnclosureCheck===null){doEncCheck=!1}
for(i=0;i<nodes.length;i++){seekLinkedElement(nodes[i])}
return{linkedNode:linkedNodesCollection,widgetNode:widgetNodesCollection};function seekLinkedElement(node){var nType,currentEnclosure,children,i;nType=node.nodeType;if(nType===1){if(INTERMediatorLib.isLinkedElement(node)){currentEnclosure=doEncCheck?INTERMediatorLib.getEnclosure(node):null;if(currentEnclosure===null){linkedNodesCollection.push(node)}else{return currentEnclosure}}
if(INTERMediatorLib.isWidgetElement(node)){currentEnclosure=doEncCheck?INTERMediatorLib.getEnclosure(node):null;if(currentEnclosure===null){widgetNodesCollection.push(node)}else{return currentEnclosure}}
children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElement(children[i])}}
return null}},createErrorMessageNode:function(tag,message){'use strict';var messageNode;messageNode=document.createElement(tag);INTERMediatorLib.setClassAttributeToNode(messageNode,'_im_alertmessage');messageNode.appendChild(document.createTextNode(message));return messageNode},removeChildNodes:function(node){'use strict';if(node){while(node.childNodes.length>0){node.removeChild(node.childNodes[0])}}},clearErrorMessage:function(node){'use strict';var errorMsgs,j;if(node){errorMsgs=INTERMediatorLib.getElementsByClassName(node.parentNode,'_im_alertmessage');for(j=0;j<errorMsgs.length;j++){errorMsgs[j].parentNode.removeChild(errorMsgs[j])}}},dateTimeStringISO:function(dt){'use strict';dt=(!dt)?new Date():dt;return dt.getFullYear()+'-'+('0'+(dt.getMonth()+1)).substr(-2,2)+'-'+('0'+dt.getDate()).substr(-2,2)+' '+('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)},dateTimeStringFileMaker:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+(dt.getMonth()+1)).substr(-2,2)+'/'+('0'+dt.getDate()).substr(-2,2)+'/'+dt.getFullYear()+' '+('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)},dateStringISO:function(dt){'use strict';dt=(!dt)?new Date():dt;return dt.getFullYear()+'-'+('0'+(dt.getMonth()+1)).substr(-2,2)+'-'+('0'+dt.getDate()).substr(-2,2)},dateStringFileMaker:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+(dt.getMonth()+1)).substr(-2,2)+'/'+('0'+dt.getDate()).substr(-2,2)+'/'+dt.getFullYear()},timeString:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)}};INTERMediatorLib.initialize();var IMLibNodeGraph={nodes:[],edges:[],clear:function(){'use strict';this.nodes=[];this.edges=[]},addNode:function(node){'use strict';if(this.nodes.indexOf(node)<0){this.nodes.push(node)}},addEdge:function(fromNode,toNode){'use strict';if(this.nodes.indexOf(fromNode)<0){this.addNode(fromNode)}
if(this.nodes.indexOf(toNode)<0){this.addNode(toNode)}
this.edges.push({from:fromNode,to:toNode})},getAllNodesInEdge:function(){'use strict';var i,nodes=[];for(i=0;i<this.edges.length;i++){if(nodes.indexOf(this.edges[i].from)<0){nodes.push(this.edges[i].from)}
if(nodes.indexOf(this.edges[i].to)<0){nodes.push(this.edges[i].to)}}
return nodes},getLeafNodes:function(){'use strict';var i,srcs=[],dests=[],srcAndDests=this.getAllNodesInEdge();for(i=0;i<this.edges.length;i++){srcs.push(this.edges[i].from)}
for(i=0;i<this.edges.length;i++){if(srcs.indexOf(this.edges[i].to)<0&&dests.indexOf(this.edges[i].to)<0){dests.push(this.edges[i].to)}}
for(i=0;i<this.nodes.length;i++){if(srcAndDests.indexOf(this.nodes[i])<0){dests.push(this.nodes[i])}}
return dests},getLeafNodesWithRemoving:function(){'use strict';var i,newEdges=[],dests=this.getLeafNodes();for(i=0;i<this.edges.length;i++){if(dests.indexOf(this.edges[i].to)<0){newEdges.push(this.edges[i])}}
this.edges=newEdges;for(i=0;i<dests.length;i++){this.nodes.splice(this.nodes.indexOf(dests[i]),1)}
return dests},removeNode:function(node){'use strict';var i,newEdges=[];for(i=0;i<this.edges.length;i++){if(this.edges[i].to!=node){newEdges.push(this.edges[i])}}
this.edges=newEdges;this.nodes.splice(this.nodes.indexOf(node),1)},applyToAllNodes:function(f){'use strict';var i;for(i=0;i<this.nodes.length;i++){f(this.nodes[i])}},};var IMLibFormat={numberFormatImpl:function(str,digit,decimalPoint,thousandsSep,currencySymbol,flags){'use strict';var s,n,prefix,i,sign,tailSign='',power,underDot,underNumStr,pstr,roundedNum,underDecimalNum,integerNum,formatted,numStr,j,isMinusValue,numerals,numbers;if(str===''||str===null||str===undefined){return''}
prefix=(String(str).substring(0,1)==='-')?'-':'';if(String(str).match(/[-]/)){str=prefix+String(str).split('-').join('')}
n=INTERMediatorLib.toNumber(str);if(isNaN(n)){return''}
if(flags===undefined){flags={}}
sign=INTERMediatorOnPage.localeInfo.positive_sign;isMinusValue=!1;if(n<0){sign=INTERMediatorOnPage.localeInfo.negative_sign;if(flags.negativeStyle===0||flags.negativeStyle===1){sign='-'}else if(flags.negativeStyle===2){sign='(';tailSign=')'}else if(flags.negativeStyle===3){sign='<';tailSign='>'}else if(flags.negativeStyle===4){sign=' CR'}else if(flags.negativeStyle===5){sign='▲'}
n=-n;isMinusValue=!0}
if(flags.blankIfZero===!0&&n===0){return''}
if(flags.usePercentNotation){n=n*100}
underDot=(digit===undefined)?INTERMediatorOnPage.localeInfo.frac_digits:INTERMediatorLib.toNumber(digit);power=Math.pow(10,underDot);roundedNum=Math.round(n*power);underDecimalNum=(underDot>0)?roundedNum%power:0;integerNum=(roundedNum-underDecimalNum)/power;underNumStr=(underDot>0)?String(underDecimalNum):'';while(underNumStr.length<underDot){underNumStr='0'+underNumStr}
if(flags.useSeparator===!0){if(n===0){formatted='0'}else{n=integerNum;s=[];if(flags.kanjiSeparator===1||flags.kanjiSeparator===2){numerals=['万','億','兆','京','垓','𥝱','穣','溝','澗','正','載','極','恒河沙','阿僧祇','那由他','不可思議','無量大数'];i=0;formatted='';for(n=Math.floor(n);n>0;n=Math.floor(n/10000)){if(n>=10000){pstr='0000'+(n%10000).toString()}else{pstr=(n%10000).toString()}
if(flags.kanjiSeparator===1){if(n>=10000){if(pstr.substr(pstr.length-4)!=='0000'){formatted=numerals[i]+Number(pstr.substr(pstr.length-4))+formatted}else{if(numerals[i-1]!==formatted.charAt(0)){formatted=numerals[i]+formatted}else{formatted=numerals[i]+formatted.slice(1)}}}else{formatted=n+formatted}}else if(flags.kanjiSeparator===2){numStr=pstr.substr(pstr.length-4);pstr='';if(numStr==='0001'){pstr='1'}else if(numStr!=='0000'){for(j=0;j<numStr.length;j++){if(numStr.charAt(j)>1){pstr=pstr+numStr.charAt(j)}
if(numStr.charAt(j)>0){if(numStr.length-j===4){pstr=pstr+'千'}else if(numStr.length-j===3){pstr=pstr+'百'}else if(numStr.length-j===2){pstr=pstr+'十'}}}}
if(n>=10000){if(pstr.length>0){formatted=numerals[i]+pstr+formatted}else{if(numerals[i-1]!==formatted.charAt(0)){formatted=numerals[i]+formatted}else{formatted=numerals[i]+formatted.slice(1)}}}else{if(numStr.length===1){formatted=n+formatted}else{formatted=pstr+formatted}}}
i++}
formatted=formatted+(underNumStr===''?'':decimalPoint+underNumStr)}else{for(n=Math.floor(n);n>0;n=Math.floor(n/1000)){if(n>=1000){pstr='000'+(n%1000).toString();s.push(pstr.substr(pstr.length-3))}else{s.push(n)}}
formatted=s.reverse().join(thousandsSep)+(underNumStr===''?'':decimalPoint+underNumStr)}
if(flags.negativeStyle===0||flags.negativeStyle===5){formatted=sign+formatted}else if(flags.negativeStyle===1||flags.negativeStyle===4){formatted=formatted+sign}else if(flags.negativeStyle===2||flags.negativeStyle===3){formatted=sign+formatted+tailSign}else{formatted=sign+formatted}}}else{formatted=integerNum+(underNumStr===''?'':decimalPoint+underNumStr);if(flags.negativeStyle===0||flags.negativeStyle===5){formatted=sign+formatted}else if(flags.negativeStyle===1||flags.negativeStyle===4){formatted=formatted+sign}else if(flags.negativeStyle===2||flags.negativeStyle===3){formatted=sign+formatted+tailSign}else{formatted=sign+formatted}}
if(currencySymbol){if(!isMinusValue){if(parseInt(INTERMediatorOnPage.localeInfo.p_cs_precedes)===1){if(parseInt(INTERMediatorOnPage.localeInfo.p_sep_by_space)===1){formatted=currencySymbol+' '+formatted}else{formatted=currencySymbol+formatted}}else{if(parseInt(INTERMediatorOnPage.localeInfo.p_sep_by_space)===1){formatted=formatted+' '+currencySymbol}else{formatted=formatted+currencySymbol}}}else{if(parseInt(INTERMediatorOnPage.localeInfo.n_cs_precedes)===1){if(parseInt(INTERMediatorOnPage.localeInfo.n_sep_by_space)===1){formatted=currencySymbol+' '+formatted}else{formatted=currencySymbol+formatted}}else{if(parseInt(INTERMediatorOnPage.localeInfo.n_sep_by_space)===1){formatted=formatted+' '+currencySymbol}else{formatted=formatted+currencySymbol}}}}
if(flags.charStyle){if(flags.charStyle===1){for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String.fromCharCode(65296+i))}}else if(flags.charStyle===2){numbers={0:'〇',1:'一',2:'二',3:'三',4:'四',5:'五',6:'六',7:'七',8:'八',9:'九'};for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String(numbers[i]))}}else if(flags.charStyle===3){numbers={0:'〇',1:'壱',2:'弐',3:'参',4:'四',5:'伍',6:'六',7:'七',8:'八',9:'九'};for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String(numbers[i]))}}}
if(flags.usePercentNotation===!0&&formatted!==''){formatted=formatted+'%'}
return formatted},getKanjiNumber:function(n){'use strict';var s=[],count=0;String(n).split('').reverse().forEach(function(c){s.push(IMLibFormat.kanjiDigit[count]);count++;s.push(IMLibFormat.kanjiNumbers[parseInt(c)])});return s.reverse().join('')},numberFormat:function(str,digit,flags){'use strict';if(flags===undefined){flags={}}
flags.useSeparator=!0;return this.decimalFormat(str,digit,flags)},percentFormat:function(str,digit,flags){'use strict';if(typeof flags!=='object'){flags={}}
flags.usePercentNotation=!0;return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',!1,flags)},decimalFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',!1,flags)},currencyFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',INTERMediatorOnPage.localeInfo.currency_symbol?INTERMediatorOnPage.localeInfo.currency_symbol:'¥',flags)},booleanFormat:function(str,forms){'use strict';var trueString='true',falseString='false',fmtStr;var params=forms.split(',');if(params[0]){fmtStr=params[0].trim();if(fmtStr.length>0){trueString=fmtStr}}
if(params[1]){fmtStr=params[1].trim();if(fmtStr.length>0){falseString=fmtStr}}
if(str===''||str===null){return''}else{if(parseInt(str,10)!==0){return trueString}else{return falseString}}},datetimeFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'datetime')},dateFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'date')},timeFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'time')},placeHolder:{'%Y':Date.prototype.getFullYear,'%y':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getFullYear())},'%g':function(){'use strict';return IMLibFormat.getLocalYear(this,1)},'%G':function(){'use strict';return IMLibFormat.getLocalYear(this,2)},'%M':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getMonth()+1)},'%m':function(){'use strict';return this.getMonth()+1},'%b':function(){'use strict';return INTERMediatorOnPage.localeInfo.ABMON[this.getMonth()]},'%B':function(){'use strict';return INTERMediatorOnPage.localeInfo.MON[this.getMonth()]},'%t':function(){'use strict';return IMLibFormat.eMonAbbr[this.getMonth()]},'%T':function(){'use strict';return IMLibFormat.eMonName[this.getMonth()]},'%D':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getDate())},'%d':Date.prototype.getDate,'%a':function(){'use strict';return IMLibFormat.eDayAbbr[this.getDay()]},'%A':function(){'use strict';return IMLibFormat.eDayName[this.getDay()]},'%w':function(){'use strict';return INTERMediatorOnPage.localeInfo.ABDAY[this.getDay()]},'%W':function(){'use strict';return INTERMediatorOnPage.localeInfo.DAY[this.getDay()]},'%H':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getHours())},'%h':Date.prototype.getHours,'%J':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getHours()%12)},'%j':function(){'use strict';return this.getHours()%12},'%K':function(){'use strict';var n=this.getHours()%12;return IMLibFormat.tweDigitsNumber(n===0?12:n)},'%k':function(){'use strict';var n=this.getHours()%12;return n===0?12:n},'%I':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getMinutes())},'%i':Date.prototype.getMinutes,'%S':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getSeconds())},'%s':Date.prototype.getSeconds,'%P':function(){'use strict';return Math.floor(this.getHours()/12)===0?'AM':'PM'},'%p':function(){'use strict';return Math.floor(this.getHours()/12)===0?'am':'pm'},'%N':function(){'use strict';return Math.floor(this.getHours()/12)===0?INTERMediatorOnPage.localeInfo.AM_STR:INTERMediatorOnPage.localeInfo.PM_STR},'%%':function(){'use strict';return'%'}},tweDigitsNumber:function(n){'use strict';var v=parseInt(n);return('0'+v.toString()).substr(-2,2)},jYearStartDate:{'2019/5/1':'令和','1989/1/8':'平成','1926/12/25':'昭和','1912/7/30':'大正','1868/1/25':'明治'},eDayName:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],eDayAbbr:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],eMonName:['January','February','March','April','May','June','July','August','September','October','November','December'],eMonAbbr:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],kanjiNumbers:['〇','一','二','三','四','五','六','七','八','九'],kanjiDigit:['','十','百','千','万'],getLocalYear:function(dt,fmt){'use strict';var gengoName,gengoYear,startDateStr,dtStart;if(!dt){return''}
gengoName='';gengoYear=0;for(startDateStr in IMLibFormat.jYearStartDate){if(IMLibFormat.jYearStartDate.hasOwnProperty(startDateStr)){dtStart=new Date(startDateStr);if(dt>=dtStart){gengoName=IMLibFormat.jYearStartDate[startDateStr];gengoYear=dt.getFullYear()-dtStart.getFullYear()+1;gengoYear=((gengoYear===1)?'元':(fmt===2?IMLibFormat.getKanjiNumber(gengoYear):gengoYear));break}}}
return gengoName+gengoYear+'年'},datetimeFormatImpl:function(str,params,flags){'use strict';var dt,c,result='',replaced,hasColon,hasSlash,hasDash;str=(Object.prototype.toString.call(str)==='[object Array]')?str.join():str;var paramStr=params.trim().toUpperCase();var kind=flags.trim().toUpperCase();var key=kind.substr(0,1)+'_FMT_'+paramStr;if(INTERMediatorOnPage.localeInfo[key]){params=INTERMediatorOnPage.localeInfo[key];if(kind==='DATETIME'){params+=' '+INTERMediatorOnPage.localeInfo['T_FMT_'+paramStr]}}
hasColon=str.indexOf(':')>-1;hasSlash=str.indexOf('/')>-1;hasDash=str.indexOf('-')>-1;if(!hasColon&&(hasSlash||hasDash)){str+=' 00:00:00'}else if(hasColon&&!hasSlash&&!hasDash){str='1970/01/01 '+str}
dt=new Date(str);if(dt.toString()==='Invalid Date'){dt=new Date(str.replace(/-/g,'/'))}
if(dt.toString()==='Invalid Date'){return''}
for(c=0;c<params.length;c++){if((c+1)<params.length&&IMLibFormat.placeHolder[params.substr(c,2)]){replaced=(IMLibFormat.placeHolder[params.substr(c,2)]).apply(dt);result+=replaced;c++}else{result+=params.substr(c,1)}}
return result},convertNumeric:function(value){'use strict';value=value.replace(new RegExp(INTERMediatorOnPage.localeInfo.mon_thousands_sep,'g'),'');value=INTERMediatorLib.normalizeNumerics(value);if(value!==''){value=parseFloat(value)}
return value},convertBoolean:function(value,forms){'use strict';var trueString='true',falseString='false',fmtStr;value=value.trim();var params=forms.split(',');if(params[0]){fmtStr=params[0].trim();if(fmtStr.length>0){trueString=fmtStr}}
if(params[1]){fmtStr=params[1].trim();if(fmtStr.length>0){falseString=fmtStr}}
if(value===trueString){return!0}else if(value===falseString){return!1}
return null},convertPercent:function(value){'use strict';value=value.replace(new RegExp(INTERMediatorOnPage.localeInfo.mon_thousands_sep,'g'),'');value=value.replace('%','');value=INTERMediatorLib.normalizeNumerics(value);if(value!==''){value=parseFloat(value)/100}
return value},convertDate:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'date')},convertTime:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'time')},convertDateTime:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'datetime')},convertDateTimeImpl:function(value,params,flags){'use strict';var c,result,replacement=[],regexp='';var r,matched,y,m,d,h,i,s,paramStr,kind,key,mon;paramStr=params.trim().toUpperCase();kind=flags.trim().toUpperCase();key=kind.substr(0,1)+'_FMT_'+paramStr;if(INTERMediatorOnPage.localeInfo[key]){params=INTERMediatorOnPage.localeInfo[key];if(kind==='DATETIME'){params+=' '+INTERMediatorOnPage.localeInfo['T_FMT_'+paramStr]}}
params=params.replace(/([\(\)])/g,'\\$1');for(c=0;c<params.length;c++){if((c+1)<params.length&&IMLibFormat.reverseRegExp[params.substr(c,2)]){regexp+=IMLibFormat.reverseRegExp[params.substr(c,2)];replacement.push(params.substr(c,2));c++}else{regexp+=params.substr(c,1)}}
r=new RegExp(regexp);matched=r.exec(value);result=value;if(matched){for(c=0;c<replacement.length;c++){switch(replacement[c]){case '%Y':case '%y':y=matched[c+1];break;case '%M':case '%m':m=matched[c+1];break;case '%T':case '%t':mon=matched[c+1];m=IMLibFormat.eMonAbbr.indexOf(mon.substr(0,1).toUpperCase()+mon.substr(1,2).toLowerCase());m++;break;case '%D':case '%d':d=matched[c+1];break;case '%H':case '%h':h=matched[c+1];break;case '%I':case '%i':i=matched[c+1];break;case '%S':case '%s':s=matched[c+1];break}}
if(y&&m&&d&&h&&i&&s){result=y+'-'+m+'-'+d+' '+h+':'+i+':'+s}else if(y&&m&&d){result=y+'-'+m+'-'+d}else if(h&&i&&s){result=h+':'+i+':'+s}}
return result},reverseRegExp:{'%Y':'([\\d]{4})','%y':'([\\d]{2})','%g':'(明治|大正|昭和|平成|令和)(元|[\\d]{1,2})年','%G':'(明治|大正|昭和|平成|令和)(.+)年','%M':'([\\d]{1,2})','%m':'([\\d]{1,2})','%b':'(.+)','%B':'(.+)','%t':'(.+)','%T':'(.+)','%D':'([\\d]{1,2})','%d':'([\\d]{1,2})','%a':'(.+)','%A':'(.+)','%w':'(.+)','%W':'(.+)','%H':'([\\d]{1,2})','%h':'([\\d]{1,2})','%J':'([\\d]{1,2})','%j':'([\\d]{1,2})','%K':'([\\d]{1,2})','%k':'([\\d]{1,2})','%I':'([\\d]{1,2})','%i':'([\\d]{1,2})','%S':'([\\d]{1,2})','%s':'([\\d]{1,2})','%P':'(AM|PM)','%p':'(am|pm)','%N':'('+INTERMediatorOnPage.localeInfo.AM_STR+'|'+INTERMediatorOnPage.localeInfo.PM_STR+')','%%':'[\%]'}};var IMLibElement={formatters:{number:IMLibFormat.decimalFormat,currency:IMLibFormat.currencyFormat,boolean:IMLibFormat.booleanFormat,percent:IMLibFormat.percentFormat,date:IMLibFormat.dateFormat,datetime:IMLibFormat.datetimeFormat,time:IMLibFormat.timeFormat},unformatters:{number:IMLibFormat.convertNumeric,currency:IMLibFormat.convertNumeric,boolean:IMLibFormat.convertBoolean,percent:IMLibFormat.convertPercent,date:IMLibFormat.convertDate,datetime:IMLibFormat.convertDateTime,time:IMLibFormat.convertTime},formatOptions:{'useseparator':{useSeparator:!0},'blankifzero':{blankIfZero:!0}},formatNegativeStyle:{leadingminus:{negativeStyle:0},'leading-minus':{negativeStyle:0},trailingminus:{negativeStyle:1},'trailing-minus':{negativeStyle:1},parenthesis:{negativeStyle:2},angle:{negativeStyle:3},credit:{negativeStyle:4},triangle:{negativeStyle:5}},formatNumeralType:{'half-width':{charStyle:0},'full-width':{charStyle:1},'kanji-numeral-modern':{charStyle:2},'kanji-numeral':{charStyle:3}},formatKanjiSeparator:{'every-4th-place':{kanjiSeparator:1,useSeparator:!0},'full-notation':{kanjiSeparator:2,useSeparator:!0}},appendObject:function(obj,adding){'use strict';var result=obj;if(adding){for(var key in adding){if(adding.hasOwnProperty(key)){result[key]=adding[key]}}}
return result},initilaizeFlags:function(element){'use strict';var flags,formatOption,negativeStyle,charStyle,kanjiSeparator;flags={useSeparator:!1,blankIfZero:!1,negativeStyle:0,charStyle:0,kanjiSeparator:0};formatOption=element.getAttribute('data-im-format-options');flags=IMLibElement.appendObject(flags,IMLibElement.formatOptions[formatOption]);negativeStyle=element.getAttribute('data-im-format-negative-style');flags=IMLibElement.appendObject(flags,IMLibElement.formatNegativeStyle[negativeStyle]);charStyle=element.getAttribute('data-im-format-numeral-type');flags=IMLibElement.appendObject(flags,IMLibElement.formatNumeralType[charStyle]);kanjiSeparator=element.getAttribute('data-im-format-kanji-separator');flags=IMLibElement.appendObject(flags,IMLibElement.formatKanjiSeparator[kanjiSeparator]);return flags},getFormattedValue:function(element,curVal){'use strict';var flags,formatSpec,parsed,formattedValue=null,params,formatFunc,firstParen,lastParen;formatSpec=element.getAttribute('data-im-format');if(!formatSpec){return null}
flags=IMLibElement.initilaizeFlags(element);params=0;formatFunc=IMLibElement.formatters[formatSpec.trim().toLocaleLowerCase()];if(!formatFunc){firstParen=formatSpec.indexOf('(');lastParen=formatSpec.lastIndexOf(')');parsed=formatSpec.substr(0,firstParen).match(/[^a-zA-Z]*([a-zA-Z]+).*/);formatFunc=IMLibElement.formatters[parsed[1].toLocaleLowerCase()];params=formatSpec.substring(firstParen+1,lastParen);if(params.length===0){params=0}}
if(formatFunc){formattedValue=formatFunc(curVal,params,flags)}
return formattedValue},getUnformattedValue:function(element,value){'use strict';var formatSpec,unformatFunc,parsed,params,convertedValue,flags,firstParen,lastParen;formatSpec=element.getAttribute('data-im-format');if(!formatSpec){return null}
flags=IMLibElement.initilaizeFlags(element);unformatFunc=IMLibElement.unformatters[formatSpec.trim().toLocaleLowerCase()];if(!unformatFunc){firstParen=formatSpec.indexOf('(');lastParen=formatSpec.lastIndexOf(')');parsed=formatSpec.substr(0,firstParen).match(/[^a-zA-Z]*([a-zA-Z]+).*/);unformatFunc=IMLibElement.unformatters[parsed[1].toLocaleLowerCase()];params=formatSpec.substring(firstParen+1,lastParen)}
if(unformatFunc){convertedValue=unformatFunc(value,params,flags)}
return convertedValue},setValueToIMNode:function(element,curTarget,curVal,clearField){'use strict';var styleName,currentValue,scriptNode,typeAttr,valueAttr,textNode,formatSpec,formattedValue,needPostValueSet=!1,curValues,i,isReplaceOrAppend=!1,imControl,negativeColor,originalValue,negativeSign,negativeTailSign,flags;if(curVal===undefined){return!1}
if(!element){return!1}
if(curVal===null||curVal===!1){curVal=''}
if(typeof curVal==='object'&&curVal.constructor===Array&&curVal.length>0){curVal=curVal[0]}
imControl=element.getAttribute('data-im-control');if(clearField&&curTarget===''){switch(element.tagName){case 'INPUT':switch(element.getAttribute('type')){case 'text':element.value='';break}
break;case 'SELECT':break;default:while(element.childNodes.length>0){if(element.parentNode.getAttribute('data-im-element')==='processed'||INTERMediatorLib.isWidgetElement(element.parentNode)){return!1}
element.removeChild(element.childNodes[0])}
break}}
formattedValue=IMLibElement.getFormattedValue(element,curVal);if(element.getAttribute('data-im-format')){if(formattedValue===null){INTERMediatorLog.setErrorMessage('The \'data-im-format\' attribute is not valid: '+formatSpec)}else{curVal=formattedValue}}
curVal=String(curVal);negativeColor=element.getAttribute('data-im-format-negative-color');if(curTarget!==null&&curTarget.length>0){if(curTarget.charAt(0)==='#'){curTarget=curTarget.substring(1);originalValue=element.getAttribute('data-im-original-'+curTarget);if(curTarget==='innerHTML'){currentValue=originalValue?originalValue:element.innerHTML;element.innerHTML=currentValue+curVal}else if(curTarget==='textNode'||curTarget==='script'){currentValue=originalValue?originalValue:element.textContent;element.textContent=currentValue+curVal}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);currentValue=originalValue?originalValue:element.style[styleName];if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=currentValue+curVal}}else{currentValue=originalValue?originalValue:element.getAttribute(curTarget);if(curVal.indexOf('/fmi/xml/cnt/')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal}else if(curVal.indexOf('https://'+location.hostname+'/Streaming_SSL/MainDB')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+encodeURIComponent(curVal.replace('https://'+location.hostname,''))}
element.setAttribute(curTarget,currentValue+curVal)}
isReplaceOrAppend=!0;if(!originalValue){element.setAttribute('data-im-original-'+curTarget,currentValue)}}else if(curTarget.charAt(0)==='){curTarget=curTarget.substring(1);originalValue=element.getAttribute('data-im-original-'+curTarget);if(curTarget==='innerHTML'){currentValue=element.innerHTML;curVal=currentValue.replace(',curVal);if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else if(curTarget==='textNode'||curTarget==='script'){currentValue=element.textContent;element.textContent=currentValue.replace(',curVal)}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);currentValue=element.style[styleName];if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=currentValue.replace(',curVal)}}else{currentValue=element.getAttribute(curTarget);if(curVal.indexOf('/fmi/xml/cnt/')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal}else if(curVal.indexOf('https://'+location.hostname+'/Streaming_SSL/MainDB')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal.replace('https://'+location.hostname,'')}
element.setAttribute(curTarget,currentValue.replace(',curVal))}
isReplaceOrAppend=!0;if(!originalValue){element.setAttribute('data-im-original-'+curTarget,currentValue)}}else{if(INTERMediatorLib.isWidgetElement(element)){if(element._im_setValue){element._im_setValue(curVal)}}else if(curTarget==='innerHTML'){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else if(curTarget==='textNode'){textNode=document.createTextNode(curVal);element.appendChild(textNode)}else if(curTarget==='script'){textNode=document.createTextNode(curVal);if(element.tagName==='SCRIPT'){element.appendChild(textNode)}else{scriptNode=document.createElement('script');scriptNode.type='text/javascript';scriptNode.appendChild(textNode);element.appendChild(scriptNode)}}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=curVal}}else{if(INTERMediator.isIE&&INTERMediator.ieVersion<10&&element.tagName==='TEXTAREA'){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.setAttribute(curTarget,curVal)}}}else{if(INTERMediatorLib.isWidgetElement(element)){if(element._im_setValue){element._im_setValue(curVal)}}else if(element.tagName==='INPUT'){typeAttr=element.getAttribute('type');if(typeAttr==='checkbox'||typeAttr==='radio'){valueAttr=element.value;if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){curValues=curVal.split(IMLib.cr_char)}else{curValues=curVal.split(IMLib.nl_char)}
if(typeAttr==='checkbox'&&curValues.length>1){for(i=0;i<curValues.length;i++){if(valueAttr===curValues[i]&&!INTERMediator.dontSelectRadioCheck){if(INTERMediator.isIE){element.setAttribute('checked','checked')}else{element.checked=!0}}}}else{if(valueAttr===curVal&&!INTERMediator.dontSelectRadioCheck){if(INTERMediator.isIE){element.setAttribute('checked','checked')}else{element.checked=!0}}else{element.checked=!1}}}else{element.value=curVal}}else if(element.tagName==='SELECT'){needPostValueSet=!0;element.value=curVal}else if(element.tagName==='TEXTAREA'){if(INTERMediator.defaultTargetInnerHTML){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else{element.value=curVal}}else{if(INTERMediator.defaultTargetInnerHTML){element.innerHTML=curVal}else{element.appendChild(document.createTextNode(curVal))}}}
if(formatSpec&&negativeColor){negativeSign=INTERMediatorOnPage.localeInfo.negative_sign;negativeTailSign='';flags=IMLibElement.initilaizeFlags(element);if(flags.negativeStyle===0||flags.negativeStyle===1){negativeSign='-'}else if(flags.negativeStyle===2){negativeSign='(';negativeTailSign=')'}else if(flags.negativeStyle===3){negativeSign='<';negativeTailSign='>'}else if(flags.negativeStyle===4){negativeSign=' CR'}else if(flags.negativeStyle===5){negativeSign='▲'}
if(flags.negativeStyle===0||flags.negativeStyle===5){if(curVal.indexOf(negativeSign)===0){element.style.color=negativeColor}}else if(flags.negativeStyle===1||flags.negativeStyle===4){if(curVal.indexOf(negativeSign)>-1&&curVal.indexOf(negativeSign)===curVal.length-negativeSign.length){element.style.color=negativeColor}}else if(flags.negativeStyle===2||flags.negativeStyle===3){if(curVal.indexOf(negativeSign)===0){if(curVal.indexOf(negativeTailSign)>-1&&curVal.indexOf(negativeTailSign)===curVal.length-1){element.style.color=negativeColor}}}}
if((element.tagName==='INPUT'||element.tagName==='SELECT'||element.tagName==='TEXTAREA')&&!isReplaceOrAppend&&(!imControl||imControl.indexOf('unbind')>0)){if(!element.getAttribute('data-imbluradded')){INTERMediatorLib.addEvent(element,'blur',(function(){var idValue=element.id;var elementCapt=element;return function(){if(!IMLibUI.valueChange(idValue,!0)){elementCapt.focus()}}})());element.setAttribute('data-imbluradded','set')}
if(!element.getAttribute('data-imchangeadded')){IMLibChangeEventDispatch.setExecute(element.id,(function(){var idValue=element.id;var elementCapt=element;return function(){if(!IMLibUI.valueChange(idValue,!1)){elementCapt.focus()}}})());element.setAttribute('data-imchangeadded','set')}
if((INTERMediator.isTrident||INTERMediator.isEdge)&&!element.getAttribute('data-iminputadded')){IMLibInputEventDispatch.setExecute(element.id,(function(){var idValue=element.id;var elementCapt=element;return function(){if(document.getElementById(idValue).value===''){if(!IMLibUI.valueChange(idValue,!1)){elementCapt.focus()}}}})());element.setAttribute('data-iminputadded','set')}}
element.setAttribute('data-im-element','processed');return needPostValueSet},getValueFromIMNode:function(element){'use strict';var nodeTag,typeAttr,newValue,mergedValues,targetNodes,k,valueAttr,convertedValue;if(element){nodeTag=element.tagName;typeAttr=element.getAttribute('type')}else{return''}
if(INTERMediatorLib.isWidgetElement(element)||(INTERMediatorLib.isWidgetElement(element.parentNode))){newValue=element._im_getValue()}else if(nodeTag==='INPUT'){if(typeAttr==='checkbox'){if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){mergedValues=[];targetNodes=element.parentNode.getElementsByTagName('INPUT');for(k=0;k<targetNodes.length;k++){if(targetNodes[k].checked){mergedValues.push(targetNodes[k].getAttribute('value'))}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){newValue=mergedValues.join(IMLib.cr_char)}else{newValue=mergedValues.join(IMLib.nl_char)}}else{valueAttr=element.getAttribute('value');if(element.checked){newValue=valueAttr}else{newValue=''}}}else if(typeAttr==='radio'){newValue=element.value}else{newValue=element.value}}else if(nodeTag==='SELECT'){newValue=element.value}else if(nodeTag==='TEXTAREA'){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){newValue=element.innerHTML.replace(/<br[\/]{0,1}>/g,'\n')}else{newValue=element.value}}else{newValue=element.innerHTML}
convertedValue=IMLibElement.getUnformattedValue(element,newValue);newValue=convertedValue?convertedValue:newValue;return newValue},deleteNodes:function(removeNodes){'use strict';var removeNode,removingNodes,i,j,k,removeNodeId,nodeId,calcObject,referes,values,key;for(key=0;key<removeNodes.length;key++){removeNode=document.getElementById(removeNodes[key]);if(removeNode){removingNodes=INTERMediatorLib.getElementsByIMManaged(removeNode);if(removingNodes){for(i=0;i<removingNodes.length;i++){removeNodeId=removingNodes[i].id;if(removeNodeId in IMLibCalc.calculateRequiredObject){delete IMLibCalc.calculateRequiredObject[removeNodeId]}}
for(i=0;i<removingNodes.length;i++){removeNodeId=removingNodes[i].id;for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];referes={};values={};for(j in calcObject.referes){if(calcObject.referes.hasOwnProperty(j)){referes[j]=[];values[j]=[];for(k=0;k<calcObject.referes[j].length;k++){if(removeNodeId!==calcObject.referes[j][k]){referes[j].push(calcObject.referes[j][k]);values[j].push(calcObject.values[j][k])}}}}
calcObject.referes=referes;calcObject.values=values}}}}
try{removeNode.parentNode.removeChild(removeNode)}catch(ex){}}}}};var Parser=(function(scope){var TNUMBER=0;var TOP1=1;var TOP2=2;var TOP3=5;var SEP=65;var TVAR=3;var TFUNCALL=4;Parser.regFirstVarChar=new RegExp('[\u00A0-\u1FFF\u2C00-\uDFFFa-zA-Z@_]');Parser.regRestVarChar=new RegExp('[\u00A0-\u1FFF\u2C00-\uDFFFa-zA-Z@_:0-9]');function Token(type_,index_,prio_,number_){this.type_=type_;this.index_=index_||0;this.prio_=prio_||0;this.number_=(number_!==undefined&&number_!==null)?number_:0;this.toString=function(){switch(this.type_){case TNUMBER:return this.number_;case TOP1:case TOP2:case TOP3:case TVAR:return this.index_;case TFUNCALL:return'CALL';case SEP:return'SEPARATOR';default:return'Invalid Token'}}}
function Expression(tokens,ops1,ops2,functions,ops3,ops3Trail){this.tokens=tokens}
var escapable=/[\\\'\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;var meta={'\b':IMLib.backSlash_char+'b','\t':IMLib.backSlash_char+'t','\n':IMLib.backSlash_char+'n','\f':IMLib.backSlash_char+'f','\r':IMLib.backSlash_char+'r','\'':IMLib.backSlash_char+IMLib.singleQuote_char,'\\':IMLib.backSlash_char+IMLib.backSlash_char};function escapeValue(v){if(typeof v==='string'){escapable.lastIndex=0;return escapable.test(v)?IMLib.singleQuote_char+v.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})+IMLib.singleQuote_char:IMLib.singleQuote_char+v+IMLib.singleQuote_char}
return v}
Expression.prototype={simplify:function(values){values=values||{};var nstack=[];var newexpression=[];var n1;var n2;var n3;var f;var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TNUMBER){nstack.push(item)}else if(type_===TVAR&&(item.index_ in values)){item=new Token(TNUMBER,0,0,values[item.index_]);nstack.push(item)}else if(type_===TOP3&&nstack.length>2){n3=nstack.pop();n2=nstack.pop();n1=nstack.pop();f=Parser.ops3[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_,n2.number_,n3.number_));nstack.push(item)}else if(type_===TOP2&&nstack.length>1){n2=nstack.pop();n1=nstack.pop();f=Parser.ops2[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_,n2.number_));nstack.push(item)}else if(type_===TOP1&&nstack.length>0){n1=nstack.pop();f=Parser.ops1[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_));nstack.push(item)}else{while(nstack.length>0){newexpression.push(nstack.shift())}
newexpression.push(item)}}
while(nstack.length>0){newexpression.push(nstack.shift())}
return new Expression(newexpression)},substitute:function(variable,expr){if(!(expr instanceof Expression)){expr=new Parser().parse(String(expr))}
var newexpression=[];var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TVAR&&item.index_===variable){for(var j=0;j<expr.tokens.length;j++){var expritem=expr.tokens[j];var replitem=new Token(expritem.type_,expritem.index_,expritem.prio_,expritem.number_);newexpression.push(replitem)}}else{newexpression.push(item)}}
return new Expression(newexpression)},evaluate:function(values){values=values||{};var nstack=[];var n1;var n2;var n3;var f;var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TNUMBER){nstack.push(item.number_)}else if(type_===TOP3){n3=nstack.pop();n2=nstack.pop();n1=nstack.pop();f=Parser.ops3Trail[item.index_];nstack.push(f(n1,n2,n3))}else if(type_===TOP2){n2=nstack.pop();n1=nstack.pop();f=Parser.ops2[item.index_];nstack.push(f(n1,n2))}else if(type_===TVAR){if(item.index_ in values){nstack.push(values[item.index_])}else if(item.index_ in Parser.functions){nstack.push(Parser.functions[item.index_])}else{throw new Error('undefined variable: '+item.index_)}}else if(type_===TOP1){n1=nstack.pop();f=Parser.ops1[item.index_];nstack.push(f(n1))}else if(type_===SEP){n2=nstack.pop();n1=nstack.pop();nstack.push([n1,n2])}else if(type_===TFUNCALL){n1=nstack.pop();f=nstack.pop();if(f.apply&&f.call){if(Object.prototype.toString.call(n1)=='[object Array]'){nstack.push(f.apply(undefined,n1))}else{nstack.push(f.call(undefined,n1))}}else{throw new Error(f+' is not a function')}}else{throw new Error('invalid Expression')}}
if(nstack.length>1){throw new Error('invalid Expression (parity)')}
return nstack[0]},variables:function(){var L=this.tokens.length;var vars=[];for(var i=0;i<L;i++){var item=this.tokens[i];if(item.type_===TVAR&&(vars.indexOf(item.index_)==-1)&&!(item.index_ in Parser.functions)){vars.push(item.index_)}}
return vars}};function iff(a,b,c){var vala,valb,valc;vala=(a instanceof Array)?arguments[0][0]:arguments[0];valb=(b instanceof Array)?arguments[1][0]:arguments[1];valc=(c instanceof Array)?arguments[2][0]:arguments[2];return vala?valb:valc}
function greaterthan(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)>Number(numb)}
return a>b}
function lessthan(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)<Number(numb)}
return a<b}
function greaterequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)>=Number(numb)}
return a>=b}
function lessequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)<=Number(numb)}
return a<=b}
function equal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)==Number(numb)}
return a==b}
function notequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)!=Number(numb)}
return a!=b}
function isReallyNaN(x){return x!==x}
function add(a,b){var numa,numb;if((typeof a)=="string"||(typeof b)=="string"){return addstring(a,b)}
if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numb)){return Number(numa)+Number(numb)}
return a+b}
function addstring(a,b){return String(a)+String(b)}
function sub(a,b){var numa,numb,str,pos;if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numb)){return numa-numb}
str=String(a);do{pos=str.indexOf(b);if(pos>-1){str=str.substr(0,pos)+str.substr(pos+b.length)}}while(pos>-1);return str}
function mul(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a*b}
function div(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a/b}
function mod(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a%b}
function neg(a){if(isReallyNaN(a)){return NaN}
a=toNumber(a);return-a}
function random(a){a=toNumber(a);return Math.random()*(a||1)}
function fac(a){if(isReallyNaN(a)){return NaN}
a=toNumber(a);a=Math.floor(a);var b=a;while(a>1){b=b*(--a)}
return b}
function logicalnot(a){a=toNumber(a);return!a}
function logicaland(a,b){a=toNumber(a);b=toNumber(b);return a&&b}
function logicalor(a,b){a=toNumber(a);b=toNumber(b);return a||b}
function sumfunc(){var result=0,i;for(i=0;i<arguments.length;i++){result+=toNumber(arguments[i])}
return result}
function averagefunc(){var result=0,i,count=0;for(i=0;i<arguments.length;i++){result+=toNumber(arguments[i]);count++}
return result/count}
function countElements(){var i,count=0;for(i=0;i<arguments.length;i++){count+=Array.isArray(arguments[i])?arguments[i].length:1}
return count}
function listfunc(){var result=IMLib.zerolength_str,i;for(i=0;i<arguments.length;i++){result+=String(arguments[i]);result+=IMLib.nl_char}
return result}
function roundfunc(a,b){if(b==undefined){return Math.round(a)}else{a=(a instanceof Array)?a.join():a;b=(b instanceof Array)?b.join():b;return INTERMediatorLib.Round(a,b)}}
function length(a){if(a==undefined||a==null){return 0}else{a=(a instanceof Array)?a.join():a;return(new String(a)).length}}
function toNumber(str){var value;if(str===undefined){return NaN}
if(str===!0){return!0}
if(str===!1){return!1}
if(str==IMLib.zerolength_str){return 0}
value=str;if(INTERMediatorLib.is_array(str)){if(str.length<1){return 0}else{value=str[0]}}
value=unformat(value);return value}
function pyt(a,b){return Math.sqrt(a*a+b*b)}
function append(a,b){if(Object.prototype.toString.call(a)!='[object Array]'){return[a,b]}
a=a.slice();a.push(b);return a}
function charsetand(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<stra.length;i++){if(strb.indexOf(stra.substr(i,1))>-1){result+=stra.substr(i,1)}}
return result}
function charsetor(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<strb.length;i++){if(stra.indexOf(strb.substr(i,1))<0){result+=strb.substr(i,1)}}
return stra+result}
function charsetnoother(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<stra.length;i++){if(strb.indexOf(stra.substr(i,1))<0){result+=stra.substr(i,1)}}
return result}
function parametersOfMultiline(a,b){var stra,strb,arraya,arrayb,i,nls,nl=IMLib.nl_char;stra=(a instanceof Array)?a.join():a;nls=[stra.indexOf(IMLib.crlf_str),stra.indexOf(IMLib.cr_char),stra.indexOf(IMLib.nl_char)];for(i=0;i<nls.length;i++){nls[i]=(nls[i]<0)?stra.length:nls[i]}
if(nls[0]<stra.length&&nls[0]<=nls[1]&&nls[0]<nls[2]){nl=IMLib.crlf_str}else if(nls[1]<stra.length&&nls[1]<nls[0]&&nls[1]<nls[2]){nl=IMLib.cr_char}
arraya=stra.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char).split(IMLib.nl_char);strb=(b instanceof Array)?b.join():b;arrayb=strb.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char).split(IMLib.nl_char);return[arraya,arrayb,nl]}
function itemsetand(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arrayb.indexOf(arraya[i])>-1&&arraya[i].length>0){result+=arraya[i]+nl}}
return result}
function itemsetor(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arraya[i].length>0){result+=arraya[i]+nl}}
for(i=0;i<arrayb.length;i++){if(arraya.indexOf(arrayb[i])<0&&arrayb[i].length>0){result+=arrayb[i]+nl}}
return result}
function itemsetnoother(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arrayb.indexOf(arraya[i])<0&&arraya[i].length>0){result+=arraya[i]+nl}}
return result}
function itematindex(a,start,end){var params,arraya,nl,i,result='';params=parametersOfMultiline(a,'');arraya=params[0];nl=params[2];end=(end==undefined)?arraya.length:end;for(i=start;(i<start+end)&&(i<arraya.length);i++){result+=arraya[i]+nl}
return result}
function itemIndexOfFunc(list,str){if(!list){return-1}
var a=list.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char);var ix=0;var item,pos;while(a.length>0){pos=a.indexOf(IMLib.nl_char);if(pos>-1){item=a.substr(0,pos);a=a.substr(pos+1)}else{item=a;a=IMLib.zerolength_str}
if(item==str){return ix}
ix++}
return-1}
function numberformat(val,digit){var stra,strb;stra=(val instanceof Array)?val.join():val;strb=(digit instanceof Array)?digit.join():digit;return IMLibFormat.numberFormat(stra,strb,{useSeparator:!0})}
function currencyformat(val,digit){var stra,strb;stra=(val instanceof Array)?val.join():val;strb=(digit instanceof Array)?digit.join():digit;return IMLibFormat.currencyFormat(stra,strb,{useSeparator:!0})}
function substr(str,pos,len){var stra,p,l;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;p=(pos instanceof Array)?pos.join():pos;l=(len instanceof Array)?len.join():len;return stra.substr(p,l)}
function substring(str,start,end){var stra,s,e;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(start instanceof Array)?start.join():start;e=(end instanceof Array)?end.join():end;return stra.substring(s,e)}
function leftstring(str,start){var stra,s;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);return stra.substring(0,s)}
function midstring(str,start,end){var stra,s,e;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);e=parseInt((end instanceof Array)?end.join():end);return stra.substr(s,e)}
function rightstring(str,start){var stra,s;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);return stra.substring(stra.length-s)}
function indexof(str,search,from){var stra,s;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;if(from==undefined){return stra.indexOf(s)}
return stra.indexOf(s,from)}
function lastindexof(str,search,from){var stra,s;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;if(from==undefined){return stra.lastIndexOf(s)}
return stra.lastIndexOf(s,from)}
function replace(str,start,end,rep){var stra,s,e,r;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(start instanceof Array)?start.join():start;e=(end instanceof Array)?end.join():end;r=(rep instanceof Array)?rep.join():rep;return stra.substr(0,s)+r+stra.substr(e)}
function substitute(str,search,rep){var stra,s,r,reg;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;r=(rep instanceof Array)?rep.join():rep;reg=new RegExp(s,'g');return stra.replace(reg,r)}
function match(str,pattern){var stra,p;stra=(str instanceof Array)?str.join():str;p=(pattern instanceof Array)?pattern.join():pattern;return stra.match(new RegExp(p))}
function test(str,pattern){var stra,p;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;p=(pattern instanceof Array)?pattern.join():pattern;return(new RegExp(p)).test(stra)}
Parser.timeOffset=(new Date()).getTimezoneOffset();function DateInt(str){var theDate;if(str===undefined){theDate=Date.now()}else{theDate=Date.parse(str.replace(/-/g,'/'));theDate-=Parser.timeOffset*60000}
return parseInt(theDate/86400000)}
function SecondInt(str){var theDate;if(str===undefined){theDate=Date.now()}else{theDate=Date.parse(str.replace(/-/g,'/'))}
return parseInt(theDate/1000)}
function dvalue(s){if(parseInt(s).length==s.length){return s}else{return DateInt(s)}}
function dtvalue(s){if(parseInt(s).length==s.length){return s}else{return SecondInt(s)}}
function calcDateComponent(d,a,index){var dtComp=[];dtComp.push(yeard(d));dtComp.push(monthd(d));dtComp.push(dayd(d));dtComp[index]+=a;return datecomponents(dtComp[0],dtComp[1],dtComp[2])}
function calcDateTimeComponent(dt,a,index){var dtComp=[];dtComp.push(yeardt(dt));dtComp.push(monthdt(dt));dtComp.push(daydt(dt));dtComp.push(hourdt(dt));dtComp.push(minutedt(dt));dtComp.push(seconddt(dt));dtComp[index]+=a;return datetimecomponents(dtComp[0],dtComp[1],dtComp[2],dtComp[3],dtComp[4],dtComp[5])}
function datecomponents(y,m,d){var m0=m-1;if(m0<0||m0>11){y+=parseInt(m0/12);m=m0%12+1}
return parseInt(Date.UTC(y,m-1,d,0,0,0)/86400000)}
function datetimecomponents(y,m,d,h,i,s){if(s<0||s>59){i+=parseInt(s/60);s=s%60}
if(i<0||i>59){h+=parseInt(i/60);i=i%60}
if(h<0||h>23){d+=parseInt(h/24);h=h%24}
var m0=m-1;if(m0<0||m0>11){y+=parseInt(m0/12);m=m0%12+1}
return Date.UTC(y,m-1,d,h,i,s)/1000}
function yearAlt(d){return INTERMediator.dateTimeFunction?yeardt(d):yeard(d)}
function monthAlt(d){return INTERMediator.dateTimeFunction?monthdt(d):monthd(d)}
function dayAlt(d){return INTERMediator.dateTimeFunction?daydt(d):dayd(d)}
function weekdayAlt(d){return INTERMediator.dateTimeFunction?weekdaydt(d):weekdayd(d)}
function hourAlt(d){return INTERMediator.dateTimeFunction?hourdt(d):0}
function minuteAlt(d){return INTERMediator.dateTimeFunction?minutedt(d):0}
function secondAlt(d){return INTERMediator.dateTimeFunction?seconddt(d):0}
function yeard(d){return new Date(dvalue(d)*86400000).getFullYear()}
function monthd(d){return new Date(dvalue(d)*86400000).getMonth()+1}
function dayd(d){return new Date(dvalue(d)*86400000).getDate()}
function weekdayd(d){return new Date(dvalue(d)*86400000).getDay()}
function yeardt(dt){return new Date(dtvalue(dt)*1000).getFullYear()}
function monthdt(dt){return new Date(dtvalue(dt)*1000).getMonth()+1}
function daydt(dt){return new Date(dtvalue(dt)*1000).getDate()}
function weekdaydt(dt){return new Date(dtvalue(dt)*1000).getDay()}
function hourdt(dt){return new Date(dtvalue(dt)*1000).getHours()}
function minutedt(dt){return new Date(dtvalue(dt)*1000).getMinutes()}
function seconddt(dt){return new Date(dtvalue(dt)*1000).getSeconds()}
function addyear(d,a){return INTERMediator.dateTimeFunction?addyeardt(d,a):addyeard(d,a)}
function addmonth(d,a){return INTERMediator.dateTimeFunction?addmonthdt(d,a):addmonthd(d,a)}
function addday(d,a){return INTERMediator.dateTimeFunction?adddaydt(d,a):adddayd(d,a)}
function addhour(d,a){return INTERMediator.dateTimeFunction?addhourdt(d,a):NaN}
function addminute(d,a){return INTERMediator.dateTimeFunction?addminutedt(d,a):NaN}
function addsecond(d,a){return INTERMediator.dateTimeFunction?addseconddt(d,a):NaN}
function addyeard(d,a){return calcDateComponent(d,a,0)}
function addmonthd(d,a){return calcDateComponent(d,a,1)}
function adddayd(d,a){return calcDateComponent(d,a,2)}
function addyeardt(dt,a){return calcDateTimeComponent(dt,a,0)}
function addmonthdt(dt,a){return calcDateTimeComponent(dt,a,1)}
function adddaydt(dt,a){return calcDateTimeComponent(dt,a,2)}
function addhourdt(dt,a){return calcDateTimeComponent(dt,a,3)}
function addminutedt(dt,a){return calcDateTimeComponent(dt,a,4)}
function addseconddt(dt,a){return calcDateTimeComponent(dt,a,5)}
function endofmonth(d){return INTERMediator.dateTimeFunction?endofmonthdt(d):endofmonthd(d)}
function endofmonthd(d){return adddayd(addmonthd(startofmonthd(d),1),-1)}
function endofmonthdt(dt){return addseconddt(addmonthdt(startofmonthdt(dt),1),-1)}
function startofmonth(d){return INTERMediator.dateTimeFunction?startofmonthdt(d):startofmonthd(d)}
function startofmonthd(d){var str=yeard(d)+'/'+('0'+monthd(d)).substr(-2,2)+'/01';return DateInt(str)}
function startofmonthdt(dt){var str=yeardt(dt)+'/'+('0'+monthdt(dt)).substr(-2,2)+'/01 00:00:00';return SecondInt(str)}
function today(){return parseInt(Date.now()/86400)}
function nowFunction(){return parseInt(Date.now()/1000)}
function unformat(value){var valueString,numberString,i,c;valueString=String(value);numberString=IMLib.zerolength_str;for(i=0;i<valueString.length;i++){c=valueString.substr(i,1);if(c>='0'&&c<='9'){numberString+=c}else if(c>='0'&&c<='9'){numberString+=String.fromCharCode('0'.charCodeAt(0)+c.charCodeAt(0)-'0'.charCodeAt(0))}else if(c=='.'||c=='-'){numberString+=c}}
return parseFloat(numberString)}
function choiceFunc(){var index;if(arguments[0]==null||arguments[0]==undefined){return arguments[0]}
index=parseInt(arguments[0]);if(index<0||index>=(arguments.length-1)){return undefined}
return arguments[index+1]}
function conditionFunc(){var index;for(index=0;index<arguments.length;index+=2){if(arguments[index]==!0&&index+1<arguments.length){return arguments[index+1]}}
return undefined}
function accumulateFunc(){var index,c='';for(index=0;index<arguments.length;index+=2){if(arguments[index]==!0&&index+1<arguments.length){c=c+arguments[index+1]+'\n'}}
return c}
function Parser(){this.success=!1;this.errormsg=IMLib.zerolength_str;this.expression=IMLib.zerolength_str;this.pos=0;this.tokennumber=0;this.tokenprio=0;this.tokenindex=0;this.tmpprio=0;Parser.functions={'count':countElements,'random':random,'fac':fac,'min':Math.min,'max':Math.max,'pyt':pyt,'pow':Math.pow,'atan2':Math.atan2,'if':iff,'sum':sumfunc,'average':averagefunc,'list':listfunc,'format':numberformat,'currency':currencyformat,'substr':substr,'substring':substring,'indexof':indexof,'lastindexof':lastindexof,'replace':replace,'substitute':substitute,'match':match,'test':test,'sin':Math.sin,'cos':Math.cos,'tan':Math.tan,'asin':Math.asin,'acos':Math.acos,'atan':Math.atan,'sqrt':Math.sqrt,'log':Math.log,'abs':Math.abs,'ceil':Math.ceil,'floor':Math.floor,'round':roundfunc,'exp':Math.exp,'items':itematindex,'length':length,'datetime':SecondInt,'date':DateInt,'datecomponents':datecomponents,'datetimecomponents':datetimecomponents,'year':yearAlt,'month':monthAlt,'day':dayAlt,'weekday':weekdayAlt,'hour':hourAlt,'minute':minuteAlt,'second':secondAlt,'yeard':yeard,'monthd':monthd,'dayd':dayd,'weekdayd':weekdayd,'yeardt':yeardt,'monthdt':monthdt,'daydt':daydt,'weekdaydt':weekdaydt,'hourdt':hourdt,'minutedt':minutedt,'seconddt':seconddt,'addyear':addyear,'addmonth':addmonth,'addday':addday,'addhour':addhour,'addminute':addminute,'addsecond':addsecond,'addyeard':addyeard,'addmonthd':addmonthd,'adddayd':adddayd,'addyeardt':addyeardt,'addmonthdt':addmonthdt,'adddaydt':adddaydt,'addhourdt':addhourdt,'addminutedt':addminutedt,'addseconddt':addseconddt,'endofmonth':endofmonth,'startofmonth':startofmonth,'endofmonthd':endofmonthd,'startofmonthd':startofmonthd,'endofmonthdt':endofmonthdt,'startofmonthdt':startofmonthdt,'today':today,'now':nowFunction,'right':rightstring,'mid':midstring,'left':leftstring,'itemIndexOf':itemIndexOfFunc,'choice':choiceFunc,'condition':conditionFunc,'accumulate':accumulateFunc};this.consts={'E':Math.E,'PI':Math.PI};Parser.operators={'!':[1,logicalnot,2],'+':[2,add,4],'⊕':[2,addstring,4],'-':[2,sub,4],'*':[2,mul,3],'/':[2,div,3],'%':[2,mod,3],'^':[2,Math.pow,1],',':[2,append,15],'>':[2,greaterthan,6],'<':[2,lessthan,6],'>=':[2,greaterequal,6],'<=':[2,lessequal,6],'==':[2,equal,7],'=':[2,equal,7],'!=':[2,notequal,7],'<>':[2,notequal,7],'&&':[2,logicaland,11],'||':[2,logicalor,12],'∩':[2,charsetand,3],'∪':[2,charsetor,4],'⊁':[2,charsetnoother,4],'⋀':[2,itemsetand,3],'⋁':[2,itemsetor,4],'⊬':[2,itemsetnoother,4],'?':[2,iff,13],':':[4,iff,13]};Parser.ops1={'-':neg};Parser.ops2={};Parser.ops3={};Parser.ops3Trail={};for(var op in Parser.operators){if(Parser.operators.hasOwnProperty(op)){switch(Parser.operators[op][0]){case 1:Parser.ops1[op]=Parser.operators[op][1];break;case 2:Parser.ops2[op]=Parser.operators[op][1];break;case 3:Parser.ops3[op]=Parser.operators[op][1];break;case 4:Parser.ops3Trail[op]=Parser.operators[op][1];break}}}}
Parser.parse=function(expr){return new Parser().parse(expr)};Parser.evaluate=function(expr,variables){var result;result=Parser.parse(expr).evaluate(variables);return result};Parser.Expression=Expression;var PRIMARY=1<<0;var OPERATOR=1<<1;var FUNCTION=1<<2;var LPAREN=1<<3;var RPAREN=1<<4;var COMMA=1<<5;var SIGN=1<<6;var CALL=1<<7;var NULLARY_CALL=1<<8;Parser.prototype={parse:function(expr){this.errormsg=IMLib.zerolength_str;this.success=!0;var operstack=[];var tokenstack=[];this.tmpprio=0;var expected=(PRIMARY|LPAREN|FUNCTION|SIGN);var noperators=0;this.expression=expr;this.pos=0;var funcstack=[],token;while(this.pos<this.expression.length){if(this.isOperator()){if(this.isSign()&&(expected&SIGN)){if(this.isNegativeSign()){this.tokenprio=2;this.tokenindex='-';noperators++;this.addfunc(tokenstack,operstack,TOP1)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN)}else if(this.isComment()){}else{if((expected&OPERATOR)===0){this.error_parsing(this.pos,'unexpected operator')}
if(this.tokenindex=='?'){this.tmpprio-=40;this.tokenindex='if';this.addfunc(tokenstack,operstack,TOP2);this.tmpprio+=40;this.tokenindex=',';noperators+=3;this.addfunc(tokenstack,operstack,TOP2)}else if(this.tokenindex==':'){this.tokenindex=',';noperators+=2;this.addfunc(tokenstack,operstack,TOP2)}else{noperators+=2;this.addfunc(tokenstack,operstack,TOP2)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN)}}else if(this.isNumber()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected number')}
token=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(token);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isString()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected string')}
token=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(token);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isLeftParenth()){if((expected&LPAREN)===0){this.error_parsing(this.pos,'unexpected \'(\"')}
if(expected&CALL){funcstack.push(!0)}else{funcstack.push(!1)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN|NULLARY_CALL)}else if(this.isRightParenth()){var isFunc=funcstack.pop();if(isFunc){noperators+=2;this.tokenprio=-2;this.tokenindex=-1;this.addfunc(tokenstack,operstack,TFUNCALL)}
if(expected&NULLARY_CALL){token=new Token(TNUMBER,0,0,[]);tokenstack.push(token)}else if((expected&RPAREN)===0){this.error_parsing(this.pos,'unexpected \")\"')}
expected=(OPERATOR|RPAREN|COMMA|LPAREN|CALL)}else if(this.isConst()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected constant')}
var consttoken=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(consttoken);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isVar()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected variable')}
var vartoken=new Token(TVAR,this.tokenindex,0,0);tokenstack.push(vartoken);expected=(OPERATOR|RPAREN|COMMA|LPAREN|CALL)}else if(this.isWhite()){}else{if(this.errormsg===IMLib.zerolength_str){this.error_parsing(this.pos,'unknown character')}else{this.error_parsing(this.pos,this.errormsg)}}}
if(this.tmpprio<0||this.tmpprio>=10){this.error_parsing(this.pos,'unmatched \"()\"')}
while(operstack.length>0){var tmp=operstack.pop();tokenstack.push(tmp)}
return new Expression(tokenstack)},evaluate:function(expr,variables){var result;this.parse(expr).evaluate(variables);return result},error_parsing:function(column,msg){this.success=!1;this.errormsg='parse error [column '+(column)+']: '+msg;throw new Error(this.errormsg)},addfunc:function(tokenstack,operstack,type_){var operator=new Token(type_,this.tokenindex,this.tokenprio+this.tmpprio,0);while(operstack.length>0){if(operator.prio_>=operstack[operstack.length-1].prio_){tokenstack.push(operstack.pop())}else{break}}
operstack.push(operator)},isNumber:function(){var r=!1;var str=IMLib.zerolength_str;while(this.pos<this.expression.length){var code=this.expression.charCodeAt(this.pos);if((code>=48&&code<=57)||code===46){str+=this.expression.charAt(this.pos);this.pos++;this.tokennumber=parseFloat(str);r=!0}else{break}}
return r},unescape:function(v,pos){var buffer=[];var escaping=!1;for(var i=0;i<v.length;i++){var c=v.charAt(i);if(escaping){switch(c){case IMLib.singleQuote_char:buffer.push(IMLib.singleQuote_char);break;case IMLib.backSlash_char:buffer.push(IMLib.backSlash_char);break;case '/':buffer.push('/');break;case 'b':buffer.push('\b');break;case 'f':buffer.push('\f');break;case 'n':buffer.push(IMLib.nl_char);break;case 'r':buffer.push(IMLib.cr_char);break;case 't':buffer.push(IMLib.tab_char);break;case 'u':var codePoint=parseInt(v.substring(i+1,i+5),16);buffer.push(String.fromCharCode(codePoint));i+=4;break;default:throw this.error_parsing(pos+i,'Illegal escape sequence: \'\\'+c+IMLib.singleQuote_char)}
escaping=!1}else{if(c==IMLib.backSlash_char){escaping=!0}else{buffer.push(c)}}}
return buffer.join('')},isString:function(){var r=!1;var str=IMLib.zerolength_str;var startpos=this.pos;if(this.pos<this.expression.length&&this.expression.charAt(this.pos)==IMLib.singleQuote_char){this.pos++;while(this.pos<this.expression.length){var code=this.expression.charAt(this.pos);if(code!=IMLib.singleQuote_char||str.slice(-1)==IMLib.backSlash_char){str+=this.expression.charAt(this.pos);this.pos++}else{this.pos++;this.tokennumber=this.unescape(str,startpos);r=!0;break}}}
return r},isConst:function(){var str,i;for(i in this.consts){if(this.consts.hasOwnProperty(i)){var L=i.length;str=this.expression.substr(this.pos,L);if(i===str){this.tokennumber=this.consts[i];this.pos+=L;return!0}}}
return!1},isOperator:function(){var code;if(this.pos+1<this.expression.length){code=this.expression.substr(this.pos,2);if(Parser.operators[code]){this.tokenprio=Parser.operators[code][2];this.tokenindex=code;this.pos+=2;return!0}}
code=this.expression.substr(this.pos,1);if(Parser.operators[code]){this.tokenprio=Parser.operators[code][2];this.tokenindex=code;this.pos++;return!0}
return!1},isSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===45||code===43){return!0}
return!1},isPositiveSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===43){return!0}
return!1},isNegativeSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===45){return!0}
return!1},isLeftParenth:function(){var code=this.expression.charCodeAt(this.pos);if(code===40){this.pos++;this.tmpprio-=20;return!0}
return!1},isRightParenth:function(){var code=this.expression.charCodeAt(this.pos);if(code===41){this.pos++;this.tmpprio+=20;return!0}
return!1},isComma:function(){var code=this.expression.charCodeAt(this.pos);if(code===44){this.pos++;this.tokenprio=15;this.tokenindex=',';return!0}
return!1},isWhite:function(){var code=this.expression.charCodeAt(this.pos);if(code===32||code===9||code===10||code===13){this.pos++;return!0}
return!1},isVar:function(){var str=IMLib.zerolength_str;for(var i=this.pos;i<this.expression.length;i++){var c=this.expression.charAt(i);if(i===this.pos){if(!c.match(Parser.regFirstVarChar)){break}}else{if(!c.match(Parser.regRestVarChar)){break}}
str+=c}
if(str.length>0){this.tokenindex=str;this.tokenprio=0;this.pos+=str.length;return!0}
return!1},isComment:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===47&&this.expression.charCodeAt(this.pos)===42){this.pos=this.expression.indexOf('*/',this.pos)+2;if(this.pos===1){this.pos=this.expression.length}
return!0}
return!1}};scope.Parser=Parser;return Parser})(typeof exports==='undefined'?{}:exports);var IMLibCalc={calculateRequiredObject:null,updateCalculationInfo:function(contextObj,keyingValue,nodeId,nInfo,currentRecord){'use strict';var calcDef,exp,field,elements,i,index,objectKey,itemIndex,values,referes,calcDefField,atPos,fieldLength;calcDef=contextObj.getContextDef().calculation;for(index in calcDef){if(calcDef.hasOwnProperty(index)){atPos=calcDef[index].field.indexOf(INTERMediator.separator);fieldLength=calcDef[index].field.length;calcDefField=calcDef[index].field.substring(0,atPos>=0?atPos:fieldLength);if(calcDefField===nInfo.field){try{exp=calcDef[index].expression;field=calcDef[index].field;elements=Parser.parse(exp).variables();objectKey=nodeId+(nInfo.target.length>0?(INTERMediator.separator+nInfo.target):'')}catch(ex){INTERMediatorLog.setErrorMessage(ex,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1036],[field,exp]))}
if(elements&&objectKey){values={};referes={};for(i=0;i<elements.length;i++){itemIndex=elements[i];if(itemIndex){values[itemIndex]=currentRecord[itemIndex];referes[itemIndex]=undefined}
contextObj.setValue(keyingValue,itemIndex,currentRecord[itemIndex],nodeId,nInfo.target,null)}
IMLibCalc.calculateRequiredObject[objectKey]={'field':field,'expression':exp,'nodeInfo':nInfo,'values':values,'referes':referes}}}}}},updateCalculationFields:function(){'use strict';var nodeId,exp,nInfo,valuesArray,leafNodes,calcObject,ix,refersArray,key,fName,vArray;var targetNode,field,valueSeries,targetElement,i,hasReferes,contextInfo,idValue,record,val;IMLibCalc.setUndefinedToAllValues();IMLibNodeGraph.clear();for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];if(calcObject){hasReferes=!1;for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){IMLibNodeGraph.addEdge(nodeId,calcObject.referes[field][ix]);hasReferes=!1}}}
if(!hasReferes){IMLibNodeGraph.addEdge(nodeId)}}}}
do{leafNodes=IMLibNodeGraph.getLeafNodesWithRemoving();for(i=0;i<leafNodes.length;i++){calcObject=IMLibCalc.calculateRequiredObject[leafNodes[i]];if(calcObject){idValue=leafNodes[i].match(IMLibCalc.regexpForSeparator)?leafNodes[i].split(IMLibCalc.regexpForSeparator)[0]:leafNodes[i];targetNode=document.getElementById(idValue);exp=calcObject.expression;nInfo=calcObject.nodeInfo;valuesArray=calcObject.values;refersArray=calcObject.referes;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nInfo.target);if(contextInfo&&contextInfo.context){record=contextInfo.context.getContextRecord(idValue)}else{record=null}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){if(field.indexOf(nInfo.table+'@')===0){fName=field.substr(field.indexOf('@')+1);vArray=[];for(key in contextInfo.context.store){if(contextInfo.context.store.hasOwnProperty(key)&&contextInfo.context.store[key][fName]){vArray.push(contextInfo.context.store[key][fName])}}
valuesArray[field]=vArray}}}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){valueSeries=[];for(ix=0;ix<valuesArray[field].length;ix++){if(valuesArray[field][ix]===undefined){if(record[field]){valueSeries.push(record[field])}else if(refersArray[field][ix]){targetElement=document.getElementById(refersArray[field][ix]);valueSeries.push(IMLibElement.getValueFromIMNode(targetElement))}}else{valueSeries.push(valuesArray[field][ix])}}
calcObject.values[field]=valueSeries}}
val=Parser.evaluate(exp,valuesArray);IMLibElement.setValueToIMNode(targetNode,nInfo.target,val,!0);contextInfo.context.setValue(contextInfo.record,contextInfo.field,val,nodeId,targetNode,!1)}}}while(leafNodes.length>0);if(IMLibNodeGraph.nodes.length>0){INTERMediatorLog.setErrorMessage(new Error('Expressons are cyclic.'),INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1037],[]))}},recalculation:function(updatedNodeId){'use strict';var nodeId,newValueAdded,leafNodes,calcObject,ix,updatedValue,isRecalcAll=!1,targetNode;var newValue,field,i,updatedNodeIds,updateNodeValues,cachedIndex,nInfo,valuesArray;var refersArray,valueSeries,targetElement,contextInfo,record,idValue,key,fName,vArray;if(updatedNodeId===undefined){isRecalcAll=!0;updatedNodeIds=[];updateNodeValues=[]}else{newValue=IMLibElement.getValueFromIMNode(document.getElementById(updatedNodeId));updatedNodeIds=[updatedNodeId];updateNodeValues=[newValue]}
IMLibCalc.setUndefinedToAllValues();IMLibNodeGraph.clear();for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){IMLibNodeGraph.addEdge(nodeId,calcObject.referes[field][ix])}}}}}
do{leafNodes=IMLibNodeGraph.getLeafNodesWithRemoving();for(i=0;i<leafNodes.length;i++){calcObject=IMLibCalc.calculateRequiredObject[leafNodes[i]];if(calcObject){idValue=leafNodes[i].match(IMLibCalc.regexpForSeparator)?leafNodes[i].split(IMLibCalc.regexpForSeparator)[0]:leafNodes[i];targetNode=document.getElementById(idValue);nInfo=calcObject.nodeInfo;valuesArray=calcObject.values;refersArray=calcObject.referes;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nInfo.target);if(contextInfo&&contextInfo.context){record=contextInfo.context.getContextRecord(idValue)}else{record=null}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){if(field.indexOf(nInfo.table+'@')===0){fName=field.substr(field.indexOf('@')+1);vArray=[];for(key in contextInfo.context.store){if(contextInfo.context.store.hasOwnProperty(key)&&contextInfo.context.store[key][fName]){vArray.push(contextInfo.context.store[key][fName])}}
valuesArray[field]=vArray}}}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){valueSeries=[];for(ix=0;ix<valuesArray[field].length;ix++){if(valuesArray[field][ix]===undefined){if(record[field]){valueSeries.push(record[field])}else if(refersArray[field][ix]){targetElement=document.getElementById(refersArray[field][ix]);valueSeries.push(IMLibElement.getValueFromIMNode(targetElement))}}else{valueSeries.push(valuesArray[field][ix])}}
calcObject.values[field]=valueSeries}}
if(isRecalcAll){newValueAdded=!0}else{newValueAdded=!1;for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){cachedIndex=updatedNodeIds.indexOf(calcObject.referes[field][ix]);if(cachedIndex>=0){calcObject.values[field][ix]=updateNodeValues[cachedIndex];newValueAdded=!0}}}}}
if(newValueAdded){updatedValue=Parser.evaluate(calcObject.expression,calcObject.values);IMLibElement.setValueToIMNode(document.getElementById(idValue),nInfo.target,updatedValue,!0);updatedNodeIds.push(idValue);updateNodeValues.push(updatedValue);contextInfo.context.setValue(contextInfo.record,contextInfo.field,updatedValue,idValue,targetNode,!1)}}}}while(leafNodes.length>0);if(IMLibNodeGraph.nodes.length>0){INTERMediatorLog.setErrorMessage(new Error('Expressons are cyclic.'),INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1037],[]))}},setUndefinedToAllValues:function(){'use strict';var nodeId,calcObject,ix,targetNode,field,targetExp,targetIds,isContextName,isRemoved,idValue,repeaterTop,checkRepeater,nodeInfo,linkInfos;do{isRemoved=!1;for(nodeId in IMLibCalc.calculateRequiredObject){idValue=nodeId.match(IMLibCalc.regexpForSeparator)?nodeId.split(IMLibCalc.regexpForSeparator)[0]:nodeId;if(!document.getElementById(idValue)){delete IMLibCalc.calculateRequiredObject[nodeId];isRemoved=!0;break}}}while(isRemoved);for(nodeId in IMLibCalc.calculateRequiredObject){calcObject=IMLibCalc.calculateRequiredObject[nodeId];idValue=nodeId.match(IMLibCalc.regexpForSeparator)?nodeId.split(IMLibCalc.regexpForSeparator)[0]:nodeId;targetNode=document.getElementById(idValue);linkInfos=INTERMediatorLib.getLinkedElementInfo(targetNode);if(INTERMediatorLib.is_array(linkInfos)){linkInfos=linkInfos[0]}
nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos);for(field in calcObject.values){if(field.indexOf(INTERMediator.separator)>-1){targetExp=field;isContextName=!0}else{targetExp=calcObject.nodeInfo.table+INTERMediator.separator+field;isContextName=!1}
if(nodeInfo&&nodeInfo.crossTable){repeaterTop=targetNode;while(repeaterTop.tagName!=='TD'&&repeaterTop.tagName!=='TH'){repeaterTop=repeaterTop.parentNode}
do{targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromNode(repeaterTop,targetExp);if(targetIds&&targetIds.length>0){break}
repeaterTop=getParentRepeater(INTERMediatorLib.getParentEnclosure(repeaterTop))}while(repeaterTop);}else{checkRepeater=targetNode;do{targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromRepeater(checkRepeater,targetExp);if(targetIds&&targetIds.length>0){break}
if(isContextName){targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromEnclosure(checkRepeater,targetExp);if(targetIds&&targetIds.length>0){break}}
checkRepeater=getParentRepeater(INTERMediatorLib.getParentEnclosure(checkRepeater))}while(checkRepeater);}
if(INTERMediatorLib.is_array(targetIds)&&targetIds.length>0){calcObject.referes[field]=[];calcObject.values[field]=[];for(ix=0;ix<targetIds.length;ix++){calcObject.referes[field].push(targetIds[ix]);calcObject.values[field].push(undefined)}}else{calcObject.referes[field]=[undefined];calcObject.values[field]=[undefined]}}}
function getParentRepeater(node){var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null}}};var IMParts_Catalog={};IMParts_Catalog.fileupload={html5DDSuported:!1,progressSupported:!1,forceOldStyleForm:!1,uploadButtonLabel:'送信',uploadCancelButtonLabel:'キャンセル',uploadId:'sign'+Math.random(),instanciate:function(parentNode){'use strict';var inputNode,formNode,buttonNode,hasTapEvent;var newId=parentNode.getAttribute('id')+'-e';var newNode=document.createElement('DIV');IMLibLocalContext.setValue('uploadFileSelect','false');INTERMediatorLib.setClassAttributeToNode(newNode,'_im_fileupload');newNode.setAttribute('id',newId);this.ids.push(newId);if(this.forceOldStyleForm||(INTERMediator.isEdge&&INTERMediator.ieVersion<14)){this.html5DDSuported=!1}else{if(window.FileReader&&window.FormData){this.html5DDSuported=!0}else{this.html5DDSuported=!1}}
hasTapEvent=('ontouchstart' in window);if(hasTapEvent){this.html5DDSuported=!1}
var autoReload=(parentNode.getAttribute('data-im-widget-reload')!==null)?parentNode.getAttribute('data-im-widget-reload'):!1;newNode.setAttribute('data-im-widget-reload',autoReload);if(this.html5DDSuported){newNode.dropzone='copy';var widgetStyle=(parentNode.getAttribute('data-im-widget-style')==='false')?!1:!0;if(widgetStyle){newNode.style.width='200px';newNode.style.height='100px';newNode.style.paddingTop='20px';newNode.style.backgroundColor='#AAAAAA';newNode.style.border='3px dotted #808080';newNode.style.textAlign='center';newNode.style.fontSize='75%';var eachLine=INTERMediatorOnPage.getMessages()[3101].split(/\n/);for(var i=0;i<eachLine.length;i++){if(i>0){newNode.appendChild(document.createElement('BR'))}
newNode.appendChild(document.createTextNode(eachLine[i]))}}}else{formNode=document.createElement('FORM');formNode.className='_im_fileupload_form';formNode.setAttribute('method','post');formNode.setAttribute('action',INTERMediatorOnPage.getEntryPath()+'?access=uploadfile');formNode.setAttribute('enctype','multipart/form-data');var divNode=document.createElement('DIV');divNode.className='_im_fileupload_form_wrapper form-wrapper';divNode.appendChild(formNode);newNode.appendChild(divNode);if(this.progressSupported){inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','APC_UPLOAD_PROGRESS');inputNode.setAttribute('id','progress_key');inputNode.setAttribute('value',this.uploadId+(this.ids.length-1));formNode.appendChild(inputNode)}
inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_redirect');inputNode.setAttribute('value',location.href);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_contextnewrecord');inputNode.setAttribute('value','uploadfile');formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','access');inputNode.setAttribute('value','uploadfile');formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','file');inputNode.setAttribute('accept','*/*');inputNode.setAttribute('name','_im_uploadfile');inputNode.className='_im_uploadfile';inputNode.addEventListener('change',function(){if(this.files[0].size>0){this.nextSibling.removeAttribute('disabled')}},!1);formNode.appendChild(inputNode);var cancelButtonWrapper,cancelButton;cancelButtonWrapper=document.createElement('DIV');cancelButtonWrapper.className='_im_fileupload_cancel_button_wrapper';cancelButton=document.createElement('BUTTON');cancelButton.className='_im_fileupload_cancel_button';cancelButton.appendChild(document.createTextNode(this.uploadCancelButtonLabel));cancelButtonWrapper.appendChild(cancelButton);buttonNode=document.createElement('BUTTON');buttonNode.className='_im_fileupload_button';buttonNode.setAttribute('type','submit');buttonNode.setAttribute('disabled','');buttonNode.appendChild(document.createTextNode(this.uploadButtonLabel));if(!newNode.id){newNode.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(newNode.id,function(){var node=document.getElementById(newNode.id);if(node!==null&&node.children.length>0){if(node.children[0].style.display==='none'||node.children[0].style.display===''){node.children[0].style.display='flex';node.children[0].style.display='-webkit-flex'}}},!0);if(!cancelButtonWrapper.id){cancelButtonWrapper.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(cancelButtonWrapper.id,function(){this.parentNode.style.display='none'});divNode.appendChild(cancelButtonWrapper);formNode.appendChild(buttonNode);this.formFromId[newId]=formNode}
if(parentNode.getAttribute('data-im-widget-inner')==='true'){var children=parentNode.children;for(var c=children.length-1;c>=0;c--){newNode.appendChild(children[c])}}
parentNode.appendChild(newNode);newNode._im_getValue=function(){var targetNode=newNode;return targetNode.value};parentNode._im_getValue=function(){var targetNode=newNode;return targetNode.value};parentNode._im_getComponentId=function(){var theId=newId;return theId}},ids:[],formFromId:{},finish:function(){'use strict';var shaObj,hmacValue,targetNode,formNode,i,tagetIdLocal,isProgressingLocal,serialIdLocal,uploadIdLocal;var encrypt=new JSEncrypt();if(this.html5DDSuported){for(i=0;i<this.ids.length;i++){tagetIdLocal=this.ids[i];targetNode=document.getElementById(tagetIdLocal);if(targetNode){INTERMediatorLib.addEvent(targetNode,'dragleave',function(event){event.preventDefault();event.target.style.backgroundColor='#AAAAAA'});INTERMediatorLib.addEvent(targetNode,'dragover',function(event){event.preventDefault();event.target.style.backgroundColor='#AADDFF'});isProgressingLocal=this.progressSupported;serialIdLocal=this.ids.length;uploadIdLocal=this.uploadId;INTERMediatorLib.addEvent(targetNode,'drop',(function(){var iframeId=i;var isProgressing=isProgressingLocal;var serialId=serialIdLocal;var uploadId=uploadIdLocal;var tagetId=tagetIdLocal;return function(event){var file,fileNameNode,i,updateInfo,infoFrame;event.preventDefault();var eventTarget=event.currentTarget;if(isProgressing){infoFrame=document.createElement('iframe');infoFrame.setAttribute('id','upload_frame'+serialId);infoFrame.setAttribute('name','upload_frame');infoFrame.setAttribute('frameborder','0');infoFrame.setAttribute('border','0');infoFrame.setAttribute('scrolling','no');infoFrame.setAttribute('scrollbar','no');infoFrame.style.width='100%';infoFrame.style.height='24px';eventTarget.appendChild(infoFrame)}
for(i=0;i<event.dataTransfer.files.length;i++){file=event.dataTransfer.files[i];fileNameNode=document.createElement('DIV');fileNameNode.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[3102]+file.name));fileNameNode.style.marginTop='20px';fileNameNode.style.backgroundColor='#FFFFFF';fileNameNode.style.textAlign='center';event.target.appendChild(fileNameNode)}
updateInfo=IMLibContextPool.getContextInfoFromId(eventTarget.getAttribute('id'),'');if(isProgressing){if(infoFrame){infoFrame.style.display='block'}
setTimeout((function(){var frameNode=infoFrame;var param=uploadId+iframeId;return function(){if(frameNode){frameNode.setAttribute('src','upload_frame.php?up_id='+param)}}})())}
IMLibQueue.setTask((function(){var uploadData='&_im_contextname='+encodeURIComponent(updateInfo.context.contextName)+'&_im_field='+encodeURIComponent(updateInfo.field)+'&_im_keyfield='+encodeURIComponent(updateInfo.record.split('=')[0])+'&_im_keyvalue='+encodeURIComponent(updateInfo.record.split('=')[1])+'&_im_contextnewrecord='+encodeURIComponent('uploadfile')+(isProgressing?('&APC_UPLOAD_PROGRESS='+encodeURIComponent(uploadId+iframeId)):'');var uploadSpec={fileName:file.name,content:file};var contextName=updateInfo.context.contextName;var updateField=updateInfo.field;var targetIdCapt=tagetId;var targetNodeCapt=targetNode;var finishFunc=(function(){var infoFrameCapt=infoFrame;var fileNameNodeCapt=fileNameNode;return function(){if(infoFrameCapt){infoFrameCapt.setAttribute('src','')}
if(fileNameNodeCapt){fileNameNodeCapt.parentNode.removeChild(fileNameNodeCapt)}}})();return function(completeTask){INTERMediator_DBAdapter.uploadFile(uploadData,uploadSpec,function(dbresult){var contextObj,contextInfo,contextObjects=null,fvalue,i,context,relatedContextName='',index;context=IMLibContextPool.getContextDef(contextName);if(context['file-upload']){for(index in context['file-upload']){if(context['file-upload'][index].field===updateField){relatedContextName=context['file-upload'][index].context;break}}
fvalue=IMLibContextPool.getKeyFieldValueFromId(targetIdCapt,'');contextObjects=IMLibContextPool.getContextsFromNameAndForeignValue(relatedContextName,fvalue,context.key)}else{contextObjects=IMLibContextPool.getContextFromName(contextName)}
contextInfo=IMLibContextPool.getContextInfoFromId(targetIdCapt,'');contextInfo.context.setValue(contextInfo.record,contextInfo.field,dbresult);if(contextObjects){for(i=0;i<contextObjects.length;i++){contextObj=contextObjects[i];INTERMediator.construct(contextObj)}}
INTERMediatorLog.flushMessage();if(targetNodeCapt.getAttribute('data-im-widget-reload')==='true'){INTERMediator.construct()}
event.target.style.backgroundColor='#AAAAAA';finishFunc();completeTask()},function(){event.target.style.backgroundColor='#AAAAAA';finishFunc();completeTask()})}})())}})())}}}else{for(i=0;i<this.ids.length;i++){targetNode=document.getElementById(this.ids[i]);formNode=targetNode.getElementsByTagName('FORM')[0];if(targetNode&&formNode){var updateInfo=IMLibContextPool.getContextInfoFromId(this.ids[i],'');var inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_contextname');inputNode.setAttribute('value',updateInfo.context.contextName);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_field');inputNode.setAttribute('value',updateInfo.field);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_keyfield');inputNode.setAttribute('value',updateInfo.record.split('=')[0]);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_keyvalue');inputNode.setAttribute('value',updateInfo.record.split('=')[1]);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','clientid');if(INTERMediatorOnPage.authUser.length>0){inputNode.value=INTERMediatorOnPage.clientId}
formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','authuser');if(INTERMediatorOnPage.authUser.length>0){inputNode.value=INTERMediatorOnPage.authUser}
formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','response');if(INTERMediatorOnPage.authUser.length>0){if(INTERMediatorOnPage.authHashedPassword&&INTERMediatorOnPage.authChallenge){shaObj=new jsSHA(INTERMediatorOnPage.authHashedPassword,'ASCII');hmacValue=shaObj.getHMAC(INTERMediatorOnPage.authChallenge,'ASCII','SHA-256','HEX');inputNode.value=hmacValue}else{inputNode.value='dummy'}}
formNode.appendChild(inputNode);if(INTERMediatorOnPage.authUser.length>0){encrypt.setPublicKey(INTERMediatorOnPage.publickey);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','cresponse');inputNode.setAttribute('value',encrypt.encrypt(INTERMediatorOnPage.authCryptedPassword.substr(0,220)+IMLib.nl_char+INTERMediatorOnPage.authChallenge)+IMLib.nl_char+INTERMediatorOnPage.authCryptedPassword.substr(220));formNode.appendChild(inputNode)}
if(this.progressSupported){inputNode=document.createElement('iframe');inputNode.setAttribute('id','upload_frame'+i);inputNode.setAttribute('name','upload_frame');inputNode.setAttribute('frameborder','0');inputNode.setAttribute('border','0');inputNode.setAttribute('scrolling','no');inputNode.setAttribute('scrollbar','no');formNode.appendChild(inputNode);INTERMediatorLib.addEvent(formNode,'submit',(function(){var iframeId=i;return function(){var iframeNode=document.getElementById('upload_frame'+iframeId);iframeNode.style.display='block';setTimeout(function(){var infoURL=selfURL()+'?uploadprocess='+this.uploadId+iframeId;iframeNode.setAttribute('src',infoURL)});return!0}})())}}}}
this.ids=[];this.formFromId={};function selfURL(){var nodes=document.getElementsByTagName('SCRIPT');for(var i=0;i<nodes.length;i++){var srcAttr=nodes[i].getAttribute('src');if(srcAttr.match(/\.php/)){return srcAttr}}
return null}}};IMParts_Catalog.jsonformat={instanciate:function(parentNode){'use strict';var newId=parentNode.getAttribute('id')+'-jsonf';var newNode=document.createElement('pre');newNode.setAttribute('id',newId);parentNode.appendChild(newNode);IMParts_Catalog.jsonformat.ids.push(newId);parentNode._im_getComponentId=(function(){var theId=newId;return function(){return theId}})();parentNode._im_setValue=(function(){var theId=newId;return function(str){IMParts_Catalog.jsonformat.initialValues[theId]=str?JSON.stringify(JSON.parse(str),null,' '):''}})()},ids:[],initialValues:{},finish:function(){'use strict';for(var i=0;i<IMParts_Catalog.jsonformat.ids.length;i++){var targetId=IMParts_Catalog.jsonformat.ids[i];var targetNode=document.getElementById(targetId);if(targetNode){targetNode.appendChild(document.createTextNode(IMParts_Catalog.jsonformat.initialValues[targetId]))}}
IMParts_Catalog.jsonformat.ids=[];IMParts_Catalog.jsonformat.initialValues={}}};IMParts_Catalog.popupselector={instanciate:function(parentNode){'use strict';var widgetId,node,inNode,valueNode;if(parentNode.getAttribute('class')!=='_im_widget_popup'){parentNode.setAttribute('class','_im_widget_popup');parentNode.style.zIndex=(IMParts_Catalog.popupselector.zIndex--);node=document.createElement('SPAN');node.setAttribute('data-im-control','enclosure');node.setAttribute('class','_im_widget_popup_panel');parentNode.appendChild(node);IMParts_Catalog.popupselector.selectionRoots.push(node);inNode=document.createElement('SPAN');inNode.setAttribute('data-im-control','repeater');inNode.setAttribute('data-im',parentNode.getAttribute('data-im-popup'));node.appendChild(inNode);inNode=document.createElement('DIV');inNode.setAttribute('class','_im_widget_popup_close');inNode.appendChild(document.createTextNode('×'));node.appendChild(inNode);INTERMediatorLib.addEvent(inNode,'click',(function(){return function(){IMParts_Catalog.popupselector.clearSelection()}})());widgetId=parentNode.getAttribute('id');IMParts_Catalog.popupselector.ids.push(widgetId);valueNode=document.createElement('span');valueNode.setAttribute('class','_im_widget_popup_value');INTERMediatorLib.addEvent(valueNode,'click',(function(){var selRoot=node;return function(){IMParts_Catalog.popupselector.clearSelection();IMParts_Catalog.popupselector.clickValue(selRoot)}})());parentNode.appendChild(valueNode);parentNode._im_getComponentId=(function(){var theId=widgetId;return function(){return theId}})();parentNode._im_setValue=(function(){var theId=widgetId;return function(str){IMParts_Catalog.popupselector.initialValues[theId]=str}})()}},ids:[],selectionRoots:[],initialValues:{},zIndex:9000,finish:function(){'use strict';var i,targetId,targetNode,j,nodes,selectionRoot,nodeValue,displayValue,innodes,k;for(i=0;i<IMParts_Catalog.popupselector.ids.length;i++){targetId=IMParts_Catalog.popupselector.ids[i];targetNode=document.getElementById(targetId);selectionRoot=IMParts_Catalog.popupselector.selectionRoots[i];nodeValue=IMParts_Catalog.popupselector.initialValues[targetId];if(selectionRoot){displayValue=null;nodes=selectionRoot.childNodes;for(j=0;j<nodes.length;j++){if(nodes[j]&&nodes[j].nodeType===1&&nodes[j].getAttribute('data-im-control')==='repeater'){nodes[j].setAttribute('class','_im_widget_popup_selection');if(nodeValue===nodes[j].getAttribute('data-im-value')){displayValue=nodes[j].innerHTML;nodes[j].setAttribute('class','_im_widget_popup_selection _im_widget_popup_selected')}
IMLibMouseEventDispatch.setExecute(nodes[j].id,(function(){var node=nodes[j];return function(){IMParts_Catalog.popupselector.clearSelection();IMParts_Catalog.popupselector.setData(node)}})())}}
if(targetNode){innodes=targetNode.getElementsByClassName('_im_widget_popup_value');for(k=0;k<innodes.length;k++){innodes[k].innerHTML=displayValue?displayValue:'[Not selected]'}}}}},clickValue:function(selectionRoot){'use strict';var body,panelBack;selectionRoot.style.display='block';body=document.getElementsByTagName('BODY')[0];panelBack=document.createElement('DIV');body.appendChild(panelBack);panelBack.setAttribute('class','_im_widget_popup_panelback');panelBack.setAttribute('id','_im_widget_popup_panelback');panelBack.style.width=body.clientWidth+'px';panelBack.style.height=body.clientHeight+'px';IMLibMouseEventDispatch.setExecute('_im_widget_popup_panelback',function(){IMParts_Catalog.popupselector.clearSelection()})},clearSelection:function(){'use strict';var i,body,targetNode,selectionRoot;body=document.getElementsByTagName('BODY')[0];targetNode=document.getElementById('_im_widget_popup_panelback');if(targetNode){body.removeChild(targetNode)}
for(i=0;i<IMParts_Catalog.popupselector.ids.length;i++){selectionRoot=IMParts_Catalog.popupselector.selectionRoots[i];if(selectionRoot){selectionRoot.style.display='none'}}},setData:function(node){'use strict';var i,selectedData,target,targetField,bindingId,keyRec,nodes,contextInfo;selectedData=node.getAttribute('data-im-value');target=node.parentNode.parentNode.getAttribute('data-im').split(' ')[0].split('@');targetField=target[1];bindingId=node.parentNode.parentNode.id;contextInfo=IMLibContextPool.getContextInfoFromId(bindingId,target[2]);keyRec=contextInfo.record.split('=');contextInfo.context.setDataWithKey(keyRec[1],targetField,selectedData);nodes=node.parentNode.parentNode.getElementsByClassName('_im_widget_popup_value');for(i=0;i<nodes.length;i++){nodes[i].innerHTML=node.innerHTML}
nodes=node.parentNode.getElementsByClassName('_im_widget_popup_selection');for(i=0;i<nodes.length;i++){if(node.getAttribute('data-im-value')===nodes[i].getAttribute('data-im-value')){nodes[i].setAttribute('class','_im_widget_popup_selection _im_widget_popup_selected')}else{nodes[i].setAttribute('class','_im_widget_popup_selection')}}}};var IMLibPageNavigation={deleteInsertOnNavi:[],previousModeDetail:null,stepNavigation:[],stepCurrentContextName:null,stepStartContextName:null,navigationSetup:function(){'use strict';var navigation,i,insideNav,navLabel,node,start,pageSize,allCount,dataSources,disableClass,c_node,prevPageCount,nextPageCount,endPageCount,contextName,contextDef,buttonLabel,dataSource;navigation=document.getElementById('IM_NAVIGATOR');if(navigation!==null){if(!IMLibContextPool.getPagingContext()){navigation.style.display='none';return}
insideNav=navigation.childNodes;for(i=0;i<insideNav.length;i++){navigation.removeChild(insideNav[i])}
navigation.innerHTML='';navigation.setAttribute('class','IM_NAV_panel');navLabel=INTERMediator.navigationLabel;if(navLabel===null||navLabel[8]!==!1){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(((navLabel===null||navLabel[8]===null)?INTERMediatorOnPage.getMessages()[2]:navLabel[8])));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){INTERMediator.initialize();IMLibLocalContext.archive();location.reload()})}
if(navLabel===null||navLabel[4]!==!1){start=Number(INTERMediator.startFrom);dataSource=IMLibContextPool.getPagingContext().getContextDef();if(dataSource&&dataSource.maxrecords&&dataSource.maxrecords<parseInt(INTERMediator.pagedSize,10)){INTERMediator.pagedSize=dataSource.maxrecords}
pageSize=Number(INTERMediator.pagedSize);allCount=Number(INTERMediator.pagedAllCount);disableClass=' IM_NAV_disabled';node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(((navLabel===null||navLabel[4]===null)?INTERMediatorOnPage.getMessages()[1]:navLabel[4])+(allCount===0?0:start+1)+((Math.min(start+pageSize,allCount)-start>1)?(((navLabel===null||navLabel[5]===null)?'-':navLabel[5])+Math.min(start+pageSize,allCount)):'')+((navLabel===null||navLabel[6]===null)?' / ':navLabel[6])+(allCount)+((navLabel===null||navLabel[7]===null)?'':navLabel[7])));node.setAttribute('class','IM_NAV_info')}
if((navLabel===null||navLabel[0]!==!1)&&INTERMediator.pagination===!0){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[0]===null)?'<<':navLabel[0]));node.setAttribute('class','IM_NAV_button'+(start===0?disableClass:''));if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',0)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[1]===null)?'<':navLabel[1]));node.setAttribute('class','IM_NAV_button'+(start===0?disableClass:''));prevPageCount=(start-pageSize>0)?start-pageSize:0;if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',prevPageCount)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[2]===null)?'>':navLabel[2]));node.setAttribute('class','IM_NAV_button'+(start+pageSize>=allCount?disableClass:''));nextPageCount=(start+pageSize<allCount)?start+pageSize:((allCount-pageSize>0)?start:0);if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',nextPageCount)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[3]===null)?'>>':navLabel[3]));node.setAttribute('class','IM_NAV_button'+(start+pageSize>=allCount?disableClass:''));if(allCount%pageSize===0){endPageCount=allCount-(allCount%pageSize)-pageSize}else{endPageCount=allCount-(allCount%pageSize)}
if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',(endPageCount>0)?endPageCount:0)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[10]));c_node=document.createElement('INPUT');c_node.setAttribute('class','IM_NAV_JUMP');c_node.setAttribute('type','text');if(!c_node.id){c_node.id=INTERMediator.nextIdValue()}
c_node.setAttribute('value',String(Math.ceil(INTERMediator.startFrom/pageSize+1)));node.appendChild(c_node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[11]));IMLibChangeEventDispatch.setExecute(c_node.id,function(){var moveTo,max_page;moveTo=INTERMediatorLib.toNumber(c_node.value);if(moveTo<1){moveTo=1}
max_page=Math.ceil(allCount/pageSize);if(max_page<moveTo){moveTo=max_page}
INTERMediator.startFrom=(moveTo-1)*pageSize;INTERMediator.constructMain(!0)})}
if(navLabel===null||navLabel[9]!==!1){for(i=0;i<IMLibPageNavigation.deleteInsertOnNavi.length;i++){switch(IMLibPageNavigation.deleteInsertOnNavi[i].kind){case 'INSERT':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].insert){buttonLabel=contextDef['button-names'].insert}else{buttonLabel=INTERMediatorOnPage.getMessages()[3]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextName=obj.name,keyValue=obj.key,confirming=obj.confirm;return function(){IMLibPageNavigation.insertRecordFromNavi(contextName,keyValue,confirming)}})());break;case 'DELETE':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].delete){buttonLabel=contextDef['button-names'].delete}else{buttonLabel=INTERMediatorOnPage.getMessages()[4]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');INTERMediatorLib.addEvent(node,'click',(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextName=obj.name,keyName=obj.key,keyValue=obj.value,confirming=obj.confirm;return function(){IMLibPageNavigation.deleteRecordFromNavi(contextName,keyName,keyValue,confirming)}})());break;case 'COPY':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].copy){buttonLabel=contextDef['button-names'].copy}else{buttonLabel=INTERMediatorOnPage.getMessages()[15]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextDef=obj.contextDef,record=obj.keyValue;return function(){IMLibPageNavigation.copyRecordFromNavi(contextDef,record)}})());break}}}
if(navLabel===null||navLabel[10]!==!1){if(INTERMediatorOnPage.getOptionsTransaction()==='none'){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[10]===null)?INTERMediatorOnPage.getMessages()[7]:navLabel[10]));node.setAttribute('class','IM_NAV_button');INTERMediatorLib.addEvent(node,'click',IMLibPageNavigation.saveRecordFromNavi)}}
if(navLabel===null||navLabel[11]!==!1){if(INTERMediatorOnPage.requireAuthentication){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[8]+INTERMediatorOnPage.authUser));node.setAttribute('class','IM_NAV_info');node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[11]===null)?INTERMediatorOnPage.getMessages()[9]:navLabel[11]));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){INTERMediatorOnPage.logout();location.reload()})}}}},moveRecordFromNavi:function(targetName,page){'use strict';INTERMediator_DBAdapter.unregister();INTERMediator.startFrom=page;INTERMediator.constructMain(!0)},insertRecordFromNavi:function(targetName,keyField,isConfirm){'use strict';var contextDef;if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1026])){return}}
INTERMediatorOnPage.showProgress();contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',targetName);if(contextDef===null){window.alert('no targetname :'+targetName);INTERMediatorOnPage.hideProgress();return}
IMLibQueue.setTask((function(){var conditions,restore;var contextDefCapt=contextDef;var targetNameCapt=targetName;var keyFieldCapt=keyField;var isConfirmCapt=isConfirm;return function(completeTask){try{INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_createRecord_async({name:targetNameCapt,dataset:[]},function(response){var newId=response.newRecordKeyValue;if(newId>-1){restore=INTERMediator.additionalCondition;if(contextDefCapt.records<=1){INTERMediator.startFrom=0;INTERMediator.pagedAllCount=1;conditions=INTERMediator.additionalCondition;conditions[targetNameCapt]={field:keyFieldCapt,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}else{INTERMediator.pagedAllCount++}
completeTask();INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(!0);INTERMediator.additionalCondition=restore;IMLibPageNavigation.navigationSetup()}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()},completeTask)}catch(ex){completeTask();if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibPageNavigation.insertRecordFromNavi(targetNameCapt,keyFieldCapt,isConfirmCapt)});INTERMediatorLog.flushMessage()}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-5')}}}})())},deleteRecordFromNavi:function(targetName,keyField,keyValue,isConfirm){'use strict';if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1025])){return}}
IMLibQueue.setTask((function(){var deleteArgs={name:targetName,conditions:[{field:keyField,operator:'=',value:keyValue}]};return function(completeTask){INTERMediatorOnPage.showProgress();try{INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_delete_async(deleteArgs,(function(){return function(){INTERMediator.pagedAllCount--;INTERMediator.totalRecordCount--;if(INTERMediator.pagedAllCount-INTERMediator.startFrom<1){INTERMediator.startFrom--;if(INTERMediator.startFrom<0){INTERMediator.startFrom=0}}
completeTask();INTERMediator.constructMain(!0);INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),completeTask())}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-6');completeTask()}}})())},copyRecordFromNavi:function(contextDef,keyValue){'use strict';if(contextDef['repeat-control'].match(/confirm-copy/)){if(!window.confirm(INTERMediatorOnPage.getMessages()[1041])){return}}
IMLibQueue.setTask((function(){var contextDefCapt=contextDef;var keyValueCapt=keyValue;return function(completeTask){var assocDef,i,def,assocContexts,pStart,copyTerm,index;INTERMediatorOnPage.showProgress();try{if(contextDefCapt.relation){for(index in contextDefCapt.relation){if(contextDefCapt.relation[index].portal===!0){contextDefCapt.portal=!0}}}
assocDef=[];if(contextDefCapt['repeat-control'].match(/copy-/)){pStart=contextDefCapt['repeat-control'].indexOf('copy-');copyTerm=contextDefCapt['repeat-control'].substr(pStart+5);if((pStart=copyTerm.search(/\s/))>-1){copyTerm=copyTerm.substr(0,pStart)}
assocContexts=copyTerm.split(',');for(i=0;i<assocContexts.length;i++){def=IMLibContextPool.getContextDef(assocContexts[i]);if(def.relation[0]['foreign-key']){assocDef.push({name:def.name,field:def.relation[0]['foreign-key'],value:keyValueCapt})}}}
INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_copy_async({name:contextDefCapt.name,conditions:[{field:contextDefCapt.key,operator:'=',value:keyValueCapt}],associated:assocDef.length>0?assocDef:null},(function(){var contextDefCapt2=contextDefCapt;return function(result){var restore,conditions;var newId=result.newRecordKeyValue;completeTask();if(newId>-1){restore=INTERMediator.additionalCondition;INTERMediator.startFrom=0;if(contextDefCapt2.records<=1){conditions=INTERMediator.additionalCondition;conditions[contextDefCapt2.name]={field:contextDefCapt2.key,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}
INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(!0);INTERMediator.additionalCondition=restore}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),completeTask)}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-43');completeTask()}}})())},saveRecordFromNavi:function(dontUpdate){'use strict';var keying,field,keyingComp,keyingField,keyingValue,checkQueryParameter,i,initialValue,currentVal,fieldArray,valueArray,difference,needUpdate=!0,context,updateData,response;INTERMediatorOnPage.showProgress();INTERMediatorOnPage.retrieveAuthInfo();for(i=0;i<IMLibContextPool.poolingContexts.length;i++){context=IMLibContextPool.poolingContexts[i];updateData=context.getModified();for(keying in updateData){if(updateData.hasOwnProperty(keying)){fieldArray=[];valueArray=[];for(field in updateData[keying]){if(updateData[keying].hasOwnProperty(field)){fieldArray.push(field);valueArray.push({field:field,value:updateData[keying][field]})}}
keyingComp=keying.split('=');keyingField=keyingComp[0];keyingComp.shift();keyingValue=keyingComp.join('=');if(!INTERMediator.ignoreOptimisticLocking){checkQueryParameter={name:context.contextName,records:1,paging:!1,fields:fieldArray,parentkeyvalue:null,conditions:[{field:keyingField,operator:'=',value:keyingValue}],useoffset:!1,primaryKeyOnly:!0};try{currentVal=INTERMediator_DBAdapter.db_query(checkQueryParameter)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating((function(){var qParam=checkQueryParameter;return function(){INTERMediator.db_query(qParam)}})());return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-28')}}
if(currentVal.recordset===null||currentVal.recordset[0]===null){window.alert(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1003],[fieldArray.join(',')]));return}
if(currentVal.count>1){response=window.confirm(INTERMediatorOnPage.getMessages()[1024]);if(!response){return}}
difference=!1;for(field in updateData[keying]){if(updateData[keying].hasOwnProperty(field)){initialValue=context.getValue(keying,field);if(initialValue!==currentVal.recordset[0][field]){difference+=INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1035],[field,currentVal.recordset[0][field],updateData[keying][field]])}}}
if(difference!==!1){if(!window.confirm(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1034],[difference]))){return}
INTERMediatorOnPage.retrieveAuthInfo()}}
try{INTERMediator_DBAdapter.db_update({name:context.contextName,conditions:[{field:keyingField,operator:'=',value:keyingValue}],dataset:valueArray})}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibPageNavigation.saveRecordFromNavi(dontUpdate)});return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-29')}}
context.clearModified()}}}
if(needUpdate&&(dontUpdate!==!0)){INTERMediator.constructMain(!0)}
INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()},setupCopyButton:function(encNodeTag,repNodeTag,repeaters,currentContext,currentRecord){'use strict';var buttonNode,thisId,tdNodes,tdNode,buttonName,currentContextDef;currentContextDef=currentContext.getContextDef();if(!currentContextDef['repeat-control']||!currentContextDef['repeat-control'].match(/copy/i)){return}
if(currentContextDef.relation||currentContextDef.records===undefined||!currentContextDef.paging||(currentContextDef.records>1&&Number(INTERMediator.pagedSize)!==1)){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Copy');buttonName=INTERMediatorOnPage.getMessages()[14];if(currentContextDef['button-names']&&currentContextDef['button-names'].copy){buttonName=currentContextDef['button-names'].copy}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;IMLibMouseEventDispatch.setExecute(thisId,(function(){var currentContextCapt=currentContext,currentRecordCapt=currentRecord[currentContextDef.key];return function(){IMLibUI.copyButton(currentContextCapt,currentRecordCapt)}})());switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[tdNodes.length-1];tdNode.appendChild(buttonNode);break;case 'SELECT':break;default:if(repeaters[0]&&repeaters[0].childNodes){repeaters[repeaters.length-1].appendChild(buttonNode)}else{repeaters.push(buttonNode)}
break}}else{IMLibPageNavigation.deleteInsertOnNavi.push({kind:'COPY',name:currentContextDef.name,contextDef:currentContextDef,keyValue:currentRecord[currentContextDef.key]})}},setupDeleteButton:function(encNodeTag,repeaters,currentContext,keyField,keyValue){'use strict';var buttonNode,thisId,tdNodes,tdNode,buttonName,currentContextDef;currentContextDef=currentContext.contextDefinition;if(!currentContextDef['repeat-control']||!currentContextDef['repeat-control'].match(/delete/i)){return}
if(currentContextDef.relation||currentContextDef.records===undefined||!currentContextDef.paging||(currentContextDef.records>1&&Number(INTERMediator.pagedSize)!==1)){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Delete');buttonName=INTERMediatorOnPage.getMessages()[6];if(currentContextDef['button-names']&&currentContextDef['button-names'].delete){buttonName=currentContextDef['button-names'].delete}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;IMLibMouseEventDispatch.setExecute(thisId,(function(){var currentContextCapt=currentContext,keyFieldCapt=keyField,keyValueCapt=keyValue,confirmingCapt=!!currentContextDef['repeat-control'].match(/confirm-delete/i);return function(){IMLibUI.deleteButton(currentContextCapt,keyFieldCapt,keyValueCapt,confirmingCapt)}})());switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[tdNodes.length-1];tdNode.appendChild(buttonNode);break;case 'SELECT':break;default:if(repeaters[0]&&repeaters[0].childNodes){repeaters[repeaters.length-1].appendChild(buttonNode)}else{repeaters.push(buttonNode)}
break}}else{IMLibPageNavigation.deleteInsertOnNavi.push({kind:'DELETE',name:currentContextDef.name,key:keyField,value:keyValue,confirm:currentContextDef['repeat-control'].match(/confirm-delete/i)})}},setupInsertButton:function(currentContext,keyValue,node,relationValue){'use strict';var buttonNode,enclosedNode,footNode,trNode,tdNode,liNode,divNode,i,firstLevelNodes,targetNodeTag,existingButtons,keyField,thisId,encNodeTag,buttonName,setTop,currentContextDef;encNodeTag=node.tagName;currentContextDef=currentContext.getContextDef();if(currentContextDef['repeat-control']&&currentContextDef['repeat-control'].match(/insert/i)){if(relationValue.length>0||!currentContextDef.paging||currentContextDef.paging===!1){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Insert');buttonName=INTERMediatorOnPage.getMessages()[5];if(currentContextDef['button-names']&&currentContextDef['button-names'].insert){buttonName=currentContextDef['button-names'].insert}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;switch(encNodeTag){case 'TBODY':setTop=!1;targetNodeTag='TFOOT';if(currentContextDef['repeat-control'].match(/top/i)){targetNodeTag='THEAD';setTop=!0}
enclosedNode=node.parentNode;firstLevelNodes=enclosedNode.childNodes;footNode=null;for(i=0;i<firstLevelNodes.length;i++){if(firstLevelNodes[i].tagName===targetNodeTag){footNode=firstLevelNodes[i];break}}
if(footNode===null){footNode=document.createElement(targetNodeTag);enclosedNode.appendChild(footNode)}
existingButtons=INTERMediatorLib.getElementsByClassName(footNode,'IM_Button_Insert');if(existingButtons.length===0){trNode=document.createElement('TR');INTERMediatorLib.setClassAttributeToNode(trNode,'IM_Insert_TR');tdNode=document.createElement('TD');tdNode.setAttribute('colspan',100);INTERMediatorLib.setClassAttributeToNode(tdNode,'IM_Insert_TD');INTERMediator.setIdValue(trNode);if(setTop&&footNode.childNodes){footNode.insertBefore(trNode,footNode.childNodes[0])}else{footNode.appendChild(trNode)}
trNode.appendChild(tdNode);tdNode.appendChild(buttonNode)}
break;case 'UL':case 'OL':liNode=document.createElement('LI');existingButtons=INTERMediatorLib.getElementsByClassName(liNode,'IM_Button_Insert');if(existingButtons.length===0){liNode.appendChild(buttonNode);if(currentContextDef['repeat-control'].match(/top/i)){node.insertBefore(liNode,node.firstChild)}else{node.appendChild(liNode)}}
break;case 'SELECT':break;default:divNode=document.createElement('DIV');existingButtons=INTERMediatorLib.getElementsByClassName(divNode,'IM_Button_Insert');if(existingButtons.length===0){divNode.appendChild(buttonNode);if(currentContextDef['repeat-control'].match(/top/i)){node.insertBefore(divNode,node.firstChild)}else{node.appendChild(divNode)}}
break}
IMLibMouseEventDispatch.setExecute(buttonNode.id,(function(){var context=currentContext,keyValueCapt=keyValue,relationValueCapt=relationValue,nodeId=node.getAttribute('id'),confirming=!!currentContextDef['repeat-control'].match(/confirm-insert/i);return function(){IMLibUI.insertButton(context,keyValueCapt,relationValueCapt,nodeId,confirming)}})())}else{if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){keyField=currentContextDef.key?currentContextDef.key:INTERMediatorOnPage.defaultKeyName}else{keyField=currentContextDef.key?currentContextDef.key:'id'}
IMLibPageNavigation.deleteInsertOnNavi.push({kind:'INSERT',name:currentContextDef.name,key:keyField,confirm:currentContextDef['repeat-control'].match(/confirm-insert/i)})}}},setupNavigationButton:function(encNodeTag,repeaters,currentContextDef,keyField,keyValue,contextObj){'use strict';var buttonNode,thisId,tdNodes,tdNode,firstInNode,isMasterDetail,isStep,isHide,masterContext,detailContext,showingNode,isHidePageNavi,buttonName,i,isTouchRepeater,moveToDetailFunc;if(!currentContextDef['navi-control']||(!currentContextDef['navi-control'].match(/master/i)&&!currentContextDef['navi-control'].match(/step/i))||encNodeTag==='SELECT'){return}
isTouchRepeater=INTERMediator.isMobile||INTERMediator.isTablet;isHide=!!currentContextDef['navi-control'].match(/hide/i);isHidePageNavi=isHide&&!!currentContextDef.paging;isMasterDetail=!!currentContextDef['navi-control'].match(/master/i);isStep=!!currentContextDef['navi-control'].match(/step/i);if(isMasterDetail&&INTERMediator.detailNodeOriginalDisplay){detailContext=IMLibContextPool.getDetailContext();if(detailContext){showingNode=detailContext.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
INTERMediator.detailNodeOriginalDisplay=showingNode.style.display}}
buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Master');buttonName=INTERMediatorOnPage.getMessages()[12];if(currentContextDef['button-names']&&currentContextDef['button-names']['navi-detail']){buttonName=currentContextDef['button-names']['navi-detail']}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;if(isMasterDetail){masterContext=IMLibContextPool.getMasterContext();masterContext.setValue(keyField+'='+keyValue,'_im_button_master_id',thisId,thisId)}
if(isMasterDetail){moveToDetailFunc=IMLibPageNavigation.moveToDetail(keyField,keyValue,isHide,isHidePageNavi)}
if(isStep){moveToDetailFunc=IMLibPageNavigation.moveToNextStep(contextObj,keyField,keyValue)}
if(isTouchRepeater){for(i=0;i<repeaters.length;i++){var originalColor=repeaters[i].style.backgroundColor;INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchstart','todo':(function(){var targetNode=repeaters[i];return function(){IMLibEventResponder.touchEventCancel=!1;targetNode.style.backgroundColor=IMLibUI.mobileSelectionColor}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchend','todo':(function(){var targetNode=repeaters[i];var orgColor=originalColor;return function(){targetNode.style.backgroundColor=orgColor;if(!IMLibEventResponder.touchEventCancel){IMLibEventResponder.touchEventCancel=!1;moveToDetailFunc()}}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchmove','todo':(function(){return function(){IMLibEventResponder.touchEventCancel=!0}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchcancel','todo':(function(){return function(){IMLibEventResponder.touchEventCancel=!0}})()})}}else{IMLibMouseEventDispatch.setExecute(thisId,moveToDetailFunc);switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[0];firstInNode=tdNode.childNodes[0];if(firstInNode){tdNode.insertBefore(buttonNode,firstInNode)}else{tdNode.appendChild(buttonNode)}
break;case 'SELECT':break;default:firstInNode=repeaters[repeaters.length-1].childNodes[0];if(firstInNode){repeaters[repeaters.length-1].insertBefore(buttonNode,firstInNode)}else{repeaters[repeaters.length-1].appendChild(buttonNode)}
break}}},getStepLastSelectedRecord:function(){'use strict';var lastSelection=IMLibPageNavigation.stepNavigation[IMLibPageNavigation.stepNavigation.length-1];return lastSelection.context.store[lastSelection.key]},isNotExpandingContext:function(contextDef){'use strict';if(contextDef['navi-control']&&contextDef['navi-control'].match(/step/i)){return IMLibPageNavigation.stepCurrentContextName!==contextDef.name}
return!1},startStep:function(){'use strict';IMLibPageNavigation.initializeStepInfo(!0);INTERMediator.constructMain(IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName))},initializeStepInfo:function(includeHide){'use strict';var key,dataSrcs,cDef,judgeHide,isDetected=!1;IMLibPageNavigation.stepNavigation=[];IMLibPageNavigation.stepCurrentContextName=null;IMLibPageNavigation.stepStartContextName=null;IMLibPageNavigation.setupStepReturnButton('none');if(INTERMediatorOnPage.getDataSources){dataSrcs=INTERMediatorOnPage.getDataSources();for(key in dataSrcs){if(dataSrcs.hasOwnProperty(key)){cDef=dataSrcs[key];if(cDef['navi-control']){judgeHide=includeHide||(!includeHide&&!cDef['navi-control'].match(/hide/i));if(cDef['navi-control']&&cDef['navi-control'].match(/step/i)){if(judgeHide&&!isDetected){IMLibPageNavigation.stepCurrentContextName=cDef.name;IMLibPageNavigation.stepStartContextName=IMLibPageNavigation.stepCurrentContextName;isDetected=!0;if(cDef['navi-title']){IMLibLocalContext.setValue('navi_title',cDef['navi-title'],!0)}
if(INTERMediatorOnPage[cDef['just-move-thisstep']]){INTERMediatorOnPage[cDef['just-move-thisstep']]()}}}}}}}},setupStepReturnButton:function(style){'use strict';var nodes,i;nodes=document.getElementsByClassName('IM_Button_StepBack');for(i=0;i<nodes.length;i++){nodes[i].style.display=style;if(!INTERMediatorLib.isProcessed(nodes[i])){INTERMediatorLib.addEvent(nodes[i],'click',function(){IMLibPageNavigation.backToPreviousStep()});INTERMediatorLib.markProcessed(nodes[i])}}},moveToNextStep:function(contextObj,keyField,keyValue){'use strict';var context=contextObj,keying=keyField+'='+keyValue;return function(){IMLibQueue.setTask(function(complete){IMLibPageNavigation.moveToNextStepImpl(context,keying);complete()})}},moveNextStep:function(keying){'use strict';var context=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);IMLibPageNavigation.moveToNextStepImpl(context,keying)},moveToNextStepImpl:function(contextObj,keying){'use strict';var key,cDef,dataSrcs,contextDef,isAfterCurrent=!1,control=null,hasNextContext=!1,nextContext;contextDef=contextObj.getContextDef();IMLibPageNavigation.stepNavigation.push({context:contextObj,key:keying});if(INTERMediatorOnPage[contextDef['before-move-nextstep']]){control=INTERMediatorOnPage[contextDef['before-move-nextstep']]()}
if(control===!1){IMLibPageNavigation.stepNavigation.pop();return}else if(control){IMLibPageNavigation.stepCurrentContextName=control}else{dataSrcs=INTERMediatorOnPage.getDataSources();for(key in dataSrcs){if(dataSrcs.hasOwnProperty(key)){cDef=dataSrcs[key];if(cDef.name===contextDef.name){isAfterCurrent=!0}else if(isAfterCurrent&&cDef['navi-control'].match(/step/i)){IMLibPageNavigation.stepCurrentContextName=cDef.name;hasNextContext=!0;break}}}
if(!hasNextContext){return}}
if(INTERMediatorOnPage[contextDef['just-leave-thisstep']]){INTERMediatorOnPage[contextDef['just-leave-thisstep']]()}
if(contextObj.enclosureNode.tagName==='TBODY'){contextObj.enclosureNode.parentNode.style.display='none'}else{contextObj.enclosureNode.style.display='none'}
nextContext=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);contextDef=nextContext.getContextDef();if(nextContext.enclosureNode.tagName==='TBODY'){nextContext.enclosureNode.parentNode.style.display=''}else{nextContext.enclosureNode.style.display=''}
INTERMediator.constructMain(nextContext);IMLibPageNavigation.setupStepReturnButton('');if(contextDef['navi-title']){IMLibLocalContext.setValue('navi_title',contextDef['navi-title'],!0)}
if(INTERMediatorOnPage[contextDef['just-move-thisstep']]){INTERMediatorOnPage[contextDef['just-move-thisstep']]()}},backToPreviousStep:function(){'use strict';var currentContext,prevInfo,contextDef;currentContext=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);contextDef=currentContext.getContextDef();if(INTERMediatorOnPage[contextDef['just-leave-thisstep']]){INTERMediatorOnPage[contextDef['just-leave-thisstep']]()}
prevInfo=IMLibPageNavigation.stepNavigation.pop();IMLibPageNavigation.stepCurrentContextName=prevInfo.context.contextName;if(prevInfo.context.enclosureNode.tagName==='TBODY'){prevInfo.context.enclosureNode.parentNode.style.display=''}else{prevInfo.context.enclosureNode.style.display=''}
if(IMLibPageNavigation.stepStartContextName===IMLibPageNavigation.stepCurrentContextName){IMLibPageNavigation.setupStepReturnButton('none')}
INTERMediator.constructMain(currentContext);INTERMediator.constructMain(prevInfo.context);contextDef=prevInfo.context.getContextDef();if(contextDef['navi-title']){IMLibLocalContext.setValue('navi_title',contextDef['navi-title'],!0)}
if(INTERMediatorOnPage[contextDef['just-move-thisstep']]){INTERMediatorOnPage[contextDef['just-move-thisstep']]()}},moveToDetail:function(keyField,keyValue,isHide,isHidePageNavi){'use strict';var f=keyField,v=keyValue,mh=isHide,pnh=isHidePageNavi;return function(){return IMLibPageNavigation.moveToDetailImpl(f,v,mh,pnh)}},moveToDetailImpl:function(keyField,keyValue,isHide,isHidePageNavi){'use strict';var masterContext,detailContext,contextName,masterEnclosure,detailEnclosure,node,contextDef;IMLibPageNavigation.previousModeDetail={keyField:keyField,keyValue:keyValue,isHide:isHide,isHidePageNavi:isHidePageNavi};masterContext=IMLibContextPool.getMasterContext();detailContext=IMLibContextPool.getDetailContext();if(detailContext){if(INTERMediatorOnPage.naviBeforeMoveToDetail){INTERMediatorOnPage.naviBeforeMoveToDetail(masterContext,detailContext)}
contextDef=detailContext.getContextDef();contextName=contextDef.name;INTERMediator.clearCondition(contextName,'_imlabel_crosstable');INTERMediator.addCondition(contextName,{field:keyField,operator:'=',value:keyValue},undefined,'_imlabel_crosstable');INTERMediator.constructMain(detailContext);INTERMediator.clearCondition(contextName);if(isHide){INTERMediatorOnPage.masterScrollPosition={x:window.scrollX,y:window.scrollY};window.scrollTo(0,0);masterEnclosure=masterContext.enclosureNode;if(masterEnclosure.tagName==='TBODY'){masterEnclosure=masterEnclosure.parentNode}
INTERMediator.masterNodeOriginalDisplay=masterEnclosure.style.display;masterEnclosure.style.display='none';detailEnclosure=detailContext.enclosureNode;if(detailEnclosure.tagName==='TBODY'){detailEnclosure=detailEnclosure.parentNode}
detailEnclosure.style.display=INTERMediator.detailNodeOriginalDisplay}
if(isHidePageNavi){document.getElementById('IM_NAVIGATOR').style.display='none'}
if(IMLibUI.mobileNaviBackButtonId){node=document.getElementById(IMLibUI.mobileNaviBackButtonId);node.style.display='inline-block'}
if(INTERMediatorOnPage.naviAfterMoveToDetail){masterContext=IMLibContextPool.getMasterContext();detailContext=IMLibContextPool.getDetailContext();INTERMediatorOnPage.naviAfterMoveToDetail(masterContext,detailContext)}}},setupDetailAreaToFirstRecord:function(currentContextDef,masterContext){'use strict';var i,comp;if(currentContextDef['navi-control']&&currentContextDef['navi-control'].match(/master/i)){var contextDefs=INTERMediatorOnPage.getDataSources();for(i in contextDefs){if(contextDefs.hasOwnProperty(i)&&contextDefs[i]&&contextDefs[i].name&&contextDefs[i]['navi-control']&&contextDefs[i]['navi-control'].match(/detail/i)){if(Object.keys(masterContext.store).length>0){comp=Object.keys(masterContext.store)[0].split('=');if(comp.length>1){INTERMediator.clearCondition(contextDefs[i].name,'_imlabel_crosstable');INTERMediator.addCondition(contextDefs[i].name,{field:comp[0],operator:'=',value:comp[1]},undefined,'_imlabel_crosstable')}}}}}},moveDetailOnceAgain:function(){'use strict';var p=IMLibPageNavigation.previousModeDetail;IMLibPageNavigation.moveToDetailImpl(p.keyField,p.keyValue,p.isHide,p.isHidePageNavi)},setupBackNaviButton:function(currentContext,node){'use strict';var buttonNode,divNode,i,masterContext,naviControlValue,currentContextDef,showingNode,isHidePageNavi,isUpdateMaster,isTouchRepeater,aNode,nodes,isTop;currentContextDef=currentContext.getContextDef();if(!currentContextDef['navi-control']||!currentContextDef['navi-control'].match(/detail/i)){return}
masterContext=IMLibContextPool.getMasterContext();isHidePageNavi=!!masterContext.getContextDef().paging;if(masterContext.getContextDef().paging&&currentContextDef.paging){INTERMediatorLog.setErrorMessage('The datail context definition has the "paging" key. '+'This is not required and causes bad effect to the pagination.','Detected Error')}
naviControlValue=masterContext.getContextDef()['navi-control'];if(!naviControlValue||(!naviControlValue.match(/hide/i))){return}
isUpdateMaster=!!currentContextDef['navi-control'].match(/update/i);isTouchRepeater=INTERMediator.isMobile||INTERMediator.isTablet;isTop=!(currentContextDef['navi-control'].match(/bottom/i));showingNode=currentContext.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
if(INTERMediator.detailNodeOriginalDisplay){INTERMediator.detailNodeOriginalDisplay=showingNode.style.display}
showingNode.style.display='none';if(isTouchRepeater){nodes=document.getElementsByClassName('IM_Button_BackNavi');if(!nodes||nodes.length===0){aNode=createBackButton('DIV',currentContextDef);IMLibUI.mobileNaviBackButtonId=aNode.id;aNode.style.display='none';nodes=INTERMediatorLib.getElementsByAttributeValue(document.getElementsByTagName('BODY')[0],'data-role',isTop?'header':'footer');if(nodes&&nodes[0]){if(nodes[0].firstChild){nodes[0].insertBefore(aNode,nodes[0].firstChild)}else{nodes[0].appendChild(aNode)}}else{switch(node.tagName){case 'TBODY':tbodyTargetNode(node,isTop,aNode);break;case 'UL':case 'OL':genericTargetNode(node,isTop,'LI',aNode);break;case 'SELECT':break;default:genericTargetNode(node,isTop,'DIV',aNode);break}}
if(!aNode.id){aNode.id=INTERMediator.nextIdValue()}
INTERMediator.eventListenerPostAdding.push({'id':aNode.id,'event':'touchend','todo':moveToMaster(masterContext,currentContext,isHidePageNavi,isUpdateMaster)})}}else{buttonNode=createBackButton('BUTTON',currentContextDef);switch(node.tagName){case 'TBODY':tbodyTargetNode(node,isTop,buttonNode);break;case 'UL':case 'OL':genericTargetNode(node,isTop,'LI',buttonNode);break;case 'SELECT':break;default:genericTargetNode(node,isTop,'DIV',buttonNode);break}
INTERMediatorLib.addEvent(buttonNode,'click',moveToMaster(masterContext,currentContext,isHidePageNavi,isUpdateMaster))}
function createBackButton(tagName,currentContextDef){var buttonNode,buttonName;buttonNode=document.createElement(tagName);INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_BackNavi');buttonName=INTERMediatorOnPage.getMessages()[13];if(currentContextDef['button-names']&&currentContextDef['button-names']['navi-back']){buttonName=currentContextDef['button-names']['navi-back']}
buttonNode.appendChild(document.createTextNode(buttonName));setIdForIMButtons(buttonNode);return buttonNode}
function setIdForIMButtons(node){var thisId;thisId='IM_Button_'+INTERMediator.buttonIdNum;node.setAttribute('id',thisId);INTERMediator.buttonIdNum++}
function tbodyTargetNode(node,isTop,buttonNode){var targetNodeTag,enclosedNode,firstLevelNodes,targetNode,existingButtons,trNode,tdNode;targetNodeTag=isTop?'THEAD':'TFOOT';enclosedNode=node.parentNode;firstLevelNodes=enclosedNode.childNodes;targetNode=null;for(i=0;i<firstLevelNodes.length;i++){if(firstLevelNodes[i].tagName===targetNodeTag){targetNode=firstLevelNodes[i];break}}
if(targetNode===null){targetNode=document.createElement(targetNodeTag);INTERMediator.appendingNodesAtLast.push({targetNode:targetNode,parentNode:enclosedNode,siblingNode:(targetNodeTag==='THEAD')?enclosedNode.firstChild:null})}
existingButtons=INTERMediatorLib.getElementsByClassName(targetNode,'IM_Button_BackNavi');if(existingButtons.length===0){trNode=document.createElement('TR');INTERMediatorLib.setClassAttributeToNode(trNode,'IM_NaviBack_TR');tdNode=document.createElement('TD');tdNode.setAttribute('colspan',100);INTERMediatorLib.setClassAttributeToNode(tdNode,'IM_NaviBack_TD');INTERMediator.setIdValue(trNode);targetNode.appendChild(trNode);trNode.appendChild(tdNode);tdNode.appendChild(buttonNode)}}
function genericTargetNode(node,isTop,naviEncTag,buttonNode){var newNode,existingButtons;newNode=document.createElement(naviEncTag);existingButtons=INTERMediatorLib.getElementsByClassName(divNode,'IM_Button_BackNavi');if(existingButtons.length===0){newNode.appendChild(buttonNode);if(!isTop){node.appendChild(newNode)}else{node.insertBefore(newNode,node.firstChild)}}}
function moveToMaster(a,b,c,d){var masterContextCL=a,detailContextCL=b,pageNaviShow=c,masterUpdate=d,node;return function(event){var showingNode;if(INTERMediatorOnPage.naviBeforeMoveToMaster){INTERMediatorOnPage.naviBeforeMoveToMaster(masterContextCL,detailContextCL)}
showingNode=detailContextCL.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
showingNode.style.display='none';showingNode=masterContextCL.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
showingNode.style.display=INTERMediator.masterNodeOriginalDisplay;if(pageNaviShow){document.getElementById('IM_NAVIGATOR').style.display='block'}
if(masterUpdate){INTERMediator.constructMain(masterContextCL)}
if(IMLibUI.mobileNaviBackButtonId){node=document.getElementById(IMLibUI.mobileNaviBackButtonId);node.style.display='none'}
if(INTERMediatorOnPage.naviAfterMoveToMaster){masterContextCL=IMLibContextPool.getMasterContext();detailContextCL=IMLibContextPool.getDetailContext();INTERMediatorOnPage.naviAfterMoveToMaster(masterContextCL,detailContextCL)}
if(INTERMediatorOnPage.masterScrollPosition){window.scrollTo(INTERMediatorOnPage.masterScrollPosition.x,INTERMediatorOnPage.masterScrollPosition.y)}
event.preventDefault()}}}};var IMLibUI={mobileSelectionColor:'#BBBBBB',mobileNaviBackButtonId:null,mergedFieldSeparator:'\n',valueChange:function(idValue,validationOnly){'use strict';var changedObj,contextInfo,linkInfo,nodeInfo,returnValue=!0;changedObj=document.getElementById(idValue);if(!changedObj){return!1}
if(changedObj.readOnly){return!0}
if(!IMLibUI.validation(changedObj)){changedObj.focus();linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);window.setTimeout((function(){var originalObj=changedObj;var originalContextInfo=contextInfo;return function(){if(originalContextInfo){originalObj.value=originalContextInfo.context.getValue(originalContextInfo.record,originalContextInfo.field)}
originalObj.removeAttribute('data-im-validation-notification')}})(),0);return!1}
if(validationOnly===!0){return!0}
IMLibQueue.setTask(function(completeTask){returnValue=valueChangeImpl(idValue,completeTask)});return returnValue;function valueChangeImpl(idValue,completeTask){var changedObj,objType,i,newValue,result,linkInfo,nodeInfo,contextInfo,parentContext,targetField,targetNode,targetSpec,returnValue=!0;try{changedObj=document.getElementById(idValue);linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);if(!contextInfo){targetNode=document.getElementById(idValue);targetSpec=targetNode.getAttribute('data-im');if(targetSpec&&targetSpec.split(INTERMediator.separator)[0]===IMLibLocalContext.contextName){IMLibLocalContext.updateFromNodeValue(idValue);IMLibCalc.recalculation();completeTask();return!0}
throw 'unfinished'}
objType=changedObj.getAttribute('type');if(objType==='radio'&&!changedObj.checked){completeTask();return!0}
if(!contextInfo){throw 'unfinished'}
newValue=IMLibElement.getValueFromIMNode(changedObj);if(contextInfo.context.parentContext){parentContext=contextInfo.context.parentContext}else{parentContext=IMLibContextPool.getContextFromName(contextInfo.context.sourceName)[0]}
if(parentContext){result=parentContext.isValueUndefined(Object.keys(parentContext.store)[0],contextInfo.field,contextInfo.record)}else{result=contextInfo.context.isValueUndefined(contextInfo.record,contextInfo.field,!1)}
if(result){INTERMediatorLog.setErrorMessage('Error in updating.',INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1040],[contextInfo.context.contextName,contextInfo.field]));throw 'unfinished'}
if(INTERMediatorOnPage.getOptionsTransaction()==='none'){contextInfo.context.setValue(contextInfo.record,contextInfo.field,newValue);contextInfo.context.setModified(contextInfo.record,contextInfo.field,newValue);throw 'unfinished'}
if(INTERMediatorOnPage.doBeforeValueChange){INTERMediatorOnPage.doBeforeValueChange(idValue)}
INTERMediatorOnPage.showProgress();contextInfo.context.updateFieldValue(idValue,(function(){var idValueCapt2=idValue;var contextInfoCapt=contextInfo;var newValueCapt=newValue;var completeTaskCapt=completeTask;return function(result){var updateRequiredContext,currentValue,associatedNode,field,node,children,delNodes,recordObj,keepProp;var keyField=contextInfoCapt.context.getKeyField();if(result&&result.dbresult){recordObj=result.dbresult[0];keepProp=INTERMediator.partialConstructing;INTERMediator.partialConstructing=!1;for(field in recordObj){if(recordObj.hasOwnProperty(field)){contextInfoCapt.context.setValue(keyField+'='+recordObj[keyField],field,recordObj[field])}}}
INTERMediator.partialConstructing=keepProp;updateRequiredContext=IMLibContextPool.dependingObjects(idValueCapt2);for(i=0;i<updateRequiredContext.length;i++){updateRequiredContext[i].foreignValue={};updateRequiredContext[i].foreignValue[contextInfoCapt.field]=newValueCapt;if(updateRequiredContext[i]){INTERMediator.constructMain(updateRequiredContext[i]);associatedNode=updateRequiredContext[i].enclosureNode;if(INTERMediatorLib.isPopupMenu(associatedNode)){currentValue=contextInfo.context.getContextValue(associatedNode.id,'');IMLibElement.setValueToIMNode(associatedNode,'',currentValue,!1)}}}
node=document.getElementById(idValueCapt2);if(node&&node.tagName==='SELECT'){children=node.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(children[i].tagName==='OPTION'&&children[i].getAttribute('data-im-element')==='auto-generated'){delNodes=[];delNodes.push(children[i].getAttribute('id'));IMLibElement.deleteNodes(delNodes)}}}}
IMLibCalc.recalculation();if(INTERMediatorOnPage.doAfterValueChange){INTERMediatorOnPage.doAfterValueChange(idValueCapt2)}
INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage();if(completeTaskCapt){completeTaskCapt()}}})(),(function(){var targetFieldCapt=targetField;var completeTaskCapt=completeTask;return function(){window.alert(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1003],[targetFieldCapt]));INTERMediatorOnPage.hideProgress();if(completeTaskCapt){completeTaskCapt()}}})(),function(){var response=window.confirm(INTERMediatorOnPage.getMessages()[1024]);if(!response){INTERMediatorOnPage.hideProgress()}
if(completeTask){completeTask()}
return response},(function(){var changedObjectCapt=changedObj;var completeTaskCapt=completeTask;return function(initialvalue,newValue,currentFieldVal){if(completeTaskCapt){completeTaskCapt()}
if(!window.confirm(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1001],[initialvalue,newValue,currentFieldVal]))){window.setTimeout(function(){changedObjectCapt.focus()},0);INTERMediatorOnPage.hideProgress();return!1}
return!0}})())}catch(e){if(completeTask){completeTask()}
returnValue=!1}
return returnValue}},validation:function(changedObj){'use strict';var linkInfo,matched,context,i,index,didValidate,contextInfo,result,messageNodes=[],messageNode;if(messageNodes){while(messageNodes.length>0){messageNodes[0].parentNode.removeChild(messageNodes[0]);delete messageNodes[0]}}
if(!messageNodes){messageNodes=[]}
try{linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);didValidate=!1;result=!0;if(linkInfo.length>0){matched=linkInfo[0].match(/([^@]+)/);if(matched[1]!==IMLibLocalContext.contextName){context=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',matched[1]);if(context&&context.validation){for(i=0;i<linkInfo.length;i++){matched=linkInfo[i].match(/([^@]+)@([^@]+)/);for(index in context.validation){if(context.validation[index].field===matched[2]){didValidate=!0;result=Parser.evaluate(context.validation[index].rule,{'value':changedObj.value,'target':changedObj});if(!result){switch(context.validation[index].notify){case 'inline':INTERMediatorLib.clearErrorMessage(changedObj);messageNode=INTERMediatorLib.createErrorMessageNode('SPAN',context.validation[index].message);changedObj.parentNode.insertBefore(messageNode,changedObj.nextSibling);messageNodes.push(messageNode);break;case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(changedObj);messageNode=INTERMediatorLib.createErrorMessageNode('DIV',context.validation[index].message);changedObj.parentNode.appendChild(messageNode);messageNodes.push(messageNode);break;default:if(changedObj.getAttribute('data-im-validation-notification')!=='alert'){window.alert(context.validation[index].message);changedObj.setAttribute('data-im-validation-notification','alert')}
break}
contextInfo=IMLibContextPool.getContextInfoFromId(changedObj,'');if(contextInfo){changedObj.value=contextInfo.context.getValue(contextInfo.record,contextInfo.field);window.setTimeout(function(){changedObj.focus()},0);if(INTERMediatorOnPage.doAfterValidationFailure!==null){INTERMediatorOnPage.doAfterValidationFailure(changedObj,linkInfo[i])}}
return result}else{switch(context.validation[index].notify){case 'inline':case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(changedObj);break}}}}}}}
if(didValidate){if(INTERMediatorOnPage.doAfterValidationSucceed){result=INTERMediatorOnPage.doAfterValidationSucceed(changedObj,linkInfo[i])}}}
return result}catch(ex){if(ex==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-32: on the validation process.')}
return!1}},copyButton:function(contextObj,keyValue){'use strict';var contextDef=contextObj.getContextDef();if(contextDef['repeat-control'].match(/confirm-copy/)){if(!window.confirm(INTERMediatorOnPage.getMessages()[1041])){return}}
IMLibQueue.setTask((function(){var contextObjCapt=contextObj;var keyValueCapt=keyValue;return function(completeTask){var contextDef,assocDef,i,index,def,assocContexts,pStart,copyTerm;contextDef=contextObjCapt.getContextDef();INTERMediatorOnPage.showProgress();try{if(contextDef.relation){for(index in contextDef.relation){if(contextDef.relation[index].portal===!0){contextDef.portal=!0}}}
assocDef=[];if(contextDef['repeat-control'].match(/copy-/)){pStart=contextDef['repeat-control'].indexOf('copy-');copyTerm=contextDef['repeat-control'].substr(pStart+5);if((pStart=copyTerm.search(/\s/))>-1){copyTerm=copyTerm.substr(0,pStart)}
assocContexts=copyTerm.split(',');for(i=0;i<assocContexts.length;i++){def=IMLibContextPool.getContextDef(assocContexts[i]);if(def.relation[0]['foreign-key']){assocDef.push({name:def.name,field:def.relation[0]['foreign-key'],value:keyValueCapt})}}}
INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_copy_async({name:contextDef.name,conditions:[{field:contextDef.key,operator:'=',value:keyValueCapt}],associated:assocDef.length>0?assocDef:null},(function(){var contextDefCapt=contextDef;var contextObjCapt2=contextObjCapt;var completeTaskCapt=completeTask;return function(result){var restore,conditions,sameOriginContexts;var newId=result.newRecordKeyValue;if(newId>-1){restore=INTERMediator.additionalCondition;INTERMediator.startFrom=0;if(contextDefCapt.records<=1){conditions=INTERMediator.additionalCondition;conditions[contextDefCapt.name]={field:contextDefCapt.key,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}
INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(contextObjCapt2);sameOriginContexts=IMLibContextPool.getContextsWithSameOrigin(contextObjCapt2);for(i=0;i<sameOriginContexts.length;i++){INTERMediator.constructMain(sameOriginContexts[i],null)}
INTERMediator.additionalCondition=restore}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();completeTaskCapt();INTERMediatorLog.flushMessage()}})(),completeTask)}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-43')}}})())},deleteButton:function(currentContext,keyField,keyValue,isConfirm){'use strict';var dialogMessage;if(isConfirm){dialogMessage=INTERMediatorOnPage.getMessages()[1025];if(!window.confirm(dialogMessage)){return}}
IMLibQueue.setTask((function(){var currentContextCapt=currentContext;var keyFieldCapt=keyField;var keyValueCapt=keyValue;return function(completeTask){var i,parentKeyValue,deleteSuccessProc,targetRepeaters;INTERMediatorOnPage.showProgress();try{INTERMediatorOnPage.retrieveAuthInfo();deleteSuccessProc=(function(){var currentContextCapt2=currentContextCapt;var completeTaskCapt=completeTask;var keying=keyFieldCapt+'='+keyValueCapt;return function(){if(currentContextCapt2.relation===!0){INTERMediator.pagedAllCount--;if(INTERMediator.pagedAllCount-INTERMediator.startFrom<1){INTERMediator.startFrom=INTERMediator.startFrom-INTERMediator.pagedSize;if(INTERMediator.startFrom<0){INTERMediator.startFrom=0}}
if(INTERMediator.pagedAllCount>=INTERMediator.pagedSize){INTERMediator.construct()}}
IMLibPageNavigation.navigationSetup();targetRepeaters=currentContextCapt2.binding[keying]._im_repeater;for(i=0;i<targetRepeaters.length;i++){IMLibContextPool.removeRecordFromPool(targetRepeaters[i].id)}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();completeTaskCapt();INTERMediatorLog.flushMessage()}})();if(currentContextCapt.isPortal){if(currentContextCapt.potalContainingRecordKV===null){parentKeyValue=Object.keys(currentContextCapt.foreignValue);parentKeyValue[1]=currentContextCapt.foreignValue[parentKeyValue[0]]}else{parentKeyValue=currentContextCapt.potalContainingRecordKV.split('=')}
INTERMediator_DBAdapter.db_update_async({name:currentContextCapt.parentContext&&currentContextCapt.parentContext.contextName?currentContextCapt.parentContext.contextName:currentContextCapt.sourceName,conditions:[{field:parentKeyValue[0],operator:'=',value:parentKeyValue[1]}],dataset:[{field:INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'?'deleteRelated':'-delete.related',operator:'=',value:currentContextCapt.contextName+'.'+keyValue}]},deleteSuccessProc,completeTask)}else{INTERMediator_DBAdapter.db_delete_async({name:currentContextCapt.contextName,conditions:[{field:keyFieldCapt,operator:'=',value:keyValueCapt}]},deleteSuccessProc,function(){INTERMediatorLog.setErrorMessage('Delete Error','EXCEPTION-46');completeTask()})}}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibUI.deleteButton(currentContextCapt,keyFieldCapt,keyValueCapt,!1)});return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-3')}
completeTask()}}})())},insertButton:function(currentObj,keyValue,foreignValues,updateNodes,isConfirm){'use strict';if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1026])){return}}
IMLibQueue.setTask((function(){var currentContext,targetName,isPortal,parentContextName;var keyValueCapt=keyValue;var foreignValuesCapt=foreignValues;var updateNodesCapt=updateNodes;targetName=currentObj.contextName;currentContext=currentObj.getContextDef();isPortal=currentObj.isPortal;if(isPortal){parentContextName=currentObj.sourceName?currentObj.sourceName:null}else{parentContextName=currentObj.parentContext?currentObj.parentContext.contextName:null}
return function(completeTask){var targetRecord,portalField,recordSet,index,targetPortalField,targetPortalValue,existRelated=!1,relatedRecordSet;INTERMediatorOnPage.showProgress();recordSet=[];relatedRecordSet=[];if(foreignValuesCapt){for(index in currentContext.relation){if(currentContext.relation.hasOwnProperty(index)){recordSet.push({field:currentContext.relation[index]['foreign-key'],value:foreignValuesCapt[currentContext.relation[index]['join-field']]})}}}
INTERMediatorOnPage.retrieveAuthInfo();if(isPortal){relatedRecordSet=[];for(index in currentContext['default-values']){if(currentContext['default-values'].hasOwnProperty(index)){relatedRecordSet.push({field:targetName+'::'+currentContext['default-values'][index].field+'.0',value:currentContext['default-values'][index].value})}}
if(relatedRecordSet.length===0){targetPortalValue='';targetRecord=INTERMediator_DBAdapter.db_query({name:targetName,records:1,conditions:[{field:currentContext.key?currentContext.key:INTERMediatorOnPage.defaultKeyName,operator:'=',value:keyValueCapt}]});if(targetRecord.recordset&&targetRecord.recordset[0]&&targetRecord.recordset[0][0]){for(portalField in targetRecord.recordset[0][0]){if(portalField.indexOf(targetName+'::')>-1&&portalField!==targetName+'::'+INTERMediatorOnPage.defaultKeyName){existRelated=!0;targetPortalField=portalField;if(portalField===targetName+'::'+recordSet[0].field){targetPortalValue=recordSet[0].value;break}
if(portalField!==targetName+'::id'&&portalField!==targetName+'::'+recordSet[0].field){break}}}}
if(existRelated===!1){targetRecord=INTERMediator_DBAdapter.db_query({name:targetName,records:0,conditions:[{field:currentContext.key?currentContext.key:INTERMediatorOnPage.defaultKeyName,operator:'=',value:keyValueCapt}]});for(portalField in targetRecord.recordset){if(portalField.indexOf(targetName+'::')>-1&&portalField!==targetName+'::'+INTERMediatorOnPage.defaultKeyName){targetPortalField=portalField;if(portalField===targetName+'::'+recordSet[0].field){targetPortalValue=recordSet[0].value;break}
if(portalField!==targetName+'::id'&&portalField!==targetName+'::'+recordSet[0].field){break}}}}
if(foreignValuesCapt&&recordSet[0]){targetPortalField=targetName+'::'+recordSet[0].field;targetPortalValue=recordSet[0].value}else if(targetPortalField===undefined&&currentContext.relation&&currentContext.relation[0]&&currentContext.relation[0]['join-field']){targetPortalField=targetName+'::'+currentContext.relation[0]['join-field']}
relatedRecordSet.push({field:targetPortalField+'.0',value:targetPortalValue})}
completeTask();if(currentContext.relation&&currentContext.relation[0]&&currentContext.relation[0]['join-field']){INTERMediator_DBAdapter.db_update({name:parentContextName,conditions:[{field:currentContext.relation[0]['join-field'],operator:'=',value:foreignValuesCapt&&foreignValuesCapt.id?foreignValuesCapt.id:keyValueCapt}],dataset:relatedRecordSet});INTERMediator.constructMain()}else{INTERMediatorLog.setErrorMessage('Insert Error (Portal Access Mode)','EXCEPTION-4')}}else{INTERMediator_DBAdapter.db_createRecord_async({name:targetName,dataset:recordSet},(function(){var targetNameCapt=targetName;var currentContextCapt=currentContext;var updateNodesCapt2=updateNodesCapt;var foreignValuesCapt2=foreignValuesCapt;var existRelatedCapt=existRelated;var keyValueCapt2=keyValueCapt;return function(result){var keyField,newRecordId,associatedContext,conditions,createdRecord,i,sameOriginContexts;newRecordId=result.newRecordKeyValue;keyField=currentContextCapt.key?currentContextCapt.key:INTERMediatorOnPage.defaultKeyName;associatedContext=IMLibContextPool.contextFromEnclosureId(updateNodesCapt2);completeTask();if(associatedContext){associatedContext.foreignValue=foreignValuesCapt2;if(currentContextCapt.portal===!0&&existRelatedCapt===!1){conditions=INTERMediator.additionalCondition;conditions[targetNameCapt]={field:keyField,operator:'=',value:keyValueCapt2};INTERMediator.additionalCondition=conditions}
createdRecord=[{}];createdRecord[0][keyField]=newRecordId;INTERMediator.constructMain(associatedContext,result.dbresult);sameOriginContexts=IMLibContextPool.getContextsWithSameOrigin(associatedContext);for(i=0;i<sameOriginContexts.length;i++){INTERMediator.constructMain(sameOriginContexts[i],null)}}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),function(){INTERMediatorLog.setErrorMessage('Insert Error','EXCEPTION-4');completeTask()})}}})())},clickPostOnlyButton:function(node){'use strict';var i,j,fieldData,elementInfo,comp,contextCount,selectedContext,contextInfo,validationInfo;var mergedValues,inputNodes,typeAttr,k,messageNode,result,alertmessage;var linkedNodes,namedNodes,index,hasInvalid,isMerged,contextNodes;var targetNode=node.parentNode;while(!INTERMediatorLib.isEnclosure(targetNode,!0)){targetNode=targetNode.parentNode;if(!targetNode){return}}
if(INTERMediatorOnPage.processingBeforePostOnlyContext){if(!INTERMediatorOnPage.processingBeforePostOnlyContext(targetNode)){return}}
contextNodes=[];linkedNodes=[];namedNodes=[];for(i=0;i<targetNode.childNodes.length;i++){seekLinkedElementInThisContext(targetNode.childNodes[i]);seekLinkedElementInAllChildren(targetNode.childNodes[i])}
contextCount={};for(i=0;i<contextNodes.length;i++){elementInfo=INTERMediatorLib.getLinkedElementInfo(contextNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(!contextCount[comp[j]]){contextCount[comp[j]]=0}
contextCount[comp[j]]++}}
if(contextCount.length<1){return}
var maxCount=-100;for(var contextName in contextCount){if(maxCount<contextCount[contextName]){maxCount=contextCount[contextName];selectedContext=contextName;contextInfo=INTERMediatorOnPage.getContextInfo(contextName)}}
alertmessage='';fieldData=[];hasInvalid=!1;for(i=0;i<linkedNodes.length;i++){elementInfo=INTERMediatorLib.getLinkedElementInfo(linkedNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(comp[0]===selectedContext){if(contextInfo.validation){for(index in contextInfo.validation){if(contextInfo.validation.hasOwnProperty(index)){validationInfo=contextInfo.validation[index];if(validationInfo&&validationInfo.field===comp[1]){switch(validationInfo.notify){case 'inline':case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);break}}}}
for(index in contextInfo.validation){if(contextInfo.validation.hasOwnProperty(index)){validationInfo=contextInfo.validation[index];if(validationInfo.field===comp[1]){if(validationInfo){result=Parser.evaluate(validationInfo.rule,{'value':linkedNodes[i].value,'target':linkedNodes[i]});if(!result){hasInvalid=!0;switch(validationInfo.notify){case 'inline':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);messageNode=INTERMediatorLib.createErrorMessageNode('SPAN',validationInfo.message);linkedNodes[i].parentNode.insertBefore(messageNode,linkedNodes[i].nextSibling);break;case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);messageNode=INTERMediatorLib.createErrorMessageNode('DIV',validationInfo.message);linkedNodes[i].parentNode.appendChild(messageNode);break;default:alertmessage+=validationInfo.message+IMLib.nl_char}
if(INTERMediatorOnPage.doAfterValidationFailure){INTERMediatorOnPage.doAfterValidationFailure(linkedNodes[i])}}}}}}}
if(INTERMediatorLib.isWidgetElement(linkedNodes[i])){fieldData.push({field:comp[1],value:linkedNodes[i]._im_getValue()})}else if(linkedNodes[i].tagName==='SELECT'){fieldData.push({field:comp[1],value:linkedNodes[i].value})}else if(linkedNodes[i].tagName==='TEXTAREA'){fieldData.push({field:comp[1],value:linkedNodes[i].value})}else if(linkedNodes[i].tagName==='INPUT'){if((linkedNodes[i].getAttribute('type')==='radio')||(linkedNodes[i].getAttribute('type')==='checkbox')){if(linkedNodes[i].checked){fieldData.push({field:comp[1],value:linkedNodes[i].value})}}else{fieldData.push({field:comp[1],value:linkedNodes[i].value})}}}}}
for(i=0;i<namedNodes.length;i++){elementInfo=INTERMediatorLib.getNamedInfo(namedNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(comp[0]===selectedContext){mergedValues=[];if(namedNodes[i].tagName==='INPUT'){inputNodes=[namedNodes[i]]}else{inputNodes=namedNodes[i].getElementsByTagName('INPUT')}
for(k=0;k<inputNodes.length;k++){typeAttr=inputNodes[k].getAttribute('type');if(typeAttr==='radio'||typeAttr==='checkbox'){if(inputNodes[k].checked){mergedValues.push(inputNodes[k].value)}}else{mergedValues.push(inputNodes[k].value)}}
if(mergedValues.length>0){isMerged=!1;for(index=0;index<fieldData.length;index++){if(fieldData[index].field===comp[1]){fieldData[index].value+=IMLibUI.mergedFieldSeparator;fieldData[index].value+=mergedValues.join(IMLibUI.mergedFieldSeparator);isMerged=!0}}
if(!isMerged){fieldData.push({field:comp[1],value:mergedValues.join(IMLibUI.mergedFieldSeparator)})}}}}}
if(alertmessage.length>0){window.alert(alertmessage);return}
if(hasInvalid){return}
contextInfo=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',selectedContext);if(INTERMediatorOnPage.modifyPostOnlyContext){contextInfo=INTERMediatorOnPage.modifyPostOnlyContext(contextInfo)}
INTERMediator_DBAdapter.db_createRecord_async({name:selectedContext,dataset:fieldData},function(result){var newNode,parentOfTarget,targetNode=node,thisContext=contextInfo,isSetMsg=!1;INTERMediatorLog.flushMessage();if(INTERMediatorOnPage.processingAfterPostOnlyContext){INTERMediatorOnPage.processingAfterPostOnlyContext(targetNode,result.newRecordKeyValue)}
if(thisContext['post-dismiss-message']){parentOfTarget=targetNode.parentNode;parentOfTarget.removeChild(targetNode);newNode=document.createElement('SPAN');INTERMediatorLib.setClassAttributeToNode(newNode,'IM_POSTMESSAGE');newNode.appendChild(document.createTextNode(thisContext['post-dismiss-message']));parentOfTarget.appendChild(newNode);isSetMsg=!0}
if(thisContext['post-reconstruct']){setTimeout(function(){INTERMediator.construct(!0)},isSetMsg?INTERMediator.waitSecondsAfterPostMessage*1000:0)}
if(thisContext['post-move-url']){setTimeout(function(){location.href=thisContext['post-move-url']},isSetMsg?INTERMediator.waitSecondsAfterPostMessage*1000:0)}},null);function seekLinkedElementInThisContext(node){var children,i;if(node.nodeType===1){if(INTERMediatorLib.isLinkedElement(node)){contextNodes.push(node)}else if(INTERMediatorLib.isWidgetElement(node)){contextNodes.push(node)}else{if(INTERMediatorLib.isEnclosure(node)){return}
children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElementInThisContext(children[i])}}}}
function seekLinkedElementInAllChildren(node){var children,i;if(node.nodeType===1){if(INTERMediatorLib.isNamedElement(node)){namedNodes.push(node)}else if(INTERMediatorLib.isLinkedElement(node)){linkedNodes.push(node)}else if(INTERMediatorLib.isWidgetElement(node)){linkedNodes.push(node)}else{children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElementInAllChildren(children[i])}}}}},eventUpdateHandler:function(contextName){'use strict';IMLibLocalContext.updateAll();var context=IMLibContextPool.getContextFromName(contextName);INTERMediator.constructMain(context[0])},eventAddOrderHandler:function(e){'use strict';var targetKey,targetSplit,key,itemSplit,extValue;if(e.target){targetKey=e.target.getAttribute('data-im')}else{targetKey=e.srcElement.getAttribute('data-im')}
targetSplit=targetKey.split(':');if(targetSplit[0]!=='_@addorder'||targetSplit.length<3){return}
for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){itemSplit=key.split(':');if(itemSplit.length>3&&itemSplit[0]==='valueofaddorder'&&itemSplit[1]===targetSplit[1]){extValue=IMLibLocalContext.getValue(key);if(extValue){IMLibLocalContext.store[key]++}}}}
IMLibLocalContext.setValue('valueof'+targetKey.substring(2),1);IMLibUI.eventUpdateHandler(targetSplit[1])}};var INTERMediatorLog={debugMode:!1,suppressDebugMessageOnPage:!1,suppressErrorMessageOnPage:!1,errorMessages:[],debugMessages:[],errorMessageByAlert:!1,errorMessageOnAlert:null,setDebugMessage:function(message,level){'use strict';if(level===undefined){level=1}
if(INTERMediatorLog.debugMode>=level){INTERMediatorLog.debugMessages.push(message);if(typeof console!=='undefined'){console.log('INTER-Mediator[DEBUG:%s]: %s',new Date(),message)}}},setErrorMessage:function(ex,moreMessage){'use strict';moreMessage=moreMessage===undefined?'':(' - '+moreMessage);if(INTERMediatorLog.errorMessageByAlert){window.alert(INTERMediatorLog.errorMessageOnAlert===null?(ex+moreMessage):INTERMediatorLog.errorMessageOnAlert)}
if((typeof ex==='string'||ex instanceof String)){INTERMediatorLog.errorMessages.push(ex+moreMessage);if(typeof console!=='undefined'){console.error('INTER-Mediator[ERROR]: %s',ex+moreMessage)}}else{if(ex.message){INTERMediatorLog.errorMessages.push(ex.message+moreMessage);if(typeof console!=='undefined'){console.error('INTER-Mediator[ERROR]: %s',ex.message+moreMessage)}}
if(ex.stack&&typeof console!=='undefined'){console.error(ex.stack)}}},flushMessage:function(){'use strict';var debugNode,title,body,i,j,lines,clearButton,tNode;if(INTERMediatorLog.errorMessageByAlert){INTERMediatorLog.suppressErrorMessageOnPage=!0}
if(!INTERMediatorLog.suppressErrorMessageOnPage&&INTERMediatorLog.errorMessages.length>0){debugNode=document.getElementById('_im_error_panel_4873643897897');if(debugNode===null){debugNode=document.createElement('div');debugNode.setAttribute('id','_im_error_panel_4873643897897');debugNode.style.backgroundColor='#FFDDDD';title=document.createElement('h3');title.appendChild(document.createTextNode('Error Info from INTER-Mediator'));title.appendChild(document.createElement('hr'));debugNode.appendChild(title);body=document.getElementsByTagName('body')[0];body.insertBefore(debugNode,body.firstChild)}
debugNode.appendChild(document.createTextNode('============ERROR MESSAGE on '+new Date()+'============'));debugNode.appendChild(document.createElement('hr'));for(i=0;i<INTERMediatorLog.errorMessages.length;i++){lines=INTERMediatorLog.errorMessages[i].split(IMLib.nl_char);for(j=0;j<lines.length;j++){if(j>0){debugNode.appendChild(document.createElement('br'))}
debugNode.appendChild(document.createTextNode(lines[j]))}
debugNode.appendChild(document.createElement('hr'))}}
if(!INTERMediatorLog.suppressDebugMessageOnPage&&INTERMediatorLog.debugMode&&INTERMediatorLog.debugMessages.length>0){debugNode=document.getElementById('_im_debug_panel_4873643897897');if(debugNode===null){debugNode=document.createElement('div');debugNode.setAttribute('id','_im_debug_panel_4873643897897');debugNode.style.backgroundColor='#DDDDDD';clearButton=document.createElement('button');clearButton.setAttribute('title','clear');clearButton.id='_im_debug_panel_4873643897897_button';IMLibMouseEventDispatch.setExecute(clearButton.id,function(){var target;target=document.getElementById('_im_debug_panel_4873643897897');target.parentNode.removeChild(target)});tNode=document.createTextNode('clear');clearButton.appendChild(tNode);title=document.createElement('h3');title.appendChild(document.createTextNode('Debug Info from INTER-Mediator'));title.appendChild(clearButton);title.appendChild(document.createElement('hr'));debugNode.appendChild(title);body=document.getElementsByTagName('body')[0];if(body){if(body.firstChild){body.insertBefore(debugNode,body.firstChild)}else{body.appendChild(debugNode)}}}
debugNode.appendChild(document.createTextNode('============DEBUG INFO on '+new Date()+'============ '));if(INTERMediatorOnPage.getEditorPath()){var aLink=document.createElement('a');aLink.setAttribute('href',INTERMediatorOnPage.getEditorPath());aLink.appendChild(document.createTextNode('Definition File Editor'));debugNode.appendChild(aLink)}
debugNode.appendChild(document.createElement('hr'));for(i=0;i<INTERMediatorLog.debugMessages.length;i++){lines=INTERMediatorLog.debugMessages[i].split(IMLib.nl_char);for(j=0;j<lines.length;j++){if(j>0){debugNode.appendChild(document.createElement('br'))}
debugNode.appendChild(document.createTextNode(lines[j]))}
debugNode.appendChild(document.createElement('hr'))}}
INTERMediatorLog.errorMessages=[];INTERMediatorLog.debugMessages=[]}};var INTERMediator_DBAdapter={eliminateDuplicatedConditions:!1,debugMessage:!1,generate_authParams:function(){'use strict';var authParams='',shaObj,hmacValue,encrypted;var encrypt=new JSEncrypt();if(INTERMediatorOnPage.authUser.length>0){authParams='&clientid='+encodeURIComponent(INTERMediatorOnPage.clientId);authParams+='&authuser='+encodeURIComponent(INTERMediatorOnPage.authUser);if(INTERMediatorOnPage.isNativeAuth||INTERMediatorOnPage.isLDAP){if(INTERMediatorOnPage.authCryptedPassword&&INTERMediatorOnPage.authChallenge){encrypt.setPublicKey(INTERMediatorOnPage.publickey);encrypted=encrypt.encrypt(INTERMediatorOnPage.authCryptedPassword.substr(0,220)+IMLib.nl_char+INTERMediatorOnPage.authChallenge);authParams+='&cresponse='+encodeURIComponent(encrypted+IMLib.nl_char+INTERMediatorOnPage.authCryptedPassword.substr(220));if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('generate_authParams/authCryptedPassword='+INTERMediatorOnPage.authCryptedPassword);INTERMediatorLog.setDebugMessage('generate_authParams/authChallenge='+INTERMediatorOnPage.authChallenge)}}else{authParams+='&cresponse=dummy'}}
if(INTERMediatorOnPage.authHashedPassword&&INTERMediatorOnPage.authChallenge){shaObj=new jsSHA(INTERMediatorOnPage.authHashedPassword,'ASCII');hmacValue=shaObj.getHMAC(INTERMediatorOnPage.authChallenge,'ASCII','SHA-256','HEX');authParams+='&response='+encodeURIComponent(hmacValue);if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('generate_authParams/authHashedPassword='+INTERMediatorOnPage.authHashedPassword);INTERMediatorLog.setDebugMessage('generate_authParams/authChallenge='+INTERMediatorOnPage.authChallenge)}}else{authParams+='&response=dummy'}}
authParams+='&notifyid=';authParams+=encodeURIComponent(INTERMediatorOnPage.clientNotificationIdentifier());authParams+=('&pusher='+(INTERMediator.pusherAvailable?'yes':''));return authParams},store_challenge:function(challenge){'use strict';if(challenge!==null){INTERMediatorOnPage.authChallenge=challenge.substr(0,24);INTERMediatorOnPage.authUserHexSalt=challenge.substr(24,32);INTERMediatorOnPage.authUserSalt=String.fromCharCode(parseInt(challenge.substr(24,2),16),parseInt(challenge.substr(26,2),16),parseInt(challenge.substr(28,2),16),parseInt(challenge.substr(30,2),16));if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('store_challenge/authChallenge='+INTERMediatorOnPage.authChallenge);INTERMediatorLog.setDebugMessage('store_challenge/authUserHexSalt='+INTERMediatorOnPage.authUserHexSalt);INTERMediatorLog.setDebugMessage('store_challenge/authUserSalt='+INTERMediatorOnPage.authUserSalt)}}},logging_comAction:function(debugMessageNumber,appPath,accessURL,authParams){'use strict';INTERMediatorLog.setDebugMessage(INTERMediatorOnPage.getMessages()[debugMessageNumber]+'Accessing:'+decodeURI(appPath)+', Parameters:'+decodeURI(accessURL+authParams))},logging_comResult:function(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken){'use strict';var responseTextTrancated;if(INTERMediatorLog.debugMode>1){if(myRequest.responseText.length>1000){responseTextTrancated=myRequest.responseText.substr(0,1000)+' ...[trancated]'}else{responseTextTrancated=myRequest.responseText}
INTERMediatorLog.setDebugMessage('myRequest.responseText='+responseTextTrancated);INTERMediatorLog.setDebugMessage('Return: resultCount='+resultCount+', dbresult='+INTERMediatorLib.objectToString(dbresult)+IMLib.nl_char+'Return: requireAuth='+requireAuth+', challenge='+challenge+', clientid='+clientid+IMLib.nl_char+'Return: newRecordKeyValue='+newRecordKeyValue+', changePasswordResult='+changePasswordResult+', mediatoken='+mediatoken)}},server_access:function(accessURL,debugMessageNumber,errorMessageNumber){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,totalCount=null,challenge=null,clientid=null,requireAuth=!1,myRequest=null,changePasswordResult=null,mediatoken=null,appPath,authParams,jsonObject,i,notifySupport=!1,useNull=!1,registeredID='';appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();INTERMediator_DBAdapter.logging_comAction(debugMessageNumber,appPath,accessURL,authParams);INTERMediatorOnPage.notifySupport=notifySupport;try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!1,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');myRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');myRequest.setRequestHeader('X-Requested-With','XMLHttpRequest');myRequest.setRequestHeader('X-From',location.href);myRequest.send(accessURL+authParams);jsonObject=JSON.parse(myRequest.responseText);resultCount=jsonObject.resultCount?jsonObject.resultCount:0;totalCount=jsonObject.totalCount?jsonObject.totalCount:null;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;notifySupport=jsonObject.notifySupport;for(i=0;i<jsonObject.errorMessages.length;i++){INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
useNull=jsonObject.usenull;registeredID=jsonObject.hasOwnProperty('registeredid')?jsonObject.registeredid:'';INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(INTERMediatorOnPage.isLDAP===!0&&INTERMediatorOnPage.authUserHexSalt!==INTERMediatorOnPage.authHashedPassword.substr(-8,8)){if(accessURL!=='access=challenge'){requireAuth=!0}}}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorMessageNumber],[e,myRequest.responseText]))}
if(accessURL.indexOf('access=changepassword&newpass=')===0){return changePasswordResult}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();throw new Error('_im_requath_request_')}
if(!accessURL.match(/access=challenge/)){INTERMediatorOnPage.authCount=0}
INTERMediatorOnPage.storeCredentialsToCookieOrStorage();INTERMediatorOnPage.notifySupport=notifySupport;return{dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull}},server_access_async:function(accessURL,debugMessageNumber,errorMessageNumber,successProc,failedProc,authAgainProc){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,totalCount=null,challenge=null,clientid=null,requireAuth=!1,myRequest=null,changePasswordResult=null,mediatoken=null,appPath,authParams,jsonObject,i,notifySupport=!1,useNull=!1,registeredID='';appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();INTERMediator_DBAdapter.logging_comAction(debugMessageNumber,appPath,accessURL,authParams);INTERMediatorOnPage.notifySupport=notifySupport;try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!0,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');myRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');myRequest.setRequestHeader('X-Requested-With','XMLHttpRequest');myRequest.setRequestHeader('X-From',location.href);myRequest.onreadystatechange=function(){switch(myRequest.readyState){case 0:break;case 1:break;case 2:break;case 3:break;case 4:try{jsonObject=JSON.parse(myRequest.responseText)}catch(ex){INTERMediatorLog.setErrorMessage('Communication Error: '+myRequest.responseText);if(failedProc){failedProc(new Error('_im_communication_error_'))}
return}
resultCount=jsonObject.resultCount?jsonObject.resultCount:0;totalCount=jsonObject.totalCount?jsonObject.totalCount:null;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;notifySupport=jsonObject.notifySupport;for(i=0;i<jsonObject.errorMessages.length;i++){INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
useNull=jsonObject.usenull;registeredID=jsonObject.hasOwnProperty('registeredid')?jsonObject.registeredid:'';if(jsonObject.errorMessages.length>0){INTERMediatorLog.setErrorMessage('Communication Error: '+jsonObject.errorMessages);if(failedProc){failedProc()}
throw 'Communication Error'}
INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(INTERMediatorOnPage.isLDAP===!0&&INTERMediatorOnPage.authUserHexSalt!==INTERMediatorOnPage.authHashedPassword.substr(-8,8)){if(accessURL!=='access=challenge'){requireAuth=!0}}
if(accessURL.indexOf('access=changepassword&newpass=')===0){if(successProc){successProc({dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull})}
return}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();if(authAgainProc){authAgainProc(myRequest)}
return}
if(!accessURL.match(/access=challenge/)){INTERMediatorOnPage.authCount=0}
INTERMediatorOnPage.storeCredentialsToCookieOrStorage();INTERMediatorOnPage.notifySupport=notifySupport;if(successProc){successProc({dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull})}
break}};myRequest.send(accessURL+authParams)}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorMessageNumber],[e,myRequest.responseText]));if(failedProc){failedProc()}}},changePassword:function(username,oldpassword,newpassword){'use strict';var challengeResult,params,result,messageNode;var encrypt=new JSEncrypt();if(username&&oldpassword){INTERMediatorOnPage.authUser=username;if(username!==''&&(INTERMediatorOnPage.authChallenge===null||INTERMediatorOnPage.authChallenge.length<24)){INTERMediatorOnPage.authHashedPassword='need-hash-pls';challengeResult=INTERMediator_DBAdapter.getChallenge();if(!challengeResult){messageNode=document.getElementById('_im_newpass_message');if(messageNode){INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2008)))}else{window.alert(INTERMediatorLib.getInsertedStringFromErrorNumber(2008))}
INTERMediatorLog.flushMessage();return}}
INTERMediatorOnPage.authHashedPassword=SHA1(oldpassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt}else{INTERMediatorOnPage.retrieveAuthInfo()}
params='access=changepassword&newpass='+INTERMediatorLib.generatePasswordHash(newpassword);try{result=INTERMediator_DBAdapter.server_access(params,1029,1030);if(result){encrypt.setPublicKey(INTERMediatorOnPage.publickey);INTERMediatorOnPage.authCryptedPassword=encrypt.encrypt(newpassword);INTERMediatorOnPage.authHashedPassword=SHA1(newpassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt;INTERMediatorOnPage.storeCredentialsToCookieOrStorage()}}catch(e){return!1}
return result},getChallenge:function(){'use strict';try{this.server_access('access=challenge',1027,1028)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-19')}}
if(INTERMediatorOnPage.authChallenge===null){return!1}
return!0},uploadFile:function(parameters,uploadingFile,doItOnFinish,exceptionProc){'use strict';var myRequest=null,appPath,authParams,accessURL,i;appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();accessURL='access=uploadfile'+parameters;INTERMediator_DBAdapter.logging_comAction(1031,appPath,accessURL,authParams);try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!0,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');var params=(accessURL+authParams).split('&');var fd=new FormData();for(i=0;i<params.length;i++){var valueset=params[i].split('=');fd.append(valueset[0],decodeURIComponent(valueset[1]))}
fd.append('_im_uploadfile',uploadingFile.content);myRequest.onreadystatechange=function(){switch(myRequest.readyState){case 3:break;case 4:INTERMediator_DBAdapter.uploadFileAfterSucceed(myRequest,doItOnFinish,exceptionProc,!1);break}};myRequest.send(fd)}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1032],[e,myRequest.responseText]));exceptionProc()}},uploadFileAfterSucceed:function(myRequest,doItOnFinish,exceptionProc,isErrorDialog){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,challenge=null,clientid=null,requireAuth=!1,changePasswordResult=null,mediatoken=null,jsonObject,i,returnValue=!0;try{jsonObject=JSON.parse(myRequest.responseText)}catch(ex){INTERMediatorLog.setErrorMessage(ex,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1032],['','']));INTERMediatorLog.flushMessage();exceptionProc();return!1}
resultCount=jsonObject.resultCount?jsonObject.resultCount:0;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;for(i=0;i<jsonObject.errorMessages.length;i++){if(isErrorDialog){window.alert(jsonObject.errorMessages[i])}else{INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
returnValue=!1}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();exceptionProc()}
INTERMediatorOnPage.authCount=0;INTERMediatorOnPage.storeCredentialsToCookieOrStorage();doItOnFinish(dbresult);return returnValue},db_query:function(args){'use strict';var params,returnValue,result,contextDef;if(!INTERMediator_DBAdapter.db_queryChecking(args)){return}
params=INTERMediator_DBAdapter.db_queryParameters(args);returnValue={};try{result=this.server_access(params,1012,1004);returnValue.recordset=result.dbresult;returnValue.totalCount=result.resultCount;returnValue.count=0;returnValue.registeredId=result.registeredId;returnValue.nullAcceptable=result.nullAcceptable;returnValue.count=result.dbresult?Object.keys(result.dbresult).length:0;contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',args.name);if(!contextDef.relation&&args.paging&&Boolean(args.paging)===!0){INTERMediator.pagedAllCount=parseInt(result.resultCount,10);if(result.totalCount){INTERMediator.totalRecordCount=parseInt(result.totalCount,10)}}
if((args.paging!==null)&&(Boolean(args.paging)===!0)){INTERMediator.pagination=!0;if(!(Number(args.records)>=Number(INTERMediator.pagedSize)&&Number(INTERMediator.pagedSize)>0)){INTERMediator.pagedSize=parseInt(args.records,10)}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-17')}
returnValue.recordset=null;returnValue.totalCount=0;returnValue.count=0;returnValue.registeredid=null;returnValue.nullAcceptable=null}
return returnValue},db_queryWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_query(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_queryWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-16')}}
completion(returnValue)},db_query_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_queryChecking(args)){return}
params=INTERMediator_DBAdapter.db_queryParameters(args);try{this.server_access_async(params,1012,1004,(function(){var contextDef;var contextName=args.name;var recordsNumber=Number(args.records);var succesProcCapt=successProc;return function(result){result.count=result.dbresult?Object.keys(result.dbresult).length:0;contextDef=IMLibContextPool.getContextDef(contextName);if(!contextDef.relation&&args.paging&&Boolean(args.paging)===!0){INTERMediator.pagedAllCount=parseInt(result.resultCount,10);if(result.totalCount){INTERMediator.totalRecordCount=parseInt(result.totalCount,10)}}
if((args.paging!==null)&&(Boolean(args.paging)===!0)){INTERMediator.pagination=!0;if(!(recordsNumber>=Number(INTERMediator.pagedSize)&&Number(INTERMediator.pagedSize)>0)){INTERMediator.pagedSize=parseInt(recordsNumber,10)}}
succesProcCapt(result)}})(),failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_query_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-17')}},db_queryChecking:function(args){'use strict';var noError=!0;if(args.name===null||args.name===''){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1005));noError=!1}
return noError},db_queryParameters:function(args){'use strict';var i,index,params,counter,extCount,criteriaObject,sortkeyObject,extCountSort,recordLimit=10000000,conditions,conditionSign,modifyConditions,orderFields,key,keyParams,value,fields,operator,orderedKeys,removeIndice=[];if(args.records===null){params='access=read&name='+encodeURIComponent(args.name)}else{if(parseInt(args.records,10)===0&&(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI')){params='access=describe&name='+encodeURIComponent(args.name)}else{params='access=read&name='+encodeURIComponent(args.name)}
if(Boolean(args.uselimit)===!0&&parseInt(args.records,10)>=INTERMediator.pagedSize&&parseInt(INTERMediator.pagedSize,10)>0){recordLimit=INTERMediator.pagedSize}else{recordLimit=args.records}}
if(args.primaryKeyOnly){params+='&pkeyonly=true'}
if(args.fields){for(i=0;i<args.fields.length;i++){params+='&field_'+i+'='+encodeURIComponent(args.fields[i])}}
counter=0;if(args.parentkeyvalue){for(index in args.parentkeyvalue){if(args.parentkeyvalue.hasOwnProperty(index)){params+='&foreign'+counter+'field='+encodeURIComponent(index);params+='&foreign'+counter+'value='+encodeURIComponent(args.parentkeyvalue[index]);counter++}}}
if(args.useoffset&&INTERMediator.startFrom!==null){params+='&start='+encodeURIComponent(INTERMediator.startFrom)}
extCount=0;conditions=[];while(args.conditions&&args.conditions[extCount]){conditionSign=args.conditions[extCount].field+'#'+args.conditions[extCount].operator+'#'+args.conditions[extCount].value;if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount;params+='field='+encodeURIComponent(args.conditions[extCount].field);params+='&condition'+extCount;params+='operator='+encodeURIComponent(args.conditions[extCount].operator);params+='&condition'+extCount;params+='value='+encodeURIComponent(args.conditions[extCount].value);conditions.push(conditionSign)}
extCount++}
criteriaObject=INTERMediator.additionalCondition[args.name];if(criteriaObject){if(criteriaObject.field){criteriaObject=[criteriaObject]}
for(index=0;index<criteriaObject.length;index++){if(criteriaObject[index]&&criteriaObject[index].field){if(criteriaObject[index].value||criteriaObject[index].field==='__operation__'){conditionSign=criteriaObject[index].field+'#'+((criteriaObject[index].operator!==undefined)?criteriaObject[index].operator:'')+'#'+((criteriaObject[index].value!==undefined)?criteriaObject[index].value:'');if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount;params+='field='+encodeURIComponent(criteriaObject[index].field);if(criteriaObject[index].operator!==undefined){params+='&condition'+extCount;params+='operator='+encodeURIComponent(criteriaObject[index].operator)}
if(criteriaObject[index].value!==undefined){params+='&condition'+extCount;value=criteriaObject[index].value;if(Array.isArray(value)){value=JSON.stringify(value)}
params+='value='+encodeURIComponent(value)}
if(criteriaObject[index].field!=='__operation__'){conditions.push(conditionSign)}}
extCount++}}
if(criteriaObject[index]&&criteriaObject[index].onetime){removeIndice.push=index}}
if(removeIndice.length>0){modifyConditions=[];for(index=0;index<criteriaObject.length;index++){if(!(index in removeIndice)){modifyConditions.push(criteriaObject[index])}}
INTERMediator.additionalCondition[args.name]=modifyConditions;IMLibLocalContext.archive()}}
extCountSort=0;sortkeyObject=INTERMediator.additionalSortKey[args.name];if(sortkeyObject){if(sortkeyObject.field){sortkeyObject=[sortkeyObject]}
for(index=0;index<sortkeyObject.length;index++){params+='&sortkey'+extCountSort;params+='field='+encodeURIComponent(sortkeyObject[index].field);params+='&sortkey'+extCountSort;params+='direction='+encodeURIComponent(sortkeyObject[index].direction);extCountSort++}}
orderFields={};for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){value=String(IMLibLocalContext.store[key]);keyParams=key.split(':');if(keyParams&&keyParams.length>1&&keyParams[1].trim()===args.name&&value.length>0){if(keyParams[0].trim()==='condition'&&keyParams.length>=4){fields=keyParams[2].split(',');operator=keyParams[3].trim();if(fields.length>1){params+='&condition'+extCount+'field=__operation__';params+='&condition'+extCount+'operator=ex';extCount++}
for(index=0;index<fields.length;index++){conditionSign=fields[index].trim()+'#'+operator+'#'+value;if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount+'field='+encodeURIComponent(fields[index].replace(';;','::').trim());params+='&condition'+extCount+'operator='+encodeURIComponent(operator);params+='&condition'+extCount+'value='+encodeURIComponent(value);conditions.push(conditionSign)}
extCount++}}else if(keyParams[0].trim()==='valueofaddorder'&&keyParams.length>=4){orderFields[parseInt(value)]=[keyParams[2].trim(),keyParams[3].trim()]}}}}
params+='&records='+encodeURIComponent(recordLimit);orderedKeys=Object.keys(orderFields);for(i=0;i<orderedKeys.length;i++){params+='&sortkey'+extCountSort+'field='+encodeURIComponent(orderFields[orderedKeys[i]][0]);params+='&sortkey'+extCountSort+'direction='+encodeURIComponent(orderFields[orderedKeys[i]][1]);extCountSort++}
return params},db_update:function(args){'use strict';var params,result;if(!INTERMediator_DBAdapter.db_updateChecking(args)){return}
params=INTERMediator_DBAdapter.db_updateParameters(args);result=this.server_access(params,1013,1014);return result.dbresult},db_updateWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_update(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_updateWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-15')}}
completion(returnValue)},db_updateChecking:function(args){'use strict';var noError=!0,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1007));noError=!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));noError=!1}
if(args.dataset===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1011));noError=!1}
return noError},db_updateParameters:function(args){'use strict';var params,extCount,counter,index,addedObject;params='access=update&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnUpdate&&INTERMediator.additionalFieldValueOnUpdate[args.name]){addedObject=INTERMediator.additionalFieldValueOnUpdate[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
if(args.conditions){for(extCount=0;extCount<args.conditions.length;extCount++){params+='&condition'+extCount+'field=';params+=encodeURIComponent(args.conditions[extCount].field);params+='&condition'+extCount+'operator=';params+=encodeURIComponent(args.conditions[extCount].operator);if(args.conditions[extCount].value){params+='&condition'+extCount+'value=';params+=encodeURIComponent(args.conditions[extCount].value)}}}
for(extCount=0;extCount<args.dataset.length;extCount++){params+='&field_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].field);if(INTERMediator.isTrident&&INTERMediator.ieVersion===8){params+='&value_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].value.replace(/\n/g,''))}else{params+='&value_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].value)}}
return params},db_update_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_updateChecking(args)){return}
params=INTERMediator_DBAdapter.db_updateParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1013,1014,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_update_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_delete:function(args){'use strict';var params,result;if(!INTERMediator_DBAdapter.db_deleteChecking(args)){return}
params=INTERMediator_DBAdapter.db_deleteParameters(args);result=this.server_access(params,1017,1015);INTERMediatorLog.flushMessage();return result},db_deleteWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_delete(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_deleteWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-14')}}
completion(returnValue)},db_deleteChecking:function(args){'use strict';var noError=!0,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1019));noError=!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));noError=!1}
if(args.conditions===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1020));noError=!1}
return noError},db_deleteParameters:function(args){'use strict';var params,i,counter,index,addedObject;params='access=delete&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnDelete&&INTERMediator.additionalFieldValueOnDelete[args.name]){addedObject=INTERMediator.additionalFieldValueOnDelete[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
for(i=0;i<args.conditions.length;i++){params+='&condition'+i+'field='+encodeURIComponent(args.conditions[i].field);params+='&condition'+i+'operator='+encodeURIComponent(args.conditions[i].operator);params+='&condition'+i+'value='+encodeURIComponent(args.conditions[i].value)}
return params},db_delete_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_deleteChecking(args)){return}
params=INTERMediator_DBAdapter.db_deleteParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1017,1015,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_delete_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_createRecord:function(args){'use strict';var params,result;params=INTERMediator_DBAdapter.db_createParameters(args);if(params){result=INTERMediator_DBAdapter.server_access(params,1018,1016);INTERMediatorLog.flushMessage();return{newKeyValue:result.newRecordKeyValue,recordset:result.dbresult}}
return!1},db_createRecordWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_createRecord(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_createRecordWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-13')}}
if(completion){completion(returnValue.newKeyValue)}},db_createRecord_async:function(args,successProc,failedProc){'use strict';var params=INTERMediator_DBAdapter.db_createParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1018,1016,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_createRecord_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_createParameters:function(args){'use strict';var params,i,index,addedObject,counter,targetKey,ds,key,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1021));return!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));return!1}
ds=INTERMediatorOnPage.getDataSources();targetKey=null;for(key in ds){if(ds.hasOwnProperty(key)&&ds[key].name===args.name){targetKey=key;break}}
if(targetKey===null){INTERMediatorLog.setErrorMessage('no targetname :'+args.name);return!1}
params='access=create&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnNewRecord&&INTERMediator.additionalFieldValueOnNewRecord[args.name]){addedObject=INTERMediator.additionalFieldValueOnNewRecord[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
for(i=0;i<args.dataset.length;i++){params+='&field_'+counter+'='+encodeURIComponent(args.dataset[i].field);params+='&value_'+counter+'='+encodeURIComponent(args.dataset[i].value);counter++}
return params},db_copy:function(args){'use strict';var params,result;params=INTERMediator_DBAdapter.db_copyParameters(args);if(params){result=INTERMediator_DBAdapter.server_access(params,1017,1015);INTERMediatorLog.flushMessage();return{newKeyValue:result.newRecordKeyValue,recordset:result.dbresult}}
return!1},db_copyWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_copy(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_copyWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-14')}}
completion(returnValue)},db_copy_async:function(args,successProc,failedProc){'use strict';var params=INTERMediator_DBAdapter.db_copyParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1017,1015,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_copy_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_copyParameters:function(args){'use strict';var noError=!0,params,i;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1019));noError=!1}
if(args.conditions===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1020));noError=!1}
if(!noError){return!1}
params='access=copy&name='+encodeURIComponent(args.name);for(i=0;i<args.conditions.length;i++){params+='&condition'+i+'field='+encodeURIComponent(args.conditions[i].field);params+='&condition'+i+'operator='+encodeURIComponent(args.conditions[i].operator);params+='&condition'+i+'value='+encodeURIComponent(args.conditions[i].value)}
if(args.associated){for(i=0;i<args.associated.length;i++){params+='&assoc'+i+'='+encodeURIComponent(args.associated[i].name);params+='&asfield'+i+'='+encodeURIComponent(args.associated[i].field);params+='&asvalue'+i+'='+encodeURIComponent(args.associated[i].value)}}
return params},createExceptionFunc:function(errMessageNumber,AuthProc){'use strict';var errorNumCapt=errMessageNumber;return function(myRequest){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(AuthProc)}}else{INTERMediatorLog.setErrorMessage('Communication Error',INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorNumCapt],['Communication Error',myRequest.responseText]))}}},unregister:function(entityPkInfo){'use strict';var result=null,params;if(INTERMediatorOnPage.clientNotificationKey){var appKey=INTERMediatorOnPage.clientNotificationKey();if(appKey&&appKey!=='_im_key_isnt_supplied'){params='access=unregister';if(entityPkInfo){params+='&pks='+encodeURIComponent(JSON.stringify(entityPkInfo))}
result=this.server_access(params,1018,1016);return result}}}};var IMLibQueue={tasks:[],isExecute:!1,dataStore:{},dsLabel:0,readyTo:!1,getNewLabel:function(){'use strict';IMLibQueue.dsLabel++;return IMLibQueue.dsLabel},getDataStore:function(label,key){'use strict';if(!IMLibQueue.dataStore[label]){IMLibQueue.dataStore[label]={}}
return IMLibQueue.dataStore[label][key]},setDataStore:function(label,key,value){'use strict';if(!IMLibQueue.dataStore[label]){IMLibQueue.dataStore[label]={}}
IMLibQueue.dataStore[label][key]=value},setTask:function(aTask,startHere){'use strict';if(startHere){IMLibQueue.isExecute=!0;aTask(function(){});IMLibQueue.isExecute=!1}else{IMLibQueue.tasks.push(aTask);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}}},setPriorTask:function(aTask){'use strict';IMLibQueue.tasks.unshift(aTask);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},setSequentialTasks:function(tasksArray){'use strict';Array.prototype.push.apply(IMLibQueue.tasks,tasksArray);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},setSequentialPriorTasks:function(tasksArray){'use strict';Array.prototype.push.apply(tasksArray,IMLibQueue.tasks);IMLibQueue.tasks=tasksArray;if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},startNextTask:function(){'use strict';if(IMLibQueue.isExecute){if(IMLibQueue.tasks.length>0){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}
return}
if(IMLibQueue.tasks.length>0){var aTask=IMLibQueue.tasks.shift();IMLibQueue.isExecute=!0;IMLibQueue.readyTo=!1;aTask(function(){IMLibQueue.isExecute=!1;if(IMLibQueue.tasks.length>0){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}})}}};var IMLibChangeEventDispatch;var IMLibKeyDownEventDispatch;var IMLibKeyUpEventDispatch;var IMLibInputEventDispatch;var IMLibMouseEventDispatch;var IMLibBlurEventDispatch;function IMLibEventDispatch(){'use strict';this.dispatchTable={};this.dispatchTableTarget={}}
IMLibEventDispatch.prototype.clearAll=function(){'use strict';this.dispatchTable={};this.dispatchTableTarget={}};IMLibEventDispatch.prototype.setExecute=function(idValue,exec){'use strict';if(idValue&&exec){this.dispatchTable[idValue]=exec}};IMLibEventDispatch.prototype.setTargetExecute=function(targetValue,exec){'use strict';if(targetValue&&exec){this.dispatchTableTarget[targetValue]=exec}};IMLibEventDispatch.prototype.setExecuteByCode=function(idValue,keyCode,exec){'use strict';if(idValue&&keyCode){if(!this.dispatchTable[idValue]){this.dispatchTable[idValue]={}}
this.dispatchTable[idValue][keyCode]=exec}};var IMLibEventResponder={touchEventCancel:!1,isSetup:!1,setup:function(){'use strict';var body;if(IMLibEventResponder.isSetup){return}
IMLibEventResponder.isSetup=!0;IMLibChangeEventDispatch=new IMLibEventDispatch();IMLibKeyDownEventDispatch=new IMLibEventDispatch();IMLibKeyUpEventDispatch=new IMLibEventDispatch();IMLibMouseEventDispatch=new IMLibEventDispatch();IMLibBlurEventDispatch=new IMLibEventDispatch();IMLibInputEventDispatch=new IMLibEventDispatch();body=document.getElementsByTagName('BODY')[0];INTERMediatorLib.addEvent(body,'change',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibChangeEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'blur',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibBlurEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'input',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibInputEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'keydown',function(e){var event,target,idValue,keyCode;event=e?e:window.event;if(!event){return}
keyCode=(window.event)?e.which:e.keyCode;target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
if(!IMLibKeyDownEventDispatch.dispatchTable[idValue]){return}
var executable=IMLibKeyDownEventDispatch.dispatchTable[idValue][keyCode];if(!executable){return}
executable(event)});INTERMediatorLib.addEvent(body,'keyup',function(e){var event,charCode,target,idValue;event=e?e:window.event;if(event.charCode){charCode=event.charCode}else{charCode=event.keyCode}
if(!event){return}
target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
if(!IMLibKeyUpEventDispatch.dispatchTable[idValue]){return}
var executable=IMLibKeyUpEventDispatch.dispatchTable[idValue][charCode];if(!executable){return}
executable(event)});INTERMediatorLib.addEvent(body,'click',function(e){var event,target,idValue,executable,targetDefs,i,nodeInfo,value;event=e?e:window.event;if(!event){return}
target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
executable=IMLibMouseEventDispatch.dispatchTable[idValue];if(executable){executable(event);return}
targetDefs=INTERMediatorLib.getLinkedElementInfo(target);for(i=0;i<targetDefs.length;i++){executable=IMLibMouseEventDispatch.dispatchTableTarget[targetDefs[i]];if(executable){nodeInfo=INTERMediatorLib.getNodeInfoArray(targetDefs[i]);if(nodeInfo.target){value=target.getAttribute(nodeInfo.target)}else{value=IMLibElement.getValueFromIMNode(target)}
executable(value,target);return}}})}};INTERMediator.propertyIETridentSetup();INTERMediator.propertyW3CUserAgentSetup();if(INTERMediator.isIE&&INTERMediator.ieVersion<9){INTERMediator.startFrom=0;INTERMediator.pagedSize=0;INTERMediator.pagination=!1;INTERMediator.additionalCondition={};INTERMediator.additionalSortKey={};INTERMediator.recordLimit={};IMLibCalc.regexpForSeparator=INTERMediator.separator}else{Object.defineProperty(INTERMediator,'startFrom',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_startFrom',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_startFrom',value)}});Object.defineProperty(INTERMediator,'pagedSize',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_pagedSize',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_pagedSize',value)}});Object.defineProperty(INTERMediator,'pagination',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_pagination',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_pagination',value)}});Object.defineProperty(INTERMediator,'additionalCondition',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_additionalCondition',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_additionalCondition',value)}});Object.defineProperty(INTERMediator,'additionalSortKey',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_additionalSortKey',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_additionalSortKey',value)}});Object.defineProperty(INTERMediator,'recordLimit',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_recordLimit',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_recordLimit',value)}});Object.defineProperty(IMLibCalc,'regexpForSeparator',{get:function(){'use strict';if(INTERMediator){return new RegExp(INTERMediator.separator)}
return new RegExp('@')}})}
if(!INTERMediator.additionalCondition){INTERMediator.additionalCondition={}}
if(!INTERMediator.additionalSortKey){INTERMediator.additionalSortKey={}}
INTERMediatorLib.addEvent(window,'beforeunload',function(){if(IMLibQueue.tasks.length>0){var confirmationMessage='Some tasks are unfinished.';var ev=(e||window.event);ev.returnValue=confirmationMessage;return confirmationMessage}else{return undefined}});INTERMediatorLib.addEvent(window,'unload',function(){'use strict';INTERMediator_DBAdapter.unregister()});INTERMediatorLib.addEvent(window,'load',function(){'use strict';var key,errorNode;if(INTERMediatorOnPage.initLocalContext){for(key in INTERMediatorOnPage.initLocalContext){if(INTERMediatorOnPage.initLocalContext.hasOwnProperty(key)){IMLibLocalContext.setValue(key,INTERMediatorOnPage.initLocalContext[key],!0)}}}
errorNode=document.getElementById(INTERMediatorOnPage.nonSupportMessageId);if(INTERMediatorOnPage.isAutoConstruct){if(errorNode){if(INTERMediatorOnPage.INTERMediatorCheckBrowser(errorNode)){INTERMediator.construct(!0)}}else{INTERMediator.construct(!0)}}});

function SHA1(s){function U(a,b,c){while(0<c--)a.push(b)}function L(a,b){return(a<<b)|(a>>>(32-b))}function P(a,b,c){return a^b^c}function A(a,b){var c=(b&0xFFFF)+(a&0xFFFF),d=(b>>>16)+(a>>>16)+(c>>>16);return((d&0xFFFF)<<16)|(c&0xFFFF)}var B="0123456789abcdef";return(function(a){var c=[],d=a.length*4,e;for(var i=0;i<d;i++){e=a[i>>2]>>((3-(i%4))*8);c.push(B.charAt((e>>4)&0xF)+B.charAt(e&0xF))}return c.join('')}((function(a,b){var c,d,e,f,g,h=a.length,v=0x67452301,w=0xefcdab89,x=0x98badcfe,y=0x10325476,z=0xc3d2e1f0,M=[];U(M,0x5a827999,20);U(M,0x6ed9eba1,20);U(M,0x8f1bbcdc,20);U(M,0xca62c1d6,20);a[b>>5]|=0x80<<(24-(b%32));a[(((b+65)>>9)<<4)+15]=b;for(var i=0;i<h;i+=16){c=v;d=w;e=x;f=y;g=z;for(var j=0,O=[];j<80;j++){O[j]=j<16?a[j+i]:L(O[j-3]^O[j-8]^O[j-14]^O[j-16],1);var k=(function(a,b,c,d,e){var f=(e&0xFFFF)+(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF),g=(e>>>16)+(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(f>>>16);return((g&0xFFFF)<<16)|(f&0xFFFF)})(j<20?(function(t,a,b){return(t&a)^(~t&b)}(d,e,f)):j<40?P(d,e,f):j<60?(function(t,a,b){return(t&a)^(t&b)^(a&b)}(d,e,f)):P(d,e,f),g,M[j],O[j],L(c,5));g=f;f=e;e=L(d,30);d=c;c=k}v=A(v,c);w=A(w,d);x=A(x,e);y=A(y,f);z=A(z,g)}return[v,w,x,y,z]}((function(t){var a=[],b=255,c=t.length*8;for(var i=0;i<c;i+=8){a[i>>5]|=(t.charCodeAt(i/8)&b)<<(24-(i%32))}return a}(s)).slice(),s.length*8))))};
(function(){var charSize=8,b64pad="",hexCase=0,str2binb=function(a){var b=[],mask=(1<<charSize)-1,length=a.length*charSize,i;for(i=0;i<length;i+=charSize){b[i>>5]|=(a.charCodeAt(i/charSize)&mask)<<(32-charSize-(i%32))}return b},hex2binb=function(a){var b=[],length=a.length,i,num;for(i=0;i<length;i+=2){num=parseInt(a.substr(i,2),16);if(!isNaN(num)){b[i>>3]|=num<<(24-(4*(i%8)))}else{return"INVALID HEX STRING"}}return b},binb2hex=function(a){var b=(hexCase)?"0123456789ABCDEF":"0123456789abcdef",str="",length=a.length*4,i,srcByte;for(i=0;i<length;i+=1){srcByte=a[i>>2]>>((3-(i%4))*8);str+=b.charAt((srcByte>>4)&0xF)+b.charAt(srcByte&0xF)}return str},binb2b64=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+"0123456789+/",str="",length=a.length*4,i,j,triplet;for(i=0;i<length;i+=3){triplet=(((a[i>>2]>>8*(3-i%4))&0xFF)<<16)|(((a[i+1>>2]>>8*(3-(i+1)%4))&0xFF)<<8)|((a[i+2>>2]>>8*(3-(i+2)%4))&0xFF);for(j=0;j<4;j+=1){if(i*8+j*6<=a.length*32){str+=b.charAt((triplet>>6*(3-j))&0x3F)}else{str+=b64pad}}}return str},rotr=function(x,n){return(x>>>n)|(x<<(32-n))},shr=function(x,n){return x>>>n},ch=function(x,y,z){return(x&y)^(~x&z)},maj=function(x,y,z){return(x&y)^(x&z)^(y&z)},sigma0=function(x){return rotr(x,2)^rotr(x,13)^rotr(x,22)},sigma1=function(x){return rotr(x,6)^rotr(x,11)^rotr(x,25)},gamma0=function(x){return rotr(x,7)^rotr(x,18)^shr(x,3)},gamma1=function(x){return rotr(x,17)^rotr(x,19)^shr(x,10)},safeAdd_2=function(x,y){var a=(x&0xFFFF)+(y&0xFFFF),msw=(x>>>16)+(y>>>16)+(a>>>16);return((msw&0xFFFF)<<16)|(a&0xFFFF)},safeAdd_4=function(a,b,c,d){var e=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF),msw=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16);return((msw&0xFFFF)<<16)|(e&0xFFFF)},safeAdd_5=function(a,b,c,d,e){var f=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF),msw=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16)+(f>>>16);return((msw&0xFFFF)<<16)|(f&0xFFFF)},coreSHA2=function(j,k,l){var a,b,c,d,e,f,g,h,T1,T2,H,lengthPosition,i,t,K,W=[],appendedMessageLength;if(l==="SHA-224"||l==="SHA-256"){lengthPosition=(((k+65)>>9)<<4)+15;K=[0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B,0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01,0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7,0xC19BF174,0xE49B69C1,0xEFBE4786,0x0FC19DC6,0x240CA1CC,0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152,0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147,0x06CA6351,0x14292967,0x27B70A85,0x2E1B2138,0x4D2C6DFC,0x53380D13,0x650A7354,0x766A0ABB,0x81C2C92E,0x92722C85,0xA2BFE8A1,0xA81A664B,0xC24B8B70,0xC76C51A3,0xD192E819,0xD6990624,0xF40E3585,0x106AA070,0x19A4C116,0x1E376C08,0x2748774C,0x34B0BCB5,0x391C0CB3,0x4ED8AA4A,0x5B9CCA4F,0x682E6FF3,0x748F82EE,0x78A5636F,0x84C87814,0x8CC70208,0x90BEFFFA,0xA4506CEB,0xBEF9A3F7,0xC67178F2];if(l==="SHA-224"){H=[0xc1059ed8,0x367cd507,0x3070dd17,0xf70e5939,0xffc00b31,0x68581511,0x64f98fa7,0xbefa4fa4]}else{H=[0x6A09E667,0xBB67AE85,0x3C6EF372,0xA54FF53A,0x510E527F,0x9B05688C,0x1F83D9AB,0x5BE0CD19]}}j[k>>5]|=0x80<<(24-k%32);j[lengthPosition]=k;appendedMessageLength=j.length;for(i=0;i<appendedMessageLength;i+=16){a=H[0];b=H[1];c=H[2];d=H[3];e=H[4];f=H[5];g=H[6];h=H[7];for(t=0;t<64;t+=1){if(t<16){W[t]=j[t+i]}else{W[t]=safeAdd_4(gamma1(W[t-2]),W[t-7],gamma0(W[t-15]),W[t-16])}T1=safeAdd_5(h,sigma1(e),ch(e,f,g),K[t],W[t]);T2=safeAdd_2(sigma0(a),maj(a,b,c));h=g;g=f;f=e;e=safeAdd_2(d,T1);d=c;c=b;b=a;a=safeAdd_2(T1,T2)}H[0]=safeAdd_2(a,H[0]);H[1]=safeAdd_2(b,H[1]);H[2]=safeAdd_2(c,H[2]);H[3]=safeAdd_2(d,H[3]);H[4]=safeAdd_2(e,H[4]);H[5]=safeAdd_2(f,H[5]);H[6]=safeAdd_2(g,H[6]);H[7]=safeAdd_2(h,H[7])}switch(l){case"SHA-224":return[H[0],H[1],H[2],H[3],H[4],H[5],H[6]];case"SHA-256":return H;default:return[]}},jsSHA=function(a,b){this.sha224=null;this.sha256=null;this.strBinLen=null;this.strToHash=null;if("HEX"===b){if(0!==(a.length%2)){return"TEXT MUST BE IN BYTE INCREMENTS"}this.strBinLen=a.length*4;this.strToHash=hex2binb(a)}else if(("ASCII"===b)||('undefined'===typeof(b))){this.strBinLen=a.length*charSize;this.strToHash=str2binb(a)}else{return"UNKNOWN TEXT INPUT TYPE"}};jsSHA.prototype={getHash:function(a,b){var c=null,message=this.strToHash.slice();switch(b){case"HEX":c=binb2hex;break;case"B64":c=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}switch(a){case"SHA-224":if(null===this.sha224){this.sha224=coreSHA2(message,this.strBinLen,a)}return c(this.sha224);case"SHA-256":if(null===this.sha256){this.sha256=coreSHA2(message,this.strBinLen,a)}return c(this.sha256);default:return"HASH NOT RECOGNIZED"}},getHMAC:function(a,b,c,d){var e,keyToUse,i,retVal,keyBinLen,hashBitSize,keyWithIPad=[],keyWithOPad=[];switch(d){case"HEX":e=binb2hex;break;case"B64":e=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}switch(c){case"SHA-224":hashBitSize=224;break;case"SHA-256":hashBitSize=256;break;default:return"HASH NOT RECOGNIZED"}if("HEX"===b){if(0!==(a.length%2)){return"KEY MUST BE IN BYTE INCREMENTS"}keyToUse=hex2binb(a);keyBinLen=a.length*4}else if("ASCII"===b){keyToUse=str2binb(a);keyBinLen=a.length*charSize}else{return"UNKNOWN KEY INPUT TYPE"}if(64<(keyBinLen/8)){keyToUse=coreSHA2(keyToUse,keyBinLen,c);keyToUse[15]&=0xFFFFFF00}else if(64>(keyBinLen/8)){keyToUse[15]&=0xFFFFFF00}for(i=0;i<=15;i+=1){keyWithIPad[i]=keyToUse[i]^0x36363636;keyWithOPad[i]=keyToUse[i]^0x5C5C5C5C}retVal=coreSHA2(keyWithIPad.concat(this.strToHash),512+this.strBinLen,c);retVal=coreSHA2(keyWithOPad.concat(retVal),512+hashBitSize,c);return(e(retVal))}};window.jsSHA=jsSHA}());


/*! JSEncrypt v2.3.0 | https://npmcdn.com/jsencrypt@2.3.0/LICENSE.txt */
var JSEncryptExports={};!function(t){function e(t,e,i){null!=t&&("number"==typeof t?this.fromNumber(t,e,i):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function i(){return new e(null)}function r(t,e,i,r,s,n){for(;--n>=0;){var o=e*this[t++]+i[r]+s;s=Math.floor(o/67108864),i[r++]=67108863&o}return s}function s(t,e,i,r,s,n){for(var o=32767&e,h=e>>15;--n>=0;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;a=o*a+((32767&c)<<15)+i[r]+(1073741823&s),s=(a>>>30)+(c>>>15)+h*u+(s>>>30),i[r++]=1073741823&a}return s}function n(t,e,i,r,s,n){for(var o=16383&e,h=e>>14;--n>=0;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;a=o*a+((16383&c)<<14)+i[r]+s,s=(a>>28)+(c>>14)+h*u,i[r++]=268435455&a}return s}function o(t){return Be.charAt(t)}function h(t,e){var i=Ke[t.charCodeAt(e)];return null==i?-1:i}function a(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function u(t){this.t=1,this.s=0>t?-1:0,t>0?this[0]=t:-1>t?this[0]=t+this.DV:this.t=0}function c(t){var e=i();return e.fromInt(t),e}function f(t,i){var r;if(16==i)r=4;else if(8==i)r=3;else if(256==i)r=8;else if(2==i)r=1;else if(32==i)r=5;else{if(4!=i)return void this.fromRadix(t,i);r=2}this.t=0,this.s=0;for(var s=t.length,n=!1,o=0;--s>=0;){var a=8==r?255&t[s]:h(t,s);0>a?"-"==t.charAt(s)&&(n=!0):(n=!1,0==o?this[this.t++]=a:o+r>this.DB?(this[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this[this.t++]=a>>this.DB-o):this[this.t-1]|=a<<o,o+=r,o>=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),n&&e.ZERO.subTo(this,this)}function p(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function l(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<<e)-1,s=!1,n="",h=this.t,a=this.DB-h*this.DB%e;if(h-- >0)for(a<this.DB&&(i=this[h]>>a)>0&&(s=!0,n=o(i));h>=0;)e>a?(i=(this[h]&(1<<a)-1)<<e-a,i|=this[--h]>>(a+=this.DB-e)):(i=this[h]>>(a-=e)&r,0>=a&&(a+=this.DB,--h)),i>0&&(s=!0),s&&(n+=o(i));return s?n:"0"}function d(){var t=i();return e.ZERO.subTo(this,t),t}function g(){return this.s<0?this.negate():this}function m(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(e=i-t.t,0!=e)return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0}function y(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function b(){return this.t<=0?0:this.DB*(this.t-1)+y(this[this.t-1]^this.s&this.DM)}function T(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s}function S(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s}function R(t,e){var i,r=t%this.DB,s=this.DB-r,n=(1<<s)-1,o=Math.floor(t/this.DB),h=this.s<<r&this.DM;for(i=this.t-1;i>=0;--i)e[i+o+1]=this[i]>>s|h,h=(this[i]&n)<<r;for(i=o-1;i>=0;--i)e[i]=0;e[o]=h,e.t=this.t+o+1,e.s=this.s,e.clamp()}function E(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)return void(e.t=0);var r=t%this.DB,s=this.DB-r,n=(1<<r)-1;e[0]=this[i]>>r;for(var o=i+1;o<this.t;++o)e[o-i-1]|=(this[o]&n)<<s,e[o-i]=this[o]>>r;r>0&&(e[this.t-i-1]|=(this.s&n)<<s),e.t=this.t-i,e.clamp()}function D(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);s>i;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r-=t[i],e[i++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=0>r?-1:0,-1>r?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()}function w(t,i){var r=this.abs(),s=t.abs(),n=r.t;for(i.t=n+s.t;--n>=0;)i[n]=0;for(n=0;n<s.t;++n)i[n+r.t]=r.am(0,s[n],i,n,0,r.t);i.s=0,i.clamp(),this.s!=t.s&&e.ZERO.subTo(i,i)}function x(t){for(var e=this.abs(),i=t.t=2*e.t;--i>=0;)t[i]=0;for(i=0;i<e.t-1;++i){var r=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,r,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()}function B(t,r,s){var n=t.abs();if(!(n.t<=0)){var o=this.abs();if(o.t<n.t)return null!=r&&r.fromInt(0),void(null!=s&&this.copyTo(s));null==s&&(s=i());var h=i(),a=this.s,u=t.s,c=this.DB-y(n[n.t-1]);c>0?(n.lShiftTo(c,h),o.lShiftTo(c,s)):(n.copyTo(h),o.copyTo(s));var f=h.t,p=h[f-1];if(0!=p){var l=p*(1<<this.F1)+(f>1?h[f-2]>>this.F2:0),d=this.FV/l,g=(1<<this.F1)/l,m=1<<this.F2,v=s.t,b=v-f,T=null==r?i():r;for(h.dlShiftTo(b,T),s.compareTo(T)>=0&&(s[s.t++]=1,s.subTo(T,s)),e.ONE.dlShiftTo(f,T),T.subTo(h,h);h.t<f;)h[h.t++]=0;for(;--b>=0;){var S=s[--v]==p?this.DM:Math.floor(s[v]*d+(s[v-1]+m)*g);if((s[v]+=h.am(0,S,s,b,0,f))<S)for(h.dlShiftTo(b,T),s.subTo(T,s);s[v]<--S;)s.subTo(T,s)}null!=r&&(s.drShiftTo(f,r),a!=u&&e.ZERO.subTo(r,r)),s.t=f,s.clamp(),c>0&&s.rShiftTo(c,s),0>a&&e.ZERO.subTo(s,s)}}}function K(t){var r=i();return this.abs().divRemTo(t,null,r),this.s<0&&r.compareTo(e.ZERO)>0&&t.subTo(r,r),r}function A(t){this.m=t}function U(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function O(t){return t}function V(t){t.divRemTo(this.m,null,t)}function J(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function N(t,e){t.squareTo(e),this.reduce(e)}function I(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return e=e*(2-(15&t)*e)&15,e=e*(2-(255&t)*e)&255,e=e*(2-((65535&t)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function P(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function M(t){var r=i();return t.abs().dlShiftTo(this.m.t,r),r.divRemTo(this.m,null,r),t.s<0&&r.compareTo(e.ZERO)>0&&this.m.subTo(r,r),r}function L(t){var e=i();return t.copyTo(e),this.reduce(e),e}function q(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=32767&t[e],r=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(i=e+this.m.t,t[i]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function C(t,e){t.squareTo(e),this.reduce(e)}function H(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function j(){return 0==(this.t>0?1&this[0]:this.s)}function k(t,r){if(t>4294967295||1>t)return e.ONE;var s=i(),n=i(),o=r.convert(this),h=y(t)-1;for(o.copyTo(s);--h>=0;)if(r.sqrTo(s,n),(t&1<<h)>0)r.mulTo(n,o,s);else{var a=s;s=n,n=a}return r.revert(s)}function F(t,e){var i;return i=256>t||e.isEven()?new A(e):new P(e),this.exp(t,i)}
// Copyright (c) 2005-2009 Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.
function _(){var t=i();return this.copyTo(t),t}function z(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function Z(){return 0==this.t?this.s:this[0]<<24>>24}function G(){return 0==this.t?this.s:this[0]<<16>>16}function $(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function Y(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function W(t){if(null==t&&(t=10),0==this.signum()||2>t||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),s=c(r),n=i(),o=i(),h="";for(this.divRemTo(s,n,o);n.signum()>0;)h=(r+o.intValue()).toString(t).substr(1)+h,n.divRemTo(s,n,o);return o.intValue().toString(t)+h}function Q(t,i){this.fromInt(0),null==i&&(i=10);for(var r=this.chunkSize(i),s=Math.pow(i,r),n=!1,o=0,a=0,u=0;u<t.length;++u){var c=h(t,u);0>c?"-"==t.charAt(u)&&0==this.signum()&&(n=!0):(a=i*a+c,++o>=r&&(this.dMultiply(s),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(i,o)),this.dAddOffset(a,0)),n&&e.ZERO.subTo(this,this)}function X(t,i,r){if("number"==typeof i)if(2>t)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),ht,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(i);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(e.ONE.shiftLeft(t-1),this);else{var s=new Array,n=7&t;s.length=(t>>3)+1,i.nextBytes(s),n>0?s[0]&=(1<<n)-1:s[0]=0,this.fromString(s,256)}}function tt(){var t=this.t,e=new Array;e[0]=this.s;var i,r=this.DB-t*this.DB%8,s=0;if(t-- >0)for(r<this.DB&&(i=this[t]>>r)!=(this.s&this.DM)>>r&&(e[s++]=i|this.s<<this.DB-r);t>=0;)8>r?(i=(this[t]&(1<<r)-1)<<8-r,i|=this[--t]>>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,0>=r&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==s&&(128&this.s)!=(128&i)&&++s,(s>0||i!=this.s)&&(e[s++]=i);return e}function et(t){return 0==this.compareTo(t)}function it(t){return this.compareTo(t)<0?this:t}function rt(t){return this.compareTo(t)>0?this:t}function st(t,e,i){var r,s,n=Math.min(t.t,this.t);for(r=0;n>r;++r)i[r]=e(this[r],t[r]);if(t.t<this.t){for(s=t.s&this.DM,r=n;r<this.t;++r)i[r]=e(this[r],s);i.t=this.t}else{for(s=this.s&this.DM,r=n;r<t.t;++r)i[r]=e(s,t[r]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()}function nt(t,e){return t&e}function ot(t){var e=i();return this.bitwiseTo(t,nt,e),e}function ht(t,e){return t|e}function at(t){var e=i();return this.bitwiseTo(t,ht,e),e}function ut(t,e){return t^e}function ct(t){var e=i();return this.bitwiseTo(t,ut,e),e}function ft(t,e){return t&~e}function pt(t){var e=i();return this.bitwiseTo(t,ft,e),e}function lt(){for(var t=i(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}function dt(t){var e=i();return 0>t?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function gt(t){var e=i();return 0>t?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function mt(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function yt(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+mt(this[t]);return this.s<0?this.t*this.DB:-1}function vt(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function bt(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=vt(this[i]^e);return t}function Tt(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)}function St(t,i){var r=e.ONE.shiftLeft(t);return this.bitwiseTo(r,i,r),r}function Rt(t){return this.changeBit(t,ht)}function Et(t){return this.changeBit(t,ft)}function Dt(t){return this.changeBit(t,ut)}function wt(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);s>i;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r+=t[i],e[i++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=0>r?-1:0,r>0?e[i++]=r:-1>r&&(e[i++]=this.DV+r),e.t=i,e.clamp()}function xt(t){var e=i();return this.addTo(t,e),e}function Bt(t){var e=i();return this.subTo(t,e),e}function Kt(t){var e=i();return this.multiplyTo(t,e),e}function At(){var t=i();return this.squareTo(t),t}function Ut(t){var e=i();return this.divRemTo(t,e,null),e}function Ot(t){var e=i();return this.divRemTo(t,null,e),e}function Vt(t){var e=i(),r=i();return this.divRemTo(t,e,r),new Array(e,r)}function Jt(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function Nt(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function It(){}function Pt(t){return t}function Mt(t,e,i){t.multiplyTo(e,i)}function Lt(t,e){t.squareTo(e)}function qt(t){return this.exp(t,new It)}function Ct(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;var s;for(s=i.t-this.t;s>r;++r)i[r+this.t]=this.am(0,t[r],i,r,0,this.t);for(s=Math.min(t.t,e);s>r;++r)this.am(0,t[r],i,r,0,e-r);i.clamp()}function Ht(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;--r>=0;)i[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)i[this.t+r-e]=this.am(e-r,t[r],i,0,0,this.t+r-e);i.clamp(),i.drShiftTo(1,i)}function jt(t){this.r2=i(),this.q3=i(),e.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function kt(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=i();return t.copyTo(e),this.reduce(e),e}function Ft(t){return t}function _t(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function zt(t,e){t.squareTo(e),this.reduce(e)}function Zt(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function Gt(t,e){var r,s,n=t.bitLength(),o=c(1);if(0>=n)return o;r=18>n?1:48>n?3:144>n?4:768>n?5:6,s=8>n?new A(e):e.isEven()?new jt(e):new P(e);var h=new Array,a=3,u=r-1,f=(1<<r)-1;if(h[1]=s.convert(this),r>1){var p=i();for(s.sqrTo(h[1],p);f>=a;)h[a]=i(),s.mulTo(p,h[a-2],h[a]),a+=2}var l,d,g=t.t-1,m=!0,v=i();for(n=y(t[g])-1;g>=0;){for(n>=u?l=t[g]>>n-u&f:(l=(t[g]&(1<<n+1)-1)<<u-n,g>0&&(l|=t[g-1]>>this.DB+n-u)),a=r;0==(1&l);)l>>=1,--a;if((n-=a)<0&&(n+=this.DB,--g),m)h[l].copyTo(o),m=!1;else{for(;a>1;)s.sqrTo(o,v),s.sqrTo(v,o),a-=2;a>0?s.sqrTo(o,v):(d=o,o=v,v=d),s.mulTo(v,h[l],o)}for(;g>=0&&0==(t[g]&1<<n);)s.sqrTo(o,v),d=o,o=v,v=d,--n<0&&(n=this.DB-1,--g)}return s.revert(o)}function $t(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var r=e;e=i,i=r}var s=e.getLowestSetBit(),n=i.getLowestSetBit();if(0>n)return e;for(n>s&&(n=s),n>0&&(e.rShiftTo(n,e),i.rShiftTo(n,i));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return n>0&&i.lShiftTo(n,i),i}function Yt(t){if(0>=t)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i}function Wt(t){var i=t.isEven();if(this.isEven()&&i||0==t.signum())return e.ZERO;for(var r=t.clone(),s=this.clone(),n=c(1),o=c(0),h=c(0),a=c(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),i?(n.isEven()&&o.isEven()||(n.addTo(this,n),o.subTo(t,o)),n.rShiftTo(1,n)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;s.isEven();)s.rShiftTo(1,s),i?(h.isEven()&&a.isEven()||(h.addTo(this,h),a.subTo(t,a)),h.rShiftTo(1,h)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(s)>=0?(r.subTo(s,r),i&&n.subTo(h,n),o.subTo(a,o)):(s.subTo(r,s),i&&h.subTo(n,h),a.subTo(o,a))}return 0!=s.compareTo(e.ONE)?e.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}function Qt(t){var e,i=this.abs();if(1==i.t&&i[0]<=Ae[Ae.length-1]){for(e=0;e<Ae.length;++e)if(i[0]==Ae[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<Ae.length;){for(var r=Ae[e],s=e+1;s<Ae.length&&Ue>r;)r*=Ae[s++];for(r=i.modInt(r);s>e;)if(r%Ae[e++]==0)return!1}return i.millerRabin(t)}function Xt(t){var r=this.subtract(e.ONE),s=r.getLowestSetBit();if(0>=s)return!1;var n=r.shiftRight(s);t=t+1>>1,t>Ae.length&&(t=Ae.length);for(var o=i(),h=0;t>h;++h){o.fromInt(Ae[Math.floor(Math.random()*Ae.length)]);var a=o.modPow(n,this);if(0!=a.compareTo(e.ONE)&&0!=a.compareTo(r)){for(var u=1;u++<s&&0!=a.compareTo(r);)if(a=a.modPowInt(2,this),0==a.compareTo(e.ONE))return!1;if(0!=a.compareTo(r))return!1}}return!0}function te(){this.i=0,this.j=0,this.S=new Array}function ee(t){var e,i,r;for(e=0;256>e;++e)this.S[e]=e;for(i=0,e=0;256>e;++e)i=i+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[i],this.S[i]=r;this.i=0,this.j=0}function ie(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}function re(){return new te}function se(){if(null==Oe){for(Oe=re();Ne>Je;){var t=Math.floor(65536*Math.random());Ve[Je++]=255&t}for(Oe.init(Ve),Je=0;Je<Ve.length;++Je)Ve[Je]=0;Je=0}return Oe.next()}function ne(t){var e;for(e=0;e<t.length;++e)t[e]=se()}function oe(){}function he(t,i){return new e(t,i)}function ae(t,i){if(i<t.length+11)return console.error("Message too long for RSA"),null;for(var r=new Array,s=t.length-1;s>=0&&i>0;){var n=t.charCodeAt(s--);128>n?r[--i]=n:n>127&&2048>n?(r[--i]=63&n|128,r[--i]=n>>6|192):(r[--i]=63&n|128,r[--i]=n>>6&63|128,r[--i]=n>>12|224)}r[--i]=0;for(var o=new oe,h=new Array;i>2;){for(h[0]=0;0==h[0];)o.nextBytes(h);r[--i]=h[0]}return r[--i]=2,r[--i]=0,new e(r)}function ue(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function ce(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}function fe(t){return t.modPowInt(this.e,this.n)}function pe(t){var e=ae(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var r=i.toString(16);return 0==(1&r.length)?r:"0"+r}function le(t,e){for(var i=t.toByteArray(),r=0;r<i.length&&0==i[r];)++r;if(i.length-r!=e-1||2!=i[r])return null;for(++r;0!=i[r];)if(++r>=i.length)return null;for(var s="";++r<i.length;){var n=255&i[r];128>n?s+=String.fromCharCode(n):n>191&&224>n?(s+=String.fromCharCode((31&n)<<6|63&i[r+1]),++r):(s+=String.fromCharCode((15&n)<<12|(63&i[r+1])<<6|63&i[r+2]),r+=2)}return s}function de(t,e,i){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16),this.d=he(i,16)):console.error("Invalid RSA private key")}function ge(t,e,i,r,s,n,o,h){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16),this.d=he(i,16),this.p=he(r,16),this.q=he(s,16),this.dmp1=he(n,16),this.dmq1=he(o,16),this.coeff=he(h,16)):console.error("Invalid RSA private key")}function me(t,i){var r=new oe,s=t>>1;this.e=parseInt(i,16);for(var n=new e(i,16);;){for(;this.p=new e(t-s,1,r),0!=this.p.subtract(e.ONE).gcd(n).compareTo(e.ONE)||!this.p.isProbablePrime(10););for(;this.q=new e(s,1,r),0!=this.q.subtract(e.ONE).gcd(n).compareTo(e.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var h=this.p.subtract(e.ONE),a=this.q.subtract(e.ONE),u=h.multiply(a);if(0==u.gcd(n).compareTo(e.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(u),this.dmp1=this.d.mod(h),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}function ye(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)}function ve(t){var e=he(t,16),i=this.doPrivate(e);return null==i?null:le(i,this.n.bitLength()+7>>3)}function be(t){var e,i,r="";for(e=0;e+3<=t.length;e+=3)i=parseInt(t.substring(e,e+3),16),r+=Le.charAt(i>>6)+Le.charAt(63&i);for(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),r+=Le.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),r+=Le.charAt(i>>2)+Le.charAt((3&i)<<4));(3&r.length)>0;)r+=qe;return r}function Te(t){var e,i,r="",s=0;for(e=0;e<t.length&&t.charAt(e)!=qe;++e)v=Le.indexOf(t.charAt(e)),v<0||(0==s?(r+=o(v>>2),i=3&v,s=1):1==s?(r+=o(i<<2|v>>4),i=15&v,s=2):2==s?(r+=o(i),r+=o(v>>2),i=3&v,s=3):(r+=o(i<<2|v>>4),r+=o(15&v),s=0));return 1==s&&(r+=o(i<<2)),r}
// Copyright (c) 2005 Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.
var Se,Re=0xdeadbeefcafe,Ee=15715070==(16777215&Re);Ee&&"Microsoft Internet Explorer"==navigator.appName?(e.prototype.am=s,Se=30):Ee&&"Netscape"!=navigator.appName?(e.prototype.am=r,Se=26):(e.prototype.am=n,Se=28),e.prototype.DB=Se,e.prototype.DM=(1<<Se)-1,e.prototype.DV=1<<Se;var De=52;e.prototype.FV=Math.pow(2,De),e.prototype.F1=De-Se,e.prototype.F2=2*Se-De;var we,xe,Be="0123456789abcdefghijklmnopqrstuvwxyz",Ke=new Array;for(we="0".charCodeAt(0),xe=0;9>=xe;++xe)Ke[we++]=xe;for(we="a".charCodeAt(0),xe=10;36>xe;++xe)Ke[we++]=xe;for(we="A".charCodeAt(0),xe=10;36>xe;++xe)Ke[we++]=xe;A.prototype.convert=U,A.prototype.revert=O,A.prototype.reduce=V,A.prototype.mulTo=J,A.prototype.sqrTo=N,P.prototype.convert=M,P.prototype.revert=L,P.prototype.reduce=q,P.prototype.mulTo=H,P.prototype.sqrTo=C,e.prototype.copyTo=a,e.prototype.fromInt=u,e.prototype.fromString=f,e.prototype.clamp=p,e.prototype.dlShiftTo=T,e.prototype.drShiftTo=S,e.prototype.lShiftTo=R,e.prototype.rShiftTo=E,e.prototype.subTo=D,e.prototype.multiplyTo=w,e.prototype.squareTo=x,e.prototype.divRemTo=B,e.prototype.invDigit=I,e.prototype.isEven=j,e.prototype.exp=k,e.prototype.toString=l,e.prototype.negate=d,e.prototype.abs=g,e.prototype.compareTo=m,e.prototype.bitLength=b,e.prototype.mod=K,e.prototype.modPowInt=F,e.ZERO=c(0),e.ONE=c(1),It.prototype.convert=Pt,It.prototype.revert=Pt,It.prototype.mulTo=Mt,It.prototype.sqrTo=Lt,jt.prototype.convert=kt,jt.prototype.revert=Ft,jt.prototype.reduce=_t,jt.prototype.mulTo=Zt,jt.prototype.sqrTo=zt;var Ae=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Ue=(1<<26)/Ae[Ae.length-1];e.prototype.chunkSize=$,e.prototype.toRadix=W,e.prototype.fromRadix=Q,e.prototype.fromNumber=X,e.prototype.bitwiseTo=st,e.prototype.changeBit=St,e.prototype.addTo=wt,e.prototype.dMultiply=Jt,e.prototype.dAddOffset=Nt,e.prototype.multiplyLowerTo=Ct,e.prototype.multiplyUpperTo=Ht,e.prototype.modInt=Yt,e.prototype.millerRabin=Xt,e.prototype.clone=_,e.prototype.intValue=z,e.prototype.byteValue=Z,e.prototype.shortValue=G,e.prototype.signum=Y,e.prototype.toByteArray=tt,e.prototype.equals=et,e.prototype.min=it,e.prototype.max=rt,e.prototype.and=ot,e.prototype.or=at,e.prototype.xor=ct,e.prototype.andNot=pt,e.prototype.not=lt,e.prototype.shiftLeft=dt,e.prototype.shiftRight=gt,e.prototype.getLowestSetBit=yt,e.prototype.bitCount=bt,e.prototype.testBit=Tt,e.prototype.setBit=Rt,e.prototype.clearBit=Et,e.prototype.flipBit=Dt,e.prototype.add=xt,e.prototype.subtract=Bt,e.prototype.multiply=Kt,e.prototype.divide=Ut,e.prototype.remainder=Ot,e.prototype.divideAndRemainder=Vt,e.prototype.modPow=Gt,e.prototype.modInverse=Wt,e.prototype.pow=qt,e.prototype.gcd=$t,e.prototype.isProbablePrime=Qt,e.prototype.square=At,te.prototype.init=ee,te.prototype.next=ie;var Oe,Ve,Je,Ne=256;if(null==Ve){Ve=new Array,Je=0;var Ie;if(window.crypto&&window.crypto.getRandomValues){var Pe=new Uint32Array(256);for(window.crypto.getRandomValues(Pe),Ie=0;Ie<Pe.length;++Ie)Ve[Je++]=255&Pe[Ie]}var Me=function(t){if(this.count=this.count||0,this.count>=256||Je>=Ne)return void(window.removeEventListener?window.removeEventListener("mousemove",Me,!1):window.detachEvent&&window.detachEvent("onmousemove",Me));try{var e=t.x+t.y;Ve[Je++]=255&e,this.count+=1}catch(i){}};window.addEventListener?window.addEventListener("mousemove",Me,!1):window.attachEvent&&window.attachEvent("onmousemove",Me)}oe.prototype.nextBytes=ne,ue.prototype.doPublic=fe,ue.prototype.setPublic=ce,ue.prototype.encrypt=pe,ue.prototype.doPrivate=ye,ue.prototype.setPrivate=de,ue.prototype.setPrivateEx=ge,ue.prototype.generate=me,ue.prototype.decrypt=ve,
// Copyright (c) 2011 Kevin M Burns Jr.
// All Rights Reserved.
// See "LICENSE" for details.
//
// Extension to jsbn which adds facilities for asynchronous RSA key generation
// Primarily created to avoid execution timeout on mobile devices
//
// http://www-cs-students.stanford.edu/~tjw/jsbn/
//
// ---
function(){var t=function(t,r,s){var n=new oe,o=t>>1;this.e=parseInt(r,16);var h=new e(r,16),a=this,u=function(){var r=function(){if(a.p.compareTo(a.q)<=0){var t=a.p;a.p=a.q,a.q=t}var i=a.p.subtract(e.ONE),r=a.q.subtract(e.ONE),n=i.multiply(r);0==n.gcd(h).compareTo(e.ONE)?(a.n=a.p.multiply(a.q),a.d=h.modInverse(n),a.dmp1=a.d.mod(i),a.dmq1=a.d.mod(r),a.coeff=a.q.modInverse(a.p),setTimeout(function(){s()},0)):setTimeout(u,0)},c=function(){a.q=i(),a.q.fromNumberAsync(o,1,n,function(){a.q.subtract(e.ONE).gcda(h,function(t){0==t.compareTo(e.ONE)&&a.q.isProbablePrime(10)?setTimeout(r,0):setTimeout(c,0)})})},f=function(){a.p=i(),a.p.fromNumberAsync(t-o,1,n,function(){a.p.subtract(e.ONE).gcda(h,function(t){0==t.compareTo(e.ONE)&&a.p.isProbablePrime(10)?setTimeout(c,0):setTimeout(f,0)})})};setTimeout(f,0)};setTimeout(u,0)};ue.prototype.generateAsync=t;var r=function(t,e){var i=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(i.compareTo(r)<0){var s=i;i=r,r=s}var n=i.getLowestSetBit(),o=r.getLowestSetBit();if(0>o)return void e(i);o>n&&(o=n),o>0&&(i.rShiftTo(o,i),r.rShiftTo(o,r));var h=function(){(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),i.compareTo(r)>=0?(i.subTo(r,i),i.rShiftTo(1,i)):(r.subTo(i,r),r.rShiftTo(1,r)),i.signum()>0?setTimeout(h,0):(o>0&&r.lShiftTo(o,r),setTimeout(function(){e(r)},0))};setTimeout(h,10)};e.prototype.gcda=r;var s=function(t,i,r,s){if("number"==typeof i)if(2>t)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),ht,this),this.isEven()&&this.dAddOffset(1,0);var n=this,o=function(){n.dAddOffset(2,0),n.bitLength()>t&&n.subTo(e.ONE.shiftLeft(t-1),n),n.isProbablePrime(i)?setTimeout(function(){s()},0):setTimeout(o,0)};setTimeout(o,0)}else{var h=new Array,a=7&t;h.length=(t>>3)+1,i.nextBytes(h),a>0?h[0]&=(1<<a)-1:h[0]=0,this.fromString(h,256)}};e.prototype.fromNumberAsync=s}();var Le="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qe="=",Ce=Ce||{};Ce.env=Ce.env||{};var He=Ce,je=Object.prototype,ke="[object Function]",Fe=["toString","valueOf"];Ce.env.parseUA=function(t){var e,i=function(t){var e=0;return parseFloat(t.replace(/\./g,function(){return 1==e++?"":"."}))},r=navigator,s={ie:0,opera:0,gecko:0,webkit:0,chrome:0,mobile:null,air:0,ipad:0,iphone:0,ipod:0,ios:null,android:0,webos:0,caja:r&&r.cajaVersion,secure:!1,os:null},n=t||navigator&&navigator.userAgent,o=window&&window.location,h=o&&o.href;return s.secure=h&&0===h.toLowerCase().indexOf("https"),n&&(/windows|win32/i.test(n)?s.os="windows":/macintosh/i.test(n)?s.os="macintosh":/rhino/i.test(n)&&(s.os="rhino"),/KHTML/.test(n)&&(s.webkit=1),e=n.match(/AppleWebKit\/([^\s]*)/),e&&e[1]&&(s.webkit=i(e[1]),/ Mobile\//.test(n)?(s.mobile="Apple",e=n.match(/OS ([^\s]*)/),e&&e[1]&&(e=i(e[1].replace("_","."))),s.ios=e,s.ipad=s.ipod=s.iphone=0,e=n.match(/iPad|iPod|iPhone/),e&&e[0]&&(s[e[0].toLowerCase()]=s.ios)):(e=n.match(/NokiaN[^\/]*|Android \d\.\d|webOS\/\d\.\d/),e&&(s.mobile=e[0]),/webOS/.test(n)&&(s.mobile="WebOS",e=n.match(/webOS\/([^\s]*);/),e&&e[1]&&(s.webos=i(e[1]))),/ Android/.test(n)&&(s.mobile="Android",e=n.match(/Android ([^\s]*);/),e&&e[1]&&(s.android=i(e[1])))),e=n.match(/Chrome\/([^\s]*)/),e&&e[1]?s.chrome=i(e[1]):(e=n.match(/AdobeAIR\/([^\s]*)/),e&&(s.air=e[0]))),s.webkit||(e=n.match(/Opera[\s\/]([^\s]*)/),e&&e[1]?(s.opera=i(e[1]),e=n.match(/Version\/([^\s]*)/),e&&e[1]&&(s.opera=i(e[1])),e=n.match(/Opera Mini[^;]*/),e&&(s.mobile=e[0])):(e=n.match(/MSIE\s([^;]*)/),e&&e[1]?s.ie=i(e[1]):(e=n.match(/Gecko\/([^\s]*)/),e&&(s.gecko=1,e=n.match(/rv:([^\s\)]*)/),e&&e[1]&&(s.gecko=i(e[1]))))))),s},Ce.env.ua=Ce.env.parseUA(),Ce.isFunction=function(t){return"function"==typeof t||je.toString.apply(t)===ke},Ce._IEEnumFix=Ce.env.ua.ie?function(t,e){var i,r,s;for(i=0;i<Fe.length;i+=1)r=Fe[i],s=e[r],He.isFunction(s)&&s!=je[r]&&(t[r]=s)}:function(){},Ce.extend=function(t,e,i){if(!e||!t)throw new Error("extend failed, please check that all dependencies are included.");var r,s=function(){};if(s.prototype=e.prototype,t.prototype=new s,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==je.constructor&&(e.prototype.constructor=e),i){for(r in i)He.hasOwnProperty(i,r)&&(t.prototype[r]=i[r]);He._IEEnumFix(t.prototype,i)}},/*
* asn1.js - ASN.1 DER encoder classes
*
* Copyright (c) 2013 Kenji Urushima (kenji.urushima@gmail.com)
*
* This software is licensed under the terms of the MIT License.
* http://kjur.github.com/jsrsasign/license
*
* The above copyright and license notice shall be
* included in all copies or substantial portions of the Software.
*/
/**
* @fileOverview
* @name asn1-1.0.js
* @author Kenji Urushima kenji.urushima@gmail.com
* @version 1.0.2 (2013-May-30)
* @since 2.1
* @license <a href="http://kjur.github.io/jsrsasign/license/">MIT License</a>
*/
"undefined"!=typeof KJUR&&KJUR||(KJUR={}),"undefined"!=typeof KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var i=t.toString(16);if("-"!=i.substr(0,1))i.length%2==1?i="0"+i:i.match(/^[0-7]/)||(i="00"+i);else{var r=i.substr(1),s=r.length;s%2==1?s+=1:i.match(/^[0-7]/)||(s+=2);for(var n="",o=0;s>o;o++)n+="f";var h=new e(n,16),a=h.xor(t).add(e.ONE);i=a.toString(16).replace(/^-/,"")}return i},this.getPEMStringFromHex=function(t,e){var i=CryptoJS.enc.Hex.parse(t),r=CryptoJS.enc.Base64.stringify(i),s=r.replace(/(.{64})/g,"$1\r\n");return s=s.replace(/\r\n$/,""),"-----BEGIN "+e+"-----\r\n"+s+"\r\n-----END "+e+"-----\r\n"}},KJUR.asn1.ASN1Object=function(){var t="";this.getLengthHexFromValue=function(){if("undefined"==typeof this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+t.length+",v="+this.hV;var e=this.hV.length/2,i=e.toString(16);if(i.length%2==1&&(i="0"+i),128>e)return i;var r=i.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);var s=128+r;return s.toString(16)+i},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},KJUR.asn1.DERAbstractString=function(t){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex&&this.setStringHex(t.hex))},Ce.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractTime=function(t){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){utc=t.getTime()+6e4*t.getTimezoneOffset();var e=new Date(utc);return e},this.formatDate=function(t,e){var i=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var n=i(String(r.getMonth()+1),2),o=i(String(r.getDate()),2),h=i(String(r.getHours()),2),a=i(String(r.getMinutes()),2),u=i(String(r.getSeconds()),2);return s+n+o+h+a+u+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setByDateValue=function(t,e,i,r,s,n){var o=new Date(Date.UTC(t,e-1,i,r,s,n,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},Ce.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractStructured=function(t){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,"undefined"!=typeof t&&"undefined"!=typeof t.array&&(this.asn1Array=t.array)},Ce.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object),KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},Ce.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object),KJUR.asn1.DERInteger=function(t){KJUR.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var i=new e(String(t),10);this.setByBigInteger(i)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.bigint?this.setByBigInteger(t.bigint):"undefined"!=typeof t["int"]?this.setByInteger(t["int"]):"undefined"!=typeof t.hex&&this.setValueHex(t.hex))},Ce.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object),KJUR.asn1.DERBitString=function(t){KJUR.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(0>t||t>7)throw"unused bits shall be from 0 to 7: u = "+t;var i="0"+t;this.hTLV=null,this.isModified=!0,this.hV=i+e},this.setByBinaryString=function(t){t=t.replace(/0+$/,"");var e=8-t.length%8;8==e&&(e=0);for(var i=0;e>=i;i++)t+="0";for(var r="",i=0;i<t.length-1;i+=8){var s=t.substr(i,8),n=parseInt(s,2).toString(16);1==n.length&&(n="0"+n),r+=n}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",i=0;i<t.length;i++)e+=1==t[i]?"1":"0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),i=0;t>i;i++)e[i]=!1;return e},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.hex?this.setHexValueIncludingUnusedBits(t.hex):"undefined"!=typeof t.bin?this.setByBinaryString(t.bin):"undefined"!=typeof t.array&&this.setByBooleanArray(t.array))},Ce.extend(KJUR.asn1.DERBitString,KJUR.asn1.ASN1Object),KJUR.asn1.DEROctetString=function(t){KJUR.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Ce.extend(KJUR.asn1.DEROctetString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNull=function(){KJUR.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Ce.extend(KJUR.asn1.DERNull,KJUR.asn1.ASN1Object),KJUR.asn1.DERObjectIdentifier=function(t){var i=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",s=new e(t,10),n=s.toString(2),o=7-n.length%7;7==o&&(o=0);for(var h="",a=0;o>a;a++)h+="0";n=h+n;for(var a=0;a<n.length-1;a+=7){var u=n.substr(a,7);a!=n.length-7&&(u="1"+u),r+=i(parseInt(u,2))}return r};KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var e="",s=t.split("."),n=40*parseInt(s[0])+parseInt(s[1]);e+=i(n),s.splice(0,2);for(var o=0;o<s.length;o++)e+=r(s[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){if("undefined"==typeof KJUR.asn1.x509.OID.name2oidList[t])throw"DERObjectIdentifier oidName undefined: "+t;var e=KJUR.asn1.x509.OID.name2oidList[t];this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.oid?this.setValueOidString(t.oid):"undefined"!=typeof t.hex?this.setValueHex(t.hex):"undefined"!=typeof t.name&&this.setValueName(t.name))},Ce.extend(KJUR.asn1.DERObjectIdentifier,KJUR.asn1.ASN1Object),KJUR.asn1.DERUTF8String=function(t){KJUR.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Ce.extend(KJUR.asn1.DERUTF8String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNumericString=function(t){KJUR.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Ce.extend(KJUR.asn1.DERNumericString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERPrintableString=function(t){KJUR.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Ce.extend(KJUR.asn1.DERPrintableString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERTeletexString=function(t){KJUR.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Ce.extend(KJUR.asn1.DERTeletexString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERIA5String=function(t){KJUR.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Ce.extend(KJUR.asn1.DERIA5String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERUTCTime=function(t){KJUR.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex?this.setStringHex(t.hex):"undefined"!=typeof t.date&&this.setByDate(t.date))},Ce.extend(KJUR.asn1.DERUTCTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERGeneralizedTime=function(t){KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen"),this.hV=stohex(this.s)},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex?this.setStringHex(t.hex):"undefined"!=typeof t.date&&this.setByDate(t.date))},Ce.extend(KJUR.asn1.DERGeneralizedTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERSequence=function(t){KJUR.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t+=i.getEncodedHex()}return this.hV=t,this.hV}},Ce.extend(KJUR.asn1.DERSequence,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERSet=function(t){KJUR.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t.push(i.getEncodedHex())}return t.sort(),this.hV=t.join(""),this.hV}},Ce.extend(KJUR.asn1.DERSet,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERTaggedObject=function(t){KJUR.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,i){this.hT=e,this.isExplicit=t,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.tag&&(this.hT=t.tag),"undefined"!=typeof t.explicit&&(this.isExplicit=t.explicit),"undefined"!=typeof t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},Ce.extend(KJUR.asn1.DERTaggedObject,KJUR.asn1.ASN1Object),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";var e,i={};i.decode=function(i){var r;if(e===t){var s="0123456789ABCDEF",n=" \f\n\r  \u2028\u2029";for(e=[],r=0;16>r;++r)e[s.charAt(r)]=r;for(s=s.toLowerCase(),r=10;16>r;++r)e[s.charAt(r)]=r;for(r=0;r<n.length;++r)e[n.charAt(r)]=-1}var o=[],h=0,a=0;for(r=0;r<i.length;++r){var u=i.charAt(r);if("="==u)break;if(u=e[u],-1!=u){if(u===t)throw"Illegal character at offset "+r;h|=u,++a>=2?(o[o.length]=h,h=0,a=0):h<<=4}}if(a)throw"Hex encoding incomplete: 4 bits missing";return o},window.Hex=i}(),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";var e,i={};i.decode=function(i){var r;if(e===t){var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="= \f\n\r  \u2028\u2029";for(e=[],r=0;64>r;++r)e[s.charAt(r)]=r;for(r=0;r<n.length;++r)e[n.charAt(r)]=-1}var o=[],h=0,a=0;for(r=0;r<i.length;++r){var u=i.charAt(r);if("="==u)break;if(u=e[u],-1!=u){if(u===t)throw"Illegal character at offset "+r;h|=u,++a>=4?(o[o.length]=h>>16,o[o.length]=h>>8&255,o[o.length]=255&h,h=0,a=0):h<<=6}}switch(a){case 1:throw"Base64 encoding incomplete: at least 2 bits missing";case 2:o[o.length]=h>>10;break;case 3:o[o.length]=h>>16,o[o.length]=h>>8&255}return o},i.re=/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,i.unarmor=function(t){var e=i.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw"RegExp out of sync";t=e[2]}return i.decode(t)},window.Base64=i}(),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";function e(t,i){t instanceof e?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=i)}function i(t,e,i,r,s){this.stream=t,this.header=e,this.length=i,this.tag=r,this.sub=s}var r=100,s="…",n={tag:function(t,e){var i=document.createElement(t);return i.className=e,i},text:function(t){return document.createTextNode(t)}};e.prototype.get=function(e){if(e===t&&(e=this.pos++),e>=this.enc.length)throw"Requesting byte offset "+e+" on a stream of length "+this.enc.length;return this.enc[e]},e.prototype.hexDigits="0123456789ABCDEF",e.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},e.prototype.hexDump=function(t,e,i){for(var r="",s=t;e>s;++s)if(r+=this.hexByte(this.get(s)),i!==!0)switch(15&s){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r},e.prototype.parseStringISO=function(t,e){for(var i="",r=t;e>r;++r)i+=String.fromCharCode(this.get(r));return i},e.prototype.parseStringUTF=function(t,e){for(var i="",r=t;e>r;){var s=this.get(r++);i+=128>s?String.fromCharCode(s):s>191&&224>s?String.fromCharCode((31&s)<<6|63&this.get(r++)):String.fromCharCode((15&s)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return i},e.prototype.parseStringBMP=function(t,e){for(var i="",r=t;e>r;r+=2){var s=this.get(r),n=this.get(r+1);i+=String.fromCharCode((s<<8)+n)}return i},e.prototype.reTime=/^((?:1[89]|2\d)?\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,e.prototype.parseTime=function(t,e){var i=this.parseStringISO(t,e),r=this.reTime.exec(i);return r?(i=r[1]+"-"+r[2]+"-"+r[3]+" "+r[4],r[5]&&(i+=":"+r[5],r[6]&&(i+=":"+r[6],r[7]&&(i+="."+r[7]))),r[8]&&(i+=" UTC","Z"!=r[8]&&(i+=r[8],r[9]&&(i+=":"+r[9]))),i):"Unrecognized time: "+i},e.prototype.parseInteger=function(t,e){var i=e-t;if(i>4){i<<=3;var r=this.get(t);if(0===r)i-=8;else for(;128>r;)r<<=1,--i;return"("+i+" bit)"}for(var s=0,n=t;e>n;++n)s=s<<8|this.get(n);return s},e.prototype.parseBitString=function(t,e){var i=this.get(t),r=(e-t-1<<3)-i,s="("+r+" bit)";if(20>=r){var n=i;s+=" ";for(var o=e-1;o>t;--o){for(var h=this.get(o),a=n;8>a;++a)s+=h>>a&1?"1":"0";n=0}}return s},e.prototype.parseOctetString=function(t,e){var i=e-t,n="("+i+" byte) ";i>r&&(e=t+r);for(var o=t;e>o;++o)n+=this.hexByte(this.get(o));return i>r&&(n+=s),n},e.prototype.parseOID=function(t,e){for(var i="",r=0,s=0,n=t;e>n;++n){var o=this.get(n);if(r=r<<7|127&o,s+=7,!(128&o)){if(""===i){var h=80>r?40>r?0:1:2;i=h+"."+(r-40*h)}else i+="."+(s>=31?"bigint":r);r=s=0}}return i},i.prototype.typeName=function(){if(this.tag===t)return"unknown";var e=this.tag>>6,i=(this.tag>>5&1,31&this.tag);switch(e){case 0:switch(i){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString";default:return"Universal_"+i.toString(16)}case 1:return"Application_"+i.toString(16);case 2:return"["+i+"]";case 3:return"Private_"+i.toString(16)}},i.prototype.reSeemsASCII=/^[ -~]+$/,i.prototype.content=function(){if(this.tag===t)return null;var e=this.tag>>6,i=31&this.tag,n=this.posContent(),o=Math.abs(this.length);if(0!==e){if(null!==this.sub)return"("+this.sub.length+" elem)";var h=this.stream.parseStringISO(n,n+Math.min(o,r));return this.reSeemsASCII.test(h)?h.substring(0,2*r)+(h.length>2*r?s:""):this.stream.parseOctetString(n,n+o)}switch(i){case 1:return 0===this.stream.get(n)?"false":"true";case 2:return this.stream.parseInteger(n,n+o);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(n,n+o);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(n,n+o);case 6:return this.stream.parseOID(n,n+o);case 16:case 17:return"("+this.sub.length+" elem)";case 12:return this.stream.parseStringUTF(n,n+o);case 18:case 19:case 20:case 21:case 22:case 26:return this.stream.parseStringISO(n,n+o);case 30:return this.stream.parseStringBMP(n,n+o);case 23:case 24:return this.stream.parseTime(n,n+o)}return null},i.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},i.prototype.print=function(e){if(e===t&&(e=""),document.writeln(e+this),null!==this.sub){e+=" ";for(var i=0,r=this.sub.length;r>i;++i)this.sub[i].print(e)}},i.prototype.toPrettyString=function(e){e===t&&(e="");var i=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(i+="+"),i+=this.length,32&this.tag?i+=" (constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(i+=" (encapsulates)"),i+="\n",null!==this.sub){e+=" ";for(var r=0,s=this.sub.length;s>r;++r)i+=this.sub[r].toPrettyString(e)}return i},i.prototype.toDOM=function(){var t=n.tag("div","node");t.asn1=this;var e=n.tag("div","head"),i=this.typeName().replace(/_/g," ");e.innerHTML=i;var r=this.content();if(null!==r){r=String(r).replace(/</g,"&lt;");var s=n.tag("span","preview");s.appendChild(n.text(r)),e.appendChild(s)}t.appendChild(e),this.node=t,this.head=e;var o=n.tag("div","value");if(i="Offset: "+this.stream.pos+"<br/>",i+="Length: "+this.header+"+",i+=this.length>=0?this.length:-this.length+" (undefined)",32&this.tag?i+="<br/>(constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(i+="<br/>(encapsulates)"),null!==r&&(i+="<br/>Value:<br/><b>"+r+"</b>","object"==typeof oids&&6==this.tag)){var h=oids[r];h&&(h.d&&(i+="<br/>"+h.d),h.c&&(i+="<br/>"+h.c),h.w&&(i+="<br/>(warning!)"))}o.innerHTML=i,t.appendChild(o);var a=n.tag("div","sub");if(null!==this.sub)for(var u=0,c=this.sub.length;c>u;++u)a.appendChild(this.sub[u].toDOM());return t.appendChild(a),e.onclick=function(){t.className="node collapsed"==t.className?"node":"node collapsed"},t},i.prototype.posStart=function(){return this.stream.pos},i.prototype.posContent=function(){return this.stream.pos+this.header},i.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},i.prototype.fakeHover=function(t){this.node.className+=" hover",t&&(this.head.className+=" hover")},i.prototype.fakeOut=function(t){var e=/ ?hover/;this.node.className=this.node.className.replace(e,""),t&&(this.head.className=this.head.className.replace(e,""))},i.prototype.toHexDOM_sub=function(t,e,i,r,s){if(!(r>=s)){var o=n.tag("span",e);o.appendChild(n.text(i.hexDump(r,s))),t.appendChild(o)}},i.prototype.toHexDOM=function(e){var i=n.tag("span","hex");if(e===t&&(e=i),this.head.hexNode=i,this.head.onmouseover=function(){this.hexNode.className="hexCurrent"},this.head.onmouseout=function(){this.hexNode.className="hex"},i.asn1=this,i.onmouseover=function(){var t=!e.selected;t&&(e.selected=this.asn1,this.className="hexCurrent"),this.asn1.fakeHover(t)},i.onmouseout=function(){var t=e.selected==this.asn1;this.asn1.fakeOut(t),t&&(e.selected=null,this.className="hex")},this.toHexDOM_sub(i,"tag",this.stream,this.posStart(),this.posStart()+1),this.toHexDOM_sub(i,this.length>=0?"dlen":"ulen",this.stream,this.posStart()+1,this.posContent()),null===this.sub)i.appendChild(n.text(this.stream.hexDump(this.posContent(),this.posEnd())));else if(this.sub.length>0){var r=this.sub[0],s=this.sub[this.sub.length-1];this.toHexDOM_sub(i,"intro",this.stream,this.posContent(),r.posStart());for(var o=0,h=this.sub.length;h>o;++o)i.appendChild(this.sub[o].toHexDOM(e));this.toHexDOM_sub(i,"outro",this.stream,s.posEnd(),this.posEnd())}return i},i.prototype.toHexString=function(t){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},i.decodeLength=function(t){var e=t.get(),i=127&e;if(i==e)return i;if(i>3)throw"Length over 24 bits not supported at position "+(t.pos-1);if(0===i)return-1;e=0;for(var r=0;i>r;++r)e=e<<8|t.get();return e},i.hasContent=function(t,r,s){if(32&t)return!0;if(3>t||t>4)return!1;var n=new e(s);3==t&&n.get();var o=n.get();if(o>>6&1)return!1;try{var h=i.decodeLength(n);return n.pos-s.pos+h==r}catch(a){return!1}},i.decode=function(t){t instanceof e||(t=new e(t,0));var r=new e(t),s=t.get(),n=i.decodeLength(t),o=t.pos-r.pos,h=null;if(i.hasContent(s,n,t)){var a=t.pos;if(3==s&&t.get(),h=[],n>=0){for(var u=a+n;t.pos<u;)h[h.length]=i.decode(t);if(t.pos!=u)throw"Content size is not correct for container starting at offset "+a}else try{for(;;){var c=i.decode(t);if(0===c.tag)break;h[h.length]=c}n=a-t.pos}catch(f){throw"Exception while decoding undefined length content: "+f}}else t.pos+=n;return new i(r,o,n,s,h)},i.test=function(){for(var t=[{value:[39],expected:39},{value:[129,201],expected:201},{value:[131,254,220,186],expected:16702650}],r=0,s=t.length;s>r;++r){var n=new e(t[r].value,0),o=i.decodeLength(n);o!=t[r].expected&&document.write("In test["+r+"] expected "+t[r].expected+" got "+o+"\n")}},window.ASN1=i}(),ASN1.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,i=2*this.length;return t.substr(e,i)},ue.prototype.parseKey=function(t){try{var e=0,i=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,s=r.test(t)?Hex.decode(t):Base64.unarmor(t),n=ASN1.decode(s);if(3===n.sub.length&&(n=n.sub[2].sub[0]),9===n.sub.length){e=n.sub[1].getHexStringValue(),this.n=he(e,16),i=n.sub[2].getHexStringValue(),this.e=parseInt(i,16);var o=n.sub[3].getHexStringValue();this.d=he(o,16);var h=n.sub[4].getHexStringValue();this.p=he(h,16);var a=n.sub[5].getHexStringValue();this.q=he(a,16);var u=n.sub[6].getHexStringValue();this.dmp1=he(u,16);var c=n.sub[7].getHexStringValue();this.dmq1=he(c,16);var f=n.sub[8].getHexStringValue();this.coeff=he(f,16)}else{if(2!==n.sub.length)return!1;var p=n.sub[1],l=p.sub[0];e=l.sub[0].getHexStringValue(),this.n=he(e,16),i=l.sub[1].getHexStringValue(),this.e=parseInt(i,16)}return!0}catch(d){return!1}},ue.prototype.getPrivateBaseKey=function(){var t={array:[new KJUR.asn1.DERInteger({"int":0}),new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e}),new KJUR.asn1.DERInteger({bigint:this.d}),new KJUR.asn1.DERInteger({bigint:this.p}),new KJUR.asn1.DERInteger({bigint:this.q}),new KJUR.asn1.DERInteger({bigint:this.dmp1}),new KJUR.asn1.DERInteger({bigint:this.dmq1}),new KJUR.asn1.DERInteger({bigint:this.coeff})]},e=new KJUR.asn1.DERSequence(t);return e.getEncodedHex()},ue.prototype.getPrivateBaseKeyB64=function(){return be(this.getPrivateBaseKey())},ue.prototype.getPublicBaseKey=function(){var t={array:[new KJUR.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new KJUR.asn1.DERNull]},e=new KJUR.asn1.DERSequence(t);t={array:[new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e})]};var i=new KJUR.asn1.DERSequence(t);t={hex:"00"+i.getEncodedHex()};var r=new KJUR.asn1.DERBitString(t);t={array:[e,r]};var s=new KJUR.asn1.DERSequence(t);return s.getEncodedHex()},ue.prototype.getPublicBaseKeyB64=function(){return be(this.getPublicBaseKey())},ue.prototype.wordwrap=function(t,e){if(e=e||64,!t)return t;var i="(.{1,"+e+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(i,"g")).join("\n")},ue.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return t+=this.wordwrap(this.getPrivateBaseKeyB64())+"\n",t+="-----END RSA PRIVATE KEY-----"},ue.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return t+=this.wordwrap(this.getPublicBaseKeyB64())+"\n",t+="-----END PUBLIC KEY-----"},ue.prototype.hasPublicKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")},ue.prototype.hasPrivateKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},ue.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)};var _e=function(t){ue.call(this),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))};_e.prototype=new ue,_e.prototype.constructor=_e;var ze=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null};ze.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new _e(t)},ze.prototype.setPrivateKey=function(t){this.setKey(t)},ze.prototype.setPublicKey=function(t){this.setKey(t)},ze.prototype.decrypt=function(t){try{return this.getKey().decrypt(Te(t))}catch(e){return!1}},ze.prototype.encrypt=function(t){try{return be(this.getKey().encrypt(t))}catch(e){return!1}},ze.prototype.getKey=function(t){if(!this.key){if(this.key=new _e,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},ze.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},ze.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},ze.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},ze.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},ze.version="2.3.0",t.JSEncrypt=ze}(JSEncryptExports),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e:"function"==typeof define&&define.amd?define(e):t.JSEncrypt=e}(this,JSEncryptExports.JSEncrypt);
INTERMediatorOnPage.getEditorPath=function(){return '';};
INTERMediatorOnPage.getEntryPath=function(){return "/member/im_include_research.php";};
INTERMediatorOnPage.getTheme=function(){return "redb";};
INTERMediatorOnPage.getDataSources=function(){return {'0':{'records':'1','name':'staff','key':'id','query':{},'sort':{'0':{'field':'id','direction':'asc'}},'authentication':{'all':{'target':'field-user','field':'email'}}},'1':{'name':'management','key':'id'},'2':{'name':'gakubu','relation':{'0':{'foreign-key':'id','join-field':'gakubu_id','operator':'='}}},'3':{'name':'gakka','relation':{'0':{'foreign-key':'id','join-field':'gakka_id','operator':'='}}},'4':{'name':'title','relation':{'0':{'foreign-key':'id','join-field':'title_id','operator':'='}}},'5':{'name':'category','view':'research_category','table':'research_category','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}}},'6':{'name':'keyword','view':'research_keyword','table':'research_keyword','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'キーワードを追加'}},'7':{'name':'theme','view':'research_theme','table':'research_theme','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'テーマを追加'}},'8':{'name':'society','view':'academic_society','table':'academic_society','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'学会を追加'}},'9':{'records':'5','name':'paper','table':'book_paper','view':'book_paper','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','button-names':{'insert':'業績を追加'}},'10':{'records':'5','name':'exhibition_society','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','validation':{'0':{'field':'is_period','rule':'1'}},'post-repeater':'expandRecordHavingIsPeriod','button-names':{'insert':'業績を追加'}},'11':{'records':'5','name':'research_fund','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','validation':{'0':{'field':'fund','rule':'1','message':'半角数値で入力してください'},'1':{'field':'is_period','rule':'1'}},'post-repeater':'expandRecordHavingIsPeriod','button-names':{'insert':'業績を追加'}},'12':{'name':'patent','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','button-names':{'insert':'業績を追加'}}};};
INTERMediatorOnPage.getOptionsAliases=function(){return {};};
INTERMediatorOnPage.getOptionsTransaction=function(){return '';};
INTERMediatorOnPage.dbClassName="DB_PDO";
INTERMediatorOnPage.defaultKeyName="";
INTERMediatorOnPage.isEmailAsUsername=false;
INTERMediatorOnPage.getMessages=function(){return {'1':'Record #','2':'Refresh','3':'Add Record','4':'Delete Record','5':'Insert','6':'Delete','7':'Save','8':'Login as: ','9':'Logout','10':'Move to page:','11':'','12':'Detail','13':'Show List','14':'Copy','15':'Copy Record','1001':'Other people might be updated.\n\nInitially=@1@\nCurrent=@2@\nDatabase=@3@\n\nYou can overwrite with your data if you select OK.','1002':'Can\'t determine the Table Name: @1@','1003':'No information to update: field=@1@','1004':'Connection Error in db_query=@1@\/@2@','1005':'On calling db_query, Required parameter \'name\' doesn\'t specified','1006':'On calling db_query, Required parameter \'table\' doesn\'t specified','1007':'On calling db_update, Required parameter \'name\' doesn\'t specified','1008':'On calling db_update, Required parameter \'conditions\' doesn\'t specified','1009':'On calling db_update, Required parameter \'operator\' doesn\'t specified','1010':'On calling db_update, Required parameter \'value\' doesn\'t specified','1011':'On calling db_update, Required parameter \'dataset\' doesn\'t specified','1012':'Query Access: ','1013':'Update Access: ','1014':'Connection Error in db_update=@1@\/@2@','1015':'Connection Error in db_delete=@1@\/@2@','1016':'Connection Error in db_createRecord=@1@\/@2@','1017':'Delete Access: ','1018':'Create Record Access: ','1019':'On calling db_delete, Required parameter \'name\' doesn\'t specified','1020':'On calling db_delete, Required parameter \'conditions\' doesn\'t specified','1021':'On calling db_createRecord, Required parameter \'name\' doesn\'t specified','1022':'Using Unsupported Browser (Try not to use the compatibility mode of Internet Explorer)','1023':'[This site uses INTER-Mediator.]','1024':'Multiple records are going to be updated. The key field might be wrong. Are you sure?','1025':'Are you sure to delete?','1026':'Are you sure to create record?','1027':'Get Challenge: ','1028':'Connection Error in get_challenge=@1@\/@2@','1029':'Change Password Access: ','1030':'Connection Error on changing password=@1@\/@2@','1031':'Change File Uploading: ','1032':'Connection Error on uploading file=@1@\/@2@','1033':'The field name specified in the page file doesn\'t exist [folder=@1@]','1034':'Other people might be updated.\n\n@1@\n\nYou can overwrite with your data if you select OK.','1035':'field=@1@, initial value=@2@, current value=@3@\n','1036':'field=@1@, expression=@2@ happens a parse error.','1037':'A cyclic referencing is detected.','1038':'Preparing the Pusher, although the settings in the server side is available, the client library isn\'t included.','1039':'Preparing the Pusher, although the client library is included, the settings in the server side is not available.','1040':'The field \'@2@\' in the context \'@1@\' does not exist in the table.','1041':'Are you sure to copy this record?','1042':'The database class doesn\'t support aggregation-select\/from\/group-by.','1043':'Both aggregation-select and aggregation-from are required. One of them doesn\'t exist in the context definition.','1044':'The context having aggregation-select\/from\/group-by is read-only.','1045':'The \'key\' is required in the context definition if writing operations apply to the context \'@1@\'.','1046':'The context definition of the name \'@1@\' in target specifications of the page file is undefined in the definition file.','1047':'The context \'@1@\' was chosen for this context, and ignored target specifications were: @2@','2001':'Authentication Error!','2002':'User:','2003':'Password:','2004':'Login','2005':'Change Password','2006':'New Password:','2007':'Missing any of Username, old and new password.','2008':'Failure to get a challenge from server.','2009':'Succeed to change your password. Login with the new password.','2010':'Failure to change your password. Maybe the old password is not correct.','2011':'User(Mail Address):','2012':'Retry to login. You should clarify the user and the password.','2013':'You should input user and\/or password.','2014':'OAuth Login','2015':'Any alphabets have to contain in new password.','2016':'Any numbers have to contain in new password.','2017':'Any upper case alphabets have to contain in new password.','2018':'Any lower case alphabets have to contain in new password.','2019':'Any punctuations have to contain in new password.','2020':'New password have to differ from the user name.','2021':'New password have to contain more than @1@ characters.','2022':'Enrollment this site with email','2023':'Reset my password','2024':'You need to prepare your email address.','2025':'Require a 2048-bit private key at least for authentication','3101':'Drag Here.','3102':'Dragged File: ','3201':'Exceeded post size limit. Check the post_max_size in php.ini file.','3202':'No file wasn\'t uploaded. Possibly, exceeded file size limit.','3203':'Exceeded file size limit. Check the upload_max_filesize in php.ini file.','3204':'Partially uploaded.','3205':'Temporary directory doesn\'t exist.','3206':'Can\'t write to disk or file system.','3207':'Extension module prevents to upload.','3208':'Unknown error in file uploading.','3209':'Select File...','3210':'Selected File: ','3211':'Upload'};};
INTERMediatorOnPage.browserCompatibility=function(){return {'edge':'12+','trident':'4+','chrome':'1+','firefox':'2+','safari':'4+','opera':'1+','webkit':'1+'};};
INTERMediatorOnPage.clientNotificationIdentifier=function(){return '691702fed0565fd6aac03e53d2884c360b170b172eccb52da8ec18108b1d1cce';};
INTERMediatorOnPage.metadata={version:"5.12",releasedate:"2021-08-15"};
INTERMediatorLog.debugMode=false;
INTERMediatorOnPage.appLocale="ja_JP";
INTERMediatorOnPage.localeInfo=JSON.parse('{"decimal_point":".","thousands_sep":",","int_curr_symbol":"JPY ","currency_symbol":"\uffe5","mon_decimal_point":".","mon_thousands_sep":",","positive_sign":"","negative_sign":"-","int_frac_digits":0,"frac_digits":0,"p_cs_precedes":1,"p_sep_by_space":0,"n_cs_precedes":1,"n_sep_by_space":0,"p_sign_posn":1,"n_sign_posn":1,"grouping":[3],"mon_grouping":[3],"DAY":["\u65e5\u66dc\u65e5","\u6708\u66dc\u65e5","\u706b\u66dc\u65e5","\u6c34\u66dc\u65e5","\u6728\u66dc\u65e5","\u91d1\u66dc\u65e5","\u571f\u66dc\u65e5"],"ABDAY":["\u65e5","\u6708","\u706b","\u6c34","\u6728","\u91d1","\u571f"],"MON":["\u7766\u6708","\u5982\u6708","\u5f25\u751f","\u536f\u6708","\u7690\u6708","\u6c34\u7121\u6708","\u6587\u6708","\u8449\u6708","\u9577\u6708","\u795e\u7121\u6708","\u971c\u6708","\u5e2b\u8d70"],"ABMON":["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"],"AM_STR":"\u5348\u524d","PM_STR":"\u5348\u5f8c","D_FMT_LONG":"%Y\u5e74%M\u6708%D\u65e5 %W","T_FMT_LONG":"%H\u6642%I\u5206%S\u79d2","D_FMT_MIDDLE":"%Y\/%M\/%D(%w)","T_FMT_MIDDLE":"%H:%I:%S","D_FMT_SHORT":"%Y\/%m\/%d","T_FMT_SHORT":"%H:%I"}');
INTERMediatorOnPage.appCurrency="JP";
INTERMediatorOnPage.requireAuthentication=true;
INTERMediatorOnPage.authRequiredContext={'0':'staff'};
INTERMediatorOnPage.isLDAP=false;
INTERMediatorOnPage.isOAuthAvailable=false;
INTERMediatorOnPage.isNativeAuth=false;
INTERMediatorOnPage.authStoring="cookie-domainwide";
INTERMediatorOnPage.authExpired=3600;
INTERMediatorOnPage.realm="";
INTERMediatorOnPage.publickey='-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnEpCZny+NQy+aCVGivertUIt9OrI/aDpAjT7s1UYLEERFXcfFs1A9VdIowUeg3NyJxAOxbLk6RXczoVoULEte2HB/roFg7V/sVG9rjx5F4im0JLqEyvuSLTeSx3TGkIr0NHmNAO/SQrfnBiUjdkugn2WCuvQHe06wfHXWg3Pck4JS0Y6vNQz//Ny7nZVfAWRkiFtb7ZilvSWXmmFuoG3xH6IeFBMaJBcFENK58bGQaQTcfg9qzpHhzCQwqbURYSH8WzAZlPRUo1lBZ4WEpMqGWYOiiiqOlc0v+2pW5BNvu3fk8DQbGwJIywC12nfhFKZH2txv0o0hx2ukXA+nBMQLQIDAQAB-----END PUBLIC KEY-----';
INTERMediatorOnPage.publickeysize=2048;

Unexpected token '/', "/*
* INTE"... is not valid JSON - Connection Error in db_query=SyntaxError: Unexpected token '/', "/*
* INTE"... is not valid JSON//*
* INTER-Mediator
* Copyright (c) INTER-Mediator Directive Committee (http://inter-mediator.org)
* This project started at the end of 2009 by Masayuki Nii msyk@msyk.net.
*
* INTER-Mediator is supplied under MIT License.
* Please see the full license for details:
* https://github.com/INTER-Mediator/INTER-Mediator/blob/master/dist-docs/License.txt
*/
var INTERMediator={separator:'@',defDivider:'|',defaultTargetInnerHTML:!1,navigationLabel:null,elementIds:[],dontSelectRadioCheck:!1,ignoreOptimisticLocking:!1,additionalFieldValueOnNewRecord:{},additionalFieldValueOnUpdate:{},additionalFieldValueOnDelete:{},waitSecondsAfterPostMessage:4,pagedAllCount:0,totalRecordCount:null,currentEncNumber:0,isIE:!1,isTrident:!1,isEdge:!1,ieVersion:-1,titleAsLinkInfo:!0,classAsLinkInfo:!0,isDBDataPreferable:!1,noRecordClassName:'_im_for_noresult_',rootEnclosure:null,useSessionStorage:!0,partialConstructing:!0,linkedElmCounter:0,pusherObject:null,buttonIdNum:0,masterNodeOriginalDisplay:'block',detailNodeOriginalDisplay:'none',pusherAvailable:!1,dateTimeFunction:!1,postOnlyNumber:1,isTablet:!1,isMobile:!1,crossTableStage:0,eventListenerPostAdding:null,appendingNodesAtLast:null,propertyIETridentSetup:function(){'use strict';var ua,position,c,i;ua=navigator.userAgent;position=ua.toLocaleUpperCase().indexOf('MSIE');if(position>=0){INTERMediator.isIE=!0;for(i=position+4;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+4,i));break}}}
position=ua.indexOf('; Trident/');if(position>=0){INTERMediator.isTrident=!0;for(i=position+10;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+10,i))+4;if(INTERMediator.ieVersion===11){INTERMediator.isIE=!0}
break}}}
position=ua.indexOf(' Edge/');if(position>=0){INTERMediator.isEdge=!0;for(i=position+6;i<ua.length;i++){c=ua.charAt(i);if(!(c===' '||c==='.'||(c>='0'&&c<='9'))||i===ua.length-1){INTERMediator.ieVersion=INTERMediatorLib.toNumber(ua.substring(position+6,i));break}}}},propertyW3CUserAgentSetup:function(){'use strict';var u=window.navigator.userAgent.toLowerCase();INTERMediator.isTablet=(u.indexOf('windows')>-1&&u.indexOf('touch')>-1&&u.indexOf('tablet pc')===-1)||u.indexOf('ipad')>-1||(u.indexOf('android')>-1&&u.indexOf('mobile')===-1)||(u.indexOf('firefox')>-1&&u.indexOf('tablet')>-1)||u.indexOf('kindle')>-1||u.indexOf('silk')>-1||u.indexOf('playbook')>-1;INTERMediator.isMobile=(u.indexOf('windows')>-1&&u.indexOf('phone')>-1)||u.indexOf('iphone')>-1||u.indexOf('ipod')>-1||(u.indexOf('android')>-1&&u.indexOf('mobile')>-1)||(u.indexOf('firefox')>-1&&u.indexOf('mobile')>-1)||u.indexOf('blackberry')>-1},initialize:function(){'use strict';INTERMediatorOnPage.removeCookie('_im_localcontext');INTERMediator.additionalCondition={};INTERMediator.additionalSortKey={};INTERMediator.startFrom=0;IMLibLocalContext.archive()},construct:function(indexOfKeyFieldObject){'use strict';var timerTask;if(indexOfKeyFieldObject===!0||indexOfKeyFieldObject===undefined){if(INTERMediatorOnPage.isFinishToConstruct){return}
INTERMediatorOnPage.isFinishToConstruct=!0;timerTask=function(){INTERMediator.constructMain(!0)}}else{timerTask=function(){INTERMediator.constructMain(indexOfKeyFieldObject)}}
setTimeout(timerTask,0)},constructMain:function(updateRequiredContext,recordset){'use strict';var i,theNode,postSetFields=[],radioName={},nameSerial=1,nameAttrCounter=1,imPartsShouldFinished=[],isAcceptNotify=!1,originalNodes,parentNode,sybilingNode;INTERMediator.eventListenerPostAdding=[];if(INTERMediatorOnPage.doBeforeConstruct){INTERMediatorOnPage.doBeforeConstruct()}
if(!INTERMediatorOnPage.isAutoConstruct){return}
INTERMediatorOnPage.showProgress();INTERMediator.crossTableStage=0;INTERMediator.appendingNodesAtLast=[];IMLibEventResponder.setup();INTERMediatorOnPage.retrieveAuthInfo();try{if(Pusher.VERSION){INTERMediator.pusherAvailable=!0;if(!INTERMediatorOnPage.clientNotificationKey){INTERMediatorLog.setErrorMessage(Error('Pusher Configuration Error'),INTERMediatorOnPage.getMessages()[1039]);INTERMediator.pusherAvailable=!1}}}catch(ex){INTERMediator.pusherAvailable=!1;if(INTERMediatorOnPage.clientNotificationKey){INTERMediatorLog.setErrorMessage(Error('Pusher Configuration Error'),INTERMediatorOnPage.getMessages()[1038])}}
try{if(updateRequiredContext===!0||updateRequiredContext===undefined){IMLibPageNavigation.deleteInsertOnNavi=[];INTERMediator.partialConstructing=!1;INTERMediator.buttonIdNum=1;IMLibContextPool.clearAll();pageConstruct()}else{IMLibPageNavigation.deleteInsertOnNavi=[];INTERMediator.partialConstructing=!0;postSetFields=[];try{if(!recordset){updateRequiredContext.removeContext();originalNodes=updateRequiredContext.original;for(i=0;i<originalNodes.length;i++){updateRequiredContext.enclosureNode.appendChild(originalNodes[i].cloneNode(!0))}
seekEnclosureNode(updateRequiredContext.enclosureNode,updateRequiredContext.foreignValue,updateRequiredContext.dependingParentObjectInfo,updateRequiredContext)}else{expandRepeaters(updateRequiredContext,updateRequiredContext.enclosureNode,{recordset:recordset,targetTotalCount:1,targetCount:1})}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-8')}}
for(i=0;i<postSetFields.length;i++){if(postSetFields[i].id&&document.getElementById(postSetFields[i].id)){document.getElementById(postSetFields[i].id).value=postSetFields[i].value}}
IMLibCalc.updateCalculationFields()}}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.hideProgress();INTERMediatorOnPage.authenticating(function(){INTERMediator.constructMain(updateRequiredContext)});INTERMediator.partialConstructing=!0;return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-7');INTERMediator.partialConstructing=!0}}
for(i=0;i<imPartsShouldFinished.length;i++){imPartsShouldFinished[i].finish()}
for(i=0;i<INTERMediator.appendingNodesAtLast.length;i++){theNode=INTERMediator.appendingNodesAtLast[i].targetNode;parentNode=INTERMediator.appendingNodesAtLast[i].parentNode;sybilingNode=INTERMediator.appendingNodesAtLast[i].siblingNode;if(theNode&&parentNode){if(sybilingNode){parentNode.insertBefore(theNode,sybilingNode)}else{parentNode.appendChild(theNode)}}}
for(i=0;i<INTERMediator.eventListenerPostAdding.length;i++){theNode=document.getElementById(INTERMediator.eventListenerPostAdding[i].id);if(theNode){INTERMediatorLib.addEvent(theNode,INTERMediator.eventListenerPostAdding[i].event,INTERMediator.eventListenerPostAdding[i].todo)}}
if(INTERMediatorOnPage.doAfterConstruct){INTERMediatorOnPage.doAfterConstruct()}
IMLibPageNavigation.navigationSetup();INTERMediatorOnPage.isFinishToConstruct=!1;INTERMediator.partialConstructing=!0;INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage();function pageConstruct(){var i,bodyNode,emptyElement;IMLibCalc.calculateRequiredObject={};INTERMediator.currentEncNumber=1;INTERMediator.elementIds=[];bodyNode=document.getElementsByTagName('BODY')[0];if(!INTERMediator.rootEnclosure){INTERMediator.rootEnclosure=bodyNode.innerHTML}else{bodyNode.innerHTML=INTERMediator.rootEnclosure}
postSetFields=[];INTERMediatorOnPage.setReferenceToTheme();IMLibPageNavigation.initializeStepInfo(!1);IMLibLocalContext.bindingDescendant(document.documentElement);try{seekEnclosureNode(bodyNode,null,null,null)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-9')}}
for(i=0;i<postSetFields.length;i++){if(postSetFields[i].value===''&&document.getElementById(postSetFields[i].id).tagName==='SELECT'){emptyElement=document.createElement('option');emptyElement.setAttribute('id',INTERMediator.nextIdValue());emptyElement.setAttribute('value','');emptyElement.setAttribute('data-im-element','auto-generated');document.getElementById(postSetFields[i].id).insertBefore(emptyElement,document.getElementById(postSetFields[i].id).firstChild)}
document.getElementById(postSetFields[i].id).value=postSetFields[i].value}
IMLibCalc.updateCalculationFields();if(isAcceptNotify&&INTERMediator.pusherAvailable){var channelName=INTERMediatorOnPage.clientNotificationIdentifier();var appKey=INTERMediatorOnPage.clientNotificationKey();if(appKey&&appKey!=='_im_key_isnt_supplied'&&!INTERMediator.pusherObject){try{Pusher.log=function(message){if(window.console&&window.console.log){window.console.log(message)}};INTERMediator.pusherObject=new Pusher(appKey);INTERMediator.pusherChannel=INTERMediator.pusherObject.subscribe(channelName);INTERMediator.pusherChannel.bind('update',function(data){IMLibContextPool.updateOnAnotherClient('update',data)});INTERMediator.pusherChannel.bind('create',function(data){IMLibContextPool.updateOnAnotherClient('create',data)});INTERMediator.pusherChannel.bind('delete',function(data){IMLibContextPool.updateOnAnotherClient('delete',data)})}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-47')}}}
appendCredit()}
function seekEnclosureNode(node,currentRecord,parentObjectInfo,currentContextObj){var children,className,i,attr;if(node.nodeType===1){try{if(INTERMediatorLib.isEnclosure(node,!1)){className=INTERMediatorLib.getClassAttributeFromNode(node);attr=node.getAttribute('data-im-control');if((className&&className.match(/_im_post/))||(attr&&attr.indexOf('post')>=0)){setupPostOnlyEnclosure(node)}else{if(INTERMediator.isIE){try{expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}}}else{expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}}}else{children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){seekEnclosureNode(children[i],currentRecord,parentObjectInfo,currentContextObj)}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-10')}}}}
function setupPostOnlyEnclosure(node){var nodes,postNodes;postNodes=INTERMediatorLib.getElementsByClassNameOrDataAttr(node,'_im_post');for(i=0;i<postNodes.length;i++){if(postNodes[i].tagName==='BUTTON'||(postNodes[i].tagName==='INPUT'&&(postNodes[i].getAttribute('type').toLowerCase()==='button'||postNodes[i].getAttribute('type').toLowerCase()==='submit'))){if(!postNodes[i].id){postNodes[i].id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(postNodes[i].id,(function(){var targetNode=postNodes[i];return function(){IMLibUI.clickPostOnlyButton(targetNode)}})())}}
nodes=node.childNodes;for(i=0;i<nodes.length;i++){seekEnclosureInPostOnly(nodes[i])}
function seekEnclosureInPostOnly(node){var children,wInfo,i,target;if(node.nodeType===1){try{target=node.getAttribute('data-im');if(!target){target=node.getAttribute('data-im-group')}
if(target){if(!node.id){node.id='IMPOST-'+INTERMediator.postOnlyNumber;INTERMediator.postOnlyNumber++}
INTERMediatorLib.addEvent(node,'blur',function(){var idValue=node.id;IMLibUI.valueChange(idValue,!0)});if(node.tagName==='INPUT'&&node.getAttribute('type')==='radio'){if(!radioName[target]){radioName[target]='Name-'+nameSerial;nameSerial++}
node.setAttribute('name',radioName[target])}}
if(INTERMediatorLib.isWidgetElement(node)){wInfo=INTERMediatorLib.getWidgetInfo(node);if(wInfo[0]){IMParts_Catalog[wInfo[0]].instanciate(node);if(imPartsShouldFinished.indexOf(IMParts_Catalog[wInfo[0]])<0){imPartsShouldFinished.push(IMParts_Catalog[wInfo[0]])}}}else if(INTERMediatorLib.isEnclosure(node,!1)){expandEnclosure(node,null,null,null)}else{children=node.childNodes;for(i=0;i<children.length;i++){seekEnclosureInPostOnly(children[i])}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-11')}}}}}
function expandEnclosure(node,currentRecord,parentObjectInfo,currentContextObj){var recId,repNodeTag,repeatersOriginal;var imControl=node.getAttribute('data-im-control');if(currentContextObj&&currentContextObj.contextName&&currentRecord&&currentRecord[currentContextObj.contextName]&&currentRecord[currentContextObj.contextName][currentContextObj.contextName+'::'+INTERMediatorOnPage.defaultKeyName]){recId=currentRecord[currentContextObj.contextName][currentContextObj.contextName+'::'+INTERMediatorOnPage.defaultKeyName];currentRecord=currentRecord[currentContextObj.contextName][recId]}
if(imControl&&imControl.match(/cross-table/)){expandCrossTableEnclosure(node,currentRecord,parentObjectInfo,currentContextObj)}else{repNodeTag=INTERMediatorLib.repeaterTagFromEncTag(node.tagName);repeatersOriginal=collectRepeatersOriginal(node,repNodeTag);enclosureProcessing(node,repeatersOriginal,currentRecord,parentObjectInfo,currentContextObj)}
IMLibLocalContext.bindingDescendant(node);function enclosureProcessing(enclosureNode,repeatersOriginal,currentRecord,parentObjectInfo,currentContextObj,procBeforeRetrieve,customExpandRepeater){var linkedNodes,repeaters,linkDefs,voteResult,currentContextDef,fieldList,i,targetRecords,newNode,keyValue,selectedNode,isExpanding,calcFields,contextObj=null,targetRecordset,ix,keyingValue,footerNodes,headerNodes,nInfo;var tempObj={};repeaters=collectRepeaters(repeatersOriginal);linkedNodes=INTERMediatorLib.seekLinkedAndWidgetNodes(repeaters,!0).linkedNode;linkDefs=collectLinkDefinitions(linkedNodes);voteResult=tableVoting(linkDefs);currentContextDef=voteResult.targettable;INTERMediator.currentEncNumber++;if(!enclosureNode.getAttribute('id')){enclosureNode.setAttribute('id',INTERMediator.nextIdValue())}
if(!currentContextDef){for(i=0;i<repeatersOriginal.length;i++){newNode=enclosureNode.appendChild(repeatersOriginal[i]);if(repeatersOriginal[i].getAttribute('selected')){selectedNode=newNode}
if(selectedNode!==undefined){selectedNode.selected=!0}
seekEnclosureNode(newNode,null,enclosureNode,currentContextObj)}}else{isExpanding=!IMLibPageNavigation.isNotExpandingContext(currentContextDef);contextObj=IMLibContextPool.generateContextObject(currentContextDef,enclosureNode,repeaters,repeatersOriginal);calcFields=contextObj.getCalculationFields();fieldList=voteResult.fieldlist.map(function(elm){if(!calcFields[elm]){calcFields.push(elm)}
return elm});if(currentContextDef.relation&&currentContextDef.relation[0]&&Boolean(currentContextDef.relation[0].portal)===!0){contextObj.isPortal=!0;if(!currentRecord){tempObj=IMLibContextPool.generateContextObject({'name':contextObj.sourceName},enclosureNode,repeaters,repeatersOriginal);if(targetRecords===undefined){targetRecords=retrieveDataForEnclosure(tempObj,fieldList,contextObj.foreignValue)}
recId=targetRecords.recordset[0][INTERMediatorOnPage.defaultKeyName];currentRecord=targetRecords.recordset[0]}}
contextObj.setRelationWithParent(currentRecord,parentObjectInfo,currentContextObj);if(contextObj.isPortal===!0){if(currentRecord){currentContextDef.currentrecord=currentRecord;keyValue=currentRecord[currentContextDef.relation[0]['join-field']]}}
if(procBeforeRetrieve){procBeforeRetrieve(contextObj)}
if(isExpanding){targetRecords=retrieveDataForEnclosure(contextObj,fieldList,contextObj.foreignValue)}else{targetRecords=[];if(enclosureNode.tagName==='TBODY'){enclosureNode.parentNode.style.display='none'}else{enclosureNode.style.display='none'}}
contextObj.storeRecords(targetRecords);callbackForAfterQueryStored(currentContextDef,contextObj);if(customExpandRepeater===undefined){contextObj.registeredId=targetRecords.registeredId;contextObj.nullAcceptable=targetRecords.nullAcceptable;isAcceptNotify|=!(INTERMediatorOnPage.notifySupport===!1);expandRepeaters(contextObj,enclosureNode,targetRecords);IMLibPageNavigation.setupInsertButton(contextObj,keyValue,enclosureNode,contextObj.foreignValue);IMLibPageNavigation.setupBackNaviButton(contextObj,enclosureNode);callbackForEnclosure(currentContextDef,enclosureNode)}else{customExpandRepeater(contextObj,targetRecords)}
contextObj.sequencing=!1;if(enclosureNode.tagName==='TBODY'){footerNodes=enclosureNode.parentNode.getElementsByTagName('TFOOT');linkedNodes=seekWithAttribute(footerNodes[0],'data-im');if(linkedNodes){INTERMediator.setIdValue(footerNodes[0]);targetRecordset={};ix=null;keyingValue='_im_footer';for(i=0;i<linkedNodes.length;i++){nInfo=INTERMediatorLib.getNodeInfoArray(INTERMediatorLib.getLinkedElementInfo(linkedNodes[i])[0]);if(linkedNodes[i]&&currentContextDef.name===nInfo.table){INTERMediator.setIdValue(linkedNodes[i])}
IMLibCalc.updateCalculationInfo(contextObj,keyingValue,linkedNodes[i].id,nInfo,targetRecordset);if(contextObj.binding._im_footer){contextObj.binding._im_footer._im_repeater=footerNodes}}}
headerNodes=enclosureNode.parentNode.getElementsByTagName('THEAD');linkedNodes=seekWithAttribute(headerNodes[0],'data-im');if(linkedNodes){INTERMediator.setIdValue(headerNodes[0]);targetRecordset={};ix=null;keyingValue='_im_header';for(i=0;i<linkedNodes.length;i++){INTERMediator.setIdValue(linkedNodes[i]);nInfo=INTERMediatorLib.getNodeInfoArray(INTERMediatorLib.getLinkedElementInfo(linkedNodes[i])[0]);IMLibCalc.updateCalculationInfo(contextObj,keyingValue,linkedNodes[i].id,nInfo,targetRecordset);if(contextObj.binding._im_header){contextObj.binding._im_header._im_repeater=headerNodes}}}}}
return contextObj}
function seekWithAttribute(node,attrName){if(!node||node.nodeType!==1){return null}
var result=seekWithAttributeImpl(node,attrName);return result}
function seekWithAttributeImpl(node,attrName){var ix,adding,result=[];if(node&&node.nodeType===1){if(node.getAttribute(attrName)){result.push(node)}
if(node.childNodes){for(ix=0;ix<node.childNodes.length;ix++){adding=seekWithAttributeImpl(node.childNodes[ix],attrName);if(adding.length>0){[].push.apply(result,adding)}}}}
return result}
function expandCrossTableEnclosure(node,currentRecord,parentObjectInfo,currentContextObj){var i,j,colArray,rowArray,nodeForKeyValues,record,targetRepeater,lineNode,colContext,rowContext,appendingNode,trNodes,repeaters,linkedNodes,linkDefs,crossCellContext,labelKeyColumn,labelKeyRow;var ctComponentNodes=crossTableComponents(node);if(ctComponentNodes.length!==4){throw 'Exception-xx: Cross Table Components aren\'t prepared.'}
while(node.childNodes.length>0){node.removeChild(node.childNodes[0])}
repeaters=collectRepeaters([ctComponentNodes[3].cloneNode(!0)]);linkedNodes=INTERMediatorLib.seekLinkedAndWidgetNodes(repeaters,!0).linkedNode;linkDefs=collectLinkDefinitions(linkedNodes);crossCellContext=tableVoting(linkDefs).targettable;labelKeyColumn=crossCellContext.relation[0]['join-field'];labelKeyRow=crossCellContext.relation[1]['join-field'];INTERMediator.crossTableStage=1;lineNode=document.createElement('TR');targetRepeater=ctComponentNodes[0].cloneNode(!0);lineNode.appendChild(targetRepeater);node.appendChild(lineNode);targetRepeater=ctComponentNodes[1].cloneNode(!0);colContext=enclosureProcessing(lineNode,[targetRepeater],null,parentObjectInfo,currentContextObj);colArray=colContext.indexingArray(labelKeyColumn);INTERMediator.crossTableStage=2;targetRepeater=ctComponentNodes[2].cloneNode(!0);lineNode=document.createElement('TR');lineNode.appendChild(targetRepeater);rowContext=enclosureProcessing(node,[lineNode],null,parentObjectInfo,currentContextObj);rowArray=rowContext.indexingArray(labelKeyRow);INTERMediator.crossTableStage=3;targetRepeater=ctComponentNodes[3].cloneNode(!0);nodeForKeyValues={};trNodes=node.getElementsByTagName('TR');for(i=1;i<trNodes.length;i+=1){for(j=0;j<colArray.length;j+=1){appendingNode=targetRepeater.cloneNode(!0);trNodes[i].appendChild(appendingNode);INTERMediator.setIdValue(appendingNode);if(!nodeForKeyValues[colArray[j]]){nodeForKeyValues[colArray[j]]={}}
nodeForKeyValues[colArray[j]][rowArray[i-1]]=appendingNode}}
INTERMediator.setIdValue(node);enclosureProcessing(node,[targetRepeater],null,parentObjectInfo,currentContextObj,function(context){var currentContextDef=context.getContextDef();INTERMediator.clearCondition(currentContextDef.name,'_imlabel_crosstable');INTERMediator.addCondition(currentContextDef.name,{field:currentContextDef.relation[0]['foreign-key'],operator:'IN',value:colArray,onetime:!0},undefined,'_imlabel_crosstable');INTERMediator.addCondition(currentContextDef.name,{field:currentContextDef.relation[1]['foreign-key'],operator:'IN',value:rowArray,onetime:!0},undefined,'_imlabel_crosstable')},function(contextObj,targetRecords){var dataKeyColumn,dataKeyRow,currentContextDef,ix,linkedElements,targetNode,keyField,keyValue,keyingValue;currentContextDef=contextObj.getContextDef();keyField=contextObj.getKeyField();dataKeyColumn=currentContextDef.relation[0]['foreign-key'];dataKeyRow=currentContextDef.relation[1]['foreign-key'];if(targetRecords.recordset){for(ix=0;ix<targetRecords.recordset.length;ix++){record=targetRecords.recordset[ix];if(nodeForKeyValues[record[dataKeyColumn]]&&nodeForKeyValues[record[dataKeyColumn]][record[dataKeyRow]]){targetNode=nodeForKeyValues[record[dataKeyColumn]][record[dataKeyRow]];if(targetNode){linkedElements=INTERMediatorLib.seekLinkedAndWidgetNodes([targetNode],!1);keyValue=record[keyField];if(keyField&&!keyValue&&keyValue!==0){keyValue=ix}
keyingValue=keyField+'='+keyValue}
setupLinkedNode(linkedElements,contextObj,targetRecords.recordset,ix,keyingValue)}}}})}
function crossTableComponents(node){var components=[],count=0;repeatCTComponents(node.childNodes);return components;function repeatCTComponents(nodes){var childNodes,i;for(i=0;i<nodes.length;i++){if(nodes[i].nodeType===1&&(nodes[i].tagName==='TH'||nodes[i].tagName==='TD')){components[count]=nodes[i];count+=1}else{childNodes=nodes[i].childNodes;if(childNodes){repeatCTComponents(childNodes)}}}}}}
function setupLinkedNode(linkedElements,contextObj,targetRecordset,ix,keyingValue){var currentWidgetNodes,currentLinkedNodes,nInfo,currentContextDef,j,keyField,k,nodeId,curVal,replacedNode,typeAttr,children,wInfo,nameTable,idValuesForFieldName={},linkInfoArray,nameTableKey,nameNumber,nameAttr,curTarget;currentContextDef=contextObj.getContextDef();try{currentWidgetNodes=linkedElements.widgetNode;currentLinkedNodes=linkedElements.linkedNode;keyField=contextObj.getKeyField();if(targetRecordset[ix]&&(targetRecordset[ix][keyField]||targetRecordset[ix][keyField]===0)){for(k=0;k<currentLinkedNodes.length;k++){nodeId=currentLinkedNodes[k].getAttribute('id');replacedNode=INTERMediator.setIdValue(currentLinkedNodes[k]);typeAttr=replacedNode.getAttribute('type');if(typeAttr==='checkbox'||typeAttr==='radio'){children=replacedNode.parentNode.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1&&children[i].tagName==='LABEL'&&nodeId===children[i].getAttribute('for')){children[i].setAttribute('for',replacedNode.getAttribute('id'));break}}}}
for(k=0;k<currentWidgetNodes.length;k++){wInfo=INTERMediatorLib.getWidgetInfo(currentWidgetNodes[k]);if(wInfo[0]){IMParts_Catalog[wInfo[0]].instanciate(currentWidgetNodes[k]);if(imPartsShouldFinished.indexOf(IMParts_Catalog[wInfo[0]])<0){imPartsShouldFinished.push(IMParts_Catalog[wInfo[0]])}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-101')}}
nameTable={};for(k=0;k<currentLinkedNodes.length;k++){try{nodeId=currentLinkedNodes[k].getAttribute('id');if(INTERMediatorLib.isWidgetElement(currentLinkedNodes[k])){nodeId=currentLinkedNodes[k]._im_getComponentId()}
typeAttr=currentLinkedNodes[k].getAttribute('type');linkInfoArray=INTERMediatorLib.getLinkedElementInfo(currentLinkedNodes[k]);if(typeAttr==='radio'){nameTableKey=linkInfoArray.join('|');if(!nameTable[nameTableKey]){nameTable[nameTableKey]=nameAttrCounter;nameAttrCounter++}
nameNumber=nameTable[nameTableKey];nameAttr=currentLinkedNodes[k].getAttribute('name');if(nameAttr){currentLinkedNodes[k].setAttribute('name',nameAttr+'-'+nameNumber)}else{currentLinkedNodes[k].setAttribute('name','IM-R-'+nameNumber)}}
for(j=0;j<linkInfoArray.length;j++){nInfo=INTERMediatorLib.getNodeInfoArray(linkInfoArray[j]);curVal=targetRecordset[ix][nInfo.field];if(!INTERMediator.isDBDataPreferable||curVal){IMLibCalc.updateCalculationInfo(contextObj,keyingValue,nodeId,nInfo,targetRecordset[ix])}
if(nInfo.table===currentContextDef.name){curTarget=nInfo.target;if(IMLibElement.setValueToIMNode(currentLinkedNodes[k],curTarget,curVal)){postSetFields.push({'id':nodeId,'value':curVal})}
contextObj.setValue(keyingValue,nInfo.field,curVal,nodeId,curTarget);if(idValuesForFieldName[nInfo.field]===undefined){idValuesForFieldName[nInfo.field]=[]}
idValuesForFieldName[nInfo.field].push(nodeId)}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-27')}}}
return idValuesForFieldName}
function expandRepeaters(contextObj,node,targetRecords){var newNode,nodeClass,dataAttr,repeatersOneRec,newlyAddedNodes,encNodeTag,repNodeTag,ix,repeatersOriginal,targetRecordset,targetTotalCount,i,currentContextDef,indexContext,insertNode,countRecord,linkedElements,keyingValue,keyField,keyValue,idValuesForFieldName;encNodeTag=node.tagName;repNodeTag=INTERMediatorLib.repeaterTagFromEncTag(encNodeTag);repeatersOriginal=contextObj.original;currentContextDef=contextObj.getContextDef();targetRecordset=targetRecords.recordset;targetTotalCount=targetRecords.totalCount;repeatersOneRec=cloneEveryNodes(repeatersOriginal);for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}}}
if(targetRecords.count===0){for(i=0;i<repeatersOriginal.length;i++){newNode=repeatersOriginal[i].cloneNode(!0);nodeClass=INTERMediatorLib.getClassAttributeFromNode(newNode);dataAttr=newNode.getAttribute('data-im-control');if((nodeClass&&nodeClass.indexOf(INTERMediator.noRecordClassName)>-1)||(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>-1)){node.appendChild(newNode);INTERMediator.setIdValue(newNode);seekEnclosureNode(newNode,null,null,null)}}}
countRecord=targetRecordset?targetRecordset.length:0;for(ix=0;ix<countRecord;ix++){repeatersOneRec=cloneEveryNodes(repeatersOriginal);linkedElements=INTERMediatorLib.seekLinkedAndWidgetNodes(repeatersOneRec,!0);keyField=contextObj.getKeyField();for(i=0;i<repeatersOneRec.length;i++){INTERMediator.setIdValue(repeatersOneRec[i])}
if(targetRecordset[ix]&&(targetRecordset[ix][keyField]||targetRecordset[ix][keyField]===0)){keyValue=targetRecordset[ix][keyField];if(keyField&&!keyValue&&keyValue!==0){INTERMediatorLog.setErrorMessage('The value of the key field is null.','This No.['+ix+'] record should be ignored.');keyValue=ix}
keyingValue=keyField+'='+keyValue}
idValuesForFieldName=setupLinkedNode(linkedElements,contextObj,targetRecordset,ix,keyingValue);IMLibPageNavigation.setupDeleteButton(encNodeTag,repeatersOneRec,contextObj,keyField,keyValue);IMLibPageNavigation.setupNavigationButton(encNodeTag,repeatersOneRec,currentContextDef,keyField,keyValue,contextObj);IMLibPageNavigation.setupCopyButton(encNodeTag,repNodeTag,repeatersOneRec,contextObj,targetRecordset[ix]);if(!currentContextDef.portal||(!!currentContextDef.portal&&targetTotalCount>0)){newlyAddedNodes=[];insertNode=null;if(!contextObj.sequencing){indexContext=contextObj.checkOrder(targetRecordset[ix]);insertNode=contextObj.getRepeaterEndNode(indexContext+1)}
for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];nodeClass=INTERMediatorLib.getClassAttributeFromNode(newNode);dataAttr=newNode.getAttribute('data-im-control');if(!(nodeClass&&nodeClass.indexOf(INTERMediator.noRecordClassName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)&&!(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)){if(!insertNode){node.appendChild(newNode)}else{insertNode.parentNode.insertBefore(newNode,insertNode)}
newlyAddedNodes.push(newNode);if(!newNode.id){INTERMediator.setIdValue(newNode)}
contextObj.setValue(keyingValue,'_im_repeater','',newNode.id,'',currentContextDef.portal);seekEnclosureNode(newNode,targetRecordset[ix],idValuesForFieldName,contextObj)}}
if((ix+1)!==countRecord){for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}else{insertNode.parentNode.insertBefore(newNode,insertNode)}}}}
callbackForRepeaters(currentContextDef,node,newlyAddedNodes)}
contextObj.rearrangePendingOrder()}
IMLibPageNavigation.setupDetailAreaToFirstRecord(currentContextDef,contextObj);repeatersOneRec=cloneEveryNodes(repeatersOriginal);for(i=0;i<repeatersOneRec.length;i++){newNode=repeatersOneRec[i];dataAttr=newNode.getAttribute('data-im-control');if(dataAttr&&dataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0){if(!insertNode){node.appendChild(newNode)}}}}
function retrieveDataForEnclosure(contextObj,fieldList,relationValue){var targetRecords,recordNumber,useLimit,key,recordset=[];if(Boolean(contextObj.contextDefinition.cache)===!0){targetRecords=retrieveDataFromCache(contextObj.contextDefinition,relationValue)}else if(contextObj.contextDefinition.data){for(key in contextObj.contextDefinition.data){if(contextObj.contextDefinition.data.hasOwnProperty(key)){recordset.push(contextObj.contextDefinition.data[key])}}
targetRecords={'recordset':recordset,'count':recordset.length,'totalCount':recordset.length,'nullAcceptable':!0}}else{try{targetRecords=contextObj.getPortalRecords();if(!targetRecords){useLimit=contextObj.isUseLimit();recordNumber=contextObj.getRecordNumber();targetRecords=INTERMediator_DBAdapter.db_query({'name':contextObj.contextDefinition.name,'records':isNaN(recordNumber)?100000000:recordNumber,'paging':contextObj.contextDefinition.paging,'fields':fieldList,'parentkeyvalue':relationValue,'conditions':null,'useoffset':!0,'uselimit':useLimit})}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-12')}}}
if(contextObj.contextDefinition['appending-data']){for(key in contextObj.contextDefinition['appending-data']){if(contextObj.contextDefinition['appending-data'].hasOwnProperty(key)){targetRecords.recordset.push(contextObj.contextDefinition['appending-data'][key])}}}
return targetRecords}
function retrieveDataFromCache(currentContextDef,relationValue){var targetRecords=null,pagingValue,counter,ix,oneRecord,isMatch,index,keyField,fieldName,recordsValue;try{if(!INTERMediatorOnPage.dbCache[currentContextDef.name]){INTERMediatorOnPage.dbCache[currentContextDef.name]=INTERMediator_DBAdapter.db_query({name:currentContextDef.name,records:null,paging:null,fields:null,parentkeyvalue:null,conditions:null,useoffset:!1})}
if(relationValue===null){targetRecords=INTERMediatorOnPage.dbCache[currentContextDef.name]}else{targetRecords={recordset:[],count:0};counter=0;for(ix in INTERMediatorOnPage.dbCache[currentContextDef.name].recordset){if(INTERMediatorOnPage.dbCache[currentContextDef.name].recordset.hasOwnProperty(ix)){oneRecord=INTERMediatorOnPage.dbCache[currentContextDef.name].recordset[ix];isMatch=!0;index=0;for(keyField in relationValue){if(relationValue.hasOwnProperty(keyField)){fieldName=currentContextDef.relation[index]['foreign-key'];if(oneRecord[fieldName]!==relationValue[keyField]){isMatch=!1;break}
index++}}
if(isMatch){pagingValue=currentContextDef.paging?currentContextDef.paging:!1;recordsValue=currentContextDef.records?currentContextDef.records:10000000000;if(!pagingValue||(pagingValue&&(counter>=INTERMediator.startFrom))){targetRecords.recordset.push(oneRecord);targetRecords.count++;if(recordsValue<=targetRecords.count){break}}
counter++}}}
return targetRecords}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-24')}}}
function callbackForRepeaters(currentContextDef,node,newlyAddedNodes){try{if(INTERMediatorOnPage.additionalExpandingRecordFinish[currentContextDef.name]){INTERMediatorOnPage.additionalExpandingRecordFinish[currentContextDef.name](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.additionalExpandingRecordFinish['+currentContextDef.name+'] with the context.',2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-33: hint: post-repeater of '+currentContextDef.name)}}
try{if(INTERMediatorOnPage.expandingRecordFinish){INTERMediatorOnPage.expandingRecordFinish(currentContextDef.name,newlyAddedNodes);INTERMediatorLog.setDebugMessage('Call INTERMediatorOnPage.expandingRecordFinish with the context: '+currentContextDef.name,2)}
if(currentContextDef['post-repeater']){INTERMediatorOnPage[currentContextDef['post-repeater']](newlyAddedNodes);INTERMediatorLog.setDebugMessage('Call the post repeater method INTERMediatorOnPage.'+currentContextDef['post-repeater']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-23')}}}
function callbackForEnclosure(currentContextDef,node){try{if(INTERMediatorOnPage.additionalExpandingEnclosureFinish[currentContextDef.name]){INTERMediatorOnPage.additionalExpandingEnclosureFinish[currentContextDef.name](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.additionalExpandingEnclosureFinish['+currentContextDef.name+'] with the context.',2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-32: hint: post-enclosure of '+currentContextDef.name)}}
try{if(INTERMediatorOnPage.expandingEnclosureFinish){INTERMediatorOnPage.expandingEnclosureFinish(currentContextDef.name,node);INTERMediatorLog.setDebugMessage('Call INTERMediatorOnPage.expandingEnclosureFinish with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-21')}}
try{if(currentContextDef['post-enclosure']){INTERMediatorOnPage[currentContextDef['post-enclosure']](node);INTERMediatorLog.setDebugMessage('Call the post enclosure method INTERMediatorOnPage.'+currentContextDef['post-enclosure']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-22: hint: post-enclosure of '+currentContextDef.name)}}}
function callbackForAfterQueryStored(currentContextDef,context){try{if(currentContextDef['post-query-stored']){INTERMediatorOnPage[currentContextDef['post-query-stored']](context);INTERMediatorLog.setDebugMessage('Call the post query stored method INTERMediatorOnPage.'+currentContextDef['post-enclosure']+' with the context: '+currentContextDef.name,2)}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-41: hint: post-query-stored of '+currentContextDef.name)}}}
function collectRepeatersOriginal(node,repNodeTag){var i,repeatersOriginal=[],children,imControl;children=node.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(children[i].tagName===repNodeTag){repeatersOriginal.push(children[i])}else if(!repNodeTag&&(children[i].getAttribute('data-im-control'))){imControl=children[i].getAttribute('data-im-control');if(imControl.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>-1||imControl.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>-1){repeatersOriginal.push(children[i])}}else if(!repNodeTag&&INTERMediatorLib.getClassAttributeFromNode(children[i])&&INTERMediatorLib.getClassAttributeFromNode(children[i]).match(/_im_repeater/)){imControl=INTERMediatorLib.getClassAttributeFromNode(children[i]);if(imControl.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>-1){repeatersOriginal.push(children[i])}}}}
return repeatersOriginal}
function collectRepeaters(repeatersOriginal){var i,repeaters=[],inDocNode,parentOfRep,cloneNode;for(i=0;i<repeatersOriginal.length;i++){inDocNode=repeatersOriginal[i];parentOfRep=repeatersOriginal[i].parentNode;cloneNode=repeatersOriginal[i].cloneNode(!0);repeaters.push(cloneNode);cloneNode.setAttribute('id',INTERMediator.nextIdValue());if(parentOfRep){parentOfRep.removeChild(inDocNode)}}
return repeaters}
function collectLinkDefinitions(linkedNodes){var linkDefs=[],nodeDefs,j,k;for(j=0;j<linkedNodes.length;j++){nodeDefs=INTERMediatorLib.getLinkedElementInfo(linkedNodes[j]);if(nodeDefs){for(k=0;k<nodeDefs.length;k++){linkDefs.push(nodeDefs[k])}}}
return linkDefs}
function tableVoting(linkDefs){var j,nodeInfoArray,nodeInfoField,nodeInfoTable,maxVoted,maxTableName,tableName,nodeInfoTableIndex,context,restDefs=[],tableVote=[],fieldList=[];for(j=0;j<linkDefs.length;j++){nodeInfoArray=INTERMediatorLib.getNodeInfoArray(linkDefs[j]);nodeInfoField=nodeInfoArray.field;nodeInfoTable=nodeInfoArray.table;nodeInfoTableIndex=nodeInfoArray.tableindex;if(nodeInfoTable!=IMLibLocalContext.contextName){if(nodeInfoField&&nodeInfoField.length!==0&&nodeInfoTable&&nodeInfoTable.length!==0){if(!fieldList[nodeInfoTableIndex]){fieldList[nodeInfoTableIndex]=[]}
fieldList[nodeInfoTableIndex].push(nodeInfoField);if(!tableVote[nodeInfoTableIndex]){tableVote[nodeInfoTableIndex]=1}else{++tableVote[nodeInfoTableIndex]}}else{INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1006,[linkDefs[j]]))}}}
maxVoted=-1;maxTableName='';for(tableName in tableVote){if(tableVote.hasOwnProperty(tableName)){if(maxVoted<tableVote[tableName]){maxVoted=tableVote[tableName];maxTableName=tableName.substring(10)}}}
context=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',maxTableName);if(linkDefs.length>0&&!context){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1046,[maxTableName]))}
for(j=0;j<linkDefs.length;j++){if(linkDefs[j].indexOf(maxTableName)!==0&&linkDefs[j].indexOf('_@')!==0){restDefs.push(linkDefs[j])}}
if(linkDefs.length>0&&context&&restDefs.length>0){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1047,[maxTableName,restDefs.toString()]))}
return{targettable:context,fieldlist:fieldList['_im_index_'+maxTableName]}}
function cloneEveryNodes(originalNodes){var i,clonedNodes=[];for(i=0;i<originalNodes.length;i++){clonedNodes.push(originalNodes[i].cloneNode(!0))}
return clonedNodes}
function getEnclosedNode(rootNode,tableName,fieldName){var i,j,nodeInfo,nInfo,children,r;if(rootNode.nodeType===1){nodeInfo=INTERMediatorLib.getLinkedElementInfo(rootNode);for(j=0;j<nodeInfo.length;j++){nInfo=INTERMediatorLib.getNodeInfoArray(nodeInfo[j]);if(nInfo.table===tableName&&nInfo.field===fieldName){return rootNode}}}
children=rootNode.childNodes;for(i=0;i<children.length;i++){r=getEnclosedNode(children[i],tableName,fieldName);if(r){return r}}
return null}
function appendCredit(){var bodyNode,creditNode,cNode,spNode,aNode,versionString;if(document.getElementById('IM_CREDIT')===null){if(INTERMediatorOnPage.creditIncluding){bodyNode=document.getElementById(INTERMediatorOnPage.creditIncluding)}
if(!bodyNode){bodyNode=document.getElementsByTagName('BODY')[0]}
creditNode=document.createElement('div');bodyNode.appendChild(creditNode);creditNode.setAttribute('id','IM_CREDIT');creditNode.setAttribute('class','IM_CREDIT');cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#F6F7FF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#EBF1FF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.style.backgroundColor='#E1EAFF';cNode.style.height='2px';cNode.style.margin='0';cNode.style.padding='0';cNode=document.createElement('div');creditNode.appendChild(cNode);cNode.setAttribute('align','right');cNode.style.backgroundColor='#D7E4FF';cNode.style.padding='2px';cNode.style.margin='0';cNode.style.padding='0';spNode=document.createElement('span');cNode.appendChild(spNode);cNode.style.color='#666666';cNode.style.fontSize='7pt';aNode=document.createElement('a');aNode.appendChild(document.createTextNode('INTER-Mediator'));aNode.setAttribute('href','http://inter-mediator.com/');aNode.setAttribute('target','_href');spNode.appendChild(document.createTextNode('Generated by '));spNode.appendChild(aNode);if(INTERMediatorOnPage.metadata){versionString=' Ver.'+INTERMediatorOnPage.metadata.version+'('+INTERMediatorOnPage.metadata.releasedate+')'}else{versionString=' Ver. Development Now!'}
spNode.appendChild(document.createTextNode(versionString))}}},setIdValue:function(node){'use strict';var i,elementInfo,comp,overwrite=!0;if(node.getAttribute('id')===null){node.setAttribute('id',INTERMediator.nextIdValue())}else{if(INTERMediator.elementIds.indexOf(node.getAttribute('id'))>=0){elementInfo=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<elementInfo.length;i++){comp=elementInfo[i].split(INTERMediator.separator);if(comp[2]==='#id'){overwrite=!1}}
if(overwrite){node.setAttribute('id',INTERMediator.nextIdValue())}}
INTERMediator.elementIds.push(node.getAttribute('id'))}
return node},nextIdValue:function(){'use strict';INTERMediator.linkedElmCounter++;return currentIdValue();function currentIdValue(){return'IM'+INTERMediator.currentEncNumber+'-'+INTERMediator.linkedElmCounter}},getLocalProperty:function(localKey,defaultValue){'use strict';var value;value=IMLibLocalContext.getValue(localKey);return value===null?defaultValue:value},setLocalProperty:function(localKey,value){'use strict';IMLibLocalContext.setValue(localKey,value,!0)},addCondition:function(contextName,condition,notMatching,label){'use strict';var value,i,hasIdentical;if(notMatching){condition.matching=!notMatching}else{condition.matching=INTERMediator_DBAdapter.eliminateDuplicatedConditions}
if(label){condition.label=label}
if(INTERMediator.additionalCondition){value=INTERMediator.additionalCondition;if(condition){if(!value[contextName]){value[contextName]=[]}
if(!condition.matching){value[contextName].push(condition)}else{hasIdentical=!1;for(i=0;i<value[contextName].length;i++){if(value[contextName][i].field===condition.field&&value[contextName][i].operator===condition.operator){hasIdentical=!0;value[contextName][i].value=condition.value;break}}
if(!hasIdentical){value[contextName].push(condition)}}}
INTERMediator.additionalCondition=value}
IMLibLocalContext.archive()},clearCondition:function(contextName,label){'use strict';var i,value=INTERMediator.additionalCondition;if(label===undefined){if(value[contextName]){delete value[contextName];INTERMediator.additionalCondition=value;IMLibLocalContext.archive()}}else{if(value[contextName]){for(i=0;i<value[contextName].length;i++){if(value[contextName][i].label===label){value[contextName].splice(i,1);i--}}
INTERMediator.additionalCondition=value;IMLibLocalContext.archive()}}},addSortKey:function(contextName,sortKey){'use strict';var value=INTERMediator.additionalSortKey;if(value[contextName]){value[contextName].push(sortKey)}else{value[contextName]=[sortKey]}
INTERMediator.additionalSortKey=value;IMLibLocalContext.archive()},clearSortKey:function(contextName){'use strict';var value=INTERMediator.additionalSortKey;if(value[contextName]){delete value[contextName];INTERMediator.additionalSortKey=value;IMLibLocalContext.archive()}},setRecordLimit:function(contextName,limit){'use strict';var value=INTERMediator.recordLimit;value[contextName]=limit;INTERMediator.recordLimit=value;IMLibLocalContext.archive()},clearRecordLimit:function(contextName){'use strict';var value=INTERMediator.recordLimit;if(value[contextName]){delete value[contextName];INTERMediator.recordLimit=value;IMLibLocalContext.archive()}},flushMessage:function(){'use strict';INTERMediatorLog.flushMessage()},setErrorMessage:function(ex,moreMessage){'use strict';INTERMediatorLog.setErrorMessage(ex,moreMessage)},setDebugMessage:function(message,level){'use strict';INTERMediatorLog.setDebugMessage(message,level)}};if(!Object.keys){Object.keys=function(obj){'use strict';var results=[],prop;if(obj!==Object(obj)){throw new TypeError('Object.keys called on a non-object')}
for(prop in obj){if(Object.prototype.hasOwnProperty.call(obj,prop)){results.push(prop)}}
return results}}
if(!Array.indexOf){var isWebkit='WebkitAppearance' in document.documentElement.style;if(!isWebkit){Array.prototype.indexOf=function(target){'use strict';var i;for(i=0;i<this.length;i++){if(this[i]===target){return i}}
return-1}}}
if(typeof String.prototype.trim!=='function'){String.prototype.trim=function(){'use strict';return this.replace(/^\s+|\s+$/g,'')}}
var INTERMediatorOnPage={authCountLimit:4,authCount:0,authUser:'',authHashedPassword:'',authCryptedPassword:'',authUserSalt:'',authUserHexSalt:'',authChallenge:'',requireAuthentication:!1,clientId:null,authRequiredContext:null,authStoring:'cookie',authExpired:3600,isOnceAtStarting:!0,publickey:null,isNativeAuth:!1,httpuser:null,httppasswd:null,mediaToken:null,realm:'',dbCache:{},isEmailAsUsername:!1,passwordPolicy:null,creditIncluding:null,masterScrollPosition:null,nonSupportMessageId:'nonsupportmessage',isFinishToConstruct:!1,isAutoConstruct:!0,isShowChangePassword:!0,isSetDefaultStyle:!1,authPanelTitle:null,isOAuthAvailable:!1,oAuthClientID:null,oAuthClientSecret:null,oAuthBaseURL:null,oAuthRedirect:null,oAuthScope:null,additionalExpandingEnclosureFinish:{},additionalExpandingRecordFinish:{},getEditorPath:null,getEntryPath:null,getIMRootPath:null,getDataSources:null,getOptionsAliases:null,getOptionsTransaction:null,dbClassName:null,defaultKeyName:null,browserCompatibility:null,clientNotificationIdentifier:null,metadata:null,isLDAP:null,appLocale:null,localeInfo:{mon_decimal_point:'.',mon_thousands_sep:',',currency_symbol:'¥'},appCurrency:null,isShowProgress:!0,clearCredentials:function(){'use strict';INTERMediatorOnPage.authChallenge=null;INTERMediatorOnPage.authHashedPassword=null;INTERMediatorOnPage.authCryptedPassword=null},getMessages:function(){'use strict';return null},getURLParametersAsArray:function(){'use strict';var i,params,eqPos,result,key,value;result={};params=location.search.substring(1).split('&');for(i=0;i<params.length;i++){eqPos=params[i].indexOf('=');if(eqPos>0){key=params[i].substring(0,eqPos);value=params[i].substring(eqPos+1);result[key]=decodeURIComponent(value)}}
return result},getContextInfo:function(contextName){'use strict';var dataSources,index;dataSources=INTERMediatorOnPage.getDataSources();for(index in dataSources){if(dataSources.hasOwnProperty(index)&&dataSources[index].name===contextName){return dataSources[index]}}
return null},isComplementAuthData:function(){'use strict';return INTERMediatorOnPage.authUser!==null&&INTERMediatorOnPage.authUser.length>0&&INTERMediatorOnPage.authHashedPassword!==null&&INTERMediatorOnPage.authHashedPassword.length>0&&INTERMediatorOnPage.authUserSalt!==null&&INTERMediatorOnPage.authUserSalt.length>0&&INTERMediatorOnPage.authChallenge!==null&&INTERMediatorOnPage.authChallenge.length>0},retrieveAuthInfo:function(){'use strict';if(INTERMediatorOnPage.requireAuthentication){if(INTERMediatorOnPage.isOnceAtStarting){switch(INTERMediatorOnPage.authStoring){case 'cookie':case 'cookie-domainwide':INTERMediatorOnPage.authUser=INTERMediatorOnPage.getCookie('_im_username');INTERMediatorOnPage.authHashedPassword=INTERMediatorOnPage.getCookie('_im_credential');INTERMediatorOnPage.mediaToken=INTERMediatorOnPage.getCookie('_im_mediatoken');INTERMediatorOnPage.authCryptedPassword=INTERMediatorOnPage.getCookie('_im_crypted');break;case 'session-storage':INTERMediatorOnPage.authUser=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_username');INTERMediatorOnPage.authHashedPassword=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_credential');INTERMediatorOnPage.mediaToken=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_mediatoken');INTERMediatorOnPage.authCryptedPassword=INTERMediatorOnPage.getSessionStorageWithFallDown('_im_crypted');break;default:INTERMediatorOnPage.removeCookie('_im_username');INTERMediatorOnPage.removeCookie('_im_credential');INTERMediatorOnPage.removeCookie('_im_mediatoken');INTERMediatorOnPage.removeCookie('_im_crypted');break}
INTERMediatorOnPage.isOnceAtStarting=!1}
if(INTERMediatorOnPage.authUser.length>0){if(!INTERMediator_DBAdapter.getChallenge()){INTERMediatorLog.flushMessage()}}}},logout:function(){'use strict';INTERMediatorOnPage.authUser='';INTERMediatorOnPage.authHashedPassword='';INTERMediatorOnPage.authCryptedPassword='';INTERMediatorOnPage.authUserSalt='';INTERMediatorOnPage.authChallenge='';INTERMediatorOnPage.clientId='';INTERMediatorOnPage.removeCredencialsFromCookieOrStorage();INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_localcontext')},storeSessionStorageWithFallDown:function(key,value){'use strict';if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{sessionStorage.setItem(INTERMediatorOnPage.getKeyWithRealm(key),value)}catch(ex){INTERMediatorOnPage.setCookie(key,value)}}else{INTERMediatorOnPage.setCookie(key,value)}},getSessionStorageWithFallDown:function(key){'use strict';var value;if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{value=sessionStorage.getItem(INTERMediatorOnPage.getKeyWithRealm(key));value=value?value:''}catch(ex){value=INTERMediatorOnPage.getCookie(key)}}else{value=INTERMediatorOnPage.getCookie(key)}
return value},removeFromSessionStorageWithFallDown:function(key){'use strict';if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{sessionStorage.removeItem(INTERMediatorOnPage.getKeyWithRealm(key))}catch(ex){INTERMediatorOnPage.removeCookie(key)}}else{INTERMediatorOnPage.removeCookie(key)}},removeCredencialsFromCookieOrStorage:function(){'use strict';switch(INTERMediatorOnPage.authStoring){case 'cookie':case 'cookie-domainwide':INTERMediatorOnPage.removeCookie('_im_username');INTERMediatorOnPage.removeCookie('_im_credential');INTERMediatorOnPage.removeCookie('_im_mediatoken');INTERMediatorOnPage.removeCookie('_im_crypted');break;case 'session-storage':INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_username');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_credential');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_mediatoken');INTERMediatorOnPage.removeFromSessionStorageWithFallDown('_im_crypted');break}},storeCredentialsToCookieOrStorage:function(){'use strict';switch(INTERMediatorOnPage.authStoring){case 'cookie':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.setCookie('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.setCookie('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.setCookie('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.setCookie('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break;case 'cookie-domainwide':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.setCookieDomainWide('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.setCookieDomainWide('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.setCookieDomainWide('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.setCookieDomainWide('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break;case 'session-storage':if(INTERMediatorOnPage.authUser){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_username',INTERMediatorOnPage.authUser)}
if(INTERMediatorOnPage.authHashedPassword){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_credential',INTERMediatorOnPage.authHashedPassword)}
if(INTERMediatorOnPage.mediaToken){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_mediatoken',INTERMediatorOnPage.mediaToken)}
if(INTERMediatorOnPage.authCryptedPassword){INTERMediatorOnPage.storeSessionStorageWithFallDown('_im_crypted',INTERMediatorOnPage.authCryptedPassword)}
break}},loginPanelHTML:null,authenticating:function(doAfterAuth,doTest){'use strict';var bodyNode,backBox,frontPanel,labelWidth,userLabel,userSpan,userBox,msgNumber,passwordLabel,passwordSpan,passwordBox,breakLine,chgpwButton,authButton,panelTitle,newPasswordLabel,newPasswordSpan,newPasswordBox,newPasswordMessage,realmBox,keyCode,messageNode,oAuthButton,addingButton,resetMessage;var encrypt=new JSEncrypt();this.checkPasswordPolicy=function(newPassword,userName,policyString){var terms,i,message=[],minLen;if(!policyString){return message}
terms=policyString.split(/[\s,]/);for(i=0;i<terms.length;i++){switch(terms[i].toUpperCase()){case 'USEALPHABET':if(!newPassword.match(/[A-Za-z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2015))}
break;case 'USENUMBER':if(!newPassword.match(/[0-9]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2016))}
break;case 'USEUPPER':if(!newPassword.match(/[A-Z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2017))}
break;case 'USELOWER':if(!newPassword.match(/[a-z]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2018))}
break;case 'USEPUNCTUATION':if(!newPassword.match(/[^A-Za-z0-9]/)){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2019))}
break;case 'NOTUSERNAME':if(newPassword===userName){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2020))}
break;default:if(terms[i].toUpperCase().indexOf('LENGTH')===0){minLen=terms[i].match(/[0-9]+/)[0];if(newPassword.length<minLen){message.push(INTERMediatorLib.getInsertedStringFromErrorNumber(2021,[minLen]))}}}}
return message};if(doTest){return}
if(INTERMediatorOnPage.authCount>INTERMediatorOnPage.authCountLimit){INTERMediatorOnPage.authenticationError();INTERMediatorOnPage.logout();INTERMediatorLog.flushMessage();return}
bodyNode=document.getElementsByTagName('BODY')[0];backBox=document.createElement('div');backBox.id='_im_authpback';bodyNode.insertBefore(backBox,bodyNode.childNodes[0]);if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.height='100%';backBox.style.width='100%';backBox.style.backgroundImage='url('+INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=background.gif)';backBox.style.position='absolute';backBox.style.padding=' 50px 0 0 0';backBox.style.top='0';backBox.style.left='0';backBox.style.zIndex='999998'}
if(INTERMediatorOnPage.loginPanelHTML){backBox.innerHTML=INTERMediatorOnPage.loginPanelHTML;passwordBox=document.getElementById('_im_password');userBox=document.getElementById('_im_username');authButton=document.getElementById('_im_authbutton');chgpwButton=document.getElementById('_im_changebutton');oAuthButton=document.getElementById('_im_oauthbutton')}else{frontPanel=document.createElement('div');if(INTERMediatorOnPage.isSetDefaultStyle){frontPanel.style.width='450px';frontPanel.style.backgroundColor='#333333';frontPanel.style.color='#DDDDAA';frontPanel.style.margin='50px auto 0 auto';frontPanel.style.padding='20px';frontPanel.style.borderRadius='10px';frontPanel.style.position='relative'}
frontPanel.id='_im_authpanel';backBox.appendChild(frontPanel);panelTitle='';if(INTERMediatorOnPage.authPanelTitle&&INTERMediatorOnPage.authPanelTitle.length>0){panelTitle=INTERMediatorOnPage.authPanelTitle}else if(INTERMediatorOnPage.realm&&INTERMediatorOnPage.realm.length>0){panelTitle=INTERMediatorOnPage.realm}
if(panelTitle&&panelTitle.length>0){realmBox=document.createElement('DIV');realmBox.appendChild(document.createTextNode(panelTitle));realmBox.id='_im_authrealm';frontPanel.appendChild(realmBox);breakLine=document.createElement('HR');frontPanel.appendChild(breakLine)}
labelWidth='100px';userLabel=document.createElement('LABEL');frontPanel.appendChild(userLabel);userSpan=document.createElement('span');if(INTERMediatorOnPage.isSetDefaultStyle){userSpan.style.minWidth=labelWidth;userSpan.style.textAlign='right';userSpan.style.cssFloat='left'}
INTERMediatorLib.setClassAttributeToNode(userSpan,'_im_authlabel');userLabel.appendChild(userSpan);msgNumber=INTERMediatorOnPage.isEmailAsUsername?2011:2002;userSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(msgNumber)));userBox=document.createElement('INPUT');userBox.type='text';userBox.id='_im_username';userBox.size='20';userBox.setAttribute('autocapitalize','off');userLabel.appendChild(userBox);breakLine=document.createElement('BR');breakLine.clear='all';frontPanel.appendChild(breakLine);passwordLabel=document.createElement('LABEL');frontPanel.appendChild(passwordLabel);passwordSpan=document.createElement('SPAN');if(INTERMediatorOnPage.isSetDefaultStyle){passwordSpan.style.minWidth=labelWidth;passwordSpan.style.textAlign='right';passwordSpan.style.cssFloat='left'}
INTERMediatorLib.setClassAttributeToNode(passwordSpan,'_im_authlabel');passwordLabel.appendChild(passwordSpan);passwordSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2003)));passwordBox=document.createElement('INPUT');passwordBox.type='password';passwordBox.id='_im_password';passwordBox.size='20';passwordLabel.appendChild(passwordBox);authButton=document.createElement('BUTTON');authButton.id='_im_authbutton';authButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2004)));frontPanel.appendChild(authButton);breakLine=document.createElement('BR');breakLine.clear='all';frontPanel.appendChild(breakLine);newPasswordMessage=document.createElement('DIV');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordMessage.style.textAlign='center';newPasswordMessage.style.textSize='10pt';newPasswordMessage.style.color='#994433'}
newPasswordMessage.id='_im_login_message';frontPanel.appendChild(newPasswordMessage);if(this.isShowChangePassword&&!INTERMediatorOnPage.isNativeAuth){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);newPasswordLabel=document.createElement('LABEL');frontPanel.appendChild(newPasswordLabel);newPasswordSpan=document.createElement('SPAN');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordSpan.style.minWidth=labelWidth;newPasswordSpan.style.textAlign='right';newPasswordSpan.style.cssFloat='left';newPasswordSpan.style.fontSize='0.7em';newPasswordSpan.style.paddingTop='4px'}
INTERMediatorLib.setClassAttributeToNode(newPasswordSpan,'_im_authlabel_pwchange');newPasswordLabel.appendChild(newPasswordSpan);newPasswordSpan.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2006)));newPasswordBox=document.createElement('INPUT');newPasswordBox.type='password';newPasswordBox.id='_im_newpassword';newPasswordBox.size='12';newPasswordLabel.appendChild(newPasswordBox);chgpwButton=document.createElement('BUTTON');chgpwButton.id='_im_changebutton';chgpwButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2005)));frontPanel.appendChild(chgpwButton);newPasswordMessage=document.createElement('DIV');if(INTERMediatorOnPage.isSetDefaultStyle){newPasswordMessage.style.textAlign='center';newPasswordMessage.style.textSize='10pt';newPasswordMessage.style.color='#994433'}
newPasswordMessage.id='_im_newpass_message';frontPanel.appendChild(newPasswordMessage)}
if(this.isOAuthAvailable){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);oAuthButton=document.createElement('BUTTON');oAuthButton.id='_im_oauthbutton';oAuthButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2014)));frontPanel.appendChild(oAuthButton)}
if(INTERMediatorOnPage.enrollPageURL){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);addingButton=document.createElement('BUTTON');addingButton.id='_im_enrollbutton';addingButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2022)));addingButton.onclick=function(){location.href=INTERMediatorOnPage.enrollPageURL};frontPanel.appendChild(addingButton)}
if(INTERMediatorOnPage.resetPageURL){breakLine=document.createElement('HR');frontPanel.appendChild(breakLine);addingButton=document.createElement('BUTTON');addingButton.id='_im_resetbutton';addingButton.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2023)));addingButton.onclick=function(){location.href=INTERMediatorOnPage.resetPageURL};frontPanel.appendChild(addingButton);resetMessage=document.createElement('div');resetMessage.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2024)));frontPanel.appendChild(resetMessage)}}
passwordBox.onkeydown=function(event){keyCode=(window.event)?window.event.which:event.keyCode;if(keyCode===13){authButton.onclick()}};userBox.value=INTERMediatorOnPage.authUser;userBox.onkeydown=function(event){keyCode=(window.event)?window.event.which:event.keyCode;if(keyCode===13){passwordBox.focus()}};authButton.onclick=function(){var inputUsername,inputPassword,challengeResult,messageNode;messageNode=document.getElementById('_im_newpass_message');if(messageNode){INTERMediatorLib.removeChildNodes(messageNode)}
inputUsername=document.getElementById('_im_username').value;inputPassword=document.getElementById('_im_password').value;if(inputUsername===''||inputPassword===''){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2013)));return}
INTERMediatorOnPage.authUser=inputUsername;bodyNode.removeChild(backBox);if(inputUsername!==''&&(INTERMediatorOnPage.authChallenge===null||INTERMediatorOnPage.authChallenge.length<24)){INTERMediatorOnPage.authHashedPassword='need-hash-pls';challengeResult=INTERMediator_DBAdapter.getChallenge();if(!challengeResult){INTERMediatorLog.flushMessage();return}}
encrypt.setPublicKey(INTERMediatorOnPage.publickey);INTERMediatorOnPage.authCryptedPassword=encrypt.encrypt(inputPassword);INTERMediatorOnPage.authHashedPassword=SHA1(inputPassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt;if(INTERMediatorOnPage.authUser.length>0){INTERMediatorOnPage.storeCredentialsToCookieOrStorage()}
doAfterAuth();INTERMediatorLog.flushMessage()};if(chgpwButton){var checkPolicyMethod=this.checkPasswordPolicy;chgpwButton.onclick=function(){var inputUsername,inputPassword,inputNewPassword,result,messageNode,message;messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode=document.getElementById('_im_newpass_message');INTERMediatorLib.removeChildNodes(messageNode);inputUsername=document.getElementById('_im_username').value;inputPassword=document.getElementById('_im_password').value;inputNewPassword=document.getElementById('_im_newpassword').value;if(inputUsername===''||inputPassword===''||inputNewPassword===''){messageNode=document.getElementById('_im_newpass_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2007)));return}
message=checkPolicyMethod(inputNewPassword,inputUsername,INTERMediatorOnPage.passwordPolicy);if(message.length>0){messageNode.appendChild(document.createTextNode(message.join(', ')));return}
result=INTERMediator_DBAdapter.changePassword(inputUsername,inputPassword,inputNewPassword);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(result?2009:2010)));INTERMediatorLog.flushMessage()}}
if(this.isOAuthAvailable&&oAuthButton){oAuthButton.onclick=function(){var authURL;INTERMediatorOnPage.setCookieDomainWide('_im_oauth_backurl',location.href,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_realm',INTERMediatorOnPage.realm,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_expired',INTERMediatorOnPage.authExpired,!0);INTERMediatorOnPage.setCookieDomainWide('_im_oauth_storing',INTERMediatorOnPage.authStoring,!0);authURL=INTERMediatorOnPage.oAuthBaseURL+'?scope='+encodeURIComponent(INTERMediatorOnPage.oAuthScope)+'&redirect_uri='+encodeURIComponent(INTERMediatorOnPage.oAuthRedirect)+'&response_type=code'+'&client_id='+encodeURIComponent(INTERMediatorOnPage.oAuthClientID);location.href=authURL}}
if(INTERMediatorOnPage.publickeysize<2048){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2025)))}else if(INTERMediatorOnPage.authCount>0){messageNode=document.getElementById('_im_login_message');INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2012)))}
window.scroll(0,0);userBox.focus();INTERMediatorOnPage.authCount++},authenticationError:function(){'use strict';var bodyNode,backBox,frontPanel;INTERMediatorOnPage.hideProgress();bodyNode=document.getElementsByTagName('BODY')[0];backBox=document.createElement('div');backBox.id='_im_autherrorback';bodyNode.insertBefore(backBox,bodyNode.childNodes[0]);if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.height='100%';backBox.style.width='100%';if(INTERMediatorOnPage.isSetDefaultStyle){backBox.style.backgroundImage='url('+INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=background-error.gif)'}
backBox.style.position='absolute';backBox.style.padding=' 50px 0 0 0';backBox.style.top='0';backBox.style.left='0';backBox.style.zIndex='999999'}
frontPanel=document.createElement('div');frontPanel.id='_im_autherrormessage';if(INTERMediatorOnPage.isSetDefaultStyle){frontPanel.style.width='240px';frontPanel.style.backgroundColor='#333333';frontPanel.style.color='#DD6666';frontPanel.style.fontSize='16pt';frontPanel.style.margin='50px auto 0 auto';frontPanel.style.padding='20px 4px 20px 4px';frontPanel.style.borderRadius='10px';frontPanel.style.position='relatvie';frontPanel.style.textAlign='Center'}
frontPanel.onclick=function(){bodyNode.removeChild(backBox)};backBox.appendChild(frontPanel);frontPanel.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2001)))},INTERMediatorCheckBrowser:function(deleteNode){'use strict';var positiveList,matchAgent,matchOS,versionStr,agent,os,judge=!1,specifiedVersion,versionNum,agentPos=-1,dotPos,bodyNode,elm,childElm,grandChildElm,i;positiveList=INTERMediatorOnPage.browserCompatibility();matchAgent=!1;matchOS=!1;if(positiveList.edge&&navigator.userAgent.indexOf('Edge/')>-1){positiveList={'edge':positiveList.edge}}else if(positiveList.trident&&navigator.userAgent.indexOf('Trident/')>-1){positiveList={'trident':positiveList.trident}}else if(positiveList.msie&&navigator.userAgent.indexOf('MSIE ')>-1){positiveList={'msie':positiveList.msie}}else if(positiveList.opera&&(navigator.userAgent.indexOf('Opera/')>-1||navigator.userAgent.indexOf('OPR/')>-1)){positiveList={'opera':positiveList.opera,'opr':positiveList.opera}}
for(agent in positiveList){if(positiveList.hasOwnProperty(agent)){if(navigator.userAgent.toUpperCase().indexOf(agent.toUpperCase())>-1){matchAgent=!0;if(positiveList[agent]instanceof Object){for(os in positiveList[agent]){if(positiveList[agent].hasOwnProperty(os)&&navigator.platform.toUpperCase().indexOf(os.toUpperCase())>-1){matchOS=!0;versionStr=positiveList[agent][os];break}}}else{matchOS=!0;versionStr=positiveList[agent];break}}}}
if(matchAgent&&matchOS){specifiedVersion=parseInt(versionStr,10);if(navigator.appVersion.indexOf('Edge/')>-1){agentPos=navigator.appVersion.indexOf('Edge/')+5}else if(navigator.appVersion.indexOf('Trident/')>-1){agentPos=navigator.appVersion.indexOf('Trident/')+8}else if(navigator.appVersion.indexOf('MSIE ')>-1){agentPos=navigator.appVersion.indexOf('MSIE ')+5}else if(navigator.appVersion.indexOf('OPR/')>-1){agentPos=navigator.appVersion.indexOf('OPR/')+4}else if(navigator.appVersion.indexOf('Opera/')>-1){agentPos=navigator.appVersion.indexOf('Opera/')+6}else if(navigator.appVersion.indexOf('Chrome/')>-1){agentPos=navigator.appVersion.indexOf('Chrome/')+7}else if(navigator.appVersion.indexOf('Safari/')>-1&&navigator.appVersion.indexOf('Version/')>-1){agentPos=navigator.appVersion.indexOf('Version/')+8}else if(navigator.userAgent.indexOf('Firefox/')>-1){agentPos=navigator.userAgent.indexOf('Firefox/')+8}else if(navigator.appVersion.indexOf('WebKit/')>-1){agentPos=navigator.appVersion.indexOf('WebKit/')+7}
if(agentPos>-1){if(navigator.userAgent.indexOf('Firefox/')>-1){dotPos=navigator.userAgent.indexOf('.',agentPos);versionNum=parseInt(navigator.userAgent.substring(agentPos,dotPos),10)}else{dotPos=navigator.appVersion.indexOf('.',agentPos);versionNum=parseInt(navigator.appVersion.substring(agentPos,dotPos),10)}}else{dotPos=navigator.appVersion.indexOf('.');versionNum=parseInt(navigator.appVersion.substring(0,dotPos),10)}
if(INTERMediator.isTrident){specifiedVersion=specifiedVersion+4}
if(versionStr.indexOf('-')>-1){judge=(specifiedVersion>=versionNum);if(document.documentMode){judge=(specifiedVersion>=document.documentMode)}}else if(versionStr.indexOf('+')>-1){judge=(specifiedVersion<=versionNum);if(document.documentMode){judge=(specifiedVersion<=document.documentMode)}}else{judge=(specifiedVersion===versionNum);if(document.documentMode){judge=(specifiedVersion===document.documentMode)}}}
if(judge===!0){if(deleteNode){deleteNode.parentNode.removeChild(deleteNode)}}else{bodyNode=document.getElementsByTagName('BODY')[0];elm=document.createElement('div');elm.setAttribute('align','center');childElm=document.createElement('font');childElm.setAttribute('color','gray');grandChildElm=document.createElement('font');grandChildElm.setAttribute('size','+2');grandChildElm.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[1022]));childElm.appendChild(grandChildElm);childElm.appendChild(document.createElement('br'));childElm.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[1023]));childElm.appendChild(document.createElement('br'));childElm.appendChild(document.createTextNode(navigator.userAgent));elm.appendChild(childElm);for(i=bodyNode.childNodes.length-1;i>=0;i--){bodyNode.removeChild(bodyNode.childNodes[i])}
bodyNode.appendChild(elm)}
return judge},getNodeIdFromIMDefinition:function(imDefinition,fromNode,justFromNode){'use strict';console.error('INTERMediatorOnPage.getNodeIdFromIMDefinition method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'The alternative method is getNodeIdsHavingTargetFromNode or getNodeIdsHavingTargetFromRepeater.');var repeaterNode;if(justFromNode){repeaterNode=fromNode}else{repeaterNode=INTERMediatorLib.getParentRepeater(fromNode)}
return seekNode(repeaterNode,imDefinition);function seekNode(node,imDefinition){var children,i,nodeDefs,returnValue;if(node.nodeType!==1){return null}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[i])){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs.indexOf(imDefinition)>-1){returnValue=children[i].getAttribute('id');return returnValue}}
returnValue=seekNode(children[i],imDefinition);if(returnValue!==null){return returnValue}}}}
return null}},getNodeIdFromIMDefinitionOnEnclosure:function(imDefinition,fromNode){'use strict';console.error('INTERMediatorOnPage.getNodeIdFromIMDefinitionOnEnclosure method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'The alternative method is getNodeIdsHavingTargetFromEnclosure.');var repeaterNode;repeaterNode=INTERMediatorLib.getParentEnclosure(fromNode);return seekNode(repeaterNode,imDefinition);function seekNode(node,imDefinition){var children,i,nodeDefs,returnValue;if(node.nodeType!==1){return null}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[i])){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs.indexOf(imDefinition)>-1&&children[i].getAttribute){returnValue=children[i].getAttribute('id');return returnValue}}
returnValue=seekNode(children[i],imDefinition);if(returnValue!==null){return returnValue}}}}
return null}},getNodeIdsFromIMDefinition:function(imDefinition,fromNode,justFromNode){'use strict';var enclosureNode,nodeIds=[],i,j;if(justFromNode===!0){enclosureNode=[fromNode]}else if(justFromNode===!1){enclosureNode=[INTERMediatorLib.getParentEnclosure(fromNode)]}else{enclosureNode=INTERMediatorLib.getParentRepeaters(fromNode)}
if(!enclosureNode){return[]}
for(i=0;i<enclosureNode.length;i+=1){if(enclosureNode[i]!==null){if(Array.isArray(enclosureNode[i])){for(j=0;j<enclosureNode[i].length;j++){seekNode(enclosureNode[i][j],imDefinition)}}else{seekNode(enclosureNode[i],imDefinition)}}}
return nodeIds;function seekNode(node,imDefinition){var children,i,nodeDefs;if(node.nodeType!==1){return}
children=node.childNodes;if(children){for(i=0;i<children.length;i++){if(children[i].nodeType===1){nodeDefs=INTERMediatorLib.getLinkedElementInfo(children[i]);if(nodeDefs&&nodeDefs.indexOf(imDefinition)>-1){if(children[i].getAttribute('id')){nodeIds.push(children[i].getAttribute('id'))}else{nodeIds.push(children[i])}}}
seekNode(children[i],imDefinition)}}}},getNodeIdsHavingTargetFromNode:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,!0)},getNodeIdsHavingTargetFromRepeater:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,'others')},getNodeIdsHavingTargetFromEnclosure:function(fromNode,imDefinition){'use strict';return INTERMediatorOnPage.getNodeIdsFromIMDefinition(imDefinition,fromNode,!1)},getKeyWithRealm:function(str){'use strict';if(INTERMediatorOnPage.realm.length>0){return str+'_'+INTERMediatorOnPage.realm}
return str},getCookie:function(key){'use strict';var s,i,targetKey;s=document.cookie.split('; ');targetKey=this.getKeyWithRealm(key);for(i=0;i<s.length;i++){if(s[i].indexOf(targetKey+'=')===0){return decodeURIComponent(s[i].substring(s[i].indexOf('=')+1))}}
return''},removeCookie:function(key){'use strict';document.cookie=this.getKeyWithRealm(key)+'=; path=/; max-age=0; expires=Thu, 1-Jan-1900 00:00:00 GMT;';document.cookie=this.getKeyWithRealm(key)+'=; max-age=0; expires=Thu, 1-Jan-1900 00:00:00 GMT;'},setCookie:function(key,val){'use strict';this.setCookieWorker(this.getKeyWithRealm(key),val,!1,INTERMediatorOnPage.authExpired)},setCookieDomainWide:function(key,val,noRealm){'use strict';var realKey;realKey=(noRealm===!0)?key:this.getKeyWithRealm(key);this.setCookieWorker(realKey,val,!0,INTERMediatorOnPage.authExpired)},setCookieWorker:function(key,val,isDomain,expired){'use strict';var cookieString;var d=new Date();d.setTime(d.getTime()+expired*1000);cookieString=key+'='+encodeURIComponent(val)+(isDomain?';path=/':'')+';';if(expired>0){cookieString+='max-age='+expired+';expires='+d.toUTCString()+';'}
if(document.URL.substring(0,8)==='https://'){cookieString+='secure;'}
document.cookie=cookieString},hideProgress:function(){'use strict';if(!INTERMediatorOnPage.isShowProgress){return}
var frontPanel,themeName;frontPanel=document.getElementById('_im_progress');if(frontPanel){themeName=INTERMediatorOnPage.getTheme().toLowerCase();if(themeName==='least'||themeName==='thosedays'){frontPanel.style.display='none'}else{frontPanel.style.transitionDuration='0.3s';frontPanel.style.opacity=0;frontPanel.style.zIndex=-9999}}},showProgress:function(){'use strict';if(!INTERMediatorOnPage.isShowProgress){return}
var brNode,bodyNode,frontPanel,imageProgress,imageIM,themeName=INTERMediatorOnPage.getTheme().toLowerCase();frontPanel=document.getElementById('_im_progress');if(!frontPanel){frontPanel=document.createElement('div');frontPanel.setAttribute('id','_im_progress');bodyNode=document.getElementsByTagName('BODY')[0];if(bodyNode.firstChild){bodyNode.insertBefore(frontPanel,bodyNode.firstChild)}else{bodyNode.appendChild(frontPanel)}
if(themeName==='least'||themeName==='thosedays'){imageIM=document.createElement('img');imageIM.setAttribute('id','_im_logo');imageIM.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=logo.gif');frontPanel.appendChild(imageIM);imageProgress=document.createElement('img');imageProgress.setAttribute('id','_im_animatedimage');imageProgress.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=inprogress.gif');frontPanel.appendChild(imageProgress);brNode=document.createElement('BR');brNode.setAttribute('clear','all');frontPanel.appendChild(brNode);frontPanel.appendChild(document.createTextNode('INTER-Mediator working'))}else{imageIM=document.createElement('img');imageIM.setAttribute('src',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=images&name=gears.svg');frontPanel.appendChild(imageIM)}}
if(themeName!=='least'&&themeName!=='thosedays'){frontPanel.style.transitionDuration='0';frontPanel.style.opacity=1.0;frontPanel.style.display='flex';frontPanel.style.zIndex=9999}},setReferenceToTheme:function(){'use strict';var headNode,linkElement,i,styleIndex=-1;headNode=document.getElementsByTagName('HEAD')[0];linkElement=document.createElement('link');linkElement.setAttribute('href',INTERMediatorOnPage.getEntryPath()+'?theme='+INTERMediatorOnPage.getTheme()+'&type=css');linkElement.setAttribute('rel','stylesheet');linkElement.setAttribute('type','text/css');for(i=0;i<headNode.childNodes.length;i++){if(headNode.childNodes[i]&&headNode.childNodes[i].nodeType===1&&headNode.childNodes[i].tagName==='LINK'&&headNode.childNodes[i].rel==='stylesheet'){styleIndex=i;break}}
if(styleIndex>-1){headNode.insertBefore(linkElement,headNode.childNodes[styleIndex])}else{headNode.appendChild(linkElement)}}};var IMLibContextPool={poolingContexts:null,clearAll:function(){'use strict';this.poolingContexts=null},registerContext:function(context){'use strict';if(this.poolingContexts===null){this.poolingContexts=[context]}else{this.poolingContexts.push(context)}},excludingNode:null,synchronize:function(context,recKey,key,value,target,portal){'use strict';var i,j,viewName,refNode,targetNodes,result=[],calcKey;viewName=context.viewName;if(this.poolingContexts===null){return null}
if(portal){for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].viewName===viewName&&this.poolingContexts[i].binding[recKey]!==undefined&&this.poolingContexts[i].binding[recKey][key]!==undefined&&this.poolingContexts[i].binding[recKey][key][portal]!==undefined&&this.poolingContexts[i].store[recKey]!==undefined&&this.poolingContexts[i].store[recKey][key]!==undefined&&this.poolingContexts[i].store[recKey][key][portal]!==undefined){this.poolingContexts[i].store[recKey][key][portal]=value;targetNodes=this.poolingContexts[i].binding[recKey][key][portal];for(j=0;j<targetNodes.length;j++){refNode=document.getElementById(targetNodes[j].id);if(refNode){IMLibElement.setValueToIMNode(refNode,targetNodes[j].target,value,!0);result.push(targetNodes[j].id)}}}}}else{for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].viewName===viewName&&this.poolingContexts[i].binding[recKey]!==undefined&&this.poolingContexts[i].binding[recKey][key]!==undefined&&this.poolingContexts[i].store[recKey]!==undefined&&this.poolingContexts[i].store[recKey][key]!==undefined){this.poolingContexts[i].store[recKey][key]=value;targetNodes=this.poolingContexts[i].binding[recKey][key];for(j=0;j<targetNodes.length;j++){refNode=document.getElementById(targetNodes[j].id);calcKey=targetNodes[j].id;if(targetNodes[j].target&&targetNodes[j].target.length>0){calcKey+=INTERMediator.separator+targetNodes[j].target}
if(refNode&&!(calcKey in IMLibCalc.calculateRequiredObject)){IMLibElement.setValueToIMNode(refNode,targetNodes[j].target,value,!0);result.push(targetNodes[j].id)}}}}}
return result},getContextInfoFromId:function(idValue,target){'use strict';var i,targetContext,element,linkInfo,nodeInfo,targetName,result=null;if(!idValue){return result}
element=document.getElementById(idValue);if(!element){return result}
linkInfo=INTERMediatorLib.getLinkedElementInfo(element);if(!linkInfo&&INTERMediatorLib.isWidgetElement(element.parentNode)){linkInfo=INTERMediatorLib.getLinkedElementInfo(element.parentNode)}
nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);targetName=target?target:'_im_no_target';if(this.poolingContexts===null){return null}
for(i=0;i<this.poolingContexts.length;i++){targetContext=this.poolingContexts[i];if(targetContext.contextInfo[idValue]&&targetContext.contextInfo[idValue][targetName]&&targetContext.contextInfo[idValue][targetName].context.contextName===nodeInfo.table){result=targetContext.contextInfo[idValue][targetName];return result}}
return null},getKeyFieldValueFromId:function(idValue,target){'use strict';var contextInfo=this.getContextInfoFromId(idValue,target);if(!contextInfo){return null}
var contextName=contextInfo.context.contextName;var contextDef=IMLibContextPool.getContextDef(contextName);if(!contextDef){return null}
var keyField=contextDef.key?contextDef.key:'id';return contextInfo.record.substr(keyField.length+1)},updateContext:function(idValue,target){'use strict';var contextInfo,value;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,target);value=IMLibElement.getValueFromIMNode(document.getElementById(idValue));if(contextInfo){contextInfo.context.setValue(contextInfo.record,contextInfo.field,value,!1,target,contextInfo.portal)}},getContextFromEnclosure:function(enclosureNode){'use strict';var i;for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].enclosureNode===enclosureNode){return this.poolingContexts[i]}}},contextFromEnclosureId:function(idValue){'use strict';var i,enclosure;if(!idValue){return!1}
for(i=0;i<this.poolingContexts.length;i++){enclosure=this.poolingContexts[i].enclosureNode;if(enclosure.getAttribute('id')===idValue){return this.poolingContexts[i]}}
return null},contextFromName:function(cName){'use strict';var i;if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName){return this.poolingContexts[i]}}
return null},getContextFromName:function(cName){'use strict';var i,result=[];if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName){result.push(this.poolingContexts[i])}}
return result},getContextsFromNameAndForeignValue:function(cName,fValue,parentKeyField){'use strict';var i,result=[];if(!cName){return!1}
for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].contextName===cName&&this.poolingContexts[i].foreignValue[parentKeyField]===fValue){result.push(this.poolingContexts[i])}}
return result},dependingObjects:function(idValue){'use strict';var i,j,result=[];if(!idValue){return!1}
for(i=0;i<this.poolingContexts.length;i++){for(j=0;j<this.poolingContexts[i].dependingObject.length;j++){if(this.poolingContexts[i].dependingObject[j]===idValue){result.push(this.poolingContexts[i])}}}
return result.length===0?!1:result},getChildContexts:function(parentContext){'use strict';var i,childContexts=[];for(i=0;i<this.poolingContexts.length;i++){if(this.poolingContexts[i].parentContext===parentContext){childContexts.push(this.poolingContexts[i])}}
return childContexts},childContexts:null,removeContextsFromPool:function(contexts){'use strict';var i,regIds=[],delIds=[];for(i=0;i<this.poolingContexts.length;i++){if(contexts.indexOf(this.poolingContexts[i])>-1){regIds.push(this.poolingContexts[i].registeredId);delIds.push(i)}}
for(i=delIds.length-1;i>-1;i--){this.poolingContexts.splice(delIds[i],1)}
return regIds},removeRecordFromPool:function(repeaterIdValue){'use strict';var i,j,field,nodeIds=[],targetKeying,targetKeyingObj,parentKeying,relatedId,idValue,delNodes,contextAndKey,sameOriginContexts,countDeleteNodes;contextAndKey=getContextAndKeyFromId(repeaterIdValue);if(contextAndKey===null){return}
sameOriginContexts=this.getContextsWithSameOrigin(contextAndKey.context);targetKeying=contextAndKey.key;for(i=0;i<sameOriginContexts.length;i++){targetKeyingObj=sameOriginContexts[i].binding[targetKeying];for(field in targetKeyingObj){if(targetKeyingObj.hasOwnProperty(field)){for(j=0;j<targetKeyingObj[field].length;j++){if(nodeIds.indexOf(targetKeyingObj[field][j].id)<0){nodeIds.push(targetKeyingObj[field][j].id)}}}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){parentKeying=Object.keys(contextAndKey.context.binding)[0];relatedId=targetKeying.split('=')[1];if(sameOriginContexts[i].binding[parentKeying]&&sameOriginContexts[i].binding[parentKeying]._im_repeater&&sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId]&&sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId][0]){nodeIds.push(sameOriginContexts[i].binding[parentKeying]._im_repeater[relatedId][0].id)}}}
delNodes=[];for(i=0;i<sameOriginContexts.length;i++){for(idValue in sameOriginContexts[i].contextInfo){if(sameOriginContexts[i].contextInfo.hasOwnProperty(idValue)){if(nodeIds.indexOf(idValue)>=0){delete contextAndKey.context.contextInfo[idValue];delNodes.push(idValue)}}}
delete sameOriginContexts[i].binding[targetKeying];delete sameOriginContexts[i].store[targetKeying]}
countDeleteNodes=delNodes.length;IMLibElement.deleteNodes(delNodes);this.poolingContexts=this.poolingContexts.filter(function(context){return nodeIds.indexOf(context.enclosureNode.id)<0});return countDeleteNodes;function getContextAndKeyFromId(repeaterIdValue){var i,field,j,keying,foreignKey;for(i=0;i<IMLibContextPool.poolingContexts.length;i++){for(keying in IMLibContextPool.poolingContexts[i].binding){if(IMLibContextPool.poolingContexts[i].binding.hasOwnProperty(keying)){for(field in IMLibContextPool.poolingContexts[i].binding[keying]){if(IMLibContextPool.poolingContexts[i].binding[keying].hasOwnProperty(field)&&field==='_im_repeater'){for(j=0;j<IMLibContextPool.poolingContexts[i].binding[keying][field].length;j++){if(repeaterIdValue===IMLibContextPool.poolingContexts[i].binding[keying][field][j].id){return({context:IMLibContextPool.poolingContexts[i],key:keying})}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){for(foreignKey in IMLibContextPool.poolingContexts[i].binding[keying][field]){if(IMLibContextPool.poolingContexts[i].binding[keying][field].hasOwnProperty(foreignKey)){for(j=0;j<IMLibContextPool.poolingContexts[i].binding[keying][field][foreignKey].length;j++){if(repeaterIdValue===IMLibContextPool.poolingContexts[i].binding[keying][field][foreignKey][j].id){return({context:IMLibContextPool.poolingContexts[i],key:INTERMediatorOnPage.defaultKeyName+'='+foreignKey})}}}}}}}}}}
return null}},getContextsWithSameOrigin:function(originalContext){'use strict';var i,contexts=[],contextDef,isPortal=!1;contextDef=IMLibContextPool.getContextDef(originalContext.contextName);if(contextDef&&contextDef.relation){for(i in contextDef.relation){if(contextDef.relation.hasOwnProperty(i)&&contextDef.relation[i].portal){isPortal=!0;break}}}
for(i=0;i<IMLibContextPool.poolingContexts.length;i++){if(IMLibContextPool.poolingContexts[i].sourceName===originalContext.sourceName){if(!isPortal||originalContext.parentContext!==IMLibContextPool.poolingContexts[i]){contexts.push(IMLibContextPool.poolingContexts[i])}}}
return contexts},updateOnAnotherClient:function(eventName,info){'use strict';var i,j,k,entityName=info.entity,contextDef,contextView,keyField,recKey;if(eventName==='update'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){keyField=contextDef.key;recKey=keyField+'='+info.pkvalue;this.poolingContexts[i].setValue(recKey,info.field[0],info.value[0]);var bindingInfo=this.poolingContexts[i].binding[recKey][info.field[0]];for(j=0;j<bindingInfo.length;j++){var updateRequiredContext=IMLibContextPool.dependingObjects(bindingInfo[j].id);for(k=0;k<updateRequiredContext.length;k++){updateRequiredContext[k].foreignValue={};updateRequiredContext[k].foreignValue[info.field[0]]=info.value[0];if(updateRequiredContext[k]){INTERMediator.constructMain(updateRequiredContext[k])}}}}}
IMLibCalc.recalculation()}else if(eventName==='create'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){if(this.poolingContexts[i].isContaining(info.value[0])){INTERMediator.constructMain(this.poolingContexts[i],info.value)}}}
IMLibCalc.recalculation()}else if(eventName==='delete'){for(i=0;i<this.poolingContexts.length;i++){contextDef=this.getContextDef(this.poolingContexts[i].contextName);contextView=contextDef.view?contextDef.view:contextDef.name;if(contextView===entityName){this.poolingContexts[i].removeEntry(info.pkvalue)}}
IMLibCalc.recalculation()}},getMasterContext:function(){'use strict';var i,contextDef;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){contextDef=this.poolingContexts[i].getContextDef();if(contextDef['navi-control']&&contextDef['navi-control'].match(/master/)){return this.poolingContexts[i]}}
return null},getDetailContext:function(){'use strict';var i,contextDef;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){contextDef=this.poolingContexts[i].getContextDef();if(contextDef['navi-control']&&contextDef['navi-control'].match(/detail/)){return this.poolingContexts[i]}}
return null},getContextDef:function(contextName){'use strict';return INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',contextName)},getContextFromNodeId:function(nodeId){'use strict';var i,context,contextDef,rKey,fKey,pKey,isPortal,bindInfo;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];contextDef=context.getContextDef();isPortal=!1;if(contextDef.relation){for(rKey in contextDef.relation){if(contextDef.relation[rKey].portal){isPortal=!0}}}
for(rKey in context.binding){if(context.binding.hasOwnProperty(rKey)){for(fKey in context.binding[rKey]){if(isPortal){for(pKey in context.binding[rKey][fKey]){if(context.binding[rKey][fKey].hasOwnProperty(pKey)){bindInfo=context.binding[rKey][fKey][pKey];if(bindInfo.nodeId===nodeId){return context}}}}else{bindInfo=context.binding[rKey][fKey];if(bindInfo.nodeId===nodeId){return context}}}}}}
return null},getContextFromEnclosureNode:function(enclosureNode){'use strict';var i,context;if(!this.poolingContexts){return null}
for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];if(context.enclosureNode===enclosureNode){return context}}
return null},generateContextObject:function(contextDef,enclosure,repeaters,repeatersOriginal){'use strict';var contextObj=new IMLibContext(contextDef.name);contextObj.contextDefinition=contextDef;contextObj.enclosureNode=enclosure;contextObj.repeaterNodes=repeaters;contextObj.original=repeatersOriginal;contextObj.sequencing=!0;return contextObj},getPagingContext:function(){'use strict';var i,context,contextDef;if(this.poolingContexts){for(i=0;i<this.poolingContexts.length;i++){context=this.poolingContexts[i];contextDef=context.getContextDef();if(contextDef.paging){return context}}}
return null}};var IMLibContext=function(contextName){'use strict';this.contextName=contextName;this.tableName=null;this.viewName=null;this.sourceName=null;this.contextDefinition=null;this.store={};this.binding={};this.contextInfo={};this.modified={};this.recordOrder=[];this.pendingOrder=[];IMLibContextPool.registerContext(this);this.foreignValue={};this.enclosureNode=null;this.repeaterNodes=null;this.dependingObject=[];this.original=null;this.nullAcceptable=!0;this.parentContext=null;this.registeredId=null;this.sequencing=!1;this.dependingParentObjectInfo=null;this.isPortal=!1;this.potalContainingRecordKV=null;this.setTable(this)};IMLibContext.prototype.updateFieldValue=function(idValue,succeedProc,errorProc,warnMultipleRecProc,warnOthersModifyProc){'use strict';var nodeInfo,contextInfo,linkInfo,changedObj,criteria,newValue;changedObj=document.getElementById(idValue);linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);if(INTERMediator.ignoreOptimisticLocking){IMLibContextPool.updateContext(idValue,nodeInfo.target);newValue=IMLibElement.getValueFromIMNode(changedObj);if(newValue!==null){criteria=contextInfo.record.split('=');INTERMediatorOnPage.retrieveAuthInfo();if(contextInfo.context.isPortal){criteria=contextInfo.context.potalContainingRecordKV.split('=');INTERMediator_DBAdapter.db_update_async({name:contextInfo.context.parentContext.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field+'.'+contextInfo.record.split('=')[1],value:newValue}]},succeedProc,errorProc)}else{criteria=contextInfo.record.split('=');INTERMediator_DBAdapter.db_update_async({name:contextInfo.context.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field,value:newValue}]},succeedProc,errorProc)}}}else{var targetContext=contextInfo.context;var parentContext,keyingComp;if(targetContext.isPortal===!0){parentContext=IMLibContextPool.getContextFromName(targetContext.sourceName)[0]}else{parentContext=targetContext.parentContext}
var targetField=contextInfo.field;if(targetContext.isPortal===!0){keyingComp=Object.keys(parentContext.store)[0].split('=')}else{keyingComp=(targetContext.isPortal?targetContext.potalContainingRecordKV:contextInfo.record).split('=')}
var keyingField=keyingComp[0];keyingComp.shift();var keyingValue=keyingComp.join('=');INTERMediator_DBAdapter.db_query_async({name:targetContext.isPortal?parentContext.contextName:targetContext.contextName,records:1,paging:!1,fields:[contextInfo.field],parentkeyvalue:null,conditions:[{field:keyingField,operator:'=',value:keyingValue}],useoffset:!1,primaryKeyOnly:!0},(function(){var targetFieldCapt=targetField;var contextInfoCapt=contextInfo;var targetContextCapt=targetContext;var changedObjectCapt=changedObj;var nodeInfoCapt=nodeInfo;var idValueCapt=idValue;return function(result){var initialvalue,newValue,isOthersModified,currentFieldVal,recordset=[],portalRecords,index,keyField,keyingComp,criteria;if(targetContextCapt.isPortal){portalRecords=targetContextCapt.getPortalRecordsetImpl(result.dbresult[0],targetContextCapt.contextName);keyField=targetContextCapt.getKeyField();keyingComp=contextInfoCapt.record.split('=');for(index=0;index<portalRecords.length;index++){if(portalRecords[index][keyField]===keyingComp[1]){recordset.push(portalRecords[index]);break}}}else{recordset=result.dbresult}
if(!recordset||!recordset[0]||recordset[0][targetFieldCapt]===undefined){errorProc();return}
if(result.resultCount>1){if(!warnMultipleRecProc()){return}}
if(targetContextCapt.isPortal){for(var i=0;i<recordset.length;i++){if(recordset[i][INTERMediatorOnPage.defaultKeyName]===contextInfo.record.split('=')[1]){currentFieldVal=recordset[i][targetFieldCapt];break}}
initialvalue=targetContextCapt.getValue(Object.keys(parentContext.store)[0],targetFieldCapt,INTERMediatorOnPage.defaultKeyName+'='+recordset[i][INTERMediatorOnPage.defaultKeyName])}else{currentFieldVal=recordset[0][targetFieldCapt];initialvalue=targetContextCapt.getValue(contextInfoCapt.record,targetFieldCapt)}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){if(typeof(initialvalue)==='number'&&typeof(currentFieldVal)==='string'){initialvalue=initialvalue.toString()}}
isOthersModified=checkSameValue(initialvalue,currentFieldVal);if(changedObjectCapt.tagName==='INPUT'&&changedObjectCapt.getAttribute('type')==='checkbox'){if(initialvalue===changedObjectCapt.value){isOthersModified=!1}else if(!parseInt(currentFieldVal)){isOthersModified=!1}else{isOthersModified=!0}}
if(isOthersModified){newValue=IMLibElement.getValueFromIMNode(changedObjectCapt);if(!warnOthersModifyProc(initialvalue,newValue,currentFieldVal)){return}
INTERMediatorOnPage.retrieveAuthInfo()}
IMLibContextPool.updateContext(idValueCapt,nodeInfoCapt.target);newValue=IMLibElement.getValueFromIMNode(changedObjectCapt);if(newValue!==null){if(targetContextCapt.isPortal){if(targetContextCapt.potalContainingRecordKV==null){criteria=Object.keys(targetContextCapt.foreignValue);criteria[1]=targetContextCapt.foreignValue[criteria[0]]}else{criteria=targetContextCapt.potalContainingRecordKV.split('=')}
INTERMediator_DBAdapter.db_update_async({name:targetContextCapt.isPortal?targetContextCapt.sourceName:targetContextCapt.parentContext.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfoCapt.field+'.'+contextInfoCapt.record.split('=')[1],value:newValue}]},succeedProc,errorProc)}else{criteria=contextInfoCapt.record.split('=');INTERMediator_DBAdapter.db_update_async({name:targetContextCapt.contextName,conditions:[{field:criteria[0],operator:'=',value:criteria[1]}],dataset:[{field:contextInfo.field,value:newValue}]},succeedProc,errorProc)}}}})(),function(){INTERMediatorOnPage.hideProgress();INTERMediatorLog.setErrorMessage('Error in valueChange method.','EXCEPTION-1')})}
var handleAsNullValue=['0000-00-00','0000-00-00 00:00:00'];function checkSameValue(initialValue,currentFieldVal){if(handleAsNullValue.indexOf(initialValue)>=0){initialValue=''}
if(handleAsNullValue.indexOf(currentFieldVal)>=0){currentFieldVal=''}
return initialValue!==currentFieldVal}};IMLibContext.prototype.getKeyField=function(){'use strict';var keyField;if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){if(this.isPortal){keyField=INTERMediatorOnPage.defaultKeyName}else{keyField=this.contextDefinition.key?this.contextDefinition.key:INTERMediatorOnPage.defaultKeyName}}else{keyField=this.contextDefinition.key?this.contextDefinition.key:'id'}
return keyField};IMLibContext.prototype.getCalculationFields=function(){'use strict';var calcDef=this.contextDefinition.calculation;var calcFields=[],ix;for(ix in calcDef){if(calcDef.hasOwnProperty(ix)){calcFields.push(calcDef[ix].field)}}
return calcFields};IMLibContext.prototype.isUseLimit=function(){'use strict';var useLimit=!1;if(this.contextDefinition.records&&this.contextDefinition.paging){useLimit=!0}
return useLimit};IMLibContext.prototype.getPortalRecords=function(){'use strict';var targetRecords={};if(!this.isPortal){return null}
if(this.contextDefinition&&this.contextDefinition.currentrecord){targetRecords.recordset=this.getPortalRecordsetImpl(this.contextDefinition.currentrecord,this.contextName)}else{targetRecords.recordset=this.getPortalRecordsetImpl(this.parentContext.store[this.potalContainingRecordKV],this.contextName)}
return targetRecords};IMLibContext.prototype.getPortalRecordsetImpl=function(store,contextName){'use strict';var result,recId,recordset,key,contextDef;recordset=[];if(store[0]){if(!store[0][contextName]){for(key in store[0]){if(store[0].hasOwnProperty(key)){contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',key);if(contextName===contextDef.view&&!store[0][contextName]){contextName=key;break}}}}
if(store[0][contextName]){result=store[0][contextName];for(recId in result){if(result.hasOwnProperty(recId)&&isFinite(recId)){recordset.push(result[recId])}}}}
return recordset};IMLibContext.prototype.getRecordNumber=function(){'use strict';var recordNumber,key,value,keyParams;if(this.contextDefinition['navi-control']&&this.contextDefinition['navi-control']==='detail'){recordNumber=1}else{recordNumber=parseInt(this.contextDefinition.records,10);for(key in INTERMediator.recordLimit){if(INTERMediator.recordLimit.hasOwnProperty(key)){value=String(INTERMediator.recordLimit[key]);if(key===this.contextDefinition.name&&value.length>0){recordNumber=parseInt(value);INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}}}
if(parseInt(INTERMediator.pagedSize,10)>0){recordNumber=INTERMediator.pagedSize;INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}
for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){value=String(IMLibLocalContext.store[key]);keyParams=key.split(':');if(keyParams&&keyParams.length>1&&keyParams[1].trim()===this.contextDefinition.name&&value.length>0&&keyParams[0].trim()==='limitnumber'){recordNumber=parseInt(value);INTERMediator.setLocalProperty('_im_pagedSize',recordNumber)}}}
if(!this.contextDefinition.relation&&this.contextDefinition.paging&&Boolean(this.contextDefinition.paging)===!0){INTERMediator.setLocalProperty('_im_pagedSize',recordNumber);INTERMediator.pagedSize=recordNumber}}
return recordNumber};IMLibContext.prototype.setRelationWithParent=function(currentRecord,parentObjectInfo,parentContext){'use strict';var relationDef,index,joinField,fieldName,i;this.parentContext=parentContext;if(currentRecord){try{relationDef=this.contextDefinition.relation;if(relationDef){for(index in relationDef){if(relationDef.hasOwnProperty(index)){if(Boolean(relationDef[index].portal)===!0){this.isPortal=!0;this.potalContainingRecordKV=INTERMediatorOnPage.defaultKeyName+'='+currentRecord[INTERMediatorOnPage.defaultKeyName]}
joinField=relationDef[index]['join-field'];this.addForeignValue(joinField,currentRecord[joinField]);for(fieldName in parentObjectInfo){if(fieldName===relationDef[index]['join-field']){for(i=0;i<parentObjectInfo[fieldName].length;i++){this.addDependingObject(parentObjectInfo[fieldName][i])}
this.dependingParentObjectInfo=JSON.parse(JSON.stringify(parentObjectInfo))}}}}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-25')}}}};IMLibContext.prototype.getInsertOrder=function(){'use strict';var cName,sortKeys=[],contextDef,i,sortFields=[],sortDirections=[];for(cName in INTERMediator.additionalSortKey){if(cName===this.contextName){sortKeys.push(INTERMediator.additionalSortKey[cName])}}
contextDef=this.getContextDef();if(contextDef.sort){sortKeys.push(contextDef.sort)}
for(i=0;i<sortKeys.length;i++){if(sortFields.indexOf(sortKeys[i].field)<0){sortFields.push(sortKeys[i].field);sortDirections.push(sortKeys[i].direction)}}};IMLibContext.prototype.indexingArray=function(keyField){'use strict';var ar=[],key,counter=0;for(key in this.store){if(this.store.hasOwnProperty(key)){ar[counter]=this.store[key][keyField];counter+=1}}
return ar};IMLibContext.prototype.clearAll=function(){'use strict';this.store={};this.binding={}};IMLibContext.prototype.setContextName=function(name){'use strict';this.contextName=name};IMLibContext.prototype.getContextDef=function(){'use strict';return INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName)};IMLibContext.prototype.setTableName=function(name){'use strict';this.tableName=name};IMLibContext.prototype.setViewName=function(name){'use strict';this.viewName=name};IMLibContext.prototype.addDependingObject=function(idNumber){'use strict';this.dependingObject.push(idNumber)};IMLibContext.prototype.addForeignValue=function(field,value){'use strict';this.foreignValue[field]=value};IMLibContext.prototype.setOriginal=function(repeaters){'use strict';var i;this.original=[];for(i=0;i<repeaters.length;i++){this.original.push(repeaters[i].cloneNode(!0))}};IMLibContext.prototype.setTable=function(context){'use strict';var contextDef;if(!context||!INTERMediatorOnPage.getDataSources){this.tableName=this.contextName;this.viewName=this.contextName;this.sourceName=this.contextName;return}
contextDef=this.getContextDef();if(contextDef){this.viewName=contextDef.view?contextDef.view:contextDef.name;this.tableName=contextDef.table?contextDef.table:contextDef.name;this.sourceName=(contextDef.source?contextDef.source:(contextDef.table?contextDef.table:(contextDef.view?contextDef.view:contextDef.name)))}};IMLibContext.prototype.removeContext=function(){'use strict';var regIds=[],childContexts=[];seekRemovingContext(this);regIds=IMLibContextPool.removeContextsFromPool(childContexts);while(this.enclosureNode.firstChild){this.enclosureNode.removeChild(this.enclosureNode.firstChild)}
INTERMediator_DBAdapter.unregister(regIds);function seekRemovingContext(context){var i,myChildren;childContexts.push(context);regIds.push(context.registeredId);myChildren=IMLibContextPool.getChildContexts(context);for(i=0;i<myChildren.length;i++){seekRemovingContext(myChildren[i])}}};IMLibContext.prototype.setModified=function(recKey,key,value){'use strict';if(this.modified[recKey]===undefined){this.modified[recKey]={}}
this.modified[recKey][key]=value};IMLibContext.prototype.getModified=function(){'use strict';return this.modified};IMLibContext.prototype.clearModified=function(){'use strict';this.modified={}};IMLibContext.prototype.getContextDef=function(){'use strict';var contextDef;contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName);return contextDef};IMLibContext.prototype.checkOrder=function(oneRecord,isDebug){'use strict';var i,fields=[],directions=[],oneSortKey,condtextDef,lower,upper,index,targetRecord,contextValue,checkingValue,stop;if(isDebug!==!0){if(INTERMediator&&INTERMediator.additionalSortKey[this.contextName]){for(i=0;i<INTERMediator.additionalSortKey[this.contextName].length;i++){oneSortKey=INTERMediator.additionalSortKey[this.contextName][i];if(!(oneSortKey.field in fields)){fields.push(oneSortKey.field);directions.push(oneSortKey.direction)}}}
condtextDef=this.getContextDef();if(condtextDef&&condtextDef.sort){for(i=0;i<condtextDef.sort.length;i++){oneSortKey=condtextDef.sort[i];if(!(oneSortKey.field in fields)){fields.push(oneSortKey.field);directions.push(oneSortKey.direction)}}}}else{fields=['field1','field2']}
lower=0;upper=this.recordOrder.length;for(i=0;i<fields.length;i++){if(oneRecord[fields[i]]){index=parseInt((upper+lower)/2);do{targetRecord=this.store[this.recordOrder[index]];contextValue=targetRecord[fields[i]];checkingValue=oneRecord[fields[i]];if(contextValue<checkingValue){lower=index}else if(contextValue>checkingValue){upper=index}else{lower=upper=index}
index=parseInt((upper+lower)/2)}while(upper-lower>1);targetRecord=this.store[this.recordOrder[index]];contextValue=targetRecord[fields[i]];if(contextValue===checkingValue){lower=upper=index;stop=!1;do{targetRecord=this.store[this.recordOrder[lower-1]];if(targetRecord&&targetRecord[fields[i]]&&targetRecord[fields[i]]===checkingValue){lower--}else{stop=!0}}while(!stop);stop=!1;do{targetRecord=this.store[this.recordOrder[upper+1]];if(targetRecord&&targetRecord[fields[i]]&&targetRecord[fields[i]]===checkingValue){upper++}else{stop=!0}}while(!stop);if(lower===upper){break}
upper++}else if(contextValue<checkingValue){break}else if(contextValue>checkingValue){index--;break}}}
return index};IMLibContext.prototype.rearrangePendingOrder=function(isDebug){'use strict';var i,index,targetRecord;for(i=0;i<this.pendingOrder.length;i++){targetRecord=this.store[this.pendingOrder[i]];index=this.checkOrder(targetRecord,isDebug);if(index>=-1){this.recordOrder.splice(index+1,0,this.pendingOrder[i])}}
this.pendingOrder=[]};IMLibContext.prototype.getRepeaterEndNode=function(index){'use strict';var nodeId,field,repeaters=[],repeater,node,i,enclosure,children;var recKey=this.recordOrder[index];for(field in this.binding[recKey]){if(this.binding[recKey].hasOwnProperty(field)){nodeId=this.binding[recKey][field].nodeId;repeater=INTERMediatorLib.getParentRepeaters(document.getElementById(nodeId));for(i=0;i<repeater.length;i+=1){if(!(repeater[i]in repeaters)){repeaters.push(repeater[i])}}}}
if(repeaters.length<1){return null}
node=repeaters[0];enclosure=INTERMediatorLib.getParentEnclosure(node);children=enclosure.childNodes;for(i=0;i<children.length;i++){if(children[i]in repeaters){node=repeaters[i];break}}
return node};IMLibContext.prototype.storeRecords=function(records){'use strict';var ix,record,field,keyField,keyValue;var contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',this.contextName);keyField=contextDef.key?contextDef.key:'id';if(records.recordset){for(ix=0;ix<records.recordset.length;ix++){record=records.recordset[ix];for(field in record){if(record.hasOwnProperty(field)){keyValue=record[keyField]?record[keyField]:ix;this.setValue(keyField+'='+keyValue,field,record[field])}}}}};IMLibContext.prototype.getDataAtLastRecord=function(key){'use strict';var lastKey;var storekeys=Object.keys(this.store);if(storekeys.length>0){lastKey=storekeys[storekeys.length-1];return this.getValue(lastKey,key)}
return undefined};IMLibContext.prototype.setDataAtLastRecord=function(key,value){'use strict';var lastKey,keyAndValue,contextName;var storekeys=Object.keys(this.store);if(storekeys.length>0){lastKey=storekeys[storekeys.length-1];this.setValue(lastKey,key,value);contextName=this.contextName;keyAndValue=lastKey.split('=');IMLibQueue.setTask((function(){var params={name:contextName,conditions:[{field:keyAndValue[0],operator:'=',value:keyAndValue[1]}],dataset:[{field:key,value:value}]};return function(completeTask){INTERMediator_DBAdapter.db_update(params);IMLibCalc.recalculation();INTERMediatorLog.flushMessage();completeTask()}})())}};IMLibContext.prototype.setDataWithKey=function(pkValue,key,value){'use strict';var targetKey,contextDef,storeElements,contextName;contextDef=this.getContextDef();if(!contextDef){return}
targetKey=contextDef.key+'='+pkValue;storeElements=this.store[targetKey];if(storeElements){this.setValue(targetKey,key,value);contextName=this.contextName;IMLibQueue.setTask((function(){var params={name:contextName,conditions:[{field:contextDef.key,operator:'=',value:pkValue}],dataset:[{field:key,value:value}]};return function(completeTask){INTERMediator_DBAdapter.db_update(params);INTERMediatorLog.flushMessage();completeTask()}})())}};IMLibContext.prototype.setValue=function(recKey,key,value,nodeId,target,portal){'use strict';var updatedNodeIds=null;if(portal){console.error('Using the portal parameter in IMLibContext.setValue')}
if(recKey){if(this.store[recKey]===undefined){this.store[recKey]={}}
if(portal&&this.store[recKey][key]===undefined){this.store[recKey][key]={}}
if(this.binding[recKey]===undefined){this.binding[recKey]={};if(this.sequencing){this.recordOrder.push(recKey)}else{this.pendingOrder.push(recKey)}}
if(this.binding[recKey][key]===undefined){this.binding[recKey][key]=[]}
if(portal&&this.binding[recKey][key][portal]===undefined){if(this.binding[recKey][key].length<1){this.binding[recKey][key]={}}
this.binding[recKey][key][portal]=[]}
if(key){if(portal){this.store[recKey][key]=value}else{this.store[recKey][key]=value}
if(nodeId){if(portal){this.binding[recKey][key].push({id:nodeId,target:target})}else{this.binding[recKey][key].push({id:nodeId,target:target})}
if(this.contextInfo[nodeId]===undefined){this.contextInfo[nodeId]={}}
this.contextInfo[nodeId][target?target:'_im_no_target']={context:this,record:recKey,field:key};if(portal){this.contextInfo[nodeId][target?target:'_im_no_target'].portal=portal}}else{if(INTERMediator.partialConstructing){updatedNodeIds=IMLibContextPool.synchronize(this,recKey,key,value,target,portal)}}}}
return updatedNodeIds};IMLibContext.prototype.getValue=function(recKey,key,portal){'use strict';var value;try{if(portal){value=this.store[portal][key]}else{value=this.store[recKey][key]}
if(Array.isArray(value)){value=value.join()}
return value===undefined?null:value}catch(ex){return null}};IMLibContext.prototype.isValueUndefined=function(recKey,key,portal){'use strict';var value,tableOccurence,relatedRecId;try{if(portal){tableOccurence=key.split('::')[0];relatedRecId=portal.split('=')[1];value=this.store[recKey][0][tableOccurence][relatedRecId][key]}else{value=this.store[recKey][key]}
return value===undefined?!0:!1}catch(ex){return null}};IMLibContext.prototype.getContextInfo=function(nodeId,target){'use strict';try{var info=this.contextInfo[nodeId][target?target:'_im_no_target'];return info===undefined?null:info}catch(ex){return null}};IMLibContext.prototype.getContextValue=function(nodeId,target){'use strict';try{var info=this.contextInfo[nodeId][target?target:'_im_no_target'];var value=info.context.getValue(info.record,info.field);return value===undefined?null:value}catch(ex){return null}};IMLibContext.prototype.getContextRecord=function(nodeId){'use strict';var infos,keys,i;try{infos=this.contextInfo[nodeId];keys=Object.keys(infos);for(i=0;i<keys.length;i++){if(infos[keys[i]]){return this.store[infos[keys[i]].record]}}
return null}catch(ex){return null}};IMLibContext.prototype.removeEntry=function(pkvalue){'use strict';var keyField,keying,bindingInfo,contextDef,targetNode,repeaterNodes,i,removingNodeIds=[];contextDef=this.getContextDef();keyField=contextDef.key;keying=keyField+'='+pkvalue;bindingInfo=this.binding[keying];if(bindingInfo){repeaterNodes=bindingInfo._im_repeater;if(repeaterNodes){for(i=0;i<repeaterNodes.length;i++){removingNodeIds.push(repeaterNodes[i].id)}}}
if(removingNodeIds.length>0){for(i=0;i<removingNodeIds.length;i++){IMLibContextPool.removeRecordFromPool(removingNodeIds[i])}
for(i=0;i<removingNodeIds.length;i++){targetNode=document.getElementById(removingNodeIds[i]);if(targetNode){targetNode.parentNode.removeChild(targetNode)}}}};IMLibContext.prototype.isContaining=function(value){'use strict';var contextDef,contextName,checkResult=[],i,fieldName,result,opePosition,leftHand,rightHand,leftResult,rightResult;contextDef=this.getContextDef();contextName=contextDef.name;if(contextDef.query){for(i in contextDef.query){if(contextDef.query.hasOwnProperty(i)){checkResult.push(checkCondition(contextDef.query[i],value))}}}
if(INTERMediator.additionalCondition[contextName]){for(i=0;i<INTERMediator.additionalCondition[contextName].length;i++){checkResult.push(checkCondition(INTERMediator.additionalCondition[contextName][i],value))}}
result=!0;if(checkResult.length!==0){opePosition=checkResult.indexOf('D');if(opePosition>-1){leftHand=checkResult.slice(0,opePosition);rightHand=opePosition.slice(opePosition+1);if(rightHand.length===0){result=(leftHand.indexOf(!1)<0)}else{leftResult=(leftHand.indexOf(!1)<0);rightResult=(rightHand.indexOf(!1)<0);result=leftResult||rightResult}}else{opePosition=checkResult.indexOf('EX');if(opePosition>-1){leftHand=checkResult.slice(0,opePosition);rightHand=opePosition.slice(opePosition+1);if(rightHand.length===0){result=(leftHand.indexOf(!0)>-1)}else{leftResult=(leftHand.indexOf(!0)>-1);rightResult=(rightHand.indexOf(!0)>-1);result=leftResult&&rightResult}}else{opePosition=checkResult.indexOf(!1);if(opePosition>-1){result=(checkResult.indexOf(!1)<0)}}}
if(result===!1){return!1}}
if(this.foreignValue){for(fieldName in this.foreignValue){if(contextDef.relation){for(i in contextDef.relation){if(contextDef.relation[i]['join-field']===fieldName){result&=(checkCondition({field:contextDef.relation[i]['foreign-key'],operator:'=',value:this.foreignValue[fieldName]},value))}}}}}
return result;function checkCondition(conditionDef,oneRecord){var realValue;if(conditionDef.field==='__operation__'){return conditionDef.operator==='ex'?'EX':'D'}
realValue=oneRecord[conditionDef.field];if(!realValue){return!1}
switch(conditionDef.operator){case '=':case 'eq':return String(realValue)===String(conditionDef.value);case '>':case 'gt':return realValue>conditionDef.value;case '<':case 'lt':return realValue<conditionDef.value;case '>=':case 'gte':return realValue>=conditionDef.value;case '<=':case 'lte':return realValue<=conditionDef.value;case '!=':case 'neq':return String(realValue)!==String(conditionDef.value);default:return!1}}};IMLibContext.prototype.insertEntry=function(pkvalue,fields,values){'use strict';var i,field,value;for(i=0;i<fields.length;i++){field=fields[i];value=values[i];this.setValue(pkvalue,field,value)}};var IMLibLocalContext={contextName:'_',store:{},binding:{},clearAll:function(){'use strict';this.store={}},setValue:function(key,value,withoutArchive){'use strict';var i,hasUpdated,refIds,node;hasUpdated=!1;if(key){if(value===undefined||value===null){delete this.store[key]}else{this.store[key]=value;hasUpdated=!0;refIds=this.binding[key];if(refIds){for(i=0;i<refIds.length;i++){node=document.getElementById(refIds[i]);IMLibElement.setValueToIMNode(node,'',value,!0)}}}}
if(hasUpdated&&withoutArchive!==!0){this.archive()}},getValue:function(key){'use strict';var value=this.store[key];return value===undefined?null:value},archive:function(){'use strict';var jsonString,key,searchLen,hashLen,trailLen;INTERMediatorOnPage.removeCookie('_im_localcontext');if(INTERMediator.isIE&&INTERMediator.ieVersion<9){this.store._im_additionalCondition=INTERMediator.additionalCondition;this.store._im_additionalSortKey=INTERMediator.additionalSortKey;this.store._im_startFrom=INTERMediator.startFrom;this.store._im_pagedSize=INTERMediator.pagedSize;jsonString=JSON.stringify(this.store,function(k,v){return v===''?'':v})}else{jsonString=JSON.stringify(this.store)}
if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{searchLen=location.search?location.search.length:0;hashLen=location.hash?location.hash.length:0;trailLen=searchLen+hashLen;key='_im_localcontext'+document.URL.toString();key=(trailLen>0)?key.slice(0,-trailLen):key;sessionStorage.setItem(key,jsonString)}catch(ex){INTERMediatorOnPage.setCookieWorker('_im_localcontext',jsonString,!1,0)}}else{INTERMediatorOnPage.setCookieWorker('_im_localcontext',jsonString,!1,0)}},unarchive:function(){'use strict';var localContext='',searchLen,hashLen,key,trailLen;if(INTERMediator.useSessionStorage===!0&&typeof sessionStorage!=='undefined'&&sessionStorage!==null){try{searchLen=location.search?location.search.length:0;hashLen=location.hash?location.hash.length:0;trailLen=searchLen+hashLen;key='_im_localcontext'+document.URL.toString();key=(trailLen>0)?key.slice(0,-trailLen):key;localContext=sessionStorage.getItem(key)}catch(ex){localContext=INTERMediatorOnPage.getCookie('_im_localcontext')}}else{localContext=INTERMediatorOnPage.getCookie('_im_localcontext')}
if(localContext&&localContext.length>0){this.store=JSON.parse(localContext);if(INTERMediator.isIE&&INTERMediator.ieVersion<9){if(this.store._im_additionalCondition){INTERMediator.additionalCondition=this.store._im_additionalCondition}
if(this.store._im_additionalSortKey){INTERMediator.additionalSortKey=this.store._im_additionalSortKey}
if(this.store._im_startFrom){INTERMediator.startFrom=this.store._im_startFrom}
if(this.store._im_pagedSize){INTERMediator.pagedSize=this.store._im_pagedSize}}
this.updateAll(!0)}},bindingNode:function(node){'use strict';var linkInfos,nodeInfo,idValue,i,j,value,params,unbinding,unexistId,dataImControl;if(node.nodeType!==1){return}
linkInfos=INTERMediatorLib.getLinkedElementInfo(node);dataImControl=node.getAttribute('data-im-control');unbinding=(dataImControl&&dataImControl==='unbind');for(i=0;i<linkInfos.length;i++){nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===this.contextName){if(!node.id){node.id=INTERMediator.nextIdValue()}
idValue=node.id;if(!this.binding[nodeInfo.field]){this.binding[nodeInfo.field]=[]}
if(this.binding[nodeInfo.field].indexOf(idValue)<0&&!unbinding){this.binding[nodeInfo.field].push(idValue)}
unexistId=-1;while(unexistId>=0){for(j=0;j<this.binding[nodeInfo.field].length;j++){if(!document.getElementById(this.binding[nodeInfo.field][j])){unexistId=j}}
if(unexistId>=0){delete this.binding[nodeInfo.field][unexistId]}}
value=this.store[nodeInfo.field];IMLibElement.setValueToIMNode(node,nodeInfo.target,value,!0);params=nodeInfo.field.split(':');switch(params[0]){case 'addorder':IMLibMouseEventDispatch.setExecute(idValue,IMLibUI.eventAddOrderHandler);break;case 'update':IMLibMouseEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})());break;case 'condition':var attrType=node.getAttribute('type');if(attrType&&attrType==='text'){IMLibKeyDownEventDispatch.setExecuteByCode(idValue,13,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})())}else if(attrType&&(attrType==='checkbox'||attrType==='radio')){IMLibChangeEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){INTERMediator.startFrom=0;IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})())}
break;case 'limitnumber':if(node.value){this.store[nodeInfo.field]=node.value}
IMLibChangeEventDispatch.setExecute(idValue,(function(){var contextName=params[1];return function(){IMLibUI.eventUpdateHandler(contextName);IMLibPageNavigation.navigationSetup()}})());node.setAttribute('data-imchangeadded','set');break;default:IMLibChangeEventDispatch.setExecute(idValue,IMLibLocalContext.update);break}}}},update:function(idValue){'use strict';IMLibLocalContext.updateFromNodeValue(idValue)},updateFromNodeValue:function(idValue){'use strict';var node,nodeValue,linkInfos,nodeInfo,i;node=document.getElementById(idValue);nodeValue=IMLibElement.getValueFromIMNode(node);linkInfos=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<linkInfos.length;i++){IMLibLocalContext.store[linkInfos[i]]=nodeValue;nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===IMLibLocalContext.contextName){IMLibLocalContext.setValue(nodeInfo.field,nodeValue)}}},updateFromStore:function(idValue){'use strict';var node,nodeValue,linkInfos,nodeInfo,i,target,comp;node=document.getElementById(idValue);target=node.getAttribute('data-im');comp=target.split(INTERMediator.separator);if(comp[1]){nodeValue=IMLibLocalContext.store[comp[1]];linkInfos=INTERMediatorLib.getLinkedElementInfo(node);for(i=0;i<linkInfos.length;i++){IMLibLocalContext.store[linkInfos[i]]=nodeValue;nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos[i]);if(nodeInfo.table===IMLibLocalContext.contextName){IMLibLocalContext.setValue(nodeInfo.field,nodeValue)}}}},updateAll:function(isStore){'use strict';var index,key,nodeIds,idValue,targetNode;for(key in IMLibLocalContext.binding){if(IMLibLocalContext.binding.hasOwnProperty(key)){nodeIds=IMLibLocalContext.binding[key];for(index=0;index<nodeIds.length;index++){idValue=nodeIds[index];targetNode=document.getElementById(idValue);if(targetNode&&(targetNode.tagName==='INPUT'||targetNode.tagName==='TEXTAREA'||targetNode.tagName==='SELECT')){if(isStore===!0){IMLibLocalContext.updateFromStore(idValue)}else{IMLibLocalContext.updateFromNodeValue(idValue)}
break}}}}},checkedBinding:[],bindingDescendant:function(rootNode){'use strict';var self=this;seek(rootNode);IMLibLocalContext.checkedBinding.push(rootNode);function seek(node){var children,i;if(node!==rootNode&&IMLibLocalContext.checkedBinding.indexOf(node)>-1){return}
if(node.nodeType===1){try{self.bindingNode(node);children=node.childNodes;if(children){for(i=0;i<children.length;i++){seek(children[i])}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-31')}}}}}};var IMLib={nl_char:'\n',cr_char:'\r',tab_char:'\t',singleQuote_char:'\'',doubleQuote_char:'"',backSlash_char:'\\',get zerolength_str(){'use strict';return''},set zerolength_str(value){},get crlf_str(){'use strict';return'\r\n'},set crlf_str(value){}};var INTERMediatorLib={ignoreEnclosureRepeaterClassName:'_im_ignore_enc_rep',ignoreEnclosureRepeaterControlName:'ignore_enc_rep',roleAsRepeaterClassName:'_im_repeater',roleAsEnclosureClassName:'_im_enclosure',roleAsRepeaterDataControlName:'repeater',roleAsEnclosureDataControlName:'enclosure',roleAsSeparatorDataControlName:'separator',roleAsHeaderDataControlName:'header',roleAsFooterDataControlName:'footer',roleAsNoResultDataControlName:'noresult',initialize:function(){'use strict';IMLibLocalContext.unarchive();return null},setup:function(){'use strict';if(window.addEventListener){window.addEventListener('load',this.initialize,!1)}else if(window.attachEvent){window.attachEvent('onload',this.initialize)}else{window.onload=this.initialize}
return null},markProcessed:function(node){'use strict';node.setAttribute('data-im-element','processed')},isProcessed:function(node){'use strict';return node.getAttribute('data-im-element')==='processed'},generatePasswordHash:function(password){'use strict';var numToHex,salt,saltHex,code,lowCode,highCode,i;numToHex=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];salt='';saltHex='';for(i=0;i<4;i++){code=Math.floor(Math.random()*(128-32)+32);lowCode=code&0xF;highCode=(code>>4)&0xF;salt+=String.fromCharCode(code);saltHex+=numToHex[highCode]+numToHex[lowCode]}
return encodeURIComponent(SHA1(password+salt)+saltHex)},getParentRepeater:function(node){console.error('INTERMediatorLib.getParentRepeater method in INTER-Mediator-Lib.js will be removed in Ver.6.0. '+'The alternative method is getParentRepeaters.');'use strict';var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null},getParentRepeaters:function(node){'use strict';var i,target='',linkInfo,result=[],linkComp,nInfos,repeaters;if(!node){return null}
linkInfo=INTERMediatorLib.getLinkedElementInfo(node);if(linkInfo){linkComp=linkInfo[0].split('@');if(linkComp.length>2){target=linkComp[2]}
nInfos=IMLibContextPool.getContextInfoFromId(node.id,target);if(nInfos){repeaters=nInfos.context.binding[nInfos.record]._im_repeater}else{repeaters=seekFromContextPool(node)}}else{repeaters=seekFromContextPool(node)}
if(repeaters){for(i=0;i<repeaters.length;i+=1){result.push(document.getElementById(repeaters[i].id))}}
return result;function seekFromContextPool(node){var i,j,k,currentNode,repeaters;if(!node){return null}
currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){for(i=0;i<IMLibContextPool.poolingContexts.length;i++){for(j in IMLibContextPool.poolingContexts[i].binding){if(IMLibContextPool.poolingContexts[i].binding.hasOwnProperty(j)&&IMLibContextPool.poolingContexts[i].binding[j].hasOwnProperty('_im_repeater')){for(k=0;k<IMLibContextPool.poolingContexts[i].binding[j]._im_repeater.length;k++){if(IMLibContextPool.poolingContexts[i].binding[j]._im_repeater[k].id===currentNode.id){repeaters=IMLibContextPool.poolingContexts[i].binding[j]._im_repeater;return repeaters}}}}}}
currentNode=currentNode.parentNode}
return null}},getParentEnclosure:function(node){'use strict';var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isEnclosure(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null},isEnclosure:function(node,nodeOnly){'use strict';var tagName,className,children,k,controlAttr;if(!node||node.nodeType!==1){return!1}
className=INTERMediatorLib.getClassAttributeFromNode(node);if(className&&className.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterClassName)>=0){return!1}
controlAttr=node.getAttribute('data-im-control');if(controlAttr&&controlAttr.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterControlName)>=0){return!1}
tagName=node.tagName;if((tagName==='TBODY')||(tagName==='UL')||(tagName==='OL')||(tagName==='SELECT')||((tagName==='DIV'||tagName==='SPAN')&&className&&className.indexOf(INTERMediatorLib.roleAsEnclosureClassName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsEnclosureDataControlName)>=0)){if(nodeOnly){return!0}else{children=node.childNodes;for(k=0;k<children.length;k++){if(INTERMediatorLib.isRepeater(children[k],!0)){return!0}}}}
return!1},isRepeater:function(node,nodeOnly){'use strict';var tagName,className,children,k,controlAttr;if(!node||node.nodeType!==1){return!1}
className=INTERMediatorLib.getClassAttributeFromNode(node);if(className&&className.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterClassName)>=0){return!1}
controlAttr=node.getAttribute('data-im-control');if(controlAttr&&controlAttr.indexOf(INTERMediatorLib.ignoreEnclosureRepeaterControlName)>=0){return!1}
tagName=node.tagName;if((tagName==='TR')||(tagName==='LI')||(tagName==='OPTION')||(className&&className.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)||(controlAttr&&controlAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)){if(nodeOnly){return!0}else{return searchLinkedElement(node)}}
return!1;function searchLinkedElement(node){if(INTERMediatorLib.isLinkedElement(node)){return!0}
children=node.childNodes;for(k=0;k<children.length;k++){if(children[k].nodeType===1){if(INTERMediatorLib.isLinkedElement(children[k])){return!0}else if(searchLinkedElement(children[k])){return!0}}}
return!1}},isLinkedElement:function(node){'use strict';var classInfo,matched,attr;if(node!==null&&node.getAttribute){attr=node.getAttribute('data-im');if(attr){return!0}
if(INTERMediator.titleAsLinkInfo){if(node.getAttribute('TITLE')!==null&&node.getAttribute('TITLE').length>0){return!0}}
if(INTERMediator.classAsLinkInfo){classInfo=INTERMediatorLib.getClassAttributeFromNode(node);if(classInfo!==null){matched=classInfo.match(/IM\[.*\]/);if(matched){return!0}}}}
return!1},isWidgetElement:function(node){'use strict';var classInfo,matched,attr,parentNode;if(!node){return!1}
if(INTERMediatorLib.getLinkedElementInfo(node)){attr=node.getAttribute('data-im-widget');if(attr){return!0}
classInfo=INTERMediatorLib.getClassAttributeFromNode(node);if(classInfo!==null){matched=classInfo.match(/IM_WIDGET\[.*\]/);if(matched){return!0}}}else{parentNode=node.parentNode;if(!parentNode&&INTERMediatorLib.getLinkedElementInfoImpl(parentNode)){attr=parentNode.getAttribute('data-im-widget');if(attr){return!0}
classInfo=INTERMediatorLib.getClassAttributeFromNode(parentNode);if(classInfo!==null){matched=classInfo.match(/IM_WIDGET\[.*\]/);if(matched){return!0}}}}
return!1},isNamedElement:function(node){'use strict';var nameInfo,matched;if(node!==null){nameInfo=node.getAttribute('data-im-group');if(nameInfo){return!0}
nameInfo=node.getAttribute('name');if(nameInfo){matched=nameInfo.match(/IM\[.*\]/);if(matched){return!0}}}
return!1},getEnclosureSimple:function(node){'use strict';if(INTERMediatorLib.isEnclosure(node,!0)){return node}
return INTERMediatorLib.getEnclosureSimple(node.parentNode)},getEnclosure:function(node){'use strict';var currentNode,detectedRepeater;currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){detectedRepeater=currentNode}else if(isRepeaterOfEnclosure(detectedRepeater,currentNode)){detectedRepeater=null;return currentNode}
currentNode=currentNode.parentNode}
return null;function isRepeaterOfEnclosure(repeater,enclosure){var repeaterTag,enclosureTag,enclosureClass,repeaterClass,enclosureDataAttr,repeaterDataAttr,repeaterType;if(!repeater||!enclosure){return!1}
repeaterTag=repeater.tagName;enclosureTag=enclosure.tagName;if((repeaterTag==='TR'&&enclosureTag==='TBODY')||(repeaterTag==='OPTION'&&enclosureTag==='SELECT')||(repeaterTag==='LI'&&enclosureTag==='OL')||(repeaterTag==='LI'&&enclosureTag==='UL')){return!0}
enclosureClass=INTERMediatorLib.getClassAttributeFromNode(enclosure);enclosureDataAttr=enclosure.getAttribute('data-im-control');if((enclosureClass&&enclosureClass.indexOf(INTERMediatorLib.roleAsEnclosureClassName)>=0)||(enclosureDataAttr&&enclosureDataAttr.indexOf('enclosure')>=0)){repeaterClass=INTERMediatorLib.getClassAttributeFromNode(repeater);repeaterDataAttr=repeater.getAttribute('data-im-control');if((repeaterClass&&repeaterClass.indexOf(INTERMediatorLib.roleAsRepeaterClassName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsRepeaterDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsSeparatorDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsFooterDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsHeaderDataControlName)>=0)||(repeaterDataAttr&&repeaterDataAttr.indexOf(INTERMediatorLib.roleAsNoResultDataControlName)>=0)){return!0}else if(repeaterTag==='INPUT'){repeaterType=repeater.getAttribute('type');if(repeaterType&&((repeaterType.indexOf('radio')>=0||repeaterType.indexOf('check')>=0))){return!0}}}
return!1}},getLinkedElementInfo:function(node){'use strict';var result=INTERMediatorLib.getLinkedElementInfoImpl(node);if(result!==!1){return result}
if(INTERMediatorLib.isWidgetElement(node.parentNode)){return INTERMediatorLib.getLinkedElementInfo(node.parentNode)}
return!1},getLinkedElementInfoImpl:function(node){'use strict';var defs=[],eachDefs,reg,i,attr,matched;if(INTERMediatorLib.isLinkedElement(node)){attr=node.getAttribute('data-im');if(attr!==null&&attr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=attr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(resolveAlias(eachDefs[i]))}}
return defs}
if(INTERMediator.titleAsLinkInfo&&node.getAttribute('TITLE')){eachDefs=node.getAttribute('TITLE').split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(resolveAlias(eachDefs[i]))}
return defs}
if(INTERMediator.classAsLinkInfo){attr=INTERMediatorLib.getClassAttributeFromNode(node);if(attr!==null&&attr.length>0){matched=attr.match(/IM\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(resolveAlias(eachDefs[i]))}}
return defs}}
return!1;function resolveAlias(def){var aliases=INTERMediatorOnPage.getOptionsAliases();if(aliases&&aliases[def]){return aliases[def]}
return def}},getWidgetInfo:function(node){'use strict';var defs=[],eachDefs,i,classAttr,matched,reg;if(INTERMediatorLib.isWidgetElement(node)){classAttr=node.getAttribute('data-im-widget');if(classAttr&&classAttr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=classAttr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(eachDefs[i])}}
return defs}
classAttr=INTERMediatorLib.getClassAttributeFromNode(node);if(classAttr&&classAttr.length>0){matched=classAttr.match(/IM_WIDGET\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(eachDefs[i])}
return defs}}
return!1},getNamedInfo:function(node){'use strict';var defs=[],eachDefs,i,nameAttr,matched,reg;if(INTERMediatorLib.isNamedElement(node)){nameAttr=node.getAttribute('data-im-group');if(nameAttr&&nameAttr.length>0){reg=new RegExp('[\\s'+INTERMediator.defDivider+']+');eachDefs=nameAttr.split(reg);for(i=0;i<eachDefs.length;i++){if(eachDefs[i]&&eachDefs[i].length>0){defs.push(eachDefs[i])}}
return defs}
nameAttr=node.getAttribute('name');if(nameAttr&&nameAttr.length>0){matched=nameAttr.match(/IM\[([^\]]*)\]/);eachDefs=matched[1].split(INTERMediator.defDivider);for(i=0;i<eachDefs.length;i++){defs.push(eachDefs[i])}
return defs}}
return!1},repeaterTagFromEncTag:function(tag){'use strict';if(tag==='TBODY'){return'TR'}else if(tag==='SELECT'){return'OPTION'}else if(tag==='UL'){return'LI'}else if(tag==='OL'){return'LI'}
return null},getNodeInfoArray:function(nodeInfo){'use strict';var comps,tableName,fieldName,targetName;if(!nodeInfo||!nodeInfo.split){return{'table':null,'field':null,'target':null,'tableindex':null,'crossTable':!1}}
comps=nodeInfo.split(INTERMediator.separator);tableName='';fieldName='';targetName='';if(comps.length===3){tableName=comps[0];fieldName=comps[1];targetName=comps[2]}else if(comps.length===2){tableName=comps[0];fieldName=comps[1]}else{fieldName=nodeInfo}
return{'table':tableName,'field':fieldName,'target':targetName,'tableindex':'_im_index_'+tableName,'crossTable':INTERMediator.crossTableStage===3}},getCalcNodeInfoArray:function(idValue){'use strict';console.error('INTERMediatorLib.getCalcNodeInfoArray method in INTER-Mediator-Page.js will be removed in Ver.6.0. '+'Here is no alternative method.');var comps,tableName,fieldName,targetName,node,attribute;if(!idValue){return null}
node=document.getElementById(idValue);if(!node){return null}
attribute=node.getAttribute('data-im');if(!attribute){return null}
comps=attribute.split(INTERMediator.separator);tableName='';fieldName='';targetName='';if(comps.length===3){tableName=comps[0];fieldName=comps[1];targetName=comps[2]}else if(comps.length===2){fieldName=comps[0];targetName=comps[1]}else{fieldName=attribute}
return{'table':tableName,'field':fieldName,'target':targetName,'tableindex':'_im_index_'+tableName}},getClassAttributeFromNode:function(node){'use strict';var str='';if(node===null){return''}
if(INTERMediator.isIE&&INTERMediator.ieVersion<8){str=node.getAttribute('className')}else{str=node.getAttribute('class')}
return str},setClassAttributeToNode:function(node,className){'use strict';if(node===null){return}
if(INTERMediator.isIE&&INTERMediator.ieVersion<8){node.setAttribute('className',className)}else{node.setAttribute('class',className)}},eventInfos:[],addEvent:function(node,evt,func){'use strict';if(node.addEventListener){node.addEventListener(evt,func,!1);this.eventInfos.push({'node':node,'event':evt,'function':func});return this.eventInfos.length-1}else if(node.attachEvent){node.attachEvent('on'+evt,func);this.eventInfos.push({'node':node,'event':evt,'function':func});return this.eventInfos.length-1}
return-1},removeEvent:function(serialId){'use strict';if(this.eventInfos[serialId].node.removeEventListener){this.eventInfos[serialId].node.removeEventListener(this.eventInfos[serialId].evt,this.eventInfos[serialId].func,!1)}else if(this.eventInfos[serialId].node.detachEvent){this.eventInfos[serialId].node.detachEvent('on'+this.eventInfos[serialId].evt,this.eventInfos[serialId].func)}},toNumber:function(str){'use strict';var s='',i,c;str=str.toString();for(i=0;i<str.length;i++){c=str.charAt(i);if((c>='0'&&c<='9')||c==='.'||c==='-'||c===INTERMediatorOnPage.localeInfo.mon_decimal_point){s+=c}else if(c>='0'&&c<='9'){s+=String.fromCharCode(c.charCodeAt(0)-'0'.charCodeAt(0)+'0'.charCodeAt(0))}}
return parseFloat(s)},RoundHalfToEven:function(value,digit){'use strict';throw 'RoundHalfToEven method is NOT implemented.'},Round:function(value,digit){'use strict';var powers=Math.pow(10,digit);return Math.round(value*powers)/powers},normalizeNumerics:function(value){'use strict';var i;var punc=INTERMediatorOnPage.localeInfo.decimal_point?INTERMediatorOnPage.localeInfo.decimal_point:'.';var mpunc=INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.';var rule='0123456789';if(punc){rule+='\\'+punc}
if(mpunc&&mpunc!==punc){rule+='\\'+mpunc}
rule='[^'+rule+']';value=String(value);if(value&&value.match(/[0123456789]/)){for(i=0;i<10;i++){value=value.split(String.fromCharCode(65296+i)).join(String(i))}
value=value.replace('.','.')}
return value?parseFloat(value.replace(new RegExp(rule,'g'),'')):''},objectToString:function(obj){'use strict';var str,i,key,sq=String.fromCharCode(39);if(obj===null){return'null'}
if(typeof obj==='object'){str='';if(obj.constructor===Array){for(i=0;i<obj.length;i++){str+=INTERMediatorLib.objectToString(obj[i])+', '}
return'['+str+']'}else{for(key in obj){if(obj.hasOwnProperty(key)){str+=sq+key+sq+':'+INTERMediatorLib.objectToString(obj[key])+', '}}
return'{'+str+'}'}}else{return sq+obj+sq}},numberFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormat(str,digit,flags)},getTargetTableForRetrieve:function(element){'use strict';if(element.view!==null){return element.view}
return element.name},getTargetTableForUpdate:function(element){'use strict';if(element.table!==null){return element.table}
return element.name},getInsertedString:function(tmpStr,dataArray){'use strict';var resultStr,counter;resultStr=tmpStr;if(dataArray!==null){for(counter=1;counter<=dataArray.length;counter++){resultStr=resultStr.replace('@'+counter+'@',dataArray[counter-1])}}
return resultStr},getInsertedStringFromErrorNumber:function(errNum,dataArray){'use strict';var resultStr,counter,messageArray;messageArray=INTERMediatorOnPage.getMessages();resultStr=messageArray?messageArray[errNum]:'Error:'+errNum;if(dataArray){for(counter=1;counter<=dataArray.length;counter++){resultStr=resultStr.replace('@'+counter+'@',dataArray[counter-1])}}
return resultStr},getNamedObject:function(obj,key,named){'use strict';var index;for(index in obj){if(obj[index][key]===named){return obj[index]}}
return null},getNamedObjectInObjectArray:function(ar,key,named){'use strict';var i;for(i=0;i<ar.length;i++){if(ar[i][key]===named){return ar[i]}}
return null},getNamedValueInObject:function(ar,key,named,retrieveKey){var result=[],index;for(index in ar){if(ar[index][key]===named){result.push(ar[index][retrieveKey])}}
if(result.length===0){return null}else if(result.length===1){return result[0]}else{return result}},is_array:function(target){'use strict';return target&&typeof target==='object'&&typeof target.length==='number'&&typeof target.splice==='function'&&!(target.propertyIsEnumerable('length'))},getNamedValuesInObject:function(ar,key1,named1,key2,named2,retrieveKey){'use strict';var result=[],index;for(index in ar){if(ar.hasOwnProperty(index)&&ar[index][key1]===named1&&ar[index][key2]===named2){result.push(ar[index][retrieveKey])}}
if(result.length===0){return null}else if(result.length===1){return result[0]}else{return result}},getRecordsetFromFieldValueObject:function(obj){'use strict';var recordset={},index;for(index in obj){if(obj.hasOwnProperty(index)){recordset[obj[index].field]=obj[index].value}}
return recordset},getNodePath:function(node){'use strict';if(node.tagName===null){return''}else{return INTERMediatorLib.getNodePath(node.parentNode)+'/'+node.tagName}},isPopupMenu:function(element){'use strict';if(!element||!element.tagName){return!1}
if(element.tagName==='SELECT'){return!0}
return!1},getElementsByClassNameOrDataAttr:function(node,cName){'use strict';var nodes=[],attrValue;attrValue=(cName.match(/^_im_/))?cName.substr(4):cName;if(attrValue){checkNode(node)}
return nodes;function checkNode(target){var value,i,items;if(target===undefined||target.nodeType!==1){return}
value=INTERMediatorLib.getClassAttributeFromNode(target);if(value){items=value.split('|');for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
value=target.getAttribute('data-im-control');if(value){items=value.split(/[| ]/);for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
value=target.getAttribute('data-im');if(value){items=value.split(/[| ]/);for(i=0;i<items.length;i++){if(items[i]===attrValue){nodes.push(target)}}}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByAttributeValue:function(node,attribute,value){'use strict';var nodes=[];var reg=new RegExp(value);checkNode(node);return nodes;function checkNode(target){var aValue,i;if(target===undefined||target.nodeType!==1){return}
aValue=target.getAttribute(attribute);if(aValue&&aValue.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByClassName:function(node,cName){'use strict';var nodes=[];var reg=new RegExp(cName);checkNode(node);return nodes;function checkNode(target){var className,i;if(target===undefined||target.nodeType!==1){return}
className=INTERMediatorLib.getClassAttributeFromNode(target);if(className&&className.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},getElementsByIMManaged:function(node){'use strict';var nodes=[];var reg=new RegExp(/^IM/);checkNode(node);return nodes;function checkNode(target){var nodeId,i;if(target===undefined||target.nodeType!==1){return}
nodeId=target.getAttribute('id');if(nodeId&&nodeId.match(reg)){nodes.push(target)}
for(i=0;i<target.children.length;i++){checkNode(target.children[i])}}},seekLinkedAndWidgetNodes:function(nodes,ignoreEnclosureCheck){'use strict';var linkedNodesCollection=[];var widgetNodesCollection=[];var i,doEncCheck=ignoreEnclosureCheck;if(ignoreEnclosureCheck===undefined||ignoreEnclosureCheck===null){doEncCheck=!1}
for(i=0;i<nodes.length;i++){seekLinkedElement(nodes[i])}
return{linkedNode:linkedNodesCollection,widgetNode:widgetNodesCollection};function seekLinkedElement(node){var nType,currentEnclosure,children,i;nType=node.nodeType;if(nType===1){if(INTERMediatorLib.isLinkedElement(node)){currentEnclosure=doEncCheck?INTERMediatorLib.getEnclosure(node):null;if(currentEnclosure===null){linkedNodesCollection.push(node)}else{return currentEnclosure}}
if(INTERMediatorLib.isWidgetElement(node)){currentEnclosure=doEncCheck?INTERMediatorLib.getEnclosure(node):null;if(currentEnclosure===null){widgetNodesCollection.push(node)}else{return currentEnclosure}}
children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElement(children[i])}}
return null}},createErrorMessageNode:function(tag,message){'use strict';var messageNode;messageNode=document.createElement(tag);INTERMediatorLib.setClassAttributeToNode(messageNode,'_im_alertmessage');messageNode.appendChild(document.createTextNode(message));return messageNode},removeChildNodes:function(node){'use strict';if(node){while(node.childNodes.length>0){node.removeChild(node.childNodes[0])}}},clearErrorMessage:function(node){'use strict';var errorMsgs,j;if(node){errorMsgs=INTERMediatorLib.getElementsByClassName(node.parentNode,'_im_alertmessage');for(j=0;j<errorMsgs.length;j++){errorMsgs[j].parentNode.removeChild(errorMsgs[j])}}},dateTimeStringISO:function(dt){'use strict';dt=(!dt)?new Date():dt;return dt.getFullYear()+'-'+('0'+(dt.getMonth()+1)).substr(-2,2)+'-'+('0'+dt.getDate()).substr(-2,2)+' '+('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)},dateTimeStringFileMaker:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+(dt.getMonth()+1)).substr(-2,2)+'/'+('0'+dt.getDate()).substr(-2,2)+'/'+dt.getFullYear()+' '+('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)},dateStringISO:function(dt){'use strict';dt=(!dt)?new Date():dt;return dt.getFullYear()+'-'+('0'+(dt.getMonth()+1)).substr(-2,2)+'-'+('0'+dt.getDate()).substr(-2,2)},dateStringFileMaker:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+(dt.getMonth()+1)).substr(-2,2)+'/'+('0'+dt.getDate()).substr(-2,2)+'/'+dt.getFullYear()},timeString:function(dt){'use strict';dt=(!dt)?new Date():dt;return('0'+dt.getHours()).substr(-2,2)+':'+('0'+dt.getMinutes()).substr(-2,2)+':'+('0'+dt.getSeconds()).substr(-2,2)}};INTERMediatorLib.initialize();var IMLibNodeGraph={nodes:[],edges:[],clear:function(){'use strict';this.nodes=[];this.edges=[]},addNode:function(node){'use strict';if(this.nodes.indexOf(node)<0){this.nodes.push(node)}},addEdge:function(fromNode,toNode){'use strict';if(this.nodes.indexOf(fromNode)<0){this.addNode(fromNode)}
if(this.nodes.indexOf(toNode)<0){this.addNode(toNode)}
this.edges.push({from:fromNode,to:toNode})},getAllNodesInEdge:function(){'use strict';var i,nodes=[];for(i=0;i<this.edges.length;i++){if(nodes.indexOf(this.edges[i].from)<0){nodes.push(this.edges[i].from)}
if(nodes.indexOf(this.edges[i].to)<0){nodes.push(this.edges[i].to)}}
return nodes},getLeafNodes:function(){'use strict';var i,srcs=[],dests=[],srcAndDests=this.getAllNodesInEdge();for(i=0;i<this.edges.length;i++){srcs.push(this.edges[i].from)}
for(i=0;i<this.edges.length;i++){if(srcs.indexOf(this.edges[i].to)<0&&dests.indexOf(this.edges[i].to)<0){dests.push(this.edges[i].to)}}
for(i=0;i<this.nodes.length;i++){if(srcAndDests.indexOf(this.nodes[i])<0){dests.push(this.nodes[i])}}
return dests},getLeafNodesWithRemoving:function(){'use strict';var i,newEdges=[],dests=this.getLeafNodes();for(i=0;i<this.edges.length;i++){if(dests.indexOf(this.edges[i].to)<0){newEdges.push(this.edges[i])}}
this.edges=newEdges;for(i=0;i<dests.length;i++){this.nodes.splice(this.nodes.indexOf(dests[i]),1)}
return dests},removeNode:function(node){'use strict';var i,newEdges=[];for(i=0;i<this.edges.length;i++){if(this.edges[i].to!=node){newEdges.push(this.edges[i])}}
this.edges=newEdges;this.nodes.splice(this.nodes.indexOf(node),1)},applyToAllNodes:function(f){'use strict';var i;for(i=0;i<this.nodes.length;i++){f(this.nodes[i])}},};var IMLibFormat={numberFormatImpl:function(str,digit,decimalPoint,thousandsSep,currencySymbol,flags){'use strict';var s,n,prefix,i,sign,tailSign='',power,underDot,underNumStr,pstr,roundedNum,underDecimalNum,integerNum,formatted,numStr,j,isMinusValue,numerals,numbers;if(str===''||str===null||str===undefined){return''}
prefix=(String(str).substring(0,1)==='-')?'-':'';if(String(str).match(/[-]/)){str=prefix+String(str).split('-').join('')}
n=INTERMediatorLib.toNumber(str);if(isNaN(n)){return''}
if(flags===undefined){flags={}}
sign=INTERMediatorOnPage.localeInfo.positive_sign;isMinusValue=!1;if(n<0){sign=INTERMediatorOnPage.localeInfo.negative_sign;if(flags.negativeStyle===0||flags.negativeStyle===1){sign='-'}else if(flags.negativeStyle===2){sign='(';tailSign=')'}else if(flags.negativeStyle===3){sign='<';tailSign='>'}else if(flags.negativeStyle===4){sign=' CR'}else if(flags.negativeStyle===5){sign='▲'}
n=-n;isMinusValue=!0}
if(flags.blankIfZero===!0&&n===0){return''}
if(flags.usePercentNotation){n=n*100}
underDot=(digit===undefined)?INTERMediatorOnPage.localeInfo.frac_digits:INTERMediatorLib.toNumber(digit);power=Math.pow(10,underDot);roundedNum=Math.round(n*power);underDecimalNum=(underDot>0)?roundedNum%power:0;integerNum=(roundedNum-underDecimalNum)/power;underNumStr=(underDot>0)?String(underDecimalNum):'';while(underNumStr.length<underDot){underNumStr='0'+underNumStr}
if(flags.useSeparator===!0){if(n===0){formatted='0'}else{n=integerNum;s=[];if(flags.kanjiSeparator===1||flags.kanjiSeparator===2){numerals=['万','億','兆','京','垓','𥝱','穣','溝','澗','正','載','極','恒河沙','阿僧祇','那由他','不可思議','無量大数'];i=0;formatted='';for(n=Math.floor(n);n>0;n=Math.floor(n/10000)){if(n>=10000){pstr='0000'+(n%10000).toString()}else{pstr=(n%10000).toString()}
if(flags.kanjiSeparator===1){if(n>=10000){if(pstr.substr(pstr.length-4)!=='0000'){formatted=numerals[i]+Number(pstr.substr(pstr.length-4))+formatted}else{if(numerals[i-1]!==formatted.charAt(0)){formatted=numerals[i]+formatted}else{formatted=numerals[i]+formatted.slice(1)}}}else{formatted=n+formatted}}else if(flags.kanjiSeparator===2){numStr=pstr.substr(pstr.length-4);pstr='';if(numStr==='0001'){pstr='1'}else if(numStr!=='0000'){for(j=0;j<numStr.length;j++){if(numStr.charAt(j)>1){pstr=pstr+numStr.charAt(j)}
if(numStr.charAt(j)>0){if(numStr.length-j===4){pstr=pstr+'千'}else if(numStr.length-j===3){pstr=pstr+'百'}else if(numStr.length-j===2){pstr=pstr+'十'}}}}
if(n>=10000){if(pstr.length>0){formatted=numerals[i]+pstr+formatted}else{if(numerals[i-1]!==formatted.charAt(0)){formatted=numerals[i]+formatted}else{formatted=numerals[i]+formatted.slice(1)}}}else{if(numStr.length===1){formatted=n+formatted}else{formatted=pstr+formatted}}}
i++}
formatted=formatted+(underNumStr===''?'':decimalPoint+underNumStr)}else{for(n=Math.floor(n);n>0;n=Math.floor(n/1000)){if(n>=1000){pstr='000'+(n%1000).toString();s.push(pstr.substr(pstr.length-3))}else{s.push(n)}}
formatted=s.reverse().join(thousandsSep)+(underNumStr===''?'':decimalPoint+underNumStr)}
if(flags.negativeStyle===0||flags.negativeStyle===5){formatted=sign+formatted}else if(flags.negativeStyle===1||flags.negativeStyle===4){formatted=formatted+sign}else if(flags.negativeStyle===2||flags.negativeStyle===3){formatted=sign+formatted+tailSign}else{formatted=sign+formatted}}}else{formatted=integerNum+(underNumStr===''?'':decimalPoint+underNumStr);if(flags.negativeStyle===0||flags.negativeStyle===5){formatted=sign+formatted}else if(flags.negativeStyle===1||flags.negativeStyle===4){formatted=formatted+sign}else if(flags.negativeStyle===2||flags.negativeStyle===3){formatted=sign+formatted+tailSign}else{formatted=sign+formatted}}
if(currencySymbol){if(!isMinusValue){if(parseInt(INTERMediatorOnPage.localeInfo.p_cs_precedes)===1){if(parseInt(INTERMediatorOnPage.localeInfo.p_sep_by_space)===1){formatted=currencySymbol+' '+formatted}else{formatted=currencySymbol+formatted}}else{if(parseInt(INTERMediatorOnPage.localeInfo.p_sep_by_space)===1){formatted=formatted+' '+currencySymbol}else{formatted=formatted+currencySymbol}}}else{if(parseInt(INTERMediatorOnPage.localeInfo.n_cs_precedes)===1){if(parseInt(INTERMediatorOnPage.localeInfo.n_sep_by_space)===1){formatted=currencySymbol+' '+formatted}else{formatted=currencySymbol+formatted}}else{if(parseInt(INTERMediatorOnPage.localeInfo.n_sep_by_space)===1){formatted=formatted+' '+currencySymbol}else{formatted=formatted+currencySymbol}}}}
if(flags.charStyle){if(flags.charStyle===1){for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String.fromCharCode(65296+i))}}else if(flags.charStyle===2){numbers={0:'〇',1:'一',2:'二',3:'三',4:'四',5:'五',6:'六',7:'七',8:'八',9:'九'};for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String(numbers[i]))}}else if(flags.charStyle===3){numbers={0:'〇',1:'壱',2:'弐',3:'参',4:'四',5:'伍',6:'六',7:'七',8:'八',9:'九'};for(i=0;i<10;i++){formatted=String(formatted).split(String(i)).join(String(numbers[i]))}}}
if(flags.usePercentNotation===!0&&formatted!==''){formatted=formatted+'%'}
return formatted},getKanjiNumber:function(n){'use strict';var s=[],count=0;String(n).split('').reverse().forEach(function(c){s.push(IMLibFormat.kanjiDigit[count]);count++;s.push(IMLibFormat.kanjiNumbers[parseInt(c)])});return s.reverse().join('')},numberFormat:function(str,digit,flags){'use strict';if(flags===undefined){flags={}}
flags.useSeparator=!0;return this.decimalFormat(str,digit,flags)},percentFormat:function(str,digit,flags){'use strict';if(typeof flags!=='object'){flags={}}
flags.usePercentNotation=!0;return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',!1,flags)},decimalFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',!1,flags)},currencyFormat:function(str,digit,flags){'use strict';return IMLibFormat.numberFormatImpl(str,digit,INTERMediatorOnPage.localeInfo.mon_decimal_point?INTERMediatorOnPage.localeInfo.mon_decimal_point:'.',INTERMediatorOnPage.localeInfo.mon_thousands_sep?INTERMediatorOnPage.localeInfo.mon_thousands_sep:',',INTERMediatorOnPage.localeInfo.currency_symbol?INTERMediatorOnPage.localeInfo.currency_symbol:'¥',flags)},booleanFormat:function(str,forms){'use strict';var trueString='true',falseString='false',fmtStr;var params=forms.split(',');if(params[0]){fmtStr=params[0].trim();if(fmtStr.length>0){trueString=fmtStr}}
if(params[1]){fmtStr=params[1].trim();if(fmtStr.length>0){falseString=fmtStr}}
if(str===''||str===null){return''}else{if(parseInt(str,10)!==0){return trueString}else{return falseString}}},datetimeFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'datetime')},dateFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'date')},timeFormat:function(str,params){'use strict';return IMLibFormat.datetimeFormatImpl(str,params,'time')},placeHolder:{'%Y':Date.prototype.getFullYear,'%y':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getFullYear())},'%g':function(){'use strict';return IMLibFormat.getLocalYear(this,1)},'%G':function(){'use strict';return IMLibFormat.getLocalYear(this,2)},'%M':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getMonth()+1)},'%m':function(){'use strict';return this.getMonth()+1},'%b':function(){'use strict';return INTERMediatorOnPage.localeInfo.ABMON[this.getMonth()]},'%B':function(){'use strict';return INTERMediatorOnPage.localeInfo.MON[this.getMonth()]},'%t':function(){'use strict';return IMLibFormat.eMonAbbr[this.getMonth()]},'%T':function(){'use strict';return IMLibFormat.eMonName[this.getMonth()]},'%D':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getDate())},'%d':Date.prototype.getDate,'%a':function(){'use strict';return IMLibFormat.eDayAbbr[this.getDay()]},'%A':function(){'use strict';return IMLibFormat.eDayName[this.getDay()]},'%w':function(){'use strict';return INTERMediatorOnPage.localeInfo.ABDAY[this.getDay()]},'%W':function(){'use strict';return INTERMediatorOnPage.localeInfo.DAY[this.getDay()]},'%H':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getHours())},'%h':Date.prototype.getHours,'%J':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getHours()%12)},'%j':function(){'use strict';return this.getHours()%12},'%K':function(){'use strict';var n=this.getHours()%12;return IMLibFormat.tweDigitsNumber(n===0?12:n)},'%k':function(){'use strict';var n=this.getHours()%12;return n===0?12:n},'%I':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getMinutes())},'%i':Date.prototype.getMinutes,'%S':function(){'use strict';return IMLibFormat.tweDigitsNumber(this.getSeconds())},'%s':Date.prototype.getSeconds,'%P':function(){'use strict';return Math.floor(this.getHours()/12)===0?'AM':'PM'},'%p':function(){'use strict';return Math.floor(this.getHours()/12)===0?'am':'pm'},'%N':function(){'use strict';return Math.floor(this.getHours()/12)===0?INTERMediatorOnPage.localeInfo.AM_STR:INTERMediatorOnPage.localeInfo.PM_STR},'%%':function(){'use strict';return'%'}},tweDigitsNumber:function(n){'use strict';var v=parseInt(n);return('0'+v.toString()).substr(-2,2)},jYearStartDate:{'2019/5/1':'令和','1989/1/8':'平成','1926/12/25':'昭和','1912/7/30':'大正','1868/1/25':'明治'},eDayName:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],eDayAbbr:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],eMonName:['January','February','March','April','May','June','July','August','September','October','November','December'],eMonAbbr:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],kanjiNumbers:['〇','一','二','三','四','五','六','七','八','九'],kanjiDigit:['','十','百','千','万'],getLocalYear:function(dt,fmt){'use strict';var gengoName,gengoYear,startDateStr,dtStart;if(!dt){return''}
gengoName='';gengoYear=0;for(startDateStr in IMLibFormat.jYearStartDate){if(IMLibFormat.jYearStartDate.hasOwnProperty(startDateStr)){dtStart=new Date(startDateStr);if(dt>=dtStart){gengoName=IMLibFormat.jYearStartDate[startDateStr];gengoYear=dt.getFullYear()-dtStart.getFullYear()+1;gengoYear=((gengoYear===1)?'元':(fmt===2?IMLibFormat.getKanjiNumber(gengoYear):gengoYear));break}}}
return gengoName+gengoYear+'年'},datetimeFormatImpl:function(str,params,flags){'use strict';var dt,c,result='',replaced,hasColon,hasSlash,hasDash;str=(Object.prototype.toString.call(str)==='[object Array]')?str.join():str;var paramStr=params.trim().toUpperCase();var kind=flags.trim().toUpperCase();var key=kind.substr(0,1)+'_FMT_'+paramStr;if(INTERMediatorOnPage.localeInfo[key]){params=INTERMediatorOnPage.localeInfo[key];if(kind==='DATETIME'){params+=' '+INTERMediatorOnPage.localeInfo['T_FMT_'+paramStr]}}
hasColon=str.indexOf(':')>-1;hasSlash=str.indexOf('/')>-1;hasDash=str.indexOf('-')>-1;if(!hasColon&&(hasSlash||hasDash)){str+=' 00:00:00'}else if(hasColon&&!hasSlash&&!hasDash){str='1970/01/01 '+str}
dt=new Date(str);if(dt.toString()==='Invalid Date'){dt=new Date(str.replace(/-/g,'/'))}
if(dt.toString()==='Invalid Date'){return''}
for(c=0;c<params.length;c++){if((c+1)<params.length&&IMLibFormat.placeHolder[params.substr(c,2)]){replaced=(IMLibFormat.placeHolder[params.substr(c,2)]).apply(dt);result+=replaced;c++}else{result+=params.substr(c,1)}}
return result},convertNumeric:function(value){'use strict';value=value.replace(new RegExp(INTERMediatorOnPage.localeInfo.mon_thousands_sep,'g'),'');value=INTERMediatorLib.normalizeNumerics(value);if(value!==''){value=parseFloat(value)}
return value},convertBoolean:function(value,forms){'use strict';var trueString='true',falseString='false',fmtStr;value=value.trim();var params=forms.split(',');if(params[0]){fmtStr=params[0].trim();if(fmtStr.length>0){trueString=fmtStr}}
if(params[1]){fmtStr=params[1].trim();if(fmtStr.length>0){falseString=fmtStr}}
if(value===trueString){return!0}else if(value===falseString){return!1}
return null},convertPercent:function(value){'use strict';value=value.replace(new RegExp(INTERMediatorOnPage.localeInfo.mon_thousands_sep,'g'),'');value=value.replace('%','');value=INTERMediatorLib.normalizeNumerics(value);if(value!==''){value=parseFloat(value)/100}
return value},convertDate:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'date')},convertTime:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'time')},convertDateTime:function(value,params){'use strict';return IMLibFormat.convertDateTimeImpl(value,params,'datetime')},convertDateTimeImpl:function(value,params,flags){'use strict';var c,result,replacement=[],regexp='';var r,matched,y,m,d,h,i,s,paramStr,kind,key,mon;paramStr=params.trim().toUpperCase();kind=flags.trim().toUpperCase();key=kind.substr(0,1)+'_FMT_'+paramStr;if(INTERMediatorOnPage.localeInfo[key]){params=INTERMediatorOnPage.localeInfo[key];if(kind==='DATETIME'){params+=' '+INTERMediatorOnPage.localeInfo['T_FMT_'+paramStr]}}
params=params.replace(/([\(\)])/g,'\\$1');for(c=0;c<params.length;c++){if((c+1)<params.length&&IMLibFormat.reverseRegExp[params.substr(c,2)]){regexp+=IMLibFormat.reverseRegExp[params.substr(c,2)];replacement.push(params.substr(c,2));c++}else{regexp+=params.substr(c,1)}}
r=new RegExp(regexp);matched=r.exec(value);result=value;if(matched){for(c=0;c<replacement.length;c++){switch(replacement[c]){case '%Y':case '%y':y=matched[c+1];break;case '%M':case '%m':m=matched[c+1];break;case '%T':case '%t':mon=matched[c+1];m=IMLibFormat.eMonAbbr.indexOf(mon.substr(0,1).toUpperCase()+mon.substr(1,2).toLowerCase());m++;break;case '%D':case '%d':d=matched[c+1];break;case '%H':case '%h':h=matched[c+1];break;case '%I':case '%i':i=matched[c+1];break;case '%S':case '%s':s=matched[c+1];break}}
if(y&&m&&d&&h&&i&&s){result=y+'-'+m+'-'+d+' '+h+':'+i+':'+s}else if(y&&m&&d){result=y+'-'+m+'-'+d}else if(h&&i&&s){result=h+':'+i+':'+s}}
return result},reverseRegExp:{'%Y':'([\\d]{4})','%y':'([\\d]{2})','%g':'(明治|大正|昭和|平成|令和)(元|[\\d]{1,2})年','%G':'(明治|大正|昭和|平成|令和)(.+)年','%M':'([\\d]{1,2})','%m':'([\\d]{1,2})','%b':'(.+)','%B':'(.+)','%t':'(.+)','%T':'(.+)','%D':'([\\d]{1,2})','%d':'([\\d]{1,2})','%a':'(.+)','%A':'(.+)','%w':'(.+)','%W':'(.+)','%H':'([\\d]{1,2})','%h':'([\\d]{1,2})','%J':'([\\d]{1,2})','%j':'([\\d]{1,2})','%K':'([\\d]{1,2})','%k':'([\\d]{1,2})','%I':'([\\d]{1,2})','%i':'([\\d]{1,2})','%S':'([\\d]{1,2})','%s':'([\\d]{1,2})','%P':'(AM|PM)','%p':'(am|pm)','%N':'('+INTERMediatorOnPage.localeInfo.AM_STR+'|'+INTERMediatorOnPage.localeInfo.PM_STR+')','%%':'[\%]'}};var IMLibElement={formatters:{number:IMLibFormat.decimalFormat,currency:IMLibFormat.currencyFormat,boolean:IMLibFormat.booleanFormat,percent:IMLibFormat.percentFormat,date:IMLibFormat.dateFormat,datetime:IMLibFormat.datetimeFormat,time:IMLibFormat.timeFormat},unformatters:{number:IMLibFormat.convertNumeric,currency:IMLibFormat.convertNumeric,boolean:IMLibFormat.convertBoolean,percent:IMLibFormat.convertPercent,date:IMLibFormat.convertDate,datetime:IMLibFormat.convertDateTime,time:IMLibFormat.convertTime},formatOptions:{'useseparator':{useSeparator:!0},'blankifzero':{blankIfZero:!0}},formatNegativeStyle:{leadingminus:{negativeStyle:0},'leading-minus':{negativeStyle:0},trailingminus:{negativeStyle:1},'trailing-minus':{negativeStyle:1},parenthesis:{negativeStyle:2},angle:{negativeStyle:3},credit:{negativeStyle:4},triangle:{negativeStyle:5}},formatNumeralType:{'half-width':{charStyle:0},'full-width':{charStyle:1},'kanji-numeral-modern':{charStyle:2},'kanji-numeral':{charStyle:3}},formatKanjiSeparator:{'every-4th-place':{kanjiSeparator:1,useSeparator:!0},'full-notation':{kanjiSeparator:2,useSeparator:!0}},appendObject:function(obj,adding){'use strict';var result=obj;if(adding){for(var key in adding){if(adding.hasOwnProperty(key)){result[key]=adding[key]}}}
return result},initilaizeFlags:function(element){'use strict';var flags,formatOption,negativeStyle,charStyle,kanjiSeparator;flags={useSeparator:!1,blankIfZero:!1,negativeStyle:0,charStyle:0,kanjiSeparator:0};formatOption=element.getAttribute('data-im-format-options');flags=IMLibElement.appendObject(flags,IMLibElement.formatOptions[formatOption]);negativeStyle=element.getAttribute('data-im-format-negative-style');flags=IMLibElement.appendObject(flags,IMLibElement.formatNegativeStyle[negativeStyle]);charStyle=element.getAttribute('data-im-format-numeral-type');flags=IMLibElement.appendObject(flags,IMLibElement.formatNumeralType[charStyle]);kanjiSeparator=element.getAttribute('data-im-format-kanji-separator');flags=IMLibElement.appendObject(flags,IMLibElement.formatKanjiSeparator[kanjiSeparator]);return flags},getFormattedValue:function(element,curVal){'use strict';var flags,formatSpec,parsed,formattedValue=null,params,formatFunc,firstParen,lastParen;formatSpec=element.getAttribute('data-im-format');if(!formatSpec){return null}
flags=IMLibElement.initilaizeFlags(element);params=0;formatFunc=IMLibElement.formatters[formatSpec.trim().toLocaleLowerCase()];if(!formatFunc){firstParen=formatSpec.indexOf('(');lastParen=formatSpec.lastIndexOf(')');parsed=formatSpec.substr(0,firstParen).match(/[^a-zA-Z]*([a-zA-Z]+).*/);formatFunc=IMLibElement.formatters[parsed[1].toLocaleLowerCase()];params=formatSpec.substring(firstParen+1,lastParen);if(params.length===0){params=0}}
if(formatFunc){formattedValue=formatFunc(curVal,params,flags)}
return formattedValue},getUnformattedValue:function(element,value){'use strict';var formatSpec,unformatFunc,parsed,params,convertedValue,flags,firstParen,lastParen;formatSpec=element.getAttribute('data-im-format');if(!formatSpec){return null}
flags=IMLibElement.initilaizeFlags(element);unformatFunc=IMLibElement.unformatters[formatSpec.trim().toLocaleLowerCase()];if(!unformatFunc){firstParen=formatSpec.indexOf('(');lastParen=formatSpec.lastIndexOf(')');parsed=formatSpec.substr(0,firstParen).match(/[^a-zA-Z]*([a-zA-Z]+).*/);unformatFunc=IMLibElement.unformatters[parsed[1].toLocaleLowerCase()];params=formatSpec.substring(firstParen+1,lastParen)}
if(unformatFunc){convertedValue=unformatFunc(value,params,flags)}
return convertedValue},setValueToIMNode:function(element,curTarget,curVal,clearField){'use strict';var styleName,currentValue,scriptNode,typeAttr,valueAttr,textNode,formatSpec,formattedValue,needPostValueSet=!1,curValues,i,isReplaceOrAppend=!1,imControl,negativeColor,originalValue,negativeSign,negativeTailSign,flags;if(curVal===undefined){return!1}
if(!element){return!1}
if(curVal===null||curVal===!1){curVal=''}
if(typeof curVal==='object'&&curVal.constructor===Array&&curVal.length>0){curVal=curVal[0]}
imControl=element.getAttribute('data-im-control');if(clearField&&curTarget===''){switch(element.tagName){case 'INPUT':switch(element.getAttribute('type')){case 'text':element.value='';break}
break;case 'SELECT':break;default:while(element.childNodes.length>0){if(element.parentNode.getAttribute('data-im-element')==='processed'||INTERMediatorLib.isWidgetElement(element.parentNode)){return!1}
element.removeChild(element.childNodes[0])}
break}}
formattedValue=IMLibElement.getFormattedValue(element,curVal);if(element.getAttribute('data-im-format')){if(formattedValue===null){INTERMediatorLog.setErrorMessage('The \'data-im-format\' attribute is not valid: '+formatSpec)}else{curVal=formattedValue}}
curVal=String(curVal);negativeColor=element.getAttribute('data-im-format-negative-color');if(curTarget!==null&&curTarget.length>0){if(curTarget.charAt(0)==='#'){curTarget=curTarget.substring(1);originalValue=element.getAttribute('data-im-original-'+curTarget);if(curTarget==='innerHTML'){currentValue=originalValue?originalValue:element.innerHTML;element.innerHTML=currentValue+curVal}else if(curTarget==='textNode'||curTarget==='script'){currentValue=originalValue?originalValue:element.textContent;element.textContent=currentValue+curVal}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);currentValue=originalValue?originalValue:element.style[styleName];if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=currentValue+curVal}}else{currentValue=originalValue?originalValue:element.getAttribute(curTarget);if(curVal.indexOf('/fmi/xml/cnt/')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal}else if(curVal.indexOf('https://'+location.hostname+'/Streaming_SSL/MainDB')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+encodeURIComponent(curVal.replace('https://'+location.hostname,''))}
element.setAttribute(curTarget,currentValue+curVal)}
isReplaceOrAppend=!0;if(!originalValue){element.setAttribute('data-im-original-'+curTarget,currentValue)}}else if(curTarget.charAt(0)==='){curTarget=curTarget.substring(1);originalValue=element.getAttribute('data-im-original-'+curTarget);if(curTarget==='innerHTML'){currentValue=element.innerHTML;curVal=currentValue.replace(',curVal);if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else if(curTarget==='textNode'||curTarget==='script'){currentValue=element.textContent;element.textContent=currentValue.replace(',curVal)}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);currentValue=element.style[styleName];if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=currentValue.replace(',curVal)}}else{currentValue=element.getAttribute(curTarget);if(curVal.indexOf('/fmi/xml/cnt/')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal}else if(curVal.indexOf('https://'+location.hostname+'/Streaming_SSL/MainDB')===0&&currentValue.indexOf('?media=')===-1){curVal=INTERMediatorOnPage.getEntryPath()+'?media='+curVal.replace('https://'+location.hostname,'')}
element.setAttribute(curTarget,currentValue.replace(',curVal))}
isReplaceOrAppend=!0;if(!originalValue){element.setAttribute('data-im-original-'+curTarget,currentValue)}}else{if(INTERMediatorLib.isWidgetElement(element)){if(element._im_setValue){element._im_setValue(curVal)}}else if(curTarget==='innerHTML'){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else if(curTarget==='textNode'){textNode=document.createTextNode(curVal);element.appendChild(textNode)}else if(curTarget==='script'){textNode=document.createTextNode(curVal);if(element.tagName==='SCRIPT'){element.appendChild(textNode)}else{scriptNode=document.createElement('script');scriptNode.type='text/javascript';scriptNode.appendChild(textNode);element.appendChild(scriptNode)}}else if(curTarget.indexOf('style.')===0){styleName=curTarget.substring(6,curTarget.length);if(curTarget!=='style.color'||(curTarget==='style.color'&&!negativeColor)){element.style[styleName]=curVal}}else{if(INTERMediator.isIE&&INTERMediator.ieVersion<10&&element.tagName==='TEXTAREA'){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.setAttribute(curTarget,curVal)}}}else{if(INTERMediatorLib.isWidgetElement(element)){if(element._im_setValue){element._im_setValue(curVal)}}else if(element.tagName==='INPUT'){typeAttr=element.getAttribute('type');if(typeAttr==='checkbox'||typeAttr==='radio'){valueAttr=element.value;if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){curValues=curVal.split(IMLib.cr_char)}else{curValues=curVal.split(IMLib.nl_char)}
if(typeAttr==='checkbox'&&curValues.length>1){for(i=0;i<curValues.length;i++){if(valueAttr===curValues[i]&&!INTERMediator.dontSelectRadioCheck){if(INTERMediator.isIE){element.setAttribute('checked','checked')}else{element.checked=!0}}}}else{if(valueAttr===curVal&&!INTERMediator.dontSelectRadioCheck){if(INTERMediator.isIE){element.setAttribute('checked','checked')}else{element.checked=!0}}else{element.checked=!1}}}else{element.value=curVal}}else if(element.tagName==='SELECT'){needPostValueSet=!0;element.value=curVal}else if(element.tagName==='TEXTAREA'){if(INTERMediator.defaultTargetInnerHTML){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){curVal=curVal.replace(/\r\n/g,'\r').replace(/\n/g,'\r').replace(/\r/g,'<br/>')}
element.innerHTML=curVal}else{element.value=curVal}}else{if(INTERMediator.defaultTargetInnerHTML){element.innerHTML=curVal}else{element.appendChild(document.createTextNode(curVal))}}}
if(formatSpec&&negativeColor){negativeSign=INTERMediatorOnPage.localeInfo.negative_sign;negativeTailSign='';flags=IMLibElement.initilaizeFlags(element);if(flags.negativeStyle===0||flags.negativeStyle===1){negativeSign='-'}else if(flags.negativeStyle===2){negativeSign='(';negativeTailSign=')'}else if(flags.negativeStyle===3){negativeSign='<';negativeTailSign='>'}else if(flags.negativeStyle===4){negativeSign=' CR'}else if(flags.negativeStyle===5){negativeSign='▲'}
if(flags.negativeStyle===0||flags.negativeStyle===5){if(curVal.indexOf(negativeSign)===0){element.style.color=negativeColor}}else if(flags.negativeStyle===1||flags.negativeStyle===4){if(curVal.indexOf(negativeSign)>-1&&curVal.indexOf(negativeSign)===curVal.length-negativeSign.length){element.style.color=negativeColor}}else if(flags.negativeStyle===2||flags.negativeStyle===3){if(curVal.indexOf(negativeSign)===0){if(curVal.indexOf(negativeTailSign)>-1&&curVal.indexOf(negativeTailSign)===curVal.length-1){element.style.color=negativeColor}}}}
if((element.tagName==='INPUT'||element.tagName==='SELECT'||element.tagName==='TEXTAREA')&&!isReplaceOrAppend&&(!imControl||imControl.indexOf('unbind')>0)){if(!element.getAttribute('data-imbluradded')){INTERMediatorLib.addEvent(element,'blur',(function(){var idValue=element.id;var elementCapt=element;return function(){if(!IMLibUI.valueChange(idValue,!0)){elementCapt.focus()}}})());element.setAttribute('data-imbluradded','set')}
if(!element.getAttribute('data-imchangeadded')){IMLibChangeEventDispatch.setExecute(element.id,(function(){var idValue=element.id;var elementCapt=element;return function(){if(!IMLibUI.valueChange(idValue,!1)){elementCapt.focus()}}})());element.setAttribute('data-imchangeadded','set')}
if((INTERMediator.isTrident||INTERMediator.isEdge)&&!element.getAttribute('data-iminputadded')){IMLibInputEventDispatch.setExecute(element.id,(function(){var idValue=element.id;var elementCapt=element;return function(){if(document.getElementById(idValue).value===''){if(!IMLibUI.valueChange(idValue,!1)){elementCapt.focus()}}}})());element.setAttribute('data-iminputadded','set')}}
element.setAttribute('data-im-element','processed');return needPostValueSet},getValueFromIMNode:function(element){'use strict';var nodeTag,typeAttr,newValue,mergedValues,targetNodes,k,valueAttr,convertedValue;if(element){nodeTag=element.tagName;typeAttr=element.getAttribute('type')}else{return''}
if(INTERMediatorLib.isWidgetElement(element)||(INTERMediatorLib.isWidgetElement(element.parentNode))){newValue=element._im_getValue()}else if(nodeTag==='INPUT'){if(typeAttr==='checkbox'){if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){mergedValues=[];targetNodes=element.parentNode.getElementsByTagName('INPUT');for(k=0;k<targetNodes.length;k++){if(targetNodes[k].checked){mergedValues.push(targetNodes[k].getAttribute('value'))}}
if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){newValue=mergedValues.join(IMLib.cr_char)}else{newValue=mergedValues.join(IMLib.nl_char)}}else{valueAttr=element.getAttribute('value');if(element.checked){newValue=valueAttr}else{newValue=''}}}else if(typeAttr==='radio'){newValue=element.value}else{newValue=element.value}}else if(nodeTag==='SELECT'){newValue=element.value}else if(nodeTag==='TEXTAREA'){if(INTERMediator.isIE&&INTERMediator.ieVersion<10){newValue=element.innerHTML.replace(/<br[\/]{0,1}>/g,'\n')}else{newValue=element.value}}else{newValue=element.innerHTML}
convertedValue=IMLibElement.getUnformattedValue(element,newValue);newValue=convertedValue?convertedValue:newValue;return newValue},deleteNodes:function(removeNodes){'use strict';var removeNode,removingNodes,i,j,k,removeNodeId,nodeId,calcObject,referes,values,key;for(key=0;key<removeNodes.length;key++){removeNode=document.getElementById(removeNodes[key]);if(removeNode){removingNodes=INTERMediatorLib.getElementsByIMManaged(removeNode);if(removingNodes){for(i=0;i<removingNodes.length;i++){removeNodeId=removingNodes[i].id;if(removeNodeId in IMLibCalc.calculateRequiredObject){delete IMLibCalc.calculateRequiredObject[removeNodeId]}}
for(i=0;i<removingNodes.length;i++){removeNodeId=removingNodes[i].id;for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];referes={};values={};for(j in calcObject.referes){if(calcObject.referes.hasOwnProperty(j)){referes[j]=[];values[j]=[];for(k=0;k<calcObject.referes[j].length;k++){if(removeNodeId!==calcObject.referes[j][k]){referes[j].push(calcObject.referes[j][k]);values[j].push(calcObject.values[j][k])}}}}
calcObject.referes=referes;calcObject.values=values}}}}
try{removeNode.parentNode.removeChild(removeNode)}catch(ex){}}}}};var Parser=(function(scope){var TNUMBER=0;var TOP1=1;var TOP2=2;var TOP3=5;var SEP=65;var TVAR=3;var TFUNCALL=4;Parser.regFirstVarChar=new RegExp('[\u00A0-\u1FFF\u2C00-\uDFFFa-zA-Z@_]');Parser.regRestVarChar=new RegExp('[\u00A0-\u1FFF\u2C00-\uDFFFa-zA-Z@_:0-9]');function Token(type_,index_,prio_,number_){this.type_=type_;this.index_=index_||0;this.prio_=prio_||0;this.number_=(number_!==undefined&&number_!==null)?number_:0;this.toString=function(){switch(this.type_){case TNUMBER:return this.number_;case TOP1:case TOP2:case TOP3:case TVAR:return this.index_;case TFUNCALL:return'CALL';case SEP:return'SEPARATOR';default:return'Invalid Token'}}}
function Expression(tokens,ops1,ops2,functions,ops3,ops3Trail){this.tokens=tokens}
var escapable=/[\\\'\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;var meta={'\b':IMLib.backSlash_char+'b','\t':IMLib.backSlash_char+'t','\n':IMLib.backSlash_char+'n','\f':IMLib.backSlash_char+'f','\r':IMLib.backSlash_char+'r','\'':IMLib.backSlash_char+IMLib.singleQuote_char,'\\':IMLib.backSlash_char+IMLib.backSlash_char};function escapeValue(v){if(typeof v==='string'){escapable.lastIndex=0;return escapable.test(v)?IMLib.singleQuote_char+v.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})+IMLib.singleQuote_char:IMLib.singleQuote_char+v+IMLib.singleQuote_char}
return v}
Expression.prototype={simplify:function(values){values=values||{};var nstack=[];var newexpression=[];var n1;var n2;var n3;var f;var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TNUMBER){nstack.push(item)}else if(type_===TVAR&&(item.index_ in values)){item=new Token(TNUMBER,0,0,values[item.index_]);nstack.push(item)}else if(type_===TOP3&&nstack.length>2){n3=nstack.pop();n2=nstack.pop();n1=nstack.pop();f=Parser.ops3[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_,n2.number_,n3.number_));nstack.push(item)}else if(type_===TOP2&&nstack.length>1){n2=nstack.pop();n1=nstack.pop();f=Parser.ops2[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_,n2.number_));nstack.push(item)}else if(type_===TOP1&&nstack.length>0){n1=nstack.pop();f=Parser.ops1[item.index_];item=new Token(TNUMBER,0,0,f(n1.number_));nstack.push(item)}else{while(nstack.length>0){newexpression.push(nstack.shift())}
newexpression.push(item)}}
while(nstack.length>0){newexpression.push(nstack.shift())}
return new Expression(newexpression)},substitute:function(variable,expr){if(!(expr instanceof Expression)){expr=new Parser().parse(String(expr))}
var newexpression=[];var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TVAR&&item.index_===variable){for(var j=0;j<expr.tokens.length;j++){var expritem=expr.tokens[j];var replitem=new Token(expritem.type_,expritem.index_,expritem.prio_,expritem.number_);newexpression.push(replitem)}}else{newexpression.push(item)}}
return new Expression(newexpression)},evaluate:function(values){values=values||{};var nstack=[];var n1;var n2;var n3;var f;var L=this.tokens.length;var item;var i=0;for(i=0;i<L;i++){item=this.tokens[i];var type_=item.type_;if(type_===TNUMBER){nstack.push(item.number_)}else if(type_===TOP3){n3=nstack.pop();n2=nstack.pop();n1=nstack.pop();f=Parser.ops3Trail[item.index_];nstack.push(f(n1,n2,n3))}else if(type_===TOP2){n2=nstack.pop();n1=nstack.pop();f=Parser.ops2[item.index_];nstack.push(f(n1,n2))}else if(type_===TVAR){if(item.index_ in values){nstack.push(values[item.index_])}else if(item.index_ in Parser.functions){nstack.push(Parser.functions[item.index_])}else{throw new Error('undefined variable: '+item.index_)}}else if(type_===TOP1){n1=nstack.pop();f=Parser.ops1[item.index_];nstack.push(f(n1))}else if(type_===SEP){n2=nstack.pop();n1=nstack.pop();nstack.push([n1,n2])}else if(type_===TFUNCALL){n1=nstack.pop();f=nstack.pop();if(f.apply&&f.call){if(Object.prototype.toString.call(n1)=='[object Array]'){nstack.push(f.apply(undefined,n1))}else{nstack.push(f.call(undefined,n1))}}else{throw new Error(f+' is not a function')}}else{throw new Error('invalid Expression')}}
if(nstack.length>1){throw new Error('invalid Expression (parity)')}
return nstack[0]},variables:function(){var L=this.tokens.length;var vars=[];for(var i=0;i<L;i++){var item=this.tokens[i];if(item.type_===TVAR&&(vars.indexOf(item.index_)==-1)&&!(item.index_ in Parser.functions)){vars.push(item.index_)}}
return vars}};function iff(a,b,c){var vala,valb,valc;vala=(a instanceof Array)?arguments[0][0]:arguments[0];valb=(b instanceof Array)?arguments[1][0]:arguments[1];valc=(c instanceof Array)?arguments[2][0]:arguments[2];return vala?valb:valc}
function greaterthan(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)>Number(numb)}
return a>b}
function lessthan(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)<Number(numb)}
return a<b}
function greaterequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)>=Number(numb)}
return a>=b}
function lessequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)<=Number(numb)}
return a<=b}
function equal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)==Number(numb)}
return a==b}
function notequal(a,b){var numa,numb;numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numa)){return Number(numa)!=Number(numb)}
return a!=b}
function isReallyNaN(x){return x!==x}
function add(a,b){var numa,numb;if((typeof a)=="string"||(typeof b)=="string"){return addstring(a,b)}
if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numb)){return Number(numa)+Number(numb)}
return a+b}
function addstring(a,b){return String(a)+String(b)}
function sub(a,b){var numa,numb,str,pos;if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
numa=toNumber(a);numb=toNumber(b);if(!isNaN(numa)&&!isNaN(numb)){return numa-numb}
str=String(a);do{pos=str.indexOf(b);if(pos>-1){str=str.substr(0,pos)+str.substr(pos+b.length)}}while(pos>-1);return str}
function mul(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a*b}
function div(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a/b}
function mod(a,b){if(isReallyNaN(a)||isReallyNaN(b)){return NaN}
a=toNumber(a);b=toNumber(b);return a%b}
function neg(a){if(isReallyNaN(a)){return NaN}
a=toNumber(a);return-a}
function random(a){a=toNumber(a);return Math.random()*(a||1)}
function fac(a){if(isReallyNaN(a)){return NaN}
a=toNumber(a);a=Math.floor(a);var b=a;while(a>1){b=b*(--a)}
return b}
function logicalnot(a){a=toNumber(a);return!a}
function logicaland(a,b){a=toNumber(a);b=toNumber(b);return a&&b}
function logicalor(a,b){a=toNumber(a);b=toNumber(b);return a||b}
function sumfunc(){var result=0,i;for(i=0;i<arguments.length;i++){result+=toNumber(arguments[i])}
return result}
function averagefunc(){var result=0,i,count=0;for(i=0;i<arguments.length;i++){result+=toNumber(arguments[i]);count++}
return result/count}
function countElements(){var i,count=0;for(i=0;i<arguments.length;i++){count+=Array.isArray(arguments[i])?arguments[i].length:1}
return count}
function listfunc(){var result=IMLib.zerolength_str,i;for(i=0;i<arguments.length;i++){result+=String(arguments[i]);result+=IMLib.nl_char}
return result}
function roundfunc(a,b){if(b==undefined){return Math.round(a)}else{a=(a instanceof Array)?a.join():a;b=(b instanceof Array)?b.join():b;return INTERMediatorLib.Round(a,b)}}
function length(a){if(a==undefined||a==null){return 0}else{a=(a instanceof Array)?a.join():a;return(new String(a)).length}}
function toNumber(str){var value;if(str===undefined){return NaN}
if(str===!0){return!0}
if(str===!1){return!1}
if(str==IMLib.zerolength_str){return 0}
value=str;if(INTERMediatorLib.is_array(str)){if(str.length<1){return 0}else{value=str[0]}}
value=unformat(value);return value}
function pyt(a,b){return Math.sqrt(a*a+b*b)}
function append(a,b){if(Object.prototype.toString.call(a)!='[object Array]'){return[a,b]}
a=a.slice();a.push(b);return a}
function charsetand(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<stra.length;i++){if(strb.indexOf(stra.substr(i,1))>-1){result+=stra.substr(i,1)}}
return result}
function charsetor(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<strb.length;i++){if(stra.indexOf(strb.substr(i,1))<0){result+=strb.substr(i,1)}}
return stra+result}
function charsetnoother(a,b){var stra,strb,i,result='';stra=(a instanceof Array)?a.join():a;strb=(b instanceof Array)?b.join():b;for(i=0;i<stra.length;i++){if(strb.indexOf(stra.substr(i,1))<0){result+=stra.substr(i,1)}}
return result}
function parametersOfMultiline(a,b){var stra,strb,arraya,arrayb,i,nls,nl=IMLib.nl_char;stra=(a instanceof Array)?a.join():a;nls=[stra.indexOf(IMLib.crlf_str),stra.indexOf(IMLib.cr_char),stra.indexOf(IMLib.nl_char)];for(i=0;i<nls.length;i++){nls[i]=(nls[i]<0)?stra.length:nls[i]}
if(nls[0]<stra.length&&nls[0]<=nls[1]&&nls[0]<nls[2]){nl=IMLib.crlf_str}else if(nls[1]<stra.length&&nls[1]<nls[0]&&nls[1]<nls[2]){nl=IMLib.cr_char}
arraya=stra.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char).split(IMLib.nl_char);strb=(b instanceof Array)?b.join():b;arrayb=strb.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char).split(IMLib.nl_char);return[arraya,arrayb,nl]}
function itemsetand(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arrayb.indexOf(arraya[i])>-1&&arraya[i].length>0){result+=arraya[i]+nl}}
return result}
function itemsetor(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arraya[i].length>0){result+=arraya[i]+nl}}
for(i=0;i<arrayb.length;i++){if(arraya.indexOf(arrayb[i])<0&&arrayb[i].length>0){result+=arrayb[i]+nl}}
return result}
function itemsetnoother(a,b){var params,arraya,arrayb,nl,i,result='';params=parametersOfMultiline(a,b);arraya=params[0];arrayb=params[1];nl=params[2];for(i=0;i<arraya.length;i++){if(arrayb.indexOf(arraya[i])<0&&arraya[i].length>0){result+=arraya[i]+nl}}
return result}
function itematindex(a,start,end){var params,arraya,nl,i,result='';params=parametersOfMultiline(a,'');arraya=params[0];nl=params[2];end=(end==undefined)?arraya.length:end;for(i=start;(i<start+end)&&(i<arraya.length);i++){result+=arraya[i]+nl}
return result}
function itemIndexOfFunc(list,str){if(!list){return-1}
var a=list.replace(IMLib.crlf_str,IMLib.nl_char).replace(IMLib.cr_char,IMLib.nl_char);var ix=0;var item,pos;while(a.length>0){pos=a.indexOf(IMLib.nl_char);if(pos>-1){item=a.substr(0,pos);a=a.substr(pos+1)}else{item=a;a=IMLib.zerolength_str}
if(item==str){return ix}
ix++}
return-1}
function numberformat(val,digit){var stra,strb;stra=(val instanceof Array)?val.join():val;strb=(digit instanceof Array)?digit.join():digit;return IMLibFormat.numberFormat(stra,strb,{useSeparator:!0})}
function currencyformat(val,digit){var stra,strb;stra=(val instanceof Array)?val.join():val;strb=(digit instanceof Array)?digit.join():digit;return IMLibFormat.currencyFormat(stra,strb,{useSeparator:!0})}
function substr(str,pos,len){var stra,p,l;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;p=(pos instanceof Array)?pos.join():pos;l=(len instanceof Array)?len.join():len;return stra.substr(p,l)}
function substring(str,start,end){var stra,s,e;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(start instanceof Array)?start.join():start;e=(end instanceof Array)?end.join():end;return stra.substring(s,e)}
function leftstring(str,start){var stra,s;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);return stra.substring(0,s)}
function midstring(str,start,end){var stra,s,e;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);e=parseInt((end instanceof Array)?end.join():end);return stra.substr(s,e)}
function rightstring(str,start){var stra,s;if(str==null){return null}
stra=String((str instanceof Array)?str.join():str);s=parseInt((start instanceof Array)?start.join():start);return stra.substring(stra.length-s)}
function indexof(str,search,from){var stra,s;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;if(from==undefined){return stra.indexOf(s)}
return stra.indexOf(s,from)}
function lastindexof(str,search,from){var stra,s;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;if(from==undefined){return stra.lastIndexOf(s)}
return stra.lastIndexOf(s,from)}
function replace(str,start,end,rep){var stra,s,e,r;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(start instanceof Array)?start.join():start;e=(end instanceof Array)?end.join():end;r=(rep instanceof Array)?rep.join():rep;return stra.substr(0,s)+r+stra.substr(e)}
function substitute(str,search,rep){var stra,s,r,reg;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;s=(search instanceof Array)?search.join():search;r=(rep instanceof Array)?rep.join():rep;reg=new RegExp(s,'g');return stra.replace(reg,r)}
function match(str,pattern){var stra,p;stra=(str instanceof Array)?str.join():str;p=(pattern instanceof Array)?pattern.join():pattern;return stra.match(new RegExp(p))}
function test(str,pattern){var stra,p;if(str==null){return null}
stra=(str instanceof Array)?str.join():str;p=(pattern instanceof Array)?pattern.join():pattern;return(new RegExp(p)).test(stra)}
Parser.timeOffset=(new Date()).getTimezoneOffset();function DateInt(str){var theDate;if(str===undefined){theDate=Date.now()}else{theDate=Date.parse(str.replace(/-/g,'/'));theDate-=Parser.timeOffset*60000}
return parseInt(theDate/86400000)}
function SecondInt(str){var theDate;if(str===undefined){theDate=Date.now()}else{theDate=Date.parse(str.replace(/-/g,'/'))}
return parseInt(theDate/1000)}
function dvalue(s){if(parseInt(s).length==s.length){return s}else{return DateInt(s)}}
function dtvalue(s){if(parseInt(s).length==s.length){return s}else{return SecondInt(s)}}
function calcDateComponent(d,a,index){var dtComp=[];dtComp.push(yeard(d));dtComp.push(monthd(d));dtComp.push(dayd(d));dtComp[index]+=a;return datecomponents(dtComp[0],dtComp[1],dtComp[2])}
function calcDateTimeComponent(dt,a,index){var dtComp=[];dtComp.push(yeardt(dt));dtComp.push(monthdt(dt));dtComp.push(daydt(dt));dtComp.push(hourdt(dt));dtComp.push(minutedt(dt));dtComp.push(seconddt(dt));dtComp[index]+=a;return datetimecomponents(dtComp[0],dtComp[1],dtComp[2],dtComp[3],dtComp[4],dtComp[5])}
function datecomponents(y,m,d){var m0=m-1;if(m0<0||m0>11){y+=parseInt(m0/12);m=m0%12+1}
return parseInt(Date.UTC(y,m-1,d,0,0,0)/86400000)}
function datetimecomponents(y,m,d,h,i,s){if(s<0||s>59){i+=parseInt(s/60);s=s%60}
if(i<0||i>59){h+=parseInt(i/60);i=i%60}
if(h<0||h>23){d+=parseInt(h/24);h=h%24}
var m0=m-1;if(m0<0||m0>11){y+=parseInt(m0/12);m=m0%12+1}
return Date.UTC(y,m-1,d,h,i,s)/1000}
function yearAlt(d){return INTERMediator.dateTimeFunction?yeardt(d):yeard(d)}
function monthAlt(d){return INTERMediator.dateTimeFunction?monthdt(d):monthd(d)}
function dayAlt(d){return INTERMediator.dateTimeFunction?daydt(d):dayd(d)}
function weekdayAlt(d){return INTERMediator.dateTimeFunction?weekdaydt(d):weekdayd(d)}
function hourAlt(d){return INTERMediator.dateTimeFunction?hourdt(d):0}
function minuteAlt(d){return INTERMediator.dateTimeFunction?minutedt(d):0}
function secondAlt(d){return INTERMediator.dateTimeFunction?seconddt(d):0}
function yeard(d){return new Date(dvalue(d)*86400000).getFullYear()}
function monthd(d){return new Date(dvalue(d)*86400000).getMonth()+1}
function dayd(d){return new Date(dvalue(d)*86400000).getDate()}
function weekdayd(d){return new Date(dvalue(d)*86400000).getDay()}
function yeardt(dt){return new Date(dtvalue(dt)*1000).getFullYear()}
function monthdt(dt){return new Date(dtvalue(dt)*1000).getMonth()+1}
function daydt(dt){return new Date(dtvalue(dt)*1000).getDate()}
function weekdaydt(dt){return new Date(dtvalue(dt)*1000).getDay()}
function hourdt(dt){return new Date(dtvalue(dt)*1000).getHours()}
function minutedt(dt){return new Date(dtvalue(dt)*1000).getMinutes()}
function seconddt(dt){return new Date(dtvalue(dt)*1000).getSeconds()}
function addyear(d,a){return INTERMediator.dateTimeFunction?addyeardt(d,a):addyeard(d,a)}
function addmonth(d,a){return INTERMediator.dateTimeFunction?addmonthdt(d,a):addmonthd(d,a)}
function addday(d,a){return INTERMediator.dateTimeFunction?adddaydt(d,a):adddayd(d,a)}
function addhour(d,a){return INTERMediator.dateTimeFunction?addhourdt(d,a):NaN}
function addminute(d,a){return INTERMediator.dateTimeFunction?addminutedt(d,a):NaN}
function addsecond(d,a){return INTERMediator.dateTimeFunction?addseconddt(d,a):NaN}
function addyeard(d,a){return calcDateComponent(d,a,0)}
function addmonthd(d,a){return calcDateComponent(d,a,1)}
function adddayd(d,a){return calcDateComponent(d,a,2)}
function addyeardt(dt,a){return calcDateTimeComponent(dt,a,0)}
function addmonthdt(dt,a){return calcDateTimeComponent(dt,a,1)}
function adddaydt(dt,a){return calcDateTimeComponent(dt,a,2)}
function addhourdt(dt,a){return calcDateTimeComponent(dt,a,3)}
function addminutedt(dt,a){return calcDateTimeComponent(dt,a,4)}
function addseconddt(dt,a){return calcDateTimeComponent(dt,a,5)}
function endofmonth(d){return INTERMediator.dateTimeFunction?endofmonthdt(d):endofmonthd(d)}
function endofmonthd(d){return adddayd(addmonthd(startofmonthd(d),1),-1)}
function endofmonthdt(dt){return addseconddt(addmonthdt(startofmonthdt(dt),1),-1)}
function startofmonth(d){return INTERMediator.dateTimeFunction?startofmonthdt(d):startofmonthd(d)}
function startofmonthd(d){var str=yeard(d)+'/'+('0'+monthd(d)).substr(-2,2)+'/01';return DateInt(str)}
function startofmonthdt(dt){var str=yeardt(dt)+'/'+('0'+monthdt(dt)).substr(-2,2)+'/01 00:00:00';return SecondInt(str)}
function today(){return parseInt(Date.now()/86400)}
function nowFunction(){return parseInt(Date.now()/1000)}
function unformat(value){var valueString,numberString,i,c;valueString=String(value);numberString=IMLib.zerolength_str;for(i=0;i<valueString.length;i++){c=valueString.substr(i,1);if(c>='0'&&c<='9'){numberString+=c}else if(c>='0'&&c<='9'){numberString+=String.fromCharCode('0'.charCodeAt(0)+c.charCodeAt(0)-'0'.charCodeAt(0))}else if(c=='.'||c=='-'){numberString+=c}}
return parseFloat(numberString)}
function choiceFunc(){var index;if(arguments[0]==null||arguments[0]==undefined){return arguments[0]}
index=parseInt(arguments[0]);if(index<0||index>=(arguments.length-1)){return undefined}
return arguments[index+1]}
function conditionFunc(){var index;for(index=0;index<arguments.length;index+=2){if(arguments[index]==!0&&index+1<arguments.length){return arguments[index+1]}}
return undefined}
function accumulateFunc(){var index,c='';for(index=0;index<arguments.length;index+=2){if(arguments[index]==!0&&index+1<arguments.length){c=c+arguments[index+1]+'\n'}}
return c}
function Parser(){this.success=!1;this.errormsg=IMLib.zerolength_str;this.expression=IMLib.zerolength_str;this.pos=0;this.tokennumber=0;this.tokenprio=0;this.tokenindex=0;this.tmpprio=0;Parser.functions={'count':countElements,'random':random,'fac':fac,'min':Math.min,'max':Math.max,'pyt':pyt,'pow':Math.pow,'atan2':Math.atan2,'if':iff,'sum':sumfunc,'average':averagefunc,'list':listfunc,'format':numberformat,'currency':currencyformat,'substr':substr,'substring':substring,'indexof':indexof,'lastindexof':lastindexof,'replace':replace,'substitute':substitute,'match':match,'test':test,'sin':Math.sin,'cos':Math.cos,'tan':Math.tan,'asin':Math.asin,'acos':Math.acos,'atan':Math.atan,'sqrt':Math.sqrt,'log':Math.log,'abs':Math.abs,'ceil':Math.ceil,'floor':Math.floor,'round':roundfunc,'exp':Math.exp,'items':itematindex,'length':length,'datetime':SecondInt,'date':DateInt,'datecomponents':datecomponents,'datetimecomponents':datetimecomponents,'year':yearAlt,'month':monthAlt,'day':dayAlt,'weekday':weekdayAlt,'hour':hourAlt,'minute':minuteAlt,'second':secondAlt,'yeard':yeard,'monthd':monthd,'dayd':dayd,'weekdayd':weekdayd,'yeardt':yeardt,'monthdt':monthdt,'daydt':daydt,'weekdaydt':weekdaydt,'hourdt':hourdt,'minutedt':minutedt,'seconddt':seconddt,'addyear':addyear,'addmonth':addmonth,'addday':addday,'addhour':addhour,'addminute':addminute,'addsecond':addsecond,'addyeard':addyeard,'addmonthd':addmonthd,'adddayd':adddayd,'addyeardt':addyeardt,'addmonthdt':addmonthdt,'adddaydt':adddaydt,'addhourdt':addhourdt,'addminutedt':addminutedt,'addseconddt':addseconddt,'endofmonth':endofmonth,'startofmonth':startofmonth,'endofmonthd':endofmonthd,'startofmonthd':startofmonthd,'endofmonthdt':endofmonthdt,'startofmonthdt':startofmonthdt,'today':today,'now':nowFunction,'right':rightstring,'mid':midstring,'left':leftstring,'itemIndexOf':itemIndexOfFunc,'choice':choiceFunc,'condition':conditionFunc,'accumulate':accumulateFunc};this.consts={'E':Math.E,'PI':Math.PI};Parser.operators={'!':[1,logicalnot,2],'+':[2,add,4],'⊕':[2,addstring,4],'-':[2,sub,4],'*':[2,mul,3],'/':[2,div,3],'%':[2,mod,3],'^':[2,Math.pow,1],',':[2,append,15],'>':[2,greaterthan,6],'<':[2,lessthan,6],'>=':[2,greaterequal,6],'<=':[2,lessequal,6],'==':[2,equal,7],'=':[2,equal,7],'!=':[2,notequal,7],'<>':[2,notequal,7],'&&':[2,logicaland,11],'||':[2,logicalor,12],'∩':[2,charsetand,3],'∪':[2,charsetor,4],'⊁':[2,charsetnoother,4],'⋀':[2,itemsetand,3],'⋁':[2,itemsetor,4],'⊬':[2,itemsetnoother,4],'?':[2,iff,13],':':[4,iff,13]};Parser.ops1={'-':neg};Parser.ops2={};Parser.ops3={};Parser.ops3Trail={};for(var op in Parser.operators){if(Parser.operators.hasOwnProperty(op)){switch(Parser.operators[op][0]){case 1:Parser.ops1[op]=Parser.operators[op][1];break;case 2:Parser.ops2[op]=Parser.operators[op][1];break;case 3:Parser.ops3[op]=Parser.operators[op][1];break;case 4:Parser.ops3Trail[op]=Parser.operators[op][1];break}}}}
Parser.parse=function(expr){return new Parser().parse(expr)};Parser.evaluate=function(expr,variables){var result;result=Parser.parse(expr).evaluate(variables);return result};Parser.Expression=Expression;var PRIMARY=1<<0;var OPERATOR=1<<1;var FUNCTION=1<<2;var LPAREN=1<<3;var RPAREN=1<<4;var COMMA=1<<5;var SIGN=1<<6;var CALL=1<<7;var NULLARY_CALL=1<<8;Parser.prototype={parse:function(expr){this.errormsg=IMLib.zerolength_str;this.success=!0;var operstack=[];var tokenstack=[];this.tmpprio=0;var expected=(PRIMARY|LPAREN|FUNCTION|SIGN);var noperators=0;this.expression=expr;this.pos=0;var funcstack=[],token;while(this.pos<this.expression.length){if(this.isOperator()){if(this.isSign()&&(expected&SIGN)){if(this.isNegativeSign()){this.tokenprio=2;this.tokenindex='-';noperators++;this.addfunc(tokenstack,operstack,TOP1)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN)}else if(this.isComment()){}else{if((expected&OPERATOR)===0){this.error_parsing(this.pos,'unexpected operator')}
if(this.tokenindex=='?'){this.tmpprio-=40;this.tokenindex='if';this.addfunc(tokenstack,operstack,TOP2);this.tmpprio+=40;this.tokenindex=',';noperators+=3;this.addfunc(tokenstack,operstack,TOP2)}else if(this.tokenindex==':'){this.tokenindex=',';noperators+=2;this.addfunc(tokenstack,operstack,TOP2)}else{noperators+=2;this.addfunc(tokenstack,operstack,TOP2)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN)}}else if(this.isNumber()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected number')}
token=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(token);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isString()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected string')}
token=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(token);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isLeftParenth()){if((expected&LPAREN)===0){this.error_parsing(this.pos,'unexpected \'(\"')}
if(expected&CALL){funcstack.push(!0)}else{funcstack.push(!1)}
expected=(PRIMARY|LPAREN|FUNCTION|SIGN|NULLARY_CALL)}else if(this.isRightParenth()){var isFunc=funcstack.pop();if(isFunc){noperators+=2;this.tokenprio=-2;this.tokenindex=-1;this.addfunc(tokenstack,operstack,TFUNCALL)}
if(expected&NULLARY_CALL){token=new Token(TNUMBER,0,0,[]);tokenstack.push(token)}else if((expected&RPAREN)===0){this.error_parsing(this.pos,'unexpected \")\"')}
expected=(OPERATOR|RPAREN|COMMA|LPAREN|CALL)}else if(this.isConst()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected constant')}
var consttoken=new Token(TNUMBER,0,0,this.tokennumber);tokenstack.push(consttoken);expected=(OPERATOR|RPAREN|COMMA)}else if(this.isVar()){if((expected&PRIMARY)===0){this.error_parsing(this.pos,'unexpected variable')}
var vartoken=new Token(TVAR,this.tokenindex,0,0);tokenstack.push(vartoken);expected=(OPERATOR|RPAREN|COMMA|LPAREN|CALL)}else if(this.isWhite()){}else{if(this.errormsg===IMLib.zerolength_str){this.error_parsing(this.pos,'unknown character')}else{this.error_parsing(this.pos,this.errormsg)}}}
if(this.tmpprio<0||this.tmpprio>=10){this.error_parsing(this.pos,'unmatched \"()\"')}
while(operstack.length>0){var tmp=operstack.pop();tokenstack.push(tmp)}
return new Expression(tokenstack)},evaluate:function(expr,variables){var result;this.parse(expr).evaluate(variables);return result},error_parsing:function(column,msg){this.success=!1;this.errormsg='parse error [column '+(column)+']: '+msg;throw new Error(this.errormsg)},addfunc:function(tokenstack,operstack,type_){var operator=new Token(type_,this.tokenindex,this.tokenprio+this.tmpprio,0);while(operstack.length>0){if(operator.prio_>=operstack[operstack.length-1].prio_){tokenstack.push(operstack.pop())}else{break}}
operstack.push(operator)},isNumber:function(){var r=!1;var str=IMLib.zerolength_str;while(this.pos<this.expression.length){var code=this.expression.charCodeAt(this.pos);if((code>=48&&code<=57)||code===46){str+=this.expression.charAt(this.pos);this.pos++;this.tokennumber=parseFloat(str);r=!0}else{break}}
return r},unescape:function(v,pos){var buffer=[];var escaping=!1;for(var i=0;i<v.length;i++){var c=v.charAt(i);if(escaping){switch(c){case IMLib.singleQuote_char:buffer.push(IMLib.singleQuote_char);break;case IMLib.backSlash_char:buffer.push(IMLib.backSlash_char);break;case '/':buffer.push('/');break;case 'b':buffer.push('\b');break;case 'f':buffer.push('\f');break;case 'n':buffer.push(IMLib.nl_char);break;case 'r':buffer.push(IMLib.cr_char);break;case 't':buffer.push(IMLib.tab_char);break;case 'u':var codePoint=parseInt(v.substring(i+1,i+5),16);buffer.push(String.fromCharCode(codePoint));i+=4;break;default:throw this.error_parsing(pos+i,'Illegal escape sequence: \'\\'+c+IMLib.singleQuote_char)}
escaping=!1}else{if(c==IMLib.backSlash_char){escaping=!0}else{buffer.push(c)}}}
return buffer.join('')},isString:function(){var r=!1;var str=IMLib.zerolength_str;var startpos=this.pos;if(this.pos<this.expression.length&&this.expression.charAt(this.pos)==IMLib.singleQuote_char){this.pos++;while(this.pos<this.expression.length){var code=this.expression.charAt(this.pos);if(code!=IMLib.singleQuote_char||str.slice(-1)==IMLib.backSlash_char){str+=this.expression.charAt(this.pos);this.pos++}else{this.pos++;this.tokennumber=this.unescape(str,startpos);r=!0;break}}}
return r},isConst:function(){var str,i;for(i in this.consts){if(this.consts.hasOwnProperty(i)){var L=i.length;str=this.expression.substr(this.pos,L);if(i===str){this.tokennumber=this.consts[i];this.pos+=L;return!0}}}
return!1},isOperator:function(){var code;if(this.pos+1<this.expression.length){code=this.expression.substr(this.pos,2);if(Parser.operators[code]){this.tokenprio=Parser.operators[code][2];this.tokenindex=code;this.pos+=2;return!0}}
code=this.expression.substr(this.pos,1);if(Parser.operators[code]){this.tokenprio=Parser.operators[code][2];this.tokenindex=code;this.pos++;return!0}
return!1},isSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===45||code===43){return!0}
return!1},isPositiveSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===43){return!0}
return!1},isNegativeSign:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===45){return!0}
return!1},isLeftParenth:function(){var code=this.expression.charCodeAt(this.pos);if(code===40){this.pos++;this.tmpprio-=20;return!0}
return!1},isRightParenth:function(){var code=this.expression.charCodeAt(this.pos);if(code===41){this.pos++;this.tmpprio+=20;return!0}
return!1},isComma:function(){var code=this.expression.charCodeAt(this.pos);if(code===44){this.pos++;this.tokenprio=15;this.tokenindex=',';return!0}
return!1},isWhite:function(){var code=this.expression.charCodeAt(this.pos);if(code===32||code===9||code===10||code===13){this.pos++;return!0}
return!1},isVar:function(){var str=IMLib.zerolength_str;for(var i=this.pos;i<this.expression.length;i++){var c=this.expression.charAt(i);if(i===this.pos){if(!c.match(Parser.regFirstVarChar)){break}}else{if(!c.match(Parser.regRestVarChar)){break}}
str+=c}
if(str.length>0){this.tokenindex=str;this.tokenprio=0;this.pos+=str.length;return!0}
return!1},isComment:function(){var code=this.expression.charCodeAt(this.pos-1);if(code===47&&this.expression.charCodeAt(this.pos)===42){this.pos=this.expression.indexOf('*/',this.pos)+2;if(this.pos===1){this.pos=this.expression.length}
return!0}
return!1}};scope.Parser=Parser;return Parser})(typeof exports==='undefined'?{}:exports);var IMLibCalc={calculateRequiredObject:null,updateCalculationInfo:function(contextObj,keyingValue,nodeId,nInfo,currentRecord){'use strict';var calcDef,exp,field,elements,i,index,objectKey,itemIndex,values,referes,calcDefField,atPos,fieldLength;calcDef=contextObj.getContextDef().calculation;for(index in calcDef){if(calcDef.hasOwnProperty(index)){atPos=calcDef[index].field.indexOf(INTERMediator.separator);fieldLength=calcDef[index].field.length;calcDefField=calcDef[index].field.substring(0,atPos>=0?atPos:fieldLength);if(calcDefField===nInfo.field){try{exp=calcDef[index].expression;field=calcDef[index].field;elements=Parser.parse(exp).variables();objectKey=nodeId+(nInfo.target.length>0?(INTERMediator.separator+nInfo.target):'')}catch(ex){INTERMediatorLog.setErrorMessage(ex,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1036],[field,exp]))}
if(elements&&objectKey){values={};referes={};for(i=0;i<elements.length;i++){itemIndex=elements[i];if(itemIndex){values[itemIndex]=currentRecord[itemIndex];referes[itemIndex]=undefined}
contextObj.setValue(keyingValue,itemIndex,currentRecord[itemIndex],nodeId,nInfo.target,null)}
IMLibCalc.calculateRequiredObject[objectKey]={'field':field,'expression':exp,'nodeInfo':nInfo,'values':values,'referes':referes}}}}}},updateCalculationFields:function(){'use strict';var nodeId,exp,nInfo,valuesArray,leafNodes,calcObject,ix,refersArray,key,fName,vArray;var targetNode,field,valueSeries,targetElement,i,hasReferes,contextInfo,idValue,record,val;IMLibCalc.setUndefinedToAllValues();IMLibNodeGraph.clear();for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];if(calcObject){hasReferes=!1;for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){IMLibNodeGraph.addEdge(nodeId,calcObject.referes[field][ix]);hasReferes=!1}}}
if(!hasReferes){IMLibNodeGraph.addEdge(nodeId)}}}}
do{leafNodes=IMLibNodeGraph.getLeafNodesWithRemoving();for(i=0;i<leafNodes.length;i++){calcObject=IMLibCalc.calculateRequiredObject[leafNodes[i]];if(calcObject){idValue=leafNodes[i].match(IMLibCalc.regexpForSeparator)?leafNodes[i].split(IMLibCalc.regexpForSeparator)[0]:leafNodes[i];targetNode=document.getElementById(idValue);exp=calcObject.expression;nInfo=calcObject.nodeInfo;valuesArray=calcObject.values;refersArray=calcObject.referes;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nInfo.target);if(contextInfo&&contextInfo.context){record=contextInfo.context.getContextRecord(idValue)}else{record=null}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){if(field.indexOf(nInfo.table+'@')===0){fName=field.substr(field.indexOf('@')+1);vArray=[];for(key in contextInfo.context.store){if(contextInfo.context.store.hasOwnProperty(key)&&contextInfo.context.store[key][fName]){vArray.push(contextInfo.context.store[key][fName])}}
valuesArray[field]=vArray}}}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){valueSeries=[];for(ix=0;ix<valuesArray[field].length;ix++){if(valuesArray[field][ix]===undefined){if(record[field]){valueSeries.push(record[field])}else if(refersArray[field][ix]){targetElement=document.getElementById(refersArray[field][ix]);valueSeries.push(IMLibElement.getValueFromIMNode(targetElement))}}else{valueSeries.push(valuesArray[field][ix])}}
calcObject.values[field]=valueSeries}}
val=Parser.evaluate(exp,valuesArray);IMLibElement.setValueToIMNode(targetNode,nInfo.target,val,!0);contextInfo.context.setValue(contextInfo.record,contextInfo.field,val,nodeId,targetNode,!1)}}}while(leafNodes.length>0);if(IMLibNodeGraph.nodes.length>0){INTERMediatorLog.setErrorMessage(new Error('Expressons are cyclic.'),INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1037],[]))}},recalculation:function(updatedNodeId){'use strict';var nodeId,newValueAdded,leafNodes,calcObject,ix,updatedValue,isRecalcAll=!1,targetNode;var newValue,field,i,updatedNodeIds,updateNodeValues,cachedIndex,nInfo,valuesArray;var refersArray,valueSeries,targetElement,contextInfo,record,idValue,key,fName,vArray;if(updatedNodeId===undefined){isRecalcAll=!0;updatedNodeIds=[];updateNodeValues=[]}else{newValue=IMLibElement.getValueFromIMNode(document.getElementById(updatedNodeId));updatedNodeIds=[updatedNodeId];updateNodeValues=[newValue]}
IMLibCalc.setUndefinedToAllValues();IMLibNodeGraph.clear();for(nodeId in IMLibCalc.calculateRequiredObject){if(IMLibCalc.calculateRequiredObject.hasOwnProperty(nodeId)){calcObject=IMLibCalc.calculateRequiredObject[nodeId];for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){IMLibNodeGraph.addEdge(nodeId,calcObject.referes[field][ix])}}}}}
do{leafNodes=IMLibNodeGraph.getLeafNodesWithRemoving();for(i=0;i<leafNodes.length;i++){calcObject=IMLibCalc.calculateRequiredObject[leafNodes[i]];if(calcObject){idValue=leafNodes[i].match(IMLibCalc.regexpForSeparator)?leafNodes[i].split(IMLibCalc.regexpForSeparator)[0]:leafNodes[i];targetNode=document.getElementById(idValue);nInfo=calcObject.nodeInfo;valuesArray=calcObject.values;refersArray=calcObject.referes;contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nInfo.target);if(contextInfo&&contextInfo.context){record=contextInfo.context.getContextRecord(idValue)}else{record=null}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){if(field.indexOf(nInfo.table+'@')===0){fName=field.substr(field.indexOf('@')+1);vArray=[];for(key in contextInfo.context.store){if(contextInfo.context.store.hasOwnProperty(key)&&contextInfo.context.store[key][fName]){vArray.push(contextInfo.context.store[key][fName])}}
valuesArray[field]=vArray}}}
for(field in valuesArray){if(valuesArray.hasOwnProperty(field)){valueSeries=[];for(ix=0;ix<valuesArray[field].length;ix++){if(valuesArray[field][ix]===undefined){if(record[field]){valueSeries.push(record[field])}else if(refersArray[field][ix]){targetElement=document.getElementById(refersArray[field][ix]);valueSeries.push(IMLibElement.getValueFromIMNode(targetElement))}}else{valueSeries.push(valuesArray[field][ix])}}
calcObject.values[field]=valueSeries}}
if(isRecalcAll){newValueAdded=!0}else{newValueAdded=!1;for(field in calcObject.referes){if(calcObject.referes.hasOwnProperty(field)){for(ix=0;ix<calcObject.referes[field].length;ix++){cachedIndex=updatedNodeIds.indexOf(calcObject.referes[field][ix]);if(cachedIndex>=0){calcObject.values[field][ix]=updateNodeValues[cachedIndex];newValueAdded=!0}}}}}
if(newValueAdded){updatedValue=Parser.evaluate(calcObject.expression,calcObject.values);IMLibElement.setValueToIMNode(document.getElementById(idValue),nInfo.target,updatedValue,!0);updatedNodeIds.push(idValue);updateNodeValues.push(updatedValue);contextInfo.context.setValue(contextInfo.record,contextInfo.field,updatedValue,idValue,targetNode,!1)}}}}while(leafNodes.length>0);if(IMLibNodeGraph.nodes.length>0){INTERMediatorLog.setErrorMessage(new Error('Expressons are cyclic.'),INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1037],[]))}},setUndefinedToAllValues:function(){'use strict';var nodeId,calcObject,ix,targetNode,field,targetExp,targetIds,isContextName,isRemoved,idValue,repeaterTop,checkRepeater,nodeInfo,linkInfos;do{isRemoved=!1;for(nodeId in IMLibCalc.calculateRequiredObject){idValue=nodeId.match(IMLibCalc.regexpForSeparator)?nodeId.split(IMLibCalc.regexpForSeparator)[0]:nodeId;if(!document.getElementById(idValue)){delete IMLibCalc.calculateRequiredObject[nodeId];isRemoved=!0;break}}}while(isRemoved);for(nodeId in IMLibCalc.calculateRequiredObject){calcObject=IMLibCalc.calculateRequiredObject[nodeId];idValue=nodeId.match(IMLibCalc.regexpForSeparator)?nodeId.split(IMLibCalc.regexpForSeparator)[0]:nodeId;targetNode=document.getElementById(idValue);linkInfos=INTERMediatorLib.getLinkedElementInfo(targetNode);if(INTERMediatorLib.is_array(linkInfos)){linkInfos=linkInfos[0]}
nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfos);for(field in calcObject.values){if(field.indexOf(INTERMediator.separator)>-1){targetExp=field;isContextName=!0}else{targetExp=calcObject.nodeInfo.table+INTERMediator.separator+field;isContextName=!1}
if(nodeInfo&&nodeInfo.crossTable){repeaterTop=targetNode;while(repeaterTop.tagName!=='TD'&&repeaterTop.tagName!=='TH'){repeaterTop=repeaterTop.parentNode}
do{targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromNode(repeaterTop,targetExp);if(targetIds&&targetIds.length>0){break}
repeaterTop=getParentRepeater(INTERMediatorLib.getParentEnclosure(repeaterTop))}while(repeaterTop);}else{checkRepeater=targetNode;do{targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromRepeater(checkRepeater,targetExp);if(targetIds&&targetIds.length>0){break}
if(isContextName){targetIds=INTERMediatorOnPage.getNodeIdsHavingTargetFromEnclosure(checkRepeater,targetExp);if(targetIds&&targetIds.length>0){break}}
checkRepeater=getParentRepeater(INTERMediatorLib.getParentEnclosure(checkRepeater))}while(checkRepeater);}
if(INTERMediatorLib.is_array(targetIds)&&targetIds.length>0){calcObject.referes[field]=[];calcObject.values[field]=[];for(ix=0;ix<targetIds.length;ix++){calcObject.referes[field].push(targetIds[ix]);calcObject.values[field].push(undefined)}}else{calcObject.referes[field]=[undefined];calcObject.values[field]=[undefined]}}}
function getParentRepeater(node){var currentNode=node;while(currentNode!==null){if(INTERMediatorLib.isRepeater(currentNode,!0)){return currentNode}
currentNode=currentNode.parentNode}
return null}}};var IMParts_Catalog={};IMParts_Catalog.fileupload={html5DDSuported:!1,progressSupported:!1,forceOldStyleForm:!1,uploadButtonLabel:'送信',uploadCancelButtonLabel:'キャンセル',uploadId:'sign'+Math.random(),instanciate:function(parentNode){'use strict';var inputNode,formNode,buttonNode,hasTapEvent;var newId=parentNode.getAttribute('id')+'-e';var newNode=document.createElement('DIV');IMLibLocalContext.setValue('uploadFileSelect','false');INTERMediatorLib.setClassAttributeToNode(newNode,'_im_fileupload');newNode.setAttribute('id',newId);this.ids.push(newId);if(this.forceOldStyleForm||(INTERMediator.isEdge&&INTERMediator.ieVersion<14)){this.html5DDSuported=!1}else{if(window.FileReader&&window.FormData){this.html5DDSuported=!0}else{this.html5DDSuported=!1}}
hasTapEvent=('ontouchstart' in window);if(hasTapEvent){this.html5DDSuported=!1}
var autoReload=(parentNode.getAttribute('data-im-widget-reload')!==null)?parentNode.getAttribute('data-im-widget-reload'):!1;newNode.setAttribute('data-im-widget-reload',autoReload);if(this.html5DDSuported){newNode.dropzone='copy';var widgetStyle=(parentNode.getAttribute('data-im-widget-style')==='false')?!1:!0;if(widgetStyle){newNode.style.width='200px';newNode.style.height='100px';newNode.style.paddingTop='20px';newNode.style.backgroundColor='#AAAAAA';newNode.style.border='3px dotted #808080';newNode.style.textAlign='center';newNode.style.fontSize='75%';var eachLine=INTERMediatorOnPage.getMessages()[3101].split(/\n/);for(var i=0;i<eachLine.length;i++){if(i>0){newNode.appendChild(document.createElement('BR'))}
newNode.appendChild(document.createTextNode(eachLine[i]))}}}else{formNode=document.createElement('FORM');formNode.className='_im_fileupload_form';formNode.setAttribute('method','post');formNode.setAttribute('action',INTERMediatorOnPage.getEntryPath()+'?access=uploadfile');formNode.setAttribute('enctype','multipart/form-data');var divNode=document.createElement('DIV');divNode.className='_im_fileupload_form_wrapper form-wrapper';divNode.appendChild(formNode);newNode.appendChild(divNode);if(this.progressSupported){inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','APC_UPLOAD_PROGRESS');inputNode.setAttribute('id','progress_key');inputNode.setAttribute('value',this.uploadId+(this.ids.length-1));formNode.appendChild(inputNode)}
inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_redirect');inputNode.setAttribute('value',location.href);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_contextnewrecord');inputNode.setAttribute('value','uploadfile');formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','access');inputNode.setAttribute('value','uploadfile');formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','file');inputNode.setAttribute('accept','*/*');inputNode.setAttribute('name','_im_uploadfile');inputNode.className='_im_uploadfile';inputNode.addEventListener('change',function(){if(this.files[0].size>0){this.nextSibling.removeAttribute('disabled')}},!1);formNode.appendChild(inputNode);var cancelButtonWrapper,cancelButton;cancelButtonWrapper=document.createElement('DIV');cancelButtonWrapper.className='_im_fileupload_cancel_button_wrapper';cancelButton=document.createElement('BUTTON');cancelButton.className='_im_fileupload_cancel_button';cancelButton.appendChild(document.createTextNode(this.uploadCancelButtonLabel));cancelButtonWrapper.appendChild(cancelButton);buttonNode=document.createElement('BUTTON');buttonNode.className='_im_fileupload_button';buttonNode.setAttribute('type','submit');buttonNode.setAttribute('disabled','');buttonNode.appendChild(document.createTextNode(this.uploadButtonLabel));if(!newNode.id){newNode.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(newNode.id,function(){var node=document.getElementById(newNode.id);if(node!==null&&node.children.length>0){if(node.children[0].style.display==='none'||node.children[0].style.display===''){node.children[0].style.display='flex';node.children[0].style.display='-webkit-flex'}}},!0);if(!cancelButtonWrapper.id){cancelButtonWrapper.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(cancelButtonWrapper.id,function(){this.parentNode.style.display='none'});divNode.appendChild(cancelButtonWrapper);formNode.appendChild(buttonNode);this.formFromId[newId]=formNode}
if(parentNode.getAttribute('data-im-widget-inner')==='true'){var children=parentNode.children;for(var c=children.length-1;c>=0;c--){newNode.appendChild(children[c])}}
parentNode.appendChild(newNode);newNode._im_getValue=function(){var targetNode=newNode;return targetNode.value};parentNode._im_getValue=function(){var targetNode=newNode;return targetNode.value};parentNode._im_getComponentId=function(){var theId=newId;return theId}},ids:[],formFromId:{},finish:function(){'use strict';var shaObj,hmacValue,targetNode,formNode,i,tagetIdLocal,isProgressingLocal,serialIdLocal,uploadIdLocal;var encrypt=new JSEncrypt();if(this.html5DDSuported){for(i=0;i<this.ids.length;i++){tagetIdLocal=this.ids[i];targetNode=document.getElementById(tagetIdLocal);if(targetNode){INTERMediatorLib.addEvent(targetNode,'dragleave',function(event){event.preventDefault();event.target.style.backgroundColor='#AAAAAA'});INTERMediatorLib.addEvent(targetNode,'dragover',function(event){event.preventDefault();event.target.style.backgroundColor='#AADDFF'});isProgressingLocal=this.progressSupported;serialIdLocal=this.ids.length;uploadIdLocal=this.uploadId;INTERMediatorLib.addEvent(targetNode,'drop',(function(){var iframeId=i;var isProgressing=isProgressingLocal;var serialId=serialIdLocal;var uploadId=uploadIdLocal;var tagetId=tagetIdLocal;return function(event){var file,fileNameNode,i,updateInfo,infoFrame;event.preventDefault();var eventTarget=event.currentTarget;if(isProgressing){infoFrame=document.createElement('iframe');infoFrame.setAttribute('id','upload_frame'+serialId);infoFrame.setAttribute('name','upload_frame');infoFrame.setAttribute('frameborder','0');infoFrame.setAttribute('border','0');infoFrame.setAttribute('scrolling','no');infoFrame.setAttribute('scrollbar','no');infoFrame.style.width='100%';infoFrame.style.height='24px';eventTarget.appendChild(infoFrame)}
for(i=0;i<event.dataTransfer.files.length;i++){file=event.dataTransfer.files[i];fileNameNode=document.createElement('DIV');fileNameNode.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[3102]+file.name));fileNameNode.style.marginTop='20px';fileNameNode.style.backgroundColor='#FFFFFF';fileNameNode.style.textAlign='center';event.target.appendChild(fileNameNode)}
updateInfo=IMLibContextPool.getContextInfoFromId(eventTarget.getAttribute('id'),'');if(isProgressing){if(infoFrame){infoFrame.style.display='block'}
setTimeout((function(){var frameNode=infoFrame;var param=uploadId+iframeId;return function(){if(frameNode){frameNode.setAttribute('src','upload_frame.php?up_id='+param)}}})())}
IMLibQueue.setTask((function(){var uploadData='&_im_contextname='+encodeURIComponent(updateInfo.context.contextName)+'&_im_field='+encodeURIComponent(updateInfo.field)+'&_im_keyfield='+encodeURIComponent(updateInfo.record.split('=')[0])+'&_im_keyvalue='+encodeURIComponent(updateInfo.record.split('=')[1])+'&_im_contextnewrecord='+encodeURIComponent('uploadfile')+(isProgressing?('&APC_UPLOAD_PROGRESS='+encodeURIComponent(uploadId+iframeId)):'');var uploadSpec={fileName:file.name,content:file};var contextName=updateInfo.context.contextName;var updateField=updateInfo.field;var targetIdCapt=tagetId;var targetNodeCapt=targetNode;var finishFunc=(function(){var infoFrameCapt=infoFrame;var fileNameNodeCapt=fileNameNode;return function(){if(infoFrameCapt){infoFrameCapt.setAttribute('src','')}
if(fileNameNodeCapt){fileNameNodeCapt.parentNode.removeChild(fileNameNodeCapt)}}})();return function(completeTask){INTERMediator_DBAdapter.uploadFile(uploadData,uploadSpec,function(dbresult){var contextObj,contextInfo,contextObjects=null,fvalue,i,context,relatedContextName='',index;context=IMLibContextPool.getContextDef(contextName);if(context['file-upload']){for(index in context['file-upload']){if(context['file-upload'][index].field===updateField){relatedContextName=context['file-upload'][index].context;break}}
fvalue=IMLibContextPool.getKeyFieldValueFromId(targetIdCapt,'');contextObjects=IMLibContextPool.getContextsFromNameAndForeignValue(relatedContextName,fvalue,context.key)}else{contextObjects=IMLibContextPool.getContextFromName(contextName)}
contextInfo=IMLibContextPool.getContextInfoFromId(targetIdCapt,'');contextInfo.context.setValue(contextInfo.record,contextInfo.field,dbresult);if(contextObjects){for(i=0;i<contextObjects.length;i++){contextObj=contextObjects[i];INTERMediator.construct(contextObj)}}
INTERMediatorLog.flushMessage();if(targetNodeCapt.getAttribute('data-im-widget-reload')==='true'){INTERMediator.construct()}
event.target.style.backgroundColor='#AAAAAA';finishFunc();completeTask()},function(){event.target.style.backgroundColor='#AAAAAA';finishFunc();completeTask()})}})())}})())}}}else{for(i=0;i<this.ids.length;i++){targetNode=document.getElementById(this.ids[i]);formNode=targetNode.getElementsByTagName('FORM')[0];if(targetNode&&formNode){var updateInfo=IMLibContextPool.getContextInfoFromId(this.ids[i],'');var inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_contextname');inputNode.setAttribute('value',updateInfo.context.contextName);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_field');inputNode.setAttribute('value',updateInfo.field);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_keyfield');inputNode.setAttribute('value',updateInfo.record.split('=')[0]);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','_im_keyvalue');inputNode.setAttribute('value',updateInfo.record.split('=')[1]);formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','clientid');if(INTERMediatorOnPage.authUser.length>0){inputNode.value=INTERMediatorOnPage.clientId}
formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','authuser');if(INTERMediatorOnPage.authUser.length>0){inputNode.value=INTERMediatorOnPage.authUser}
formNode.appendChild(inputNode);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','response');if(INTERMediatorOnPage.authUser.length>0){if(INTERMediatorOnPage.authHashedPassword&&INTERMediatorOnPage.authChallenge){shaObj=new jsSHA(INTERMediatorOnPage.authHashedPassword,'ASCII');hmacValue=shaObj.getHMAC(INTERMediatorOnPage.authChallenge,'ASCII','SHA-256','HEX');inputNode.value=hmacValue}else{inputNode.value='dummy'}}
formNode.appendChild(inputNode);if(INTERMediatorOnPage.authUser.length>0){encrypt.setPublicKey(INTERMediatorOnPage.publickey);inputNode=document.createElement('INPUT');inputNode.setAttribute('type','hidden');inputNode.setAttribute('name','cresponse');inputNode.setAttribute('value',encrypt.encrypt(INTERMediatorOnPage.authCryptedPassword.substr(0,220)+IMLib.nl_char+INTERMediatorOnPage.authChallenge)+IMLib.nl_char+INTERMediatorOnPage.authCryptedPassword.substr(220));formNode.appendChild(inputNode)}
if(this.progressSupported){inputNode=document.createElement('iframe');inputNode.setAttribute('id','upload_frame'+i);inputNode.setAttribute('name','upload_frame');inputNode.setAttribute('frameborder','0');inputNode.setAttribute('border','0');inputNode.setAttribute('scrolling','no');inputNode.setAttribute('scrollbar','no');formNode.appendChild(inputNode);INTERMediatorLib.addEvent(formNode,'submit',(function(){var iframeId=i;return function(){var iframeNode=document.getElementById('upload_frame'+iframeId);iframeNode.style.display='block';setTimeout(function(){var infoURL=selfURL()+'?uploadprocess='+this.uploadId+iframeId;iframeNode.setAttribute('src',infoURL)});return!0}})())}}}}
this.ids=[];this.formFromId={};function selfURL(){var nodes=document.getElementsByTagName('SCRIPT');for(var i=0;i<nodes.length;i++){var srcAttr=nodes[i].getAttribute('src');if(srcAttr.match(/\.php/)){return srcAttr}}
return null}}};IMParts_Catalog.jsonformat={instanciate:function(parentNode){'use strict';var newId=parentNode.getAttribute('id')+'-jsonf';var newNode=document.createElement('pre');newNode.setAttribute('id',newId);parentNode.appendChild(newNode);IMParts_Catalog.jsonformat.ids.push(newId);parentNode._im_getComponentId=(function(){var theId=newId;return function(){return theId}})();parentNode._im_setValue=(function(){var theId=newId;return function(str){IMParts_Catalog.jsonformat.initialValues[theId]=str?JSON.stringify(JSON.parse(str),null,' '):''}})()},ids:[],initialValues:{},finish:function(){'use strict';for(var i=0;i<IMParts_Catalog.jsonformat.ids.length;i++){var targetId=IMParts_Catalog.jsonformat.ids[i];var targetNode=document.getElementById(targetId);if(targetNode){targetNode.appendChild(document.createTextNode(IMParts_Catalog.jsonformat.initialValues[targetId]))}}
IMParts_Catalog.jsonformat.ids=[];IMParts_Catalog.jsonformat.initialValues={}}};IMParts_Catalog.popupselector={instanciate:function(parentNode){'use strict';var widgetId,node,inNode,valueNode;if(parentNode.getAttribute('class')!=='_im_widget_popup'){parentNode.setAttribute('class','_im_widget_popup');parentNode.style.zIndex=(IMParts_Catalog.popupselector.zIndex--);node=document.createElement('SPAN');node.setAttribute('data-im-control','enclosure');node.setAttribute('class','_im_widget_popup_panel');parentNode.appendChild(node);IMParts_Catalog.popupselector.selectionRoots.push(node);inNode=document.createElement('SPAN');inNode.setAttribute('data-im-control','repeater');inNode.setAttribute('data-im',parentNode.getAttribute('data-im-popup'));node.appendChild(inNode);inNode=document.createElement('DIV');inNode.setAttribute('class','_im_widget_popup_close');inNode.appendChild(document.createTextNode('×'));node.appendChild(inNode);INTERMediatorLib.addEvent(inNode,'click',(function(){return function(){IMParts_Catalog.popupselector.clearSelection()}})());widgetId=parentNode.getAttribute('id');IMParts_Catalog.popupselector.ids.push(widgetId);valueNode=document.createElement('span');valueNode.setAttribute('class','_im_widget_popup_value');INTERMediatorLib.addEvent(valueNode,'click',(function(){var selRoot=node;return function(){IMParts_Catalog.popupselector.clearSelection();IMParts_Catalog.popupselector.clickValue(selRoot)}})());parentNode.appendChild(valueNode);parentNode._im_getComponentId=(function(){var theId=widgetId;return function(){return theId}})();parentNode._im_setValue=(function(){var theId=widgetId;return function(str){IMParts_Catalog.popupselector.initialValues[theId]=str}})()}},ids:[],selectionRoots:[],initialValues:{},zIndex:9000,finish:function(){'use strict';var i,targetId,targetNode,j,nodes,selectionRoot,nodeValue,displayValue,innodes,k;for(i=0;i<IMParts_Catalog.popupselector.ids.length;i++){targetId=IMParts_Catalog.popupselector.ids[i];targetNode=document.getElementById(targetId);selectionRoot=IMParts_Catalog.popupselector.selectionRoots[i];nodeValue=IMParts_Catalog.popupselector.initialValues[targetId];if(selectionRoot){displayValue=null;nodes=selectionRoot.childNodes;for(j=0;j<nodes.length;j++){if(nodes[j]&&nodes[j].nodeType===1&&nodes[j].getAttribute('data-im-control')==='repeater'){nodes[j].setAttribute('class','_im_widget_popup_selection');if(nodeValue===nodes[j].getAttribute('data-im-value')){displayValue=nodes[j].innerHTML;nodes[j].setAttribute('class','_im_widget_popup_selection _im_widget_popup_selected')}
IMLibMouseEventDispatch.setExecute(nodes[j].id,(function(){var node=nodes[j];return function(){IMParts_Catalog.popupselector.clearSelection();IMParts_Catalog.popupselector.setData(node)}})())}}
if(targetNode){innodes=targetNode.getElementsByClassName('_im_widget_popup_value');for(k=0;k<innodes.length;k++){innodes[k].innerHTML=displayValue?displayValue:'[Not selected]'}}}}},clickValue:function(selectionRoot){'use strict';var body,panelBack;selectionRoot.style.display='block';body=document.getElementsByTagName('BODY')[0];panelBack=document.createElement('DIV');body.appendChild(panelBack);panelBack.setAttribute('class','_im_widget_popup_panelback');panelBack.setAttribute('id','_im_widget_popup_panelback');panelBack.style.width=body.clientWidth+'px';panelBack.style.height=body.clientHeight+'px';IMLibMouseEventDispatch.setExecute('_im_widget_popup_panelback',function(){IMParts_Catalog.popupselector.clearSelection()})},clearSelection:function(){'use strict';var i,body,targetNode,selectionRoot;body=document.getElementsByTagName('BODY')[0];targetNode=document.getElementById('_im_widget_popup_panelback');if(targetNode){body.removeChild(targetNode)}
for(i=0;i<IMParts_Catalog.popupselector.ids.length;i++){selectionRoot=IMParts_Catalog.popupselector.selectionRoots[i];if(selectionRoot){selectionRoot.style.display='none'}}},setData:function(node){'use strict';var i,selectedData,target,targetField,bindingId,keyRec,nodes,contextInfo;selectedData=node.getAttribute('data-im-value');target=node.parentNode.parentNode.getAttribute('data-im').split(' ')[0].split('@');targetField=target[1];bindingId=node.parentNode.parentNode.id;contextInfo=IMLibContextPool.getContextInfoFromId(bindingId,target[2]);keyRec=contextInfo.record.split('=');contextInfo.context.setDataWithKey(keyRec[1],targetField,selectedData);nodes=node.parentNode.parentNode.getElementsByClassName('_im_widget_popup_value');for(i=0;i<nodes.length;i++){nodes[i].innerHTML=node.innerHTML}
nodes=node.parentNode.getElementsByClassName('_im_widget_popup_selection');for(i=0;i<nodes.length;i++){if(node.getAttribute('data-im-value')===nodes[i].getAttribute('data-im-value')){nodes[i].setAttribute('class','_im_widget_popup_selection _im_widget_popup_selected')}else{nodes[i].setAttribute('class','_im_widget_popup_selection')}}}};var IMLibPageNavigation={deleteInsertOnNavi:[],previousModeDetail:null,stepNavigation:[],stepCurrentContextName:null,stepStartContextName:null,navigationSetup:function(){'use strict';var navigation,i,insideNav,navLabel,node,start,pageSize,allCount,dataSources,disableClass,c_node,prevPageCount,nextPageCount,endPageCount,contextName,contextDef,buttonLabel,dataSource;navigation=document.getElementById('IM_NAVIGATOR');if(navigation!==null){if(!IMLibContextPool.getPagingContext()){navigation.style.display='none';return}
insideNav=navigation.childNodes;for(i=0;i<insideNav.length;i++){navigation.removeChild(insideNav[i])}
navigation.innerHTML='';navigation.setAttribute('class','IM_NAV_panel');navLabel=INTERMediator.navigationLabel;if(navLabel===null||navLabel[8]!==!1){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(((navLabel===null||navLabel[8]===null)?INTERMediatorOnPage.getMessages()[2]:navLabel[8])));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){INTERMediator.initialize();IMLibLocalContext.archive();location.reload()})}
if(navLabel===null||navLabel[4]!==!1){start=Number(INTERMediator.startFrom);dataSource=IMLibContextPool.getPagingContext().getContextDef();if(dataSource&&dataSource.maxrecords&&dataSource.maxrecords<parseInt(INTERMediator.pagedSize,10)){INTERMediator.pagedSize=dataSource.maxrecords}
pageSize=Number(INTERMediator.pagedSize);allCount=Number(INTERMediator.pagedAllCount);disableClass=' IM_NAV_disabled';node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(((navLabel===null||navLabel[4]===null)?INTERMediatorOnPage.getMessages()[1]:navLabel[4])+(allCount===0?0:start+1)+((Math.min(start+pageSize,allCount)-start>1)?(((navLabel===null||navLabel[5]===null)?'-':navLabel[5])+Math.min(start+pageSize,allCount)):'')+((navLabel===null||navLabel[6]===null)?' / ':navLabel[6])+(allCount)+((navLabel===null||navLabel[7]===null)?'':navLabel[7])));node.setAttribute('class','IM_NAV_info')}
if((navLabel===null||navLabel[0]!==!1)&&INTERMediator.pagination===!0){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[0]===null)?'<<':navLabel[0]));node.setAttribute('class','IM_NAV_button'+(start===0?disableClass:''));if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',0)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[1]===null)?'<':navLabel[1]));node.setAttribute('class','IM_NAV_button'+(start===0?disableClass:''));prevPageCount=(start-pageSize>0)?start-pageSize:0;if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',prevPageCount)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[2]===null)?'>':navLabel[2]));node.setAttribute('class','IM_NAV_button'+(start+pageSize>=allCount?disableClass:''));nextPageCount=(start+pageSize<allCount)?start+pageSize:((allCount-pageSize>0)?start:0);if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',nextPageCount)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[3]===null)?'>>':navLabel[3]));node.setAttribute('class','IM_NAV_button'+(start+pageSize>=allCount?disableClass:''));if(allCount%pageSize===0){endPageCount=allCount-(allCount%pageSize)-pageSize}else{endPageCount=allCount-(allCount%pageSize)}
if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){IMLibPageNavigation.moveRecordFromNavi('navimoving',(endPageCount>0)?endPageCount:0)});node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[10]));c_node=document.createElement('INPUT');c_node.setAttribute('class','IM_NAV_JUMP');c_node.setAttribute('type','text');if(!c_node.id){c_node.id=INTERMediator.nextIdValue()}
c_node.setAttribute('value',String(Math.ceil(INTERMediator.startFrom/pageSize+1)));node.appendChild(c_node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[11]));IMLibChangeEventDispatch.setExecute(c_node.id,function(){var moveTo,max_page;moveTo=INTERMediatorLib.toNumber(c_node.value);if(moveTo<1){moveTo=1}
max_page=Math.ceil(allCount/pageSize);if(max_page<moveTo){moveTo=max_page}
INTERMediator.startFrom=(moveTo-1)*pageSize;INTERMediator.constructMain(!0)})}
if(navLabel===null||navLabel[9]!==!1){for(i=0;i<IMLibPageNavigation.deleteInsertOnNavi.length;i++){switch(IMLibPageNavigation.deleteInsertOnNavi[i].kind){case 'INSERT':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].insert){buttonLabel=contextDef['button-names'].insert}else{buttonLabel=INTERMediatorOnPage.getMessages()[3]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextName=obj.name,keyValue=obj.key,confirming=obj.confirm;return function(){IMLibPageNavigation.insertRecordFromNavi(contextName,keyValue,confirming)}})());break;case 'DELETE':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].delete){buttonLabel=contextDef['button-names'].delete}else{buttonLabel=INTERMediatorOnPage.getMessages()[4]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');INTERMediatorLib.addEvent(node,'click',(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextName=obj.name,keyName=obj.key,keyValue=obj.value,confirming=obj.confirm;return function(){IMLibPageNavigation.deleteRecordFromNavi(contextName,keyName,keyValue,confirming)}})());break;case 'COPY':node=document.createElement('SPAN');navigation.appendChild(node);contextName=IMLibPageNavigation.deleteInsertOnNavi[i].name;contextDef=IMLibContextPool.getContextDef(contextName);if(contextDef&&contextDef['button-names']&&contextDef['button-names'].copy){buttonLabel=contextDef['button-names'].copy}else{buttonLabel=INTERMediatorOnPage.getMessages()[15]+': '+contextName}
node.appendChild(document.createTextNode(buttonLabel));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,(function(){var obj=IMLibPageNavigation.deleteInsertOnNavi[i],contextDef=obj.contextDef,record=obj.keyValue;return function(){IMLibPageNavigation.copyRecordFromNavi(contextDef,record)}})());break}}}
if(navLabel===null||navLabel[10]!==!1){if(INTERMediatorOnPage.getOptionsTransaction()==='none'){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[10]===null)?INTERMediatorOnPage.getMessages()[7]:navLabel[10]));node.setAttribute('class','IM_NAV_button');INTERMediatorLib.addEvent(node,'click',IMLibPageNavigation.saveRecordFromNavi)}}
if(navLabel===null||navLabel[11]!==!1){if(INTERMediatorOnPage.requireAuthentication){node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode(INTERMediatorOnPage.getMessages()[8]+INTERMediatorOnPage.authUser));node.setAttribute('class','IM_NAV_info');node=document.createElement('SPAN');navigation.appendChild(node);node.appendChild(document.createTextNode((navLabel===null||navLabel[11]===null)?INTERMediatorOnPage.getMessages()[9]:navLabel[11]));node.setAttribute('class','IM_NAV_button');if(!node.id){node.id=INTERMediator.nextIdValue()}
IMLibMouseEventDispatch.setExecute(node.id,function(){INTERMediatorOnPage.logout();location.reload()})}}}},moveRecordFromNavi:function(targetName,page){'use strict';INTERMediator_DBAdapter.unregister();INTERMediator.startFrom=page;INTERMediator.constructMain(!0)},insertRecordFromNavi:function(targetName,keyField,isConfirm){'use strict';var contextDef;if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1026])){return}}
INTERMediatorOnPage.showProgress();contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',targetName);if(contextDef===null){window.alert('no targetname :'+targetName);INTERMediatorOnPage.hideProgress();return}
IMLibQueue.setTask((function(){var conditions,restore;var contextDefCapt=contextDef;var targetNameCapt=targetName;var keyFieldCapt=keyField;var isConfirmCapt=isConfirm;return function(completeTask){try{INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_createRecord_async({name:targetNameCapt,dataset:[]},function(response){var newId=response.newRecordKeyValue;if(newId>-1){restore=INTERMediator.additionalCondition;if(contextDefCapt.records<=1){INTERMediator.startFrom=0;INTERMediator.pagedAllCount=1;conditions=INTERMediator.additionalCondition;conditions[targetNameCapt]={field:keyFieldCapt,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}else{INTERMediator.pagedAllCount++}
completeTask();INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(!0);INTERMediator.additionalCondition=restore;IMLibPageNavigation.navigationSetup()}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()},completeTask)}catch(ex){completeTask();if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibPageNavigation.insertRecordFromNavi(targetNameCapt,keyFieldCapt,isConfirmCapt)});INTERMediatorLog.flushMessage()}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-5')}}}})())},deleteRecordFromNavi:function(targetName,keyField,keyValue,isConfirm){'use strict';if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1025])){return}}
IMLibQueue.setTask((function(){var deleteArgs={name:targetName,conditions:[{field:keyField,operator:'=',value:keyValue}]};return function(completeTask){INTERMediatorOnPage.showProgress();try{INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_delete_async(deleteArgs,(function(){return function(){INTERMediator.pagedAllCount--;INTERMediator.totalRecordCount--;if(INTERMediator.pagedAllCount-INTERMediator.startFrom<1){INTERMediator.startFrom--;if(INTERMediator.startFrom<0){INTERMediator.startFrom=0}}
completeTask();INTERMediator.constructMain(!0);INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),completeTask())}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-6');completeTask()}}})())},copyRecordFromNavi:function(contextDef,keyValue){'use strict';if(contextDef['repeat-control'].match(/confirm-copy/)){if(!window.confirm(INTERMediatorOnPage.getMessages()[1041])){return}}
IMLibQueue.setTask((function(){var contextDefCapt=contextDef;var keyValueCapt=keyValue;return function(completeTask){var assocDef,i,def,assocContexts,pStart,copyTerm,index;INTERMediatorOnPage.showProgress();try{if(contextDefCapt.relation){for(index in contextDefCapt.relation){if(contextDefCapt.relation[index].portal===!0){contextDefCapt.portal=!0}}}
assocDef=[];if(contextDefCapt['repeat-control'].match(/copy-/)){pStart=contextDefCapt['repeat-control'].indexOf('copy-');copyTerm=contextDefCapt['repeat-control'].substr(pStart+5);if((pStart=copyTerm.search(/\s/))>-1){copyTerm=copyTerm.substr(0,pStart)}
assocContexts=copyTerm.split(',');for(i=0;i<assocContexts.length;i++){def=IMLibContextPool.getContextDef(assocContexts[i]);if(def.relation[0]['foreign-key']){assocDef.push({name:def.name,field:def.relation[0]['foreign-key'],value:keyValueCapt})}}}
INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_copy_async({name:contextDefCapt.name,conditions:[{field:contextDefCapt.key,operator:'=',value:keyValueCapt}],associated:assocDef.length>0?assocDef:null},(function(){var contextDefCapt2=contextDefCapt;return function(result){var restore,conditions;var newId=result.newRecordKeyValue;completeTask();if(newId>-1){restore=INTERMediator.additionalCondition;INTERMediator.startFrom=0;if(contextDefCapt2.records<=1){conditions=INTERMediator.additionalCondition;conditions[contextDefCapt2.name]={field:contextDefCapt2.key,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}
INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(!0);INTERMediator.additionalCondition=restore}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),completeTask)}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-43');completeTask()}}})())},saveRecordFromNavi:function(dontUpdate){'use strict';var keying,field,keyingComp,keyingField,keyingValue,checkQueryParameter,i,initialValue,currentVal,fieldArray,valueArray,difference,needUpdate=!0,context,updateData,response;INTERMediatorOnPage.showProgress();INTERMediatorOnPage.retrieveAuthInfo();for(i=0;i<IMLibContextPool.poolingContexts.length;i++){context=IMLibContextPool.poolingContexts[i];updateData=context.getModified();for(keying in updateData){if(updateData.hasOwnProperty(keying)){fieldArray=[];valueArray=[];for(field in updateData[keying]){if(updateData[keying].hasOwnProperty(field)){fieldArray.push(field);valueArray.push({field:field,value:updateData[keying][field]})}}
keyingComp=keying.split('=');keyingField=keyingComp[0];keyingComp.shift();keyingValue=keyingComp.join('=');if(!INTERMediator.ignoreOptimisticLocking){checkQueryParameter={name:context.contextName,records:1,paging:!1,fields:fieldArray,parentkeyvalue:null,conditions:[{field:keyingField,operator:'=',value:keyingValue}],useoffset:!1,primaryKeyOnly:!0};try{currentVal=INTERMediator_DBAdapter.db_query(checkQueryParameter)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating((function(){var qParam=checkQueryParameter;return function(){INTERMediator.db_query(qParam)}})());return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-28')}}
if(currentVal.recordset===null||currentVal.recordset[0]===null){window.alert(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1003],[fieldArray.join(',')]));return}
if(currentVal.count>1){response=window.confirm(INTERMediatorOnPage.getMessages()[1024]);if(!response){return}}
difference=!1;for(field in updateData[keying]){if(updateData[keying].hasOwnProperty(field)){initialValue=context.getValue(keying,field);if(initialValue!==currentVal.recordset[0][field]){difference+=INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1035],[field,currentVal.recordset[0][field],updateData[keying][field]])}}}
if(difference!==!1){if(!window.confirm(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1034],[difference]))){return}
INTERMediatorOnPage.retrieveAuthInfo()}}
try{INTERMediator_DBAdapter.db_update({name:context.contextName,conditions:[{field:keyingField,operator:'=',value:keyingValue}],dataset:valueArray})}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibPageNavigation.saveRecordFromNavi(dontUpdate)});return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-29')}}
context.clearModified()}}}
if(needUpdate&&(dontUpdate!==!0)){INTERMediator.constructMain(!0)}
INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()},setupCopyButton:function(encNodeTag,repNodeTag,repeaters,currentContext,currentRecord){'use strict';var buttonNode,thisId,tdNodes,tdNode,buttonName,currentContextDef;currentContextDef=currentContext.getContextDef();if(!currentContextDef['repeat-control']||!currentContextDef['repeat-control'].match(/copy/i)){return}
if(currentContextDef.relation||currentContextDef.records===undefined||!currentContextDef.paging||(currentContextDef.records>1&&Number(INTERMediator.pagedSize)!==1)){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Copy');buttonName=INTERMediatorOnPage.getMessages()[14];if(currentContextDef['button-names']&&currentContextDef['button-names'].copy){buttonName=currentContextDef['button-names'].copy}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;IMLibMouseEventDispatch.setExecute(thisId,(function(){var currentContextCapt=currentContext,currentRecordCapt=currentRecord[currentContextDef.key];return function(){IMLibUI.copyButton(currentContextCapt,currentRecordCapt)}})());switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[tdNodes.length-1];tdNode.appendChild(buttonNode);break;case 'SELECT':break;default:if(repeaters[0]&&repeaters[0].childNodes){repeaters[repeaters.length-1].appendChild(buttonNode)}else{repeaters.push(buttonNode)}
break}}else{IMLibPageNavigation.deleteInsertOnNavi.push({kind:'COPY',name:currentContextDef.name,contextDef:currentContextDef,keyValue:currentRecord[currentContextDef.key]})}},setupDeleteButton:function(encNodeTag,repeaters,currentContext,keyField,keyValue){'use strict';var buttonNode,thisId,tdNodes,tdNode,buttonName,currentContextDef;currentContextDef=currentContext.contextDefinition;if(!currentContextDef['repeat-control']||!currentContextDef['repeat-control'].match(/delete/i)){return}
if(currentContextDef.relation||currentContextDef.records===undefined||!currentContextDef.paging||(currentContextDef.records>1&&Number(INTERMediator.pagedSize)!==1)){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Delete');buttonName=INTERMediatorOnPage.getMessages()[6];if(currentContextDef['button-names']&&currentContextDef['button-names'].delete){buttonName=currentContextDef['button-names'].delete}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;IMLibMouseEventDispatch.setExecute(thisId,(function(){var currentContextCapt=currentContext,keyFieldCapt=keyField,keyValueCapt=keyValue,confirmingCapt=!!currentContextDef['repeat-control'].match(/confirm-delete/i);return function(){IMLibUI.deleteButton(currentContextCapt,keyFieldCapt,keyValueCapt,confirmingCapt)}})());switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[tdNodes.length-1];tdNode.appendChild(buttonNode);break;case 'SELECT':break;default:if(repeaters[0]&&repeaters[0].childNodes){repeaters[repeaters.length-1].appendChild(buttonNode)}else{repeaters.push(buttonNode)}
break}}else{IMLibPageNavigation.deleteInsertOnNavi.push({kind:'DELETE',name:currentContextDef.name,key:keyField,value:keyValue,confirm:currentContextDef['repeat-control'].match(/confirm-delete/i)})}},setupInsertButton:function(currentContext,keyValue,node,relationValue){'use strict';var buttonNode,enclosedNode,footNode,trNode,tdNode,liNode,divNode,i,firstLevelNodes,targetNodeTag,existingButtons,keyField,thisId,encNodeTag,buttonName,setTop,currentContextDef;encNodeTag=node.tagName;currentContextDef=currentContext.getContextDef();if(currentContextDef['repeat-control']&&currentContextDef['repeat-control'].match(/insert/i)){if(relationValue.length>0||!currentContextDef.paging||currentContextDef.paging===!1){buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Insert');buttonName=INTERMediatorOnPage.getMessages()[5];if(currentContextDef['button-names']&&currentContextDef['button-names'].insert){buttonName=currentContextDef['button-names'].insert}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;switch(encNodeTag){case 'TBODY':setTop=!1;targetNodeTag='TFOOT';if(currentContextDef['repeat-control'].match(/top/i)){targetNodeTag='THEAD';setTop=!0}
enclosedNode=node.parentNode;firstLevelNodes=enclosedNode.childNodes;footNode=null;for(i=0;i<firstLevelNodes.length;i++){if(firstLevelNodes[i].tagName===targetNodeTag){footNode=firstLevelNodes[i];break}}
if(footNode===null){footNode=document.createElement(targetNodeTag);enclosedNode.appendChild(footNode)}
existingButtons=INTERMediatorLib.getElementsByClassName(footNode,'IM_Button_Insert');if(existingButtons.length===0){trNode=document.createElement('TR');INTERMediatorLib.setClassAttributeToNode(trNode,'IM_Insert_TR');tdNode=document.createElement('TD');tdNode.setAttribute('colspan',100);INTERMediatorLib.setClassAttributeToNode(tdNode,'IM_Insert_TD');INTERMediator.setIdValue(trNode);if(setTop&&footNode.childNodes){footNode.insertBefore(trNode,footNode.childNodes[0])}else{footNode.appendChild(trNode)}
trNode.appendChild(tdNode);tdNode.appendChild(buttonNode)}
break;case 'UL':case 'OL':liNode=document.createElement('LI');existingButtons=INTERMediatorLib.getElementsByClassName(liNode,'IM_Button_Insert');if(existingButtons.length===0){liNode.appendChild(buttonNode);if(currentContextDef['repeat-control'].match(/top/i)){node.insertBefore(liNode,node.firstChild)}else{node.appendChild(liNode)}}
break;case 'SELECT':break;default:divNode=document.createElement('DIV');existingButtons=INTERMediatorLib.getElementsByClassName(divNode,'IM_Button_Insert');if(existingButtons.length===0){divNode.appendChild(buttonNode);if(currentContextDef['repeat-control'].match(/top/i)){node.insertBefore(divNode,node.firstChild)}else{node.appendChild(divNode)}}
break}
IMLibMouseEventDispatch.setExecute(buttonNode.id,(function(){var context=currentContext,keyValueCapt=keyValue,relationValueCapt=relationValue,nodeId=node.getAttribute('id'),confirming=!!currentContextDef['repeat-control'].match(/confirm-insert/i);return function(){IMLibUI.insertButton(context,keyValueCapt,relationValueCapt,nodeId,confirming)}})())}else{if(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'){keyField=currentContextDef.key?currentContextDef.key:INTERMediatorOnPage.defaultKeyName}else{keyField=currentContextDef.key?currentContextDef.key:'id'}
IMLibPageNavigation.deleteInsertOnNavi.push({kind:'INSERT',name:currentContextDef.name,key:keyField,confirm:currentContextDef['repeat-control'].match(/confirm-insert/i)})}}},setupNavigationButton:function(encNodeTag,repeaters,currentContextDef,keyField,keyValue,contextObj){'use strict';var buttonNode,thisId,tdNodes,tdNode,firstInNode,isMasterDetail,isStep,isHide,masterContext,detailContext,showingNode,isHidePageNavi,buttonName,i,isTouchRepeater,moveToDetailFunc;if(!currentContextDef['navi-control']||(!currentContextDef['navi-control'].match(/master/i)&&!currentContextDef['navi-control'].match(/step/i))||encNodeTag==='SELECT'){return}
isTouchRepeater=INTERMediator.isMobile||INTERMediator.isTablet;isHide=!!currentContextDef['navi-control'].match(/hide/i);isHidePageNavi=isHide&&!!currentContextDef.paging;isMasterDetail=!!currentContextDef['navi-control'].match(/master/i);isStep=!!currentContextDef['navi-control'].match(/step/i);if(isMasterDetail&&INTERMediator.detailNodeOriginalDisplay){detailContext=IMLibContextPool.getDetailContext();if(detailContext){showingNode=detailContext.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
INTERMediator.detailNodeOriginalDisplay=showingNode.style.display}}
buttonNode=document.createElement('BUTTON');INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_Master');buttonName=INTERMediatorOnPage.getMessages()[12];if(currentContextDef['button-names']&&currentContextDef['button-names']['navi-detail']){buttonName=currentContextDef['button-names']['navi-detail']}
buttonNode.appendChild(document.createTextNode(buttonName));thisId='IM_Button_'+INTERMediator.buttonIdNum;buttonNode.setAttribute('id',thisId);INTERMediator.buttonIdNum++;if(isMasterDetail){masterContext=IMLibContextPool.getMasterContext();masterContext.setValue(keyField+'='+keyValue,'_im_button_master_id',thisId,thisId)}
if(isMasterDetail){moveToDetailFunc=IMLibPageNavigation.moveToDetail(keyField,keyValue,isHide,isHidePageNavi)}
if(isStep){moveToDetailFunc=IMLibPageNavigation.moveToNextStep(contextObj,keyField,keyValue)}
if(isTouchRepeater){for(i=0;i<repeaters.length;i++){var originalColor=repeaters[i].style.backgroundColor;INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchstart','todo':(function(){var targetNode=repeaters[i];return function(){IMLibEventResponder.touchEventCancel=!1;targetNode.style.backgroundColor=IMLibUI.mobileSelectionColor}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchend','todo':(function(){var targetNode=repeaters[i];var orgColor=originalColor;return function(){targetNode.style.backgroundColor=orgColor;if(!IMLibEventResponder.touchEventCancel){IMLibEventResponder.touchEventCancel=!1;moveToDetailFunc()}}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchmove','todo':(function(){return function(){IMLibEventResponder.touchEventCancel=!0}})()});INTERMediator.eventListenerPostAdding.push({'id':repeaters[i].id,'event':'touchcancel','todo':(function(){return function(){IMLibEventResponder.touchEventCancel=!0}})()})}}else{IMLibMouseEventDispatch.setExecute(thisId,moveToDetailFunc);switch(encNodeTag){case 'TBODY':tdNodes=repeaters[repeaters.length-1].getElementsByTagName('TD');tdNode=tdNodes[0];firstInNode=tdNode.childNodes[0];if(firstInNode){tdNode.insertBefore(buttonNode,firstInNode)}else{tdNode.appendChild(buttonNode)}
break;case 'SELECT':break;default:firstInNode=repeaters[repeaters.length-1].childNodes[0];if(firstInNode){repeaters[repeaters.length-1].insertBefore(buttonNode,firstInNode)}else{repeaters[repeaters.length-1].appendChild(buttonNode)}
break}}},getStepLastSelectedRecord:function(){'use strict';var lastSelection=IMLibPageNavigation.stepNavigation[IMLibPageNavigation.stepNavigation.length-1];return lastSelection.context.store[lastSelection.key]},isNotExpandingContext:function(contextDef){'use strict';if(contextDef['navi-control']&&contextDef['navi-control'].match(/step/i)){return IMLibPageNavigation.stepCurrentContextName!==contextDef.name}
return!1},startStep:function(){'use strict';IMLibPageNavigation.initializeStepInfo(!0);INTERMediator.constructMain(IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName))},initializeStepInfo:function(includeHide){'use strict';var key,dataSrcs,cDef,judgeHide,isDetected=!1;IMLibPageNavigation.stepNavigation=[];IMLibPageNavigation.stepCurrentContextName=null;IMLibPageNavigation.stepStartContextName=null;IMLibPageNavigation.setupStepReturnButton('none');if(INTERMediatorOnPage.getDataSources){dataSrcs=INTERMediatorOnPage.getDataSources();for(key in dataSrcs){if(dataSrcs.hasOwnProperty(key)){cDef=dataSrcs[key];if(cDef['navi-control']){judgeHide=includeHide||(!includeHide&&!cDef['navi-control'].match(/hide/i));if(cDef['navi-control']&&cDef['navi-control'].match(/step/i)){if(judgeHide&&!isDetected){IMLibPageNavigation.stepCurrentContextName=cDef.name;IMLibPageNavigation.stepStartContextName=IMLibPageNavigation.stepCurrentContextName;isDetected=!0;if(cDef['navi-title']){IMLibLocalContext.setValue('navi_title',cDef['navi-title'],!0)}
if(INTERMediatorOnPage[cDef['just-move-thisstep']]){INTERMediatorOnPage[cDef['just-move-thisstep']]()}}}}}}}},setupStepReturnButton:function(style){'use strict';var nodes,i;nodes=document.getElementsByClassName('IM_Button_StepBack');for(i=0;i<nodes.length;i++){nodes[i].style.display=style;if(!INTERMediatorLib.isProcessed(nodes[i])){INTERMediatorLib.addEvent(nodes[i],'click',function(){IMLibPageNavigation.backToPreviousStep()});INTERMediatorLib.markProcessed(nodes[i])}}},moveToNextStep:function(contextObj,keyField,keyValue){'use strict';var context=contextObj,keying=keyField+'='+keyValue;return function(){IMLibQueue.setTask(function(complete){IMLibPageNavigation.moveToNextStepImpl(context,keying);complete()})}},moveNextStep:function(keying){'use strict';var context=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);IMLibPageNavigation.moveToNextStepImpl(context,keying)},moveToNextStepImpl:function(contextObj,keying){'use strict';var key,cDef,dataSrcs,contextDef,isAfterCurrent=!1,control=null,hasNextContext=!1,nextContext;contextDef=contextObj.getContextDef();IMLibPageNavigation.stepNavigation.push({context:contextObj,key:keying});if(INTERMediatorOnPage[contextDef['before-move-nextstep']]){control=INTERMediatorOnPage[contextDef['before-move-nextstep']]()}
if(control===!1){IMLibPageNavigation.stepNavigation.pop();return}else if(control){IMLibPageNavigation.stepCurrentContextName=control}else{dataSrcs=INTERMediatorOnPage.getDataSources();for(key in dataSrcs){if(dataSrcs.hasOwnProperty(key)){cDef=dataSrcs[key];if(cDef.name===contextDef.name){isAfterCurrent=!0}else if(isAfterCurrent&&cDef['navi-control'].match(/step/i)){IMLibPageNavigation.stepCurrentContextName=cDef.name;hasNextContext=!0;break}}}
if(!hasNextContext){return}}
if(INTERMediatorOnPage[contextDef['just-leave-thisstep']]){INTERMediatorOnPage[contextDef['just-leave-thisstep']]()}
if(contextObj.enclosureNode.tagName==='TBODY'){contextObj.enclosureNode.parentNode.style.display='none'}else{contextObj.enclosureNode.style.display='none'}
nextContext=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);contextDef=nextContext.getContextDef();if(nextContext.enclosureNode.tagName==='TBODY'){nextContext.enclosureNode.parentNode.style.display=''}else{nextContext.enclosureNode.style.display=''}
INTERMediator.constructMain(nextContext);IMLibPageNavigation.setupStepReturnButton('');if(contextDef['navi-title']){IMLibLocalContext.setValue('navi_title',contextDef['navi-title'],!0)}
if(INTERMediatorOnPage[contextDef['just-move-thisstep']]){INTERMediatorOnPage[contextDef['just-move-thisstep']]()}},backToPreviousStep:function(){'use strict';var currentContext,prevInfo,contextDef;currentContext=IMLibContextPool.contextFromName(IMLibPageNavigation.stepCurrentContextName);contextDef=currentContext.getContextDef();if(INTERMediatorOnPage[contextDef['just-leave-thisstep']]){INTERMediatorOnPage[contextDef['just-leave-thisstep']]()}
prevInfo=IMLibPageNavigation.stepNavigation.pop();IMLibPageNavigation.stepCurrentContextName=prevInfo.context.contextName;if(prevInfo.context.enclosureNode.tagName==='TBODY'){prevInfo.context.enclosureNode.parentNode.style.display=''}else{prevInfo.context.enclosureNode.style.display=''}
if(IMLibPageNavigation.stepStartContextName===IMLibPageNavigation.stepCurrentContextName){IMLibPageNavigation.setupStepReturnButton('none')}
INTERMediator.constructMain(currentContext);INTERMediator.constructMain(prevInfo.context);contextDef=prevInfo.context.getContextDef();if(contextDef['navi-title']){IMLibLocalContext.setValue('navi_title',contextDef['navi-title'],!0)}
if(INTERMediatorOnPage[contextDef['just-move-thisstep']]){INTERMediatorOnPage[contextDef['just-move-thisstep']]()}},moveToDetail:function(keyField,keyValue,isHide,isHidePageNavi){'use strict';var f=keyField,v=keyValue,mh=isHide,pnh=isHidePageNavi;return function(){return IMLibPageNavigation.moveToDetailImpl(f,v,mh,pnh)}},moveToDetailImpl:function(keyField,keyValue,isHide,isHidePageNavi){'use strict';var masterContext,detailContext,contextName,masterEnclosure,detailEnclosure,node,contextDef;IMLibPageNavigation.previousModeDetail={keyField:keyField,keyValue:keyValue,isHide:isHide,isHidePageNavi:isHidePageNavi};masterContext=IMLibContextPool.getMasterContext();detailContext=IMLibContextPool.getDetailContext();if(detailContext){if(INTERMediatorOnPage.naviBeforeMoveToDetail){INTERMediatorOnPage.naviBeforeMoveToDetail(masterContext,detailContext)}
contextDef=detailContext.getContextDef();contextName=contextDef.name;INTERMediator.clearCondition(contextName,'_imlabel_crosstable');INTERMediator.addCondition(contextName,{field:keyField,operator:'=',value:keyValue},undefined,'_imlabel_crosstable');INTERMediator.constructMain(detailContext);INTERMediator.clearCondition(contextName);if(isHide){INTERMediatorOnPage.masterScrollPosition={x:window.scrollX,y:window.scrollY};window.scrollTo(0,0);masterEnclosure=masterContext.enclosureNode;if(masterEnclosure.tagName==='TBODY'){masterEnclosure=masterEnclosure.parentNode}
INTERMediator.masterNodeOriginalDisplay=masterEnclosure.style.display;masterEnclosure.style.display='none';detailEnclosure=detailContext.enclosureNode;if(detailEnclosure.tagName==='TBODY'){detailEnclosure=detailEnclosure.parentNode}
detailEnclosure.style.display=INTERMediator.detailNodeOriginalDisplay}
if(isHidePageNavi){document.getElementById('IM_NAVIGATOR').style.display='none'}
if(IMLibUI.mobileNaviBackButtonId){node=document.getElementById(IMLibUI.mobileNaviBackButtonId);node.style.display='inline-block'}
if(INTERMediatorOnPage.naviAfterMoveToDetail){masterContext=IMLibContextPool.getMasterContext();detailContext=IMLibContextPool.getDetailContext();INTERMediatorOnPage.naviAfterMoveToDetail(masterContext,detailContext)}}},setupDetailAreaToFirstRecord:function(currentContextDef,masterContext){'use strict';var i,comp;if(currentContextDef['navi-control']&&currentContextDef['navi-control'].match(/master/i)){var contextDefs=INTERMediatorOnPage.getDataSources();for(i in contextDefs){if(contextDefs.hasOwnProperty(i)&&contextDefs[i]&&contextDefs[i].name&&contextDefs[i]['navi-control']&&contextDefs[i]['navi-control'].match(/detail/i)){if(Object.keys(masterContext.store).length>0){comp=Object.keys(masterContext.store)[0].split('=');if(comp.length>1){INTERMediator.clearCondition(contextDefs[i].name,'_imlabel_crosstable');INTERMediator.addCondition(contextDefs[i].name,{field:comp[0],operator:'=',value:comp[1]},undefined,'_imlabel_crosstable')}}}}}},moveDetailOnceAgain:function(){'use strict';var p=IMLibPageNavigation.previousModeDetail;IMLibPageNavigation.moveToDetailImpl(p.keyField,p.keyValue,p.isHide,p.isHidePageNavi)},setupBackNaviButton:function(currentContext,node){'use strict';var buttonNode,divNode,i,masterContext,naviControlValue,currentContextDef,showingNode,isHidePageNavi,isUpdateMaster,isTouchRepeater,aNode,nodes,isTop;currentContextDef=currentContext.getContextDef();if(!currentContextDef['navi-control']||!currentContextDef['navi-control'].match(/detail/i)){return}
masterContext=IMLibContextPool.getMasterContext();isHidePageNavi=!!masterContext.getContextDef().paging;if(masterContext.getContextDef().paging&&currentContextDef.paging){INTERMediatorLog.setErrorMessage('The datail context definition has the "paging" key. '+'This is not required and causes bad effect to the pagination.','Detected Error')}
naviControlValue=masterContext.getContextDef()['navi-control'];if(!naviControlValue||(!naviControlValue.match(/hide/i))){return}
isUpdateMaster=!!currentContextDef['navi-control'].match(/update/i);isTouchRepeater=INTERMediator.isMobile||INTERMediator.isTablet;isTop=!(currentContextDef['navi-control'].match(/bottom/i));showingNode=currentContext.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
if(INTERMediator.detailNodeOriginalDisplay){INTERMediator.detailNodeOriginalDisplay=showingNode.style.display}
showingNode.style.display='none';if(isTouchRepeater){nodes=document.getElementsByClassName('IM_Button_BackNavi');if(!nodes||nodes.length===0){aNode=createBackButton('DIV',currentContextDef);IMLibUI.mobileNaviBackButtonId=aNode.id;aNode.style.display='none';nodes=INTERMediatorLib.getElementsByAttributeValue(document.getElementsByTagName('BODY')[0],'data-role',isTop?'header':'footer');if(nodes&&nodes[0]){if(nodes[0].firstChild){nodes[0].insertBefore(aNode,nodes[0].firstChild)}else{nodes[0].appendChild(aNode)}}else{switch(node.tagName){case 'TBODY':tbodyTargetNode(node,isTop,aNode);break;case 'UL':case 'OL':genericTargetNode(node,isTop,'LI',aNode);break;case 'SELECT':break;default:genericTargetNode(node,isTop,'DIV',aNode);break}}
if(!aNode.id){aNode.id=INTERMediator.nextIdValue()}
INTERMediator.eventListenerPostAdding.push({'id':aNode.id,'event':'touchend','todo':moveToMaster(masterContext,currentContext,isHidePageNavi,isUpdateMaster)})}}else{buttonNode=createBackButton('BUTTON',currentContextDef);switch(node.tagName){case 'TBODY':tbodyTargetNode(node,isTop,buttonNode);break;case 'UL':case 'OL':genericTargetNode(node,isTop,'LI',buttonNode);break;case 'SELECT':break;default:genericTargetNode(node,isTop,'DIV',buttonNode);break}
INTERMediatorLib.addEvent(buttonNode,'click',moveToMaster(masterContext,currentContext,isHidePageNavi,isUpdateMaster))}
function createBackButton(tagName,currentContextDef){var buttonNode,buttonName;buttonNode=document.createElement(tagName);INTERMediatorLib.setClassAttributeToNode(buttonNode,'IM_Button_BackNavi');buttonName=INTERMediatorOnPage.getMessages()[13];if(currentContextDef['button-names']&&currentContextDef['button-names']['navi-back']){buttonName=currentContextDef['button-names']['navi-back']}
buttonNode.appendChild(document.createTextNode(buttonName));setIdForIMButtons(buttonNode);return buttonNode}
function setIdForIMButtons(node){var thisId;thisId='IM_Button_'+INTERMediator.buttonIdNum;node.setAttribute('id',thisId);INTERMediator.buttonIdNum++}
function tbodyTargetNode(node,isTop,buttonNode){var targetNodeTag,enclosedNode,firstLevelNodes,targetNode,existingButtons,trNode,tdNode;targetNodeTag=isTop?'THEAD':'TFOOT';enclosedNode=node.parentNode;firstLevelNodes=enclosedNode.childNodes;targetNode=null;for(i=0;i<firstLevelNodes.length;i++){if(firstLevelNodes[i].tagName===targetNodeTag){targetNode=firstLevelNodes[i];break}}
if(targetNode===null){targetNode=document.createElement(targetNodeTag);INTERMediator.appendingNodesAtLast.push({targetNode:targetNode,parentNode:enclosedNode,siblingNode:(targetNodeTag==='THEAD')?enclosedNode.firstChild:null})}
existingButtons=INTERMediatorLib.getElementsByClassName(targetNode,'IM_Button_BackNavi');if(existingButtons.length===0){trNode=document.createElement('TR');INTERMediatorLib.setClassAttributeToNode(trNode,'IM_NaviBack_TR');tdNode=document.createElement('TD');tdNode.setAttribute('colspan',100);INTERMediatorLib.setClassAttributeToNode(tdNode,'IM_NaviBack_TD');INTERMediator.setIdValue(trNode);targetNode.appendChild(trNode);trNode.appendChild(tdNode);tdNode.appendChild(buttonNode)}}
function genericTargetNode(node,isTop,naviEncTag,buttonNode){var newNode,existingButtons;newNode=document.createElement(naviEncTag);existingButtons=INTERMediatorLib.getElementsByClassName(divNode,'IM_Button_BackNavi');if(existingButtons.length===0){newNode.appendChild(buttonNode);if(!isTop){node.appendChild(newNode)}else{node.insertBefore(newNode,node.firstChild)}}}
function moveToMaster(a,b,c,d){var masterContextCL=a,detailContextCL=b,pageNaviShow=c,masterUpdate=d,node;return function(event){var showingNode;if(INTERMediatorOnPage.naviBeforeMoveToMaster){INTERMediatorOnPage.naviBeforeMoveToMaster(masterContextCL,detailContextCL)}
showingNode=detailContextCL.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
showingNode.style.display='none';showingNode=masterContextCL.enclosureNode;if(showingNode.tagName==='TBODY'){showingNode=showingNode.parentNode}
showingNode.style.display=INTERMediator.masterNodeOriginalDisplay;if(pageNaviShow){document.getElementById('IM_NAVIGATOR').style.display='block'}
if(masterUpdate){INTERMediator.constructMain(masterContextCL)}
if(IMLibUI.mobileNaviBackButtonId){node=document.getElementById(IMLibUI.mobileNaviBackButtonId);node.style.display='none'}
if(INTERMediatorOnPage.naviAfterMoveToMaster){masterContextCL=IMLibContextPool.getMasterContext();detailContextCL=IMLibContextPool.getDetailContext();INTERMediatorOnPage.naviAfterMoveToMaster(masterContextCL,detailContextCL)}
if(INTERMediatorOnPage.masterScrollPosition){window.scrollTo(INTERMediatorOnPage.masterScrollPosition.x,INTERMediatorOnPage.masterScrollPosition.y)}
event.preventDefault()}}}};var IMLibUI={mobileSelectionColor:'#BBBBBB',mobileNaviBackButtonId:null,mergedFieldSeparator:'\n',valueChange:function(idValue,validationOnly){'use strict';var changedObj,contextInfo,linkInfo,nodeInfo,returnValue=!0;changedObj=document.getElementById(idValue);if(!changedObj){return!1}
if(changedObj.readOnly){return!0}
if(!IMLibUI.validation(changedObj)){changedObj.focus();linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);window.setTimeout((function(){var originalObj=changedObj;var originalContextInfo=contextInfo;return function(){if(originalContextInfo){originalObj.value=originalContextInfo.context.getValue(originalContextInfo.record,originalContextInfo.field)}
originalObj.removeAttribute('data-im-validation-notification')}})(),0);return!1}
if(validationOnly===!0){return!0}
IMLibQueue.setTask(function(completeTask){returnValue=valueChangeImpl(idValue,completeTask)});return returnValue;function valueChangeImpl(idValue,completeTask){var changedObj,objType,i,newValue,result,linkInfo,nodeInfo,contextInfo,parentContext,targetField,targetNode,targetSpec,returnValue=!0;try{changedObj=document.getElementById(idValue);linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);nodeInfo=INTERMediatorLib.getNodeInfoArray(linkInfo[0]);contextInfo=IMLibContextPool.getContextInfoFromId(idValue,nodeInfo.target);if(!contextInfo){targetNode=document.getElementById(idValue);targetSpec=targetNode.getAttribute('data-im');if(targetSpec&&targetSpec.split(INTERMediator.separator)[0]===IMLibLocalContext.contextName){IMLibLocalContext.updateFromNodeValue(idValue);IMLibCalc.recalculation();completeTask();return!0}
throw 'unfinished'}
objType=changedObj.getAttribute('type');if(objType==='radio'&&!changedObj.checked){completeTask();return!0}
if(!contextInfo){throw 'unfinished'}
newValue=IMLibElement.getValueFromIMNode(changedObj);if(contextInfo.context.parentContext){parentContext=contextInfo.context.parentContext}else{parentContext=IMLibContextPool.getContextFromName(contextInfo.context.sourceName)[0]}
if(parentContext){result=parentContext.isValueUndefined(Object.keys(parentContext.store)[0],contextInfo.field,contextInfo.record)}else{result=contextInfo.context.isValueUndefined(contextInfo.record,contextInfo.field,!1)}
if(result){INTERMediatorLog.setErrorMessage('Error in updating.',INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1040],[contextInfo.context.contextName,contextInfo.field]));throw 'unfinished'}
if(INTERMediatorOnPage.getOptionsTransaction()==='none'){contextInfo.context.setValue(contextInfo.record,contextInfo.field,newValue);contextInfo.context.setModified(contextInfo.record,contextInfo.field,newValue);throw 'unfinished'}
if(INTERMediatorOnPage.doBeforeValueChange){INTERMediatorOnPage.doBeforeValueChange(idValue)}
INTERMediatorOnPage.showProgress();contextInfo.context.updateFieldValue(idValue,(function(){var idValueCapt2=idValue;var contextInfoCapt=contextInfo;var newValueCapt=newValue;var completeTaskCapt=completeTask;return function(result){var updateRequiredContext,currentValue,associatedNode,field,node,children,delNodes,recordObj,keepProp;var keyField=contextInfoCapt.context.getKeyField();if(result&&result.dbresult){recordObj=result.dbresult[0];keepProp=INTERMediator.partialConstructing;INTERMediator.partialConstructing=!1;for(field in recordObj){if(recordObj.hasOwnProperty(field)){contextInfoCapt.context.setValue(keyField+'='+recordObj[keyField],field,recordObj[field])}}}
INTERMediator.partialConstructing=keepProp;updateRequiredContext=IMLibContextPool.dependingObjects(idValueCapt2);for(i=0;i<updateRequiredContext.length;i++){updateRequiredContext[i].foreignValue={};updateRequiredContext[i].foreignValue[contextInfoCapt.field]=newValueCapt;if(updateRequiredContext[i]){INTERMediator.constructMain(updateRequiredContext[i]);associatedNode=updateRequiredContext[i].enclosureNode;if(INTERMediatorLib.isPopupMenu(associatedNode)){currentValue=contextInfo.context.getContextValue(associatedNode.id,'');IMLibElement.setValueToIMNode(associatedNode,'',currentValue,!1)}}}
node=document.getElementById(idValueCapt2);if(node&&node.tagName==='SELECT'){children=node.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){if(children[i].tagName==='OPTION'&&children[i].getAttribute('data-im-element')==='auto-generated'){delNodes=[];delNodes.push(children[i].getAttribute('id'));IMLibElement.deleteNodes(delNodes)}}}}
IMLibCalc.recalculation();if(INTERMediatorOnPage.doAfterValueChange){INTERMediatorOnPage.doAfterValueChange(idValueCapt2)}
INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage();if(completeTaskCapt){completeTaskCapt()}}})(),(function(){var targetFieldCapt=targetField;var completeTaskCapt=completeTask;return function(){window.alert(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1003],[targetFieldCapt]));INTERMediatorOnPage.hideProgress();if(completeTaskCapt){completeTaskCapt()}}})(),function(){var response=window.confirm(INTERMediatorOnPage.getMessages()[1024]);if(!response){INTERMediatorOnPage.hideProgress()}
if(completeTask){completeTask()}
return response},(function(){var changedObjectCapt=changedObj;var completeTaskCapt=completeTask;return function(initialvalue,newValue,currentFieldVal){if(completeTaskCapt){completeTaskCapt()}
if(!window.confirm(INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1001],[initialvalue,newValue,currentFieldVal]))){window.setTimeout(function(){changedObjectCapt.focus()},0);INTERMediatorOnPage.hideProgress();return!1}
return!0}})())}catch(e){if(completeTask){completeTask()}
returnValue=!1}
return returnValue}},validation:function(changedObj){'use strict';var linkInfo,matched,context,i,index,didValidate,contextInfo,result,messageNodes=[],messageNode;if(messageNodes){while(messageNodes.length>0){messageNodes[0].parentNode.removeChild(messageNodes[0]);delete messageNodes[0]}}
if(!messageNodes){messageNodes=[]}
try{linkInfo=INTERMediatorLib.getLinkedElementInfo(changedObj);didValidate=!1;result=!0;if(linkInfo.length>0){matched=linkInfo[0].match(/([^@]+)/);if(matched[1]!==IMLibLocalContext.contextName){context=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',matched[1]);if(context&&context.validation){for(i=0;i<linkInfo.length;i++){matched=linkInfo[i].match(/([^@]+)@([^@]+)/);for(index in context.validation){if(context.validation[index].field===matched[2]){didValidate=!0;result=Parser.evaluate(context.validation[index].rule,{'value':changedObj.value,'target':changedObj});if(!result){switch(context.validation[index].notify){case 'inline':INTERMediatorLib.clearErrorMessage(changedObj);messageNode=INTERMediatorLib.createErrorMessageNode('SPAN',context.validation[index].message);changedObj.parentNode.insertBefore(messageNode,changedObj.nextSibling);messageNodes.push(messageNode);break;case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(changedObj);messageNode=INTERMediatorLib.createErrorMessageNode('DIV',context.validation[index].message);changedObj.parentNode.appendChild(messageNode);messageNodes.push(messageNode);break;default:if(changedObj.getAttribute('data-im-validation-notification')!=='alert'){window.alert(context.validation[index].message);changedObj.setAttribute('data-im-validation-notification','alert')}
break}
contextInfo=IMLibContextPool.getContextInfoFromId(changedObj,'');if(contextInfo){changedObj.value=contextInfo.context.getValue(contextInfo.record,contextInfo.field);window.setTimeout(function(){changedObj.focus()},0);if(INTERMediatorOnPage.doAfterValidationFailure!==null){INTERMediatorOnPage.doAfterValidationFailure(changedObj,linkInfo[i])}}
return result}else{switch(context.validation[index].notify){case 'inline':case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(changedObj);break}}}}}}}
if(didValidate){if(INTERMediatorOnPage.doAfterValidationSucceed){result=INTERMediatorOnPage.doAfterValidationSucceed(changedObj,linkInfo[i])}}}
return result}catch(ex){if(ex==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-32: on the validation process.')}
return!1}},copyButton:function(contextObj,keyValue){'use strict';var contextDef=contextObj.getContextDef();if(contextDef['repeat-control'].match(/confirm-copy/)){if(!window.confirm(INTERMediatorOnPage.getMessages()[1041])){return}}
IMLibQueue.setTask((function(){var contextObjCapt=contextObj;var keyValueCapt=keyValue;return function(completeTask){var contextDef,assocDef,i,index,def,assocContexts,pStart,copyTerm;contextDef=contextObjCapt.getContextDef();INTERMediatorOnPage.showProgress();try{if(contextDef.relation){for(index in contextDef.relation){if(contextDef.relation[index].portal===!0){contextDef.portal=!0}}}
assocDef=[];if(contextDef['repeat-control'].match(/copy-/)){pStart=contextDef['repeat-control'].indexOf('copy-');copyTerm=contextDef['repeat-control'].substr(pStart+5);if((pStart=copyTerm.search(/\s/))>-1){copyTerm=copyTerm.substr(0,pStart)}
assocContexts=copyTerm.split(',');for(i=0;i<assocContexts.length;i++){def=IMLibContextPool.getContextDef(assocContexts[i]);if(def.relation[0]['foreign-key']){assocDef.push({name:def.name,field:def.relation[0]['foreign-key'],value:keyValueCapt})}}}
INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.db_copy_async({name:contextDef.name,conditions:[{field:contextDef.key,operator:'=',value:keyValueCapt}],associated:assocDef.length>0?assocDef:null},(function(){var contextDefCapt=contextDef;var contextObjCapt2=contextObjCapt;var completeTaskCapt=completeTask;return function(result){var restore,conditions,sameOriginContexts;var newId=result.newRecordKeyValue;if(newId>-1){restore=INTERMediator.additionalCondition;INTERMediator.startFrom=0;if(contextDefCapt.records<=1){conditions=INTERMediator.additionalCondition;conditions[contextDefCapt.name]={field:contextDefCapt.key,value:newId};INTERMediator.additionalCondition=conditions;IMLibLocalContext.archive()}
INTERMediator_DBAdapter.unregister();INTERMediator.constructMain(contextObjCapt2);sameOriginContexts=IMLibContextPool.getContextsWithSameOrigin(contextObjCapt2);for(i=0;i<sameOriginContexts.length;i++){INTERMediator.constructMain(sameOriginContexts[i],null)}
INTERMediator.additionalCondition=restore}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();completeTaskCapt();INTERMediatorLog.flushMessage()}})(),completeTask)}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-43')}}})())},deleteButton:function(currentContext,keyField,keyValue,isConfirm){'use strict';var dialogMessage;if(isConfirm){dialogMessage=INTERMediatorOnPage.getMessages()[1025];if(!window.confirm(dialogMessage)){return}}
IMLibQueue.setTask((function(){var currentContextCapt=currentContext;var keyFieldCapt=keyField;var keyValueCapt=keyValue;return function(completeTask){var i,parentKeyValue,deleteSuccessProc,targetRepeaters;INTERMediatorOnPage.showProgress();try{INTERMediatorOnPage.retrieveAuthInfo();deleteSuccessProc=(function(){var currentContextCapt2=currentContextCapt;var completeTaskCapt=completeTask;var keying=keyFieldCapt+'='+keyValueCapt;return function(){if(currentContextCapt2.relation===!0){INTERMediator.pagedAllCount--;if(INTERMediator.pagedAllCount-INTERMediator.startFrom<1){INTERMediator.startFrom=INTERMediator.startFrom-INTERMediator.pagedSize;if(INTERMediator.startFrom<0){INTERMediator.startFrom=0}}
if(INTERMediator.pagedAllCount>=INTERMediator.pagedSize){INTERMediator.construct()}}
IMLibPageNavigation.navigationSetup();targetRepeaters=currentContextCapt2.binding[keying]._im_repeater;for(i=0;i<targetRepeaters.length;i++){IMLibContextPool.removeRecordFromPool(targetRepeaters[i].id)}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();completeTaskCapt();INTERMediatorLog.flushMessage()}})();if(currentContextCapt.isPortal){if(currentContextCapt.potalContainingRecordKV===null){parentKeyValue=Object.keys(currentContextCapt.foreignValue);parentKeyValue[1]=currentContextCapt.foreignValue[parentKeyValue[0]]}else{parentKeyValue=currentContextCapt.potalContainingRecordKV.split('=')}
INTERMediator_DBAdapter.db_update_async({name:currentContextCapt.parentContext&&currentContextCapt.parentContext.contextName?currentContextCapt.parentContext.contextName:currentContextCapt.sourceName,conditions:[{field:parentKeyValue[0],operator:'=',value:parentKeyValue[1]}],dataset:[{field:INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI'?'deleteRelated':'-delete.related',operator:'=',value:currentContextCapt.contextName+'.'+keyValue}]},deleteSuccessProc,completeTask)}else{INTERMediator_DBAdapter.db_delete_async({name:currentContextCapt.contextName,conditions:[{field:keyFieldCapt,operator:'=',value:keyValueCapt}]},deleteSuccessProc,function(){INTERMediatorLog.setErrorMessage('Delete Error','EXCEPTION-46');completeTask()})}}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication&&!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){IMLibUI.deleteButton(currentContextCapt,keyFieldCapt,keyValueCapt,!1)});return}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-3')}
completeTask()}}})())},insertButton:function(currentObj,keyValue,foreignValues,updateNodes,isConfirm){'use strict';if(isConfirm){if(!window.confirm(INTERMediatorOnPage.getMessages()[1026])){return}}
IMLibQueue.setTask((function(){var currentContext,targetName,isPortal,parentContextName;var keyValueCapt=keyValue;var foreignValuesCapt=foreignValues;var updateNodesCapt=updateNodes;targetName=currentObj.contextName;currentContext=currentObj.getContextDef();isPortal=currentObj.isPortal;if(isPortal){parentContextName=currentObj.sourceName?currentObj.sourceName:null}else{parentContextName=currentObj.parentContext?currentObj.parentContext.contextName:null}
return function(completeTask){var targetRecord,portalField,recordSet,index,targetPortalField,targetPortalValue,existRelated=!1,relatedRecordSet;INTERMediatorOnPage.showProgress();recordSet=[];relatedRecordSet=[];if(foreignValuesCapt){for(index in currentContext.relation){if(currentContext.relation.hasOwnProperty(index)){recordSet.push({field:currentContext.relation[index]['foreign-key'],value:foreignValuesCapt[currentContext.relation[index]['join-field']]})}}}
INTERMediatorOnPage.retrieveAuthInfo();if(isPortal){relatedRecordSet=[];for(index in currentContext['default-values']){if(currentContext['default-values'].hasOwnProperty(index)){relatedRecordSet.push({field:targetName+'::'+currentContext['default-values'][index].field+'.0',value:currentContext['default-values'][index].value})}}
if(relatedRecordSet.length===0){targetPortalValue='';targetRecord=INTERMediator_DBAdapter.db_query({name:targetName,records:1,conditions:[{field:currentContext.key?currentContext.key:INTERMediatorOnPage.defaultKeyName,operator:'=',value:keyValueCapt}]});if(targetRecord.recordset&&targetRecord.recordset[0]&&targetRecord.recordset[0][0]){for(portalField in targetRecord.recordset[0][0]){if(portalField.indexOf(targetName+'::')>-1&&portalField!==targetName+'::'+INTERMediatorOnPage.defaultKeyName){existRelated=!0;targetPortalField=portalField;if(portalField===targetName+'::'+recordSet[0].field){targetPortalValue=recordSet[0].value;break}
if(portalField!==targetName+'::id'&&portalField!==targetName+'::'+recordSet[0].field){break}}}}
if(existRelated===!1){targetRecord=INTERMediator_DBAdapter.db_query({name:targetName,records:0,conditions:[{field:currentContext.key?currentContext.key:INTERMediatorOnPage.defaultKeyName,operator:'=',value:keyValueCapt}]});for(portalField in targetRecord.recordset){if(portalField.indexOf(targetName+'::')>-1&&portalField!==targetName+'::'+INTERMediatorOnPage.defaultKeyName){targetPortalField=portalField;if(portalField===targetName+'::'+recordSet[0].field){targetPortalValue=recordSet[0].value;break}
if(portalField!==targetName+'::id'&&portalField!==targetName+'::'+recordSet[0].field){break}}}}
if(foreignValuesCapt&&recordSet[0]){targetPortalField=targetName+'::'+recordSet[0].field;targetPortalValue=recordSet[0].value}else if(targetPortalField===undefined&&currentContext.relation&&currentContext.relation[0]&&currentContext.relation[0]['join-field']){targetPortalField=targetName+'::'+currentContext.relation[0]['join-field']}
relatedRecordSet.push({field:targetPortalField+'.0',value:targetPortalValue})}
completeTask();if(currentContext.relation&&currentContext.relation[0]&&currentContext.relation[0]['join-field']){INTERMediator_DBAdapter.db_update({name:parentContextName,conditions:[{field:currentContext.relation[0]['join-field'],operator:'=',value:foreignValuesCapt&&foreignValuesCapt.id?foreignValuesCapt.id:keyValueCapt}],dataset:relatedRecordSet});INTERMediator.constructMain()}else{INTERMediatorLog.setErrorMessage('Insert Error (Portal Access Mode)','EXCEPTION-4')}}else{INTERMediator_DBAdapter.db_createRecord_async({name:targetName,dataset:recordSet},(function(){var targetNameCapt=targetName;var currentContextCapt=currentContext;var updateNodesCapt2=updateNodesCapt;var foreignValuesCapt2=foreignValuesCapt;var existRelatedCapt=existRelated;var keyValueCapt2=keyValueCapt;return function(result){var keyField,newRecordId,associatedContext,conditions,createdRecord,i,sameOriginContexts;newRecordId=result.newRecordKeyValue;keyField=currentContextCapt.key?currentContextCapt.key:INTERMediatorOnPage.defaultKeyName;associatedContext=IMLibContextPool.contextFromEnclosureId(updateNodesCapt2);completeTask();if(associatedContext){associatedContext.foreignValue=foreignValuesCapt2;if(currentContextCapt.portal===!0&&existRelatedCapt===!1){conditions=INTERMediator.additionalCondition;conditions[targetNameCapt]={field:keyField,operator:'=',value:keyValueCapt2};INTERMediator.additionalCondition=conditions}
createdRecord=[{}];createdRecord[0][keyField]=newRecordId;INTERMediator.constructMain(associatedContext,result.dbresult);sameOriginContexts=IMLibContextPool.getContextsWithSameOrigin(associatedContext);for(i=0;i<sameOriginContexts.length;i++){INTERMediator.constructMain(sameOriginContexts[i],null)}}
IMLibCalc.recalculation();INTERMediatorOnPage.hideProgress();INTERMediatorLog.flushMessage()}})(),function(){INTERMediatorLog.setErrorMessage('Insert Error','EXCEPTION-4');completeTask()})}}})())},clickPostOnlyButton:function(node){'use strict';var i,j,fieldData,elementInfo,comp,contextCount,selectedContext,contextInfo,validationInfo;var mergedValues,inputNodes,typeAttr,k,messageNode,result,alertmessage;var linkedNodes,namedNodes,index,hasInvalid,isMerged,contextNodes;var targetNode=node.parentNode;while(!INTERMediatorLib.isEnclosure(targetNode,!0)){targetNode=targetNode.parentNode;if(!targetNode){return}}
if(INTERMediatorOnPage.processingBeforePostOnlyContext){if(!INTERMediatorOnPage.processingBeforePostOnlyContext(targetNode)){return}}
contextNodes=[];linkedNodes=[];namedNodes=[];for(i=0;i<targetNode.childNodes.length;i++){seekLinkedElementInThisContext(targetNode.childNodes[i]);seekLinkedElementInAllChildren(targetNode.childNodes[i])}
contextCount={};for(i=0;i<contextNodes.length;i++){elementInfo=INTERMediatorLib.getLinkedElementInfo(contextNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(!contextCount[comp[j]]){contextCount[comp[j]]=0}
contextCount[comp[j]]++}}
if(contextCount.length<1){return}
var maxCount=-100;for(var contextName in contextCount){if(maxCount<contextCount[contextName]){maxCount=contextCount[contextName];selectedContext=contextName;contextInfo=INTERMediatorOnPage.getContextInfo(contextName)}}
alertmessage='';fieldData=[];hasInvalid=!1;for(i=0;i<linkedNodes.length;i++){elementInfo=INTERMediatorLib.getLinkedElementInfo(linkedNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(comp[0]===selectedContext){if(contextInfo.validation){for(index in contextInfo.validation){if(contextInfo.validation.hasOwnProperty(index)){validationInfo=contextInfo.validation[index];if(validationInfo&&validationInfo.field===comp[1]){switch(validationInfo.notify){case 'inline':case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);break}}}}
for(index in contextInfo.validation){if(contextInfo.validation.hasOwnProperty(index)){validationInfo=contextInfo.validation[index];if(validationInfo.field===comp[1]){if(validationInfo){result=Parser.evaluate(validationInfo.rule,{'value':linkedNodes[i].value,'target':linkedNodes[i]});if(!result){hasInvalid=!0;switch(validationInfo.notify){case 'inline':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);messageNode=INTERMediatorLib.createErrorMessageNode('SPAN',validationInfo.message);linkedNodes[i].parentNode.insertBefore(messageNode,linkedNodes[i].nextSibling);break;case 'end-of-sibling':INTERMediatorLib.clearErrorMessage(linkedNodes[i]);messageNode=INTERMediatorLib.createErrorMessageNode('DIV',validationInfo.message);linkedNodes[i].parentNode.appendChild(messageNode);break;default:alertmessage+=validationInfo.message+IMLib.nl_char}
if(INTERMediatorOnPage.doAfterValidationFailure){INTERMediatorOnPage.doAfterValidationFailure(linkedNodes[i])}}}}}}}
if(INTERMediatorLib.isWidgetElement(linkedNodes[i])){fieldData.push({field:comp[1],value:linkedNodes[i]._im_getValue()})}else if(linkedNodes[i].tagName==='SELECT'){fieldData.push({field:comp[1],value:linkedNodes[i].value})}else if(linkedNodes[i].tagName==='TEXTAREA'){fieldData.push({field:comp[1],value:linkedNodes[i].value})}else if(linkedNodes[i].tagName==='INPUT'){if((linkedNodes[i].getAttribute('type')==='radio')||(linkedNodes[i].getAttribute('type')==='checkbox')){if(linkedNodes[i].checked){fieldData.push({field:comp[1],value:linkedNodes[i].value})}}else{fieldData.push({field:comp[1],value:linkedNodes[i].value})}}}}}
for(i=0;i<namedNodes.length;i++){elementInfo=INTERMediatorLib.getNamedInfo(namedNodes[i]);for(j=0;j<elementInfo.length;j++){comp=elementInfo[j].split(INTERMediator.separator);if(comp[0]===selectedContext){mergedValues=[];if(namedNodes[i].tagName==='INPUT'){inputNodes=[namedNodes[i]]}else{inputNodes=namedNodes[i].getElementsByTagName('INPUT')}
for(k=0;k<inputNodes.length;k++){typeAttr=inputNodes[k].getAttribute('type');if(typeAttr==='radio'||typeAttr==='checkbox'){if(inputNodes[k].checked){mergedValues.push(inputNodes[k].value)}}else{mergedValues.push(inputNodes[k].value)}}
if(mergedValues.length>0){isMerged=!1;for(index=0;index<fieldData.length;index++){if(fieldData[index].field===comp[1]){fieldData[index].value+=IMLibUI.mergedFieldSeparator;fieldData[index].value+=mergedValues.join(IMLibUI.mergedFieldSeparator);isMerged=!0}}
if(!isMerged){fieldData.push({field:comp[1],value:mergedValues.join(IMLibUI.mergedFieldSeparator)})}}}}}
if(alertmessage.length>0){window.alert(alertmessage);return}
if(hasInvalid){return}
contextInfo=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',selectedContext);if(INTERMediatorOnPage.modifyPostOnlyContext){contextInfo=INTERMediatorOnPage.modifyPostOnlyContext(contextInfo)}
INTERMediator_DBAdapter.db_createRecord_async({name:selectedContext,dataset:fieldData},function(result){var newNode,parentOfTarget,targetNode=node,thisContext=contextInfo,isSetMsg=!1;INTERMediatorLog.flushMessage();if(INTERMediatorOnPage.processingAfterPostOnlyContext){INTERMediatorOnPage.processingAfterPostOnlyContext(targetNode,result.newRecordKeyValue)}
if(thisContext['post-dismiss-message']){parentOfTarget=targetNode.parentNode;parentOfTarget.removeChild(targetNode);newNode=document.createElement('SPAN');INTERMediatorLib.setClassAttributeToNode(newNode,'IM_POSTMESSAGE');newNode.appendChild(document.createTextNode(thisContext['post-dismiss-message']));parentOfTarget.appendChild(newNode);isSetMsg=!0}
if(thisContext['post-reconstruct']){setTimeout(function(){INTERMediator.construct(!0)},isSetMsg?INTERMediator.waitSecondsAfterPostMessage*1000:0)}
if(thisContext['post-move-url']){setTimeout(function(){location.href=thisContext['post-move-url']},isSetMsg?INTERMediator.waitSecondsAfterPostMessage*1000:0)}},null);function seekLinkedElementInThisContext(node){var children,i;if(node.nodeType===1){if(INTERMediatorLib.isLinkedElement(node)){contextNodes.push(node)}else if(INTERMediatorLib.isWidgetElement(node)){contextNodes.push(node)}else{if(INTERMediatorLib.isEnclosure(node)){return}
children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElementInThisContext(children[i])}}}}
function seekLinkedElementInAllChildren(node){var children,i;if(node.nodeType===1){if(INTERMediatorLib.isNamedElement(node)){namedNodes.push(node)}else if(INTERMediatorLib.isLinkedElement(node)){linkedNodes.push(node)}else if(INTERMediatorLib.isWidgetElement(node)){linkedNodes.push(node)}else{children=node.childNodes;for(i=0;i<children.length;i++){seekLinkedElementInAllChildren(children[i])}}}}},eventUpdateHandler:function(contextName){'use strict';IMLibLocalContext.updateAll();var context=IMLibContextPool.getContextFromName(contextName);INTERMediator.constructMain(context[0])},eventAddOrderHandler:function(e){'use strict';var targetKey,targetSplit,key,itemSplit,extValue;if(e.target){targetKey=e.target.getAttribute('data-im')}else{targetKey=e.srcElement.getAttribute('data-im')}
targetSplit=targetKey.split(':');if(targetSplit[0]!=='_@addorder'||targetSplit.length<3){return}
for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){itemSplit=key.split(':');if(itemSplit.length>3&&itemSplit[0]==='valueofaddorder'&&itemSplit[1]===targetSplit[1]){extValue=IMLibLocalContext.getValue(key);if(extValue){IMLibLocalContext.store[key]++}}}}
IMLibLocalContext.setValue('valueof'+targetKey.substring(2),1);IMLibUI.eventUpdateHandler(targetSplit[1])}};var INTERMediatorLog={debugMode:!1,suppressDebugMessageOnPage:!1,suppressErrorMessageOnPage:!1,errorMessages:[],debugMessages:[],errorMessageByAlert:!1,errorMessageOnAlert:null,setDebugMessage:function(message,level){'use strict';if(level===undefined){level=1}
if(INTERMediatorLog.debugMode>=level){INTERMediatorLog.debugMessages.push(message);if(typeof console!=='undefined'){console.log('INTER-Mediator[DEBUG:%s]: %s',new Date(),message)}}},setErrorMessage:function(ex,moreMessage){'use strict';moreMessage=moreMessage===undefined?'':(' - '+moreMessage);if(INTERMediatorLog.errorMessageByAlert){window.alert(INTERMediatorLog.errorMessageOnAlert===null?(ex+moreMessage):INTERMediatorLog.errorMessageOnAlert)}
if((typeof ex==='string'||ex instanceof String)){INTERMediatorLog.errorMessages.push(ex+moreMessage);if(typeof console!=='undefined'){console.error('INTER-Mediator[ERROR]: %s',ex+moreMessage)}}else{if(ex.message){INTERMediatorLog.errorMessages.push(ex.message+moreMessage);if(typeof console!=='undefined'){console.error('INTER-Mediator[ERROR]: %s',ex.message+moreMessage)}}
if(ex.stack&&typeof console!=='undefined'){console.error(ex.stack)}}},flushMessage:function(){'use strict';var debugNode,title,body,i,j,lines,clearButton,tNode;if(INTERMediatorLog.errorMessageByAlert){INTERMediatorLog.suppressErrorMessageOnPage=!0}
if(!INTERMediatorLog.suppressErrorMessageOnPage&&INTERMediatorLog.errorMessages.length>0){debugNode=document.getElementById('_im_error_panel_4873643897897');if(debugNode===null){debugNode=document.createElement('div');debugNode.setAttribute('id','_im_error_panel_4873643897897');debugNode.style.backgroundColor='#FFDDDD';title=document.createElement('h3');title.appendChild(document.createTextNode('Error Info from INTER-Mediator'));title.appendChild(document.createElement('hr'));debugNode.appendChild(title);body=document.getElementsByTagName('body')[0];body.insertBefore(debugNode,body.firstChild)}
debugNode.appendChild(document.createTextNode('============ERROR MESSAGE on '+new Date()+'============'));debugNode.appendChild(document.createElement('hr'));for(i=0;i<INTERMediatorLog.errorMessages.length;i++){lines=INTERMediatorLog.errorMessages[i].split(IMLib.nl_char);for(j=0;j<lines.length;j++){if(j>0){debugNode.appendChild(document.createElement('br'))}
debugNode.appendChild(document.createTextNode(lines[j]))}
debugNode.appendChild(document.createElement('hr'))}}
if(!INTERMediatorLog.suppressDebugMessageOnPage&&INTERMediatorLog.debugMode&&INTERMediatorLog.debugMessages.length>0){debugNode=document.getElementById('_im_debug_panel_4873643897897');if(debugNode===null){debugNode=document.createElement('div');debugNode.setAttribute('id','_im_debug_panel_4873643897897');debugNode.style.backgroundColor='#DDDDDD';clearButton=document.createElement('button');clearButton.setAttribute('title','clear');clearButton.id='_im_debug_panel_4873643897897_button';IMLibMouseEventDispatch.setExecute(clearButton.id,function(){var target;target=document.getElementById('_im_debug_panel_4873643897897');target.parentNode.removeChild(target)});tNode=document.createTextNode('clear');clearButton.appendChild(tNode);title=document.createElement('h3');title.appendChild(document.createTextNode('Debug Info from INTER-Mediator'));title.appendChild(clearButton);title.appendChild(document.createElement('hr'));debugNode.appendChild(title);body=document.getElementsByTagName('body')[0];if(body){if(body.firstChild){body.insertBefore(debugNode,body.firstChild)}else{body.appendChild(debugNode)}}}
debugNode.appendChild(document.createTextNode('============DEBUG INFO on '+new Date()+'============ '));if(INTERMediatorOnPage.getEditorPath()){var aLink=document.createElement('a');aLink.setAttribute('href',INTERMediatorOnPage.getEditorPath());aLink.appendChild(document.createTextNode('Definition File Editor'));debugNode.appendChild(aLink)}
debugNode.appendChild(document.createElement('hr'));for(i=0;i<INTERMediatorLog.debugMessages.length;i++){lines=INTERMediatorLog.debugMessages[i].split(IMLib.nl_char);for(j=0;j<lines.length;j++){if(j>0){debugNode.appendChild(document.createElement('br'))}
debugNode.appendChild(document.createTextNode(lines[j]))}
debugNode.appendChild(document.createElement('hr'))}}
INTERMediatorLog.errorMessages=[];INTERMediatorLog.debugMessages=[]}};var INTERMediator_DBAdapter={eliminateDuplicatedConditions:!1,debugMessage:!1,generate_authParams:function(){'use strict';var authParams='',shaObj,hmacValue,encrypted;var encrypt=new JSEncrypt();if(INTERMediatorOnPage.authUser.length>0){authParams='&clientid='+encodeURIComponent(INTERMediatorOnPage.clientId);authParams+='&authuser='+encodeURIComponent(INTERMediatorOnPage.authUser);if(INTERMediatorOnPage.isNativeAuth||INTERMediatorOnPage.isLDAP){if(INTERMediatorOnPage.authCryptedPassword&&INTERMediatorOnPage.authChallenge){encrypt.setPublicKey(INTERMediatorOnPage.publickey);encrypted=encrypt.encrypt(INTERMediatorOnPage.authCryptedPassword.substr(0,220)+IMLib.nl_char+INTERMediatorOnPage.authChallenge);authParams+='&cresponse='+encodeURIComponent(encrypted+IMLib.nl_char+INTERMediatorOnPage.authCryptedPassword.substr(220));if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('generate_authParams/authCryptedPassword='+INTERMediatorOnPage.authCryptedPassword);INTERMediatorLog.setDebugMessage('generate_authParams/authChallenge='+INTERMediatorOnPage.authChallenge)}}else{authParams+='&cresponse=dummy'}}
if(INTERMediatorOnPage.authHashedPassword&&INTERMediatorOnPage.authChallenge){shaObj=new jsSHA(INTERMediatorOnPage.authHashedPassword,'ASCII');hmacValue=shaObj.getHMAC(INTERMediatorOnPage.authChallenge,'ASCII','SHA-256','HEX');authParams+='&response='+encodeURIComponent(hmacValue);if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('generate_authParams/authHashedPassword='+INTERMediatorOnPage.authHashedPassword);INTERMediatorLog.setDebugMessage('generate_authParams/authChallenge='+INTERMediatorOnPage.authChallenge)}}else{authParams+='&response=dummy'}}
authParams+='&notifyid=';authParams+=encodeURIComponent(INTERMediatorOnPage.clientNotificationIdentifier());authParams+=('&pusher='+(INTERMediator.pusherAvailable?'yes':''));return authParams},store_challenge:function(challenge){'use strict';if(challenge!==null){INTERMediatorOnPage.authChallenge=challenge.substr(0,24);INTERMediatorOnPage.authUserHexSalt=challenge.substr(24,32);INTERMediatorOnPage.authUserSalt=String.fromCharCode(parseInt(challenge.substr(24,2),16),parseInt(challenge.substr(26,2),16),parseInt(challenge.substr(28,2),16),parseInt(challenge.substr(30,2),16));if(INTERMediator_DBAdapter.debugMessage){INTERMediatorLog.setDebugMessage('store_challenge/authChallenge='+INTERMediatorOnPage.authChallenge);INTERMediatorLog.setDebugMessage('store_challenge/authUserHexSalt='+INTERMediatorOnPage.authUserHexSalt);INTERMediatorLog.setDebugMessage('store_challenge/authUserSalt='+INTERMediatorOnPage.authUserSalt)}}},logging_comAction:function(debugMessageNumber,appPath,accessURL,authParams){'use strict';INTERMediatorLog.setDebugMessage(INTERMediatorOnPage.getMessages()[debugMessageNumber]+'Accessing:'+decodeURI(appPath)+', Parameters:'+decodeURI(accessURL+authParams))},logging_comResult:function(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken){'use strict';var responseTextTrancated;if(INTERMediatorLog.debugMode>1){if(myRequest.responseText.length>1000){responseTextTrancated=myRequest.responseText.substr(0,1000)+' ...[trancated]'}else{responseTextTrancated=myRequest.responseText}
INTERMediatorLog.setDebugMessage('myRequest.responseText='+responseTextTrancated);INTERMediatorLog.setDebugMessage('Return: resultCount='+resultCount+', dbresult='+INTERMediatorLib.objectToString(dbresult)+IMLib.nl_char+'Return: requireAuth='+requireAuth+', challenge='+challenge+', clientid='+clientid+IMLib.nl_char+'Return: newRecordKeyValue='+newRecordKeyValue+', changePasswordResult='+changePasswordResult+', mediatoken='+mediatoken)}},server_access:function(accessURL,debugMessageNumber,errorMessageNumber){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,totalCount=null,challenge=null,clientid=null,requireAuth=!1,myRequest=null,changePasswordResult=null,mediatoken=null,appPath,authParams,jsonObject,i,notifySupport=!1,useNull=!1,registeredID='';appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();INTERMediator_DBAdapter.logging_comAction(debugMessageNumber,appPath,accessURL,authParams);INTERMediatorOnPage.notifySupport=notifySupport;try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!1,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');myRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');myRequest.setRequestHeader('X-Requested-With','XMLHttpRequest');myRequest.setRequestHeader('X-From',location.href);myRequest.send(accessURL+authParams);jsonObject=JSON.parse(myRequest.responseText);resultCount=jsonObject.resultCount?jsonObject.resultCount:0;totalCount=jsonObject.totalCount?jsonObject.totalCount:null;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;notifySupport=jsonObject.notifySupport;for(i=0;i<jsonObject.errorMessages.length;i++){INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
useNull=jsonObject.usenull;registeredID=jsonObject.hasOwnProperty('registeredid')?jsonObject.registeredid:'';INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(INTERMediatorOnPage.isLDAP===!0&&INTERMediatorOnPage.authUserHexSalt!==INTERMediatorOnPage.authHashedPassword.substr(-8,8)){if(accessURL!=='access=challenge'){requireAuth=!0}}}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorMessageNumber],[e,myRequest.responseText]))}
if(accessURL.indexOf('access=changepassword&newpass=')===0){return changePasswordResult}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();throw new Error('_im_requath_request_')}
if(!accessURL.match(/access=challenge/)){INTERMediatorOnPage.authCount=0}
INTERMediatorOnPage.storeCredentialsToCookieOrStorage();INTERMediatorOnPage.notifySupport=notifySupport;return{dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull}},server_access_async:function(accessURL,debugMessageNumber,errorMessageNumber,successProc,failedProc,authAgainProc){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,totalCount=null,challenge=null,clientid=null,requireAuth=!1,myRequest=null,changePasswordResult=null,mediatoken=null,appPath,authParams,jsonObject,i,notifySupport=!1,useNull=!1,registeredID='';appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();INTERMediator_DBAdapter.logging_comAction(debugMessageNumber,appPath,accessURL,authParams);INTERMediatorOnPage.notifySupport=notifySupport;try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!0,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');myRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');myRequest.setRequestHeader('X-Requested-With','XMLHttpRequest');myRequest.setRequestHeader('X-From',location.href);myRequest.onreadystatechange=function(){switch(myRequest.readyState){case 0:break;case 1:break;case 2:break;case 3:break;case 4:try{jsonObject=JSON.parse(myRequest.responseText)}catch(ex){INTERMediatorLog.setErrorMessage('Communication Error: '+myRequest.responseText);if(failedProc){failedProc(new Error('_im_communication_error_'))}
return}
resultCount=jsonObject.resultCount?jsonObject.resultCount:0;totalCount=jsonObject.totalCount?jsonObject.totalCount:null;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;notifySupport=jsonObject.notifySupport;for(i=0;i<jsonObject.errorMessages.length;i++){INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
useNull=jsonObject.usenull;registeredID=jsonObject.hasOwnProperty('registeredid')?jsonObject.registeredid:'';if(jsonObject.errorMessages.length>0){INTERMediatorLog.setErrorMessage('Communication Error: '+jsonObject.errorMessages);if(failedProc){failedProc()}
throw 'Communication Error'}
INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(INTERMediatorOnPage.isLDAP===!0&&INTERMediatorOnPage.authUserHexSalt!==INTERMediatorOnPage.authHashedPassword.substr(-8,8)){if(accessURL!=='access=challenge'){requireAuth=!0}}
if(accessURL.indexOf('access=changepassword&newpass=')===0){if(successProc){successProc({dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull})}
return}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();if(authAgainProc){authAgainProc(myRequest)}
return}
if(!accessURL.match(/access=challenge/)){INTERMediatorOnPage.authCount=0}
INTERMediatorOnPage.storeCredentialsToCookieOrStorage();INTERMediatorOnPage.notifySupport=notifySupport;if(successProc){successProc({dbresult:dbresult,resultCount:resultCount,totalCount:totalCount,newRecordKeyValue:newRecordKeyValue,newPasswordResult:changePasswordResult,registeredId:registeredID,nullAcceptable:useNull})}
break}};myRequest.send(accessURL+authParams)}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorMessageNumber],[e,myRequest.responseText]));if(failedProc){failedProc()}}},changePassword:function(username,oldpassword,newpassword){'use strict';var challengeResult,params,result,messageNode;var encrypt=new JSEncrypt();if(username&&oldpassword){INTERMediatorOnPage.authUser=username;if(username!==''&&(INTERMediatorOnPage.authChallenge===null||INTERMediatorOnPage.authChallenge.length<24)){INTERMediatorOnPage.authHashedPassword='need-hash-pls';challengeResult=INTERMediator_DBAdapter.getChallenge();if(!challengeResult){messageNode=document.getElementById('_im_newpass_message');if(messageNode){INTERMediatorLib.removeChildNodes(messageNode);messageNode.appendChild(document.createTextNode(INTERMediatorLib.getInsertedStringFromErrorNumber(2008)))}else{window.alert(INTERMediatorLib.getInsertedStringFromErrorNumber(2008))}
INTERMediatorLog.flushMessage();return}}
INTERMediatorOnPage.authHashedPassword=SHA1(oldpassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt}else{INTERMediatorOnPage.retrieveAuthInfo()}
params='access=changepassword&newpass='+INTERMediatorLib.generatePasswordHash(newpassword);try{result=INTERMediator_DBAdapter.server_access(params,1029,1030);if(result){encrypt.setPublicKey(INTERMediatorOnPage.publickey);INTERMediatorOnPage.authCryptedPassword=encrypt.encrypt(newpassword);INTERMediatorOnPage.authHashedPassword=SHA1(newpassword+INTERMediatorOnPage.authUserSalt)+INTERMediatorOnPage.authUserHexSalt;INTERMediatorOnPage.storeCredentialsToCookieOrStorage()}}catch(e){return!1}
return result},getChallenge:function(){'use strict';try{this.server_access('access=challenge',1027,1028)}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-19')}}
if(INTERMediatorOnPage.authChallenge===null){return!1}
return!0},uploadFile:function(parameters,uploadingFile,doItOnFinish,exceptionProc){'use strict';var myRequest=null,appPath,authParams,accessURL,i;appPath=INTERMediatorOnPage.getEntryPath();authParams=INTERMediator_DBAdapter.generate_authParams();accessURL='access=uploadfile'+parameters;INTERMediator_DBAdapter.logging_comAction(1031,appPath,accessURL,authParams);try{myRequest=new XMLHttpRequest();myRequest.open('POST',appPath,!0,INTERMediatorOnPage.httpuser,INTERMediatorOnPage.httppasswd);myRequest.setRequestHeader('charset','utf-8');var params=(accessURL+authParams).split('&');var fd=new FormData();for(i=0;i<params.length;i++){var valueset=params[i].split('=');fd.append(valueset[0],decodeURIComponent(valueset[1]))}
fd.append('_im_uploadfile',uploadingFile.content);myRequest.onreadystatechange=function(){switch(myRequest.readyState){case 3:break;case 4:INTERMediator_DBAdapter.uploadFileAfterSucceed(myRequest,doItOnFinish,exceptionProc,!1);break}};myRequest.send(fd)}catch(e){INTERMediatorLog.setErrorMessage(e,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1032],[e,myRequest.responseText]));exceptionProc()}},uploadFileAfterSucceed:function(myRequest,doItOnFinish,exceptionProc,isErrorDialog){'use strict';var newRecordKeyValue='',dbresult='',resultCount=0,challenge=null,clientid=null,requireAuth=!1,changePasswordResult=null,mediatoken=null,jsonObject,i,returnValue=!0;try{jsonObject=JSON.parse(myRequest.responseText)}catch(ex){INTERMediatorLog.setErrorMessage(ex,INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[1032],['','']));INTERMediatorLog.flushMessage();exceptionProc();return!1}
resultCount=jsonObject.resultCount?jsonObject.resultCount:0;dbresult=jsonObject.dbresult?jsonObject.dbresult:null;requireAuth=jsonObject.requireAuth?jsonObject.requireAuth:!1;challenge=jsonObject.challenge?jsonObject.challenge:null;clientid=jsonObject.clientid?jsonObject.clientid:null;newRecordKeyValue=jsonObject.newRecordKeyValue?jsonObject.newRecordKeyValue:'';changePasswordResult=jsonObject.changePasswordResult?jsonObject.changePasswordResult:null;mediatoken=jsonObject.mediatoken?jsonObject.mediatoken:null;for(i=0;i<jsonObject.errorMessages.length;i++){if(isErrorDialog){window.alert(jsonObject.errorMessages[i])}else{INTERMediatorLog.setErrorMessage(jsonObject.errorMessages[i])}
returnValue=!1}
for(i=0;i<jsonObject.debugMessages.length;i++){INTERMediatorLog.setDebugMessage(jsonObject.debugMessages[i])}
INTERMediator_DBAdapter.logging_comResult(myRequest,resultCount,dbresult,requireAuth,challenge,clientid,newRecordKeyValue,changePasswordResult,mediatoken);INTERMediator_DBAdapter.store_challenge(challenge);if(clientid!==null){INTERMediatorOnPage.clientId=clientid}
if(mediatoken!==null){INTERMediatorOnPage.mediaToken=mediatoken}
if(requireAuth){INTERMediatorLog.setDebugMessage('Authentication Required, user/password panel should be show.');INTERMediatorOnPage.clearCredentials();exceptionProc()}
INTERMediatorOnPage.authCount=0;INTERMediatorOnPage.storeCredentialsToCookieOrStorage();doItOnFinish(dbresult);return returnValue},db_query:function(args){'use strict';var params,returnValue,result,contextDef;if(!INTERMediator_DBAdapter.db_queryChecking(args)){return}
params=INTERMediator_DBAdapter.db_queryParameters(args);returnValue={};try{result=this.server_access(params,1012,1004);returnValue.recordset=result.dbresult;returnValue.totalCount=result.resultCount;returnValue.count=0;returnValue.registeredId=result.registeredId;returnValue.nullAcceptable=result.nullAcceptable;returnValue.count=result.dbresult?Object.keys(result.dbresult).length:0;contextDef=INTERMediatorLib.getNamedObject(INTERMediatorOnPage.getDataSources(),'name',args.name);if(!contextDef.relation&&args.paging&&Boolean(args.paging)===!0){INTERMediator.pagedAllCount=parseInt(result.resultCount,10);if(result.totalCount){INTERMediator.totalRecordCount=parseInt(result.totalCount,10)}}
if((args.paging!==null)&&(Boolean(args.paging)===!0)){INTERMediator.pagination=!0;if(!(Number(args.records)>=Number(INTERMediator.pagedSize)&&Number(INTERMediator.pagedSize)>0)){INTERMediator.pagedSize=parseInt(args.records,10)}}}catch(ex){if(ex.message==='_im_requath_request_'){throw ex}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-17')}
returnValue.recordset=null;returnValue.totalCount=0;returnValue.count=0;returnValue.registeredid=null;returnValue.nullAcceptable=null}
return returnValue},db_queryWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_query(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_queryWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-16')}}
completion(returnValue)},db_query_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_queryChecking(args)){return}
params=INTERMediator_DBAdapter.db_queryParameters(args);try{this.server_access_async(params,1012,1004,(function(){var contextDef;var contextName=args.name;var recordsNumber=Number(args.records);var succesProcCapt=successProc;return function(result){result.count=result.dbresult?Object.keys(result.dbresult).length:0;contextDef=IMLibContextPool.getContextDef(contextName);if(!contextDef.relation&&args.paging&&Boolean(args.paging)===!0){INTERMediator.pagedAllCount=parseInt(result.resultCount,10);if(result.totalCount){INTERMediator.totalRecordCount=parseInt(result.totalCount,10)}}
if((args.paging!==null)&&(Boolean(args.paging)===!0)){INTERMediator.pagination=!0;if(!(recordsNumber>=Number(INTERMediator.pagedSize)&&Number(INTERMediator.pagedSize)>0)){INTERMediator.pagedSize=parseInt(recordsNumber,10)}}
succesProcCapt(result)}})(),failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_query_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}catch(ex){INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-17')}},db_queryChecking:function(args){'use strict';var noError=!0;if(args.name===null||args.name===''){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1005));noError=!1}
return noError},db_queryParameters:function(args){'use strict';var i,index,params,counter,extCount,criteriaObject,sortkeyObject,extCountSort,recordLimit=10000000,conditions,conditionSign,modifyConditions,orderFields,key,keyParams,value,fields,operator,orderedKeys,removeIndice=[];if(args.records===null){params='access=read&name='+encodeURIComponent(args.name)}else{if(parseInt(args.records,10)===0&&(INTERMediatorOnPage.dbClassName==='DB_FileMaker_FX'||INTERMediatorOnPage.dbClassName==='DB_FileMaker_DataAPI')){params='access=describe&name='+encodeURIComponent(args.name)}else{params='access=read&name='+encodeURIComponent(args.name)}
if(Boolean(args.uselimit)===!0&&parseInt(args.records,10)>=INTERMediator.pagedSize&&parseInt(INTERMediator.pagedSize,10)>0){recordLimit=INTERMediator.pagedSize}else{recordLimit=args.records}}
if(args.primaryKeyOnly){params+='&pkeyonly=true'}
if(args.fields){for(i=0;i<args.fields.length;i++){params+='&field_'+i+'='+encodeURIComponent(args.fields[i])}}
counter=0;if(args.parentkeyvalue){for(index in args.parentkeyvalue){if(args.parentkeyvalue.hasOwnProperty(index)){params+='&foreign'+counter+'field='+encodeURIComponent(index);params+='&foreign'+counter+'value='+encodeURIComponent(args.parentkeyvalue[index]);counter++}}}
if(args.useoffset&&INTERMediator.startFrom!==null){params+='&start='+encodeURIComponent(INTERMediator.startFrom)}
extCount=0;conditions=[];while(args.conditions&&args.conditions[extCount]){conditionSign=args.conditions[extCount].field+'#'+args.conditions[extCount].operator+'#'+args.conditions[extCount].value;if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount;params+='field='+encodeURIComponent(args.conditions[extCount].field);params+='&condition'+extCount;params+='operator='+encodeURIComponent(args.conditions[extCount].operator);params+='&condition'+extCount;params+='value='+encodeURIComponent(args.conditions[extCount].value);conditions.push(conditionSign)}
extCount++}
criteriaObject=INTERMediator.additionalCondition[args.name];if(criteriaObject){if(criteriaObject.field){criteriaObject=[criteriaObject]}
for(index=0;index<criteriaObject.length;index++){if(criteriaObject[index]&&criteriaObject[index].field){if(criteriaObject[index].value||criteriaObject[index].field==='__operation__'){conditionSign=criteriaObject[index].field+'#'+((criteriaObject[index].operator!==undefined)?criteriaObject[index].operator:'')+'#'+((criteriaObject[index].value!==undefined)?criteriaObject[index].value:'');if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount;params+='field='+encodeURIComponent(criteriaObject[index].field);if(criteriaObject[index].operator!==undefined){params+='&condition'+extCount;params+='operator='+encodeURIComponent(criteriaObject[index].operator)}
if(criteriaObject[index].value!==undefined){params+='&condition'+extCount;value=criteriaObject[index].value;if(Array.isArray(value)){value=JSON.stringify(value)}
params+='value='+encodeURIComponent(value)}
if(criteriaObject[index].field!=='__operation__'){conditions.push(conditionSign)}}
extCount++}}
if(criteriaObject[index]&&criteriaObject[index].onetime){removeIndice.push=index}}
if(removeIndice.length>0){modifyConditions=[];for(index=0;index<criteriaObject.length;index++){if(!(index in removeIndice)){modifyConditions.push(criteriaObject[index])}}
INTERMediator.additionalCondition[args.name]=modifyConditions;IMLibLocalContext.archive()}}
extCountSort=0;sortkeyObject=INTERMediator.additionalSortKey[args.name];if(sortkeyObject){if(sortkeyObject.field){sortkeyObject=[sortkeyObject]}
for(index=0;index<sortkeyObject.length;index++){params+='&sortkey'+extCountSort;params+='field='+encodeURIComponent(sortkeyObject[index].field);params+='&sortkey'+extCountSort;params+='direction='+encodeURIComponent(sortkeyObject[index].direction);extCountSort++}}
orderFields={};for(key in IMLibLocalContext.store){if(IMLibLocalContext.store.hasOwnProperty(key)){value=String(IMLibLocalContext.store[key]);keyParams=key.split(':');if(keyParams&&keyParams.length>1&&keyParams[1].trim()===args.name&&value.length>0){if(keyParams[0].trim()==='condition'&&keyParams.length>=4){fields=keyParams[2].split(',');operator=keyParams[3].trim();if(fields.length>1){params+='&condition'+extCount+'field=__operation__';params+='&condition'+extCount+'operator=ex';extCount++}
for(index=0;index<fields.length;index++){conditionSign=fields[index].trim()+'#'+operator+'#'+value;if(!INTERMediator_DBAdapter.eliminateDuplicatedConditions||conditions.indexOf(conditionSign)<0){params+='&condition'+extCount+'field='+encodeURIComponent(fields[index].replace(';;','::').trim());params+='&condition'+extCount+'operator='+encodeURIComponent(operator);params+='&condition'+extCount+'value='+encodeURIComponent(value);conditions.push(conditionSign)}
extCount++}}else if(keyParams[0].trim()==='valueofaddorder'&&keyParams.length>=4){orderFields[parseInt(value)]=[keyParams[2].trim(),keyParams[3].trim()]}}}}
params+='&records='+encodeURIComponent(recordLimit);orderedKeys=Object.keys(orderFields);for(i=0;i<orderedKeys.length;i++){params+='&sortkey'+extCountSort+'field='+encodeURIComponent(orderFields[orderedKeys[i]][0]);params+='&sortkey'+extCountSort+'direction='+encodeURIComponent(orderFields[orderedKeys[i]][1]);extCountSort++}
return params},db_update:function(args){'use strict';var params,result;if(!INTERMediator_DBAdapter.db_updateChecking(args)){return}
params=INTERMediator_DBAdapter.db_updateParameters(args);result=this.server_access(params,1013,1014);return result.dbresult},db_updateWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_update(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_updateWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-15')}}
completion(returnValue)},db_updateChecking:function(args){'use strict';var noError=!0,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1007));noError=!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));noError=!1}
if(args.dataset===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1011));noError=!1}
return noError},db_updateParameters:function(args){'use strict';var params,extCount,counter,index,addedObject;params='access=update&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnUpdate&&INTERMediator.additionalFieldValueOnUpdate[args.name]){addedObject=INTERMediator.additionalFieldValueOnUpdate[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
if(args.conditions){for(extCount=0;extCount<args.conditions.length;extCount++){params+='&condition'+extCount+'field=';params+=encodeURIComponent(args.conditions[extCount].field);params+='&condition'+extCount+'operator=';params+=encodeURIComponent(args.conditions[extCount].operator);if(args.conditions[extCount].value){params+='&condition'+extCount+'value=';params+=encodeURIComponent(args.conditions[extCount].value)}}}
for(extCount=0;extCount<args.dataset.length;extCount++){params+='&field_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].field);if(INTERMediator.isTrident&&INTERMediator.ieVersion===8){params+='&value_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].value.replace(/\n/g,''))}else{params+='&value_'+(counter+extCount)+'='+encodeURIComponent(args.dataset[extCount].value)}}
return params},db_update_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_updateChecking(args)){return}
params=INTERMediator_DBAdapter.db_updateParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1013,1014,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_update_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_delete:function(args){'use strict';var params,result;if(!INTERMediator_DBAdapter.db_deleteChecking(args)){return}
params=INTERMediator_DBAdapter.db_deleteParameters(args);result=this.server_access(params,1017,1015);INTERMediatorLog.flushMessage();return result},db_deleteWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_delete(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_deleteWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-14')}}
completion(returnValue)},db_deleteChecking:function(args){'use strict';var noError=!0,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1019));noError=!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));noError=!1}
if(args.conditions===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1020));noError=!1}
return noError},db_deleteParameters:function(args){'use strict';var params,i,counter,index,addedObject;params='access=delete&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnDelete&&INTERMediator.additionalFieldValueOnDelete[args.name]){addedObject=INTERMediator.additionalFieldValueOnDelete[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
for(i=0;i<args.conditions.length;i++){params+='&condition'+i+'field='+encodeURIComponent(args.conditions[i].field);params+='&condition'+i+'operator='+encodeURIComponent(args.conditions[i].operator);params+='&condition'+i+'value='+encodeURIComponent(args.conditions[i].value)}
return params},db_delete_async:function(args,successProc,failedProc){'use strict';var params;if(!INTERMediator_DBAdapter.db_deleteChecking(args)){return}
params=INTERMediator_DBAdapter.db_deleteParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1017,1015,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_delete_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_createRecord:function(args){'use strict';var params,result;params=INTERMediator_DBAdapter.db_createParameters(args);if(params){result=INTERMediator_DBAdapter.server_access(params,1018,1016);INTERMediatorLog.flushMessage();return{newKeyValue:result.newRecordKeyValue,recordset:result.dbresult}}
return!1},db_createRecordWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_createRecord(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_createRecordWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-13')}}
if(completion){completion(returnValue.newKeyValue)}},db_createRecord_async:function(args,successProc,failedProc){'use strict';var params=INTERMediator_DBAdapter.db_createParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1018,1016,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_createRecord_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_createParameters:function(args){'use strict';var params,i,index,addedObject,counter,targetKey,ds,key,contextDef;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1021));return!1}
contextDef=IMLibContextPool.getContextDef(args.name);if(!contextDef.key){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1045,[args.name]));return!1}
ds=INTERMediatorOnPage.getDataSources();targetKey=null;for(key in ds){if(ds.hasOwnProperty(key)&&ds[key].name===args.name){targetKey=key;break}}
if(targetKey===null){INTERMediatorLog.setErrorMessage('no targetname :'+args.name);return!1}
params='access=create&name='+encodeURIComponent(args.name);counter=0;if(INTERMediator.additionalFieldValueOnNewRecord&&INTERMediator.additionalFieldValueOnNewRecord[args.name]){addedObject=INTERMediator.additionalFieldValueOnNewRecord[args.name];if(addedObject.field){addedObject=[addedObject]}
for(index in addedObject){if(addedObject.hasOwnProperty(index)){var oneDefinition=addedObject[index];params+='&field_'+counter+'='+encodeURIComponent(oneDefinition.field);params+='&value_'+counter+'='+encodeURIComponent(oneDefinition.value);counter++}}}
for(i=0;i<args.dataset.length;i++){params+='&field_'+counter+'='+encodeURIComponent(args.dataset[i].field);params+='&value_'+counter+'='+encodeURIComponent(args.dataset[i].value);counter++}
return params},db_copy:function(args){'use strict';var params,result;params=INTERMediator_DBAdapter.db_copyParameters(args);if(params){result=INTERMediator_DBAdapter.server_access(params,1017,1015);INTERMediatorLog.flushMessage();return{newKeyValue:result.newRecordKeyValue,recordset:result.dbresult}}
return!1},db_copyWithAuth:function(args,completion){'use strict';var returnValue=!1;INTERMediatorOnPage.retrieveAuthInfo();try{returnValue=INTERMediator_DBAdapter.db_copy(args)}catch(ex){if(ex.message==='_im_requath_request_'){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(function(){returnValue=INTERMediator_DBAdapter.db_copyWithAuth(args,completion)});return}}}else{INTERMediatorLog.setErrorMessage(ex,'EXCEPTION-14')}}
completion(returnValue)},db_copy_async:function(args,successProc,failedProc){'use strict';var params=INTERMediator_DBAdapter.db_copyParameters(args);if(params){INTERMediatorOnPage.retrieveAuthInfo();INTERMediator_DBAdapter.server_access_async(params,1017,1015,successProc,failedProc,INTERMediator_DBAdapter.createExceptionFunc(1016,(function(){var argsCapt=args;var succesProcCapt=successProc;var failedProcCapt=failedProc;return function(){INTERMediator_DBAdapter.db_copy_async(argsCapt,succesProcCapt,failedProcCapt)}})()))}},db_copyParameters:function(args){'use strict';var noError=!0,params,i;if(args.name===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1019));noError=!1}
if(args.conditions===null){INTERMediatorLog.setErrorMessage(INTERMediatorLib.getInsertedStringFromErrorNumber(1020));noError=!1}
if(!noError){return!1}
params='access=copy&name='+encodeURIComponent(args.name);for(i=0;i<args.conditions.length;i++){params+='&condition'+i+'field='+encodeURIComponent(args.conditions[i].field);params+='&condition'+i+'operator='+encodeURIComponent(args.conditions[i].operator);params+='&condition'+i+'value='+encodeURIComponent(args.conditions[i].value)}
if(args.associated){for(i=0;i<args.associated.length;i++){params+='&assoc'+i+'='+encodeURIComponent(args.associated[i].name);params+='&asfield'+i+'='+encodeURIComponent(args.associated[i].field);params+='&asvalue'+i+'='+encodeURIComponent(args.associated[i].value)}}
return params},createExceptionFunc:function(errMessageNumber,AuthProc){'use strict';var errorNumCapt=errMessageNumber;return function(myRequest){if(INTERMediatorOnPage.requireAuthentication){if(!INTERMediatorOnPage.isComplementAuthData()){INTERMediatorOnPage.clearCredentials();INTERMediatorOnPage.authenticating(AuthProc)}}else{INTERMediatorLog.setErrorMessage('Communication Error',INTERMediatorLib.getInsertedString(INTERMediatorOnPage.getMessages()[errorNumCapt],['Communication Error',myRequest.responseText]))}}},unregister:function(entityPkInfo){'use strict';var result=null,params;if(INTERMediatorOnPage.clientNotificationKey){var appKey=INTERMediatorOnPage.clientNotificationKey();if(appKey&&appKey!=='_im_key_isnt_supplied'){params='access=unregister';if(entityPkInfo){params+='&pks='+encodeURIComponent(JSON.stringify(entityPkInfo))}
result=this.server_access(params,1018,1016);return result}}}};var IMLibQueue={tasks:[],isExecute:!1,dataStore:{},dsLabel:0,readyTo:!1,getNewLabel:function(){'use strict';IMLibQueue.dsLabel++;return IMLibQueue.dsLabel},getDataStore:function(label,key){'use strict';if(!IMLibQueue.dataStore[label]){IMLibQueue.dataStore[label]={}}
return IMLibQueue.dataStore[label][key]},setDataStore:function(label,key,value){'use strict';if(!IMLibQueue.dataStore[label]){IMLibQueue.dataStore[label]={}}
IMLibQueue.dataStore[label][key]=value},setTask:function(aTask,startHere){'use strict';if(startHere){IMLibQueue.isExecute=!0;aTask(function(){});IMLibQueue.isExecute=!1}else{IMLibQueue.tasks.push(aTask);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}}},setPriorTask:function(aTask){'use strict';IMLibQueue.tasks.unshift(aTask);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},setSequentialTasks:function(tasksArray){'use strict';Array.prototype.push.apply(IMLibQueue.tasks,tasksArray);if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},setSequentialPriorTasks:function(tasksArray){'use strict';Array.prototype.push.apply(tasksArray,IMLibQueue.tasks);IMLibQueue.tasks=tasksArray;if(!IMLibQueue.readyTo){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}},startNextTask:function(){'use strict';if(IMLibQueue.isExecute){if(IMLibQueue.tasks.length>0){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}
return}
if(IMLibQueue.tasks.length>0){var aTask=IMLibQueue.tasks.shift();IMLibQueue.isExecute=!0;IMLibQueue.readyTo=!1;aTask(function(){IMLibQueue.isExecute=!1;if(IMLibQueue.tasks.length>0){setTimeout(IMLibQueue.startNextTask,0);IMLibQueue.readyTo=!0}})}}};var IMLibChangeEventDispatch;var IMLibKeyDownEventDispatch;var IMLibKeyUpEventDispatch;var IMLibInputEventDispatch;var IMLibMouseEventDispatch;var IMLibBlurEventDispatch;function IMLibEventDispatch(){'use strict';this.dispatchTable={};this.dispatchTableTarget={}}
IMLibEventDispatch.prototype.clearAll=function(){'use strict';this.dispatchTable={};this.dispatchTableTarget={}};IMLibEventDispatch.prototype.setExecute=function(idValue,exec){'use strict';if(idValue&&exec){this.dispatchTable[idValue]=exec}};IMLibEventDispatch.prototype.setTargetExecute=function(targetValue,exec){'use strict';if(targetValue&&exec){this.dispatchTableTarget[targetValue]=exec}};IMLibEventDispatch.prototype.setExecuteByCode=function(idValue,keyCode,exec){'use strict';if(idValue&&keyCode){if(!this.dispatchTable[idValue]){this.dispatchTable[idValue]={}}
this.dispatchTable[idValue][keyCode]=exec}};var IMLibEventResponder={touchEventCancel:!1,isSetup:!1,setup:function(){'use strict';var body;if(IMLibEventResponder.isSetup){return}
IMLibEventResponder.isSetup=!0;IMLibChangeEventDispatch=new IMLibEventDispatch();IMLibKeyDownEventDispatch=new IMLibEventDispatch();IMLibKeyUpEventDispatch=new IMLibEventDispatch();IMLibMouseEventDispatch=new IMLibEventDispatch();IMLibBlurEventDispatch=new IMLibEventDispatch();IMLibInputEventDispatch=new IMLibEventDispatch();body=document.getElementsByTagName('BODY')[0];INTERMediatorLib.addEvent(body,'change',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibChangeEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'blur',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibBlurEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'input',function(e){var event=e?e:window.event;if(!event){return}
var target=event.target;if(!target){target=event.srcElement;if(!target){return}}
var idValue=target.id;if(!idValue){return}
var executable=IMLibInputEventDispatch.dispatchTable[idValue];if(!executable){return}
executable(idValue)});INTERMediatorLib.addEvent(body,'keydown',function(e){var event,target,idValue,keyCode;event=e?e:window.event;if(!event){return}
keyCode=(window.event)?e.which:e.keyCode;target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
if(!IMLibKeyDownEventDispatch.dispatchTable[idValue]){return}
var executable=IMLibKeyDownEventDispatch.dispatchTable[idValue][keyCode];if(!executable){return}
executable(event)});INTERMediatorLib.addEvent(body,'keyup',function(e){var event,charCode,target,idValue;event=e?e:window.event;if(event.charCode){charCode=event.charCode}else{charCode=event.keyCode}
if(!event){return}
target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
if(!IMLibKeyUpEventDispatch.dispatchTable[idValue]){return}
var executable=IMLibKeyUpEventDispatch.dispatchTable[idValue][charCode];if(!executable){return}
executable(event)});INTERMediatorLib.addEvent(body,'click',function(e){var event,target,idValue,executable,targetDefs,i,nodeInfo,value;event=e?e:window.event;if(!event){return}
target=event.target;if(!target){target=event.srcElement;if(!target){return}}
idValue=target.id;if(!idValue){return}
executable=IMLibMouseEventDispatch.dispatchTable[idValue];if(executable){executable(event);return}
targetDefs=INTERMediatorLib.getLinkedElementInfo(target);for(i=0;i<targetDefs.length;i++){executable=IMLibMouseEventDispatch.dispatchTableTarget[targetDefs[i]];if(executable){nodeInfo=INTERMediatorLib.getNodeInfoArray(targetDefs[i]);if(nodeInfo.target){value=target.getAttribute(nodeInfo.target)}else{value=IMLibElement.getValueFromIMNode(target)}
executable(value,target);return}}})}};INTERMediator.propertyIETridentSetup();INTERMediator.propertyW3CUserAgentSetup();if(INTERMediator.isIE&&INTERMediator.ieVersion<9){INTERMediator.startFrom=0;INTERMediator.pagedSize=0;INTERMediator.pagination=!1;INTERMediator.additionalCondition={};INTERMediator.additionalSortKey={};INTERMediator.recordLimit={};IMLibCalc.regexpForSeparator=INTERMediator.separator}else{Object.defineProperty(INTERMediator,'startFrom',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_startFrom',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_startFrom',value)}});Object.defineProperty(INTERMediator,'pagedSize',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_pagedSize',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_pagedSize',value)}});Object.defineProperty(INTERMediator,'pagination',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_pagination',0)},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_pagination',value)}});Object.defineProperty(INTERMediator,'additionalCondition',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_additionalCondition',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_additionalCondition',value)}});Object.defineProperty(INTERMediator,'additionalSortKey',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_additionalSortKey',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_additionalSortKey',value)}});Object.defineProperty(INTERMediator,'recordLimit',{get:function(){'use strict';return INTERMediator.getLocalProperty('_im_recordLimit',{})},set:function(value){'use strict';INTERMediator.setLocalProperty('_im_recordLimit',value)}});Object.defineProperty(IMLibCalc,'regexpForSeparator',{get:function(){'use strict';if(INTERMediator){return new RegExp(INTERMediator.separator)}
return new RegExp('@')}})}
if(!INTERMediator.additionalCondition){INTERMediator.additionalCondition={}}
if(!INTERMediator.additionalSortKey){INTERMediator.additionalSortKey={}}
INTERMediatorLib.addEvent(window,'beforeunload',function(){if(IMLibQueue.tasks.length>0){var confirmationMessage='Some tasks are unfinished.';var ev=(e||window.event);ev.returnValue=confirmationMessage;return confirmationMessage}else{return undefined}});INTERMediatorLib.addEvent(window,'unload',function(){'use strict';INTERMediator_DBAdapter.unregister()});INTERMediatorLib.addEvent(window,'load',function(){'use strict';var key,errorNode;if(INTERMediatorOnPage.initLocalContext){for(key in INTERMediatorOnPage.initLocalContext){if(INTERMediatorOnPage.initLocalContext.hasOwnProperty(key)){IMLibLocalContext.setValue(key,INTERMediatorOnPage.initLocalContext[key],!0)}}}
errorNode=document.getElementById(INTERMediatorOnPage.nonSupportMessageId);if(INTERMediatorOnPage.isAutoConstruct){if(errorNode){if(INTERMediatorOnPage.INTERMediatorCheckBrowser(errorNode)){INTERMediator.construct(!0)}}else{INTERMediator.construct(!0)}}});

function SHA1(s){function U(a,b,c){while(0<c--)a.push(b)}function L(a,b){return(a<<b)|(a>>>(32-b))}function P(a,b,c){return a^b^c}function A(a,b){var c=(b&0xFFFF)+(a&0xFFFF),d=(b>>>16)+(a>>>16)+(c>>>16);return((d&0xFFFF)<<16)|(c&0xFFFF)}var B="0123456789abcdef";return(function(a){var c=[],d=a.length*4,e;for(var i=0;i<d;i++){e=a[i>>2]>>((3-(i%4))*8);c.push(B.charAt((e>>4)&0xF)+B.charAt(e&0xF))}return c.join('')}((function(a,b){var c,d,e,f,g,h=a.length,v=0x67452301,w=0xefcdab89,x=0x98badcfe,y=0x10325476,z=0xc3d2e1f0,M=[];U(M,0x5a827999,20);U(M,0x6ed9eba1,20);U(M,0x8f1bbcdc,20);U(M,0xca62c1d6,20);a[b>>5]|=0x80<<(24-(b%32));a[(((b+65)>>9)<<4)+15]=b;for(var i=0;i<h;i+=16){c=v;d=w;e=x;f=y;g=z;for(var j=0,O=[];j<80;j++){O[j]=j<16?a[j+i]:L(O[j-3]^O[j-8]^O[j-14]^O[j-16],1);var k=(function(a,b,c,d,e){var f=(e&0xFFFF)+(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF),g=(e>>>16)+(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(f>>>16);return((g&0xFFFF)<<16)|(f&0xFFFF)})(j<20?(function(t,a,b){return(t&a)^(~t&b)}(d,e,f)):j<40?P(d,e,f):j<60?(function(t,a,b){return(t&a)^(t&b)^(a&b)}(d,e,f)):P(d,e,f),g,M[j],O[j],L(c,5));g=f;f=e;e=L(d,30);d=c;c=k}v=A(v,c);w=A(w,d);x=A(x,e);y=A(y,f);z=A(z,g)}return[v,w,x,y,z]}((function(t){var a=[],b=255,c=t.length*8;for(var i=0;i<c;i+=8){a[i>>5]|=(t.charCodeAt(i/8)&b)<<(24-(i%32))}return a}(s)).slice(),s.length*8))))};
(function(){var charSize=8,b64pad="",hexCase=0,str2binb=function(a){var b=[],mask=(1<<charSize)-1,length=a.length*charSize,i;for(i=0;i<length;i+=charSize){b[i>>5]|=(a.charCodeAt(i/charSize)&mask)<<(32-charSize-(i%32))}return b},hex2binb=function(a){var b=[],length=a.length,i,num;for(i=0;i<length;i+=2){num=parseInt(a.substr(i,2),16);if(!isNaN(num)){b[i>>3]|=num<<(24-(4*(i%8)))}else{return"INVALID HEX STRING"}}return b},binb2hex=function(a){var b=(hexCase)?"0123456789ABCDEF":"0123456789abcdef",str="",length=a.length*4,i,srcByte;for(i=0;i<length;i+=1){srcByte=a[i>>2]>>((3-(i%4))*8);str+=b.charAt((srcByte>>4)&0xF)+b.charAt(srcByte&0xF)}return str},binb2b64=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+"0123456789+/",str="",length=a.length*4,i,j,triplet;for(i=0;i<length;i+=3){triplet=(((a[i>>2]>>8*(3-i%4))&0xFF)<<16)|(((a[i+1>>2]>>8*(3-(i+1)%4))&0xFF)<<8)|((a[i+2>>2]>>8*(3-(i+2)%4))&0xFF);for(j=0;j<4;j+=1){if(i*8+j*6<=a.length*32){str+=b.charAt((triplet>>6*(3-j))&0x3F)}else{str+=b64pad}}}return str},rotr=function(x,n){return(x>>>n)|(x<<(32-n))},shr=function(x,n){return x>>>n},ch=function(x,y,z){return(x&y)^(~x&z)},maj=function(x,y,z){return(x&y)^(x&z)^(y&z)},sigma0=function(x){return rotr(x,2)^rotr(x,13)^rotr(x,22)},sigma1=function(x){return rotr(x,6)^rotr(x,11)^rotr(x,25)},gamma0=function(x){return rotr(x,7)^rotr(x,18)^shr(x,3)},gamma1=function(x){return rotr(x,17)^rotr(x,19)^shr(x,10)},safeAdd_2=function(x,y){var a=(x&0xFFFF)+(y&0xFFFF),msw=(x>>>16)+(y>>>16)+(a>>>16);return((msw&0xFFFF)<<16)|(a&0xFFFF)},safeAdd_4=function(a,b,c,d){var e=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF),msw=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16);return((msw&0xFFFF)<<16)|(e&0xFFFF)},safeAdd_5=function(a,b,c,d,e){var f=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF),msw=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16)+(f>>>16);return((msw&0xFFFF)<<16)|(f&0xFFFF)},coreSHA2=function(j,k,l){var a,b,c,d,e,f,g,h,T1,T2,H,lengthPosition,i,t,K,W=[],appendedMessageLength;if(l==="SHA-224"||l==="SHA-256"){lengthPosition=(((k+65)>>9)<<4)+15;K=[0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B,0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01,0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7,0xC19BF174,0xE49B69C1,0xEFBE4786,0x0FC19DC6,0x240CA1CC,0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152,0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147,0x06CA6351,0x14292967,0x27B70A85,0x2E1B2138,0x4D2C6DFC,0x53380D13,0x650A7354,0x766A0ABB,0x81C2C92E,0x92722C85,0xA2BFE8A1,0xA81A664B,0xC24B8B70,0xC76C51A3,0xD192E819,0xD6990624,0xF40E3585,0x106AA070,0x19A4C116,0x1E376C08,0x2748774C,0x34B0BCB5,0x391C0CB3,0x4ED8AA4A,0x5B9CCA4F,0x682E6FF3,0x748F82EE,0x78A5636F,0x84C87814,0x8CC70208,0x90BEFFFA,0xA4506CEB,0xBEF9A3F7,0xC67178F2];if(l==="SHA-224"){H=[0xc1059ed8,0x367cd507,0x3070dd17,0xf70e5939,0xffc00b31,0x68581511,0x64f98fa7,0xbefa4fa4]}else{H=[0x6A09E667,0xBB67AE85,0x3C6EF372,0xA54FF53A,0x510E527F,0x9B05688C,0x1F83D9AB,0x5BE0CD19]}}j[k>>5]|=0x80<<(24-k%32);j[lengthPosition]=k;appendedMessageLength=j.length;for(i=0;i<appendedMessageLength;i+=16){a=H[0];b=H[1];c=H[2];d=H[3];e=H[4];f=H[5];g=H[6];h=H[7];for(t=0;t<64;t+=1){if(t<16){W[t]=j[t+i]}else{W[t]=safeAdd_4(gamma1(W[t-2]),W[t-7],gamma0(W[t-15]),W[t-16])}T1=safeAdd_5(h,sigma1(e),ch(e,f,g),K[t],W[t]);T2=safeAdd_2(sigma0(a),maj(a,b,c));h=g;g=f;f=e;e=safeAdd_2(d,T1);d=c;c=b;b=a;a=safeAdd_2(T1,T2)}H[0]=safeAdd_2(a,H[0]);H[1]=safeAdd_2(b,H[1]);H[2]=safeAdd_2(c,H[2]);H[3]=safeAdd_2(d,H[3]);H[4]=safeAdd_2(e,H[4]);H[5]=safeAdd_2(f,H[5]);H[6]=safeAdd_2(g,H[6]);H[7]=safeAdd_2(h,H[7])}switch(l){case"SHA-224":return[H[0],H[1],H[2],H[3],H[4],H[5],H[6]];case"SHA-256":return H;default:return[]}},jsSHA=function(a,b){this.sha224=null;this.sha256=null;this.strBinLen=null;this.strToHash=null;if("HEX"===b){if(0!==(a.length%2)){return"TEXT MUST BE IN BYTE INCREMENTS"}this.strBinLen=a.length*4;this.strToHash=hex2binb(a)}else if(("ASCII"===b)||('undefined'===typeof(b))){this.strBinLen=a.length*charSize;this.strToHash=str2binb(a)}else{return"UNKNOWN TEXT INPUT TYPE"}};jsSHA.prototype={getHash:function(a,b){var c=null,message=this.strToHash.slice();switch(b){case"HEX":c=binb2hex;break;case"B64":c=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}switch(a){case"SHA-224":if(null===this.sha224){this.sha224=coreSHA2(message,this.strBinLen,a)}return c(this.sha224);case"SHA-256":if(null===this.sha256){this.sha256=coreSHA2(message,this.strBinLen,a)}return c(this.sha256);default:return"HASH NOT RECOGNIZED"}},getHMAC:function(a,b,c,d){var e,keyToUse,i,retVal,keyBinLen,hashBitSize,keyWithIPad=[],keyWithOPad=[];switch(d){case"HEX":e=binb2hex;break;case"B64":e=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}switch(c){case"SHA-224":hashBitSize=224;break;case"SHA-256":hashBitSize=256;break;default:return"HASH NOT RECOGNIZED"}if("HEX"===b){if(0!==(a.length%2)){return"KEY MUST BE IN BYTE INCREMENTS"}keyToUse=hex2binb(a);keyBinLen=a.length*4}else if("ASCII"===b){keyToUse=str2binb(a);keyBinLen=a.length*charSize}else{return"UNKNOWN KEY INPUT TYPE"}if(64<(keyBinLen/8)){keyToUse=coreSHA2(keyToUse,keyBinLen,c);keyToUse[15]&=0xFFFFFF00}else if(64>(keyBinLen/8)){keyToUse[15]&=0xFFFFFF00}for(i=0;i<=15;i+=1){keyWithIPad[i]=keyToUse[i]^0x36363636;keyWithOPad[i]=keyToUse[i]^0x5C5C5C5C}retVal=coreSHA2(keyWithIPad.concat(this.strToHash),512+this.strBinLen,c);retVal=coreSHA2(keyWithOPad.concat(retVal),512+hashBitSize,c);return(e(retVal))}};window.jsSHA=jsSHA}());


/*! JSEncrypt v2.3.0 | https://npmcdn.com/jsencrypt@2.3.0/LICENSE.txt */
var JSEncryptExports={};!function(t){function e(t,e,i){null!=t&&("number"==typeof t?this.fromNumber(t,e,i):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function i(){return new e(null)}function r(t,e,i,r,s,n){for(;--n>=0;){var o=e*this[t++]+i[r]+s;s=Math.floor(o/67108864),i[r++]=67108863&o}return s}function s(t,e,i,r,s,n){for(var o=32767&e,h=e>>15;--n>=0;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;a=o*a+((32767&c)<<15)+i[r]+(1073741823&s),s=(a>>>30)+(c>>>15)+h*u+(s>>>30),i[r++]=1073741823&a}return s}function n(t,e,i,r,s,n){for(var o=16383&e,h=e>>14;--n>=0;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;a=o*a+((16383&c)<<14)+i[r]+s,s=(a>>28)+(c>>14)+h*u,i[r++]=268435455&a}return s}function o(t){return Be.charAt(t)}function h(t,e){var i=Ke[t.charCodeAt(e)];return null==i?-1:i}function a(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function u(t){this.t=1,this.s=0>t?-1:0,t>0?this[0]=t:-1>t?this[0]=t+this.DV:this.t=0}function c(t){var e=i();return e.fromInt(t),e}function f(t,i){var r;if(16==i)r=4;else if(8==i)r=3;else if(256==i)r=8;else if(2==i)r=1;else if(32==i)r=5;else{if(4!=i)return void this.fromRadix(t,i);r=2}this.t=0,this.s=0;for(var s=t.length,n=!1,o=0;--s>=0;){var a=8==r?255&t[s]:h(t,s);0>a?"-"==t.charAt(s)&&(n=!0):(n=!1,0==o?this[this.t++]=a:o+r>this.DB?(this[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this[this.t++]=a>>this.DB-o):this[this.t-1]|=a<<o,o+=r,o>=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),n&&e.ZERO.subTo(this,this)}function p(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function l(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<<e)-1,s=!1,n="",h=this.t,a=this.DB-h*this.DB%e;if(h-- >0)for(a<this.DB&&(i=this[h]>>a)>0&&(s=!0,n=o(i));h>=0;)e>a?(i=(this[h]&(1<<a)-1)<<e-a,i|=this[--h]>>(a+=this.DB-e)):(i=this[h]>>(a-=e)&r,0>=a&&(a+=this.DB,--h)),i>0&&(s=!0),s&&(n+=o(i));return s?n:"0"}function d(){var t=i();return e.ZERO.subTo(this,t),t}function g(){return this.s<0?this.negate():this}function m(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(e=i-t.t,0!=e)return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0}function y(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function b(){return this.t<=0?0:this.DB*(this.t-1)+y(this[this.t-1]^this.s&this.DM)}function T(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s}function S(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s}function R(t,e){var i,r=t%this.DB,s=this.DB-r,n=(1<<s)-1,o=Math.floor(t/this.DB),h=this.s<<r&this.DM;for(i=this.t-1;i>=0;--i)e[i+o+1]=this[i]>>s|h,h=(this[i]&n)<<r;for(i=o-1;i>=0;--i)e[i]=0;e[o]=h,e.t=this.t+o+1,e.s=this.s,e.clamp()}function E(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)return void(e.t=0);var r=t%this.DB,s=this.DB-r,n=(1<<r)-1;e[0]=this[i]>>r;for(var o=i+1;o<this.t;++o)e[o-i-1]|=(this[o]&n)<<s,e[o-i]=this[o]>>r;r>0&&(e[this.t-i-1]|=(this.s&n)<<s),e.t=this.t-i,e.clamp()}function D(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);s>i;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r-=t[i],e[i++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=0>r?-1:0,-1>r?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()}function w(t,i){var r=this.abs(),s=t.abs(),n=r.t;for(i.t=n+s.t;--n>=0;)i[n]=0;for(n=0;n<s.t;++n)i[n+r.t]=r.am(0,s[n],i,n,0,r.t);i.s=0,i.clamp(),this.s!=t.s&&e.ZERO.subTo(i,i)}function x(t){for(var e=this.abs(),i=t.t=2*e.t;--i>=0;)t[i]=0;for(i=0;i<e.t-1;++i){var r=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,r,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()}function B(t,r,s){var n=t.abs();if(!(n.t<=0)){var o=this.abs();if(o.t<n.t)return null!=r&&r.fromInt(0),void(null!=s&&this.copyTo(s));null==s&&(s=i());var h=i(),a=this.s,u=t.s,c=this.DB-y(n[n.t-1]);c>0?(n.lShiftTo(c,h),o.lShiftTo(c,s)):(n.copyTo(h),o.copyTo(s));var f=h.t,p=h[f-1];if(0!=p){var l=p*(1<<this.F1)+(f>1?h[f-2]>>this.F2:0),d=this.FV/l,g=(1<<this.F1)/l,m=1<<this.F2,v=s.t,b=v-f,T=null==r?i():r;for(h.dlShiftTo(b,T),s.compareTo(T)>=0&&(s[s.t++]=1,s.subTo(T,s)),e.ONE.dlShiftTo(f,T),T.subTo(h,h);h.t<f;)h[h.t++]=0;for(;--b>=0;){var S=s[--v]==p?this.DM:Math.floor(s[v]*d+(s[v-1]+m)*g);if((s[v]+=h.am(0,S,s,b,0,f))<S)for(h.dlShiftTo(b,T),s.subTo(T,s);s[v]<--S;)s.subTo(T,s)}null!=r&&(s.drShiftTo(f,r),a!=u&&e.ZERO.subTo(r,r)),s.t=f,s.clamp(),c>0&&s.rShiftTo(c,s),0>a&&e.ZERO.subTo(s,s)}}}function K(t){var r=i();return this.abs().divRemTo(t,null,r),this.s<0&&r.compareTo(e.ZERO)>0&&t.subTo(r,r),r}function A(t){this.m=t}function U(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function O(t){return t}function V(t){t.divRemTo(this.m,null,t)}function J(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function N(t,e){t.squareTo(e),this.reduce(e)}function I(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return e=e*(2-(15&t)*e)&15,e=e*(2-(255&t)*e)&255,e=e*(2-((65535&t)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function P(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function M(t){var r=i();return t.abs().dlShiftTo(this.m.t,r),r.divRemTo(this.m,null,r),t.s<0&&r.compareTo(e.ZERO)>0&&this.m.subTo(r,r),r}function L(t){var e=i();return t.copyTo(e),this.reduce(e),e}function q(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=32767&t[e],r=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(i=e+this.m.t,t[i]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function C(t,e){t.squareTo(e),this.reduce(e)}function H(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function j(){return 0==(this.t>0?1&this[0]:this.s)}function k(t,r){if(t>4294967295||1>t)return e.ONE;var s=i(),n=i(),o=r.convert(this),h=y(t)-1;for(o.copyTo(s);--h>=0;)if(r.sqrTo(s,n),(t&1<<h)>0)r.mulTo(n,o,s);else{var a=s;s=n,n=a}return r.revert(s)}function F(t,e){var i;return i=256>t||e.isEven()?new A(e):new P(e),this.exp(t,i)}
// Copyright (c) 2005-2009 Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.
function _(){var t=i();return this.copyTo(t),t}function z(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function Z(){return 0==this.t?this.s:this[0]<<24>>24}function G(){return 0==this.t?this.s:this[0]<<16>>16}function $(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function Y(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function W(t){if(null==t&&(t=10),0==this.signum()||2>t||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),s=c(r),n=i(),o=i(),h="";for(this.divRemTo(s,n,o);n.signum()>0;)h=(r+o.intValue()).toString(t).substr(1)+h,n.divRemTo(s,n,o);return o.intValue().toString(t)+h}function Q(t,i){this.fromInt(0),null==i&&(i=10);for(var r=this.chunkSize(i),s=Math.pow(i,r),n=!1,o=0,a=0,u=0;u<t.length;++u){var c=h(t,u);0>c?"-"==t.charAt(u)&&0==this.signum()&&(n=!0):(a=i*a+c,++o>=r&&(this.dMultiply(s),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(i,o)),this.dAddOffset(a,0)),n&&e.ZERO.subTo(this,this)}function X(t,i,r){if("number"==typeof i)if(2>t)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),ht,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(i);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(e.ONE.shiftLeft(t-1),this);else{var s=new Array,n=7&t;s.length=(t>>3)+1,i.nextBytes(s),n>0?s[0]&=(1<<n)-1:s[0]=0,this.fromString(s,256)}}function tt(){var t=this.t,e=new Array;e[0]=this.s;var i,r=this.DB-t*this.DB%8,s=0;if(t-- >0)for(r<this.DB&&(i=this[t]>>r)!=(this.s&this.DM)>>r&&(e[s++]=i|this.s<<this.DB-r);t>=0;)8>r?(i=(this[t]&(1<<r)-1)<<8-r,i|=this[--t]>>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,0>=r&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==s&&(128&this.s)!=(128&i)&&++s,(s>0||i!=this.s)&&(e[s++]=i);return e}function et(t){return 0==this.compareTo(t)}function it(t){return this.compareTo(t)<0?this:t}function rt(t){return this.compareTo(t)>0?this:t}function st(t,e,i){var r,s,n=Math.min(t.t,this.t);for(r=0;n>r;++r)i[r]=e(this[r],t[r]);if(t.t<this.t){for(s=t.s&this.DM,r=n;r<this.t;++r)i[r]=e(this[r],s);i.t=this.t}else{for(s=this.s&this.DM,r=n;r<t.t;++r)i[r]=e(s,t[r]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()}function nt(t,e){return t&e}function ot(t){var e=i();return this.bitwiseTo(t,nt,e),e}function ht(t,e){return t|e}function at(t){var e=i();return this.bitwiseTo(t,ht,e),e}function ut(t,e){return t^e}function ct(t){var e=i();return this.bitwiseTo(t,ut,e),e}function ft(t,e){return t&~e}function pt(t){var e=i();return this.bitwiseTo(t,ft,e),e}function lt(){for(var t=i(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}function dt(t){var e=i();return 0>t?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function gt(t){var e=i();return 0>t?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function mt(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function yt(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+mt(this[t]);return this.s<0?this.t*this.DB:-1}function vt(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function bt(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=vt(this[i]^e);return t}function Tt(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)}function St(t,i){var r=e.ONE.shiftLeft(t);return this.bitwiseTo(r,i,r),r}function Rt(t){return this.changeBit(t,ht)}function Et(t){return this.changeBit(t,ft)}function Dt(t){return this.changeBit(t,ut)}function wt(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);s>i;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r+=t[i],e[i++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=0>r?-1:0,r>0?e[i++]=r:-1>r&&(e[i++]=this.DV+r),e.t=i,e.clamp()}function xt(t){var e=i();return this.addTo(t,e),e}function Bt(t){var e=i();return this.subTo(t,e),e}function Kt(t){var e=i();return this.multiplyTo(t,e),e}function At(){var t=i();return this.squareTo(t),t}function Ut(t){var e=i();return this.divRemTo(t,e,null),e}function Ot(t){var e=i();return this.divRemTo(t,null,e),e}function Vt(t){var e=i(),r=i();return this.divRemTo(t,e,r),new Array(e,r)}function Jt(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function Nt(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function It(){}function Pt(t){return t}function Mt(t,e,i){t.multiplyTo(e,i)}function Lt(t,e){t.squareTo(e)}function qt(t){return this.exp(t,new It)}function Ct(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;var s;for(s=i.t-this.t;s>r;++r)i[r+this.t]=this.am(0,t[r],i,r,0,this.t);for(s=Math.min(t.t,e);s>r;++r)this.am(0,t[r],i,r,0,e-r);i.clamp()}function Ht(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;--r>=0;)i[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)i[this.t+r-e]=this.am(e-r,t[r],i,0,0,this.t+r-e);i.clamp(),i.drShiftTo(1,i)}function jt(t){this.r2=i(),this.q3=i(),e.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function kt(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=i();return t.copyTo(e),this.reduce(e),e}function Ft(t){return t}function _t(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function zt(t,e){t.squareTo(e),this.reduce(e)}function Zt(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function Gt(t,e){var r,s,n=t.bitLength(),o=c(1);if(0>=n)return o;r=18>n?1:48>n?3:144>n?4:768>n?5:6,s=8>n?new A(e):e.isEven()?new jt(e):new P(e);var h=new Array,a=3,u=r-1,f=(1<<r)-1;if(h[1]=s.convert(this),r>1){var p=i();for(s.sqrTo(h[1],p);f>=a;)h[a]=i(),s.mulTo(p,h[a-2],h[a]),a+=2}var l,d,g=t.t-1,m=!0,v=i();for(n=y(t[g])-1;g>=0;){for(n>=u?l=t[g]>>n-u&f:(l=(t[g]&(1<<n+1)-1)<<u-n,g>0&&(l|=t[g-1]>>this.DB+n-u)),a=r;0==(1&l);)l>>=1,--a;if((n-=a)<0&&(n+=this.DB,--g),m)h[l].copyTo(o),m=!1;else{for(;a>1;)s.sqrTo(o,v),s.sqrTo(v,o),a-=2;a>0?s.sqrTo(o,v):(d=o,o=v,v=d),s.mulTo(v,h[l],o)}for(;g>=0&&0==(t[g]&1<<n);)s.sqrTo(o,v),d=o,o=v,v=d,--n<0&&(n=this.DB-1,--g)}return s.revert(o)}function $t(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var r=e;e=i,i=r}var s=e.getLowestSetBit(),n=i.getLowestSetBit();if(0>n)return e;for(n>s&&(n=s),n>0&&(e.rShiftTo(n,e),i.rShiftTo(n,i));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return n>0&&i.lShiftTo(n,i),i}function Yt(t){if(0>=t)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i}function Wt(t){var i=t.isEven();if(this.isEven()&&i||0==t.signum())return e.ZERO;for(var r=t.clone(),s=this.clone(),n=c(1),o=c(0),h=c(0),a=c(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),i?(n.isEven()&&o.isEven()||(n.addTo(this,n),o.subTo(t,o)),n.rShiftTo(1,n)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;s.isEven();)s.rShiftTo(1,s),i?(h.isEven()&&a.isEven()||(h.addTo(this,h),a.subTo(t,a)),h.rShiftTo(1,h)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(s)>=0?(r.subTo(s,r),i&&n.subTo(h,n),o.subTo(a,o)):(s.subTo(r,s),i&&h.subTo(n,h),a.subTo(o,a))}return 0!=s.compareTo(e.ONE)?e.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}function Qt(t){var e,i=this.abs();if(1==i.t&&i[0]<=Ae[Ae.length-1]){for(e=0;e<Ae.length;++e)if(i[0]==Ae[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<Ae.length;){for(var r=Ae[e],s=e+1;s<Ae.length&&Ue>r;)r*=Ae[s++];for(r=i.modInt(r);s>e;)if(r%Ae[e++]==0)return!1}return i.millerRabin(t)}function Xt(t){var r=this.subtract(e.ONE),s=r.getLowestSetBit();if(0>=s)return!1;var n=r.shiftRight(s);t=t+1>>1,t>Ae.length&&(t=Ae.length);for(var o=i(),h=0;t>h;++h){o.fromInt(Ae[Math.floor(Math.random()*Ae.length)]);var a=o.modPow(n,this);if(0!=a.compareTo(e.ONE)&&0!=a.compareTo(r)){for(var u=1;u++<s&&0!=a.compareTo(r);)if(a=a.modPowInt(2,this),0==a.compareTo(e.ONE))return!1;if(0!=a.compareTo(r))return!1}}return!0}function te(){this.i=0,this.j=0,this.S=new Array}function ee(t){var e,i,r;for(e=0;256>e;++e)this.S[e]=e;for(i=0,e=0;256>e;++e)i=i+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[i],this.S[i]=r;this.i=0,this.j=0}function ie(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}function re(){return new te}function se(){if(null==Oe){for(Oe=re();Ne>Je;){var t=Math.floor(65536*Math.random());Ve[Je++]=255&t}for(Oe.init(Ve),Je=0;Je<Ve.length;++Je)Ve[Je]=0;Je=0}return Oe.next()}function ne(t){var e;for(e=0;e<t.length;++e)t[e]=se()}function oe(){}function he(t,i){return new e(t,i)}function ae(t,i){if(i<t.length+11)return console.error("Message too long for RSA"),null;for(var r=new Array,s=t.length-1;s>=0&&i>0;){var n=t.charCodeAt(s--);128>n?r[--i]=n:n>127&&2048>n?(r[--i]=63&n|128,r[--i]=n>>6|192):(r[--i]=63&n|128,r[--i]=n>>6&63|128,r[--i]=n>>12|224)}r[--i]=0;for(var o=new oe,h=new Array;i>2;){for(h[0]=0;0==h[0];)o.nextBytes(h);r[--i]=h[0]}return r[--i]=2,r[--i]=0,new e(r)}function ue(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function ce(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}function fe(t){return t.modPowInt(this.e,this.n)}function pe(t){var e=ae(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var r=i.toString(16);return 0==(1&r.length)?r:"0"+r}function le(t,e){for(var i=t.toByteArray(),r=0;r<i.length&&0==i[r];)++r;if(i.length-r!=e-1||2!=i[r])return null;for(++r;0!=i[r];)if(++r>=i.length)return null;for(var s="";++r<i.length;){var n=255&i[r];128>n?s+=String.fromCharCode(n):n>191&&224>n?(s+=String.fromCharCode((31&n)<<6|63&i[r+1]),++r):(s+=String.fromCharCode((15&n)<<12|(63&i[r+1])<<6|63&i[r+2]),r+=2)}return s}function de(t,e,i){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16),this.d=he(i,16)):console.error("Invalid RSA private key")}function ge(t,e,i,r,s,n,o,h){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16),this.d=he(i,16),this.p=he(r,16),this.q=he(s,16),this.dmp1=he(n,16),this.dmq1=he(o,16),this.coeff=he(h,16)):console.error("Invalid RSA private key")}function me(t,i){var r=new oe,s=t>>1;this.e=parseInt(i,16);for(var n=new e(i,16);;){for(;this.p=new e(t-s,1,r),0!=this.p.subtract(e.ONE).gcd(n).compareTo(e.ONE)||!this.p.isProbablePrime(10););for(;this.q=new e(s,1,r),0!=this.q.subtract(e.ONE).gcd(n).compareTo(e.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var h=this.p.subtract(e.ONE),a=this.q.subtract(e.ONE),u=h.multiply(a);if(0==u.gcd(n).compareTo(e.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(u),this.dmp1=this.d.mod(h),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}function ye(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)}function ve(t){var e=he(t,16),i=this.doPrivate(e);return null==i?null:le(i,this.n.bitLength()+7>>3)}function be(t){var e,i,r="";for(e=0;e+3<=t.length;e+=3)i=parseInt(t.substring(e,e+3),16),r+=Le.charAt(i>>6)+Le.charAt(63&i);for(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),r+=Le.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),r+=Le.charAt(i>>2)+Le.charAt((3&i)<<4));(3&r.length)>0;)r+=qe;return r}function Te(t){var e,i,r="",s=0;for(e=0;e<t.length&&t.charAt(e)!=qe;++e)v=Le.indexOf(t.charAt(e)),v<0||(0==s?(r+=o(v>>2),i=3&v,s=1):1==s?(r+=o(i<<2|v>>4),i=15&v,s=2):2==s?(r+=o(i),r+=o(v>>2),i=3&v,s=3):(r+=o(i<<2|v>>4),r+=o(15&v),s=0));return 1==s&&(r+=o(i<<2)),r}
// Copyright (c) 2005 Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.
var Se,Re=0xdeadbeefcafe,Ee=15715070==(16777215&Re);Ee&&"Microsoft Internet Explorer"==navigator.appName?(e.prototype.am=s,Se=30):Ee&&"Netscape"!=navigator.appName?(e.prototype.am=r,Se=26):(e.prototype.am=n,Se=28),e.prototype.DB=Se,e.prototype.DM=(1<<Se)-1,e.prototype.DV=1<<Se;var De=52;e.prototype.FV=Math.pow(2,De),e.prototype.F1=De-Se,e.prototype.F2=2*Se-De;var we,xe,Be="0123456789abcdefghijklmnopqrstuvwxyz",Ke=new Array;for(we="0".charCodeAt(0),xe=0;9>=xe;++xe)Ke[we++]=xe;for(we="a".charCodeAt(0),xe=10;36>xe;++xe)Ke[we++]=xe;for(we="A".charCodeAt(0),xe=10;36>xe;++xe)Ke[we++]=xe;A.prototype.convert=U,A.prototype.revert=O,A.prototype.reduce=V,A.prototype.mulTo=J,A.prototype.sqrTo=N,P.prototype.convert=M,P.prototype.revert=L,P.prototype.reduce=q,P.prototype.mulTo=H,P.prototype.sqrTo=C,e.prototype.copyTo=a,e.prototype.fromInt=u,e.prototype.fromString=f,e.prototype.clamp=p,e.prototype.dlShiftTo=T,e.prototype.drShiftTo=S,e.prototype.lShiftTo=R,e.prototype.rShiftTo=E,e.prototype.subTo=D,e.prototype.multiplyTo=w,e.prototype.squareTo=x,e.prototype.divRemTo=B,e.prototype.invDigit=I,e.prototype.isEven=j,e.prototype.exp=k,e.prototype.toString=l,e.prototype.negate=d,e.prototype.abs=g,e.prototype.compareTo=m,e.prototype.bitLength=b,e.prototype.mod=K,e.prototype.modPowInt=F,e.ZERO=c(0),e.ONE=c(1),It.prototype.convert=Pt,It.prototype.revert=Pt,It.prototype.mulTo=Mt,It.prototype.sqrTo=Lt,jt.prototype.convert=kt,jt.prototype.revert=Ft,jt.prototype.reduce=_t,jt.prototype.mulTo=Zt,jt.prototype.sqrTo=zt;var Ae=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Ue=(1<<26)/Ae[Ae.length-1];e.prototype.chunkSize=$,e.prototype.toRadix=W,e.prototype.fromRadix=Q,e.prototype.fromNumber=X,e.prototype.bitwiseTo=st,e.prototype.changeBit=St,e.prototype.addTo=wt,e.prototype.dMultiply=Jt,e.prototype.dAddOffset=Nt,e.prototype.multiplyLowerTo=Ct,e.prototype.multiplyUpperTo=Ht,e.prototype.modInt=Yt,e.prototype.millerRabin=Xt,e.prototype.clone=_,e.prototype.intValue=z,e.prototype.byteValue=Z,e.prototype.shortValue=G,e.prototype.signum=Y,e.prototype.toByteArray=tt,e.prototype.equals=et,e.prototype.min=it,e.prototype.max=rt,e.prototype.and=ot,e.prototype.or=at,e.prototype.xor=ct,e.prototype.andNot=pt,e.prototype.not=lt,e.prototype.shiftLeft=dt,e.prototype.shiftRight=gt,e.prototype.getLowestSetBit=yt,e.prototype.bitCount=bt,e.prototype.testBit=Tt,e.prototype.setBit=Rt,e.prototype.clearBit=Et,e.prototype.flipBit=Dt,e.prototype.add=xt,e.prototype.subtract=Bt,e.prototype.multiply=Kt,e.prototype.divide=Ut,e.prototype.remainder=Ot,e.prototype.divideAndRemainder=Vt,e.prototype.modPow=Gt,e.prototype.modInverse=Wt,e.prototype.pow=qt,e.prototype.gcd=$t,e.prototype.isProbablePrime=Qt,e.prototype.square=At,te.prototype.init=ee,te.prototype.next=ie;var Oe,Ve,Je,Ne=256;if(null==Ve){Ve=new Array,Je=0;var Ie;if(window.crypto&&window.crypto.getRandomValues){var Pe=new Uint32Array(256);for(window.crypto.getRandomValues(Pe),Ie=0;Ie<Pe.length;++Ie)Ve[Je++]=255&Pe[Ie]}var Me=function(t){if(this.count=this.count||0,this.count>=256||Je>=Ne)return void(window.removeEventListener?window.removeEventListener("mousemove",Me,!1):window.detachEvent&&window.detachEvent("onmousemove",Me));try{var e=t.x+t.y;Ve[Je++]=255&e,this.count+=1}catch(i){}};window.addEventListener?window.addEventListener("mousemove",Me,!1):window.attachEvent&&window.attachEvent("onmousemove",Me)}oe.prototype.nextBytes=ne,ue.prototype.doPublic=fe,ue.prototype.setPublic=ce,ue.prototype.encrypt=pe,ue.prototype.doPrivate=ye,ue.prototype.setPrivate=de,ue.prototype.setPrivateEx=ge,ue.prototype.generate=me,ue.prototype.decrypt=ve,
// Copyright (c) 2011 Kevin M Burns Jr.
// All Rights Reserved.
// See "LICENSE" for details.
//
// Extension to jsbn which adds facilities for asynchronous RSA key generation
// Primarily created to avoid execution timeout on mobile devices
//
// http://www-cs-students.stanford.edu/~tjw/jsbn/
//
// ---
function(){var t=function(t,r,s){var n=new oe,o=t>>1;this.e=parseInt(r,16);var h=new e(r,16),a=this,u=function(){var r=function(){if(a.p.compareTo(a.q)<=0){var t=a.p;a.p=a.q,a.q=t}var i=a.p.subtract(e.ONE),r=a.q.subtract(e.ONE),n=i.multiply(r);0==n.gcd(h).compareTo(e.ONE)?(a.n=a.p.multiply(a.q),a.d=h.modInverse(n),a.dmp1=a.d.mod(i),a.dmq1=a.d.mod(r),a.coeff=a.q.modInverse(a.p),setTimeout(function(){s()},0)):setTimeout(u,0)},c=function(){a.q=i(),a.q.fromNumberAsync(o,1,n,function(){a.q.subtract(e.ONE).gcda(h,function(t){0==t.compareTo(e.ONE)&&a.q.isProbablePrime(10)?setTimeout(r,0):setTimeout(c,0)})})},f=function(){a.p=i(),a.p.fromNumberAsync(t-o,1,n,function(){a.p.subtract(e.ONE).gcda(h,function(t){0==t.compareTo(e.ONE)&&a.p.isProbablePrime(10)?setTimeout(c,0):setTimeout(f,0)})})};setTimeout(f,0)};setTimeout(u,0)};ue.prototype.generateAsync=t;var r=function(t,e){var i=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(i.compareTo(r)<0){var s=i;i=r,r=s}var n=i.getLowestSetBit(),o=r.getLowestSetBit();if(0>o)return void e(i);o>n&&(o=n),o>0&&(i.rShiftTo(o,i),r.rShiftTo(o,r));var h=function(){(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),i.compareTo(r)>=0?(i.subTo(r,i),i.rShiftTo(1,i)):(r.subTo(i,r),r.rShiftTo(1,r)),i.signum()>0?setTimeout(h,0):(o>0&&r.lShiftTo(o,r),setTimeout(function(){e(r)},0))};setTimeout(h,10)};e.prototype.gcda=r;var s=function(t,i,r,s){if("number"==typeof i)if(2>t)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),ht,this),this.isEven()&&this.dAddOffset(1,0);var n=this,o=function(){n.dAddOffset(2,0),n.bitLength()>t&&n.subTo(e.ONE.shiftLeft(t-1),n),n.isProbablePrime(i)?setTimeout(function(){s()},0):setTimeout(o,0)};setTimeout(o,0)}else{var h=new Array,a=7&t;h.length=(t>>3)+1,i.nextBytes(h),a>0?h[0]&=(1<<a)-1:h[0]=0,this.fromString(h,256)}};e.prototype.fromNumberAsync=s}();var Le="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qe="=",Ce=Ce||{};Ce.env=Ce.env||{};var He=Ce,je=Object.prototype,ke="[object Function]",Fe=["toString","valueOf"];Ce.env.parseUA=function(t){var e,i=function(t){var e=0;return parseFloat(t.replace(/\./g,function(){return 1==e++?"":"."}))},r=navigator,s={ie:0,opera:0,gecko:0,webkit:0,chrome:0,mobile:null,air:0,ipad:0,iphone:0,ipod:0,ios:null,android:0,webos:0,caja:r&&r.cajaVersion,secure:!1,os:null},n=t||navigator&&navigator.userAgent,o=window&&window.location,h=o&&o.href;return s.secure=h&&0===h.toLowerCase().indexOf("https"),n&&(/windows|win32/i.test(n)?s.os="windows":/macintosh/i.test(n)?s.os="macintosh":/rhino/i.test(n)&&(s.os="rhino"),/KHTML/.test(n)&&(s.webkit=1),e=n.match(/AppleWebKit\/([^\s]*)/),e&&e[1]&&(s.webkit=i(e[1]),/ Mobile\//.test(n)?(s.mobile="Apple",e=n.match(/OS ([^\s]*)/),e&&e[1]&&(e=i(e[1].replace("_","."))),s.ios=e,s.ipad=s.ipod=s.iphone=0,e=n.match(/iPad|iPod|iPhone/),e&&e[0]&&(s[e[0].toLowerCase()]=s.ios)):(e=n.match(/NokiaN[^\/]*|Android \d\.\d|webOS\/\d\.\d/),e&&(s.mobile=e[0]),/webOS/.test(n)&&(s.mobile="WebOS",e=n.match(/webOS\/([^\s]*);/),e&&e[1]&&(s.webos=i(e[1]))),/ Android/.test(n)&&(s.mobile="Android",e=n.match(/Android ([^\s]*);/),e&&e[1]&&(s.android=i(e[1])))),e=n.match(/Chrome\/([^\s]*)/),e&&e[1]?s.chrome=i(e[1]):(e=n.match(/AdobeAIR\/([^\s]*)/),e&&(s.air=e[0]))),s.webkit||(e=n.match(/Opera[\s\/]([^\s]*)/),e&&e[1]?(s.opera=i(e[1]),e=n.match(/Version\/([^\s]*)/),e&&e[1]&&(s.opera=i(e[1])),e=n.match(/Opera Mini[^;]*/),e&&(s.mobile=e[0])):(e=n.match(/MSIE\s([^;]*)/),e&&e[1]?s.ie=i(e[1]):(e=n.match(/Gecko\/([^\s]*)/),e&&(s.gecko=1,e=n.match(/rv:([^\s\)]*)/),e&&e[1]&&(s.gecko=i(e[1]))))))),s},Ce.env.ua=Ce.env.parseUA(),Ce.isFunction=function(t){return"function"==typeof t||je.toString.apply(t)===ke},Ce._IEEnumFix=Ce.env.ua.ie?function(t,e){var i,r,s;for(i=0;i<Fe.length;i+=1)r=Fe[i],s=e[r],He.isFunction(s)&&s!=je[r]&&(t[r]=s)}:function(){},Ce.extend=function(t,e,i){if(!e||!t)throw new Error("extend failed, please check that all dependencies are included.");var r,s=function(){};if(s.prototype=e.prototype,t.prototype=new s,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==je.constructor&&(e.prototype.constructor=e),i){for(r in i)He.hasOwnProperty(i,r)&&(t.prototype[r]=i[r]);He._IEEnumFix(t.prototype,i)}},/*
* asn1.js - ASN.1 DER encoder classes
*
* Copyright (c) 2013 Kenji Urushima (kenji.urushima@gmail.com)
*
* This software is licensed under the terms of the MIT License.
* http://kjur.github.com/jsrsasign/license
*
* The above copyright and license notice shall be
* included in all copies or substantial portions of the Software.
*/
/**
* @fileOverview
* @name asn1-1.0.js
* @author Kenji Urushima kenji.urushima@gmail.com
* @version 1.0.2 (2013-May-30)
* @since 2.1
* @license <a href="http://kjur.github.io/jsrsasign/license/">MIT License</a>
*/
"undefined"!=typeof KJUR&&KJUR||(KJUR={}),"undefined"!=typeof KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var i=t.toString(16);if("-"!=i.substr(0,1))i.length%2==1?i="0"+i:i.match(/^[0-7]/)||(i="00"+i);else{var r=i.substr(1),s=r.length;s%2==1?s+=1:i.match(/^[0-7]/)||(s+=2);for(var n="",o=0;s>o;o++)n+="f";var h=new e(n,16),a=h.xor(t).add(e.ONE);i=a.toString(16).replace(/^-/,"")}return i},this.getPEMStringFromHex=function(t,e){var i=CryptoJS.enc.Hex.parse(t),r=CryptoJS.enc.Base64.stringify(i),s=r.replace(/(.{64})/g,"$1\r\n");return s=s.replace(/\r\n$/,""),"-----BEGIN "+e+"-----\r\n"+s+"\r\n-----END "+e+"-----\r\n"}},KJUR.asn1.ASN1Object=function(){var t="";this.getLengthHexFromValue=function(){if("undefined"==typeof this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+t.length+",v="+this.hV;var e=this.hV.length/2,i=e.toString(16);if(i.length%2==1&&(i="0"+i),128>e)return i;var r=i.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);var s=128+r;return s.toString(16)+i},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},KJUR.asn1.DERAbstractString=function(t){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex&&this.setStringHex(t.hex))},Ce.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractTime=function(t){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){utc=t.getTime()+6e4*t.getTimezoneOffset();var e=new Date(utc);return e},this.formatDate=function(t,e){var i=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var n=i(String(r.getMonth()+1),2),o=i(String(r.getDate()),2),h=i(String(r.getHours()),2),a=i(String(r.getMinutes()),2),u=i(String(r.getSeconds()),2);return s+n+o+h+a+u+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setByDateValue=function(t,e,i,r,s,n){var o=new Date(Date.UTC(t,e-1,i,r,s,n,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},Ce.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractStructured=function(t){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,"undefined"!=typeof t&&"undefined"!=typeof t.array&&(this.asn1Array=t.array)},Ce.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object),KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},Ce.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object),KJUR.asn1.DERInteger=function(t){KJUR.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var i=new e(String(t),10);this.setByBigInteger(i)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.bigint?this.setByBigInteger(t.bigint):"undefined"!=typeof t["int"]?this.setByInteger(t["int"]):"undefined"!=typeof t.hex&&this.setValueHex(t.hex))},Ce.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object),KJUR.asn1.DERBitString=function(t){KJUR.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(0>t||t>7)throw"unused bits shall be from 0 to 7: u = "+t;var i="0"+t;this.hTLV=null,this.isModified=!0,this.hV=i+e},this.setByBinaryString=function(t){t=t.replace(/0+$/,"");var e=8-t.length%8;8==e&&(e=0);for(var i=0;e>=i;i++)t+="0";for(var r="",i=0;i<t.length-1;i+=8){var s=t.substr(i,8),n=parseInt(s,2).toString(16);1==n.length&&(n="0"+n),r+=n}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",i=0;i<t.length;i++)e+=1==t[i]?"1":"0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),i=0;t>i;i++)e[i]=!1;return e},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.hex?this.setHexValueIncludingUnusedBits(t.hex):"undefined"!=typeof t.bin?this.setByBinaryString(t.bin):"undefined"!=typeof t.array&&this.setByBooleanArray(t.array))},Ce.extend(KJUR.asn1.DERBitString,KJUR.asn1.ASN1Object),KJUR.asn1.DEROctetString=function(t){KJUR.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Ce.extend(KJUR.asn1.DEROctetString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNull=function(){KJUR.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Ce.extend(KJUR.asn1.DERNull,KJUR.asn1.ASN1Object),KJUR.asn1.DERObjectIdentifier=function(t){var i=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",s=new e(t,10),n=s.toString(2),o=7-n.length%7;7==o&&(o=0);for(var h="",a=0;o>a;a++)h+="0";n=h+n;for(var a=0;a<n.length-1;a+=7){var u=n.substr(a,7);a!=n.length-7&&(u="1"+u),r+=i(parseInt(u,2))}return r};KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var e="",s=t.split("."),n=40*parseInt(s[0])+parseInt(s[1]);e+=i(n),s.splice(0,2);for(var o=0;o<s.length;o++)e+=r(s[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){if("undefined"==typeof KJUR.asn1.x509.OID.name2oidList[t])throw"DERObjectIdentifier oidName undefined: "+t;var e=KJUR.asn1.x509.OID.name2oidList[t];this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.oid?this.setValueOidString(t.oid):"undefined"!=typeof t.hex?this.setValueHex(t.hex):"undefined"!=typeof t.name&&this.setValueName(t.name))},Ce.extend(KJUR.asn1.DERObjectIdentifier,KJUR.asn1.ASN1Object),KJUR.asn1.DERUTF8String=function(t){KJUR.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Ce.extend(KJUR.asn1.DERUTF8String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNumericString=function(t){KJUR.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Ce.extend(KJUR.asn1.DERNumericString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERPrintableString=function(t){KJUR.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Ce.extend(KJUR.asn1.DERPrintableString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERTeletexString=function(t){KJUR.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Ce.extend(KJUR.asn1.DERTeletexString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERIA5String=function(t){KJUR.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Ce.extend(KJUR.asn1.DERIA5String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERUTCTime=function(t){KJUR.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex?this.setStringHex(t.hex):"undefined"!=typeof t.date&&this.setByDate(t.date))},Ce.extend(KJUR.asn1.DERUTCTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERGeneralizedTime=function(t){KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen"),this.hV=stohex(this.s)},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex?this.setStringHex(t.hex):"undefined"!=typeof t.date&&this.setByDate(t.date))},Ce.extend(KJUR.asn1.DERGeneralizedTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERSequence=function(t){KJUR.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t+=i.getEncodedHex()}return this.hV=t,this.hV}},Ce.extend(KJUR.asn1.DERSequence,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERSet=function(t){KJUR.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t.push(i.getEncodedHex())}return t.sort(),this.hV=t.join(""),this.hV}},Ce.extend(KJUR.asn1.DERSet,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERTaggedObject=function(t){KJUR.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,i){this.hT=e,this.isExplicit=t,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.tag&&(this.hT=t.tag),"undefined"!=typeof t.explicit&&(this.isExplicit=t.explicit),"undefined"!=typeof t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},Ce.extend(KJUR.asn1.DERTaggedObject,KJUR.asn1.ASN1Object),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";var e,i={};i.decode=function(i){var r;if(e===t){var s="0123456789ABCDEF",n=" \f\n\r  \u2028\u2029";for(e=[],r=0;16>r;++r)e[s.charAt(r)]=r;for(s=s.toLowerCase(),r=10;16>r;++r)e[s.charAt(r)]=r;for(r=0;r<n.length;++r)e[n.charAt(r)]=-1}var o=[],h=0,a=0;for(r=0;r<i.length;++r){var u=i.charAt(r);if("="==u)break;if(u=e[u],-1!=u){if(u===t)throw"Illegal character at offset "+r;h|=u,++a>=2?(o[o.length]=h,h=0,a=0):h<<=4}}if(a)throw"Hex encoding incomplete: 4 bits missing";return o},window.Hex=i}(),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";var e,i={};i.decode=function(i){var r;if(e===t){var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="= \f\n\r  \u2028\u2029";for(e=[],r=0;64>r;++r)e[s.charAt(r)]=r;for(r=0;r<n.length;++r)e[n.charAt(r)]=-1}var o=[],h=0,a=0;for(r=0;r<i.length;++r){var u=i.charAt(r);if("="==u)break;if(u=e[u],-1!=u){if(u===t)throw"Illegal character at offset "+r;h|=u,++a>=4?(o[o.length]=h>>16,o[o.length]=h>>8&255,o[o.length]=255&h,h=0,a=0):h<<=6}}switch(a){case 1:throw"Base64 encoding incomplete: at least 2 bits missing";case 2:o[o.length]=h>>10;break;case 3:o[o.length]=h>>16,o[o.length]=h>>8&255}return o},i.re=/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,i.unarmor=function(t){var e=i.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw"RegExp out of sync";t=e[2]}return i.decode(t)},window.Base64=i}(),
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
function(t){"use strict";function e(t,i){t instanceof e?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=i)}function i(t,e,i,r,s){this.stream=t,this.header=e,this.length=i,this.tag=r,this.sub=s}var r=100,s="…",n={tag:function(t,e){var i=document.createElement(t);return i.className=e,i},text:function(t){return document.createTextNode(t)}};e.prototype.get=function(e){if(e===t&&(e=this.pos++),e>=this.enc.length)throw"Requesting byte offset "+e+" on a stream of length "+this.enc.length;return this.enc[e]},e.prototype.hexDigits="0123456789ABCDEF",e.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},e.prototype.hexDump=function(t,e,i){for(var r="",s=t;e>s;++s)if(r+=this.hexByte(this.get(s)),i!==!0)switch(15&s){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r},e.prototype.parseStringISO=function(t,e){for(var i="",r=t;e>r;++r)i+=String.fromCharCode(this.get(r));return i},e.prototype.parseStringUTF=function(t,e){for(var i="",r=t;e>r;){var s=this.get(r++);i+=128>s?String.fromCharCode(s):s>191&&224>s?String.fromCharCode((31&s)<<6|63&this.get(r++)):String.fromCharCode((15&s)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return i},e.prototype.parseStringBMP=function(t,e){for(var i="",r=t;e>r;r+=2){var s=this.get(r),n=this.get(r+1);i+=String.fromCharCode((s<<8)+n)}return i},e.prototype.reTime=/^((?:1[89]|2\d)?\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,e.prototype.parseTime=function(t,e){var i=this.parseStringISO(t,e),r=this.reTime.exec(i);return r?(i=r[1]+"-"+r[2]+"-"+r[3]+" "+r[4],r[5]&&(i+=":"+r[5],r[6]&&(i+=":"+r[6],r[7]&&(i+="."+r[7]))),r[8]&&(i+=" UTC","Z"!=r[8]&&(i+=r[8],r[9]&&(i+=":"+r[9]))),i):"Unrecognized time: "+i},e.prototype.parseInteger=function(t,e){var i=e-t;if(i>4){i<<=3;var r=this.get(t);if(0===r)i-=8;else for(;128>r;)r<<=1,--i;return"("+i+" bit)"}for(var s=0,n=t;e>n;++n)s=s<<8|this.get(n);return s},e.prototype.parseBitString=function(t,e){var i=this.get(t),r=(e-t-1<<3)-i,s="("+r+" bit)";if(20>=r){var n=i;s+=" ";for(var o=e-1;o>t;--o){for(var h=this.get(o),a=n;8>a;++a)s+=h>>a&1?"1":"0";n=0}}return s},e.prototype.parseOctetString=function(t,e){var i=e-t,n="("+i+" byte) ";i>r&&(e=t+r);for(var o=t;e>o;++o)n+=this.hexByte(this.get(o));return i>r&&(n+=s),n},e.prototype.parseOID=function(t,e){for(var i="",r=0,s=0,n=t;e>n;++n){var o=this.get(n);if(r=r<<7|127&o,s+=7,!(128&o)){if(""===i){var h=80>r?40>r?0:1:2;i=h+"."+(r-40*h)}else i+="."+(s>=31?"bigint":r);r=s=0}}return i},i.prototype.typeName=function(){if(this.tag===t)return"unknown";var e=this.tag>>6,i=(this.tag>>5&1,31&this.tag);switch(e){case 0:switch(i){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString";default:return"Universal_"+i.toString(16)}case 1:return"Application_"+i.toString(16);case 2:return"["+i+"]";case 3:return"Private_"+i.toString(16)}},i.prototype.reSeemsASCII=/^[ -~]+$/,i.prototype.content=function(){if(this.tag===t)return null;var e=this.tag>>6,i=31&this.tag,n=this.posContent(),o=Math.abs(this.length);if(0!==e){if(null!==this.sub)return"("+this.sub.length+" elem)";var h=this.stream.parseStringISO(n,n+Math.min(o,r));return this.reSeemsASCII.test(h)?h.substring(0,2*r)+(h.length>2*r?s:""):this.stream.parseOctetString(n,n+o)}switch(i){case 1:return 0===this.stream.get(n)?"false":"true";case 2:return this.stream.parseInteger(n,n+o);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(n,n+o);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(n,n+o);case 6:return this.stream.parseOID(n,n+o);case 16:case 17:return"("+this.sub.length+" elem)";case 12:return this.stream.parseStringUTF(n,n+o);case 18:case 19:case 20:case 21:case 22:case 26:return this.stream.parseStringISO(n,n+o);case 30:return this.stream.parseStringBMP(n,n+o);case 23:case 24:return this.stream.parseTime(n,n+o)}return null},i.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},i.prototype.print=function(e){if(e===t&&(e=""),document.writeln(e+this),null!==this.sub){e+=" ";for(var i=0,r=this.sub.length;r>i;++i)this.sub[i].print(e)}},i.prototype.toPrettyString=function(e){e===t&&(e="");var i=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(i+="+"),i+=this.length,32&this.tag?i+=" (constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(i+=" (encapsulates)"),i+="\n",null!==this.sub){e+=" ";for(var r=0,s=this.sub.length;s>r;++r)i+=this.sub[r].toPrettyString(e)}return i},i.prototype.toDOM=function(){var t=n.tag("div","node");t.asn1=this;var e=n.tag("div","head"),i=this.typeName().replace(/_/g," ");e.innerHTML=i;var r=this.content();if(null!==r){r=String(r).replace(/</g,"&lt;");var s=n.tag("span","preview");s.appendChild(n.text(r)),e.appendChild(s)}t.appendChild(e),this.node=t,this.head=e;var o=n.tag("div","value");if(i="Offset: "+this.stream.pos+"<br/>",i+="Length: "+this.header+"+",i+=this.length>=0?this.length:-this.length+" (undefined)",32&this.tag?i+="<br/>(constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(i+="<br/>(encapsulates)"),null!==r&&(i+="<br/>Value:<br/><b>"+r+"</b>","object"==typeof oids&&6==this.tag)){var h=oids[r];h&&(h.d&&(i+="<br/>"+h.d),h.c&&(i+="<br/>"+h.c),h.w&&(i+="<br/>(warning!)"))}o.innerHTML=i,t.appendChild(o);var a=n.tag("div","sub");if(null!==this.sub)for(var u=0,c=this.sub.length;c>u;++u)a.appendChild(this.sub[u].toDOM());return t.appendChild(a),e.onclick=function(){t.className="node collapsed"==t.className?"node":"node collapsed"},t},i.prototype.posStart=function(){return this.stream.pos},i.prototype.posContent=function(){return this.stream.pos+this.header},i.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},i.prototype.fakeHover=function(t){this.node.className+=" hover",t&&(this.head.className+=" hover")},i.prototype.fakeOut=function(t){var e=/ ?hover/;this.node.className=this.node.className.replace(e,""),t&&(this.head.className=this.head.className.replace(e,""))},i.prototype.toHexDOM_sub=function(t,e,i,r,s){if(!(r>=s)){var o=n.tag("span",e);o.appendChild(n.text(i.hexDump(r,s))),t.appendChild(o)}},i.prototype.toHexDOM=function(e){var i=n.tag("span","hex");if(e===t&&(e=i),this.head.hexNode=i,this.head.onmouseover=function(){this.hexNode.className="hexCurrent"},this.head.onmouseout=function(){this.hexNode.className="hex"},i.asn1=this,i.onmouseover=function(){var t=!e.selected;t&&(e.selected=this.asn1,this.className="hexCurrent"),this.asn1.fakeHover(t)},i.onmouseout=function(){var t=e.selected==this.asn1;this.asn1.fakeOut(t),t&&(e.selected=null,this.className="hex")},this.toHexDOM_sub(i,"tag",this.stream,this.posStart(),this.posStart()+1),this.toHexDOM_sub(i,this.length>=0?"dlen":"ulen",this.stream,this.posStart()+1,this.posContent()),null===this.sub)i.appendChild(n.text(this.stream.hexDump(this.posContent(),this.posEnd())));else if(this.sub.length>0){var r=this.sub[0],s=this.sub[this.sub.length-1];this.toHexDOM_sub(i,"intro",this.stream,this.posContent(),r.posStart());for(var o=0,h=this.sub.length;h>o;++o)i.appendChild(this.sub[o].toHexDOM(e));this.toHexDOM_sub(i,"outro",this.stream,s.posEnd(),this.posEnd())}return i},i.prototype.toHexString=function(t){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},i.decodeLength=function(t){var e=t.get(),i=127&e;if(i==e)return i;if(i>3)throw"Length over 24 bits not supported at position "+(t.pos-1);if(0===i)return-1;e=0;for(var r=0;i>r;++r)e=e<<8|t.get();return e},i.hasContent=function(t,r,s){if(32&t)return!0;if(3>t||t>4)return!1;var n=new e(s);3==t&&n.get();var o=n.get();if(o>>6&1)return!1;try{var h=i.decodeLength(n);return n.pos-s.pos+h==r}catch(a){return!1}},i.decode=function(t){t instanceof e||(t=new e(t,0));var r=new e(t),s=t.get(),n=i.decodeLength(t),o=t.pos-r.pos,h=null;if(i.hasContent(s,n,t)){var a=t.pos;if(3==s&&t.get(),h=[],n>=0){for(var u=a+n;t.pos<u;)h[h.length]=i.decode(t);if(t.pos!=u)throw"Content size is not correct for container starting at offset "+a}else try{for(;;){var c=i.decode(t);if(0===c.tag)break;h[h.length]=c}n=a-t.pos}catch(f){throw"Exception while decoding undefined length content: "+f}}else t.pos+=n;return new i(r,o,n,s,h)},i.test=function(){for(var t=[{value:[39],expected:39},{value:[129,201],expected:201},{value:[131,254,220,186],expected:16702650}],r=0,s=t.length;s>r;++r){var n=new e(t[r].value,0),o=i.decodeLength(n);o!=t[r].expected&&document.write("In test["+r+"] expected "+t[r].expected+" got "+o+"\n")}},window.ASN1=i}(),ASN1.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,i=2*this.length;return t.substr(e,i)},ue.prototype.parseKey=function(t){try{var e=0,i=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,s=r.test(t)?Hex.decode(t):Base64.unarmor(t),n=ASN1.decode(s);if(3===n.sub.length&&(n=n.sub[2].sub[0]),9===n.sub.length){e=n.sub[1].getHexStringValue(),this.n=he(e,16),i=n.sub[2].getHexStringValue(),this.e=parseInt(i,16);var o=n.sub[3].getHexStringValue();this.d=he(o,16);var h=n.sub[4].getHexStringValue();this.p=he(h,16);var a=n.sub[5].getHexStringValue();this.q=he(a,16);var u=n.sub[6].getHexStringValue();this.dmp1=he(u,16);var c=n.sub[7].getHexStringValue();this.dmq1=he(c,16);var f=n.sub[8].getHexStringValue();this.coeff=he(f,16)}else{if(2!==n.sub.length)return!1;var p=n.sub[1],l=p.sub[0];e=l.sub[0].getHexStringValue(),this.n=he(e,16),i=l.sub[1].getHexStringValue(),this.e=parseInt(i,16)}return!0}catch(d){return!1}},ue.prototype.getPrivateBaseKey=function(){var t={array:[new KJUR.asn1.DERInteger({"int":0}),new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e}),new KJUR.asn1.DERInteger({bigint:this.d}),new KJUR.asn1.DERInteger({bigint:this.p}),new KJUR.asn1.DERInteger({bigint:this.q}),new KJUR.asn1.DERInteger({bigint:this.dmp1}),new KJUR.asn1.DERInteger({bigint:this.dmq1}),new KJUR.asn1.DERInteger({bigint:this.coeff})]},e=new KJUR.asn1.DERSequence(t);return e.getEncodedHex()},ue.prototype.getPrivateBaseKeyB64=function(){return be(this.getPrivateBaseKey())},ue.prototype.getPublicBaseKey=function(){var t={array:[new KJUR.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new KJUR.asn1.DERNull]},e=new KJUR.asn1.DERSequence(t);t={array:[new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e})]};var i=new KJUR.asn1.DERSequence(t);t={hex:"00"+i.getEncodedHex()};var r=new KJUR.asn1.DERBitString(t);t={array:[e,r]};var s=new KJUR.asn1.DERSequence(t);return s.getEncodedHex()},ue.prototype.getPublicBaseKeyB64=function(){return be(this.getPublicBaseKey())},ue.prototype.wordwrap=function(t,e){if(e=e||64,!t)return t;var i="(.{1,"+e+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(i,"g")).join("\n")},ue.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return t+=this.wordwrap(this.getPrivateBaseKeyB64())+"\n",t+="-----END RSA PRIVATE KEY-----"},ue.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return t+=this.wordwrap(this.getPublicBaseKeyB64())+"\n",t+="-----END PUBLIC KEY-----"},ue.prototype.hasPublicKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")},ue.prototype.hasPrivateKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},ue.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)};var _e=function(t){ue.call(this),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))};_e.prototype=new ue,_e.prototype.constructor=_e;var ze=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null};ze.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new _e(t)},ze.prototype.setPrivateKey=function(t){this.setKey(t)},ze.prototype.setPublicKey=function(t){this.setKey(t)},ze.prototype.decrypt=function(t){try{return this.getKey().decrypt(Te(t))}catch(e){return!1}},ze.prototype.encrypt=function(t){try{return be(this.getKey().encrypt(t))}catch(e){return!1}},ze.prototype.getKey=function(t){if(!this.key){if(this.key=new _e,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},ze.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},ze.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},ze.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},ze.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},ze.version="2.3.0",t.JSEncrypt=ze}(JSEncryptExports),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e:"function"==typeof define&&define.amd?define(e):t.JSEncrypt=e}(this,JSEncryptExports.JSEncrypt);
INTERMediatorOnPage.getEditorPath=function(){return '';};
INTERMediatorOnPage.getEntryPath=function(){return "/member/im_include_research.php";};
INTERMediatorOnPage.getTheme=function(){return "redb";};
INTERMediatorOnPage.getDataSources=function(){return {'0':{'records':'1','name':'staff','key':'id','query':{},'sort':{'0':{'field':'id','direction':'asc'}},'authentication':{'all':{'target':'field-user','field':'email'}}},'1':{'name':'management','key':'id'},'2':{'name':'gakubu','relation':{'0':{'foreign-key':'id','join-field':'gakubu_id','operator':'='}}},'3':{'name':'gakka','relation':{'0':{'foreign-key':'id','join-field':'gakka_id','operator':'='}}},'4':{'name':'title','relation':{'0':{'foreign-key':'id','join-field':'title_id','operator':'='}}},'5':{'name':'category','view':'research_category','table':'research_category','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}}},'6':{'name':'keyword','view':'research_keyword','table':'research_keyword','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'キーワードを追加'}},'7':{'name':'theme','view':'research_theme','table':'research_theme','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'テーマを追加'}},'8':{'name':'society','view':'academic_society','table':'academic_society','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'repeat-control':'confirm-insert confirm-delete','button-names':{'insert':'学会を追加'}},'9':{'records':'5','name':'paper','table':'book_paper','view':'book_paper','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','button-names':{'insert':'業績を追加'}},'10':{'records':'5','name':'exhibition_society','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','validation':{'0':{'field':'is_period','rule':'1'}},'post-repeater':'expandRecordHavingIsPeriod','button-names':{'insert':'業績を追加'}},'11':{'records':'5','name':'research_fund','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','validation':{'0':{'field':'fund','rule':'1','message':'半角数値で入力してください'},'1':{'field':'is_period','rule':'1'}},'post-repeater':'expandRecordHavingIsPeriod','button-names':{'insert':'業績を追加'}},'12':{'name':'patent','key':'id','relation':{'0':{'foreign-key':'staff_id','join-field':'id','operator':'='}},'sort':{'0':{'field':'year','direction':'DESC'},'1':{'field':'month','direction':'DESC'},'2':{'field':'id','direction':'DESC'}},'repeat-control':'confirm-insert-top confirm-delete','button-names':{'insert':'業績を追加'}}};};
INTERMediatorOnPage.getOptionsAliases=function(){return {};};
INTERMediatorOnPage.getOptionsTransaction=function(){return '';};
INTERMediatorOnPage.dbClassName="DB_PDO";
INTERMediatorOnPage.defaultKeyName="";
INTERMediatorOnPage.isEmailAsUsername=false;
INTERMediatorOnPage.getMessages=function(){return {'1':'Record #','2':'Refresh','3':'Add Record','4':'Delete Record','5':'Insert','6':'Delete','7':'Save','8':'Login as: ','9':'Logout','10':'Move to page:','11':'','12':'Detail','13':'Show List','14':'Copy','15':'Copy Record','1001':'Other people might be updated.\n\nInitially=@1@\nCurrent=@2@\nDatabase=@3@\n\nYou can overwrite with your data if you select OK.','1002':'Can\'t determine the Table Name: @1@','1003':'No information to update: field=@1@','1004':'Connection Error in db_query=@1@\/@2@','1005':'On calling db_query, Required parameter \'name\' doesn\'t specified','1006':'On calling db_query, Required parameter \'table\' doesn\'t specified','1007':'On calling db_update, Required parameter \'name\' doesn\'t specified','1008':'On calling db_update, Required parameter \'conditions\' doesn\'t specified','1009':'On calling db_update, Required parameter \'operator\' doesn\'t specified','1010':'On calling db_update, Required parameter \'value\' doesn\'t specified','1011':'On calling db_update, Required parameter \'dataset\' doesn\'t specified','1012':'Query Access: ','1013':'Update Access: ','1014':'Connection Error in db_update=@1@\/@2@','1015':'Connection Error in db_delete=@1@\/@2@','1016':'Connection Error in db_createRecord=@1@\/@2@','1017':'Delete Access: ','1018':'Create Record Access: ','1019':'On calling db_delete, Required parameter \'name\' doesn\'t specified','1020':'On calling db_delete, Required parameter \'conditions\' doesn\'t specified','1021':'On calling db_createRecord, Required parameter \'name\' doesn\'t specified','1022':'Using Unsupported Browser (Try not to use the compatibility mode of Internet Explorer)','1023':'[This site uses INTER-Mediator.]','1024':'Multiple records are going to be updated. The key field might be wrong. Are you sure?','1025':'Are you sure to delete?','1026':'Are you sure to create record?','1027':'Get Challenge: ','1028':'Connection Error in get_challenge=@1@\/@2@','1029':'Change Password Access: ','1030':'Connection Error on changing password=@1@\/@2@','1031':'Change File Uploading: ','1032':'Connection Error on uploading file=@1@\/@2@','1033':'The field name specified in the page file doesn\'t exist [folder=@1@]','1034':'Other people might be updated.\n\n@1@\n\nYou can overwrite with your data if you select OK.','1035':'field=@1@, initial value=@2@, current value=@3@\n','1036':'field=@1@, expression=@2@ happens a parse error.','1037':'A cyclic referencing is detected.','1038':'Preparing the Pusher, although the settings in the server side is available, the client library isn\'t included.','1039':'Preparing the Pusher, although the client library is included, the settings in the server side is not available.','1040':'The field \'@2@\' in the context \'@1@\' does not exist in the table.','1041':'Are you sure to copy this record?','1042':'The database class doesn\'t support aggregation-select\/from\/group-by.','1043':'Both aggregation-select and aggregation-from are required. One of them doesn\'t exist in the context definition.','1044':'The context having aggregation-select\/from\/group-by is read-only.','1045':'The \'key\' is required in the context definition if writing operations apply to the context \'@1@\'.','1046':'The context definition of the name \'@1@\' in target specifications of the page file is undefined in the definition file.','1047':'The context \'@1@\' was chosen for this context, and ignored target specifications were: @2@','2001':'Authentication Error!','2002':'User:','2003':'Password:','2004':'Login','2005':'Change Password','2006':'New Password:','2007':'Missing any of Username, old and new password.','2008':'Failure to get a challenge from server.','2009':'Succeed to change your password. Login with the new password.','2010':'Failure to change your password. Maybe the old password is not correct.','2011':'User(Mail Address):','2012':'Retry to login. You should clarify the user and the password.','2013':'You should input user and\/or password.','2014':'OAuth Login','2015':'Any alphabets have to contain in new password.','2016':'Any numbers have to contain in new password.','2017':'Any upper case alphabets have to contain in new password.','2018':'Any lower case alphabets have to contain in new password.','2019':'Any punctuations have to contain in new password.','2020':'New password have to differ from the user name.','2021':'New password have to contain more than @1@ characters.','2022':'Enrollment this site with email','2023':'Reset my password','2024':'You need to prepare your email address.','2025':'Require a 2048-bit private key at least for authentication','3101':'Drag Here.','3102':'Dragged File: ','3201':'Exceeded post size limit. Check the post_max_size in php.ini file.','3202':'No file wasn\'t uploaded. Possibly, exceeded file size limit.','3203':'Exceeded file size limit. Check the upload_max_filesize in php.ini file.','3204':'Partially uploaded.','3205':'Temporary directory doesn\'t exist.','3206':'Can\'t write to disk or file system.','3207':'Extension module prevents to upload.','3208':'Unknown error in file uploading.','3209':'Select File...','3210':'Selected File: ','3211':'Upload'};};
INTERMediatorOnPage.browserCompatibility=function(){return {'edge':'12+','trident':'4+','chrome':'1+','firefox':'2+','safari':'4+','opera':'1+','webkit':'1+'};};
INTERMediatorOnPage.clientNotificationIdentifier=function(){return '691702fed0565fd6aac03e53d2884c360b170b172eccb52da8ec18108b1d1cce';};
INTERMediatorOnPage.metadata={version:"5.12",releasedate:"2021-08-15"};
INTERMediatorLog.debugMode=false;
INTERMediatorOnPage.appLocale="ja_JP";
INTERMediatorOnPage.localeInfo=JSON.parse('{"decimal_point":".","thousands_sep":",","int_curr_symbol":"JPY ","currency_symbol":"\uffe5","mon_decimal_point":".","mon_thousands_sep":",","positive_sign":"","negative_sign":"-","int_frac_digits":0,"frac_digits":0,"p_cs_precedes":1,"p_sep_by_space":0,"n_cs_precedes":1,"n_sep_by_space":0,"p_sign_posn":1,"n_sign_posn":1,"grouping":[3],"mon_grouping":[3],"DAY":["\u65e5\u66dc\u65e5","\u6708\u66dc\u65e5","\u706b\u66dc\u65e5","\u6c34\u66dc\u65e5","\u6728\u66dc\u65e5","\u91d1\u66dc\u65e5","\u571f\u66dc\u65e5"],"ABDAY":["\u65e5","\u6708","\u706b","\u6c34","\u6728","\u91d1","\u571f"],"MON":["\u7766\u6708","\u5982\u6708","\u5f25\u751f","\u536f\u6708","\u7690\u6708","\u6c34\u7121\u6708","\u6587\u6708","\u8449\u6708","\u9577\u6708","\u795e\u7121\u6708","\u971c\u6708","\u5e2b\u8d70"],"ABMON":["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"],"AM_STR":"\u5348\u524d","PM_STR":"\u5348\u5f8c","D_FMT_LONG":"%Y\u5e74%M\u6708%D\u65e5 %W","T_FMT_LONG":"%H\u6642%I\u5206%S\u79d2","D_FMT_MIDDLE":"%Y\/%M\/%D(%w)","T_FMT_MIDDLE":"%H:%I:%S","D_FMT_SHORT":"%Y\/%m\/%d","T_FMT_SHORT":"%H:%I"}');
INTERMediatorOnPage.appCurrency="JP";
INTERMediatorOnPage.requireAuthentication=true;
INTERMediatorOnPage.authRequiredContext={'0':'staff'};
INTERMediatorOnPage.isLDAP=false;
INTERMediatorOnPage.isOAuthAvailable=false;
INTERMediatorOnPage.isNativeAuth=false;
INTERMediatorOnPage.authStoring="cookie-domainwide";
INTERMediatorOnPage.authExpired=3600;
INTERMediatorOnPage.realm="";
INTERMediatorOnPage.publickey='-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnEpCZny+NQy+aCVGivertUIt9OrI/aDpAjT7s1UYLEERFXcfFs1A9VdIowUeg3NyJxAOxbLk6RXczoVoULEte2HB/roFg7V/sVG9rjx5F4im0JLqEyvuSLTeSx3TGkIr0NHmNAO/SQrfnBiUjdkugn2WCuvQHe06wfHXWg3Pck4JS0Y6vNQz//Ny7nZVfAWRkiFtb7ZilvSWXmmFuoG3xH6IeFBMaJBcFENK58bGQaQTcfg9qzpHhzCQwqbURYSH8WzAZlPRUo1lBZ4WEpMqGWYOiiiqOlc0v+2pW5BNvu3fk8DQbGwJIywC12nfhFKZH2txv0o0hx2ukXA+nBMQLQIDAQAB-----END PUBLIC KEY-----';
INTERMediatorOnPage.publickeysize=2048;

Generated by INTER-Mediator Ver.5.12(2021-08-15)