var min_segment_size=5;var max_segment_size=25;var editmachineCounter=0;var editmachineConstructorTime=0;var EDIT_MACHINE="EDIT_MACHINE";var LIST_MACHINE="LIST_MACHINE";function Machine(f,e,d,c,b,a){this.name=f;this.type=EDIT_MACHINE;this.mainform=e;this.miniform=d;this.tableobj=c;if(this.tableobj!=null){this.tableobj.machine=this;}this.allow_insert=b;this.tableborder=false;this.isinline=false;this.bShowAllEditedFields=false;this.hasInterceptedEvents=false;this.ischanged=false;this.waschanged=false;this.isdeleting=false;this.showEditor=true;this.showRowNumbers=false;this.rowNumberLabel="#";this.autoEdit=true;this.sortable=false;this.allowMoveLines=false;this.allowQuickDeleteLines=false;this.showButtons=true;this.moveButtons=true;this.sortDirUp=true;this.sortIndex=-1;this.allWhiteDisplayMode=false;this.fieldSetIncludesCancelButton=false;this.addonly=false;this.savedState=new Object();this.indentFirstVisibleColumn=false;if(f){this.form_elems=splitIntoCells(this.mainform.elements[f+"fields"].value);this.table_labels=splitIntoCells(this.mainform.elements[f+"labels"].value);this.miniform_elem_types=splitIntoCells(this.mainform.elements[f+"types"].value);this.miniform_elem_flags=splitIntoCells(this.mainform.elements[f+"flags"].value);this.miniform_elem_fieldsets=splitIntoCells(this.mainform.elements[f+"fieldsets"].value);}this.elementCache=new Array();this.recalcType=null;this.currentRowNum=0;this.segmentSelect=null;this.segmentStartIndex=1;this.lastStartSegmentIndex=1;this.segmentable=false;this.isCurrentlySegmented=false;this.doCheckMandatoryData=Machine_doCheckMandatoryData;this.synclinefields=Machine_lineInit;this.validatedelete=Machine_validatedelete;this.validateinsert=Machine_validateinsert;this.validateline=Machine_validateline;this.preSelectRow=Machine_preSelectRow;this.getDisplayCellContentOverride=Machine_getDisplayCellContentOverride;this.getFieldOverride=Machine_getFieldOverride;this.getRowFormElementTypeOverride=null;this.isFieldEditableOverride=Machine_isFieldEditableOverride;this.isNeedUpdateFieldDisplayValue=Machine_isNeedUpdateFieldDisplayValue;this.postBuildTable=Machine_postBuildTable;this.postdeleteline=Machine_postdeleteline;this.postEditRow=Machine_postEditRow;this.postprocessline=Machine_lineCommit;this.recalc=Machine_recalc;editmachineCounter++;if(typeof this.name!="undefined"){if(!window.machines){window.machines=new Object;}window.machines[this.name]=this;}this.bInitFormInputValues=false;if(a){this.dataManager=a;if(this.isRecordManagerUsed()&&this.dataManager.getNumRows()>0){var h=this.dataManager.getNumOfRows();var g=this.getMachineIndex();this.setIndex(h+1);if(this.allow_insert){this.setMachineIndex(h+1);}else{this.setMachineIndex(h);this.bInitFormInputValues=true;}this.dataManager.addListener(this);}else{this.setMachineIndex(this.getMachineIndex());}}else{this.dataManager=new NLMachineDataManager(this);}}Machine.prototype.getSegmentAdjustedRowNum=function Machine_getSegmentAdjustedRowNum(){if(this.segmentable){return this.currentRowNum+Math.max(0,(this.segmentStartIndex-1));}else{return this.currentRowNum;}};Machine.prototype.getAdjustedSegmentIndex=function Machine_getAdjustedSegmentIndex(b,a){if(this.segmentable){return b-((a?-1:1)*(Math.max(0,this.segmentStartIndex-1)));}else{return b;}};Machine.prototype.manageSegmentSelect=function Machine_manageSegmentSelect(h){var c=Math.ceil(((h-1)/max_segment_size));var g=this.segmentStartIndex==-1;var f=!g&&c>1;if(this.segmentable&&(f||g)){deleteAllSelectOptions(this.getSegmentSelect());var d=1;for(var b=0;b<c;b++){var e=Math.min(d+max_segment_size-1,h-1);addSelectOption(document,this.getSegmentSelect(),d+" - "+e+" of "+(h-1),d,false);this.lastStartSegmentIndex=d;if(!g&&this.segmentStartIndex==d){setFormValue(this.getSegmentSelect(),d);if(this.getMachineIndex()<d||this.getMachineIndex()>e){this.setMachineIndex(this.getNextIndex());}this.isCurrentlySegmented=true;this.segmentStartIndex=d;}d+=max_segment_size;}addSelectOption(document,this.getSegmentSelect(),"All",-1,false);if(g){setFormValue(this.getSegmentSelect(),-1);this.isCurrentlySegmented=false;this.lastStartSegmentIndex=-1;}}else{this.segmentStartIndex=1;this.lastStartSegmentIndex=1;this.isCurrentlySegmented=false;}showFieldAndLabel(this.name+"_segment_select_fs",(f||g));if(this.segmentable&&f){var a=document.getElementById(this.name+"_segment_select_fs");a.parentNode.previousSibling.style.width="80%";}return f&&this.segmentable;};Machine.prototype.getSegmentSelect=function Machine_getSegmentSelect(){if(this.segmentSelect==null){var a=this.name+"_segment_select";var b=document.forms[this.name+"_form"].elements[a];this.segmentSelect=b;}return this.segmentSelect;};Machine.prototype.getTableName=function Machine_getTableName(){return this.tableobj==null?null:this.tableobj.id;};Machine.prototype.getFormName=function Machine_getFormName(){return this.miniform.name;};Machine.prototype.getFormElementType=function Machine_getFormElementType(a){return this.miniform_elem_types[a];};Machine.prototype.getRowFormElementType=function Machine_getRowFormElementType(a,c){var b=null;if(this.getRowFormElementTypeOverride){b=this.getRowFormElementTypeOverride(a,c);}if(b!=null){return b;}return this.getFormElementType(a);};Machine.prototype.getFormElementName=function Machine_getFormElementName(a){return this.form_elems[a];};Machine.prototype.getFormElementLabel=function Machine_getFormElementLabel(a){return this.table_labels[a];};Machine.prototype.setFormElementLabel=function Machine_setFormElementLabel(b,a){this.table_labels[this.getArrayPosition(b)]=a;};Machine.prototype.getFormElementFieldSet=function Machine_getFormElementFieldSet(a){return this.miniform_elem_fieldsets[a];};Machine.prototype.countFormElements=function Machine_countFormElements(){return this.form_elems.length;};Machine.prototype.getFormElement=function Machine_getFormElement(a,b){var c=this.getFormElementName(a)+(b>0?b:"");var d=this.elementCache[c];if(d){return d;}d=this.miniform.elements[c];this.elementCache[c]=d;return d;};Machine.prototype.getInputElements=function Machine_getInputElements(e,b){var a=new Array();if(!b){b=this.getFormFieldNames();}var g=false;if(this.idMap==null){this.createEditorMap();}for(var d=0;d<b.length;d++){var f=null;var c=(g)?this.getFormElementLabel(d-1):this.getFormElementLabel(d);f=this.idMap[d];if(e!=true&&(c==null||c.length==0||this.getFormElementFieldSet(d).length>0)){f=null;}a[a.length]=f;g=this.isElementPopupDisplayField(d);}return a;};Machine.prototype.getElementDisplayLabel=function Machine_getElementDisplayLabel(a){return this.getFormElementLabel(a).length>0?this.getFormElementLabel(a):this.getFormElementLabel(a-1);};Machine.prototype.isElementDisplayOnlyWithField=function Machine_isElementDisplayOnlyWithField(a){return(this.miniform_elem_flags[a]&32)!=0;};Machine.prototype.isElementPopupDisplayField=function Machine_isElementPopupDisplayField(a){return(this.miniform_elem_flags[a]&8)!=0;};Machine.prototype.isElementRequired=function Machine_isElementRequired(a){return(this.miniform_elem_flags[a]&1)!=0;};Machine.prototype.getElementRequired=function Machine_getElementRequired(b){var a=this.getArrayPosition(b);return(this.miniform_elem_flags[a]&1)!=0;};Machine.prototype.setElementRequired=function Machine_setElementRequired(d,c){var a=this.getArrayPosition(d);if(c){this.miniform_elem_flags[a]|=1;}else{this.miniform_elem_flags[a]&=~1;}var b=this.getFormElement(a);setRequired(b,c);};Machine.prototype.isCurrentRowRequired=function Machine_isCurrentRowRequired(){return this.isRowRequired(this.getMachineIndex());};Machine.prototype.isElementNoCopy=function Machine_isElementNoCopy(a){return(this.miniform_elem_flags[a]&2)!=0;};Machine.prototype.isFieldEditable=function Machine_isFieldEditable(a,k){if(typeof k=="undefined"||k==null){k=this.getMachineIndex();}var e=this.isFieldEditableOverride(a,k);if(e!=null){return e;}e=false;var h=this.getFormElementType(a);var b=this.getFormElementName(a);var g=this.getFormElement(a);var c=(a>0&&this.isElementPopupDisplayField(a-1));var d=c?this.getFormElementLabel(a-1):this.getFormElementLabel(a);if(d==null||d.length==0||this.isElementDisplayOnlyWithField(a)||this.getFormElementFieldSet(a).length>0){}else{if(h=="select"){if(c){g=this.getFormElement(a-1);}e=!g.disabled;}else{if(h=="slaveselect"){e=!g.disabled;}else{if(h=="integer"&&c){if(g.disabled){e=(g.type!="hidden");}else{var f=this.getFormElement(a-1);if(f.type=="hidden"){e=true;if(window.getDropDown){var l=getDropDown(f);e=!l.disabled;}}else{e=!f.disabled;}}}else{if(h=="fieldset"){e=true;}else{if(h=="namevaluelist"){e=true;g=g.form.elements[g.name+"_display"];}else{if(h=="color"){e=true;}else{e=(g.type!="hidden")&&!g.disabled&&!this.isElementPopupDisplayField(a);}}}}}}}return e?g:false;};Machine.prototype.isPopupSelect=function Machine_isPopupSelect(c){var a=null;if(!c){return;}elems=c.getElementsByTagName("INPUT");for(var b=0;b<elems.length;b++){if(elems[b].type=="hidden"){a=elems[b];break;}}if(a){return isPopupSelect(a);}return false;};Machine.prototype.isPopupMultiSelect=function Machine_isPopupMultiSelect(c){var a=null;if(!c){return;}elems=c.getElementsByTagName("INPUT");for(var b=0;b<elems.length;b++){if(elems[b].type=="hidden"){a=elems[b];break;}}if(a){return isPopupMultiSelect(a);}return false;};Machine.prototype.setAddOnly=function Machine_setAddOnly(a){this.addonly=a;};Machine.prototype.addOnly=function Machine_addOnly(){return this.addonly;};Machine.prototype.machineIsVisible=function Machine_machineIsVisible(b){var a=document.getElementById(this.name+"_layer");return a.style.display!="none"&&a.style.visibility=="inherit"?a.parentNode.style.visibility=="visible"||a.parentNode.style.visibility=="":a.style.visibility=="visible";};Machine.prototype.setEnableEdit=function Machine_setEnableEdit(a,c,b){if(!this.isinline){return;}a=(a!=false);if(a){this.showEditor=true;if(typeof b!="undefined"&&b!=null){this.allow_insert=b;}else{if(typeof this.savedState.allow_insert!="undefined"){this.allow_insert=this.savedState.allow_insert;}}if(typeof this.savedState.allowMoveLines!="undefined"){this.allowMoveLines=this.savedState.allowMoveLines;}}else{this.savedState.allow_insert=this.allow_insert;this.savedState.allowMoveLines=this.allowMoveLines;this.allow_insert=false;this.showEditor=false;this.allowMoveLines=false;}if(c==true){this.buildTable();}};Machine.prototype.clearSavedState=function Machine_clearSavedState(){this.savedState=new Object();};Machine.prototype.getNextIndex=function Machine_getNextIndex(){return parseInt(this.mainform.elements["next"+this.name+"idx"].value);};Machine.prototype.getMaxIndex=function Machine_getMaxIndex(){return this.getNextIndex();};Machine.prototype.getMachineIndex=function Machine_getMachineIndex(){if(this.miniform.elements[this.name+"_lineindex"]){return parseInt(this.miniform.elements[this.name+"_lineindex"].value);}return parseInt(this.miniform.elements.lineindex.value);};Machine.prototype.setMachineIndex=function Machine_setMachineIndex(b){this.doSetMachineIndex(b);var a=this.dataManager.setActiveLine(b,this.allow_insert);if(a&&!window.virtualBrowser){this.dataManager.setInitialFieldValues(this.getLineData(),this.dataManager.activeRowIdx);}};Machine.prototype.doSetMachineIndex=function Machine_doSetMachineIndex(a){if(this.miniform.elements[this.name+"_lineindex"]){this.miniform.elements[this.name+"_lineindex"].value=a;}if(this.miniform.elements.lineindex!=null){this.miniform.elements.lineindex.value=a;}};Machine.prototype.incrementIndex=function Machine_incrementIndex(){this.mainform.elements["next"+this.name+"idx"].value-=-1;};Machine.prototype.decrementIndex=function Machine_decrementIndex(){this.mainform.elements["next"+this.name+"idx"].value-=1;};Machine.prototype.setIndex=function Machine_setIndex(a){this.mainform.elements["next"+this.name+"idx"].value=parseInt(a);};Machine.prototype.getFieldSetIncludesCancelButton=function Machine_getFieldSetIncludesCancelButton(){return this.fieldSetIncludesCancelButton;};Machine.prototype.getFieldSetDoneAction=function Machine_getFieldSetDoneAction(){return this.name+"_machine.gotoField(1); setEventCancelBubble(evnt); return false;";};Machine.prototype.setPreferredValue=function Machine_setPreferredValue(a){return setPreferredFields(this.name,this.preferredfield,this.preferredwithinfield,a);};Machine.prototype.imalive=function Machine_imalive(){alert("..imalive "+this.name);};Machine.prototype.fieldHasFocus=function Machine_fieldHasFocus(b){var a=this.getArrayPosition(b);return a==this.focusedColumn;};Machine.prototype.applyFocusToFocusElement=function NLMachine_applyFocusToFocusElement(){if(this.focusElement&&isFocusable(this.focusElement)){this.focusElement.parentNode.style.left=Number(document.body.scrollLeft)+50+"px";this.focusElement.focus();}};Machine.prototype.setFocusToCurrentColumn=function Machine_setFocusToCurrentColumn(){this.setFocus(this.focusedColumn,false);};Machine.prototype.setFocusToFirstEditable=function Machine_setFocusToFirstEditable(){if(this.isinline){var a=this.focusedColumn;this.gotoField(this.getFieldOffset(-1,1),true);if(a==this.focusedColumn){this.setFocus(this.focusedColumn);}}};Machine.prototype.getFieldOffset=function Machine_getFieldOffset(a,d,c){for(var b=a+d;(b<this.countFormElements())&&(b>=0);b+=d){if(this.isFieldEditable(b)&&(c||this.getFormElementType(b)!="fieldset")){return b;}}return(a==-1)?0:a;};Machine.prototype.setColToFirstEditable=function Machine_setColToFirstEditable(a){this.focusedColumn=this.getFieldOffset(-1,1,a);};Machine.prototype.createEditorMap=function Machine_createEditorMap(){this.idMap=new Array();var d=false;var a=this.getFormFieldNames();for(var b=0;b<a.length;b++){editorName=this.name+"_"+a[b]+"_fs";var c=document.getElementById(editorName);if(!c){editorName=this.name+"_"+a[b]+"_fs";c=document.getElementById(editorName);}if(c){c.indexOfEditor=d?b-1:b;this.idMap[b]=c;}d=this.isElementPopupDisplayField(b);}};Machine.prototype.isRecordManagerUsed=function Machine_isRecordManagerUsed(){return this.dataManager&&this.dataManager.getNumOfRows;};Machine.prototype.showMachine=function Machine_showMachine(b){var a=document.getElementById(this.name+"_singlespacer");if(a!=null){a.style.display=b?"":"none";}document.getElementById(this.name+"_layer").style.display=b?"":"none";};Machine.prototype.refresheditmachine=function Machine_refreshEditMachine(a){this.setMachineIndex(this.getNextIndex());this.buildtable(null,a);return true;};Machine.prototype.buildtable=function Machine_buildtable(k,o){var u=new Date().getTime();var g=pTransferTimeouts[this.name];if(g){clearTimeout(g);}pTransferTimeouts[this.name]=null;if(window.fieldSetDiv!=null&&window.fieldSetDiv.parentNode){var p=window.fieldSetDiv.parentNode;p.removeChild(window.fieldSetDiv);}if((this.currentRowNum==0&&!this.allow_insert)||this.bInitFormInputValues){this.setupLineData(this.getMachineIndex());if(this.bInitFormInputValues){this.bInitFormInputValues=false;}}this.currentRowNum=0;if(this.isinline&&!this.hasInterceptedEvents){this.createFocusElement();for(var A=0;A<this.countFormElements();A++){if(this.getFormElementFieldSet(A).length==0){Mch_setUpEventHandlerInterception(this,this.getFormElement(A),this.getFormElementType(A));}}this.hasInterceptedEvents=true;}this.suspendEdit();var F=this.getTableName();if(this.isinline&&this.moveButtons){moveButtonDiv(this.name);}var t=new Array();var s=0;var m=this.constructHeaderRow();t[s++]=m;var C=parseInt(this.getNextIndex());this.segmentStartIndex=(k&&this.segmentable?k:this.segmentStartIndex);var b=this.manageSegmentSelect(C);var v=1;var E=Math.max(0,parseInt(this.segmentStartIndex))+parseInt(max_segment_size);for(var w=1;w<C;w++){if(b&&(w<this.segmentStartIndex||w>=E)){continue;}m=this.constructMainTableRow(null,w);t[s++]=m;v++;}var D=1;var d=null;if(this.isinline&&this.allow_insert){D=C;}var r=this.countFormElements();var H=this.getFormFieldNames();var l="if (window.isinited) { if("+this.name+"_machine.ischanged) "+this.name+"_machine.addline(); else "+this.name+"_machine.clearline(false, "+this.lastStartSegmentIndex+");}";var h=this.isinline&&this.allow_insert&&(this.getMachineIndex()!=this.getNextIndex()||(b&&this.getMachineIndex()!=this.getAdjustedSegmentIndex(v,true)));for(;w<=D;w++){m=document.createElement("TR");if(!this.isinline){m.onclick=new Function(l);}m.className="listtextnonedit";if(h){var f=(this.showRowNumbers?1:0)+(this.allowMoveLines?1:0)+(this.allowQuickDeleteLines?1:0);for(var A=0;A<r;A++){if(this.getFormElementLabel(A).length>0&&this.getFormElementFieldSet(A).length==0){f++;}}d=document.createElement("TD");d.colSpan=f;d.className=this.allWhiteDisplayMode?"listtexthlwht":"listtexthl";d.style.color="#666666";d.style.cursor="default";d.style.height="100%";d.innerHTML="[Click here for a new line]";m.appendChild(d);m.onclick=new Function(l);}else{var G=(this.showRowNumbers?1:0)+(this.allowMoveLines?1:0);for(var z=0;z<G;z++){d=document.createElement("TD");var e="listinlinefocusedrow";if(z==0){e+="left";}d.className=e;d.style.height="100%";d.innerHTML="<div style='height:100%;'></div> ";m.appendChild(d);}var n=true;for(var A=0;A<r;A++){if(this.getFormElementLabel(A).length>0&&this.getFormElementFieldSet(A).length==0){d=document.createElement("TD");d.align=this.getAlignmentForColumn(A);if(this.isinline){d.className="listinlinefocusedrow";if(n&&G==0&&n){d.className+="left";n=false;}d.style.cursor="hand";d.style.height="100%";var B=this.isElementPopupDisplayField(A)?1:0;var a=this.isElementDisplayOnlyWithField(A)?null:(A+B);var c=this.name+"_machine.viewline("+w+","+a+", true); return true;";d.onclick=new Function(c);}d.innerHTML="&nbsp;";m.appendChild(d);}}if(this.allowQuickDeleteLines){d=document.createElement("TD");d.className="listinlinefocusedrow";d.style.height="100%";d.innerHTML="<div style='height:100%;'>&nbsp;</div> ";m.appendChild(d);}if(this.isinline&&d){d.className+="right";}}t[s++]=m;}m=document.createElement("TR");if(d=this.createGrippyCell()){d.innerHTML="<div />";m.appendChild(d);}if(this.showRowNumbers){d=this.createColumnHeaderCell(this.rowNumberLabel);m.appendChild(d);}var A;var y=this.countFormElements();for(A=0;A<y;A++){if(this.getFormElementLabel(A).length==0||this.getFormElementFieldSet(A).length>0){continue;}d=document.createElement("TD");d.className="listinlinefocusedrow";d.align=this.getAlignmentForColumn(A);d.style.paddingTop="0px";d.style.paddingBottom="0px";d.innerHTML="<div></div>";d.style.borderWidth="0 0 0 1";m.appendChild(d);}if(d=this.createDeleteCell()){m.appendChild(d);}for(var A=0;A<m.childNodes.length;A++){if(m.childNodes[A].firstChild){m.childNodes[A].firstChild.style.height="3px";m.childNodes[A].firstChild.style.overflowY="hidden";}}this.lastRow=m;this.lastRow.style.height="3px";this.lastRow.style.visibility="hidden";t[s++]=m;this.tableobj=document.getElementById(F);var q=this.tableobj.firstChild;var x=null;if(q.hasChildNodes()){x=q.getElementsByTagName("TR").length;}for(var A=0;A<t.length;A++){q.appendChild(t[A]);}if(x!=null){for(var z=0;z<x;z++){if(q.firstChild!=null){q.removeChild(q.firstChild);}}}if(this.allow_insert||this.getLineCount()>0){if(this.showEditor){this.editRow(this.getAdjustedSegmentIndex(this.getMachineIndex(),false),!o);}else{this.setFocus(this.focusedColumn);}}window.status="";this.hasRendered=true;this.postBuildTable();editmachineConstructorTime+=(new Date().getTime()-u);return false;};Machine.prototype.suspendEdit=function Machine_suspendEdit(){if(!this.isinline){return;}var a=this.getInputElements(true);for(var b=0;b<a.length;b++){var c=a[b];if(c==null||(this.getFormElementFieldSet(b)&&this.getFormElementFieldSet(b).length>0)){continue;}Machine_reparent(c,this.miniform);}hideButtons(this.name);return a;};Machine.prototype.constructHeaderRow=function Machine_constructHeaderRow(){var d=document.createElement("TR");d.id=this.name+"_headerrow";var a=null;if(this.allowMoveLines){a=this.createColumnHeaderCell("&nbsp;",true);d.appendChild(a);}if(this.showRowNumbers){a=this.createColumnHeaderCell(this.rowNumberLabel,!this.allowMoveLines);d.appendChild(a);}var e=0;var c=(a==null);for(var b=0;b<this.countFormElements();b++){if(this.getFormElementLabel(b).length>0&&this.getFormElementFieldSet(b).length==0){a=document.createElement("TD");a=this.getDisplayHeaderCell(b,a,c);d.appendChild(a);e++;if(c==true){c=false;}}}if(this.allowQuickDeleteLines){a=this.createColumnHeaderCell("&nbsp;");d.appendChild(a);}this.nHeaderLabelCount=e;return d;};Machine.prototype.getDisplayHeaderCell=function Machine_getDisplayHeaderCell(b,l,f){var h=this.getFormElementType(b);var e="listheadertd";if(this.allWhiteDisplayMode){e+="wht";}else{e+=(f?"left":"");}e+=" listheadertextb";var d="listheader";if(this.allWhiteDisplayMode){d+="wht";}var g="";var k="";if(this.sortable){g=this.name+"_machine.sort("+b+"); window.ischanged=true; return false;";k=this.getSortImage(b);}var c=this.getRequiredImage(b);l.height="100%";l.className=e;l.onclick=new Function(g);l.align=this.getAlignmentForColumn(b);var a="<div class='"+d+"'>";a+=c+this.getFormElementLabel(b).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")+k;a+="</div>";l.innerHTML=a;return l;};Machine.prototype.getSortImage=function Machine_getSortImage(a){var b="listheadersort";if(this.sortable){if(a==this.sortIndex){b+=this.sortDirUp?"up":"down";}}return"<span id="+this.name+"dir"+a+" class='"+b+"'></span>";};Machine.prototype.getRequiredImage=function Machine_getRequiredImage(a){var b=(a>0&&this.isElementPopupDisplayField(a))?(a+1):a;if(this.isElementRequired(b)){var c="listheaderreq";return"<span id="+this.name+"req"+a+" class='"+c+"' title='Required Field'></span>";}return"";};Machine.prototype.getAlignmentForColumn=function Machine_getAlignmentForColumn(a){var b=this.getFormElementType(a);if(b=="currency"||b=="currency2"||b=="rtext"||b=="rate"||b=="float"||b=="pct"){return"right";}else{return"left";}};Machine.prototype.constructMainTableRow=function Machine_constructMainTableRow(f,k){var r=this.getLineArrayLine(k-1);var q=this.allWhiteDisplayMode?"listtexthlwht":"listtext"+((k%2==1)?"hl":"");var b=k==this.getMachineIndex();var h=null;if(b){if(this.isinline){onclick=null;q="listinlinefocusedrow";}else{q+=" listfocusedrow";}}row=document.createElement("TR");row.id=this.name+"_row_"+k;if(h!=null){row.className=h;}if(this.allowMoveLines){var p=this.createGrippyCell();p.className=q+(b?"left":"");p.style.backgroundImage="url('"+location.protocol+"//"+location.host+"/images/nav/endcaps/grippy2.gif')";p.style.backgroundRepeat="no-repeat";p.style.backgroundPosition="center";p.innerHTML="<div>&nbsp;</div>";row.appendChild(p);addDragDropHandlersToRow(this.name,row,b);}if(this.showRowNumbers){var p=document.createElement("TD");p.className=q;if(b&&!this.allowMoveLines){p.className+="left";}p.align="center";p.innerHTML="<div> "+k+" </div>";row.appendChild(p);}var g;var n=this.countFormElements();var l;var e=this.getFormFieldNames();var m=true;var p=null;for(g=0;g<n;g++){if(this.getFormElementLabel(g).length==0||this.getFormElementFieldSet(g).length>0){continue;}var p=document.createElement("TD");p.className=q;if(b&&m&&!this.allowMoveLines&&!this.showRowNumbers){p.className+="left";}p.align=this.getAlignmentForColumn(g);p.noWrap=p.align=="right";if(this.indentFirstVisibleColumn&&m){var c=g+1;if(e[g].indexOf("_display")!=-1){c++;}var o=(r[c])?r[c]:0;p.style.paddingLeft=20*parseFloat(o)+"px";}p.innerHTML=this.getCellContentHTML(g,g,r?r[g]:null,k);p.style.cursor="hand";p.style.height="100%";l=this.isElementPopupDisplayField(g)?1:0;var a=this.isElementDisplayOnlyWithField(g)?null:(g+l);var d=this.name+"_machine.viewline("+k+","+a+", true); return true;";p.onclick=new Function(d);row.appendChild(p);m=false;}if(this.allowQuickDeleteLines){p=this.createDeleteCell(k);p.className=q;if(b){p.className+="right";}row.appendChild(p);}else{if(b){p.className+="right";}}return row;};Machine.prototype.getCellContentHTML=function Machine_getCellContentHTML(a,c,e,f){var d=this.getDisplayCellContent(c,e,f);if(f==this.getAdjustedSegmentIndex(this.getMachineIndex(),false)){var b=this.getActiveRowCellContentClassName(a,f);d="<div class='"+b+"' style='height:100%; -moz-box-sizing: border-box;' focusedrowcell=1>"+d+"</div>";}return d;};Machine.prototype.getDisplayCellContent=function Machine_getDisplayCellContent(a,c,e){var m=this.getDisplayCellContentOverride(a,c,e);if(m!=null){if(m.length>0&&m.search(/[^ \t]/)>=0){return m;}else{return"&nbsp;";}}var l=this.getFormElementType(a);var b=this.getFormElementName(a);var k=this.getFormElement(a);if(c==null){c="";}else{if(l!="select"&&l!="slaveselect"){c=(c+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");}}if(l=="address"||l=="textarea"){if(c.length>250){c=c.substring(0,250)+"(more...)";}var f=c.split(String.fromCharCode(5));c=f.join("<br>");}var h="";if(l=="select"||l=="slaveselect"){if(isMultiSelect(k)){var d=getmultiselectlisttext(k,c,String.fromCharCode(5));d=d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");d=d.split(String.fromCharCode(5));h+=d.join("<br />");}else{h+=getlisttext(k,c);h=h.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");}}else{if(l=="currency"){h+=format_currency(parseFloat(c));}else{if(l=="currency2"||l=="rate"){h+=format_rate(parseFloat(c),c.indexOf("%")!=-1);}else{if(l=="checkbox"){h+=c=="T"?"Yes":"";}else{if(l=="radio"){h+=getradiotext(k,c);}else{if(l=="namevaluelist"){h+=getnamevaluelisttext(c,"<br>");}else{if(l=="fieldset"){var g=getFieldSetDisplayText(this,b,e);if(g!=null&&g.length>0){h+="<img src='/images/reportbuilder/fieldsetup.gif' border=0><img src='/images/nav/stretch.gif' height=1 width=6 border=0>";}h+=g;}else{if(l=="phone"&&window.tapidevice!=null&&window.tapidevice.length>0){h+="<a href='#' src='/images/forms/phone.gif' onclick='NLDial(\""+c+"\");event.cancelBubble=true;return false;'>"+c+"</a>";}else{if(l=="password"){h=c.replace(/./g,"&bull;");}else{if(l=="color"&&c.length>0){if(this.isinline){h="<span style='width:40px' align='center'><img src='/images/nav/stretch.gif' style='border:1px solid; padding:0px; height:12px; width:12px; background-color:"+c+"' /></span>";}else{h="<img align='top' style='background-color:"+c+"' border=1 src='/images/nav/stretch.gif' width='18' height='12'>&nbsp;"+c;}}else{if(l=="summary"){h="&nbsp;";}else{if(c!=null){h+=c.replace(/\n/g,"<br>");}}}}}}}}}}}}if(h.length>0&&h.search(/[^ \t]/)>=0){return h;}else{return"&nbsp;";}};Machine.prototype.getActiveRowCellContentClassName=function Machine_getActiveRowCellContentClassName(a,d){var c="listinlinefocusedrowcell";var b=this.isFieldEditable(a,d);if(!b||!this.isinline){c+="noedit";}return c;};Machine.prototype.updateCellContent=function Machine_updateCellContent(a,b,c,e,f){if(f==this.getAdjustedSegmentIndex(this.getMachineIndex(),false)){if(a.firstChild&&a.firstChild.focusedrowcell){var d=this.getDisplayCellContent(c,e,f);a.firstChild.className=this.getActiveRowCellContentClassName(b,f);a.firstChild.innerHTML=d;}else{a.innerHTML=this.getCellContentHTML(b,c,e,f);}}};Machine.prototype.editRow=function Machine_editRow(f,c){if(!this.isinline){return;}if((!this.allow_insert&&this.getNumOfRows()==0)||f==0){return;}var h=this.tableobj;var l=h.getElementsByTagName("tr");if((l.length-1)<=f){return;}var k=l[f];var a=this.getInputElements();if(this.currentRowNum!=f){var g=this.lastRow.cells;var b=k.cells;for(var e=0;e<g.length;e++){var d=g[e];if(this.allow_insert&&this.getMachineIndex()==this.getNextIndex()){d.innerHTML="<div>&nbsp;</div>";}else{d.innerHTML=b[e].innerHTML;}if(d.firstChild&&d.firstChild.style){d.firstChild.style.height="3px";d.firstChild.style.overflowY="hidden";}}}this.currentRowNum=f;this.addEditor(a,k,f,c);h.machineName=this.name;putButtonsInMachine(this,k,h);if(this.getMachineIndex()==this.getNextIndex()){setButtonText(this.name+"_addedit","Add");setButtonText(this.name+"_copy","Copy Previous");disableButton(this.name+"_copy",this.getNextIndex()==1);disableButton(this.name+"_remove",true);disableButton(this.name+"_insert",true);}else{this.mode="edit";setButtonText(this.name+"_addedit","Done");setButtonText(this.name+"_edit","Done");setButtonText(this.name+"_copy","Make Copy");disableButton(this.name+"_copy",this.isinserting);disableButton(this.name+"_remove",this.isCurrentRowRequired());disableButton(this.name+"_insert",this.isinserting);}if(c&&elementIsFocusable(this.tableobj)){this.setFocus(this.focusedColumn);}Machine_scheduleTransfer(this);this.postEditRow();};Machine.prototype.addEditor=function Machine_addEditor(a,p,l,n){p.onclick=null;var g=false;var b=this.getFormFieldNames();var d=-1+(this.showRowNumbers?1:0)+(this.allowMoveLines?1:0);if(!this.focusedColumn||!this.isFieldEditable(this.focusedColumn,l)){this.setColToFirstEditable();}for(var e=0;e<a.length;e++){var k=null;var h=null;var f=this.getFieldOverride(a,p,l,e);if(f){k=f==null?null:f[0];h=f==null?null:f[1];}else{k=a[e];h=(g)?this.getFormElementLabel(e-1):this.getFormElementLabel(e);}if((h==null)||(h.length==0)||this.getFormElementFieldSet(e).length>0){continue;}if(!g){++d;}g=this.isElementPopupDisplayField(e);var c=p.cells[d];c.height=ACTIVE_LINE_HEIGHT+"px";if(k==null){continue;}if((e==this.focusedColumn&&!this.isElementDisplayOnlyWithField(e))||this.bShowAllEditedFields){var o=c.style;Machine_showField(k);c.origPaddingTop=o.paddingTop;c.origPaddingRight=o.paddingRight;c.origPaddingLeft=o.paddingLeft;c.origPaddingBottom=o.paddingBottom;storeCheckboxState(k);var m=k.parentNode;m.removeChild(k);this.setCellContents(c,k,this,d,this.getRowFormElementType(e,l),e,n);restoreCheckboxState(k);this.focusedCell=k;}}};Machine.prototype.setCellContents=function NLMachine_setCellContents(b,p,o,n,e,f,q){var g=true;if(o.bShowAllEditedFields){cleanUpCellContents(b);b.appendChild(p);return;}o.copiedlastrowcell=n;b.innerHTML="";var l=o.cellContainerDIV;var h=o.cellHoverDIV;if(!l){l=document.createElement("div");l.className="bigouter";l.style.margin="0 0 0 0";l.style.padding="0 0 0 0";l.style.position="relative";l.style.height="100%";l.style.width="100%";l.style.zIndex=1000;l.style.overflow="visible";h=document.createElement("div");h.className="divhover";h.style.width="100%";h.style.height="100%";h.style.left="0px";h.style.top="0px";h.style.margin="0 0 0 0";h.sourceMachine=o;h.style.top="-1px";o.cellContainerDIV=l;o.cellHoverDIV=h;}l.appendChild(h);b.appendChild(l);if(p.className&&p.className.indexOf("listcontrol")>=0){l.style.border="0";}else{l.style.border="2px solid #888888";}l.style.width="100%";h.style.textAlgin="";h.innerHTML="";h.style.padding="0 0 0 0";h.style.position="absolute";if(e!="fieldset"){h.appendChild(p);}if(o.nHeaderLabelCount==1){h.style.position="relative";g=false;}if(!p.helperButtonWidth){var r="0";var m=b.clientWidth-p.helperButtonWidth-4;u=p.getElementsByTagName("SPAN");for(var n=0;n<u.length;n++){if(u[n].className.indexOf("field_widget_")>=0){r=u[n].offsetWidth;if(!(e=="select"||e=="slaveselect")){u[n].style.left="0";}break;}}p.helperButtonWidth=r;}if(e=="integer"&&f>0&&o.isElementPopupDisplayField(f-1)){if(getDropdown(p)){e="select";}else{var c=p.getElementsByTagName("TEXTAREA").length>0?p.getElementsByTagName("TEXTAREA")[0]:p.getElementsByTagName("SELECT")[0];if(o.isPopupMultiSelect(p)){e="popupmultiselect";}if(p.firstChild.style){p.firstChild.style.position="relative";p.firstChild.style.width="100%";}else{p.style.width="100%";}}}if(e=="textarea"){var c=p.tagName=="TEXTAREA"?p:p.firstChild;NLMachine_updateTextAreaSize(c);}else{if((e=="select")||(e=="slaveselect")){if(e=="slaveselect"&&f>0&&o.isElementPopupDisplayField(f-1)){if(p.tagName!="SELECT"&&p.firstChild.style){p.firstChild.style.position="relative";p.firstChild.style.width="100%";}}var s=getDropdown(p);if(s){o.layoutdd=s;o.layoutparent=b;o.showinparent=l;s.setText(null,true,null);s.inpt.style.verticalAlign="top";}}else{if(e=="namevaluelist"){p.firstChild.style.width="100%";}else{if(e=="color"){}else{if(e=="checkbox"){p.style.display="inline-block";p.style.top="1";p.style.left="1";p.style.textAlign="center";}else{if(e=="summary"){}else{p.style.width="100%";if(p.tagName=="INPUT"){p.style.width="100%";}else{p.firstChild.style.width="100%";}}}}}}}if(e=="popupmultiselect"){if(p.helperButtonWidth!=0){p.style.width="auto";}}else{if(e!="checkbox"&&e!="summary"&&p.firstChild&&p.firstChild.style&&p.helperButtonWidth!=0){var m=b.clientWidth-p.helperButtonWidth-6;p.firstChild.style.width=(m>=30?m:30);}else{if(o.isPopupSelect(p)){var m=b.clientWidth-15;p.firstChild.style.width=(m>=50?m:50);p.lastChild.style.top="3px";var u=p.getElementsByTagName("SPAN");for(var n=0;n<u.length;n++){if(u[n].className.indexOf("fwpopupsel_pos")>=0){u[n].style.top="0px";break;}}}}}if(g&&(e=="select"||e=="slaveselect")){if(o.layoutdd){if(p.helperButtonWidth){var m=b.offsetWidth-p.helperButtonWidth-10;o.layoutdd.inpt.style.width=(m>=30?m:30);}else{o.layoutdd.inpt.style.width="100%";}setTimeout(new Function("this.relayout("+(window.loadcomplete==true&&document.page_is_resetting!=true&&q!=false)+"==true)").bind(o),100);}}if(e=="fieldset"){l.style.border="0";var k=document.createElement("DIV");k.id="fieldset_options_div";window.fieldSetDiv=k;k.style.borderStyle="solid";k.style.borderWidth=1;k.style.borderColor="#999999";k.style.backgroundColor="#EFEFEF";k.style.className="fieldset";k.style.position="absolute";var v=document.createElement("DIV");k.appendChild(v);v.style.padding=5;v.style.borderStyle="solid";v.style.borderWidth=1;v.style.borderColor="#FFFFFF #CCCCCC #CCCCCC #FFFFFF";var a=document.createElement("INPUT");a.type="button";a.name="done";a.id=o.name+"_fldsetbutton_done";a.value="Done";a.className="nlbuttontiny";a.onclick=new Function("evnt",o.getFieldSetDoneAction());p.style.paddingBottom="5";v.appendChild(p);v.appendChild(a);if(o.getFieldSetIncludesCancelButton()){var t=document.createElement("INPUT");t.type="button";t.name="cancel";t.id=o.name+"_fldsetbutton_cancel";t.value="Cancel";t.className="nlbuttontiny";t.onclick=new Function("evnt",o.name+"_machine.clearline(true); setEventCancelBubble(evnt); return false;");var d=document.createElement("IMG");d.src="/images/nav/stretch.gif";d.height=10;d.width=8;d.border=0;v.appendChild(d);v.appendChild(t);}img=document.createElement("IMG");img.border=0;img.src="/images/reportbuilder/fieldsetdown.gif";img.height="16";img.width="17";img.style.position="relative";img.style.zIndex=10000;img.style.top=1;h.appendChild(img);h.appendChild(k);o.positionFieldsetDiv(k,b,img);setTimeout(function(){o.positionFieldsetDiv(k,b,img);},300);}b.origClassName=b.className;};Machine.prototype.positionFieldsetDiv=function NLMachine_positionFieldsetDiv(d,a,b){var e=0;var c=b.offsetHeight;if((findPosX(b)+d.offsetWidth)>(getDocumentClientWidth()+document.body.scrollLeft)){e=b.offsetWidth-d.offsetWidth;}if((findPosY(b)+b.offsetHeight+d.offsetHeight)>(getDocumentClientHeight()+document.body.scrollTop)){c=-d.offsetHeight;b.src="/images/reportbuilder/fieldsetdown_above.gif";}d.style.left=e;d.style.top=c;};Machine.prototype.createGrippyCell=function Machine_createGrippyCell(){var a=null;if(this.allowMoveLines){a=document.createElement("TD");a.style.width="5px";a.className="smalltext listheadertdleft";}return a;};Machine.prototype.createDeleteCell=function Machine_createDeleteCell(c){var a=null;if(this.allowQuickDeleteLines){a=document.createElement("TD");a.className="listheadertdright";var b=document.createElement("IMG");b.border=0;var d=this.isRowRequired(c);b.src="/images/icons/controls/machine_x"+(d?"_dis":"")+".gif";if(!d){b.onclick=new Function(this.name+"_machine.deleteline("+(c)+");setMachineChanged('"+this.name+"');return false;");a.style.cursor="hand";}a.appendChild(b);a.style.width="14px";a.valign="middle";}return a;};Machine.prototype.createColumnHeaderCell=function Machine_createColumnHeaderCell(a,b){cell=document.createElement("TD");cell.className="listheadertd";if(this.allWhiteDisplayMode){cell.className+="wht";}else{if(b){cell.className+="left";}}cell.className+=" listheadertextb";var c=document.createElement("div");c.className="listheader";if(this.allWhiteDisplayMode){c.className+="wht";}c.innerHTML=a;cell.appendChild(c);return cell;};Machine.prototype.createFocusElement=function NLMachine_createFocusElement(){var a=document.createElement("DIV");a.style.width="1px";a.style.height="1px";a.style.border="none";a.style.position="absolute";a.tabIndex=0;this.focusElement=document.createElement("A");this.focusElement.tabIndex=0;a.appendChild(this.focusElement);this.tableobj.parentNode.appendChild(a);};Machine.prototype.transferInputFieldValuesToDisplayOnly=function Machine_transferInputFieldValuesToDisplayOnly(){var l=this.currentRowNum;var n=this.tableobj;var p=n.getElementsByTagName("tr");if((!this.allow_insert&&this.getNumOfRows()==0)||l==0){return;}if((p.length-(this.isCurrentlySegmented&&(this.segmentStartIndex!=this.lastStartSegmentIndex)?3:0))<=l){return;}var o=p[l];var b=this.getFormFieldNames();var a=this.getInputElements(false,b);var d=-1+(this.showRowNumbers?1:0)+(this.allowMoveLines?1:0);var g=false;for(var e=0;e<a.length;e++){var k=null;var h=null;var f=this.getFieldOverride(a,o,l,e);if(f){k=f==null?null:f[0];h=f==null?null:f[1];}else{k=a[e];h=(g)?this.getFormElementLabel(e-1):this.getFormElementLabel(e);}if((h==null)||(h.length==0)||this.getFormElementFieldSet(e).length>0){continue;}if(!g){++d;}g=this.isElementPopupDisplayField(e);var m=o.cells[d];if((k)&&this.isNeedUpdateFieldDisplayValue(k)){var c=this.getDisplayHTMLOfField(k.indexOfEditor);this.updateCellContent(m,e,k.indexOfEditor,c,l);}}this.adjustButtonPosition();};Machine.prototype.getDisplayHTMLOfField=function Machine_getDisplayHTMLOfField(d){var e="";var c=this.getFormElementType(d);var a=this.getFormElement(d);if(c=="select"||c=="slaveselect"){if(d>0&&this.isElementPopupDisplayField(d-1)){e=(a.value.length==0?"":this.getFormElement(d-1).value);}else{e=getFormValue(a);}}else{if(c=="checkbox"){e=getCheckboxState(a)?"T":"F";}else{if(c=="radio"){for(var b=0;b<a.length;b++){if(a[b].checked){e=a[b].value;}}}else{if(c=="integer"&&d>0&&this.isElementPopupDisplayField(d-1)){e=(a.value.length==0?"":this.getFormElement(d-1).value);}else{if(c=="address"||c=="textarea"){if(a.value!=null){var f=a.value.split(/\r?\n/);e=f.join(String.fromCharCode(5));}else{a=a[0];var f=a.value.split(/\r?\n/);e=f.join(String.fromCharCode(5));}}else{if(c!="fieldset"){e=a.value;}}}}}}return e;};Machine.prototype.relayout=function Machine_relayout(a){this.layoutdd.setText(null,a==false?true:false,null);};Machine.prototype.adjustButtonPosition=function NLMachine_adjustButtonPosition(){if(!this.isinline){return;}};function putButtonsInMachine(b,h,g){if(h.hasButton||!b.moveButtons){return;}var a=b.name;var e=getButtonDiv(a);e.parentNode.removeChild(e);e.style.padding="0 2";var f=1+h.rowIndex;var c=g.insertRow(f);if(b.allowMoveLines){c.onselectstart=OrderedListCancelDragDrop;}var k=g.getElementsByTagName("tr");var d=c.insertCell(0);d.colSpan=Math.max(k[0].cells.length,1);d.className="machineButtonRow";showButtonsInMachine(b.showButtons,d,e);h.hasButton=true;}function showButtonsInMachine(a,c,b){b.style.visibility="hidden";if(this.buttonRowAnimation){this.buttonRowAnimation.stop();}if(!a){b.style.display="none";c.appendChild(b);return;}b.style.height="1px";b.style.overflow="hidden";b.style.display="block";b.style.visibility="";c.appendChild(b);setTimeout(function(){doShowButtonsInMachine(a,c,b);},0);}function doShowButtonsInMachine(b,d,c){var a=getRuntimeStyle(c.children[0],"height");this.buttonRowAnimation=nlGetHeightAnimation(c,1,a,150,onFinishshowButtonsInMachine);this.buttonRowAnimation.start();}function onFinishshowButtonsInMachine(c,a,b){if(a){a.style.overflow="";}}function Mch_setUpEventHandlerInterception(f,d,c){var a=(c=="namevaluelist")?d.form.elements[d.name+"_display"]:d;if(true){a.originalOnChange=a.onchange?a.onchange:null;a.handleChange=MachineField_handleChange;a.machine=f;a.onchange=new Function("this.handleChange();");}var e=d.childNodes;if(e!=null){for(var b=0;b<e.length;b++){if(e[b].nodeType==1){Mch_setUpEventHandlerInterception(f,e[b],c);}}}}function addDragDropHandlersToRow(c,b,a){b.machineName=c;if(a){b.selectedRow=true;b.firstChild.style.cursor="move";}b.onmousedown=Machine_OnMouseDown;b.onmousemove=OrderedListOnMouseMove;b.onselectstart=OrderedListCancelDragDrop;}function cleanUpCellContents(a){while(a.firstChild!=null){a.removeChild(a.firstChild);}}function NLMachine_doSetBackground(a,b){if(a.getAttribute("sCurrentBackground")!=b){a.style.background=b;a.setAttribute("sCurrentBackground",b);}}function NLMachine_deferredSetBackgroundStyle(a,b){if(window.loadcomplete){NLMachine_doSetBackground(a,b);}else{setTimeout(function(){NLMachine_doSetBackground(a,b);},1);}}function Machine_reparent(c,b){Machine_hideField(c);var a=c.parentNode;storeCheckboxState(c);a.removeChild(c);b.appendChild(c);restoreCheckboxState(c);}function setWidth(b,c){b.style.width=c;if(b.className=="dropdownInput"){var a=getDropdown(b);a.setText(a.getText(),true,c);}}function tweakTable(a){var b=document.getElementById(a);b.style.tableLayout="fixed";b.style.tableLayout="auto";}function Machine_hideField(a){a.style.display="none";}function Machine_showField(a){a.style.display="block";}function NLMachine_updateTextAreaSize(e){var c=e.value+".";var d=c.split("\n");var f=d.length;var b=f;for(var a=0;a<f;a++){b+=parseInt(((d[a]).length/25));}b++;if(b<3){b=3;}else{if(b>20){b=20;e.style.overflow="scroll";}else{e.style.overflow="hidden";}}if(b>0){e.rows=b;}}var s_machineKeyDown=NLMachine_EditFieldOnKeyDown;var s_docKeyDown=document.onkeydown;var mchMachineWithFocus=null;if(s_docKeyDown==null){document.onkeydown=s_machineKeyDown;}else{document.onkeydown=function(a){s_machineKeyDown(a);s_docKeyDown(a);};}var ACTIVE_LINE_HEIGHT=18+8;function NLMachine_safeSetFocus(a){setFieldFocus(a);if(document.activeElement!=a){setTimeout(function(){setFieldFocus(a);},0);}}function NLMachine_EditFieldOnKeyDown(e){var a=getEventKeypress(e);if(a==9){if(window.popupDIV||(popupAutoSuggest&&popupAutoSuggest.visible)){return;}var b=Machine_getParentDIV(getEventTarget(e));if(mchMachineWithFocus||(b&&b.className=="divhover")){var c=mchMachineWithFocus;if(!c){c=b.sourceMachine;mchMachineWithFocus=c;}var d=(getEventShiftKey(e))?-1:1;if(c.isinline&&c.gotoField(d)){setEventPreventDefault(e);setEventCancelBubble(e);return false;}else{mchMachineWithFocus=null;return true;}}}}function NLMachine_onMouseUp(b){var a=Machine_getParentTABLE(getEventTarget(b));if(a&&a.machine){mchMachineWithFocus=a.machine;}else{mchMachineWithFocus=null;}}function Machine_OnMouseDown(b){var a=getEventTarget(b);if(a.nodeName=="IMG"){return;}OrderedListOnMouseDown(b);}function handleTab(b,a){if(getEventKeypress(b)==9&&!getEventShiftKey(b)){setTimeout(a,1);}}Machine.prototype.enterKeyHandleField=function Machine_enterKeyHandleField(){this.enterKeyPressed=true;var c;var b=false;window.lastKeyStroke=13;if(c=this.isFieldEditable(this.focusedColumn)){b=isSelect(c);if(isPopupSelect(c)||isPopupMultiSelect(c)){c=NLPopupSelect_getDisplayFieldByValueInput(c);}if(c.onblur){c.onblur();}if(!b&&c.onchange){c.onchange();}}var a=b||c.isvalid;if(window.lastKeyStroke==-1){a=false;this.enterKeyPressed=false;}else{window.lastKeyStroke=-1;}return a;};Machine.prototype.doAddEdit=function Machine_doAddEdit(b){focusDefaultButton(this);if(!window.isvalid){return false;}var a=0;if(this.enterKeyPressed){a=200;}if((a==0)||(typeof this.name=="undefined")){if(this.addline(b)){setWindowChanged(window,true);}}else{setTimeout("if (window.machines['"+this.name+"'].addline("+b+")) setWindowChanged(window, true);",a);this.enterKeyPressed=false;}};Machine.prototype.copyline=function Machine_copyline(){if(!window.isinited){return false;}var linenum=parseInt(this.getMachineIndex());if(linenum==this.getNextIndex()){linenum-=1;}else{if(this.ischanged){this.addline();}else{this.clearline();}}this.loadline(linenum,true);for(var i=0;i<this.countFormElements();i++){if(this.getFormElementType(i)=="slaveselect"){eval(getSyncFunctionName(this.getFormElementName(i),this.name)+"(true, "+(linenum-1).toString()+", true);");}}this.synclinefields();if(this.isRecordManagerUsed()){this.dataManager.setInitialFieldValues(this.getLineData(),this.dataManager.activeRowIdx);}this.buildtable();this.ischanged=true;this.isinserting=false;return true;};Machine.prototype.insertline=function Machine_insertline(){if(!window.isinited){return false;}var a=parseInt(this.getMachineIndex())-1;if(this.ischanged){this.addline();}if(!this.nlapivalidateinsert()){return false;}if(!this.validateinsert()){return false;}if(a+1==this.getNextIndex()){return false;}this.insertLine(null,a+1);this.incrementIndex();this.recalcType="insert";this.recalc();var b=a+1;this.clearline(false);this.setMachineIndex(b);this.isinserting=true;this.ischanged=true;this.getsyncline(a);this.buildtable();return true;};Machine.prototype.deleteline=function Machine_deleteline(a){if(!window.isinited){return false;}this.isdeleting=true;if(!this.nlapivalidatedelete()){return false;}if(!this.validatedelete()){return false;}if(!a){a=parseInt(this.getMachineIndex());}a-=1;if(a+1==this.getNextIndex()){return false;}this.dataManager.removeLine(a+1);this.decrementIndex();this.recalcType="remove";this.recalc();this.isinserting=false;if(a<parseInt(this.getNextIndex())-1){this.ischanged=false;this.viewline(a+1);}else{this.clearline(false,this.isCurrentlySegmented?(this.lastStartSegmentIndex==this.segmentStartIndex&&this.getNextIndex()-1<this.lastStartSegmentIndex+min_segment_size?Math.max(1,this.lastStartSegmentIndex-max_segment_size):this.lastStartSegmentIndex):null);this.getsyncline(0);}this.isdeleting=false;this.postdeleteline();this.waschanged=true;return true;};Machine.prototype.moveline=function Machine_moveline(a){if(!window.isinited){return false;}linenum=parseInt(this.getMachineIndex())-1;if(linenum+1==this.getNextIndex()){return false;}if((linenum==0&&a==-1)||(linenum+1==parseInt(this.getNextIndex())-1&&a==1)){return false;}this.movelineto(linenum+a+1);return true;};Machine.prototype.movelineto=function Machine_movelineto(a,b){if(!window.isinited){return false;}a-=1;linenum=parseInt(this.getMachineIndex())-1;if(linenum+1==this.getNextIndex()){return false;}this.setLinePosition(a,linenum);this.setMachineIndex(a+1);if(!b){this.recalcType="move";this.recalc();this.buildtable();}return true;};Machine.prototype.moveLineToTopOrBottom=function Machine_moveLineToTopOrBottom(b){var a=!b;if(!window.isinited){return false;}linenum=parseInt(this.getMachineIndex())-1;if(b&&linenum==0){return;}if(a&&linenum+1==this.getNextIndex()-1){return false;}this.movelineto(b?1:this.getLineCount());return true;};Machine.prototype.clearline=function Machine_clearline(sync,startSegmentIndex){if(!window.isinited){return false;}if(this.isinserting){return this.deleteline();}else{this.dataManager.cancelLineChanges();}this.setColToFirstEditable();var oldidx=this.getAdjustedSegmentIndex(this.getMachineIndex(),false);if(this.getFormName()=="main_form"){for(var i=0;i<this.countFormElements();i++){var elem=this.getFormElement(i);elem.value="";if(isNLDropDown(elem)||isNLMultiDropDown(elem)){var dropdown=getDropdown(elem);if(dropdown){dropdown.resetDropDown();}}}}else{this.miniform.reset();if(typeof(resetNLDropDowns)!="undefined"){resetNLDropDowns(this.miniform);}}if(!sync){for(var i=0;i<this.countFormElements();i++){if(this.getFormElementType(i)=="slaveselect"){deleteAllSelectOptions(this.getFormElement(i));}}}for(var i=0;i<this.countFormElements();i++){if(this.getFormElementType(i)=="checkbox"){NLCheckboxOnChange(this.getFormElement(i));}}this.setMachineIndex(this.getNextIndex());if(sync){for(var i=0;i<this.countFormElements();i++){if(this.getFormElementFieldSet(i)&&this.getFormElementFieldSet(i)==""&&this.getFormElementType(i)=="slaveselect"){eval(getSyncFunctionName(this.getFormElementName(i),this.name)+"(true,null,true);");}}}for(var i=0;i<this.countFormElements();i++){if((this.getFormElementType(i)=="text"||this.getFormElementType(i)=="textarea")&&this.isElementPopupDisplayField(i)&&i<this.countFormElements()-1&&(this.getFormElementType(i+1)=="integer"&&isSelect(this.getFormElement(i+1)))){setFormValue(this.getFormElement(i),getSelectText(this.getFormElement(i+1)));}}this.synclinefields();this.setColToFirstEditable();this.buildtable(startSegmentIndex);this.ischanged=false;this.isinserting=false;};Machine.prototype.viewline=function Machine_viewline(b,f,e){if(!e&&!window.isinited){return false;}if(this.isCurrentlySegmented&&b<this.getNextIndex()&&(b<this.segmentStartIndex||b>=(this.segmentStartIndex+max_segment_size+(this.segmentStartIndex==this.lastStartSegmentIndex?min_segment_size:0)))){var d=b>=this.lastStartSegmentIndex+max_segment_size?b-min_segment_size:b;var a=Math.floor((d-1)/max_segment_size)*max_segment_size+1;this.segmentStartIndex=Math.max(1,a);}var c=this.getSegmentAdjustedRowNum();if(b==c&&!this.isdeleting&&this.isinline){if(this.focusedColumn==f){return false;}else{this.gotoField(f,true);return true;}}else{if(!this.isdeleting){if(this.autoEdit&&this.ischanged){if(!this.addline()){return false;}}}}if(f!=null&&f>=0){this.focusedColumn=f;}else{this.setColToFirstEditable(true);}if(!this.preSelectRow(b)){return;}this.setupLineData(b);this.buildtable();this.ischanged=false;this.isinserting=false;};Machine.prototype.addline=function Machine_addline(f){if(this.isCurrentlySegmented){f=true;}if(!window.isinited){return false;}var c=parseInt(this.getMachineIndex());var h=parseInt(this.getMaxIndex());if(!this.allow_insert&&h<c+1){alert("Please choose a line to edit");return false;}if(!this.nlapivalidateline()){return false;}if(!this.validateline()){return false;}var d;var a=new Array();var g=new Array();var b=true;for(d=0;d<this.countFormElements();d++){if(((this.isElementRequired(d)&&this.isMandatoryOnThisLine(c,d))||(this.getFormElementType(d)=="namevaluelist"&&this.getFormElement(d).value.length>0))&&this.doCheckMandatoryData(this.getFormElement(d).name,c)){a[a.length]=this.getFormElement(d);g[g.length]=this.getElementDisplayLabel(d);}if(b&&!isempty(this.getFormElement(d))){b=false;}}if(a.length>0){var e=checkMandatoryFields(a,g);if(e.length!=0){if(e.indexOf(",")!=-1){alert("Please enter value(s) for: "+e);}else{alert("Please enter a value for "+e);}return false;}}if(b){alert("Please enter a value into at least one field before adding the row.");return false;}if(this.uniquefield!=null&&!this.checkunique()){return false;}this.updateLineData();if(this.preferredfield!=null){this.setPreferredValue(c);}this.recalcType="commit";this.recalc();this.isinserting=false;if(f==true&&c<this.getNextIndex()-1){this.ischanged=false;this.viewline(c+1);this.postprocessline(c);this.nlapilinecommit(c);}else{this.clearline(false);this.postprocessline(c);this.nlapilinecommit(c);this.getsyncline(c-1);}this.waschanged=true;return true;};Machine.prototype.isMandatoryOnThisLine=function Machine_isMandatoryOnThisLine(b,a){var c=false;if(this.miniform.elements["mandatory"+this.getFormElementName(a)]){c=this.miniform.elements["mandatory"+this.getFormElementName(a)].value!="F";}else{if(hasEncodedField(this.name,"mandatory"+this.getFormElement(a).name)){c=getEncodedValue(this.name,b,"mandatory"+this.getFormElement(a).name)!="F";}else{if(this.getFormElement(a)!=null){c=getRequired(this.getFormElement(a));}}}return c;};Machine.prototype.getsyncline=function Machine_getsyncline(line){if(window.virtualBrowser){return;}var syncline="";for(var i=0;i<this.countFormElements();i++){if((this.getFormElementType(i)=="select"||this.getFormElementType(i)=="slaveselect"||(this.getFormElementType(i)=="integer"&&i>0&&this.isElementPopupDisplayField(i-1)))&&!isMultiSelect(this.getFormElement(i))){var elem=this.getFormElement(i);var val=getSelectValue(elem);if((val!=null)&&(val.length>0)){syncline+=getSyncFunctionName(elem.name,this.name)+"(true,"+line+");";}}}if(syncline.length>0){eval(syncline);}};Machine.prototype.checkunique=function Machine_checkunique(){var b=new Array(this.uniquefield);var a=new Array(window.virtualBrowser?this.uniquefield:this.getElementDisplayLabel(this.getArrayPosition(this.uniquefield)));if(this.uniquefield2!=null){b.push(this.uniquefield2);a.push(window.virtualBrowser?this.uniquefield2:this.getElementDisplayLabel(this.getArrayPosition(this.uniquefield2)));}var c=checkUniqueFields(this.name,b,a);if(c!=null&&c.length>0){alert(c.join("/")+" must be unique");return false;}return true;};Machine.prototype.checkMandatoryData=function Machine_checkMandatoryData(e){var a="";for(var c=0;c<this.countFormElements();c++){if(this.isElementRequired(c)&&this.getFormElement(c).name!=e){var h=this.getFormElement(c);for(var d=1;d<this.getMachineIndex();d++){if(this.doCheckMandatoryData(h.name,d)&&getEncodedValue(this.name,d,"mandatory"+h.name)!="F"&&getEncodedValue(this.name,d,h.name).length==0){a+=(a.length!=0?", ":"")+this.getElementDisplayLabel(c)+" (on line "+d+")";break;}}}else{if(this.getFormElementType(c)=="namevaluelist"){var h=this.getFormElement(c);var k=new Array();for(var d=1;d<this.getMachineIndex();d++){var g=getEncodedValue(this.name,d,h.name).split(String.fromCharCode(4));for(var b=0;b<g.length;b++){var f=g[b].split(String.fromCharCode(3));if(f[1]=="T"&&!(k[f[0]]==true)){if(f[3].length==0){a+=(a.length!=0?",":"")+f[2];k[f[0]]=true;}}}}}}}if(a.length>0){if(a.indexOf(",")!=-1){alert("Please enter value(s) for: "+a);}else{alert("Please enter a value for "+a);}return false;}else{return true;}};Machine.prototype.setFocus=function Machine_setFocus(a,b){if(!b&&window.loadcomplete!=true){return;}if(document.page_is_resetting){return;}mchMachineWithFocus=this;if(!a){this.setColToFirstEditable();a=this.focusedColumn;}var d;if(d=this.isFieldEditable(a)){var c=(d.type!="textarea"||d.value.length==0);d.mch=this;setTimeout(function(){doSetFocusStatic(d,c);},0);}};Machine.prototype.gotoFieldWithName=function Machine_gotoFieldWithName(b){var a=this.getArrayPosition(b);this.gotoField(a,true);this.setFocus(this.focusedColumn,true);};Machine.prototype.gotoField=function Machine_gotoField(k,b){var e=this.focusedColumn;var g=false;if(b){this.focusedColumn=k;}else{this.focusedColumn=this.getFieldOffset(this.focusedColumn,k);if(e==this.focusedColumn){if(e<this.countFormElements()&&this.getFormElementType(e)=="fieldset"){this.focusedColumn=this.getFieldOffset(-1,k);}}}if(e==this.focusedColumn){return false;}var a=this.getInputElements(true);for(var c=0;c<a.length;c++){var f=null;var d=this.getFieldOverride(a,this.tableobj.getElementsByTagName("tr")[this.currentRowNum],this.currentRowNum,c);if(d){f=d[0];}else{f=a[c];}if(f==null||(this.getFormElementFieldSet(c)&&this.getFormElementFieldSet(c).length>0)){continue;}var h=f.parentNode;if(h!=this.miniform&&!this.bShowAllEditedFields){if(!Mch_callAllOnBlur(this,f)){this.focusedColumn=e;return true;}h=Machine_getParentTD(h);Machine_reparent(f,this.miniform);if(h.origPaddingTop){h.style.paddingTop=h.origPaddingTop;}if(h.origPaddingRight){h.style.paddingRight=h.origPaddingRight;}if(h.origPaddingBottom){h.style.paddingBottom=h.origPaddingBottom;}if(h.origPaddingLeft){h.style.paddingLeft=h.origPaddingLeft;}h.className=h.origClassName;h.height="";}}if(!g){this.editRow(this.currentRowNum,true);}this.transferInputFieldValuesToDisplayOnly();return true;};Machine.prototype.sort=function Machine_sort(a){if(!window.isinited){return false;}if(a==this.sortIndex){this.sortDirUp=!this.sortDirUp;}else{this.sortDirUp=true;}this.sortIndex=a;var d=this.getFormElementType(a);window.status=this.sortIndex+" "+d;var b=getLineArray(this.name);var k=new Array();var e;var f="";for(e=0;e<b.length;e++){var h=splitIntoCells(b[e]);var c=h[a];if(d=="select"){c=getlisttext(this.getFormElement(a),c);}f+=c+" ";k[e]=new machine_line(c,d,this.sortDirUp,e);}k.sort(Machine_sortlines);var g=new Array();for(e=0;e<b.length;e++){g[e]=b[k[e].idx];}setLineArray(this.name,g);this.buildtable();};function machine_line(d,b,c,a){this.val=d;this.dir_up=c;this.type=b;this.idx=a;}function Machine_sortlines(c,b){var a=l_sortnodes2(c.val,b.val,c.type.toUpperCase())*(c.dir_up?1:-1);return a;}function Mch_callAllOnBlur(f,d){var c=true;if(d.onblur){var b=false;if(d.type=="textarea"){b=true;d.isvalid=true;}f.applyFocusToFocusElement();if(d.isvalid==false){c=false;}if(b){d.isvalid=null;}}var e=d.childNodes;if(e!=null){for(var a=0;a<e.length;a++){if(!Mch_callAllOnBlur(f,e[a])){c=false;break;}}}return c;}function MachineField_handleBlur(){return this.originalOnBlur();}function MachineField_handleChange(){var a=false;if(this.originalOnChange){a=this.originalOnChange();if(a!=false&&this.machine&&this.machine.dataManager&&this.machine.dataManager.setFieldValue){this.machine.dataManager.setFieldValue(this.name,this.value);}}Machine_scheduleTransfer(this.machine);return a;}var pTransferTimeouts=new Object();function Machine_doDelayedTransfer(sMachineName,bForce){if(!window.isinited||bForce){var timerID=pTransferTimeouts[sMachineName];if(timerID){clearTimeout(timerID);}pTransferTimeouts[sMachineName]=setTimeout("Machine_doDelayedTransfer('"+sMachineName+"');",100);}else{eval(sMachineName+"_machine.transferInputFieldValuesToDisplayOnly();");}}function Machine_scheduleTransfer(a){a.transferInputFieldValuesToDisplayOnly();Machine_doDelayedTransfer(a.name,true);}function doSetFocusStatic(a,c){try{if(a.mch!=mchMachineWithFocus){return;}NLMachine_safeSetFocus(a);if(c){if(isPopupSelect(a)||isPopupMultiSelect(a)){var b=NLPopupSelect_getDisplayFieldByValueInput(a);if(b&&a.value.length>0){b.select();}}else{a.select();}}}catch(d){}}function Machine_getParentTD(a){while(a.parentNode!=null&&a.parentNode.nodeName!="TD"){a=a.parentNode;}return a.parentNode;}function Machine_getParentTABLE(a){while(a.parentNode!=null&&a.parentNode.nodeName!="TABLE"){a=a.parentNode;}return a.parentNode;}function Machine_getParentDIV(a){while(a.parentNode!=null&&a.parentNode.nodeName!="DIV"){a=a.parentNode;}return a.parentNode;}Machine.prototype.updateMachineData=function Machine_updateMachineData(f,d){if(!isArray(f)){return;}var a=this.getLineArray(this.name);for(var c=0;c<f.length;c++){var e=f[c]["row"];if(e==null){e=this.getMachineIndex();}var b=splitIntoCells(a[e-1]);for(col in f[c]){if(col=="row"){continue;}var g=this.getArrayPosition(col);b[g]=f[c][col];}a[e-1]=b;}this.setLineArray(a,doGetFieldNamesArray(this.name));this.loadline(this.getMachineIndex());this.buildtable(null,d);};Machine.prototype.setContentUpdated=function Machine_updateContent(a){this.bContentUpdated=a;};Machine.prototype.updateContent=function Machine_updateContent(){};Machine.prototype.updateDataManager=function Machine_updateDataManager(){doClearLineArray(this.name);var a=doGetLineArray(this.name);var c=new Array();for(var b=0;b<a.length;b++){c[b]=doGetLineArrayLine(this.name,b);}this.setLineArray(c,doGetFieldNamesArray(this.name));};Machine.prototype.setupLineData=function Machine_setupLineData(linenum,iscopy){if(linenum<=0){return;}var numRows=this.getNumRows();if(numRows<=0){return;}if(linenum>numRows){linenum=numRows;}this.loadline(linenum,iscopy);this.setMachineIndex(linenum);for(var i=0;i<this.countFormElements();i++){if(this.getFormElementType(i)=="slaveselect"){eval(getSyncFunctionName(this.getFormElementName(i),this.name)+"(true, "+(linenum-1).toString()+", true);");}}this.synclinefields();};Machine.prototype.loadline=function Machine_loadline(b,d){var f;linedata=this.getLineArrayLine(b-1);for(f=0;f<this.countFormElements();f++){if(d==true&&this.isElementNoCopy(f)){continue;}var e=this.getFormElementType(f);var c=this.getFormElement(f);if(e=="select"||e=="slaveselect"){if(isMultiSelect(c)||isPopupMultiSelect(c)){syncmultiselectlist(c,linedata[f],(f>0&&this.isElementPopupDisplayField(f-1))?linedata[f-1]:null,true);}else{synclist(c,linedata[f],false);}}else{if(e=="radio"){syncradio(c,linedata[f],false);}else{if(e=="address"||e=="textarea"){var a=linedata[f].split(String.fromCharCode(5));c.value=a.join("\n");}else{if(e=="currency"){c.value=format_currency(parseFloat(linedata[f]));}else{if(e=="currency2"||e=="rate"){c.value=format_rate(parseFloat(linedata[f]),linedata[f].indexOf("%")!=-1);}else{if(e=="checkbox"){setNLCheckboxValue(c,(linedata[f]=="T"));}else{if(e=="namevaluelist"){c.value=linedata[f];syncnamevaluelist(c);}else{if(e=="fieldset_inline"){setInlineTextValue(document.getElementById(this.getFormElementName(f)+"_val"),linedata[f]);}else{if(isSelect(c)){synclist(c,linedata[f],false);}else{if(e=="color"){c.value=linedata[f];document.getElementById(c.name+"_chip").style.backgroundColor=linedata[f].length>0?linedata[f]:"#FFFFFF";}else{if(e!="fieldset"){c.value=linedata[f];if(isCheckboxImageField(c)){c.onclick();}if(this.isElementPopupDisplayField(f)){c.setAttribute("previousvalue",c.value);}}}}}}}}}}}}}};Machine.prototype.insertdata=function Machine_insertdata(b,a){this.dataManager.insertLines(newlinearray=splitIntoRows(b),a);var c=this.getNumRows();this.setIndex(c+1);this.setMachineIndex(c+1);return true;};Machine.prototype.getLineData=function Machine_getLineData(g){var d=this.countFormElements();var n=new Array();for(var f=0;f<d;f++){var m=this.getFormElementType(f);var a=this.getFormElementName(f);var l=this.getFormElement(f,g);if(!l){n[f]=null;}else{if(m=="select"||m=="slaveselect"){if(isMultiSelect(l)||isPopupMultiSelect(l)){n[f]=getMultiSelectValues(l);}else{n[f]=getSelectValue(l);}}else{if(m=="checkbox"){n[f]=l.checked?"T":"F";}else{if(m=="radio"){for(var e=0;e<l.length;e++){if(l[e].checked){n[f]=l[e].value;}}}else{if((m=="text"||m=="textarea")&&this.isElementPopupDisplayField(f)&&f<this.countFormElements()-1&&(this.getFormElementType(f+1)=="integer"||this.getFormElementType(f+1)=="slaveselect")&&this.getFormElement(f+1).value.length==0){n[f]="";}else{if(m=="address"||m=="textarea"){n[f]=(typeof l.value=="undefined"||l.value==null)?"":l.value.replace(/\r/g,"").replace(/\n/g,String.fromCharCode(5));}else{if(m=="fieldset_inline"){n[f]=getInlineTextValue(document.getElementById(this.getFormElementName(f)+"_val"));}else{if(m!="fieldset"){n[f]=l.value;}}}}}}}}if(l!=null&&this.getFormElementFieldSet&&this.getFormElementFieldSet(f).length>0){var h=this.name+"_"+(a.indexOf("_display")==-1?a:this.getFormElementName(f+1))+"_fs";var c=document.getElementById(h);if(c!=null&&c.style.display=="none"){n[f]="";}}if(n[f]!=null){var k=new RegExp("["+String.fromCharCode(1)+String.fromCharCode(2)+"]","g");n[f]=new String(n[f]).replace(k,".");}if(window.virtualBrowser){var b=parseInt(this.getMachineIndex());setEncodedValue(this.name,b,a,n[f]!=null?n[f]:"");}}return n;};Machine.prototype.updateLineData=function Machine_updateLineData(){var b=parseInt(this.getMachineIndex());var c=this.getLineArray(this.name);var e=c==null?new Array():c;var a=this.getLineData();this.setLineArrayLine(a,b);var d=parseInt(this.getNextIndex());if(d<b+1){this.setIndex((b+1).toString());}};Machine.prototype.updateDependentFieldValues=function Machine_updateDependentFieldValues(a){var b=this.getLineData(a);if(this.dataManager.updateDependentFieldValues){if(typeof a=="undefined"||a==null){a=this.getMachineIndex();}this.dataManager.updateDependentFieldValues(b,a-1);}};Machine.prototype.getLineFieldValue=function Machine_getLineFieldValue(b,a){var c=this.getArrayPosition(a);if(c==-1){return false;}return b!=null&&b.length>c?b[c]:null;};Machine.prototype.setMainFormData=function Machine_setMainFormData(a){this.mainform.elements[this.name+"data"].value=a;this.waschanged=true;};Machine.prototype.getMainFormData=function Machine_getMainFormData(){return this.mainform.elements[this.name+"data"].value;};var MACHINE_NAME_PREPEND="mch_";window.linearrayArray=new Array();Machine.prototype.isRowRequired=function Machine_isRowRequired(a){if(this.addOnly()){return true;}return this.dataManager.isLineRequired(a);};Machine.prototype.getNumRows=function Machine_getNumRows(){return this.dataManager.getNumRows();};Machine.prototype.getLineCount=function Machine_getLineCount(){return this.dataManager.getNumRows();};Machine.prototype.getNumOfRows=function Machine_getNumOfRows(){return this.getLineCount();};Machine.prototype.getLineArray=function Machine_getLineArray(){return this.dataManager.getLineArray();};Machine.prototype.setLineArray=function Machine_setLineArray(b,a){this.dataManager.setLineArray(b,a);};Machine.prototype.getLineArrayLine=function Machine_getLineArrayLine(a){return this.dataManager.getLineArrayLine(a);};Machine.prototype.setLineArrayLine=function Machine_setLineArrayLine(a,b){this.dataManager.setLineArrayLine(b,a);};Machine.prototype.hasLineArray=function Machine_hasLineArray(){return this.dataManager.hasLineArray();};Machine.prototype.clearLineArray=function Machine_clearLineArray(){this.dataManager.clearLineArray();};Machine.prototype.insertLine=function Machine_insertLine(b,a){this.dataManager.insertLine(b,a);};Machine.prototype.saveLine=function Machine_saveLine(a){this.dataManager.saveLine(linedata,a);};Machine.prototype.setLinePosition=function Machine_setLinePosition(b,a){this.dataManager.setLinePosition(b,a);};Machine.prototype.writeLineArray=function Machine_writeLineArray(){this.dataManager.writeLineArray();};Machine.prototype.getFieldValue=function Machine_getFieldValue(a,c,b){return this.dataManager.getLineFieldValue(a,c,b&&this.canUseOldFieldValue(c));};Machine.prototype.findEncodedValue=function Machine_findFieldValueLineNum(a,b,c){return this.dataManager.findFieldValueLineNum(a,b,c&&this.canUseOldFieldValue(this.getMachineIndex()));};Machine.prototype.setFieldValue=function Machine_setFieldValue(b,a,c){this.dataManager.setLineFieldValue(a,c,b);};Machine.prototype.setFieldInputValue=function Machine_setFieldInputValue(b,c,d,a){this.dataManager.setFieldInputValue(b,c,a,d);};Machine.prototype.setEncodedValues=function Machine_setEncodedValues(a,b){doSetEncodedValues(this.name,a,b);};Machine.prototype.setFormValues=function Machine_setFormValues(b,d,c,a){doSetFormValues(this.name,b,d,c,a);};Machine.prototype.getArrayPosition=function Machine_getArrayPosition(a){return this.getFieldPosition(a);};Machine.prototype.getFieldPosition=function Machine_getFieldPosition(a){return this.dataManager.getFieldPosition(a);};Machine.prototype.getFormFieldNames=function Machine_getFormFieldNames(){return this.dataManager.getFieldNames();};Machine.prototype.hasEncodedField=function Machine_hasEncodedField(a){return this.hasField(a);};Machine.prototype.hasField=function Machine_hasField(a){return this.dataManager.hasField(a);};Machine.prototype.hasRecordManager=function Machine_hasRecordManager(){return(this.dataManager&&this.dataManager.getActiveRow);};Machine.prototype.canUseOldFieldValue=function Machine_canUseOldFieldValue(a){return !(a>this.getNumRows());};function NLMachineDataManager(a){this.machine=a;}NLMachineDataManager.prototype.setActiveLine=function NLMachineDataManager_setActiveLine(a){};NLMachineDataManager.prototype.getNumRows=function NLMachineDataManager_getNumRows(){return doGetLineCount(this.machine.name);};NLMachineDataManager.prototype.isLineRequired=function NLMachineDataManager_isLineRequired(a){return(this.getLineFieldValue("_reqline",a)=="T");};NLMachineDataManager.prototype.getLineArray=function NLMachineDataManager_getLineArray(){return doGetLineArray(this.machine.name);};NLMachineDataManager.prototype.setLineArray=function NLMachineDataManager_setLineArray(a){doSetLineArray(this.machine.name,a);};NLMachineDataManager.prototype.getLineArrayLine=function NLMachineDataManager_getLineArrayLine(a){return doGetLineArrayLine(this.machine.name,a);};NLMachineDataManager.prototype.setLineArrayLine=function NLMachineDataManager_setLineArrayLine(b,a){doSetLineArrayLine(this.machine.name,b-1,a);};NLMachineDataManager.prototype.hasLineArray=function NLMachineDataManager_hasLineArray(){return doHasLineArray(this.machine.name);};NLMachineDataManager.prototype.clearLineArray=function NLMachineDataManager_clearLineArray(){return doClearLineArray(this.machine.name);};NLMachineDataManager.prototype.cancelLineChanges=function NLMachineDataManager_cancelLineChanges(){};NLMachineDataManager.prototype.removeLine=function NLMachineDataManager_removeLine(a){linearray=this.getLineArray(this.name);linearray.splice(a-1,1);this.setLineArray(linearray);};NLMachineDataManager.prototype.removeAllLines=function NLMachineDataManager_removeAllLines(){clearLineArray(this.machine.name);};NLMachineDataManager.prototype.deleteLineItems=function NLMachineDataManager_deleteLineItems(b,a){return doDeleteLineItems(this.machine.name,b,a);};NLMachineDataManager.prototype.addLine=function NLMachineDataManager_addLine(a,b){};NLMachineDataManager.prototype.insertLine=function NLMachineDataManager_insertLine(b,a){if(!b){var b=new Array(this.machine.countFormElements());for(var c=0;c<b.length;c++){b[c]="";}}linearray=this.getLineArray(this.name);linearray.splice(a-1,0,b);this.setLineArray(linearray);};NLMachineDataManager.prototype.insertLines=function Machine_insertLines(b,a){linearray=this.getLineArray(this.name);linearray1=linearray.slice(0,a-1);linearray2=linearray.slice(a-1);setLineArray(this.machine.name,linearray1.concat(newlinearray).concat(linearray2));};NLMachineDataManager.prototype.saveLine=function NLMachineDataManager_saveLine(a){};NLMachineDataManager.prototype.setLinePosition=function NLMachineDataManager_setLinePosition(c,b){if(!b){b=parseInt(this.machine.getMachineIndex())-1;}linearray=this.getLineArray(this.name);var d=linearray[b];if(c<b){for(var a=(b-1);a>=c;a--){linearray[a+1]=linearray[a];}linearray[c]=d;}else{for(var a=b;a<c;a++){linearray[a]=linearray[a+1];}linearray[c]=d;}this.setLineArray(linearray);};NLMachineDataManager.prototype.writeLineArray=function NLMachineDataManager_writeLineArray(){var b=this.machine.name;if(hasLineArray(b)){var c=this.getLineArray(b);for(var a=0;a<c.length;a++){if(c[a]!=null&&typeof(c[a])!="string"){c[a]=c[a].join(String.fromCharCode(1));}}document.forms.main_form.elements[b+"data"].value=getLineArray(b).join(String.fromCharCode(2));}};NLMachineDataManager.prototype.getLineFieldValue=function NLMachineDataManager_getLineFieldValue(c,b){if(typeof b=="undefined"||b==null){b=this.machine.getMachineIndex();}var a=doGetLineArray(this.machine.name);if(b<=0||b>a.length){return null;}return doGetEncodedValue(this.machine.name,b,c);};NLMachineDataManager.prototype.findFieldValueLineNum=function NLMachineDataManager_findFieldValueLineNum(a,b){return doFindEncodedValue(this.machine.name,a,b);};NLMachineDataManager.prototype.setLineFieldValue=function NLMachineDataManager_setLineFielddValue(b,c,a){doSetEncodedValue(this.machine.name,a,b,c);};NLMachineDataManager.prototype.setFieldInputValue=function NLMachineDataManager_setFieldInputValue(c,d,a,e,b){};NLMachineDataManager.prototype.setInitialFieldValues=function NLMachineDataManager_setInitialFieldValues(b,a){};NLMachineDataManager.prototype.updateDependentFieldValues=function NLMachineDataManager_updateDependentFieldValues(b,a){};NLMachineDataManager.prototype.hasField=function NLMachineDataManager_hasField(a){return doHasEncodedField(this.machine.name,a);};NLMachineDataManager.prototype.getFieldPosition=function NLMachineDataManager_getFieldPosition(a){return doGetEncodedFieldPosition(this.machine.name,a);};NLMachineDataManager.prototype.getFieldNames=function NLMachineDataManager_getFieldNames(){return doGetFieldNamesArray(this.machine.name);};function Machine_validateline(){return true;}function Machine_validatedelete(){return true;}function Machine_postdeleteline(){}function Machine_validateinsert(){return true;}function Machine_doCheckMandatoryData(b,a){return true;}function Machine_lineCommit(a){}function Machine_postEditRow(){}function Machine_preSelectRow(a){return true;}function Machine_lineInit(){}function Machine_getFieldOverride(a,d,c,b){return null;}function Machine_isFieldEditableOverride(a){return null;}function Machine_isNeedUpdateFieldDisplayValue(a){return a.parentNode==this.miniform;}function Machine_getDisplayCellContentOverride(a,b,c){return null;}function Machine_postBuildTable(){return;}function Machine_recalc(a){}Machine.prototype.nlapilinecommit=function Machine_nlapiLineCommit(a){if(document.forms.main_form.elements.nsapiLC!=null){nlapiLineCommit(this.name,a);}};Machine.prototype.nlapirecalc=function Machine_nlapirecalc(a){if(document.forms.main_form.elements.nlapiRC!=null||document.forms.main_form.elements.nsapiRC!=null){nlapiRecalc(this.name,false,nvl(this.recalcType,"commit"));}this.recalcType=null;};Machine.prototype.nlapilineinit=function Machine_nlapiLineInit(){if(document.forms.main_form.elements.nlapiLI!=null||document.forms.main_form.elements.nsapiLI!=null){nlapiLineInit(this.name);}};Machine.prototype.nlapivalidateline=function Machine_nlapiValidateLine(){if(document.forms.main_form.elements.nlapiVL!=null||document.forms.main_form.elements.nsapiVL!=null){return nlapiValidateLine(this.name);}return true;};Machine.prototype.nlapivalidatedelete=function Machine_nlapiValidateDelete(){if(document.forms.main_form.elements.nlapiVD!=null||document.forms.main_form.elements.nsapiVD!=null){return nlapiValidateDelete(this.name);}return true;};Machine.prototype.nlapivalidateinsert=function Machine_nlapiValidateInsert(){if(document.forms.main_form.elements.nlapiVI!=null||document.forms.main_form.elements.nsapiVI!=null){return nlapiValidateInsert(this.name);}return true;};function getButtonDiv(a){return document.getElementById(a+"_buttons");}function hideButtons(a){if(getButtonDiv(a)){getButtonDiv(a).style.display="none";}}function moveButtonDiv(a){hideButtons(a);var b=getButtonDiv(a);if(b){b.parentNode.removeChild(b);document.body.appendChild(b);}}function focusDefaultButton(a){if(!focusButton(a.name+"_addedit")){focusButton(a.name+"_edit");}}function focusButton(b){var a=document.getElementById(b);if(a!=null&&isFocusable(a)){a.focus();return true;}return false;}function setButtonText(c,a){var b=document.getElementById(c);if(b!=null){if(b.nodeName=="INPUT"){b.value=a;}else{b.innerHTML=a;}}}function disableButton(b,c){var a=document.getElementById(b);if(a!=null&&a.disabled!=c){if(a.nodeName=="INPUT"){a.disabled=c;}}}function storeCheckboxState(b){if(b.type=="checkbox"&&b.checked!=null){b.doubleCheck=b.checked;}var c=b.childNodes;if(c==null){return;}for(var a=0;a<c.length;a++){storeCheckboxState(c[a]);}}function restoreCheckboxState(b){if(b.type=="checkbox"&&b.doubleCheck!=null){setNLCheckboxValue(b,b.doubleCheck);b.doubleCheck=null;}var c=b.childNodes;if(c==null){return;}for(var a=0;a<c.length;a++){restoreCheckboxState(c[a]);}}function getCheckboxState(c){if(c.checked!=null){return c.checked;}var d=c.childNodes;if(d==null){return null;}for(var b=0;b<d.length;b++){var a=getCheckboxState(d[b]);if(a!=null){return a;}}return null;}function setMachineChanged(name,fld){if(fld==null||!fld.noslaving){eval("setWindowChanged(window, true)");if(allowAddLines(name)){eval(name+"_machine."+(fld==null?"waschanged":"ischanged")+" = true;");}else{eval(name+"ischanged = true;");}}}function isMachineChanged(name){if(allowAddLines(name)){return eval(name+"_machine.ischanged");}else{return eval(name+"ischanged");}}function wasMachineChanged(name){if(allowAddLines(name)){return eval(name+"_machine.waschanged");}else{return eval(name+"ischanged");}}function getInputElementsFromTable(d){var c=d.getElementsByTagName("INPUT");var a=d.getElementsByTagName("TEXTAREA");var b=new Array();for(i=0;i<c.length;i++){b[b.length]=c[i];}for(i=0;i<a.length;i++){b[b.length]=a[i];}return b;}function getColumnWidthForNode(c){var d=c.style.display;c.style.display="none";var a=c;var b=0;while(a!=null&&a.nodeName!="TD"){a=a.parentNode;}if(a!=null){b=a.offsetWidth;}c.style.display=d;return b;}Machine.prototype.addblankrow=function Machine_addblankrow(){var d=this.getLineArray(this.name);var a=this.getFormFieldNames();var c=new Array(a.length);for(var b=0;b<a.length;b++){c[b]="";}d[d.length]=c.join(String.fromCharCode(1));setLineArray(this.name,d);this.incrementIndex();return true;};Machine.prototype.clearmachine=function Machine_clearmachine(){return this.removeAllLines();};Machine.prototype.removeAllLines=function Machine_removeAllLines(){this.setMainFormData("");this.setIndex(1);this.dataManager.removeAllLines();this.clearline(true);return true;};Machine.prototype.deletelines=function Machine_deletelines(c,a){var b=this.dataManager.deleteLineItems(c,a);if(this.dataManager.removeRows){this.setIndex(this.getNextIndex()-(a-c));}return b;};function NLListMachine(g,f,e,d,b,a){this.base=Machine;this.base(g,f,e,d,b,a);this.type=LIST_MACHINE;var c=doGetFieldNamesArray(this.name);this.updateFormElements();}NLListMachine.prototype=new Machine;NLListMachine.prototype.viewline=function NLListMachine_viewline(a){this.setMachineIndex(a);};NLListMachine.prototype.addline=function NLListMachine_addline(a){this.dataManager.saveRow();};NLListMachine.prototype.insertline=function NLListMachine_insertline(a){};NLListMachine.prototype.deleteline=function NLListMachine_deleteline(a){};NLListMachine.prototype.clearline=function NLListMachine_clearline(a){};NLListMachine.prototype.loadline=function NLListMachine_loadline(){};NLListMachine.prototype.setupLineData=function NLListMachine_setupLineData(a,b){this.updateDataManager();this.setMachineIndex(a);};NLListMachine.prototype.updateContent=function NLListMachine_updateContent(){if(this.bContentUpdated){this.updateFormElements();this.updateDataManager();this.setContentUpdated(false);}};NLListMachine.prototype.updateFormElements=function NLListMachine_updateFormElements(d,b){if(typeof d=="undefined"||d==null){d=0;}if(typeof b=="undefined"||b==null){b=this.getNumRows();}var a=this.countFormElements();for(i=d;i<=b;i++){for(j=0;j<a;j++){var c=this.getFormElement(j,i+1);if(c){c.machine=this;}}}};NLListMachine.prototype.setEncodedValues=function NLListMachine_setEncodedValues(b,g){if(g==null){g=document.forms[this.name+"_form"];}var a=doGetFieldNamesArray(this.name);var f=splitIntoCells(document.forms.main_form.elements[this.name+"flags"].value);this.dataManager.setActiveRow(b-1);var h;for(var e=0;e<a.length;e++){if(isValEmpty(a[e])){continue;}if((f[e]&4)==0){continue;}else{var d;if(g.elements[a[e]]!=null&&g.elements[a[e]][0]!=null&&g.elements[a[e]][0].type=="radio"){for(var c=0;c<g.elements[a[e]].length;c++){if(g.elements[a[e]][c].value==b){d=g.elements[a[e]][c];}}}else{if((f[e]&8)!=0){d=g.elements[a[e+1]+b.toString()+"_display"];}else{d=g.elements[a[e]+b.toString()];}}if(d!=null){if(d.type=="checkbox"||d.type=="radio"){h=d.checked?"T":"F";}else{if(d.type=="select-one"){h=d.options[d.selectedIndex].value;}else{if(d.type=="textarea"){h=d.value.replace(/\r/g,"").replace(/\n/g,String.fromCharCode(5));}else{h=d.value;}}}this.dataManager.setFieldValue(a[e],h,false,null);}}}};NLListMachine.prototype.hasEncodedField=function NLListMachine_hasEncodedField(a){return doHasEncodedField(this.name,a);};NLListMachine.prototype.setFieldInputValue=function NLListMachine_setFieldInputValue(c,e,a,f){var d=c.search(/(\d)+$/);var b=c.substring(d);var c=c.substring(0,d);this.dataManager.setFieldInputValue(c,e,a,f,b);};NLListMachine.prototype.canUseOldFieldValue=function NLListMachine_canUseOldFieldValue(a){return false;};function NLGetUIForm(a){if(!a){return window.NL_UIFORM;}if(window.NL_UIFORMs){return window.NL_UIFORMs[a];}return null;}function NLSetUIForm(a){if(!window.NL_UIFORMs){window.NL_UIFORMs=new Object();}window.NL_UIFORMs[a.name]=a;if(!window.NL_UIFORM){window.NL_UIFORM=a;}}function NLUIForm(b,a){this.name=b;this.recordManager=a;this.init();NLSetUIForm(this);}NLUIForm.prototype.init=function NLUIForm_init(){this.setUpEventHandlerInterception();if(!this.recordManager.getActiveRow()){this.recordManager.doCreateRow(0);this.recordManager.doSetActiveRow(0);}this.recordManager.addRow();this.updateRecordValues();};NLUIForm.prototype.setUpEventHandlerInterception=function NLUIForm_setUpEventHandlerInterception(){var c=this.recordManager.getFieldNames();for(var a=0;a<c.length;a++){var b=document.forms[this.name][c[a]];if(b){b.originalOnChange=b.onchange?b.onchange:null;b.uiform=this;b.onchange=new Function("this.uiform.handleChange(this);");}}};NLUIForm.prototype.handleChange=function NLUIForm_handleChange(b){var a=false;if(b.originalOnChange){a=b.originalOnChange();if(a!=false){this.recordManager.setFieldValue(b.name,b.value);}}return a;};NLUIForm.prototype.updateRecordValues=function NLUIForm_updateRecordValues(){var d=this.recordManager.getFieldNames();for(var a=0;a<d.length;a++){var c=document.forms[this.name][d[a]];if(c){var b=getFormValue(c,false);this.recordManager.setFieldValue(c.name,b);}}};NLUIForm.prototype.setFieldInputValue=function NLUIForm_setFieldInputValue(b,c,d,a){this.recordManager.setFieldInputValue(b,c,a,d);};function popupBinDiv(n,b,c,h){if(n==null||n.length==0){return;}var m=parseFloat(h.value);if(!isNaN(m)){m=Math.abs(parseFloat(m));}var d=document.getElementById("BinInlineDIV"+c);if(d!=null){document.body.removeChild(d);}d=document.createElement("div");d.style.border="1px solid black";d.style.position="absolute";d.style.padding="2px";d.id="BinInlineDIV"+c;d.className="bglt";d.style.display="none";d.style.zIndex=1000;d.targetField=b;d.targetQtyField=h;document.body.appendChild(d);var a=n.split(String.fromCharCode(5));var o=new Array();var g=new Array();for(var e=0;e<a.length;e++){var l=parseBinQuantityString(a[e]);if(l!=null){o[e]=l[0];g[l[0]]=l[1];}}d.binCount=o.length;var f=parseBinNumbers(b.value,o,m);var k="<form name='BinInlineDivForm"+c+"'><table border=0 cellpadding=0 cellspacing=0><tr><td class=text align=left><b>Bin</b></td><td nowrap class=text>&nbsp;&nbsp;</td><td class=text align=center><b>On Hand</b></td><td nowrap class=text>&nbsp;&nbsp;</td><td class=text align=center><b>Qty</b></td></tr>";for(var e=0;e<d.binCount;e++){k+="<tr><td class=text align=left>"+o[e]+"</td><td></td><td class=text align=center>"+g[o[e]]+"</td><td></td><td class=text align=right><input type=hidden name='BinInlineDivName"+e+"' value="+o[e]+"><input type=text maxlength=10 size=5 name='BinInlineDivQty"+e+"' value="+(f[o[e]]==null?"":f[o[e]])+"></td></tr>";}k+="</table><center><INPUT type='button' class='bgbutton' value='Done' id='done' name='done' onkeypress=\"event.cancelBubble=true;\" onclick=\"syncBinDiv(BinInlineDivForm"+c+", document.getElementById('BinInlineDIV"+c+"'),"+c+"); document.getElementById('BinInlineDIV"+c+"').style.display='none';\"'></center></form>";d.innerHTML=k;d.style.left=findPosX(b);d.style.top=findPosY(b)+b.offsetHeight;d.style.display="";}function syncBinDiv(b,a,d){var h="";var n=0;var f=0;var l=0;var c=parseFloat(a.targetQtyField.value);var e=Math.abs(c);for(var g=0;g<a.binCount;g++){var m=parseFloat(b.elements["BinInlineDivQty"+g].value);if(!isNaN(m)){l=Math.max(l,getUserEnteredPrecision(b.elements["BinInlineDivQty"+g].value));if(m<0){m=Math.abs(m);b.elements["BinInlineDivQty"+g].value=m;}else{if(m>0){n++;f+=m;}}}}if(!isNaN(e)&&!equalsDouble(f,parseFloat(e))){alert("The sum of all bin quantities ("+f+") is not equal to the total line quantity ("+c+")");return;}else{if(f!=0&&isNaN(c)){a.targetQtyField.value=roundDecimal(f,l);}}var k=false;for(var g=0;g<a.binCount;g++){var m=parseFloat(b.elements["BinInlineDivQty"+g].value);if(isNaN(m)){continue;}if(k==true){h+="\n";}h+=b.elements["BinInlineDivName"+g].value;if(n>1){h+="("+roundDecimal(m,l)+")";}k=true;}a.targetField.value=h;if(a.targetField.onchange!=null){a.targetField.onchange();}}function getUserEnteredPrecision(f){var d=parseInt(f);var b=parseFloat(f);if(!equalsDouble(d,b)){var a=f.indexOf(".");if(a>=0){var e=0;for(var c=a+1;c<f.length;c++,e++){if((f.charAt(c)<"0")||(f.charAt(c)>"9")){break;}}return e;}}return 0;}var EPSILON=0.000001;function equalsDouble(b,a){if(isNaN(b)){return isNaN(a);}else{if(isNaN(a)){return false;}else{return Math.abs(b-a)<EPSILON;}}}function roundDecimal(b,e){var d=b.toFixed(e);if(e==0){return d;}else{var a=d.length;for(var c=d.length-1;true;c--){if(d.charAt(c)=="."){a=c;break;}if(d.charAt(c)!="0"){a=c+1;break;}}return d.substring(0,a);}}function parseBinNumbers(g,b,f){var c=new Array();if(isNaN(f)){f=1;}var h=new RegExp("^\\s*(\\S+)\\s*$");var a=h.exec(g);if(a!=null){c[a[1]]=f;return c;}for(var d=0;d<b.length;d++){var k=b[d];h=new RegExp("\\b"+k+"\\s*\\(\\s*(\\d+\\.?\\d*)\\s*\\)");var e=h.exec(g);if(e!=null){c[k]=e[1];}}return c;}function parseBinQuantityString(b){re=new RegExp("^\\s*(\\S+)\\s*\\(\\s*(\\d+\\.?\\d*)\\s*\\)\\s*$");var a=re.exec(b);if(a!=null){a.shift();return a;}else{return null;}}
