
/*
 * Copyright (c) 2006 BMC Software, Inc.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of 
 * BMC Software, Inc ("Confidential Information"). You shall not 
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement between 
 * you and BMC Software, Inc. 
 */


function ARRunGotoX(funcs) {
var args = [funcs, 0];
return {n:{f:ARRunGoto, a:args, e:ARRunGotoException, ea:args}};
}
function ARRunGoto(funcs, index) {
;
;
; 
while (index < funcs.length) {
;
;
var res = CurWFC.execute({f:funcs[index + 1]});
if (res) {
LogWrite("ARRunGoto: imode interrupt signalled");
var args = [funcs, index + 2];
return {i:1, n:{f:ARRunGoto, a:args, e:ARRunGotoException, ea:args}};
}
index += 2;
}
}
function ARRunGotoException(exception, funcs, index) {
;
; 
if (typeof exception != "object" || !(exception instanceof WorkflowException))
throw exception;
;
;
if (exception.mCode == 1) {
;
;
var target = exception.mArg;
while ((index >= 0 && target < funcs[index]) || index >= funcs.length) {
index -= 2;
}
while (index < funcs.length && target > funcs[index]) {
index += 2;
}
if (index < funcs.length) {
var args = [funcs, index];
return {n:{f:ARRunGoto, a:args, e:ARRunGotoException, ea:args}};
}
} else {
throw exception;
}
}
function ARRunX(funcs) {
var fste = [];
var len = funcs.length;
for (var ii = len -1; ii >= 0;ii--) {
fste.push({f:funcs[ii]});
}
return CurWFC.executeAll(fste);
}
function ARGotoGuideLabel(label) {
;
var gs = CurWFC.getGuideState();
if (gs != null) {
;
var funcs = gs.f;
var ii;
for (ii = 0; ii < funcs.length; ++ii) {
if (funcs[ii] == label) {
gs.i = ii;
throw new WorkflowException(2, label);
}
}
}
}
function ARRunGuideX(funcs) {
var gs = CurWFC.getGuideState();
;
gs.f = funcs;
gs.i = 0;
return {c:{f:ARRunGuide, e:ARRunGuideException}};
}
function ARRunGuide() {
var gs = CurWFC.getGuideState();
; 
;
while (gs.i < gs.f.length) {
var idxobj = gs.f[gs.i++];
if (typeof idxobj == "function") {
var res = CurWFC.execute({f:idxobj});
if (res) {
LogWrite("ARRunGuide: imode interrupt signalled");
return {i:1, n:{f:ARRunGuide, e:ARRunGuideException}};
}
}
}
}
function ARRunGuideException(exception) {
if (typeof exception != "object" || !(exception instanceof WorkflowException))
throw exception;
;
;
switch(exception.mCode) {
case 2:
return {n:{f:ARRunGuide, e:ARRunGuideException}};
case 1 :
return {n:{f:ARRunGuide, e:ARRunGuideException }};
default:
throw exception;    
} 
}
function CallIf(res, func)  {
;
;
if (!res)
return;
var args = new Array(arguments.length - 2);
for (var i = 0; i < arguments.length - 2; ++i)
args[i] = arguments[i + 2];
return func.apply(null, args);
}
function External(qualfieldid) {
;
var qual = F(qualfieldid).G().toString().trim(1|2);
if (qual == "")
return true;
qual = ExpandString(qual, 2|4|8);
req = new NDXCompileQualification(ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), ARKWGetStringByIdx(17), qual);
;
return req.result;
}
var WorkflowEventMap = {
0 : {f: "AREVTNone" },
1 : {f: "AREVTButton", id:true },
2 : {f: "AREVTReturn", id:true },
4 : {f: "AREVTSubmit" },
8 : {f: "AREVTModify" },
16 : {f: "AREVTDisplay" },
32 : {f: "AREVTModifyAll" },
64 : {f: "AREVTMenuOpen", id:true },
128 : {f: "AREVTMenuChoice", id:true },
256 : {f: "AREVTLoseFocus", id:true },
512 : {f: "AREVTSetDefault" },
1024 : {f: "AREVTQuery" },
2048 : {f: "AREVTAfterModify" },
4096 : {f: "AREVTAfterSubmit" },
8192 : {f: "AREVTGainFocus", id:true },
16384 : {f: "AREVTWindowOpen" },
32768 : {f: "AREVTWindowClose" },
65536 : {f: "AREVTUndisplay" },
131072 : {f: "AREVTCopySubmit" },
262144 : {f: "AREVTWindowLoaded" },
524288 : {f: "AREVTInterval", id:true },
1048576 : {f: "AREVTEvent" }        
};
function AREventFunction(event, id) {
;
;
if (event in WorkflowEventMap) {
var evt = WorkflowEventMap[event];
var fname = evt.f;
if (evt.id && typeof id != "undefined")
fname = fname + id;
if (fname in window)
return window[fname];
}
return null;
}

function ARRegisterInterval(func, interval)
{
LogWrite("ARRegisterInterval(" + func + ", " + interval + ")");
setInterval(function () {new WorkflowContext({f:func});},interval*1000);
}
function ExpandServerName(servername)
{
servername = ExpandString(servername, 1 | 2 | 4);
if (servername == "@") 
servername = ARKWGetStringByIdx(7);
;
return servername;
}
function ExpandSchemaName(schemaname)
{
schemaname = ExpandString(schemaname, 1 | 2 | 4);
if (schemaname == "@") 
schemaname = ARKWGetStringByIdx(6);
;
return schemaname;
}
function ExpandGuideName(guidename)
{
return ExpandString(guidename, 1 | 2 | 4);
}
function ExpandQualifier(qual, schema, server)
{
;
;
;
if ("extids" in qual) {
do {
var fieldids = new Array();
var fieldvals = new Array();
var fieldtypes = new Array();
var fl = new FieldList(qual.extids);
fl.ToArrays(fieldids, fieldvals, fieldtypes);
;
req = new NDXCompileExternalQualification(ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), ARKWGetStringByIdx(17), server, schema, qual.qual, fieldids, fieldvals, fieldtypes);
;
qual = req.result;
} while ("extids" in qual);
}
qual.fieldids = new Array();
qual.fieldvals = new Array();
qual.fieldtypes = new Array();
if ("ids" in qual) {
var fl = new FieldList(qual.ids);
fl.ToArrays(qual.fieldids, qual.fieldvals, qual.fieldtypes);
}
;
;
;
;
return qual;
}
function ExpandKeyword(part, flags, fieldid, datatype, hasKeywordResult)
{
var value = null;
var idx   = null;
var re    = /^-{0,2}[0-9]+$/; 
var match = re.exec(part);
if (match != null){
if (match[0] > 0) { 
return value;
}
if ( match[0] == "--1") { 
return "";
}
idx = -match[0] + 1; 
if (!ARKWIsKeywordIdx(idx)) {
return value;
}
value = "$" + ARKWGetNameByIdx(idx) + "$"; 
} else {
if (ARKWIsKeywordName(part)) {
idx = ARKWGetKeywordIdx(part);
}
if (idx == null || isNaN(idx) || !ARKWIsKeywordIdx(idx)) {
return value;
}   
}
var isTemporal=ARKWIsTemporal(idx);
if (((flags & 2) && !ARKWIsTimeRelated(idx) && !isTemporal)
|| ((flags & 4) && isTemporal)
|| ((flags & 16) && ARKwIsConstant(idx))) {
if (hasKeywordResult) {
hasKeywordResult.hasKeyword=true;
if (isTemporal)
hasKeywordResult.hasTemporalKeyword=true;
}
var dt = ARKWGetByIdx(idx, fieldid);
;
if (ARKWIsTimeRelated(idx))
{
switch(datatype)
{
case 13:
dt = dt.toDate();
break;
case 7:
dt = dt.toTime();
break;
case 14:
dt = dt.toTOD();
break;
case 3:
dt = dt.toReal();
break;
case 10:
dt = dt.toDecimal();
break;
case 2:
dt = dt.toInteger();
break;
}
}
value = dt.toString();
}
return value;
}
function ExpandFieldReference(ref, flags)
{
var value = null;
var num   = parseInt(ref);
var field = (isNaN(parseInt(ref))) ? Field_FindByDBN(ref) : F(ref); 
var parts = [];
if (field == null || field == DummyField) {
var i = 0;
var dotIdx = -1;
while (i < 2) {
dotIdx = ref.lastIndexOf(".");
if (dotIdx < 1) {
break;
}
parts[i++] = ref.substring(dotIdx+1, ref.length) + "";
ref = ref.substring(0, dotIdx);
field = (isNaN(parseInt(ref))) ? Field_FindByDBN(ref) : F(ref);
if (field != null && field.mID != 0) {
break;
}
}
}
if (field != null && field != DummyField) { 
var dt = field.G();
if (field.mIsComplexField && parts.length > 0) {
var compVal = dt.compound(parts);
if (compVal != null) {
value = compVal.toString();
}
} else {
value = dt.toString();
}
}
return value;
}
function ExpandStringInDollar(string, flags, fieldid, datatype, hasKeywordResult)
{
var result = "";
var previousEmpty = previousExpand = sentinel = 0;
var start = end = 0;
var bQuote = eQuote = needQuote = false;
var splitStr = "$";
var parts = string.split(splitStr);
for (var i = 0; i < parts.length; ++i) {
var part = parts[i];
if (part == "" || (i == (parts.length-1))) { 
if (previousEmpty || ( sentinel && !previousExpand)) {
result += splitStr;
}
if (i == (parts.length-1))
result += part;
previousEmpty  = 1;
previousExpand = 0;
continue;
}
sentinel = 1; 
if (i > 0 && !previousExpand) { 
var value;
if ((flags & 2) ||(flags & 4)) {
if (!(parts.length == 3 && parts[0] == "" && parts[2] == ""))
datatype = 4;
value = ExpandKeyword(part, flags, fieldid, datatype, hasKeywordResult);
}
if (value == null && (flags & 1)) {
value = ExpandFieldReference(part, flags);
}
if (value != null) {
part = value;
previousExpand = 1;         
} else if (parts.length > 1 ) {
result += splitStr;
}
} else {
previousExpand = 0;
}
previousEmpty  = 0; 
result +=  part;  
}
return result;
}
function ExpandString(string, flags, fieldid, datatype, hasKeywordResult)
{
;
;
;
;
;
if (string.indexOf("$") == -1)
return string;
var val = ExpandStringInDollar(string, flags, fieldid, datatype, hasKeywordResult);
if ((flags & 4) && ARKWIsTemporalString(val))
val = ExpandStringInDollar(val, flags, fieldid, datatype, hasKeywordResult);
return val;
}
function DeserializeGlobals(name) {
var ck = getCookie(name);
if (ck != null && ck.length > 0) {
var vals;
eval("vals = " + ck + ";");
return vals;
}
return {};
}
function SerializeGlobals(name, globals) {
var ck = [];
weDeepSerialise(globals, ck);
ck = ck.join("");
var curCookie = document.cookie;
var curGF = getCookie(name);
var l = curCookie.length;
if (curGF != null) {
l -= (3 + encodeURIComponent(curGF).length); 
}
l += 3 + encodeURIComponent(ck).length; 
if (l >= 4096) {
throw new WorkflowException(0, [{t : 2, n: 9360, m:null, a:null}]);
}
setCookie(name, ck, null, "/", null, null);
}
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + encodeURIComponent(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = -1;
if (dc.indexOf(prefix) == 0) {
begin = 0;
} else {
begin = dc.indexOf("; " + prefix);
if (begin != -1) begin += 2;
}
if (begin == -1) {
return null;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
var cookievalue = dc.substring(begin + prefix.length, end);
if (cookievalue == "com.remedy.SomethingUnlikely") {
return null;
}
return decodeURIComponent(cookievalue);
}
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=com.remedy.SomethingUnlikely" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "");
}
}

function FakeButton_SetAlternative(n, disabled) {
;
if(n.firstChild && n.firstChild.firstChild && n.firstChild.firstChild.className=="btnimg"){
var domImg = n.firstChild.firstChild;
var newalt = domImg.ARTXT;
domImg.alt = (disabled)?getLocalizedMessage("{0}. Disabled",[newalt]):newalt;
}
else {
var text=SharedSupport_GetAnchorText(n);
if(text.trim(1|2) == "")
text = n.ARTXT;
var field=Field_FromElement(n.parentElement);
if(field != null && (field.mObj.getAttribute("ARTYPE")=="AttachmentPool" 
|| field.mObj.getAttribute("ARTYPE")=="Table")) {
var args = [text, field.GLabel()];
n.title=(disabled)?getLocalizedMessage("{0} for table {1} is disabled", args):
getLocalizedMessage("{0} for table {1}", args);
} else 
n.title=(disabled)?getLocalizedMessage("{0}. Disabled",[text]):text;
} 
}
function FakeButton_SetDisable(n,disabled) {
;
;
var p = n.parentNode;
if (p != null && p.style.visibility=="hidden")
{
p.style.visibility="visible";
n.className=n.className.replace(/[ ]*btnd[ ]*/," ");
p.style.visibility="hidden"
}
else
n.className=n.className.replace(/[ ]*btnd[ ]*/," ");
if (disabled)
n.className+=" btnd";
if(n.firstChild && n.firstChild.firstChild &&n.firstChild.firstChild.className=="btnimg") {
FakeButton_SetAlternative(n, disabled);
}
}
function SharedSupport_GetAnchorText(ele) {
;
var text=[];
var c=ele.firstChild; 
while (c) {
if (c.firstChild)
c=c.firstChild;
else {
if (c.nodeType==3)
text.push(c.nodeValue);
while (!(c.nextSibling)) {
c=c.parentNode;
if ((c==ele) || (c==null)) {
text=text.join("");
return text;
}
}
c=c.nextSibling;
}
}
return "";
}
function FakeButton_MouseDown(n,evt) {
;
;
if(!FakeButton_Disabled(n))
n.className=n.className.replace(/btn3d/,"btn3ddown");
}
function FakeButton_MouseUpOut(n,evt) {
;
n.className=n.className.replace(/btn3ddown/,"btn3d");
}
function FakeButton_Disabled(n) {
;
;
return n.className.indexOf("btnd")!=-1;
}
function FakeButton_TabableElementSelector(n) {
;
;
if (!FakeButton_Disabled(n) && (!n.style||(n.style.visibility!="hidden")))
return n;
else 
return null;
}
function FakeButton_Find(n) {
for(var i=0;n;n=n.parentNode) {
if(n.nodeType==1&&n.tagName=="A"&&n.className) {
var clist=n.className.split(" ");
for(var j in clist)
if(clist[j]=="btn")
return n;
}
}
return null;
}
function getLocalizedMessage(msgKey, args, context) {
;
;
;
var key = (context == null) ? msgKey : context + "|" + msgKey;
var msgText = localizedMessages[key];
if (msgText == null) { 
msgText = msgKey; 
}
if (args == null || args.length < 0) {
return msgText;
}
var re;
var i = 0;
while(true) {
var count = 0;
re = new RegExp("\\{" + i + "\\}","gi");
while(re.test(msgText)){
;
msgText = msgText.replace(re, args[i]);
count++;
}
if ( count == 0) {
break;
}
i++;
}
return msgText;
}
function CompileFunction(str,args,subs) {
for(var i in subs)
str=str.replace(new RegExp(i,"g"),subs[i]);
eval("window.CompiledFunction=function("+args+"){"+str+"}");
}
function ComputeElementPosition(e,pnt,x,y) {
;
while(e!=pnt) {
var bw=parseInt(e.style.borderTopWidth);
var bh=parseInt(e.style.borderLeftWidth);
y+=e.offsetTop;
x+=e.offsetLeft;
x-=e.scrollLeft;
y-=e.scrollTop;
if(!isNaN(bw))
x+=bw;
if(!isNaN(bh))
y+=bh;
e=e.offsetParent;
; 
}
return {x:x,y:y};
}
function GetStylePixelValue(ele,prop) {
var str = (ele.currentStyle[prop]);
;
return parseInt(str);
}

var LogWindow = null;
var clientLogEnabled = serverLogEnabled = 0;
function LogInit()
{
clientLogEnabled |= ARPrefsGetAsNumber(20112);
serverLogEnabled |= ARPrefsGetAsNumber(20113)| ARPrefsGetAsNumber(20114) | ARPrefsGetAsNumber(20115);
LogInit1();
}
function LogInit1()
{
if (LogWindow == null || LogWindow.closed) {
if (window.opener && !window.opener.closed && window.opener.LogWindow && !window.opener.LogWindow.closed)
LogWindow = window.opener.LogWindow;
}
if ((clientLogEnabled || serverLogEnabled) && (LogWindow == null || LogWindow.closed)) {
var left = 0;
var top = 0;
var width = Math.floor(window.screen.availWidth / 2);
var height = Math.floor(window.screen.availHeight / 2);
LogWindow = window.open((AbsContextPath + "resources/html/Blank.html"), "Log"+document.domain.replace(/[^A-Za-z0-9_]/g, "_"), "width=" + (width-10) + ",height=" + (height-28) +
",top=" + top + ",left=" + left + ",scrollbars,resizable=yes");
LogWindow.document.write('<html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"><title>Workflow Logging - '+document.domain+'</title><style>pre { margin-bottom:0px;margin-top:0px}</style></head><body>');
}
}
function LogWrite(str, serverLog)
{
if (serverLog) {
if (!serverLogEnabled)
return;
} else if (!clientLogEnabled) {
return;
}
LogInit1();
LogWindow.document.write("<pre>" + str + "</pre>");
LogWindow.scroll(0, 1e9);
}
function LogAndAlert(str)
{
if (clientLogEnabled)
LogWrite("Alert: " + str);
alert(str);
}

FormEvent.Trampoline=function(func) {
return function(edata) {
var fe=new FormEvent(edata);
var result=func(fe);
if(typeof result=="boolean"&&result==false)
fe.StopDefault();
else if (typeof result=="string")
{
return result;
}
}
}
function FormEvent(obj) {
;
;
this.mStoppedDefault=false;
if(typeof obj!="number")
this.PDBuild(obj);
else {
var fe = Fields[obj].GetFocusElement();
this.alt=this.ctrl=this.shift=this.key=this.ox=this.oy=this.button=0;
this.element=fe;
}
;
;
}
FormEvent.prototype.PDBuild=function(obj) {
; 
this.alt=window.event.altKey;
this.ctrl=window.event.ctrlKey;
this.shift=window.event.shiftKey;
this.key=window.event.keyCode;
this.ox=window.event.offsetX;
this.oy=window.event.offsetY;
this.button=window.event.button;
this.element=window.event.srcElement;
if (this.element&&!this.element.tagName)
this.element=document.body; 
}
FormEvent.prototype.PDStopBubbling=function() {
window.event.cancelBubble=true;
}
FormEvent.prototype.PDStopDefault=function() {
window.event.returnValue=false;
this.mStoppedDefault=true;
}
FormEvent.prototype.PDSetKeyCode=function(arg) {
;
try { window.event.keyCode=arg; }catch(e) {}
}
FormEvent.PDFireChangeEvent=function(ele) {
;
var evt = document.createEventObject();
ele.fireEvent("onchange", evt);
}
FormEvent.PDFireClickEvent=function(ele) {
;
var evt = document.createEventObject();
ele.fireEvent("onclick", evt);
}
;
;
;
FormEvent.prototype.StopBubbling=FormEvent.prototype.PDStopBubbling;
FormEvent.prototype.StopDefault=FormEvent.prototype.PDStopDefault;
FormEvent.prototype.SetKeyCode=FormEvent.prototype.PDSetKeyCode;
FormEvent.FireChangeEvent=FormEvent.PDFireChangeEvent;
FormEvent.FireClickEvent=FormEvent.PDFireClickEvent;

function FormPane(fixh,obj,initvis,handler,handlerthis) {
;
this.mFixedHeight=fixh;
this.mHandler=handler;
this.mHandlerObj=(handlerthis!=null)?handlerthis:this;
this.mObj=obj;
this.mVisible=initvis;
if(!initvis) 
this.mObj.style.left=100000;
this.mHeight=0;
this.mY=0;
FormPane.MPanes.push(this);
}
FormPane.MPanes=[];
FormPane.prototype.SVis=function(vis) {
;
this.mVisible=vis;
this.mObj.style.left=(vis?0:100000);
}
FormPane.prototype.GVis=function() {
return this.mVisible;
}
FormPane.Layout=function() {
var h=document.body.clientHeight,fudgedwidth=document.body.clientWidth+1; 
var totlen=FormPane.MPanes.length,minh=0,novar=0;
for(var i=0;i<totlen;++i) {
var pi=FormPane.MPanes[i];
if(pi.mVisible) {
if(pi.mFixedHeight!=-1) {
pi.mHeight=pi.mFixedHeight;
minh+=pi.mHeight;
} else {
pi.mHeight=0;
++novar;
}
}
}
if(minh<h&&novar>0) {
var remain=h-minh;
for(var i=0;i<totlen;++i) {
var pi=FormPane.MPanes[i];
if(pi.mVisible&&pi.mFixedHeight==-1) {
var diff=Math.floor(remain/novar);
pi.mHeight+=diff;
;
remain-=diff;
--novar;
}
}
}
var y=0;
for(var i=0;i<totlen;++i) {
var pi=FormPane.MPanes[i];
if(pi.mVisible) {
pi.mObj.style.height=pi.mHeight;
pi.mObj.style.top=y;
pi.mY=y;
if(pi.mHandler)
pi.mHandler.call(pi.mHandlerObj,fudgedwidth,pi.mHeight);
y+=pi.mHeight;
}
}
;
var fc=FormElements["FormContainer"],fcb=fc.firstChild;
if(FormContainerPaneSH==null) {
FormContainerPaneSH=fc.scrollHeight;
FormContainerPaneSW=fc.scrollWidth;
}
if(fcb.nodeType==1&&fcb.className=="FormContainerBackground") {
fcb.style.height=FormContainerPane.mHeight>FormContainerPaneSH?FormContainerPane.mHeight:FormContainerPaneSH;
fcb.style.width=(fudgedwidth-1)>FormContainerPaneSW?(fudgedwidth-1):FormContainerPaneSW;
}
}
var ToolBarPane=null,FormContainerPane,FormContainerPaneSH=null,FormContainerPaneSW,SplitterPane,ResultsListPane,QBPane=null;
function ToolbarButtonIterator(iter) {
var outer = FormElements["Toolbar"];
do {    if (!(typeof iter=="function")) {         Assert("(Form.js:143) typeof iter==\"function\"");     } } while (0);
do {    if (!(iter.length==2)) {         Assert("(Form.js:144) iter.length==2");     } } while (0);
do {    if (!(outer.childNodes[2].tagName=="TABLE")) {         Assert("(Form.js:145) outer.childNodes[2].tagName==\"TABLE\"");     } } while (0);
var gcell=outer.childNodes[2].firstChild.firstChild.firstChild;
while(gcell!=null) {
if(gcell.nodeType==1) {
do {    if (!(gcell.tagName=="TD")) {         Assert("(Form.js:149) gcell.tagName==\"TD\"");     } } while (0);
var gbut=gcell.firstChild;
while(gbut!=null) {
if(gbut.nodeType==1) {
do {    if (!(gbut.tagName=="A")) {         Assert("(Form.js:153) gbut.tagName==\"A\"");     } } while (0);
iter(gbut,gbut.className.split(" ")[0]);
}
gbut=gbut.nextSibling;
}
}
gcell=gcell.nextSibling;
}
}
function BuildToolbar(tbh,outer) {
var ToolbarItemMap={
searchsavechanges:function() {
if((ARStateCurrent == 4))
return CurWFC.executeAll({f:FormActionButtonFlags[1002].f});
else if((ARStateCurrent == 1))
return CurWFC.executeAll({f:FormActionButtonFlags[1001].f});
else if ((ARStateCurrent == 5) || (ARStateCurrent == 6))
return CurWFC.executeAll({f:FormActionButtonFlags[1003].f});
},
newsearch:1009,
newrequest:1010,
modifyall:1004,
savedsearches:1013,
advancedsearch:function() {
if(QBPane!=null&&(ARStateCurrent == 4))
F(1005).VisClick();
},
clear:1006,
settodefaults:1007,
statushistory:1011,
help:1008,
home:1012,
logout:ARProcessExitApp
};
new ToolbarButtonIterator(function(node,cname) {
if(cname=="searchsavechanges") {
node.parentNode.style.width=node.offsetWidth+4;
node.parentNode.style.textAlign="center";
}
});
var flipper=outer.childNodes[1];
;
var rightimg=flipper.childNodes[0],downimg=flipper.childNodes[1];
;
var tbopen=true;
rightimg.style.visibility="hidden";
window.Toolbar_Click=function(ed) {
var elem=ed.element;
if(elem==flipper||elem==rightimg||elem==downimg) {
tbopen=!tbopen;
rightimg.style.visibility=(tbopen?"hidden":"inherit");
downimg.style.visibility=(tbopen?"inherit":"hidden");
;
outer.childNodes[2].style.visibility=(tbopen?"inherit":"hidden");
ToolBarPane.mFixedHeight=(tbopen?tbh:flipper.offsetHeight);
FormPane.Layout();
} else {
var elem=FakeButton_Find(ed.element);
; 
var cname=elem.className.split(" ");
if(cname.length>=1)
cname=cname[0];
if(!(cname in ToolbarItemMap))
return;
var id=ToolbarItemMap[cname];
if(typeof id=="function")
return id();
else if(id in FormActionButtonFlags) {
;
return CurWFC.executeAll({f:FormActionButtonFlags[id].f, a:[elem]});
}
}
}
window.Toolbar_UpdateFormActionButtons=function() {
new ToolbarButtonIterator(function(bnode,cname) {
var id=ToolbarItemMap[cname];
if(typeof id!="function" && typeof id!="undefined") {
var enable=((FormActionButtonFlags[id].c & (1 << ARStateCurrent)) == 0);
if(id==1011&&!Fields[15])
enable=false;
else if(id==1013&&userSearches==null)
enable=false;
FakeButton_SetDisable(bnode,!enable);
} else {
if(cname=="advancedsearch")
FakeButton_SetDisable(bnode,QBPane==null||!(ARStateCurrent == 4));
else if(cname=="searchsavechanges") {
var str=StateMgr.GetActionButtonString();
;
NodeWrite(bnode.firstChild,str);
if(((ARStateCurrent == 4)&&!Form.TbSearch)||(!(ARStateCurrent == 4)&&!Form.TbSave)||((ARStateCurrent == 3))) {
bnode.style.visibility="hidden";
FakeButton_SetDisable(bnode,true);
} else {
bnode.style.visibility="inherit";
FakeButton_SetDisable(bnode,false);
}
}
}
});
;
outer.firstChild.className="TBTopBarStatus TBTopBarStatusMode"+ARStateCurrent;
}
window.Toolbar_DirtyFlagChanged=function(dirty) {
if(ApplyButtonIDs[ARStateCurrent]) {
new ToolbarButtonIterator(function(bnode,cname) {
if(cname=="searchsavechanges")
FakeButton_SetDisable(bnode,!dirty);
});
}
}
ToolBarPane=new FormPane(tbh,outer,true,null,null);
}
function ResizeResultsList(verticalonly) {
if (!ResultsListPane.GVis())
return;
if(1020 in Fields)
Fields[1020].Resize(verticalonly?null:document.body.clientWidth+1,ResultsListPane.mHeight); 
}
function ShowResultsListPane() {
ResultsListPane.SVis(true);
SplitterPane.SVis(true);
FormPane.Layout();
Form.LastFormFID = 0;
}
function HideResultsListPane() {
ResultsListPane.SVis(false);
SplitterPane.SVis(false);
FormPane.Layout();
}
function ARSystemInit() {
if (typeof(userDataOk) == "undefined") {
window.status=getLocalizedMessage("Waiting to load {0}",["userdata.js"]);
return;
}
SetContextPath();
UserData_Init();
UserSearches_Init();
LogInit();
StateMgr_Init();
window.status=ExpandString("$USER$ | $SERVER$",2|16);
new WorkflowContext({f:Form_Init});
}
var FormElements=[]; 
function Form_Init() {
var d = new Date();
;
;
;
;
var showTb=weAmDialogue(window.name)?false:Form.ShowTb;
var n=document.body;
if(n.firstChild) {
n=n.firstChild;
while(n) {
if(n.id)
FormElements[n.id]=n;
n=n.nextSibling;
}
}
delete FormElements["PostAppletElement"];
document.body.style.display="";
JField_Init();
Field_Init();
Field_ExpandDefaultValues();
var fc=FormElements["FormContainer"],rl=FormElements["ResultsList"];
var splitter=FormElements["Splitter"],qb=FormElements["QueryBar"];
var tb=FormElements["Toolbar"],tbh=parseInt((tb.currentStyle["height"]));
var rlattop=!RLAtBottom();
if(showTb)
BuildToolbar(tbh,tb);
else
tb.style.visibility="hidden";
var rlh = parseInt((rl.currentStyle["height"]));  
if(rlattop) {
ResultsListPane=new FormPane(rlh,rl,false,DTable.prototype.Resize,Fields[1020]);
SplitterPane=new FormPane(parseInt((splitter.currentStyle["height"])),splitter,false,null,null);
}
FormContainerPane=new FormPane(-1,fc,true,null,null);
if(!rlattop) { 
SplitterPane=new FormPane(parseInt((splitter.currentStyle["height"])),splitter,false,null,null);
ResultsListPane=new FormPane(rlh,rl,false,DTable.prototype.Resize,Fields[1020]);
}
if (qb)
QBPane=new FormPane(parseInt((qb.currentStyle["height"])),qb,false,null,null);
CreateAdvancedSearchBar();
window.URLParams=[];
var re=/\?*(\w+)=([^\&]*)/g;
var res;
while(res=re.exec(window.location.search)) {
if(res.length==3) {
try { window.URLParams[res[1]]=decodeURIComponent(res[2].replace(/\+/g," ")); }catch(e) {}
}
}
weOnLoad();
SetupHandlers();
FocusMgr_Init();
FocusMgr.SetFocusToFirst();
ARProcessEvent.InitKeywordsEtc();
ARKWGetGlobalKeywords();
FormPane.Layout();
var imode = [];
if("external" in window) { 
imode.push({f:function() {
try { window.external.FormLoaded(); } catch (e) {}
}});
}
if(typeof window["RegisterIntervalEvents"] == "function")
imode.push({f:RegisterIntervalEvents});
if("openingArgs" in window)
window.weArgs=openingArgs;
if (window.weArgs != null) {
if("runGuide" in weArgs)
imode.push({f:ARACTCallGuide, a:[weArgs.runGuide.server, weArgs.runGuide.guidename, weArgs.runGuide.hidden, weArgs.runGuide.tableid, weArgs.runGuide.selectedonly]});
if ("eid" in weArgs) {
var q = { qual: "4\\1\\1\\1\\2\\4\\" + weArgs.eid.length + "\\" + weArgs.eid + "\\",fieldids:[],fieldvals:[],fieldtypes:[]};
imode.push({t:StateMgr,f:StateMgr.OpenWindowQuery, a:[10, q]});
} else if ("qual" in weArgs) {
var mode = 10;
if ("wMode" in weArgs) {
mode = weArgs.wMode;
}
if (typeof weArgs.sort != "undefined") {
if (tablePrefs == null) {
tablePrefs = {"colSort":{},"colWs":{},"colOrd":{}}; 
}
tablePrefs.colSort[1020] = weArgs.sort;
}
imode.push({t:StateMgr,f:StateMgr.OpenWindowQuery,a:[mode, weArgs.qual]});
}
}
imode.push({f:SetupState}); 
return {n : imode};
}
function RLAtBottom() {
if((F(1020) instanceof DTable)&&
F(1020).GetAtBottom())
return true;
if(ARPrefsGetAsNumber(23207)==4)
return true;
return false;
}
function BodyDrag(ed) {
var w=document.body.clientWidth;
if(ed.state==0) {
var y1=(FormContainerPane.mY<ResultsListPane.mY?FormContainerPane.mY:ResultsListPane.mY);
var a=FormContainerPane.mY+FormContainerPane.mH,b=ResultsListPane.mY+ResultsListPane.mH;
var y2=(a>b?a:b);
if(y1>=y2)
WDEDragContext_Stop(); 
ed.dragContext.SetDragBounds(0,y1,w,y2-y1);
} else {
var sply=parseInt(SplitterPane.mObj.style.top),newh;
if(!RLAtBottom())
newh=sply-ResultsListPane.mY;
else
newh=(ResultsListPane.mY+ResultsListPane.mHeight)-(sply+SplitterPane.mObj.offsetHeight);
;
ResultsListPane.mFixedHeight=(newh<8?8:newh);
FormPane.Layout();
}
}
function Form_UpdateToolbar() {
if(ToolBarPane) {
var tb=FormElements["Toolbar"];
;
NodeWrite(tb.firstChild.childNodes[1],StateMgr.GetToolbarTitle());
}
if (QBPane != null) {
if ((ARStateCurrent == 4)) {
F(1005).SVis(
F(1005).mKeepOpen || ARPrefsGetAsNumber(23203) > 0); 
} else {
F(1005).SVis(false);
}
}
}
function NodeWrite(n,str) {
;
while(n.hasChildNodes())
n.removeChild(n.firstChild);
n.appendChild(document.createTextNode(str));
}
function FormAction_Submit() {
LogWrite("Action:Submit");
;
return {c:{t:StateMgr,f:StateMgr.Submit}};
}
function FormAction_Query() {
LogWrite("Action:Query");
;
return {n:{t:StateMgr,f:StateMgr.Query}};
}
function FormAction_Modify() {
LogWrite("Action:Modify");
;
return {n:{t:StateMgr,f:StateMgr.Modify}};
}
function FormAction_ModifyAll() {
LogWrite("Action:ModifyAll");
;
var table = Fields[1020];
;
if (table.GetSelectedRowsByEntryId().length == 0)
CurWFC.status(9365);
return {n:{t:StateMgr, f:StateMgr.ARStateChange, a:[6]}};
}
function FormAction_Clear() {
LogWrite("Action:Clear");
Field_Clear(false);
}
function FormAction_SavedSearches(node) {
LogWrite("Action:Saved Searches");
if (Form.SavedSearchesMenu == null)
Form.SavedSearchesMenu = new SearchesMenu();
Form.SavedSearchesMenu.Open(node, 3);
}
function FormAction_SetToDefaults() {
LogWrite("Action:SetDefaults");
;
return StateMgr.SetDefaults(false, true);
}
function FormAction_NewSearch() {
LogWrite("Action:NewSearch");
;
if (userSearches!=null)
userSearches.lastSearch = null;
return {n:{t:StateMgr,f:StateMgr.ARStateChange, a:[4]}};
}
function FormAction_NewRequest() {
LogWrite("Action:NewRequest");
;
return {n:{t:StateMgr,f:StateMgr.ARStateChange, a:[1]}};
}
function FormAction_NewDialog() {
LogWrite("Action:NewDialog");
;
return {n:{t:StateMgr,f:StateMgr.ARStateChange, a:[2]}};
}
function FormAction_ShowStatusHistory() {
LogWrite("Action:ShowStatusHistory");
;
var sh = F(15).G();
;
if (sh instanceof StatusHistoryType) {
var hist = sh.GetTable();
var title = getLocalizedMessage("Status History -- {0} ({1}) #{2}", [ARKWGetStringByIdx(6), ARKWGetStringByIdx(7), F(1).G().toString()]);
return {c:{f:StatusHistoryPopup, a:[ title, hist ]}};
}
}
function FormAction_ShowHelp() {
LogWrite("Action:ShowHelp");
window.open("help.html");
WorkflowContext.WindowOpened();
}
function FormAction_OpenHomePage() {
LogWrite("Action:HomePage");
weOpen(ARKWGetStringByIdx(30)+"home",(""+new Date().getTime()),"HOME",null,null);
WorkflowContext.WindowOpened();
}
function FormAction_GenericApply() {
LogWrite("Action:GenericApply");
if ((ARStateCurrent == 1)) {
return CurWFC.execute({f : FormAction_Submit});
} else if ((ARStateCurrent == 4)) {
return CurWFC.execute({f : FormAction_Query});
} else if ((ARStateCurrent == 5) || (ARStateCurrent == 6)) {
return CurWFC.execute({f : FormAction_Modify});
}
}
function SetupState() {
;
var state = {f:FormAction_NewSearch};
if (window.weArgs != null && "wMode" in weArgs) {
;
;
state.f = StateMgr.OpenWindowFunctions[StateMgr.OpenWindowStates[weArgs.wMode][0]];
}
var tmpval = CurWFC.execute(state);
var d = new Date();
;
;
;
return tmpval;
}
function SetupHandlers() {
FormElements["FormContainer"].onscroll=FormEvent.Trampoline(function(edata) {
Menu_Close();
});
document.body.onmouseover=FormEvent.Trampoline(function(ed) {
if(!window.weDialogueName) {
if(Menu_DispatchEvent(1,ed))
return false;
var f=Field_FromElement(ed.element);
if(f) {
f.DOMMouseOver(ed);
}
}
return true;
});
document.body.onmousedown=FormEvent.Trampoline(function(ed) {
if(!wePuntFocus()) {
if (Menu_DispatchEvent(2,ed))
return false; 
if(WDEHandleEvent(0,ed))
return false; 
var ee=ed.element;
if(ee=FakeButton_Find(ee)) {
if (FakeButton_Disabled(ee))
return false; 
FakeButton_MouseDown(ee);
}
var f=Field_FromElement(ed.element);
if(f) {
if(f.TracksCaret)
f.TrackCaret(ed.element);
f.DOMMouseDown(ed);
if (ed.element.tagName=="INPUT" || ed.element.tagName=="TEXTAREA" || ed.element.tagName=="LABEL") {
new WorkflowContext({t:FocusMgr, f:FocusMgr.HandleFocusEvt, a:[ed]});
}
}
}
return true;
})
document.body.onmouseup=FormEvent.Trampoline(function(ed) {
if(!wePuntFocus()) {
if (Menu_DispatchEvent(3,ed))
return false; 
if(WDEHandleEvent(1,ed))
return false; 
var ee=ed.element;
if(ee=FakeButton_Find(ee)) {
if (FakeButton_Disabled(ee)) {
return false;
}
FakeButton_MouseUpOut(ee);
}
var f=Field_FromElement(ed.element);
if(f) {
if(f.TracksCaret)
f.TrackCaret(ed.element);
f.DOMMouseUp(ed);
}
}
return true;
});
document.body.onmouseout=FormEvent.Trampoline(function(ed) {
if(!window.weDialogueName) { 
var ee=ed.element;
if(ee=FakeButton_Find(ee)) {
if (FakeButton_Disabled(ee)) {
return false;
}
FakeButton_MouseUpOut(ee);
}
var f=Field_FromElement(ed.element);
if(f)
f.DOMMouseOut(ed);
}
return true;
});
document.body.onkeydown=FormEvent.Trampoline(function(ed) {
if(!wePuntFocus()) {
var ee=ed.element;
var dp=DIVPopup.FindPopup(ee);
if (dp)
return dp.KeyDown(ed);
if(Menu_DispatchEvent(4,ed))
return false; 
if(WDEHandleEvent(3,ed))
return false; 
if (ed.alt && ed.ctrl) {
return Form_FormActionShortcutHandler(ed);
}
if (ed.ctrl && ed.shift && ed.key == 36) {
FocusMgr.SetFocusToFirst();
}
if (ed.ctrl && ed.shift && ed.key == 35) {
FocusMgr.SetFocusToLast();
}
if (ed.key == 9) {
var handled;
if (ed.shift) {
handled = FocusMgr.SetFocusToPrevious(ed);
} else {
handled = FocusMgr.SetFocusToNext(ed);
}
if (handled) {
ed.SetKeyCode(505);
return false;
}
return true;
}
if(ee=FakeButton_Find(ee)) {
if (FakeButton_Disabled(ee))
return false;
}
var f=Field_FromElement(ed.element);
if(f) {
if (ed.ctrl && ed.key == 86) 
return f.FieldValChanged();
new WorkflowContext({t:f,f:f.DOMKeyDown, a:[ed]});
if(ed.mStoppedDefault==true) {
ed.SetKeyCode(505);
return false;
}
}
}
return true;
});
document.body.onkeyup=FormEvent.Trampoline(function(ed) { 
var f=Field_FromElement(ed.element);
if (f) {
f.FieldValChanged();
if(f.TracksCaret)
f.TrackCaret(ed.element);
new WorkflowContext({t:f,f:f.DOMKeyUp,a:[ed]});
}
});
document.body.onpaste=FormEvent.Trampoline(function(ed){
var f=Field_FromElement(ed.element);
if (f) 
setTimeout(function() {
f.FieldValChanged();
},0);
});
document.body.onselectstart=FormEvent.Trampoline(function(ed) {
var f=Field_FromElement(ed.element);
if(f) {
if(f.TracksCaret)
f.TrackCaret(ed.element);
return f.IsMouseSelectable(ed.element);
}
return true;
});
document.body.onclick=FormEvent.Trampoline(function(ed) {
var fakebutton=false;
if(!wePuntFocus()) {
var ee=ed.element;
var dp=DIVPopup.FindPopup(ee);
if (dp)
return dp.Click(ed);
if(Menu_DispatchEvent(0,ed))
return false; 
if(ee=FakeButton_Find(ee)) {
if (FakeButton_Disabled(ee))
return false; 
fakebutton=true;
}
var f=Field_FromElement(ed.element);
if(f) {
if(f.TracksCaret)
f.TrackCaret(ed.element);
new WorkflowContext({f:function() {
var stk={};
if (!(ed.element.tagName=="INPUT" || ed.element.tagName=="TEXTAREA")) {
stk.c={t:FocusMgr, f:FocusMgr.HandleFocusEvt, a:[ed]};
}
stk.n = {f: function() {
if(f.GetFocusElementForEvent(ed)!=null) {
return {c:{t:f,f:f.DOMClick, a:[ed]}};
} else {
if (f.IsLabelPart(ed.element)) {
if (1005 in Fields && F(1005).GVis()) {
if (ed.element.className.indexOf("do")!=-1 && 
(parseInt(ed.element.parentNode.getAttribute("ARID")) != 178)) 
{
var al = new AlertPopup();
var contents = ed.element.innerHTML + getLocalizedMessage(" is a display only field.");
al.SetContents(getLocalizedMessage("Error"), contents);
al.ShowCentredPopup();
}
else
F(1005).InsertAtCaret("'" + f.GLabel().ARQualifierEncode() + "'");
}
ed.StopBubbling();
ed.StopDefault();
}
}
}};
return stk; 
}});
} else if(fakebutton&&"Toolbar_Click" in window)
new WorkflowContext({f:Toolbar_Click,a:[ed]});
}
return !fakebutton;
});
document.body.ondblclick=FormEvent.Trampoline(function(ed) {
if(!wePuntFocus()) {
var ee=ed.element;
if(ee=FakeButton_Find(ee)) {
if (FakeButton_Disabled(ee)) {
return false; 
}
}
var f=Field_FromElement(ed.element);
if(f) {
if(f.TracksCaret)
f.TrackCaret(ed.element);
if(f.GetFocusElementForEvent(ed)!=null)
new WorkflowContext({t:f,f:f.DOMDoubleClick,a:[ed]});
f.FieldValChanged();
}
}
return true; 
});
document.body.onkeypress=FormEvent.Trampoline(function(ed) {
if (!wePuntFocus()) {
var ee=ed.element;
var dp=DIVPopup.FindPopup(ee);
if (dp)
return dp.KeyPress(ed);
if (ed.alt && ed.ctrl) {
return Form_FormActionShortcutHandler(ed);
}
var f=Field_FromElement(ed.element);
if(f) {
if ((ed.key==13) || (ed.key==32)) { 
if(ee=FakeButton_Find(ee)) {
if (FakeButton_Disabled(ee)) {
return false;
}
FakeButton_MouseDown(ee);
setTimeout(function() {
FakeButton_MouseUpOut(ee);
}, 250);
var stk={t:f,f:f.DOMClick,a:[ed]};
new WorkflowContext(stk);
return false;
}
}
var stk={t:f,f:f.DOMKeyPress, a:[ed]};
new WorkflowContext(stk);
}
}
return true;
});
window.onfocus=FormEvent.Trampoline(function(edata) {
if (!wePuntFocus()) {
if (FocusMgr)
FocusMgr.WindowGotFocus();
FieldList.SetAllGlobals();
}
return true;
});
window.onresize=FormEvent.Trampoline(function(edata) {
Menu_Close();
FormPane.Layout();
return true;
});
window.onbeforeunload=FormEvent.Trampoline(function(edata) {
Menu_Close();
var abortclose = {};
new WorkflowContext({t:StateMgr,f:StateMgr.WindowIsClosing, a:[abortclose]});
if (abortclose.ab) {
StateMgr.mWindowIsClosed = false;
return getLocalizedMessage("One or more active links failed when closing the form.  Close this form anyway?", null);
} else if (((ARStateCurrent == 5) || (ARStateCurrent == 1)) && Field_GetChanged()){
StateMgr.mWindowIsClosed = false;
return getLocalizedMessage("Your changes have not been saved or sent.  Do you really want to close the window?", null);
} else {
StateMgr.ClearSnapshot();
weOnUnload();
}
});
}
function ToggleFocusFocusToField() {
var newFocusID = Form.LastFormFID;
;
if (newFocusID == 0)
newFocusID = FieldListInfo.firstField.mID;
Form.LastFormFID = 0;
return new WorkflowContext({t:FocusMgr, f : FocusMgr.SetFocusToField, a:[newFocusID]});
}
function ToggleFocusResultsList() {
var curFocusID = FocusMgr.getFocusedID();
var newFocusID;
if (curFocusID == 1020) {
return ToggleFocusFocusToField()
}
else if (curFocusID == 1005) {
return ToggleFocusAdvSearch();
}
else {
if (F(1020).GVis()) {
Form.LastFormFID = curFocusID;
return new WorkflowContext({t:FocusMgr, f : FocusMgr.SetFocusToField, a:[1020]});
}
}
}
function ToggleFocusAdvSearch() {
var curFocusID = FocusMgr.getFocusedID();
if (curFocusID == 1005) {
ToggleFocusFocusToField();
}
else {
if (F(1005).GVis()) {
Form.LastFormFID = curFocusID;
return new WorkflowContext({t:FocusMgr, f : FocusMgr.SetFocusToField, a:[1005]});
}
}
}
function Form_FormActionShortcutHandler(ed) {
switch(ed.key) {
case 13: return new WorkflowContext({f : FormAction_GenericApply});
case 113: return new WorkflowContext({f : FormAction_NewRequest});
case 114: return new WorkflowContext({f : FormAction_NewSearch});
case 117: return ToggleFocusResultsList();
case 76: if(ARStateCurrent == 1 || ARStateCurrent == 4) { 
return FormAction_Clear();
}
else
return;
case 85: return new WorkflowContext({f : FormAction_SetToDefaults});
case 72: return new WorkflowContext({f : FormAction_ShowStatusHistory});
case 83: return ToggleFocusAdvSearch();
default: return;     
}
}
var AbsDocumentPath;
function GetDocumentLocation() {
var loc = document.location;
var abs = loc.protocol + "//" + loc.hostname;
if (loc.port)
abs += ":" + loc.port;
var path = loc.pathname;
var len = path.length;
if (path.charAt(len - 1) != "/") {
len = path.lastIndexOf("/");
path = path.substring(0, len + 1);
}
return abs + path;
}
function SetContextPath() {
if (AbsContextPath == null) {
AbsDocumentPath = GetDocumentLocation();
AbsContextPath = AbsDocumentPath + RelContextPath;
var req = AbsContextPath.split("/");
var res = [];
for(var i=0;i<req.length;++i) {
if (req[i]=="..") {
;
res.pop();
} else
res.push(req[i]);
}
AbsContextPath = res.join("/");
} else {
AbsDocumentPath = "";
}
;
ARKWSet(30, AbsContextPath);
}
function GetAppStyleSheet(path) {
var appstylesheet = (((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : "") == "") ? "" : path + "apps/" + encodeURIComponent(ARKWGetStringByIdx(7)) + "/" + encodeURIComponent(((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : "")) + "/resources/stylesheets/ARSystem.css";
}

function WorkflowException(code, arg) {
;
this.mArg=arg;
this.mCode=code;
if (code<0) {
LogWrite("WorkflowException: " + code);
}
}
WorkflowException.prototype.toString=function() {
;
if(typeof this.mArg=="number")
return "Non-translated, non-formatted AR Error: "+this.mArg;
;
return WorkflowContext_StatusToString(this.mArg);
}

String.prototype.trim = function(flags, blankspace) {
;
var string = this;
if (flags & 1)
string = string.replace((blankspace?(/^[ \t]+/):(/^\s+/)), "");
if (flags & 2)
string = string.replace((blankspace?(/[ \t]+$/):(/\s+$/)), "");
return string;    
}
String.prototype.compareString=function(str) {
;
var len1=this.length;
var len2=str.length;
var min=Math.min(len1,len2);
for (var i=0; i<min; i++) {
if (this.charCodeAt(i) > str.charCodeAt(i)) {
return 1;
} else if (this.charCodeAt(i) < str.charCodeAt(i)) {
return -1;
}
}
if (len1 > len2) {
return 1;
} else if (len1 < len2) {
return -1;
}
return 0;
}
String.prototype.isDigits = function() {
return (this.match(/[0-9]+/) != null);
}
String.prototype.isNumeric = function() {
return (this.match(/^[\d]+$/) != null);
}
String.prototype.replaceArgs = function() {
var args = arguments;
return this.replace(/\{(\d+)\}/g, function(sub, p) { return args[p]; });
}
var REGEXPSPECIALCHARS = /([\.\*\?\+\[\]\(\)\{\}\^\$\|\\])/g;
String.prototype.toRegExp = function() {
return this.replace(REGEXPSPECIALCHARS,"\\$1");
}
String.prototype.HTMLEncode = function() {
return this.replace(/(<)|(>)|(\")|(&)/gim, function (sub, p0, p1, p2, p3) {
if (p0) return "&lt;";
if (p1) return "&gt;";
if (p2) return "&quot;";
if (p3) return "&amp;";
});
}
String.prototype.HTMLDecode = function() {
return this.replace(/(&lt;)|(&gt;)|(&quot;)|(&amp;)/gim, function (sub, p0, p1, p2, p3) {
if (p0) return "<";
if (p1) return ">";
if (p2) return "\"";
if (p3) return "&";
});
}
String.prototype.JScriptEncode = function() {
return this.replace(/(\")|(\n)|(\r)|(\\)/gim, function (sub, p0, p1, p2, p3) {
if (p0) return "\\\"";
if (p1) return "\\n";
if (p2) return "\\r";
if (p3) return "\\\\";
});
}
String.prototype.ARQualifierEncode = function() {
return this.replace(/(')/gim, function (sub, p0) {
        if (p0) return "''";
    });
}

//escape single quote
String.prototype.EscapeQuote = function() {
    return this.replace(/(')/gim, function (sub, p0) {
if (p0) return "\\'";
});
}
String.prototype.ARToJSIdentifier = function() {
return this.replace(/[^A-Za-z0-9]/g, function (substr) { 
return "_" + substr.charCodeAt(0);
});
}
String.prototype.compareToIgnoreCase = function(arg) {
return this.toLowerCase() == arg.toLowerCase();
}
String.NBSP = new RegExp(String.fromCharCode(160),"g");
String.prototype.replaceNBSP = function() {
return this.replace(String.NBSP, ' ');
}
String.fromCharCodeWithNumPad = function(key) {
if (key >= 96 && key <= 105) {
key = key - (96 - 48);
}
return String.fromCharCode(key);
}

function weWindow(win,arg,wname,wtype,continuation) {
;
this.mWin=win;
this.mArg=arg;
this.mName=wname;
this.mType=wtype;
this.mContinuation=continuation;
this.mArrived=false;
window.weChildren[wname]=this;
}
function weDeepCopy(dest,src) {
for(var i in src) {
if(typeof src[i]=="number"||typeof src[i]=="boolean") {
dest[i]=src[i];
} else if(typeof src[i]=="string") {
dest[i]=new String(src[i]);
} else if(typeof src[i]=="object") {
dest[i]={};
weDeepCopy(dest[i],src[i]);
} else
LogAndAlert("Unknown type "+typeof i);
}
}
function weDeepSerialise(src,strobj) {
var amarray=src instanceof Array;
strobj.push(amarray?"[":"{");
var first=true;
for(var i in src) {
var ty=typeof src[i];
if (ty=="undefined")
continue;
if(!first)
strobj.push(",");
if(!amarray)
strobj.push(i+":");
if(ty=="number"||ty=="boolean") {
strobj.push(src[i]);
} else if(ty=="string") {
var strval=src[i].JScriptEncode();
strobj.push("\""+strval+"\"");
} else if(ty=="object") {
if(src[i] != null) {
weDeepSerialise(src[i],strobj);
} else                
strobj.push(src[i] + "");
} else {
;
}
first=false;
}
strobj.push(amarray?"]":"}");
}
function weDeepSerialiseVariable(argobj) {
var argstr=[];
weDeepSerialise(argobj,argstr);
return argstr.join("");
}
function weOnLoad() {
window.weChildren=[]; 
window.weDialogueName=null; 
if ("dialogArguments" in window) {
window.name = window.dialogArguments.name;
window.opener = window.dialogArguments.opener;
window.opener.weChildren[window.name].mWin = window;
}
try {
if(window.opener&&!window.opener.closed&&window.name==window.opener.name)
window.opener=null;
} catch (e) {
window.opener=null;
}
if(window.opener&&!window.opener.closed&&window.name!="") {
if(window.opener&&!window.opener.closed&&window.opener.window.weChildCome) {
window.opener.window.weChildCome(window,window.name, window.arWindowType);
window.arWindowType=window.opener.window.weExtractWindowType(window.name);
window.weArgs=window.opener.window.weExtractArgs(window.name);
}
} else {
if(window.name=="") {
window.weArgs=null;
window.name="ARRoot"+new Date().getTime(); 
} else {
if(!("weArgs" in window))
window.weArgs=null;
}
}
if(window.URLParams) {
if ("eid" in window.URLParams) {
if (!window.weArgs) window.weArgs = {};
weArgs.eid = window.URLParams.eid;
}
if ("qual" in window.URLParams) {
if (!window.weArgs) window.weArgs = {};
try {
var encoded = new NDXParseAndEncodeQualifier(ARKWGetByName("SERVER").toString(), ARKWGetByName("SCHEMA").toString(), ARKWGetByName("VUI").toString(), window.URLParams.qual).result;
weArgs.qual = {qual : encoded, fieldids:[],fieldvals:[],fieldtypes:[]};
} catch (ex) {
LogAndAlert(ex);
}            
}
if ("mode" in window.URLParams) {
if (!window.weArgs) window.weArgs = {};
weArgs.wMode = (window.URLParams.mode.compareToIgnoreCase("submit") || window.URLParams.mode.compareToIgnoreCase("create")) ? 2 : 1;
}
}
if("external" in window) { try{ window.external.FormLoaded(); } catch (e) {} }
}
window.weOpen=function(url,wname,wtype,arg,dims) {
;
;
;
;
;
if(weAmDialogue(window.name)) {
if(window.opener&&!window.opener.closed&&window.opener.window.weOpen)
return window.opener.window.weOpen(url,wname,wtype,arg,dims);
return null;
}
var win=window.open(url,wname,(dims?(",width="+dims[0]+",height="+dims[1]):""));
WorkflowContext.WindowOpened();
new weWindow(win,arg,wname,wtype,null);
return win;
}
function weDisableStuff() {
if (OpenDIVPopup && OpenDIVPopup.mModal)
{
return;
}    
var e=document.createElement("DIV");
window.weDisabledObj=e;
e.className="BlankOutForm";
document.body.appendChild(e);
}
function weEnableStuff() {
if (OpenDIVPopup && OpenDIVPopup.mModal)
{
return;
}
if (window.weDisabledObj) {
document.body.removeChild(window.weDisabledObj);
window.weDisabledObj=null;
}
}
window.weOpenDialogue=function(url,wtype,arg,cont,dims) {
;
;
arg.wMode = 0; 
if(window.weDialogueName!=null)
return; 
var wname=new Date().getTime()+"D";
window.weDialogueName=wname; 
weDisableStuff();
var centerX, centerY;
var posSizeStr = "";
if (dims) {
centerX = screen.width / 2;
centerY = screen.height / 2;
centerX -= (dims[0] / 2);
centerY -= (dims[1]/ 2);
if (centerX < 0)
centerX = 0;
if (centerY < 0)
centerY = 0;
centerX = Math.floor(centerX);
centerY = Math.floor(centerY);
posSizeStr = ",width="+dims[0]+",height="+dims[1] +
",left="+centerX+",top="+centerY;
}
var w=window.open(url,wname,"toolbar=no,location=no,resizable=yes,scrollbars=no,menubar=no"+posSizeStr);
if (w == null) {
window.weDialogueName=null;
weEnableStuff();
return w;
}
WorkflowContext.WindowOpened();
var mywin=new weWindow(w,arg,wname,wtype,cont);
wePuntFocus();
return w;
}
window.weOpenModalPopup=function(url,wtype,arg,res,dims) {
;
;
;
arg.wMode = 0; 
if(window.weDialogueName!=null)
return; 
var wname=new Date().getTime()+"D";
window.weDialogueName=wname; 
var mywin=new weWindow(null,arg,wname,wtype,function(arg) { res.result = arg; CurWFC.resume(); });
var w=window.showModalDialog(url,{name:wname,opener:window},"scroll:0;resizable:1;unadorned:1;status:0;help:0"+(dims?(";dialogWidth:"+dims[0]+"px;dialogHeight:"+dims[1]+"px"):""));
res.result=w;
return {i:1};
}
window.weOpenModelessPopup=function(url,wtype,arg,cont,dims) {
;
;
arg.wMode = 0; 
var wname=new Date().getTime()+"MD"; 
var w=window.showModelessDialog(url,{name:wname,opener:window},"scroll:0;resizable:1;unadorned:1;status:0;help:0"+(dims?(";dialogWidth:"+dims[0]+"px;dialogHeight:"+dims[1]+"px"):""));
WorkflowContext.WindowOpened();
var mywin=new weWindow(w,arg,wname,wtype,cont);
return w;
}
window.weCloseNonModalChildren=function() {
for(var i in window.weChildren) {
var wi=window.weChildren[i];
if(wi.mName.indexOf("MD")!=-1)
window.weChildren[i].mWin.weForceDialogueClose();
}
}
window.weExtractWindowType=function(wname) {
var type=window.weChildren[wname].mType;
;
return type;
}
window.weExtractArgs=function(wname) {
var arg=window.weChildren[wname].mArg;
;
window.weChildren[wname].mArg=null;
return arg;
}
window.weChildGone=function(wname,retobj) {
if(!weChildren[wname]) {
;
return;
}
;
var winobj=window.weChildren[wname];
if(weAmDialogue(wname)) {
;
if(weAmModal(wname)) {
window.weDialogueName=null;
if(winobj.mContinuation==null)
weEnableStuff();
}
FieldList.SetAllGlobals();
if(winobj.mContinuation!=null) {
var continue_obj={};
if (retobj) {
weDeepCopy(continue_obj,retobj);
}
window.setTimeout(function() {
if(weAmModal(wname))
weEnableStuff();
var c=winobj.mContinuation;
if (c) c(continue_obj);
},1);
}
}
delete window.weChildren[wname];
}
window.weChildCome=function(awin,wname,wtype) {
var win=window.weChildren[wname];
if(!win)
win=new weWindow(awin,null,wname,wtype,null);
win.mArrived=true;
}
function weOnUnload() {
var haveloading=false;
;
for(var i in window.weChildren) {
if(window.weChildren[i].mArg!=null) {
haveloading=true;
break;
}
}
if(haveloading)
LogAndAlert(getLocalizedMessage("Warning: If AR System windows are still loading, they will load incorrectly.\nIf you have AR System windows still loading, do not press 'OK' until they are complete."));
if(window.weDialogueName!=null) {
;
window.weChildren[window.weDialogueName].mWin.window.weForceDialogueClose();
}
weCloseNonModalChildren();
try {
if(window.opener&&!window.opener.closed&&window.opener.weChildGone) {
window.opener.weChildGone(window.name,"weDialogueReturnValue" in window ? window.weDialogueReturnValue:null);
} 
} catch (ignore) {
}
document.body.disabled=true;
var e=document.createElement("DIV");
e.style.top=0;
e.style.left=0;
e.style.width=2400;
e.style.height=1900;
e.style.backgroundColor="white";
e.style.zIndex=100000;
document.body.appendChild(e);
if(weAmDialogue(window.name))
setTimeout("window.close()", 1);
}
function weCloseDialogue(retobj) {
;
window.weDialogueReturnValue=retobj;
window.close();
}
var REGEXPDIALOGUE = /^[0-9]+(D{1}|(M{1}D{1}))$/g
function weAmDialogue(nstr) {
return(nstr.match(REGEXPDIALOGUE)!=null);
}
function weAmModal(nstr) {
return(nstr.indexOf("M")==-1);
}
function weGetOpenDialogueName() {
return window.weDialogueName;
}
function weGetWindowType() {
;
return window.arWindowType;
}
window.weForceDialogueClose=function() {
;
window.onbeforeunload=window.onunload=null;
if(window.weDialogueName!=null) {
;
window.weChildren[window.weDialogueName].mWin.window.weForceDialogueClose();
}
setInterval(close,10); 
}
function wePunt() {
if(window.weDialogueName) {
var w=window.weChildren[window.weDialogueName];
if (w) {
if(w.mWin) {
if (!w.mWin.closed) {
if(!w.mWin.closed&&typeof w.mWin.window!="unknown"&&w.mWin.window.wePunt)
w.mWin.window.wePunt();
} else if(!w.mArrived) {
weChildGone(window.weDialogueName,null);
}
} else {
}
}
} else
window.focus();
}
function wePuntFocus() {
if(window.weDialogueName) {
setTimeout(wePunt,100);
if("Menu_Close" in window.self) 
Menu_Close();
return true;
}
return false;
}
function weCloseAllWindows(windowObj, topLevel, url) {
if (windowObj.weChildren) {
for (winId in windowObj.weChildren) {
var win = windowObj.weChildren[winId].mWin;
if (win && !win.closed && "weCloseAllWindows" in win) {
weCloseAllWindows(win, false, null);
}
}
}
if (windowObj.weAmDialogue(windowObj.name)) {
windowObj.weCloseDialogue(null);
} else {
if (topLevel == true && url != null)
{
try {
windowObj.document.location = url;
} catch (ignore) {
}  
}
else
weCloseWindow(windowObj, topLevel);
}
}
function weRecurAllWindowsIterator(arraylist) {
arraylist[window.self.name]=window.self;
for(var i in window.weChildren) {
var wi=window.weChildren[i];
if(wi.mWin&&!wi.mWin.closed&&"weRecurAllWindowsIterator" in wi.mWin)
wi.mWin.weRecurAllWindowsIterator(arraylist);
}
}
function weGetAllWindows() {
var list=[];
var win=window;
list[window.name]=window;
try {
while(win.opener&&!win.opener.closed&&"weRecurAllWindowsIterator" in win.opener) {
win=win.opener;
list[win.name]=win;
}
} catch(e) {};
try {
win.weRecurAllWindowsIterator(list);
} catch (e) {};
return list;
}
function weGetChildWindows() {
var list=[];
try {
weRecurAllWindowsIterator(list);
} catch(e) {}
delete list[window.name]; 
return list;
}
function weGetWindowByName(wname) {
var list=weGetAllWindows();
try {
for(var i in list) {
var li=list[i];
if(li&&!li.closed&&"weRecurAllWindowsIterator" in li) {
if(li.name==wname)
return li;
}
}
} catch(e) {}
return null;
}
function weCloseWindow(windowObj, topLevel) {
if (topLevel && windowObj.history.length != undefined && windowObj.history.length != 0)
windowObj.history.back();
else {
windowObj.close(); 
setInterval(function() { if (StateMgr.mWindowIsClosed)windowObj.close(); },0); 
}
}
function weGetOpener()
{
return window.opener;    
}
function weDisplayWFNotes(windowObj)
{
if (windowObj.CurWFC)
{
var workflowNotes = windowObj.CurWFC.notes;
if(workflowNotes.length > 0) {
windowObj.CurWFC.notes = [];
return MessagePopup(workflowNotes);    
}
}
}
function weDisplayWFException(exc) {
if ((exc instanceof WorkflowException) && exc.mArg && exc.mArg.length > 0) {
return MessagePopup(exc.mArg);
} else
throw exc;
}

var WDECurrentDrag=null;
function WDEDragContext(ed,e) {
;
;
this.mStartElement=e;
this.mOrigX=this.mOrigY=0;
this.mDX=-ed.ox;
this.mDY=-ed.oy;
this.mX=this.mY=this.mMouseX=this.mMouseY=0;
this.mWidth=this.mStartElement.offsetWidth;
this.mHeight=this.mStartElement.offsetHeight;
this.mParentElement=this.mStartElement.offsetParent;
while(!this.mParentElement.getAttribute("draghandler")&&this.mParentElement)
this.mParentElement=this.mParentElement.offsetParent;
;
this.mMaxX=this.mParentElement.offsetWidth;
this.mMaxY=this.mParentElement.offsetHeight;
this.mMinX=this.mMinY=0;
this.mNewElement=null;
this.mHandler=window.self[this.mParentElement.getAttribute("draghandler")];
;
this.mDragState=0;
WDECurrentDrag=this;
this.mParentElement.onmousemove=FormEvent.Trampoline(function(mmdata) {
;
return !WDECurrentDrag.MouseMove(mmdata);
});
}
WDEDragContext.prototype.MouseMove=function(ed) {
;
var e=ed.element;
var x=ed.ox,y=ed.oy;
var res=ComputeElementPosition(e,this.mParentElement,x,y);
x=res.x;
y=res.y;
var handle=-1;
this.mMouseX=x;
this.mMouseY=y;
if(this.mDragState==0) {
this.mOrigX=x;
this.mOrigY=y;
this.mDragState=1;
} else if(this.mDragState==1) {
var dy=Math.abs(y-this.mOrigY);
var dx=Math.abs(x-this.mOrigX);
if(Math.sqrt(dy*dy+dx*dx)>4) {
if(this.mStartElement.getAttribute("dragoriginal"))
this.mNewElement=this.mStartElement;
else {
this.mNewElement=this.mStartElement.cloneNode(true);
;
this.mNewElement.setAttribute("draggable","");
this.mParentElement.appendChild(this.mNewElement);
}
this.mNewElement.className=this.mNewElement.className+" dragging";
this.mDragState=2;
x+=dx;
y+=dy;
handle=0;
} else {
return false;
}
} else if(this.mDragState==2) {
y+=this.mDY;
y=(y<this.mMinY?this.mMinY:y);
if(y+this.mHeight>this.mMaxY)
y=this.mMaxY-this.mHeight;
x+=this.mDX;
x=(x<this.mMinX?this.mMinX:x);
if(x+this.mWidth>this.mMaxX)
x=this.mMaxX-this.mWidth;
this.mNewElement.style.top=y;
this.mNewElement.style.left=x;
handle=1;
}
if(handle!=-1) {
this.mX=x;
this.mY=y;
this.CallHandler(handle);
}
return true;
}
WDEDragContext.prototype.SetDragBounds=function(minx,miny,maxx,maxy) {
if(minx!=null)
this.mMinX=minx;
if(miny!=null)
this.mMinY=miny;
if(maxx!=null)
this.mMaxX=maxx;
if(maxy!=null)
this.mMaxY=maxy;
}
WDEDragContext.prototype.CallHandler=function(evt) {
var o={};
o.state=evt;
o.x=this.mX;
o.y=this.mY;
o.mx=this.mMouseX;
o.my=this.mMouseY;
o.srcElement=this.mStartElement;
o.newElement=this.mNewElement;
o.dragContext=this;
o.original=(this.mStartElement==this.mNewElement);
this.mHandler(o);
}
WDEDragContext.prototype.Stop=function(aborted) {
this.mParentElement.onmousemove=null;
if(this.mDragState>=2) {
if(this.mStartElement!=this.mNewElement)
this.mParentElement.removeChild(this.mNewElement);
else
this.mStartElement.className=this.mStartElement.className.replace(/dragging/,"");
if(aborted) {
this.mX=this.mOrigX+this.mDX;
this.mY=this.mOrigY+this.mDY;
}
this.CallHandler(aborted?3:2);
}
WDECurrentDrag=null;
}
function WDEDragContext_Stop() {
if(WDECurrentDrag!=null)
WDECurrentDrag.Stop(true);
}
WDEDragContext.prototype.HandleMouseUp=function(ed) {
var e=ed.element;
while(e&&e!=this.mParentElement)
e=e.offsetParent;
this.Stop(e!=this.mParentElement);
return true;
}
function WDEHandleEvent(etype,ed) {
;
if(etype==0) {
var e=ed.element;
while(e&&!e.getAttribute("draggable"))
e=e.offsetParent;
if(!e||!e.getAttribute("draggable"))
return false;
if(ed.button!=1||WDECurrentDrag)
return true;
new WDEDragContext(ed,e);
return true;
} else if(etype==1&&WDECurrentDrag!=null) {
return WDECurrentDrag.HandleMouseUp(ed);
} else if(etype==3&&ed.key==27&&WDECurrentDrag!=null) {
WDEDragContext_Stop();
return true;
}
return false;
}

var WFThreadsList = [];
var CurWFC;
function WorkflowContext(se) {
this.execStks = [];
this.guideCtxt = [];
this.notes = [];
this.mCallbacks = [];
this.mStatusTimeout=null;
this.dirtyElements = {};
if(WFThreadsList.length==0) {
for(var i in AsyncFields)
AsyncFields[i].SetAsync(1);
}
WFThreadsList.push(this);
CurWFC = this;
this.AddCallback(this, AsyncField_DecrAsyncRef);
this.execute(se);
}
WorkflowContext.prototype.mOpenedWindow=false;
WorkflowContext.prototype.setStatus=function(str) {
var oldstr=window.status;
window.status=str;
if(this.mStatusTimeout!=null)
clearTimeout(this.mStatusTimeout);
this.mStatusTimeout=setTimeout(function() {
window.status=oldstr;
this.mStatusTimeout=null;
},5000);
}
var INTERRUPTED_SE = {i:1};
WorkflowContext.prototype.executeAll = WorkflowContext.prototype.resume = WorkflowContext.prototype.execute =  function
(se) {
var iss = this.execStks;
var popDepth;
var curstack;
if (se) {
if (se instanceof Array) {
iss.push(se);
} else {
iss.push([se]);
}
popDepth = 1;
} else {
popDepth = iss.length;
}
try {
while (popDepth > 0) {
curstack = iss[iss.length - 1];
while (curstack.length > 0) {
var se = curstack.pop();
if (se.eonly) {
continue;
}
;
;
var r;
try {
r = (se.a) ? se.f.apply(se.t ? se.t:null, se.a) :
((se.t) ? se.f.apply(se.t, []) : se.f());
} catch (ex0) {
while (true) {
if (se.e) {
var exargs = [ex0];
if (se.ea) { 
exargs = exargs.concat(se.ea);
}
try {
r  = (se.t) ? se.e.apply(se.t, exargs) : se.e.apply(null, exargs);
;
break; 
} catch (ex1) {
ex0 = ex1;
}
}
do {                        
if (curstack.length > 0) {
se = curstack.pop();
} else {
se = null;
iss.pop(); 
popDepth--;
if (popDepth > 0) {
curstack = iss[iss.length -1];
} else { 
if (iss.length > 0) {
throw ex0; 
} else {
if (typeof ex0 != "object") {
LogAndAlert("Caught exception " + (ex0+(("name" in ex0)?("["+ex0.name+"]"):"")+("message" in ex0)?(":"+ex0.message):""));
return false;
}
if (ex0 instanceof WorkflowException) {
if (ex0 != "")
{
if(this.notes.length > 0) {
var r = MessagePopup(this.notes);
this.notes = [];
;
iss.push([{f:MessagePopup, a:[ex0.mArg]}]);
}
else {
var r = MessagePopup(ex0.mArg);
;
}
iss.push([{f:function() {}}]);
return INTERRUPTED_SE;
}
return false;
} else {
LogAndAlert("Caught exception " + (ex0+(("name" in ex0)?("["+ex0.name+"]"):"")+("message" in ex0)?(":"+ex0.message):""));
return false;
}
}
}
}
} while (se == null);                    }
}
if(r) {
;
if(r.i) {
if(r.n) {
curstack.push(r.n);
}
;
return INTERRUPTED_SE;
} else {
if(r.n) {
if (r.n instanceof Array) {
for (var el in r.n) {
curstack.push(r.n[el]);
}
} else {
curstack.push(r.n);
}
}
if(r.c) {
if (se.e) {
var excEntry = (se.ea) ? { eonly:1, e: se.e, ea: se.ea, t: se.t } 
: { eonly:1, e: se.e, t: se.t };
curstack.push(excEntry);
}
curstack.push(r.c);
}
}
}
}
iss.pop(); 
popDepth--;
}
return false;
} finally {
if (iss.length==0) {
if (this.notes.length > 0) {
var r = MessagePopup(this.notes);
;
;
iss.push([{f:function() {}}]);
this.notes = [];
return INTERRUPTED_SE;
}
if(WFThreadsList.length==1) {
this.RunCallbacks();
var chg = Field_GetChanged();
this.signalDOM();
if ((chg == 0) && (Field_GetChanged()!=0)) {
Field_ClearChanged();
}
}
FocusMgr.WorkflowComplete();
var lastThread = WFThreadsList.pop();
;
CurWFC = WFThreadsList[WFThreadsList.length - 1];
}
}
}
var FIDMATCH=/^((.*)(:)\s*([0-9]+)\s*)$|([0-9]+)$/;
function WorkflowContext_StatusFIDToLabel(msg) {
var mat = msg.match(FIDMATCH);
if (mat != null && ((mat[4]!=""&&mat[4]!=null) || (mat[5]!=""&&mat[5]!=null))) {
var fid = (mat[4]==""||mat[4]==null) ? parseInt(mat[5]) : parseInt(mat[4]);
var lab = F(fid).GLabel();
if (lab == null || lab==" " || lab =="") {
lab = F(fid).GName();
}
if (lab != null && lab != "") {
msg = (mat[2]==null?"":mat[2]) + (mat[3]==null?"":mat[3]) + " " + lab;
}
}
return msg;
}
function WorkflowContext_StatusToString(arr) {
;
var ntypes={1:"ARWARN",
0:"ARNOTE",
2:"ARERR",
3:"ARERR"};
var out=[];
for(var i=0;i<arr.length;++i) {
with (arr[i]) {
if (n==0)
continue;
if (m != null && m != "" || a == null || ntypes[t] == "ARERR" || ntypes[t] == "ARWARN") {
if (m==null || m=="") {
m=getLocalizedMessage(n, null);
}
;
if ("cId" in arr[i] && (t != 0) && (n < 9999)) {
out.push(WorkflowContext_StatusFIDToLabel(m));
} else {
if(m != n) {
out.push(m);
}
}
if (a) {
if(m != n) {
out.push(" :\n");
}
if ("cId" in arr[i] && (t != 0) && (n < 9999)) {
out.push(WorkflowContext_StatusFIDToLabel(a));
} else {
out.push(a);
}
}
} else {
out.push(a);
}
out.push(" (");
out.push(ntypes[t]);
out.push(" ");
out.push(n);
out.push(")");
out.push("\n");
}
}
return out.join("");
}
WorkflowContext.prototype.status = function(arg) {
;
var workflowNotes = this.notes;
if(arg instanceof Array) {
var errors=[];
for(var i in arg) {
var ai=arg[i];
if(ai.t==2||ai.t==3)
errors.push(ai);
else if (ai.t==0 && ai.n==8914)
LogWrite(WorkflowContext_StatusToString([ai]), true);
else
workflowNotes.push(ai);
}
if(errors.length) {
throw new WorkflowException(0, errors);
}
} else {
throw new WorkflowException(0,[{n:arg,t:2,m:null,a:null}]);
}
}
WorkflowContext.WindowOpened=function() {
if(CurWFC)
CurWFC.mOpenedWindow=true;
}
WorkflowContext.prototype.enterGuide = function(gs) {
this.guideCtxt.push(gs);
}
WorkflowContext.prototype.getGuideState = function() {
var len = this.guideCtxt.length;
if (len > 0) {
return this.guideCtxt[len - 1];
} else {
return null;
}
}
WorkflowContext.prototype.exitGuide = function() {
this.guideCtxt.pop();
}
WorkflowContext.prototype.AddCallback = function(t, func, args) {
this.mCallbacks.push({t:t, func:func, args:args});
}
WorkflowContext.prototype.RunCallbacks = function() {
while (this.mCallbacks.length > 0) {
var o = this.mCallbacks.pop();
o.func.apply(o.t, o.args ? o.args : []);
}
;
}
WorkflowContext.prototype.addDirtyElement = function(id, ele) {
;
;
this.dirtyElements[id] = ele;
}
WorkflowContext.prototype.signalDOM = function() {
;
for (var ii in this.dirtyElements) {
if ("onchange" in this.dirtyElements[ii]) {
FormEvent.FireChangeEvent(this.dirtyElements[ii]);
}
}
this.dirtyElements = {};
}

var FocusMgr;
function FocusMgr_Init() {
FocusMgr = new function() {
this.mCurFocusID = 0;
this.mCurFocusElement = null;
this.mOpenedWindow=false;
this.mFocusStk = [];
this.HandleFocusEvt = function(ed) {
;
;
if (this.mFocusStk.length > 0) {
return;
}
var tid = ed.element.getAttribute("ARTABID");
if(!tid&&ed.element.parentNode.parentNode&&ed.element.parentNode.parentNode.getAttribute("ARTABID"))
tid=ed.element.parentNode.parentNode.getAttribute("ARTABID");
if(!tid&&ed.element.parentNode&&ed.element.parentNode.getAttribute("ARTABID"))
tid=ed.element.parentNode.getAttribute("ARTABID");
var f=(tid) ? Fields[tid] : Field_FromElement(ed.element);
if (f) {
var focusEle = f.GetFocusElementForEvent(ed);
if (focusEle!=null) {
this.mUIFocusElement = ed.element;
return {c:{t:this, f:this.changeFocusTo, a:[f.mID, ed, focusEle]}};
} else {
this.mForceFocusToCurrent=true;
}
}
}
this.changeFocusTo = function(nextID, evt, focusEle) {
;
;
;
if (nextID != this.mCurFocusID) {
var flen = this.mFocusStk.length;
if (flen == 0) {
this.mFocusStk.push({ty:2});
this.mWFC = CurWFC;
}
this.mFocusStk.push({id:nextID, ed:evt, fe:focusEle, ty: 1});
if (this.mCurFocusID != 0) {
this.mFocusStk.push({id:this.mCurFocusID, ed:new FormEvent(this.mCurFocusID), ty: 0 });
}
return {n:{t:this, f:this.transitionFocus, a:[flen]} };
} else {
if (evt) {
if ((!this.mUIFocusElement) || this.mCurFocusElement != evt.element) {
this.mCurFocusElement=focusEle;
this.mForceFocusToCurrent=(!this.mUIFocusElement)||(focusEle != evt.element);
}
}
}
}
this.transitionFocus = function(popTillIdx) {
;
while(this.mFocusStk.length > popTillIdx) {
var fe = this.mFocusStk.pop();
if (fe.ty == 2) {
;
return;
} else {
var f = Fields[fe.id];
var df;
var prevID = this.mCurFocusID;
var prevElement = this.mCurFocusElement;
switch(fe.ty) {
case 0:
df = f.DOMBlur;
break;
case 1:
this.mCurFocusID = fe.id;
if (this.mCurFocusID <=0) {
this.mCurFocusElement=null;
continue; 
}
this.mCurFocusElement = fe.fe;
df = f.DOMFocus;
break;
default:
;    
}
var res = CurWFC.execute({t:f, f:df, a:[fe.ed], e:this.ftExceptionHandler, ea:[prevID, prevElement]});
if (res) {
return {i:1, n:{t:this, f:this.transitionFocus, a:[popTillIdx]}};
}
}
}
}
this.TryFocus=function(fe) {
try {
if (("focus" in fe) && !fe.disabled && fe.parentNode && ((this.mCurFocusID in Fields) && Fields[this.mCurFocusID].GetNestedFocusability())) {            
fe.focus();
return true;
}
} catch (ex) {
LogWrite("Caught exception while setting focus" + ("message" in ex) ? ex.message : ex);
}
return false;
}
this.reallySetFocus = function() {
var fe = this.mCurFocusElement;
if (!this.mOpenedWindow && (this.mFocusStk.length == 0)) {
this.mForceFocusToCurrent=false; 
if(this.TryFocus(fe))
return;
if (this.mCurFocusID) {
this.mCurFocusElement = Fields[this.mCurFocusID].GetFocusElement();
if(this.TryFocus(this.mCurFocusElement))
return;
}
this.TryFocus(this.mCurFocusElement = document.body);
}
}
this.getFocusedID=function() {
return this.mCurFocusID;
}
this.ftExceptionHandler=function(exception, prevID, prevElement) {
;
;
;
if (FocusMgr.mFocusStk.length > 0) {
FocusMgr.mFocusStk = [];
FocusMgr.mCurFocusID = prevID;
FocusMgr.mCurFocusElement = prevElement;
FocusMgr.mUIFocusElement=null;
FocusMgr.mForceFocusToCurrent=true;
}
throw exception;
}
this.SetFocusToField=function(fieldID) {
;
;
;
if (!(fieldID in Fields)) {
return;
}
var f = Fields[fieldID];
if (!f.GetNestedFocusability()) {
return; 
}
var p = f.GetParent();
while (p) {
if (p instanceof DPage) {
p.SelectPageDueToFocusInChildField();
}
p=p.GetParent();
}
var evt = new FormEvent(fieldID);
var flen = this.mFocusStk.length;
if (flen > 0) {
var fe = this.mFocusStk[flen-1];
if (fe.ty == 1) {
this.mFocusStk.pop();
this.mFocusStk.push({ty:1, id: fieldID, ed:evt, fe:evt.element});
return {n:{t:this, f:this.transitionFocus, a:[flen-1]}};
} else {
return {n:{t:this, f:this.changeFocusTo, a:[fieldID, evt, evt.element]}};
}
} else {
this.mUIFocusElement=null;
return {n:{t:this, f:this.changeFocusTo, a:[fieldID, evt, evt.element]}};
}
}
this.WorkflowComplete = function() {
if (CurWFC == this.mWFC) {
this.mWFC = null;
if (this.mCurFocusID != 0 && this.mCurFocusElement != this.mUIFocusElement)
this.mForceFocusToCurrent=true;
this.mUIFocusElement = null;
}
if (CurWFC.mOpenedWindow)
this.mOpenedWindow=true; 
if (!this.mOpenedWindow && this.mForceFocusToCurrent) {
if (this.mTimeoutID==null) 
this.mTimeoutID=setTimeout(function() {
FocusMgr.mTimeoutID=null;
FocusMgr.reallySetFocus();
},0);
}
if (this.mFocusStk.length > 0)
this.mFocusStk = [];
}
this.WindowGotFocus = function() {
this.mOpenedWindow=false; 
if (this.mForceFocusToCurrent)
this.reallySetFocus();
}
this.SetFocusToFirst = function() {
;
this.setFocusToTabElementFromCur(FieldListInfo.firstField.mObj, true);
}
this.SetFocusToLast = function() {
;
this.setFocusToTabElementFromCur(FieldListInfo.lastField.mObj, false);
}
this.SetFocusToNext = function(ed) {
;
return this.setFocusToTabElement(ed, true);
}
this.SetFocusToPrevious = function(ed) {
;
return this.setFocusToTabElement(ed, false);
}
this.setFocusToTabElement=function(ed, next) {
;
this.setFocusToTabElementFromCur(ed.element, next);
}
this.setFocusToTabElementFromCur = function(curEle, next) {
var field = Field_FromElement(curEle);
var firstFieldEleFunc;
var nextFieldEleFunc;
var nextFieldOrTBEleFunc;
if (next) {
nextFieldOrTBEleFunc = this.getNextFieldOrTBEle;
nextFieldEleFunc = this.getNextFieldElement;
firstFieldEleFunc = this.getFirstFieldElement;
} else {
nextFieldOrTBEleFunc = this.getPrevFieldOrTBEle;
nextFieldEleFunc = this.getPrevFieldElement;
firstFieldEleFunc = this.getLastFieldElement;
}
var nextEle = null;
if (field!=null) {
nextEle = nextFieldEleFunc.call(this, field, curEle);
curEle = field.mObj; 
} else {
if (curEle==document.body && this.mCurFocusID>0) {
;
curEle=Fields[this.mCurFocusID].mObj;                
}
}
while (nextEle==null) {
var fOrTb = nextFieldOrTBEleFunc.call(this, curEle);
if (fOrTb instanceof Field) {
field = fOrTb;
nextEle = firstFieldEleFunc.call(this, field);
curEle = field.mObj; 
} else {
nextEle = fOrTb;
break;
}
}
if (nextEle) {
if (field) {
var fe = new FormEvent(field.mID);
fe.element=nextEle;
new WorkflowContext({t:this, f: this.changeFocusTo, a:[field.mID, fe, nextEle]});
return true; 
} else {
setTimeout(function() { nextEle.focus(); },0);
}
}
new WorkflowContext({t:this, f:this.changeFocusTo, a:[0, null, null]});
return false; 
}
this.getNextFieldOrTBEle=function(curEle) {
return this.nextElementWalker(curEle, document.body, this, this.fieldOrTBSelector);
}
this.getPrevFieldOrTBEle=function(curEle) {
return this.prevElementWalker(curEle, document.body, this, this.fieldOrTBSelector);
}
this.getNextFieldElement=function(field, curEle) {
;
return this.nextElementWalker(curEle, field.mObj, field, field.TabableElementSelector);
}
this.getPrevFieldElement=function(field, curEle) {
;
return this.prevElementWalker(curEle, field.mObj, field, field.TabableElementSelector);
}
this.getFirstFieldElement=function(field) {
;
var fe = field.TabableElementSelector(field.mObj);
if (fe==null)
fe=this.nextElementWalker(field.mObj, field.mObj, field, field.TabableElementSelector);
return fe;    
}
this.getLastFieldElement=function(field) {
;
var le = field.mObj.lastChild;
while (le.lastChild&&(!le.style || le.style.visibility!="hidden")) {
le=le.lastChild;
}
if (le.nodeType==1) {
var retval = field.TabableElementSelector(le);
if (retval)
return retval;    
}
return this.prevElementWalker(le, field.mObj, field, field.TabableElementSelector);
}
this.nextElementWalker=function(curEle, stopAt, nodeSelectorObj, nodeSelector) {
;
var n = curEle;
while(true) {
var nid;
if(n.firstChild&&(!n.style || n.style.visibility!="hidden")) {
n=n.firstChild;
} else {
if (n==stopAt) {
return null; 
}
while(!n.nextSibling) {
n=n.parentNode;
if(n==stopAt) {
return null; 
}
}
n=n.nextSibling;
}
if (n.nodeType==1) {
var retval;
if ((retval = nodeSelector.call(nodeSelectorObj, n)) != null) {
return retval;
}
}
}
}
this.prevElementWalker = function(curEle, stopAt, nodeSelectorObj, nodeSelector) {
;
var n=curEle;
if (curEle==document.body) {
while (n.lastChild&&(!n.style || n.style.visibility!="hidden")) {
n=n.lastChild;
}
if (n.nodeType==1) {
var retval;
if ((retval=nodeSelector.call(nodeSelectorObj, n))!=null) {
return retval;
}
}
}
while(n!=stopAt) {
var nid;
if (n.previousSibling) {
n=n.previousSibling;
while (n.lastChild&&(!n.style || n.style.visibility!="hidden")) {
n=n.lastChild;
}
} else {
n=n.parentNode;
}
if (n.nodeType==1) {
var retval;
if ((retval=nodeSelector.call(nodeSelectorObj, n))!=null) {
return retval;
}
}
}
return null;
}
this.fieldOrTBSelector=function(n) {
;
var fidStr;
if((fidStr=n.getAttribute("ARID"))!=null) {
var field=Fields[parseInt(fidStr)];
if (field.GetNestedFocusability()) {
return field;
}
}
if (n.tagName=="A" && n.className && (n.className.indexOf("tbbtn")!=-1 || n.className.indexOf("TBTopBarBox")!=-1)) {
return FakeButton_TabableElementSelector(n);
}
return null;
}
}();
}
function arJumpOutForward() 
{
;
if (FocusMgr.mCurFocusID != 0) {
var fe = new FormEvent(FocusMgr.mCurFocusID);
FocusMgr.SetFocusToNext(fe);
}
}
function arJumpOutBackward() 
{
;
if (FocusMgr.mCurFocusID != 0) {
var fe = new FormEvent(FocusMgr.mCurFocusID);
fe.shift = true;
FocusMgr.SetFocusToPrevious(fe);
}
}

function Arithmetic(op, a, b, t) {
;
if (t) {
if (!(t in DatatypeFactories)) {
;
return Null;
}
if (a.isNull && b.isNull)
return Null;
return (DatatypeFactories[t]())[op](a,b);
} else if (a instanceof Datatype && b instanceof Datatype) {
;
if (a.isNull && b.isNull)
return Null;
var t = a.isNull ? b.type : a.type;
return (DatatypeFactories[t]())[op](a,b);
} else if (a instanceof Datatype && b == null) {
;
var t = a.type;
return (DatatypeFactories[t]())[op](a);
}
;
}
function Relational(op, a, b, t) {
;
if (t) {
if (!(t in DatatypeFactories)) {
;
return false;
}
return (DatatypeFactories[t]())[op](a,b);
} else if (a instanceof Datatype) {
;
return a[op](b);
}
;
}
function EQ(a, b, t) {
return Relational("EQ", a, b, t);
}
function NE(a, b, t) {
return Relational("NE", a, b, t);
}
function LT(a, b, t) {
return Relational("LT", a, b, t);
}
function LE(a, b, t) {
return Relational("LE", a, b, t);
}
function GT(a, b, t) {
return Relational("GT", a, b, t);
}
function GE(a, b, t) {
return Relational("GE", a, b, t);
}
function LIKE(a, b, t) {
return Relational("LIKE", a, b, t);
}
function ADD(a, b, t) {
return Arithmetic("ADD", a, b, t);
}
function SUB(a, b, t) {
return Arithmetic("SUB", a, b, t);
}
function MUL(a, b, t) {
return Arithmetic("MUL", a, b, t);
}
function DIV(a, b, t) {
return Arithmetic("DIV", a, b, t);
}
function MOD(a, b, t) {
return Arithmetic("MOD", a, b, t);
}
function NEG(a, t) {
return Arithmetic("NEG", a, null, t);
}

Datatype.prototype.constructor=Datatype;;
var DatatypeFactories = {}
function Datatype() {
}
Datatype.prototype.init = function() {
}
Datatype.prototype.type = 0;
Datatype.prototype.args = function() {
return {};
}
Datatype.prototype.SerializeAsString = function() {
var str = "{t:" + this.type + ",v:\"" + this.toPrimitive().JScriptEncode() + "\"";
if ("args" in this) {
var args = this.args();
var str1 = [];
for (i in args) {
;
str1.push(i + ":" + args[i]);
}
str += ",a:{" + str1.join(",") + "}";
}
str += "}";
return str;
}
Datatype.prototype.isNull = true;
Datatype.prototype.toInteger = function() {
var res = new IntegerType(this.toString());
return res.toInteger();
}
Datatype.prototype.toReal = function() {
var res = new RealType(LCRealToEn_US(this.toString(), false));
return res.toReal();
}
Datatype.prototype.toDecimal = function() {
var res = new DecimalType(LCDecimalToEn_US(this.toString(), false));
return res.toDecimal();
}
Datatype.prototype.toCurrency = function(p) {
return new CurrencyType(this.toDecimal(), p);
}
Datatype.prototype.toChar = function() {
return this.toString();
}
Datatype.prototype.toTOD = function() {
return new TODType(this.toInteger());
}
Datatype.prototype.toTime = function() {
return new TimeType(this.toInteger());
}
Datatype.prototype.toDate = function() {
return new DateType(this.toInteger());
}
Datatype.prototype.toString = function() {
;
CurWFC.status(9215);
}
Datatype.prototype.toAttach = function(p) {
return new AttachmentType(this.toString());
}
Datatype.prototype.toPrimitive = function() {
;
CurWFC.status(9215);
}
Datatype.prototype.toDbgString = function() {
var str = "dt:{t:"+this.type;
if ("mValue" in this)
str += ",mValue:"+this.mValue;
return str + "}";
}
Datatype.prototype.part = function() {
;
CurWFC.status(9215);
}
Datatype.prototype.compound = function(args) {
;
return null;
}
Datatype.prototype.Diff = function(a) {
return !(this.type == a.type && this.mValue == a.mValue);
}
Datatype.prototype.EQ = function(a) {
;
CurWFC.status(9367);
}
Datatype.prototype.NE = function(a) {
;
CurWFC.status(9367);
}
Datatype.prototype.LT = function(a) {
;
CurWFC.status(9367);
}
Datatype.prototype.LE = function(a) {
;
CurWFC.status(9367);
}
Datatype.prototype.GT = function(a) {
;
CurWFC.status(9367);
}
Datatype.prototype.GE = function(a) {
;
CurWFC.status(9367);
}
Datatype.prototype.LIKE = function(a) {
;
CurWFC.status(9367);
}
Datatype.prototype.ADD = function(a, b) {
;
;
;
if (b.isNull) return a;
else if (a.isNull) return b;
;
CurWFC.status(9339);
}
Datatype.prototype.SUB = function(a, b) {
;
;
;
if (b.isNull) return a;
else if (a.isNull) return b;
;
CurWFC.status(9339);
}
Datatype.prototype.MUL = function(a, b) {
;
;
;
;
CurWFC.status(9339);
}
Datatype.prototype.DIV = function(a, b) {
;
;
;
;
CurWFC.status(9339);
}
Datatype.prototype.MOD = function(a, b) {
;
;
;
;
CurWFC.status(9339);
}
Datatype.prototype.NEG = function(a) {
;
CurWFC.status(9339);
}
function Datatype_Factory(item) {
;
;
if (item.t in DatatypeFactories) {
return DatatypeFactories[item.t](item.v, item.a);
}
return Null;
}
Datatype.prototype.ROUND = function() {
var realNum = this.toReal();
realNum = (realNum > 2147483647) ? 2147483647 : 
(realNum < -2147483647) ? -2147483647 : realNum;
return new IntegerType(Math.round(realNum));
}
Datatype.prototype.TRUNC = function() {
var realNum = this.toReal();
realNum = (realNum > 2147483647) ? 2147483647 : 
(realNum < -2147483647) ? -2147483647 : realNum;
return new IntegerType(parseInt(realNum));
}
Datatype.prototype.EQForSet = function(val) {
;
return this.toString()==val.toString();
}
Datatype.prototype.ConvertForPushFields = function(type, args) {
if (this.isNull) {
return this;
}
return DatatypeFactories[type](this, args);
}
Datatype.prototype.ConvertForDynamicPushFields = function(pfTypes, fieldId) {
if (this.isNull || !(fieldId in pfTypes)) {
return this;
}
return DatatypeFactories[pfTypes[fieldId].t](this, pfTypes[fieldId].a);
}

NullType.prototype=new Datatype(); NullType.prototype.constructor=NullType; NullType.superclass=Datatype.prototype;;
DatatypeFactories[0] = function(val) {
return Null;
}
function NullType() {
if(arguments.length)
this.init();
}
NullType.prototype.type = 0;
NullType.prototype.isNull = true;
NullType.prototype.toInteger = function() {
return 0;
}
NullType.prototype.toReal = function() {
return 0;
}
NullType.prototype.toString = function() {
return "";
}
NullType.prototype.toPrimitive = function() {
return "";
}
NullType.prototype.part = function() {
return Null;
}
NullType.prototype.compound = function(args) {
return Null;
}
NullType.prototype.ADD = function(a) {
;
return a;
}
Null = new NullType();
NullType.KEYWORD_NULL = new NullType();
NullType.prototype.EQ = function(a) {
;
;
return a.isNull;
}
NullType.prototype.NE = function(a) {
;
return !this.EQ(a)
}
NullType.prototype.GT = function(a) {
;
;
return a.isNull;
}
NullType.prototype.LT = function(a) {
;
;
return a.isNull;
}
NullType.prototype.GE = function(a) {
;
;
return a.isNull;
}
NullType.prototype.LE = function(a) {
;
;
return a.isNull;
}
NullType.prototype.LIKE = function(a) {
;
;
return false;
}
CharNullType.prototype=new NullType(); CharNullType.prototype.constructor=CharNullType; CharNullType.superclass=NullType.prototype;;
function CharNullType() {
if(arguments.length)
this.init();
}
CharNull = new CharNullType();
CharNullType.KEYWORD_CHAR_NULL = new CharNullType();
NullType.prototype.ROUND = function() {
return Null;    
}
NullType.prototype.TRUNC = function() {
return Null;
}

CharType.prototype=new Datatype(); CharType.prototype.constructor=CharType; CharType.superclass=Datatype.prototype;;
DatatypeFactories[4] = function(val) {
return new CharType(val);
}
function CharType(a) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a);
}
CharType.prototype.init = function(val) {
;
;
if (val instanceof Datatype) {
;
this.mValue = val.toChar();
} else if (typeof val == "string")
this.mValue = val;
else
this.mValue = val;
}
CharType.prototype.type = 4;
CharType.prototype.isNull = false;
CharType.prototype.toString = function() {
;
return this.mValue;
}
CharType.prototype.toPrimitive = function() {
;
return this.mValue;
}
CharType.prototype.toTime = function() {
return new TimeType(this.toString());
}
CharType.prototype.toDate = function() {
return new DateType(this.toString());
}
CharType.prototype.toTOD = function() {
return new TODType(this.toString());
}
CharType.prototype.ADD = function(a, b) {
;
;
;
this.mValue = a.toChar() + b.toChar();
return this;
}
CharType.prototype.MOD = function(a, b) {
;
;
;
if ((1<<2 & (1<<a.type)) && ((1<<2 & (1<<b.type))||(1<<0 & (1<<b.type)))) {
if (b.toInteger() == 0) {
CurWFC.status(9306);
return;
}
else {
this.mValue = (a.toInteger() % b.toInteger()) + "";
}
}
else if (b.isNull) return a;
else if (a.isNull) {
if (b instanceof IntegerType)
this.mValue = "0";
else
return b;
}
else 
CurWFC.status(9339);
return this;
}
CharType.prototype.DIV = function(a, b) {
;
;
;
if (b.isNull) return a;
else if (a.isNull) return b;
CurWFC.status(9339);
}
CharType.prototype.MUL = function(a, b) {
;
;
;
if (b.isNull) return a;
else if (a.isNull) return b;
CurWFC.status(9339);
}
CharType.prototype.EQ = function(a) {
;
;
if (a.isNull)
return false;
var lhs = this.mValue;
var rhs = a.toChar();
;
if (FormElements["FormContainer"].getAttribute("ARcs") == "1") {
if (lhs != null) lhs = lhs.toLowerCase();
if (rhs != null) rhs = rhs.toLowerCase();
}
if (lhs == null || rhs == null) {
if (lhs == null && rhs == null)
return true;
else
return false;
} else
return lhs.localeCompare(rhs) == 0;
}
CharType.prototype.NE = function(a) {
;
return !this.EQ(a)
}
CharType.prototype.GT = function(a) {
;
;
var lhs = this.mValue;
var rhs = a.toChar();
;
if (FormElements["FormContainer"].getAttribute("ARcs") == "1") {
if (lhs != null) lhs = lhs.toLowerCase();
if (rhs != null) rhs = rhs.toLowerCase();
}
if (lhs == null || rhs == null) {
if (lhs == null && rhs == null)
return true;
else
return false;
} else
return lhs.localeCompare(rhs) > 0;
}
CharType.prototype.LT = function(a) {
;
;
var lhs = this.mValue;
var rhs = a.toChar();
;
if (FormElements["FormContainer"].getAttribute("ARcs") == "1") {
if (lhs != null) lhs = lhs.toLowerCase();
if (rhs != null) rhs = rhs.toLowerCase();
}
if (lhs == null || rhs == null) {
if (lhs == null && rhs == null)
return true;
else
return false;
} else
return lhs.localeCompare(rhs) < 0;
}
CharType.prototype.GE = function(a) {
;
;
var lhs = this.mValue;
var rhs = a.toChar();
;
if (FormElements["FormContainer"].getAttribute("ARcs") == "1") {
if (lhs != null) lhs = lhs.toLowerCase();
if (rhs != null) rhs = rhs.toLowerCase();
}
if (lhs == null || rhs == null) {
if (lhs == null && rhs == null)
return true;
else
return false;
} else
return lhs.localeCompare(rhs) >= 0;
}
CharType.prototype.LE = function(a) {
;
;
var lhs = this.mValue;
var rhs = a.toChar();
;
if (FormElements["FormContainer"].getAttribute("ARcs") == "1") {
if (lhs != null) lhs = lhs.toLowerCase();
if (rhs != null) rhs = rhs.toLowerCase();
}
if (lhs == null || rhs == null) {
if (lhs == null && rhs == null)
return true;
else
return false;
} else
return lhs.localeCompare(rhs) <= 0;
}
CharType.prototype.LIKE = function(a) {
;
;
var lhs = this.mValue;
var rhs = a.toChar();
;
if (lhs == null || rhs == null) {
return false;
}
if (FormElements["FormContainer"].getAttribute("ARcs") == "1") {
lhs = lhs.toLowerCase();
rhs = rhs.toLowerCase();
}
rhs = rhs.replace(/(%)|(_)|(\[.*?\])|([.$^+?*{()\\\/|[\]])/gm, function (sub, p1, p2, p3, p4) {
if (p1) return "(.|\\n)*";
else if (p2) return "(.|\\n)";
else if (p3) return p3;
else if (p4) return "\\" + p4;
});
;
try {
var re = new RegExp("^" + rhs + "$"); 
} catch (exception) {
return false;
}
return lhs.match(re) != null;
}
CharType.prototype.toCurrency = function(p) {
return new CurrencyType(this.toString(), p, true);
}

DiaryType.prototype=new CharType(); DiaryType.prototype.constructor=DiaryType; DiaryType.superclass=CharType.prototype;;
DatatypeFactories[5] = function(val) {
return new DiaryType(val);
}
function DiaryType(a) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a);
}
DiaryType.prototype.init = function(val) {
;
DiaryType.superclass.init.call(this, val);
;
}
DiaryType.prototype.type = 5;
DiaryType.prototype.toCurrency = function(p) {
return new CurrencyType(this.toString(), p, true);
}

ColumnType.prototype=new Datatype(); ColumnType.prototype.constructor=ColumnType; ColumnType.superclass=Datatype.prototype;;
function ColumnType(a) {
if(arguments.length)
this.init(a);
}
ColumnType.prototype.init = function(a) {
ColumnType.superclass.init.call(this);
this.mValue = a;
}

MathContext.prototype.getDigits =  function () {
return this.digits;
}
MathContext.prototype.getForm =  function () {
return this.form;
}
MathContext.prototype.getLostDigits =  function () {
return this.lostDigits;
}
MathContext.prototype.getRoundingMode =  function () {
return this.roundingMode;
}
MathContext.prototype.toString =  function () {
var formstr=null;
var r=0;
var roundword=null;
{
if (this.form==1)
formstr="SCIENTIFIC";
else if (this.form==2)
formstr="ENGINEERING";
else{
formstr="PLAIN";
}
}
{var $1=this.ROUNDS.length;r=0;r:for(;$1>0;$1--,r++){
if (this.roundingMode==this.ROUNDS[r]) 
{
roundword=this.ROUNDWORDS[r];
break r;
}
}
}
return "digits="+this.digits+" "+"form="+formstr+" "+"lostDigits="+(this.lostDigits?"1":"0")+" "+"roundingMode="+roundword;
}
MathContext.prototype.isValidRound =  function(testround) {
var r=0;
{var $2=this.ROUNDS.length;r=0;r:for(;$2>0;$2--,r++){
if (testround==this.ROUNDS[r]) 
return true;
}
}
return false;
}
MathContext.prototype.ROUNDS=new Array(4,7,2,1,3,5,6,0);
MathContext.prototype.ROUNDWORDS=new Array("ROUND_HALF_UP","ROUND_UNNECESSARY","ROUND_CEILING","ROUND_DOWN","ROUND_FLOOR","ROUND_HALF_DOWN","ROUND_HALF_EVEN","ROUND_UP"); 
function MathContext() {
this.digits = 0;
this.form = 0; 
this.lostDigits = false;
this.roundingMode = 0;
var setform = 1;
var setlostdigits = false;
var setroundingmode = 4;
if (MathContext.arguments.length == 4)
{
setform = MathContext.arguments[1];
setlostdigits = MathContext.arguments[2];
setroundingmode = MathContext.arguments[3];
}
else if (MathContext.arguments.length == 3)
{
setform = MathContext.arguments[1];
setlostdigits = MathContext.arguments[2];
}
else if (MathContext.arguments.length == 2)
{
setform = MathContext.arguments[1];
}
else if (MathContext.arguments.length != 1)
{
throw "MathContext(): " + MathContext.arguments.length + " arguments given; expected 1 to 4";
}
var setdigits = MathContext.arguments[0];
if (setdigits!=9) 
{
if (setdigits<0) 
throw "MathContext(): Digits too small: "+setdigits;
if (setdigits>999999999) 
throw "MathContext(): Digits too large: "+setdigits;
}
{
if (setform==1)
; 
else if (setform==2)
;
else if (setform==0)
;
else{
throw "MathContext() Bad form value: "+setform;
}
}
if ((!(this.isValidRound(setroundingmode)))) 
throw "MathContext(): Bad roundingMode value: "+setroundingmode;
this.digits=setdigits;
this.form=setform;
this.lostDigits=setlostdigits; 
this.roundingMode=setroundingmode;
return;}

BigDecimal.div = function(a, b) {
return (a-(a%b))/b;
}
BigDecimal.prototype.arraycopy = function arraycopy(src, srcindex, dest, destindex, length) {
var i;
if (destindex > srcindex) {
for (i = length-1; i >= 0; --i) {
dest[i+destindex] = src[i+srcindex];
}
} else {
for (i = 0; i < length; ++i) {
dest[i+destindex] = src[i+srcindex];
}
}
}
BigDecimal.prototype.createArrayWithZeros = function createArrayWithZeros(length) {
var retVal = new Array(length);
var i;
for (i = 0; i < length; ++i) {
retVal[i] = 0;
}
return retVal;
}
BigDecimal.prototype.add =  function () {
var set;
if (arguments.length == 2)
{
set = arguments[1];
}
else if (arguments.length == 1)
{
set = this.plainMC();
}
else
{
throw "add(): " + arguments.length + " arguments given; expected 1 or 2";
}
var rhs = arguments[0];
var lhs;
var reqdig;
var res;
var usel;
var usellen;
var user;
var userlen;
var newlen=0;
var tlen=0;
var mult=0;
var t=null;
var ia=0;
var ib=0;
var ea=0;
var eb=0;
var ca=0;
var cb=0;
if (set.lostDigits) 
this.checkdigits(rhs,set.digits);
lhs=this; 
if (lhs.ind==0) 
if (set.form!=0) 
return rhs.plus(set);
if (rhs.ind==0) 
if (set.form!=0) 
return lhs.plus(set);
reqdig=set.digits; 
if (reqdig>0) 
{
if (lhs.mant.length>reqdig) 
lhs=this.clone(lhs).round(set);
if (rhs.mant.length>reqdig) 
rhs=this.clone(rhs).round(set);
}
res=new BigDecimal(); 
usel=lhs.mant;
usellen=lhs.mant.length;
user=rhs.mant;
userlen=rhs.mant.length;
{padder:do{
if (lhs.exp==rhs.exp)
{
res.exp=lhs.exp;
}
else if (lhs.exp>rhs.exp)
{ 
newlen=(usellen+lhs.exp)-rhs.exp;
if (newlen>=((userlen+reqdig)+1)) 
if (reqdig>0) 
{
res.mant=usel;
res.exp=lhs.exp;
res.ind=lhs.ind;
if (usellen<reqdig) 
{ 
res.mant=this.extend(lhs.mant,reqdig);
res.exp=res.exp-((reqdig-usellen));
}
return res.finish(set,false);
}
res.exp=rhs.exp; 
if (newlen>(reqdig+1)) 
if (reqdig>0) 
{
tlen=(newlen-reqdig)-1; 
userlen=userlen-tlen;
res.exp=res.exp+tlen;
newlen=reqdig+1;
}
if (newlen>usellen) 
usellen=newlen; 
}
else{ 
newlen=(userlen+rhs.exp)-lhs.exp;
if (newlen>=((usellen+reqdig)+1)) 
if (reqdig>0) 
{
res.mant=user;
res.exp=rhs.exp;
res.ind=rhs.ind;
if (userlen<reqdig) 
{ 
res.mant=this.extend(rhs.mant,reqdig);
res.exp=res.exp-((reqdig-userlen));
}
return res.finish(set,false);
}
res.exp=lhs.exp; 
if (newlen>(reqdig+1)) 
if (reqdig>0) 
{
tlen=(newlen-reqdig)-1; 
usellen=usellen-tlen;
res.exp=res.exp+tlen;
newlen=reqdig+1;
}
if (newlen>userlen) 
userlen=newlen; 
}
}while(false);}
if (lhs.ind==this.iszero) 
res.ind=this.ispos;
else 
res.ind=lhs.ind; 
if (((lhs.ind==this.isneg)?1:0)==((rhs.ind==this.isneg)?1:0))  
mult=1;
else 
{signdiff:do{ 
mult=-1; 
{swaptest:do{
if (rhs.ind==this.iszero)
; 
else if ((usellen<userlen)||(lhs.ind==this.iszero))
{ 
t=usel;
usel=user;
user=t; 
tlen=usellen;
usellen=userlen;
userlen=tlen; 
res.ind=-res.ind; 
}
else if (usellen>userlen)
; 
else{
{ 
ia=0;
ib=0;
ea=usel.length-1;
eb=user.length-1;
{compare:for(;;){
if (ia<=ea) 
ca=usel[ia];
else 
{
if (ib>eb) 
{
if (set.form!=0) 
return this.ZERO;
break compare;
}
ca=0;
}
if (ib<=eb) 
cb=user[ib];
else 
cb=0;
if (ca!=cb) 
{
if (ca<cb) 
{
t=usel;
usel=user;
user=t; 
tlen=usellen;
usellen=userlen;
userlen=tlen; 
res.ind=-res.ind;
}
break compare;
}
ia++;
ib++;
}
}
} 
}
}while(false);}
}while(false);}
res.mant=this.byteaddsub(usel,usellen,user,userlen,mult,false);
return res.finish(set,false);
}
BigDecimal.prototype.compareTo =  function () {
var set;
if (arguments.length == 2)
{
set = arguments[1];
}
else if (arguments.length == 1)
{
set = this.plainMC();
}
else
{
throw "compareTo(): " + arguments.length + " arguments given; expected 1 or 2";
}
var rhs = arguments[0];
var thislength=0;
var i=0;
var newrhs;
if (set.lostDigits) 
this.checkdigits(rhs,set.digits);
if ((this.ind==rhs.ind)&&(this.exp==rhs.exp)) 
{
thislength=this.mant.length;
if (thislength<rhs.mant.length) 
return -this.ind;
if (thislength>rhs.mant.length) 
return this.ind;
if ((thislength<=set.digits)||(set.digits==0)) 
{
{var $6=thislength;i=0;i:for(;$6>0;$6--,i++){
if (this.mant[i]<rhs.mant[i]) 
return -this.ind;
if (this.mant[i]>rhs.mant[i]) 
return this.ind;
}
}
return 0; 
}
}
else 
{
if (this.ind<rhs.ind) 
return -1;
if (this.ind>rhs.ind) 
return 1;
}
newrhs=this.clone(rhs); 
newrhs.ind=-newrhs.ind; 
return this.add(newrhs,set).ind; 
}
BigDecimal.prototype.divide =  function () {
var set;
var scale = -1;
if (arguments.length == 2)
{
if (typeof arguments[1] == 'number')
{
set=new MathContext(0,0,false,arguments[1]); 
}
else
{
set = arguments[1];
}
}
else if (arguments.length == 3)
{
scale = arguments[1];
if (scale<0) 
throw "divide(): Negative scale: "+scale;
set=new MathContext(0,0,false,arguments[2]); 
}
else if (arguments.length == 1)
{
set = this.plainMC();
}
else
{
throw "divide(): " + arguments.length + " arguments given; expected between 1 and 3";
}
var rhs = arguments[0];
return this.dodivide('D',rhs,set,scale);
}
BigDecimal.prototype.max =  function () {
var set;
if (arguments.length == 2)
{
set = arguments[1];
}
else if (arguments.length == 1)
{
set = this.plainMC();
}
else
{
throw "max(): " + arguments.length + " arguments given; expected 1 or 2";
}
var rhs = arguments[0];
if ((this.compareTo(rhs,set))>=0) 
return this.plus(set);
else 
return rhs.plus(set);
}
BigDecimal.prototype.min =  function () {
var set;
if (arguments.length == 2)
{
set = arguments[1];
}
else if (arguments.length == 1)
{
set = this.plainMC();
}
else
{
throw "min(): " + arguments.length + " arguments given; expected 1 or 2";
}
var rhs = arguments[0];
if ((this.compareTo(rhs,set))<=0) 
return this.plus(set);
else 
return rhs.plus(set);
}
BigDecimal.prototype.multiply =  function () {
var set;
if (arguments.length == 2)
{
set = arguments[1];
}
else if (arguments.length == 1)
{
set = this.plainMC();
}
else
{
throw "multiply(): " + arguments.length + " arguments given; expected 1 or 2";
}
var rhs = arguments[0];
var lhs;
var padding;
var reqdig;
var multer=null;
var multand=null;
var multandlen;
var acclen=0;
var res;
var acc;
var n=0;
var mult=0;
if (set.lostDigits) 
this.checkdigits(rhs,set.digits);
lhs=this; 
padding=0; 
reqdig=set.digits; 
if (reqdig>0) 
{
if (lhs.mant.length>reqdig) 
lhs=this.clone(lhs).round(set);
if (rhs.mant.length>reqdig) 
rhs=this.clone(rhs).round(set);
}
else 
{
if (lhs.exp>0) 
padding=padding+lhs.exp;
if (rhs.exp>0) 
padding=padding+rhs.exp;
}
if (lhs.mant.length<rhs.mant.length) 
{
multer=lhs.mant;
multand=rhs.mant;
}
else 
{
multer=rhs.mant;
multand=lhs.mant;
}
multandlen=(multer.length+multand.length)-1; 
if ((multer[0]*multand[0])>9) 
acclen=multandlen+1;
else 
acclen=multandlen;
res=new BigDecimal(); 
acc=this.createArrayWithZeros(acclen); 
{var $7=multer.length;n=0;n:for(;$7>0;$7--,n++){
mult=multer[n];
if (mult!=0) 
{ 
acc=this.byteaddsub(acc,acc.length,multand,multandlen,mult,true);
}
multandlen--; 
}
}
res.ind=lhs.ind*rhs.ind; 
res.exp=(lhs.exp+rhs.exp)-padding; 
if (padding==0) 
res.mant=acc;
else 
res.mant=this.extend(acc,acc.length+padding); 
return res.finish(set,false);
}
BigDecimal.prototype.negate =  function () {
var set;
if (arguments.length == 1)
{
set = arguments[0];
}
else if (arguments.length == 0)
{
set = this.plainMC();
}
else
{
throw "negate(): " + arguments.length + " arguments given; expected 0 or 1";
}
var res;
if (set.lostDigits) 
this.checkdigits(null,set.digits);
res=this.clone(this); 
res.ind=-res.ind;
return res.finish(set,false);
}
BigDecimal.prototype.plus =  function () {
var set;
if (arguments.length == 1)
{
set = arguments[0];
}
else if (arguments.length == 0)
{
set = this.plainMC();
}
else
{
throw "plus(): " + arguments.length + " arguments given; expected 0 or 1";
}
if (set.lostDigits) 
this.checkdigits(null,set.digits);
if (set.form==0) 
if (this.form==0) 
{
if (this.mant.length<=set.digits) 
return this;
if (set.digits==0) 
return this;
}
return this.clone(this).finish(set,false);
}
BigDecimal.prototype.subtract =  function () {
var set;
if (arguments.length == 2)
{
set = arguments[1];
}
else if (arguments.length == 1)
{
set = this.plainMC();
}
else
{
throw "subtract(): " + arguments.length + " arguments given; expected 1 or 2";
}
var rhs = arguments[0];
var newrhs;
if (set.lostDigits) 
this.checkdigits(rhs,set.digits);
newrhs=this.clone(rhs); 
newrhs.ind=-newrhs.ind; 
return this.add(newrhs,set); 
}
BigDecimal.prototype.equals =  function (obj) {
var rhs;
var i=0;
var lca=null;
var rca=null;
if (obj==null) 
return false; 
if ((!(((obj instanceof BigDecimal))))) 
return false; 
rhs=obj; 
if (this.ind!=rhs.ind) 
return false; 
if (((this.mant.length==rhs.mant.length)&&(this.exp==rhs.exp))&&(this.form==rhs.form)) 
{ 
{var $8=this.mant.length;i=0;i:for(;$8>0;$8--,i++){
if (this.mant[i]!=rhs.mant[i]) 
return false;
}
}
}
else 
{ 
lca=this.layout(); 
rca=rhs.layout();
if (lca.length!=rca.length) 
return false; 
{var $9=lca.length;i=0;i:for(;$9>0;$9--,i++){
if (lca[i]!=rca[i]) 
return false;
}
}
}
return true; 
}
BigDecimal.prototype.format =  function () {
var explaces;
var exdigits;
var exformint;
var exround;
if (arguments.length == 6)
{
explaces = arguments[2];
exdigits = arguments[3];
exformint = arguments[4];
exround = arguments[5];
}
else if (arguments.length == 2)
{
explaces = -1;
exdigits = -1;
exformint = 1;
exround = 4;
}
else
{
throw "format(): " + arguments.length + " arguments given; expected 2 or 6";
}
var before = arguments[0];
var after = arguments[1];
var num;
var mag=0;
var thisafter=0;
var lead=0;
var newmant=null;
var chop=0;
var need=0;
var oldexp=0;
var a;
var p=0;
var newa=null;
var i=0;
var places=0;
if ((before<(-1))||(before==0)) 
this.badarg("format",1,before);
if (after<(-1)) 
this.badarg("format",2,after);
if ((explaces<(-1))||(explaces==0)) 
this.badarg("format",3,explaces);
if (exdigits<(-1)) 
this.badarg("format",4,exdigits);
{
if (exformint==1)
;
else if (exformint==2)
;
else if (exformint==(-1))
exformint=1;
else{
this.badarg("format",5,exformint);
}
}
if (exround!=4) 
{try{ 
if (exround==(-1)) 
exround=4;
else 
new MathContext(9,1,false,exround);
}
catch ($10){
this.badarg("format",6,exround);
}}
num=this.clone(this); 
{setform:do{
if (exdigits==(-1))
num.form=0;
else if (num.ind==this.iszero)
num.form=0;
else{
mag=num.exp+num.mant.length;
if (mag>exdigits) 
num.form=exformint;
else 
if (mag<(-5)) 
num.form=exformint;
else 
num.form=0;
}
}while(false);}
if (after>=0) 
{setafter:for(;;){
{
if (num.form==0)
thisafter=-num.exp; 
else if (num.form==1)
thisafter=num.mant.length-1;
else{ 
lead=(((num.exp+num.mant.length)-1))%3; 
if (lead<0) 
lead=3+lead; 
lead++; 
if (lead>=num.mant.length) 
thisafter=0;
else 
thisafter=num.mant.length-lead;
}
}
if (thisafter==after) 
break setafter; 
if (thisafter<after) 
{ 
newmant=this.extend(num.mant,(num.mant.length+after)-thisafter);
num.mant=newmant;
num.exp=num.exp-((after-thisafter)); 
if (num.exp<this.MinExp) 
throw "format(): Exponent Overflow: " + num.exp;
break setafter;
}
chop=thisafter-after; 
if (chop>num.mant.length) 
{ 
num.mant=this.ZERO.mant;
num.ind=this.iszero;
num.exp=0;
continue setafter; 
}
need=num.mant.length-chop; 
oldexp=num.exp; 
num.round(need,exround);
if ((num.exp-oldexp)==chop) 
break setafter; 
}
}
a=num.layout(); 
if (before>0) 
{
{var $11=a.length;p=0;p:for(;$11>0;$11--,p++){
if (a[p]=='.') 
break p;
if (a[p]=='E') 
break p;
}
}
if (p>before) 
this.badarg("format",1,before); 
if (p<before) 
{ 
newa=new Array((a.length+before)-p);
{var $12=before-p;i=0;i:for(;$12>0;$12--,i++){
newa[i]=' ';
}
}
this.arraycopy(a,0,newa,i,a.length);
a=newa;
}
}
if (explaces>0) 
{
{var $13=a.length-1;p=a.length-1;p:for(;$13>0;$13--,p--){
if (a[p]=='E') 
break p;
}
}
if (p==0) 
{ 
newa=new Array((a.length+explaces)+2);
this.arraycopy(a,0,newa,0,a.length);
{var $14=explaces+2;i=a.length;i:for(;$14>0;$14--,i++){
newa[i]=' ';
}
}
a=newa;
}
else 
{ 
places=(a.length-p)-2; 
if (places>explaces) 
this.badarg("format",3,explaces);
if (places<explaces) 
{ 
newa=new Array((a.length+explaces)-places);
this.arraycopy(a,0,newa,0,p+2);
{var $15=explaces-places;i=p+2;i:for(;$15>0;$15--,i++){
newa[i]='0';
}
}
this.arraycopy(a,p+2,newa,i,places);
a=newa;
}
}
}
return a.join("");
}
BigDecimal.prototype.intValueExact =  function () {
var lodigit;
var useexp=0;
var result;
var i=0;
var topdig=0;
if (this.ind==this.iszero) 
return 0; 
lodigit=this.mant.length-1;
if (this.exp<0) 
{
lodigit=lodigit+this.exp; 
if ((!(this.allzero(this.mant,lodigit+1)))) 
throw "intValueExact(): Decimal part non-zero: " + this.toString();
if (lodigit<0) 
return 0; 
useexp=0;
}
else 
{
if ((this.exp+lodigit)>9)  
throw "intValueExact(): Conversion overflow: "+this.toString();
useexp=this.exp;
}
result=0;
{var $16=lodigit+useexp;i=0;i:for(;i<=$16;i++){
result=result*10;
if (i<=lodigit) 
result=result+this.mant[i];
}
}
if ((lodigit+useexp)==9) 
{
topdig=BigDecimal.div(result,1000000000); 
if (topdig!=this.mant[0]) 
{ 
if (result==-2147483648)  
if (this.ind==this.isneg)  
if (this.mant[0]==2) 
return result; 
throw "intValueExact(): Conversion overflow: "+this.toString();
}
}
if (this.ind==this.ispos) 
return result;
return -result;
}
BigDecimal.prototype.movePointLeft =  function (n) {
var res;
res=this.clone(this);
res.exp=res.exp-n;
return res.finish(this.plainMC(),false); 
}
BigDecimal.prototype.movePointRight =  function (n) {
var res;
res=this.clone(this);
res.exp=res.exp+n;
return res.finish(this.plainMC(),false);
}
BigDecimal.prototype.scale =  function () {
if (this.exp>=0) 
return 0; 
return -this.exp;
}
BigDecimal.prototype.setScale =  function () {
var round;
if (arguments.length == 2)
{
round = arguments[1];
}
else if (arguments.length == 1)
{
round = 7;
}
else
{
throw "setScale(): " + arguments.length + " given; expected 1 or 2";
}
var scale = arguments[0];
var ourscale;
var res;
var padding=0;
var newlen=0;
ourscale=this.scale();
if (ourscale==scale)  
if (this.form==0)  
return this;
res=this.clone(this); 
if (ourscale<=scale) 
{ 
if (ourscale==0) 
padding=res.exp+scale;
else 
padding=scale-ourscale;
res.mant=this.extend(res.mant,res.mant.length+padding);
res.exp=-scale; 
}
else 
{
if (scale<0) 
throw "setScale(): Negative scale: " + scale;
newlen=res.mant.length-((ourscale-scale)); 
res=res.round(newlen,round); 
if (res.exp!=(-scale)) 
{
res.mant=this.extend(res.mant,res.mant.length+1);
res.exp=res.exp-1;
}
}
res.form=0; 
return res;
}
BigDecimal.prototype.signum =  function () {
return this.ind; 
}
BigDecimal.prototype.toString =  function () {
return this.layout().join("");
}
BigDecimal.prototype.layout =  function () {
var cmant;
var i=0;
var sb=null;
var euse=0;
var sig=0;
var csign=0;
var rec=null;
var needsign;
var mag;
var len=0;
cmant=new Array(this.mant.length); 
{var $18=this.mant.length;i=0;i:for(;$18>0;$18--,i++){
cmant[i]=this.mant[i]+'';
}
}
if (this.form!=0) 
{
sb="";
if (this.ind==this.isneg) 
sb += '-';
euse=(this.exp+cmant.length)-1; 
if (this.form==1) 
{ 
sb += cmant[0]; 
if (cmant.length>1)  
sb += '.';
sb += cmant.slice(1).join("");
}
else 
{engineering:do{
sig=euse%3; 
if (sig<0) 
sig=3+sig; 
euse=euse-sig;
sig++;
if (sig>=cmant.length) 
{ 
sb += cmant.join("");
{var $19=sig-cmant.length;for(;$19>0;$19--){
sb += '0';
}
}
}
else 
{ 
sb += cmant.slice(0,sig).join("");
sb += '.';
sb += cmant.slice(sig).join("");
}
}while(false);}
if (euse!=0) 
{
if (euse<0) 
{
csign='-';
euse=-euse;
}
else 
csign='+';
sb += 'E';
sb += csign;
sb += euse;
}
return sb.split("");
}
if (this.exp==0) 
{
if (this.ind>=0) 
return cmant; 
rec=new Array(cmant.length+1);
rec[0]='-';
this.arraycopy(cmant,0,rec,1,cmant.length);
return rec;
}
needsign=((this.ind==this.isneg)?1:0); 
mag=this.exp+cmant.length;
if (mag<1) 
{
len=(needsign+2)-this.exp; 
rec=new Array(len);
if (needsign!=0) 
rec[0]='-';
rec[needsign]='0';
rec[needsign+1]='.';
{var $20=-mag;i=needsign+2;i:for(;$20>0;$20--,i++){ 
rec[i]='0';
}
}
this.arraycopy(cmant,0,rec,(needsign+2)-mag,cmant.length);
return rec;
}
if (mag>cmant.length) 
{
len=needsign+mag;
rec=new Array(len);
if (needsign!=0) 
rec[0]='-';
this.arraycopy(cmant,0,rec,needsign,cmant.length);
{var $21=mag-cmant.length;i=needsign+cmant.length;i:for(;$21>0;$21--,i++){ 
rec[i]='0';
}
}
return rec;
}
len=(needsign+1)+cmant.length;
rec=new Array(len);
if (needsign!=0) 
rec[0]='-';
this.arraycopy(cmant,0,rec,needsign,mag);
rec[needsign+mag]='.';
this.arraycopy(cmant,mag,rec,(needsign+mag)+1,cmant.length-mag);
return rec;
}
BigDecimal.prototype.intcheck =  function (min, max) {
var i;
i=this.intValueExact(); 
if ((i<min)||(i>max)) 
throw "intcheck(): Conversion overflow: "+i;
return i;
}
BigDecimal.prototype.dodivide =  function (code, rhs, set, scale) {
var lhs;
var reqdig;
var newexp;
var res;
var newlen;
var var1;
var var1len;
var var2;
var var2len;
var b2b;
var have;
var thisdigit=0;
var i=0;
var v2=0;
var ba=0;
var mult=0;
var start=0;
var padding=0;
var d=0;
var newvar1=null;
var lasthave=0;
var actdig=0;
var newmant=null;
if (set.lostDigits) 
this.checkdigits(rhs,set.digits);
lhs=this; 
if (rhs.ind==0) 
throw "dodivide(): Divide by 0"; 
if (lhs.ind==0) 
{ 
if (set.form!=0) 
return this.ZERO;
if (scale==(-1)) 
return lhs;
return lhs.setScale(scale);
}
reqdig=set.digits; 
if (reqdig>0) 
{
if (lhs.mant.length>reqdig) 
lhs=this.clone(lhs).round(set);
if (rhs.mant.length>reqdig) 
rhs=this.clone(rhs).round(set);
}
else 
{
if (scale==(-1)) 
scale=lhs.scale();
reqdig=lhs.mant.length; 
if (scale!=(-lhs.exp)) 
reqdig=(reqdig+scale)+lhs.exp;
reqdig=(reqdig-((rhs.mant.length-1)))-rhs.exp; 
if (reqdig<lhs.mant.length) 
reqdig=lhs.mant.length; 
if (reqdig<rhs.mant.length) 
reqdig=rhs.mant.length; 
}
newexp=((lhs.exp-rhs.exp)+lhs.mant.length)-rhs.mant.length;
if (newexp<0) 
if (code!='D') 
{
if (code=='I') 
return this.ZERO; 
return this.clone(lhs).finish(set,false);
}
res=new BigDecimal(); 
res.ind=(lhs.ind*rhs.ind); 
res.exp=newexp; 
res.mant=this.createArrayWithZeros(reqdig+1); 
newlen=(reqdig+reqdig)+1;
var1=this.extend(lhs.mant,newlen); 
var1len=newlen; 
var2=rhs.mant;
var2len=newlen;
b2b=(var2[0]*10)+1;
if (var2.length>1) 
b2b=b2b+var2[1];
have=0;
{outer:for(;;){
thisdigit=0;
{inner:for(;;){
if (var1len<var2len) 
break inner; 
if (var1len==var2len) 
{ 
{compare:do{ 
{var $22=var1len;i=0;i:for(;$22>0;$22--,i++){
if (i<var2.length) 
v2=var2[i];
else 
v2=0;
if (var1[i]<v2) 
break inner; 
if (var1[i]>v2) 
break compare; 
}
}
thisdigit++;
res.mant[have]=thisdigit;
have++;
var1[0]=0; 
break outer;
}while(false);}
ba=var1[0]; 
} 
else 
{
ba=var1[0]*10;
if (var1len>1) 
ba=ba+var1[1];
}
mult=BigDecimal.div((ba*10),b2b);
if (mult==0) 
mult=1;
thisdigit=thisdigit+mult;
var1=this.byteaddsub(var1,var1len,var2,var2len,-mult,true);
if (var1[0]!=0) 
continue inner; 
{var $23=var1len-2;start=0;start:for(;start<=$23;start++){
if (var1[start]!=0) 
break start;
var1len--;
}
}
if (start==0) 
continue inner;
this.arraycopy(var1,start,var1,0,var1len);
}
}
if ((have!=0)||(thisdigit!=0)) 
{ 
res.mant[have]=thisdigit;
have++;
if (have==(reqdig+1)) 
break outer; 
if (var1[0]==0) 
break outer; 
}
if (scale>=0) 
if ((-res.exp)>scale) 
break outer;
if (code!='D') 
if (res.exp<=0) 
break outer;
res.exp=res.exp-1; 
var2len--;
}
}
if (have==0) 
have=1; 
if ((code=='I')||(code=='R')) 
{
if ((have+res.exp)>reqdig) 
throw "dodivide(): Integer overflow";
if (code=='R') 
{remainder:do{
if (res.mant[0]==0)  
return this.clone(lhs).finish(set,false); 
if (var1[0]==0) 
return this.ZERO; 
res.ind=lhs.ind; 
padding=((reqdig+reqdig)+1)-lhs.mant.length;
res.exp=(res.exp-padding)+lhs.exp;
d=var1len;
{i=d-1;i:for(;i>=1;i--){if(!((res.exp<lhs.exp)&&(res.exp<rhs.exp)))break;
if (var1[i]!=0) 
break i;
d--;
res.exp=res.exp+1;
}
}
if (d<var1.length) 
{
newvar1=new Array(d);
this.arraycopy(var1,0,newvar1,0,d);
var1=newvar1;
}
res.mant=var1;
return res.finish(set,false);
}while(false);}
}
else 
{
if (var1[0]!=0) 
{ 
lasthave=res.mant[have-1];
if (((lasthave%5))==0) 
res.mant[have-1]=(lasthave+1);
}
}
if (scale>=0) 
{scaled:do{
if (have!=res.mant.length) 
res.exp=res.exp-((res.mant.length-have));
actdig=res.mant.length-(((-res.exp)-scale));
res.round(actdig,set.roundingMode); 
if (res.exp!=(-scale)) 
{
res.mant=this.extend(res.mant,res.mant.length+1);
res.exp=res.exp-1;
}
return res.finish(set,true); 
}while(false);}
if (have==res.mant.length) 
{ 
res.round(set);
have=reqdig;
}
else 
{
if (res.mant[0]==0) 
return this.ZERO; 
newmant=new Array(have); 
this.arraycopy(res.mant,0,newmant,0,have);
res.mant=newmant;
}
return res.finish(set,true);
}
BigDecimal.prototype.bad =  function (prefix, s) {
throw prefix + "Not a number: "+s;
}
BigDecimal.prototype.badarg =  function (aname, pos, value) {
throw "Bad argument "+pos+" to "+aname+": "+value;
}
BigDecimal.prototype.extend =  function (inarr, newlen) {
var newarr;
if (inarr.length==newlen) 
return inarr;
newarr=this.createArrayWithZeros(newlen);
this.arraycopy(inarr,0,newarr,0,inarr.length);
return newarr;
}
BigDecimal.prototype.byteaddsub =  function (a, avlen, b, bvlen, m, reuse) {
var alength;
var blength;
var ap;
var bp;
var maxarr;
var reb;
var quickm;
var digit;
var op=0;
var dp90=0;
var newarr;
var i=0;
alength=a.length; 
blength=b.length; 
ap=avlen-1; 
bp=bvlen-1; 
maxarr=bp;
if (maxarr<ap) 
maxarr=ap;
reb=null; 
if (reuse) 
if ((maxarr+1)==alength) 
reb=a; 
if (reb==null){ 
reb=this.createArrayWithZeros(maxarr+1); 
}
quickm=false; 
if (m==1) 
quickm=true; 
else 
if (m==(-1)) 
quickm=true; 
digit=0; 
{op=maxarr;op:for(;op>=0;op--){
if (ap>=0) 
{
if (ap<alength) 
digit=digit+a[ap]; 
ap--;
}
if (bp>=0) 
{
if (bp<blength) 
{ 
if (quickm) 
{
if (m>0) 
digit=digit+b[bp]; 
else 
digit=digit-b[bp]; 
}
else 
digit=digit+(b[bp]*m);
}
bp--;
}
if (digit<10) 
if (digit>=0) 
{quick:do{ 
reb[op]=digit;
digit=0; 
continue op;
}while(false);}
dp90=digit+90;
reb[op]=this.bytedig[dp90]; 
digit=this.bytecar[dp90]; 
}
}
if (digit==0) 
return reb; 
newarr=null;
if (reuse) 
if ((maxarr+2)==a.length) 
newarr=a; 
if (newarr==null) 
newarr=new Array(maxarr+2);
newarr[0]=digit; 
{var $24=maxarr+1;i=0;i:for(;$24>0;$24--,i++){
newarr[i+1]=reb[i];
}
}
return newarr;
}
BigDecimal.prototype.diginit =  function () {
var work;
var op=0;
var digit=0;
work=new Array((90+99)+1);
{op=0;op:for(;op<=(90+99);op++){
digit=op-90;
if (digit>=0) 
{
work[op]=(digit%10);
BigDecimal.prototype.bytecar[op]=(BigDecimal.div(digit,10)); 
continue op;
}
digit=digit+100; 
work[op]=(digit%10);
BigDecimal.prototype.bytecar[op]=((BigDecimal.div(digit,10))-10); 
}
}
return work;
}
BigDecimal.prototype.clone =  function (dec) {
var copy;
copy=new BigDecimal();
copy.ind=dec.ind;
copy.exp=dec.exp;
copy.form=dec.form;
copy.mant=dec.mant;
return copy;
}
BigDecimal.prototype.checkdigits =  function (rhs, dig) {
if (dig==0) 
return; 
if (this.mant.length>dig) 
if ((!(this.allzero(this.mant,dig)))) 
throw "Too many digits: "+this.toString();
if (rhs==null) 
return; 
if (rhs.mant.length>dig) 
if ((!(this.allzero(rhs.mant,dig)))) 
throw "Too many digits: "+rhs.toString();
return;
}
BigDecimal.prototype.round =  function () {
var len;
var mode;
if (arguments.length == 2)
{
len = arguments[0];
mode = arguments[1];
}
else if (arguments.length == 1)
{
var set = arguments[0];
len = set.digits;
mode = set.roundingMode;
}
else
{
throw "round(): " + arguments.length + " arguments given; expected 1 or 2";
}
var adjust;
var sign;
var oldmant;
var reuse=false;
var first=0;
var increment;
var newmant=null;
adjust=this.mant.length-len;
if (adjust<=0) 
return this; 
this.exp=this.exp+adjust; 
sign=this.ind; 
oldmant=this.mant; 
if (len>0) 
{
this.mant=new Array(len);
this.arraycopy(oldmant,0,this.mant,0,len);
reuse=true; 
first=oldmant[len]; 
}
else 
{
this.mant=this.ZERO.mant;
this.ind=this.iszero;
reuse=false; 
if (len==0) 
first=oldmant[0];
else 
first=0; 
}
increment=0; 
{modes:do{
if (mode==4)
{ 
if (first>=5) 
increment=sign;
}
else if (mode==7)
{ 
if ((!(this.allzero(oldmant,len)))) 
throw "round(): Rounding necessary";
}
else if (mode==5)
{ 
if (first>5) 
increment=sign;
else 
if (first==5) 
if ((!(this.allzero(oldmant,len+1)))) 
increment=sign;
}
else if (mode==6)
{ 
if (first>5) 
increment=sign;
else 
if (first==5) 
{
if ((!(this.allzero(oldmant,len+1)))) 
increment=sign;
else 
if ((((this.mant[this.mant.length-1])%2))==1) 
increment=sign;
}
}
else if (mode==1)
; 
else if (mode==0)
{ 
if ((!(this.allzero(oldmant,len)))) 
increment=sign;
}
else if (mode==2)
{ 
if (sign>0) 
if ((!(this.allzero(oldmant,len)))) 
increment=sign;
}
else if (mode==3)
{ 
if (sign<0) 
if ((!(this.allzero(oldmant,len)))) 
increment=sign;
}
else{
throw "round(): Bad round value: "+mode;
}
}while(false);}
if (increment!=0) 
{bump:do{
if (this.ind==this.iszero) 
{
this.mant=this.ONE.mant;
this.ind=increment;
}
else 
{
if (this.ind==this.isneg) 
increment=-increment;
newmant=this.byteaddsub(this.mant,this.mant.length,this.ONE.mant,1,increment,reuse);
if (newmant.length>this.mant.length) 
{ 
this.exp++;
this.arraycopy(newmant,0,this.mant,0,this.mant.length);
}
else 
this.mant=newmant;
}
}while(false);}
if (this.exp>this.MaxExp) 
throw "round(): Exponent Overflow: "+this.exp;
return this;
}
BigDecimal.prototype.allzero =  function (array, start) {
var i=0;
if (start<0) 
start=0;
{var $25=array.length-1;i=start;i:for(;i<=$25;i++){
if (array[i]!=0) 
return false;
}
}
return true;
}
BigDecimal.prototype.finish =  function (set, strip) {
var d=0;
var i=0;
var newmant=null;
var mag=0;
var sig=0;
if (set.digits!=0) 
if (this.mant.length>set.digits) 
this.round(set);
if (strip) 
if (set.form!=0) 
{
d=this.mant.length;
{i=d-1;i:for(;i>=1;i--){
if (this.mant[i]!=0) 
break i;
d--;
this.exp++;
}
}
if (d<this.mant.length) 
{
newmant=new Array(d);
this.arraycopy(this.mant,0,newmant,0,d);
this.mant=newmant;
}
}
this.form=0; 
{var $26=this.mant.length;i=0;i:for(;$26>0;$26--,i++){
if (this.mant[i]!=0) 
{
if (i>0) 
{delead:do{
newmant=new Array(this.mant.length-i);
this.arraycopy(this.mant,i,newmant,0,this.mant.length-i);
this.mant=newmant;
}while(false);}
mag=this.exp+this.mant.length;
if (mag>0) 
{ 
if (mag>set.digits) 
if (set.digits!=0) 
this.form=set.form;
if ((mag-1)<=this.MaxExp) 
return this; 
}
else 
if (mag<(-5)) 
this.form=set.form;
mag--;
if ((mag<this.MinExp)||(mag>this.MaxExp)) 
{overflow:do{
if (this.form==2) 
{
sig=mag%3; 
if (sig<0) 
sig=3+sig; 
mag=mag-sig; 
if (mag>=this.MinExp) 
if (mag<=this.MaxExp) 
break overflow;
}
throw "finish(): Exponent Overflow: "+mag;
}while(false);}
return this;
}
}
}
this.ind=this.iszero;
{
if (set.form!=0)
this.exp=0; 
else if (this.exp>0)
this.exp=0; 
else{
if (this.exp<this.MinExp) 
throw "finish(): Exponent Overflow: "+this.exp;
}
}
this.mant=this.ZERO.mant; 
return this;
}
BigDecimal.prototype.ispos = 1;
BigDecimal.prototype.iszero = 0;
BigDecimal.prototype.isneg = -1;
BigDecimal.prototype.MinExp=-999999999; 
BigDecimal.prototype.MaxExp=999999999; 
BigDecimal.prototype.MinArg=-999999999; 
BigDecimal.prototype.MaxArg=999999999; 
BigDecimal.prototype.gPlainMC = null;
BigDecimal.prototype.plainMC = function() {
if (BigDecimal.prototype.gPlainMC == null) {
BigDecimal.prototype.gPlainMC = new MathContext(0, 0);
}
return BigDecimal.prototype.gPlainMC;
}
BigDecimal.prototype.bytecar = new Array((90+99)+1);
BigDecimal.prototype.bytedig = BigDecimal.prototype.diginit();
BigDecimal.prototype.ZERO = new BigDecimal("0");
BigDecimal.prototype.ONE = new BigDecimal("1");
BigDecimal.prototype.TEN = new BigDecimal("10");
function BigDecimal() {
this.ind = 0;
this.form = 0;
this.mant = null;
this.exp = 0;
if (arguments.length == 0)
return;
var inchars;
var offset;
var length;
if (arguments.length == 1)
{
inchars = arguments[0];
offset = 0;
length = inchars.length;
}
else
{
inchars = arguments[0];
offset = arguments[1];
length = arguments[2];
}
if (typeof inchars == "string")
{
inchars = inchars.split("");
}
var exotic;
var hadexp;
var d;
var dotoff;
var last;
var i=0;
var si=0;
var eneg=false;
var k=0;
var elen=0;
var j=0;
var sj=0;
var dvalue=0;
var mag=0;
if (length<=0) 
this.bad("BigDecimal(): ", inchars); 
this.ind=this.ispos; 
if (inchars[0]==('-')) 
{
length--;
if (length==0) 
this.bad("BigDecimal(): ", inchars); 
this.ind=this.isneg;
offset++;
}
else 
if (inchars[0]==('+')) 
{
length--;
if (length==0) 
this.bad("BigDecimal(): ", inchars); 
offset++;
}
exotic=false; 
hadexp=false; 
d=0; 
dotoff=-1; 
last=-1; 
{var $1=length;i=offset;i:for(;$1>0;$1--,i++){
si=inchars[i];
if (si>='0')  
if (si<='9') 
{
last=i;
d++; 
continue i;
}
if (si=='.') 
{ 
if (dotoff>=0) 
this.bad("BigDecimal(): ", inchars); 
dotoff=i-offset; 
continue i;
}
if (si!='e') 
if (si!='E') 
{ 
if (si<'0' || si>'9') 
this.bad("BigDecimal(): ", inchars); 
exotic=true; 
last=i;
d++; 
continue i;
}
if ((i-offset)>(length-2)) 
this.bad("BigDecimal(): ", inchars); 
eneg=false;
if ((inchars[i+1])==('-')) 
{
eneg=true;
k=i+2;
}
else 
if ((inchars[i+1])==('+')) 
k=i+2;
else 
k=i+1;
elen=length-((k-offset)); 
if ((elen==0)||(elen>9)) 
this.bad("BigDecimal(): ", inchars); 
{var $2=elen;j=k;j:for(;$2>0;$2--,j++){
sj=inchars[j];
if (sj<'0') 
this.bad("BigDecimal(): ", inchars); 
if (sj>'9') 
{ 
this.bad("BigDecimal(): ", inchars);
}
else 
dvalue=sj-'0';
this.exp=(this.exp*10)+dvalue;
}
}
if (eneg) 
this.exp=-this.exp; 
hadexp=true; 
break i; 
}
}
if (d==0) 
this.bad("BigDecimal(): ", inchars); 
if (dotoff>=0) 
this.exp=(this.exp+dotoff)-d; 
{var $3=last-1;i=offset;i:for(;i<=$3;i++){
si=inchars[i];
if (si=='0') 
{
offset++;
dotoff--;
d--;
}
else 
if (si=='.') 
{
offset++; 
dotoff--;
}
else 
if (si<='9') 
break i;
else 
{
break i; 
}
}
}
this.mant=new Array(d); 
j=offset; 
if (exotic) 
{exotica:do{ 
{var $4=d;i=0;i:for(;$4>0;$4--,i++){
if (i==dotoff) 
j++; 
sj=inchars[j];
if (sj<='9') 
this.mant[i]=sj-'0';
else 
{
this.bad("BigDecimal(): ", inchars); 
}
j++;
}
}
}while(false);}
else 
{simple:do{
{var $5=d;i=0;i:for(;$5>0;$5--,i++){
if (i==dotoff) 
j++;
this.mant[i]=inchars[j]-'0';
j++;
}
}
}while(false);}
if (this.mant[0]==0) 
{
this.ind=this.iszero; 
if (this.exp>0) 
this.exp=0; 
if (hadexp) 
{ 
this.mant=this.ZERO.mant;
this.exp=0;
}
}
else 
{ 
if (hadexp) 
{
this.form=1;
mag=(this.exp+this.mant.length)-1; 
if ((mag<this.MinExp)||(mag>this.MaxExp)) 
this.bad("BigDecimal(): ", inchars);
}
}
return;
}

DecimalType.prototype=new Datatype(); DecimalType.prototype.constructor=DecimalType; DecimalType.superclass=Datatype.prototype;;
DatatypeFactories[10] = function(val, arg) {
if (typeof arg != "undefined" && "p" in arg)
return new DecimalType(val, arg.p);
else
return new DecimalType(val);
}
function DecimalType(a, p) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a, p);
}
DecimalType.prototype.mPrecision = 2;
DecimalType.prototype.init = function(val, p) {
DecimalType.superclass.init.call(this);
if (typeof p == "number")
this.mPrecision = p;
;
if (val instanceof Datatype) {
this.mValue = val.toDecimal();
} else if (typeof val == "string") {
try 
{
var re = new RegExp("^\\s*([+-]?[\\d,]+(\\.\\d+)?)(.*)$");
val = val.replace(re, "$1");
this.mValue = new BigDecimal(val);
}
catch (e)
{
this.mValue = new BigDecimal("0");
}
} else if (val == null)
this.mValue = new BigDecimal("0");
else if (val instanceof BigDecimal) {
this.mValue = val;
} else {
;
}
}
DecimalType.prototype.set = function(val) {
;
this.mValue = val;
}
DecimalType.prototype.type = 10;
DecimalType.prototype.isNull = false;
DecimalType.prototype.args = function () {
return {p : this.mPrecision};
}
DecimalType.prototype.toDecimal = function() {
;
return this.mValue;
}
DecimalType.prototype.toString = function() {
;
var val = DecimalType.Round(this.mValue, this.mPrecision);
return En_USDecimalToLC(val.toString());
}
DecimalType.prototype.toChar = function() {
return this.toString();
}
DecimalType.prototype.toPrimitive = function() {
;
var val = DecimalType.Round(this.mValue, this.mPrecision);
return val.toString();
}
DecimalType.Round = function(val, precision) {
;
return new BigDecimal(val.format(-1, precision));
}
DecimalType.prototype.ROUND = function() {
return new DecimalType(DecimalType.Round(this.mValue, 0), this.mPrecision);
}
DecimalType.prototype.TRUNC = function() {
return new DecimalType(DecimalType.Round(this.mValue.add(new BigDecimal("-0.5")), 0), this.mPrecision);
}
DecimalType.prototype.ADD = function(a, b) {
;
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) && ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
;
this.set(a.toDecimal().add(b.toDecimal()));
return this;
}
DecimalType.prototype.SUB = function(a, b) {
;
;
;
if ((!(((1<<7|1<<13|1<<14) & (1<<a.type)) || (1<<0 & (1<<a.type))) && ((1<<7|1<<13|1<<14) & (1<<b.type))) ||
(((1<<7|1<<13|1<<14) & (1<<a.type)) && ((1<<7|1<<13|1<<14) & (1<<b.type)) && (a.type != b.type))) {
CurWFC.status(9339);
return;
}
;
this.set(a.toDecimal().subtract(b.toDecimal()));
return this;
}
DecimalType.prototype.MUL = function(a, b) {
;
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) || ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
;
this.mPrecision=9;
this.set(a.toDecimal().multiply(b.toDecimal()));
return this;
}
DecimalType.prototype.DIV = function(a, b) {
;
;
;
;
this.mPrecision=9;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) || ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
if (b.toDecimal() == 0)
CurWFC.status(9306);
a = a.toDecimal();
b = b.toDecimal();
this.set(a.divide(b, 9, 4));
return this;
}
DecimalType.prototype.MOD = function(a, b) {
;
;
;
if (!((1<<2 & (1<<a.type)) && (1<<2 & (1<<b.type))) &&
!((1<<0 & (1<<a.type)) && (((((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type))) | (1<<6 & (1<<b.type)))||((1<<4|1<<5) & (1<<b.type)))) &&
!((((((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) | (1<<6 & (1<<a.type)))||((1<<4|1<<5) & (1<<a.type))) && (1<<0 & (1<<b.type)))) {
CurWFC.status(9339);
return;
}
;
if (!(a instanceof IntegerType && (b instanceof IntegerType || b instanceof NullType)))
this.set(new BigDecimal("0"));
else {
if (b.toInteger() == 0)
CurWFC.status(9306);
this.set(new BigDecimal("" + (a.toInteger() % b.toInteger())));
}
return this;
}
DecimalType.prototype.NEG = function(a) {
; 
;
;
this.set(a.toDecimal().multiply(new BigDecimal("-1")));
return this;
}
DecimalType.prototype.EQ = function(a) {
;
;
if (a.isNull)
return false;
;
return (this.mValue.compareTo(a.toDecimal()) == 0);
}
DecimalType.prototype.NE = function(a) {
;
return !this.EQ(a)
}
DecimalType.prototype.GT = function(a) {
;
;
;
return (this.mValue.compareTo(a.toDecimal()) > 0);
}
DecimalType.prototype.GE = function(a) {
;
;
;
return (this.mValue.compareTo(a.toDecimal()) >= 0);
}
DecimalType.prototype.LT = function(a) {
;
return !this.GE(a)
}
DecimalType.prototype.LE = function(a) {
;
return !this.GT(a);
}
DecimalType.prototype.toReal = function() {
;
return new RealType(this.mValue.toString()).toReal();
}
DecimalType.prototype.toInteger = function() {
;
return new IntegerType(this.mValue.toString()).toInteger();
}

CurrencyType.prototype=new Datatype(); CurrencyType.prototype.constructor=CurrencyType; CurrencyType.superclass=Datatype.prototype;;
DatatypeFactories[12] = function(val, arg) {
if (typeof arg != "undefined" && "p" in arg)
return new CurrencyType(val, arg.p);
else
return new CurrencyType(val);
}
function CurrencyType(a, p, c) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a, p, c);
}
CurrencyType.prototype.type = 12;
CurrencyType.prototype.isNull = false;
CurrencyType.prototype.mPrecision = 2;
CurrencyType.RE_NUMBER = new RegExp("^\\s*([+-]?[\\d,]+(\\.\\d+)?)(.*)$");
CurrencyType.prototype.init = function(val, p, convert) {
CurrencyType.superclass.init.call(this);
if (typeof p == "number")
this.mPrecision = p;
if (typeof convert != "boolean")
convert = false;
;
if (val instanceof CurrencyType) {
this.mValue = val.mValue;
this.mCurCode = val.mCurCode;
if (typeof(p) == "object")
this.mPrecision = p.GetPrecision(this.mCurCode);
else
this.mPrecision = val.mPrecision;
this.mDate = val.mDate;
this.mFunc = {};
for (var c in val.mFunc) {
this.mFunc[c]={};
for (var props in val.mFunc[c]) {
this.mFunc[c][props]=val.mFunc[c][props];
}
}
} else if (val instanceof Datatype) {
val = val.toCurrency(p);
this.mValue = val.mValue;
this.mCurCode = val.mCurCode;
this.mPrecision = val.mPrecision;
this.mDate = val.mDate;
this.mFunc = {};
for (var c in val.mFunc)
this.mFunc[c] = {p : val.mFunc[c].p, v : val.mFunc[c].v}; 
} else if (typeof val == "string") {
this.mValue = null;
this.mCurCode = "";
var vals = val.split(" ");
if (vals.length > 1) {
this.mCurCode = vals[1].toUpperCase();
if (typeof(p) == "object") {
this.mPrecision = p.GetPrecision(this.mCurCode);
}
}
if (vals.length > 0) {
try {
var valuePart = vals[0];
if (convert)
valuePart = LCDecimalToEn_US(valuePart, false);
valuePart = valuePart.replace(CurrencyType.RE_NUMBER, "$1");
this.mValue = new BigDecimal(valuePart);
} catch (err) {
if (this.mCurCode == null || this.mCurCode == "")
this.mValue = null;
else
this.mValue = new BigDecimal("0");
}
}
if (vals.length > 2) {
this.mDate = new TimeType(vals[2]).toInteger();
}
this.mFunc = {};
var i, prec, value;
for (i=3; i+1 < vals.length && vals[i+1].length > 0; i+=2) {
prec = 2;
if (typeof p == "object")
prec = p.GetPrecision(vals[i+1]);
value = vals[i];
if (convert)
value = LCDecimalToEn_US(value, false);
try {
value = new BigDecimal(value);
} catch (err) {
value = new BigDecimal("0");
}
this.mFunc[vals[i+1]] = {v : value, p : prec};
}
} else if (val == null) {
this.mValue = null;
this.mCurCode = "";
this.mFunc = null;
} else if (val instanceof BigDecimal || typeof val == "number") {
if (typeof val == "number")
val = new BigDecimal("" + val);
this.mValue = val;
this.mCurCode = "";
this.mFunc = null;
} else {
;
}
this.mDate = this.getDate();
}
CurrencyType.prototype.part = function(funcPart, tag) {
;
;
switch (tag) {
case 0: { 
return this;
}
case 1: { 
return (this.mValue == null) ? Null : new DecimalType(this.mValue);
}
case 2: { 
return new CharType(this.mCurCode);
}
case 3: {
return new TimeType(this.getDate());
}
case 4: {
if (funcPart in this.mFunc) {
var val = this.mFunc[funcPart].v;
if (val == null)  {
return Null;
}
;
val = new CurrencyType(val, this.mFunc[funcPart].p);
val.mCurCode = funcPart;
return val;
} else {
return Null;
}
}
}
return Null;
}
CurrencyType.prototype.compound = function(args) {
;
if (args.length != 1 && args.length != 2) {
return null;
}
;
var funcPart = "";
var tag = -1;
var val = args[0].toUpperCase();
if (val == "FIELD")
tag = 0;
else if (val == "VALUE")
tag = 1;
else if (val == "TYPE")
tag = 2;
else if (val == "DATE")
tag = 3;
else if (typeof val == "string" && val.length == 3) {
tag = 4;
funcPart = val;
}
else if (val.isDigits()){
tag = parseInt(val, 10);
if (tag < 0 || tag > 4) {
return null;
}
}
else {
return null;
}
return this.part(funcPart, tag);
}
CurrencyType.prototype.toCurrency = function() {
return this;
}
CurrencyType.prototype.toString = function() {
if (this.mValue == null)
return this.mCurCode;
;
var val = DecimalType.Round(this.mValue, this.mPrecision);
return En_USDecimalToLC(val.toString()) + " " + this.mCurCode;
}
CurrencyType.prototype.toChar = function() {
return this.toString();
}
CurrencyType.prototype.toPrimitive = function() {
var val = "";
if (this.mValue != null) {
;
val = DecimalType.Round(this.mValue, this.mPrecision);
}
if (this.mCurCode == null)
return val.toString();
val += " " + this.mCurCode;
var f1 = true;
for (var f in this.mFunc) {
if ("v" in this.mFunc[f] && this.mFunc[f].v != null) {
if (f1) {
;
val += " " + this.getDate();
f1 = false;
}
val += " " + DecimalType.Round(this.mFunc[f].v, this.mFunc[f].p);
val += " " + f;
}
}
return val.toString();
}
CurrencyType.prototype.toDecimal = function() {
if (this.mValue == null)
return new BigDecimal("0");
;
return this.mValue;
}
CurrencyType.prototype.toInteger = function() {
if (this.mValue == null)
return new IntegerType(0);
;
return new IntegerType(this.mValue.toString()).toInteger();
}
CurrencyType.prototype.toReal = function() {
if (this.mValue == null)
return new RealType("0");
;
return new RealType(this.mValue.toString()).toReal();
}
CurrencyType.prototype.CalculateFunctional = function() {
var exch = GetExchangeRates(ARKWGetByName("SERVER").toString(), this.getDate());
var c;
for (c in this.mFunc) {
if (this.mValue == null) {
this.mFunc[c].v = null;
continue;
}
var key = this.mCurCode + c;
if (this.mCurCode == c) {
this.mFunc[c].v = new BigDecimal(this.mValue.toString());
} else if (key in exch && exch[key]) {
;
this.mFunc[c].v = this.mValue.multiply(exch[key]);
}
}  
}
CurrencyType.prototype.CurrSetDate = function(date) {
if (date > 2147483647 || date <= 0) {
date = new Date().UnixTimestamp();
}
var val = new CurrencyType(this.mValue, this.mPrecision);
val.mCurCode = this.mCurCode;
val.mFunc = {};
val.mDate = date;
var c;
for (c in this.mFunc) {
val.mFunc[c] = {p : this.mFunc[c].p};
}
val.CalculateFunctional();
return val;
}
CurrencyType.prototype.CurrSetType = function(type) {
if (type instanceof CurrencyType) {
type = type.mCurCode;
} else {
type = type.toString();
var re = /[A-Za-z]+/;
var match = re.exec(type);
if (match) {
type = match[0].toUpperCase();
} else {
return Null;
}
}
if (!(type in currencyCodes)) {
return Null;
}
var val = new CurrencyType(this.mValue, this.mPrecision);
val.mCurCode = type;
val.mFunc = {};
val.mDate = this.getDate();
val.mValue = this.mValue;
var c;
for (c in this.mFunc) {
val.mFunc[c] = {p : this.mFunc[c].p};
}
val.CalculateFunctional();
return val;
}
CurrencyType.prototype.CurrSetValue = function(newVal) {
;
var val = new CurrencyType(this.mValue, this.mPrecision);
val.mCurCode = this.mCurCode;
val.mFunc = {};
val.mDate = this.getDate();
val.mValue = new BigDecimal(newVal.toString());
var c;
for (c in this.mFunc) {
val.mFunc[c] = {p : this.mFunc[c].p};
}
val.CalculateFunctional();
return val;
}
CurrencyType.prototype.CurrConvert = function(type, date, precision) {
;
;
if (typeof precision != "number")
precision = this.mPrecision;
if (date > 2147483647 || date <= 0) {
date = new Date().UnixTimestamp();
}
type = type.toUpperCase();
if (!(type in currencyCodes)) {
return Null;
}
var val = new CurrencyType(this.mValue, precision);
val.mCurCode = type;
val.mFunc = {};
val.mDate = date;
if (this.mCurCode == val.mCurCode) {
val.mValue = this.mValue;
} else {
var exch = GetExchangeRates(ARKWGetByName("SERVER").toString(), date);
var key = this.mCurCode + type;
if (key in exch && exch[key])
{
;
val.mValue = ((this.mValue == null) ? null : this.mValue.multiply(exch[key]));
}
else
{
return Null;
}
}
var c;
for (c in this.mFunc) {
val.mFunc[c] = {p : this.mFunc[c].p};
}
val.CalculateFunctional();
return val;
}
CurrencyType.prototype.getDate = function()
{
if (this.mDate == null || typeof(this.mDate) == "undefined") {
this.mDate = new Date().UnixTimestamp();
}
return this.mDate;
}
CurrencyType.prototype.ADD = function(a, b) {
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) || ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
return CurrencyType.ArithOp(a, b, BigDecimal.prototype.add, this);
}
CurrencyType.prototype.SUB = function(a, b) {
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) || ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
return CurrencyType.ArithOp(a, b, BigDecimal.prototype.subtract, this);
}
CurrencyType.prototype.MUL = function(a, b) {
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) || ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
this.mPrecision=9;
return CurrencyType.ArithOp(a, b, BigDecimal.prototype.multiply, this);
}
CurrencyType.prototype.DIV = function(a, b) {
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) || ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
this.mPrecision=9;
return CurrencyType.ArithOp(a, b, BigDecimal.prototype.divide, this);
}
CurrencyType.prototype.MOD = function(a, b) {
;
;
;
if (!((1<<2 & (1<<a.type)) && (1<<2 & (1<<b.type))) &&
!((1<<0 & (1<<a.type)) && (((((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type))) | (1<<6 & (1<<b.type))) || ((1<<4|1<<5) & (1<<b.type)))) &&
!((((((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) | (1<<6 & (1<<a.type))) || ((1<<4|1<<5) & (1<<a.type))) && (1<<0 & (1<<b.type)))) {
CurWFC.status(9339);
return;
}
;
if (!(a instanceof IntegerType && (b instanceof IntegerType || b instanceof NullType)))
this.mValue = new BigDecimal("0");
else {
if (b.toInteger() == 0)
CurWFC.status(9306);
this.mValue = new BigDecimal("" + (a.toInteger() % b.toInteger()));
}
return this;
}
CurrencyType.ArithOp = function(a, b, opfunc, result) {
;
;
;
;
;
;
var divOp = (opfunc == BigDecimal.prototype.divide);
var divResult = (a instanceof CurrencyType) && !(b instanceof CurrencyType);
a = a.toCurrency(result.mPrecision);
b = b.toCurrency(result.mPrecision);
if (a.mValue == null && b.mValue == null) {
CurWFC.status(9339);
return;
}
if (a.mValue == null || b.mValue == null)
return Null;
if (a instanceof CurrencyType && a.mCurCode != "") {
if (b.mCurCode == "")
b.mCurCode = a.mCurCode;
if (b.mCurCode != a.mCurCode) {
if (a.mCurCode in b.mFunc || !(b.mCurCode in a.mFunc))
b = b.CurrConvert(a.mCurCode, b.getDate(), result.mPrecision);
else
a = a.CurrConvert(b.mCurCode, a.getDate(), result.mPrecision);
if (b.isNull) {
b = new CurrencyType("0");
b.mCurCode = a.mCurCode;
}
}
} else {
a = new CurrencyType(a.toDecimal());
a.mCurCode = b.mCurCode;
}
result.mCurCode = a.mCurCode;
if (divOp && b.toDecimal() == 0)
CurWFC.status(9306);
a=a.ROUNDToOwnPrecision();
b=b.ROUNDToOwnPrecision();
result.mValue = opfunc.call(a.mValue, b.mValue);
result.mDate = a.mDate;
result=result.ROUNDToOwnPrecision();
if (result.mCurCode && (!divOp || (divOp && divResult)))
return result;
else
return new DecimalType(result.mValue);
}
CurrencyType.prototype.NEG = function(a) {
; 
;
;
if (a instanceof CurrencyType) {
this.mValue = a.mValue.multiply(new BigDecimal("-1"));
this.mCurCode = a.mCurCode;
this.mPrecision = a.mPrecision;
return this;
} else {
return new DecimalType(a.toDecimal().multiply(new BigDecimal("-1")));
}
}
CurrencyType.prototype.RELOP = function(a, compareFunc) {
if(this.mValue == null)
this.mValue = new BigDecimal("0");
;
;
;
if (a.isNull) {
return false;
}
if (a instanceof CurrencyType) {
if (this.mCurCode == a.mCurCode) {
return compareFunc(this.mValue.compareTo(a.mValue));
} else if (a.mCurCode) {
var b = this.CurrConvert(a.mCurCode, this.getDate());
return (!b.isNull && b.mCurCode == a.mCurCode && compareFunc(b.mValue.compareTo(a.mValue)));
}
} else {
return compareFunc(this.mValue.compareTo(a.toDecimal()));
}
return false;
}
CurrencyType.prototype.EQ = function(a) {
return this.RELOP(a, function(comp) {return (comp == 0);});
}
CurrencyType.prototype.NE = function(a) {
;
return !this.EQ(a)
}
CurrencyType.prototype.GT = function(a) {
return this.RELOP(a, function(comp) {return (comp > 0);});
}
CurrencyType.prototype.GE = function(a) {
return this.RELOP(a, function(comp) {return (comp >= 0);});
}
CurrencyType.prototype.LT = function(a) {
;
return !this.GE(a)
}
CurrencyType.prototype.LE = function(a) {
;
return !this.GT(a);
}
CurrencyType.prototype.ROUNDToOwnPrecision=function() {
var val = new CurrencyType(this);
return this.CurrSetValue(DecimalType.Round(val.mValue,val.mPrecision));
}
CurrencyType.prototype.ROUND=function() { 
var val = new CurrencyType(this);
return this.CurrSetValue(DecimalType.Round(val.mValue,0));
}
CurrencyType.prototype.TRUNC = function() {
var val = new CurrencyType(this);
return this.CurrSetValue(new DecimalType(val.mValue, val.mPrecision).TRUNC().toDecimal());
}
CurrencyType.prototype.EQForSet = function(val) {
;
if (val.type == 12 && this.mDate != val.mDate)
return false;
return this.toString()==val.toString()
}
CurrencyType.prototype.Diff = function(a) {
;
return !(this.type == 12 && this.mValue == a.mValue && this.mDate == a.mDate);
}

RealType.prototype=new Datatype(); RealType.prototype.constructor=RealType; RealType.superclass=Datatype.prototype;;
DatatypeFactories[3] = function(val, arg) {
if (typeof arg != "undefined" && "p" in arg)
return new RealType(val, arg.p);
else
return new RealType(val);
}
function RealType(a, p) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a, p);
}
RealType.prototype.mPrecision = 6;
RealType.prototype.init = function(val, p) {
;
if (typeof p == "number")
this.mPrecision = p;
;
if (val instanceof Datatype) {
this.mValue = val.toReal();
} else if (typeof val == "string") {
this.mValue = parseFloat(val);
if (isNaN(this.mValue)) {
this.mValue = 0; 
}
} else
this.mValue = val;
}
RealType.prototype.set = function(val) {
;
this.mValue = val;
}
RealType.prototype.type = 3;
RealType.prototype.isNull = false;
RealType.prototype.toReal = function() {
;
return this.mValue;
}
RealType.prototype.toChar = function() {
;
return En_USRealToLC(this.mValue.toFixed(this.mPrecision));
}
RealType.prototype.args = function () {
return {p : this.mPrecision};
}
RealType.prototype.toString = function () {
;
var result = "";
if (this.mValue >= 1000000000 || this.mValue <= -1000000000 ||
(this.mValue > 0 && this.mValue < 0.000001) || 
(this.mValue < 0 && this.mValue > -0.000001))
{
result = this.mValue.toExponential(this.mPrecision);
var re = new RegExp("^([+-]?\\d+)(\\.[1-9]*)0*([Ee][+-]?\\d+)$");
result = result.replace(re, "$1$2$3");
re = new RegExp("^(.*)\\.([Ee].*)$");
result = result.replace(re, "$1$2");
var ndx = result.length - 1;
while (ndx > 0 && result.charAt(ndx) != '+' && result.charAt(ndx) != '-')
ndx--;
ndx++;
var tmp = result.substring(0, ndx);
var pad = 3 - (result.length - ndx);
for (var i=0; i<pad;i++)
tmp += "0";
tmp += result.substr(ndx);
result = tmp;
}
else
{
result = this.mValue.toFixed(this.mPrecision);
}
return En_USRealToLC(result);
}
RealType.prototype.toPrimitive = function () {
;
return this.mValue.toString();
}
RealType.prototype.ADD = function(a, b) {
;
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) && ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
;
this.set(a.toReal() + b.toReal());
return this;
}
RealType.prototype.SUB = function(a, b) {
;
;
;
if ((!(((1<<7|1<<13|1<<14) & (1<<a.type)) || (1<<0 & (1<<a.type))) && ((1<<7|1<<13|1<<14) & (1<<b.type))) ||
(((1<<7|1<<13|1<<14) & (1<<a.type)) && ((1<<7|1<<13|1<<14) & (1<<b.type)) && (a.type != b.type))) {
CurWFC.status(9339);
return;
}
;
this.set(a.toReal() - b.toReal());
return this;
}
RealType.prototype.MUL = function(a, b) {
;
;
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) || ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
this.mPrecision=9; 
this.set(a.toReal() * b.toReal());
return this;
}
RealType.prototype.DIV = function(a, b) {
;
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) || ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
;
this.mPrecision=9; 
if (b.toReal() == 0)
CurWFC.status(9306);
this.set(a.toReal() / b.toReal());
return this;
}
RealType.prototype.MOD = function(a, b) {
;
;
;
if (!((1<<2 & (1<<a.type)) && (1<<2 & (1<<b.type))) &&
!((1<<0 & (1<<a.type)) && (((((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type))) | (1<<6 & (1<<b.type)))||((1<<4|1<<5) & (1<<b.type)))) &&
!((((((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) | (1<<6 & (1<<a.type)))||((1<<4|1<<5) & (1<<a.type))) && (1<<0 & (1<<b.type)))) {
CurWFC.status(9339);
return;
}
;
if (!(a instanceof IntegerType && (b instanceof IntegerType || b instanceof NullType)))
this.set(0);
else {
if (b.toInteger() == 0)
CurWFC.status(9306);
this.set(a.toInteger() % b.toInteger());
}
return this;
}
RealType.prototype.NEG = function(a) {
; 
;
;
this.set(-a.toReal());
return this;
}
RealType.prototype.EQ = function(a) {
;
;
if (a.isNull)
return false;
;
return this.mValue == a.toReal();
}
RealType.prototype.NE = function(a) {
;
return !this.EQ(a)
}
RealType.prototype.GT = function(a) {
;
;
;
return this.mValue > a.toReal();
}
RealType.prototype.GE = function(a) {
;
;
;
return this.mValue >= a.toReal();
}
RealType.prototype.LT = function(a) {
;
return !this.GE(a)
}
RealType.prototype.LE = function(a) {
;
return !this.GT(a);
}
RealType.prototype.toDecimal = function() {
;
var res = new DecimalType(this.mValue.toFixed(this.mPrecision));
return res.toDecimal();
}
RealType.prototype.toInteger = function() {
;
return new IntegerType(this.mValue).toInteger();
}

IntegerType.prototype=new Datatype(); IntegerType.prototype.constructor=IntegerType; IntegerType.superclass=Datatype.prototype;;
DatatypeFactories[2] = function(val) {
return new IntegerType(val);
}
function IntegerType(a) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a);
}
IntegerType.prototype.init = function(val) {
;
;
if (val instanceof Datatype) {
;
this.mValue = val.toInteger();
} else if (typeof val == "string") {
var re = /([+-]?[0-9]*).*/;
val = val.replace(re, "$1");
var f = parseInt(val, 10);
if (f > 2147483647) {
this.mValue = 2147483647;
} else if (f < -2147483647) {
this.mValue = -2147483647;
} else {
this.mValue = f;
}
if (isNaN(this.mValue))
this.mValue = 0;
} else if (typeof val == "number") {
if (val < 0)
this.mValue = Math.ceil(val);
else
this.mValue = Math.floor(val);
} else {
this.mValue = val;
}
;
if (this.mValue < -2147483647)
this.mValue = -2147483647;
else if (this.mValue > 2147483647)
this.mValue = 2147483647;
}
IntegerType.prototype.set = function(val) {
;
; 
if (val < -2147483647)
val = -2147483647;
else if (val > 2147483647)
val = 2147483647;
this.mValue = val;
}
IntegerType.prototype.type = 2;
IntegerType.prototype.isNull = false;
IntegerType.prototype.toInteger = function() {
;
return this.mValue;
}
IntegerType.prototype.toReal = function() {
;
return this.mValue;
}
IntegerType.prototype.toString = function () {
;
return this.mValue.toString();
}
IntegerType.prototype.toPrimitive = function () {
;
return this.mValue.toString();
}
IntegerType.prototype.ADD = function(a, b) {
;
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) && ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
;
if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.ADD(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType || a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new DecimalType(null);
this.set(c.ADD(a, b).toInteger());
}
else
this.set(a.toInteger() + b.toInteger());
return this;
}
IntegerType.prototype.SUB = function(a, b) {
;
;
;
if ((!(((1<<7|1<<13|1<<14) & (1<<a.type)) || (1<<0 & (1<<a.type))) && ((1<<7|1<<13|1<<14) & (1<<b.type))) ||
(((1<<7|1<<13|1<<14) & (1<<a.type)) && ((1<<7|1<<13|1<<14) & (1<<b.type)) && (a.type != b.type))) {
CurWFC.status(9339);
return;
}
;
if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.SUB(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType || a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new DecimalType(null);
this.set(c.SUB(a, b).toInteger());
}
else
this.set(a.toInteger() - b.toInteger());
return this;
}
IntegerType.prototype.MUL = function(a, b) {
;
;
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) || ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.MUL(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType) {
var c = new DecimalType(null);
this.set(c.MUL(a, b).toInteger());
}
else if (a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new CurrencyType(null);
this.set(c.MUL(a, b).toInteger());
}
else
this.set(a.toInteger() * b.toInteger());
return this;
}
IntegerType.prototype.DIV = function(a, b) {
;
;
;
if (((1<<7|1<<13|1<<14) & (1<<a.type)) || ((1<<7|1<<13|1<<14) & (1<<b.type))) {
CurWFC.status(9339);
return;
}
;
if (b.toInteger() == 0) {
CurWFC.status(9306);
return;
}
if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.DIV(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType) {
var c = new DecimalType(null);
this.set(c.DIV(a, b).toInteger());
}
else if (a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new CurrencyType(null);
this.set(c.DIV(a, b).toInteger());
}
else {
var c = (a.toInteger() / b.toInteger());
if (c < 0)
this.set(Math.ceil(c));
else
this.set(Math.floor(c));
}
return this;
}
IntegerType.prototype.MOD = function(a, b) {
;
;
;
if (!(((((1<<4|1<<5) & (1<<a.type)) | (1<<0 & (1<<a.type))) | (1<<6 & (1<<a.type))) && (((((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type))) | (1<<6 & (1<<b.type))) | ((1<<4|1<<5) & (1<<b.type)))) &&
!((1<<2 & (1<<a.type)) && (((((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type))) | (1<<6 & (1<<b.type))) | ((1<<4|1<<5) & (1<<b.type))))){
CurWFC.status(9339);
return;
}
if (((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) && !(1<<2 & (1<<b.type)))
this.set(0);
else {
;
if (b.toInteger() == 0)
CurWFC.status(9306);
this.set(a.toInteger() % b.toInteger());
}
return this;
}
IntegerType.prototype.NEG = function(a) {
; 
;
;
this.set(-a.toInteger());
return this;
}
IntegerType.prototype.EQ = function(a) {
;
;
if (a.isNull)
return false;
;
return this.mValue == a.toInteger();
}
IntegerType.prototype.NE = function(a) {
;
return !this.EQ(a)
}
IntegerType.prototype.GT = function(a) {
;
;
;
return this.mValue > a.toInteger();
}
IntegerType.prototype.GE = function(a) {
;
;
;
return this.mValue >= a.toInteger();
}
IntegerType.prototype.LT = function(a) {
;
return !this.GE(a)
}
IntegerType.prototype.LE = function(a) {
;
return !this.GT(a)
}
IntegerType.ZERO = new IntegerType(0);
IntegerType.ONE = new IntegerType(1);

TimeType.prototype=new Datatype(); TimeType.prototype.constructor=TimeType; TimeType.superclass=Datatype.prototype;; 
DatatypeFactories[7] = function(val) {
return new TimeType(val);
}
function TimeType(a) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a);
}
TimeType.prototype.init = function(val) {
;
;
if (val instanceof Datatype) {
;
this.mValue = val.toTime().toInteger();
} else if (typeof val == "string") {
if (val.isNumeric())
this.mValue = parseInt(val, 10);
else
this.mValue = TimeType.getTimestamp(val);
} else
this.mValue = val;
this.set(this.mValue);
}
TimeType.prototype.set = function(val) {
;
; 
if (val < 0) {
val = 0;
this.valueAdjusted = true;
}
else if (val > 2147483647) {
val = 2147483647;
this.valueAdjusted = true;
}
this.mValue = val;
}
TimeType.prototype.type = 7;
TimeType.prototype.isNull = false;
TimeType.prototype.valueAdjusted = false;
TimeType.prototype.toInteger = function() {
;
return this.mValue;
}
TimeType.prototype.toDecimal = function() {
;
return new IntegerType(this.toInteger()).toDecimal();
}
TimeType.prototype.toReal = function() {
;
return this.mValue;
}
TimeType.prototype.DisplayFormat=0;
TimeType.prototype.setDisplayFormat = function(a) {
;
this.DisplayFormat = a;
}
TimeType.prototype.getDisplayFormat = function() {
return this.DisplayFormat;
}
TimeType.prototype.toString = function (a) {
;
if (arguments.length<1) {
a = this.DisplayFormat;
}
return TimeType.getDateTimeString(this.mValue, a);
}
TimeType.prototype.toPrimitive = function () {
;
return this.mValue.toString();
}
TimeType.prototype.toTOD = function () {
;
var dateObj = new ARDate();
dateObj.STimestamp(this.mValue);
return new TODType(dateObj.format(localeInfo.timeFormatPattern, 7));
}
TimeType.prototype.toDate = function () {
;
var dateObj = new ARDate();
dateObj.STimestamp(this.mValue);
return new DateType(dateObj.format(localeInfo.dateFormatPattern, 13));
}
TimeType.prototype.ADD = function(a, b) {
;
;
;
if (((((1<<7|1<<13|1<<14) & (1<<a.type)) | (1<<13 & (1<<a.type)) | (1<<14 & (1<<a.type))) && b instanceof CharType) ||
((((1<<7|1<<13|1<<14) & (1<<b.type)) | (1<<13 & (1<<b.type)) | (1<<14 & (1<<b.type))) && a instanceof CharType) ) {
return new CharType(a.toString() + b.toString());
}
if (a instanceof CurrencyType ||
(!(((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) && (!(((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))||(1<<12 & (1<<b.type))))) {
CurWFC.status(9339);
return;
}
;
if (((1<<4|1<<5) & (1<<a.type)))
a = a.toTime();
if (((1<<4|1<<5) & (1<<b.type)))
b = b.toTime();
if (a instanceof DateKWType || b instanceof DateKWType || a instanceof TODKWType || b instanceof TODKWType)
this.set(a.toInteger() + b.toInteger());
else if (a instanceof DateType || b instanceof DateType) {
var c = new DateType(a.toInteger() + b.toInteger());
this.set(c.toTime().toInteger());
}
else if (a instanceof TODType || b instanceof TODType) {
var c = new TODType(a.toInteger() + b.toInteger());
this.set(c.toTime().toInteger());
}
else if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.ADD(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType || a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new DecimalType(null);
this.set(c.ADD(a, b).toInteger());
}
else
this.set(a.toInteger() + b.toInteger());
return this;
}
TimeType.prototype.SUB = function(a, b) {
;
;
;
if (((((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) || (1<<13 & (1<<a.type)) || (1<<14 & (1<<a.type))) && !(((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))) ||
(!(((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) && (1<<12 & (1<<b.type))) ) {
CurWFC.status(9339);
return;
}
if (((1<<4|1<<5) & (1<<a.type)))
a = a.toTime();
if (((1<<4|1<<5) & (1<<b.type)))
b = b.toTime();
if (a instanceof DateKWType || b instanceof DateKWType || a instanceof TODKWType || b instanceof TODKWType)
this.set(a.toInteger() - b.toInteger());
else if (a instanceof DateType) {
var c = new DateType(a.toInteger() - b.toInteger());
this.set(c.toTime().toInteger());
}
else if (a instanceof TODType) {
var c = new TODType(a.toInteger() - b.toInteger());
this.set(c.toTime().toInteger());
}
else if (a instanceof RealType || (!(a instanceof TimeType) && (b instanceof RealType))) {
var c = new RealType(0);
this.set(c.SUB(a, b).toInteger());
}
else if ((a instanceof DecimalType || (!(a instanceof TimeType) && (b instanceof DecimalType))) ||
(a instanceof CurrencyType || (!(a instanceof TimeType) && (b instanceof CurrencyType)))){
var c = new DecimalType(null);
this.set(c.SUB(a, b).toInteger());
}
else {
if (a instanceof CharType)
a = a.toTime();
this.set(a.toInteger() - b.toInteger());
}
return this;
}
TimeType.prototype.MOD = function(a, b) {
;
;
;
if (!(((1<<2 & (1<<a.type))||(1<<0 & (1<<a.type))) && ((((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))))) {
CurWFC.status(9339);
return;
}
if ((a instanceof IntegerType || a instanceof NullType) && (b instanceof IntegerType || b instanceof NullType)) {
if (b.toInteger() == 0) {
CurWFC.status(9306);
return;
}
this.set(a.toInteger() % b.toInteger());
}
else	
this.set(0);
return this;
}
TimeType.prototype.MUL = function(a, b) {
;
;
;
if (!((((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) || ((1<<7|1<<13|1<<14) & (1<<a.type))) || 
!((((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type))) || ((1<<7|1<<13|1<<14) & (1<<b.type)))) {
CurWFC.status(9339);
return;
}
;
if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.MUL(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType || a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new DecimalType(null);
this.set(c.MUL(a, b).toInteger());
}
else
this.set(a.toInteger() * b.toInteger());
return this;
}
TimeType.prototype.DIV = function(a, b) {
;
;
;
if (!(((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) || !(((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))) {
CurWFC.status(9339);
return;
}
;
if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.DIV(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType || a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new DecimalType(null);
this.set(c.DIV(a, b).toInteger());
}
else {
if (b.toInteger() == 0) {
CurWFC.status(9306);
return;
}
this.set(Math.floor(a.toInteger() / b.toInteger()));
}
return this;
}
TimeType.prototype.EQ = function(a) {
;
;
if (a.type == 4)
a = a.toTime();
if (a.isNull)
return false;
if ((a.type != 7) && (a.type != 2)
&& (a.type != 14) && (a.type != 13))
return false;
;
return this.mValue == a.toTime().toInteger();
}
TimeType.prototype.NE = function(a) {
;
return !this.EQ(a)
}
TimeType.prototype.GT = function(a) {
;
;
if (a.isNull)
return false;
if (!(a instanceof TimeType) && !(a instanceof IntegerType)
&& !(a instanceof TODType) && !(a instanceof DateType))
return false;
;
return this.mValue > a.toTime().toInteger();
}
TimeType.prototype.GE = function(a) {
;
;
if (a.isNull)
return false;
if (!(a instanceof TimeType) && !(a instanceof IntegerType)
&& !(a instanceof TODType) && !(a instanceof DateType))
return false;
;
return this.mValue >= a.toTime().toInteger();
}
TimeType.prototype.LT = function(a) {
if (a.isNull)
return false;
;
return !this.GE(a)
}
TimeType.prototype.LE = function(a) {
if (a.isNull)
return false;
;
return !this.GT(a)
}
TimeType.getTimestamp = function(strVal) {
var v = -1; 
var dateObj = ARDate.parseDateTime(strVal);
if (dateObj == null)
dateObj = ARDate.parseDate(strVal);
if (dateObj != null) {
v = dateObj.GTimestamp();
if (v >= 0 && v <= 2147483647)
return v;
}
v = LCDecimalToEn_US(strVal, false);
if (v == 0) 
v = parseFloat(strVal);
v = parseInt(v)
if (isNaN(v))
v = -1;
return v;
}
TimeType.getDateTimeString = function(ts, ds) {
;
var v = parseFloat(ts);
v = parseInt(v)
if (isNaN(v))
return "";
if (v < 0) v=0;
if (v > 2147483647) v=2147483647;
var dateObj = new ARDate();
dateObj.STimestamp(v);
var pattern;
if (ds == 2)
pattern = localeInfo.dateFormatPattern;
else if (ds == 1)
pattern = localeInfo.timeFormatPattern;
else
pattern = localeInfo.dateFormatPattern + " " + localeInfo.timeFormatPattern;
return dateObj.format(pattern, 7);
}

DateType.prototype=new Datatype(); DateType.prototype.constructor=DateType; DateType.superclass=Datatype.prototype;;
DatatypeFactories[13] = function(val) {
if (typeof val == "object" && val.type == 14 && !(val instanceof TODKWType))
return Null;
return new DateType(val);
}
function DateType(a) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a);
}
DateType.prototype.init = function(val) {
;
;
if (val instanceof Datatype) {
;
this.mValue = val.toDate().toInteger();
} else if (typeof val == "string") {
if (val.isNumeric())
this.mValue = parseInt(val, 10);
else
this.mValue = DateType.getDays(val);
} else
this.mValue = val;
this.set(this.mValue);
}
DateType.prototype.set = function(val) {
;
; 
if (val < 0) {
val = 0;
this.valueAdjusted = true;
}
else if (val > 5373120) {
val = 5373120;
this.valueAdjusted = true;
}
this.mValue = val;
}
DateType.prototype.type = 13;
DateType.prototype.isNull = false;
DateType.prototype.valueAdjusted = false;
DateType.prototype.toString = function() {
;
return DateType.getDateString(this.mValue);
}
DateType.prototype.toInteger = function() {
;
return this.mValue;
}
DateType.prototype.toDecimal = function() {
;
return new IntegerType(this.toInteger()).toDecimal();
}
DateType.prototype.toReal = function() {
;
return this.mValue;
}
DateType.prototype.toTOD = function() {
return Null;
}
DateType.prototype.toTime = function() {
var ardate = ARDate.getDateObject(this.mValue);
var timestamp = ardate.GTimestamp();
if (timestamp < 0)
timestamp = 0;
return new TimeType(timestamp);
}
DateType.prototype.toPrimitive = function () {
;
return this.mValue.toString();
}
DateType.prototype.ADD = function(a, b) {
;
;
;
if (a instanceof CurrencyType || a instanceof TODType || b instanceof TODType ||
(!(((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) && (!(((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))||(1<<12 & (1<<b.type))))) {
CurWFC.status(9339);
return;
}
;
if (((1<<4|1<<5) & (1<<a.type)))
a = a.toDate();
if (((1<<4|1<<5) & (1<<b.type)))
b = b.toDate();
if (a instanceof TimeType || b instanceof TimeType) {
var c = new TimeType(a.toInteger() + b.toInteger());
this.set(c.toDate().toInteger());
}
else if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.ADD(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType || a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new DecimalType(null);
this.set(c.ADD(a, b).toInteger());
}
else
this.set(a.toInteger() + b.toInteger());
return this;
}
DateType.prototype.SUB = function(a, b) {
;
;
;
if ((((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) && !(((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))) ||
(!(((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) && (1<<12 & (1<<b.type))) ||
(1<<14 & (1<<a.type)) || (1<<14 & (1<<b.type)) ||
(((1<<7|1<<13|1<<14) & (1<<a.type)) && ((1<<7|1<<13|1<<14) & (1<<b.type)))) {
CurWFC.status(9339);
return;
}
;
if (((1<<4|1<<5) & (1<<a.type)))
a = a.toDate();
if (((1<<4|1<<5) & (1<<b.type)))
b = b.toDate();
if (a instanceof TimeType) {
if (b instanceof TimeType) 
this.set(a.toDate().toInteger() - b.toDate().toInteger());
else {
var c = new TimeType(a.toInteger() - b.toInteger());
this.set(c.toDate().toInteger());
}
}
else if (a instanceof RealType || (!(a instanceof DateType) && (b instanceof RealType))) {
var c = new RealType(0);
this.set(c.SUB(a, b).toInteger());
}
else if ((a instanceof DecimalType || (!(a instanceof DateType) && (b instanceof DecimalType))) ||
(a instanceof CurrencyType || (!(a instanceof DateType) && (b instanceof CurrencyType)))){
var c = new DecimalType(null);
this.set(c.SUB(a, b).toInteger());
}
else {
if (a instanceof CharType)
a = a.toDate();
this.set(a.toInteger() - b.toInteger());
}
return this;
}
DateType.prototype.MOD = function(a, b) {
;
;
;
if (!(((1<<2 & (1<<a.type))||(1<<0 & (1<<a.type))) && ((((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))))) {
CurWFC.status(9339);
return;
}
if ((a instanceof IntegerType || a instanceof NullType) && (b instanceof IntegerType || b instanceof NullType)) {
if (b.toInteger() == 0) {
CurWFC.status(9306);
return;
}
this.set(a.toInteger() % b.toInteger());
}
else	
this.set(0);
return this;
}
DateType.prototype.MUL = function(a, b) {
;
;
;
if (!(((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) || !(((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))) {
CurWFC.status(9339);
return;
}
;
if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.MUL(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType || a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new DecimalType(null);
this.set(c.MUL(a, b).toInteger());
}
else
this.set(a.toInteger() * b.toInteger());
return this;
}
DateType.prototype.DIV = function(a, b) {
;
;
;
if (!(((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) || !(((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))) {
CurWFC.status(9339);
return;
}
;
if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.DIV(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType || a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new DecimalType(null);
this.set(c.DIV(a, b).toInteger());
}
else {
if (b.toInteger() == 0) {
CurWFC.status(9306);
return;
}
this.set(Math.floor(a.toInteger() / b.toInteger()));
}
return this;
}
DateType.prototype.EQ = function(a) {
;
;
if (a.type == 4)
a = a.toDate();
if (a.isNull)
return false;
if ((a.type != 7) && (a.type != 2)
&& (a.type != 14) && (a.type != 13))
return false;
;
return this.mValue == a.toDate().toInteger();
}
DateType.prototype.NE = function(a) {
;
return !this.EQ(a)
}
DateType.prototype.GT = function(a) {
;
;
if (a.isNull)
return false;
if (!(a instanceof TimeType) && !(a instanceof IntegerType)
&& !(a instanceof TODType) && !(a instanceof DateType))
return false;
;
return this.mValue > a.toDate().toInteger();
}
DateType.prototype.GE = function(a) {
;
;
if (a.isNull)
return false;
if (!(a instanceof TimeType) && !(a instanceof IntegerType)
&& !(a instanceof TODType) && !(a instanceof DateType))
return false;
;
return this.mValue >= a.toDate().toInteger();
}
DateType.prototype.LT = function(a) {
if (a.isNull)
return false;
;
return !this.GE(a)
}
DateType.prototype.LE = function(a) {
if (a.isNull)
return false;
;
return !this.GT(a)
}
DateType.prototype.ADDWEEKS = function(a) {
;
return this.ADD(this, new IntegerType(7 * a.toInteger()));
}
DateType.prototype.ADDMONTHS = function(a) {
;
var ardate = ARDate.getDateObject(this.toInteger());
a = a.toInteger();
var years;
if (a < 0)
years = ardate.GYear() - Math.floor(-a/12);
else
years = Math.floor(a/12) + ardate.GYear();
var months = (a%12) + ardate.GMonth();
if (months > 12) {
years += 1;
months = (months%12);
} else if (months < 1) {
years -= 1;
months += 12;
}
var days = ardate.GDate();
var lastDayInMonth = ARDate.getDaysInMonth(months, years);
if (days > lastDayInMonth) 
days = lastDayInMonth;
ardate = new ARDate(years, months, days, 
ardate.GHour(), ardate.GMinute(), ardate.GSecond());
this.set(ardate.GDays());
return this;
}
DateType.prototype.ADDYEARS = function(a) {
;
var ardate = ARDate.getDateObject(this.toInteger());
ardate = new ARDate(ardate.GYear() + a.toInteger(), ardate.GMonth(),
ardate.GDate(), ardate.GHour(), ardate.GMinute(), ardate.GSecond());
this.set(ardate.GDays());
return this;
}
DateType.getDays = function(strVal) {
var v = -1; 
var dateObj = ARDate.parseDate(strVal);
if (dateObj != null) {
v = dateObj.GDays();
if (v >= 0 && v <= 5373120)
return v;
}
var timeObj = ARDate.parseTime(strVal);
if (timeObj != null) {
return (new DateKWType()).mValue;
}
v = LCDecimalToEn_US(strVal, false);
if (v == 0) 
v = parseFloat(strVal);
v = parseInt(v)
if (isNaN(v))
v = -1;
return v;
}
DateType.getDateString = function(days) {
;
var v = parseFloat(days);
v = parseInt(v)
if (isNaN(v))
return "";
if (v < 0) v=0;
if (v > 5373120) v=5373120;
var dateObj = new ARDate();
dateObj.SDays(v);
return dateObj.format(localeInfo.dateFormatPattern, 13);
}

TODType.prototype=new Datatype(); TODType.prototype.constructor=TODType; TODType.superclass=Datatype.prototype;;
DatatypeFactories[14] = function(val) {
if (typeof val == "object" && val.type == 13 && !(val instanceof DateKWType))
return Null;
return new TODType(val);
}
function TODType(a) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a);
}
TODType.prototype.init = function(val) {
;
;
if (val instanceof Datatype) {
;
this.mValue = val.toTOD().toInteger();
} else if (typeof val == "string") {
this.mValue = (val.isNumeric()) ? parseInt(val, 10) : TODType.convertStringToTime(val);
} else
this.mValue = val;
this.set(this.mValue);
}
TODType.prototype.set = function(val) {
;
; 
if (val < 0) {
val = 0;
this.valueAdjusted = true;
}
else if (val > 86399) {
val = 86399;
this.valueAdjusted = true;
}
this.mValue = val;
}
TODType.prototype.type = 14;
TODType.prototype.isNull = false;
TODType.prototype.valueAdjusted = false;
TODType.prototype.getTimeObj = function() {
;
var hr = Math.floor(this.mValue / 3600);
var min = Math.floor((this.mValue - (hr * 3600)) / 60);
var sec = Math.floor((this.mValue - (hr * 3600)) - (min * 60));
return {h:hr, m:min, s:sec};
}
TODType.prototype.toTime = function() {
;
return new TimeType(this.toString());
}
TODType.prototype.toDate = function() {
return Null;
}
TODType.prototype.toInteger = function() {
;
return this.mValue;
}
TODType.prototype.toDecimal = function() {
;
return new IntegerType(this.toInteger()).toDecimal();
}
TODType.prototype.toReal = function() {
;
return this.mValue;
}
TODType.prototype.toString = function () {
;
return TODType.convertNumberToTime(this.mValue);
}
TODType.prototype.toPrimitive = function () {
;
return this.mValue.toString();
}
TODType.prototype.ADD = function(a, b) {
;
;
;
if (a instanceof CurrencyType || a instanceof DateType || b instanceof DateType ||
(!(((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) && (!(((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))||(1<<12 & (1<<b.type))))) {
CurWFC.status(9339);
return;
}
; 
if (((1<<4|1<<5) & (1<<a.type)))
a = a.toTOD();
if (((1<<4|1<<5) & (1<<b.type)))
b = b.toTOD();
if (a instanceof TimeType || b instanceof TimeType) {
var c = new TimeType(a.toInteger() + b.toInteger());
this.set(c.toTOD().toInteger());
}
else if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.ADD(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType || a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new DecimalType(null);
this.set(c.ADD(a, b).toInteger());
}
else
this.set(a.toInteger() + b.toInteger());
return this;
}
TODType.prototype.SUB = function(a, b) {
;
;
;
if ((((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) && !(((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))) ||
(!(((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) && (1<<12 & (1<<b.type))) ||
((1<<13 & (1<<a.type)) || (1<<13 & (1<<b.type))) ||
(((1<<7|1<<13|1<<14) & (1<<a.type)) && ((1<<7|1<<13|1<<14) & (1<<b.type)))) {
CurWFC.status(9339);
return;
}
;
if (((1<<4|1<<5) & (1<<a.type)))
a = a.toTOD();
if (((1<<4|1<<5) & (1<<b.type)))
b = b.toTOD();
if (a instanceof TimeType) {
if (b instanceof TimeType)
this.set(a.toTOD().toInteger() - b.toTOD().toInteger());
else {
var c = new TimeType(a.toInteger() - b.toInteger());
this.set(c.toTOD().toInteger());
}
}
else if (a instanceof RealType || (!(a instanceof TODType) && (b instanceof RealType))) {
var c = new RealType(0);
this.set(c.SUB(a, b).toInteger());
}
else if ((a instanceof DecimalType || (!(a instanceof TODType) && (b instanceof DecimalType))) || 
(a instanceof CurrencyType || (!(a instanceof TODType) && (b instanceof CurrencyType)))){
var c = new DecimalType(null);
this.set(c.SUB(a, b).toInteger());
}
else {
if (a instanceof CharType)
a = a.toTOD();
this.set(a.toInteger() - b.toInteger());
}
return this;
}
TODType.prototype.MOD = function(a, b) {
;
;
;
if (!(((1<<2 & (1<<a.type))||(1<<0 & (1<<a.type))) && ((((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))))) {
CurWFC.status(9339);
return;
}
if ((a instanceof IntegerType || a instanceof NullType) && (b instanceof IntegerType || b instanceof NullType)) {
if (b.toInteger() == 0) {
CurWFC.status(9306);
return;
}
this.set(a.toInteger() % b.toInteger());
}
else	
this.set(0);
return this;
}
TODType.prototype.MUL = function(a, b) {
;
;
;
if (!(((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) || !(((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))) {
CurWFC.status(9339);
return;
}
;
if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.MUL(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType || a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new DecimalType(null);
this.set(c.MUL(a, b).toInteger());
}
else
this.set(a.toInteger() * b.toInteger());
return this;
}
TODType.prototype.DIV = function(a, b) {
;
;
;
if (!(((1<<2|1<<3|1<<10|1<<12) & (1<<a.type)) | (1<<0 & (1<<a.type))) || !(((1<<2|1<<3|1<<10|1<<12) & (1<<b.type)) | (1<<0 & (1<<b.type)))) {
CurWFC.status(9339);
return;
}
;
if (a instanceof RealType || b instanceof RealType) {
var c = new RealType(0);
this.set(c.DIV(a, b).toInteger());
}
else if (a instanceof DecimalType || b instanceof DecimalType || a instanceof CurrencyType || b instanceof CurrencyType) {
var c = new DecimalType(null);
this.set(c.DIV(a, b).toInteger());
}
else {
if (b.toInteger() == 0) {
CurWFC.status(9306);
return;
}
this.set(Math.floor(a.toInteger() / b.toInteger()));
}
return this;
}
TODType.prototype.EQ = function(a) {
;
;
if (a.type == 4)
a = a.toTOD(a);
if (a.isNull)
return false;
if ((a.type != 14) && (a.type != 2))
return false;
;
return this.mValue == a.toInteger();
}
TODType.prototype.NE = function(a) {
;
return !this.EQ(a)
}
TODType.prototype.GT = function(a) {
;
;
if (a.isNull)
return false;
if (!(a instanceof TODType) && !(a instanceof IntegerType))
return false;
;
return this.mValue > a.toInteger();
}
TODType.prototype.GE = function(a) {
;
;
if (a.isNull)
return false;
if (!(a instanceof TODType) && !(a instanceof IntegerType))
return false;
;
return this.mValue >= a.toInteger();
}
TODType.prototype.LT = function(a) {
if (a.isNull)
return false;
;
return !this.GE(a)
}
TODType.prototype.LE = function(a) {
if (a.isNull)
return false;
;
return !this.GT(a)
}
TODType.convertStringToTime = function(strVal) {
var v = -1; 
var dateObj = ARDate.parseTime(strVal);
if (dateObj != null) {
v = dateObj.GTimeOfDay();
}
else {
v = parseFloat(strVal);
v = parseInt(v)
if (isNaN(v))
v = -1;
}
return v;
}
TODType.convertNumberToTime = function(intVal) {
var v = parseFloat(intVal);
v = parseInt(intVal)
if (isNaN(v))
return "";
if (v < 0) v=0;
if (v > 86399) v=86399;
var dateObj = new ARDate();
var s = v % 60;
dateObj.SSecond(s);
dateObj.SMinute(((v - s) % 3600)/60);
dateObj.SHour(Math.floor(v/3600));
return dateObj.format(localeInfo.timeFormatPattern, 14);
}
TODType.convertToTime = function(hr, min, sec, meridiem) { 
var sep = localeInfo.timeSeparator;
return hr + sep + min + sep + sec; 
}

EnumType.prototype=new Datatype(); EnumType.prototype.constructor=EnumType; EnumType.superclass=Datatype.prototype;;
DatatypeFactories[6] = function(val, arg) {
if (typeof arg != "undefined" && "l" in arg) 
return new EnumType(val, arg.l);
if (val instanceof Datatype) {
if (val.type != 4) {
return new EnumType(val);
}
val = val.toString();
}
var re = /^([0-9]+) (.*)$/
if (re.test(val))
return new EnumType(val.replace(re, "$1"), val.replace(re, "$2"));
if (typeof val == "string") {
if (typeof arg != "undefined" && "el" in arg) { 
var el = arg.el;
for (i in el) {
if (val == el[i])
return new EnumType(i, val);
}
}
var f = parseFloat(val);
val = parseInt(f)
if (isNaN(val))
return Null;
}
return new EnumType(val);
}
function EnumType(a, b) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a, b);
}
EnumType.prototype.init = function(idx, label) {
;
;
;
if (idx instanceof Datatype) {
;
this.mValue = idx.toInteger();
} else if (typeof idx == "string") {
var f = parseFloat(idx);
this.mValue = parseInt(f)
if (isNaN(this.mValue))
this.mValue = 0;
} else
this.mValue = idx;
;
this.mLabel = label;
}
EnumType.prototype.type = 6;
EnumType.prototype.isNull = false;
EnumType.prototype.toInteger = function() {
;
return this.mValue;
}
EnumType.prototype.toReal = function() {
;
return this.mValue;
}
EnumType.prototype.toDecimal = function() {
;
return new BigDecimal("" + this.mValue);
}
EnumType.prototype.toString = function () {
;
if (typeof this.mLabel == "undefined")
return this.mValue.toString();
;
return this.mLabel.HTMLDecode();
}
EnumType.prototype.toTime = function() {
if (this.toString().isNumeric() || ARDate.parseDateTime(this.toString()) != null)
return new TimeType(this.toString());
else
return new TimeType(this.toInteger());
}
EnumType.prototype.toDate = function() {
if (this.toString().isNumeric() || ARDate.parseDate(this.toString()) != null)
return new DateType(this.toString());
else
return new DateType(this.toInteger());
}
EnumType.prototype.toTOD = function() {
if (this.toString().isNumeric() || ARDate.parseTime(this.toString()) != null)
return new TODType(this.toString());
else
return new TODType(this.toInteger());
}
EnumType.prototype.toPrimitive = function () {
;
var label;
if (typeof this.mLabel == "undefined")
label = this.mValue;
else
label = this.mLabel.HTMLDecode();
return this.mValue + " " + label;
}
EnumType.prototype.args = function () {
if (typeof this.mLabel == "undefined")
return {};
else
return {l : this.mLabel.HTMLDecode()};
}
EnumType.prototype.EQ = function(a) {
;
;
if (a.isNull)
return false;
;
if (a.type == 4) {
var str = a.toString();
if (this.mLabel.HTMLDecode() == str)
return true;
else
return false;
}
return this.mValue == a.toInteger();
}
EnumType.prototype.NE = function(a) {
;
return !this.EQ(a)
}
EnumType.prototype.GT = function(a) {
;
;
;
return this.mValue > a.toInteger();
}
EnumType.prototype.GE = function(a) {
;
;
;
return this.mValue >= a.toInteger();
}
EnumType.prototype.LT = function(a) {
;
return !this.GE(a)
}
EnumType.prototype.LE = function(a) {
;
return !this.GT(a)
}

StatusHistoryType.prototype=new CharType(); StatusHistoryType.prototype.constructor=StatusHistoryType; StatusHistoryType.superclass=CharType.prototype;;
function StatusHistoryType(a) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a);
}
StatusHistoryType.prototype.part = function(enumidx, timeoruser) {
;
;
;
var hist = this.GetArray();
if (enumidx >= 0 && enumidx < hist.length) {
if (timeoruser == 2)
return (hist[enumidx].t == null) ? Null : new TimeType(hist[enumidx].t);
else
return (hist[enumidx].u == null) ? Null : new CharType(hist[enumidx].u);
}
return Null;
}
StatusHistoryType.prototype.compound = function(args) { 
;
if (args.length != 2)
return null;
;
var tag = args[0].toUpperCase();
if (tag == "TIME")
tag = 2;
else if (tag == "USER")
tag = 1;
else if (tag.isDigits())
tag = parseInt(tag);
else
return null;
if (tag != 1 && tag != 2)
return null;
;
;
var idx;
if (args[1].isDigits()) {
idx = parseInt(args[1]);
} else {
for (idx = 0; idx < StatusEnumInfo.length; ++idx)
if (args[1] == StatusEnumInfo[idx].m)
break;
}
;
if (idx < 0 || idx >= StatusEnumInfo.length)
return null;
return this.part(idx, tag);
}
StatusHistoryType.prototype.GetArray = function() {
if (this.mValue == null)
return [];
var parts = this.mValue.split('\03');
var hist = new Array();
;
for (var i = 0; i < StatusEnumInfo.length; ++i) {
if (parts[i]) {
var values = parts[i].split('\04');
if (values.length == 2) {
hist.push({t:values[0], u:values[1]});
continue;
}
}
hist.push({t:null, u:null});
}
return hist;
}
StatusHistoryType.prototype.GetTable = function() {
;
var hist = this.GetArray();
var table = [ [ getLocalizedMessage("Status"), getLocalizedMessage("Modified Time"), getLocalizedMessage("Modified By") ] ];
for (var i = 0; i < hist.length; ++i) {
table[i+1] = [ StatusEnumInfo[i].l, (hist[i].t == null) ? "" : new TimeType(hist[i].t).toString(), (hist[i].u == null) ? "" : hist[i].u ];
}
return table;
}
StatusHistoryType.prototype.toReal = function() {
return new RealType(this.toInteger()).toReal();
}
StatusHistoryType.prototype.toDecimal = function() {
return new IntegerType(this.toInteger()).toDecimal();
}

AttachmentType.prototype=new Datatype(); AttachmentType.prototype.constructor=AttachmentType; AttachmentType.superclass=Datatype.prototype;;
DatatypeFactories[11] = function(val, arg) {
return new AttachmentType(val);
}
function AttachmentType(val) {
if(arguments.length)
this.init(val);
}
AttachmentType.NO_SCREEN_TYPE_PAT = /^1\/0/;
AttachmentType.WITH_SCREEN_KEY_PREFIX = "1/1"; 
AttachmentType.prototype.init = function(val) {
AttachmentType.superclass.init.call(this);   
LogWrite("AttachmentType(" + val + ")");
this.mOrigSize = this.mFileName = "";
if (val instanceof AttachmentType) {
this.mValue = val.mValue;
this.mOrigSize = val.mOrigSize;
this.mFileName = val.mFileName;
this.mDataKey = val.mDataKey;
} else if (val instanceof Datatype) {
var att = val.toAttach();
this.mValue = att.mValue;
this.mOrigSize = att.mOrigSize;
this.mFileName = att.mFileName;
this.mDataKey = att.mDataKey;
} else if (typeof val == "string") {
var jj = val.indexOf("/");
;
var len = parseInt(val.substring(0, jj));
;
this.mDataKey = val.substr(++jj, len);
jj += len;
var kk = val.indexOf("/", jj);
len = parseInt(val.substring(jj, kk));
;
this.mOrigSize = val.substr(++kk, len);
jj = kk+len;
kk = val.indexOf("/", jj);
len = parseInt(val.substring(jj, kk));
;
this.mFileName = val.substr(++kk, len);
if (this.mDataKey.charAt(2) == "0") {
this.mDataKey = this.mDataKey.replace(
AttachmentType.NO_SCREEN_TYPE_PAT, AttachmentType.WITH_SCREEN_KEY_PREFIX);
this.mDataKey += window.name.length + "/" + window.name;
this.mValue = this.mDataKey.length + "/" + this.mDataKey;
this.mValue += this.mOrigSize.length + "/" + this.mOrigSize;
this.mValue += this.mFileName.length + "/" + this.mFileName;
} else {
this.mValue = val;
}
} else {
;
}
}
AttachmentType.prototype.toChar = function() {
return this.toString();
}
AttachmentType.prototype.toString = function() {
return this.mFileName;
}
AttachmentType.prototype.toAttach = function() {
return this;
}
AttachmentType.prototype.toURL = function() {
return new CharType(JAttachment.getURL(this.mDataKey));
}
AttachmentType.prototype.toPrimitive = function() {
return this.mValue;
}
AttachmentType.prototype.EQ = function(a) {
;
;
if (a.isNull) {
return false;
}
var lhs = this.mFileName;
var rhs = a.toChar();
;
if (lhs == null || rhs == null) {
return (lhs == null && rhs == null)
}
return lhs.localeCompare(rhs) == 0;
}
AttachmentType.prototype.NE = function(a) {
return !this.EQ(a)
}
AttachmentType.prototype.GT = function(a) {
;
;
var lhs = this.mFileName;
var rhs = a.toChar();
;
if (lhs == null || rhs == null) {
return (lhs == null && rhs == null)
}
return lhs.localeCompare(rhs) > 0;
}
AttachmentType.prototype.LT = function(a) {
;
;
var lhs = this.mFileName;
var rhs = a.toChar();
;
if (lhs == null || rhs == null) {
return (lhs == null && rhs == null)
}
return lhs.localeCompare(rhs) < 0;
}
AttachmentType.prototype.GE = function(a) {
;
;
var lhs = this.mFileName;
var rhs = a.toChar();
;
if (lhs == null || rhs == null) {
return (lhs == null && rhs == null)
}
return lhs.localeCompare(rhs) >= 0;
}
AttachmentType.prototype.LE = function(a) {
;
;
var lhs = this.mFileName;
var rhs = a.toChar();
;
if (lhs == null || rhs == null) {
return (lhs == null && rhs == null)
}
return lhs.localeCompare(rhs) <= 0;
}
AttachmentType.prototype.LIKE = function(a) {
;
;
var lhs = this.mFileName;
var rhs = a.toChar();
if (lhs == null || rhs == null) {
return false;
}
rhs = rhs.replace(/(%)|(_)|(\[.*\])|([.$^+?*{()\\\/|[\]])/gm, function (sub, p1, p2, p3, p4) {
if (p1) return ".*";
else if (p2) return ".";
else if (p3) return p3;
else if (p4) return "\\" + p4;
});
;
try {
var re = new RegExp("^" + rhs + "$");
} catch (exception) {
return false;
}
return lhs.match(re) != null;
}
AttachmentType.prototype.type = 11;
AttachmentType.prototype.isNull = false;
AttachmentType.getKey=function(cmd, fid, emptyIds) {
;
;
var buf=[];
var eid = F(1).G();
;
var keyArgs = ["1", ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), eid.IsNull ? "" : eid.toString(), fid + "", window.name];
for (var ii in keyArgs) {
buf.push(keyArgs[ii].length);
buf.push("/");
buf.push(keyArgs[ii]);
}
var key = buf.join("");
var keyBuf=[];
keyBuf.push(cmd.length);
keyBuf.push("/");
keyBuf.push(cmd);
keyBuf.push(key.length);
keyBuf.push("/");
keyBuf.push(key);
if (cmd == "4" && emptyIds) {
var es = emptyIds.length + "";
keyBuf.push(es.length);
keyBuf.push("/");
keyBuf.push(es);
for (var ii in emptyIds) {
var fid = emptyIds[ii];
;
var fids = fid+"";
keyBuf.push(fids.length);
keyBuf.push("/");
keyBuf.push(fids);
}
}
return keyBuf.join("");
}
AttachmentType.getKeyForCurrentField=function(fid) {
;
return AttachmentType.getKey("3", fid);
}
AttachmentType.getKeyForPoolField=function(pid, fids) {
;
return AttachmentType.getKey("4", pid, fids);
}
AttachmentType.prototype.toCurrency = function(p) {
return new CurrencyType(this.toString(), p, true);
}

Field.prototype.constructor=Field;;
var Fields={};
var FieldListInfo={};
var DOMFieldFactories={};
var JFieldFactories={};
function Field_Init(start) {
if (!start)
start=document.body;
var n=start;
while(1) {
var nid,descend=true;
if(n.nodeType==1&&(nid=n.getAttribute("ARID"))) {
var nf = DOMFieldFactories[n.getAttribute("ARType")](parseInt(nid),n);
if (nf.mID != 1020 && typeof FieldListInfo.firstField == "undefined") {
FieldListInfo.firstField = nf;
}
FieldListInfo.lastField = nf;
descend=nf.mContainFields; 
;
}
if(n.firstChild&&descend)
n=n.firstChild;
else {
while(!n.nextSibling) {
n=n.parentNode;
if(n==start) {
return;
}
}
n=n.nextSibling;
}
}
}
function Field_FromElement(elem) {
var stop=document.body;
while(elem&&elem!=stop) {    
var eid=elem.getAttribute("ARID");
if(eid)
return Fields[eid];
elem=elem.parentNode;
}
return null;
}
Field.prototype.mCFCache=new CFCacheObj();
function CFCacheObj(oo) {
if(arguments.length) {
for(var p in oo)
this[p]=oo[p];
}
}
CFCacheObj.prototype.a=2;
CFCacheObj.prototype.l="";
CFCacheObj.prototype.c="inherit";
CFCacheObj.prototype.f="f1";
CFCacheObj.prototype.v=true;
CFCacheObj.prototype.m=null;
function Field(id,obj) {
if(arguments.length)
this.init(id,obj);
}
Field.prototype.init=function(id,obj) {
this.mID=id;
this.mObj=obj;
if(!this.mDOMField&&obj!=null&&(!("v" in obj)))
this.mObj.v=Null;
;
;
if(id==0)
return;
this.mCFCache=new CFCacheObj(Defaults[id]);
Fields[id]=this;
if (this.mID>=1000000&&this.mID<=1999999)
this.ReadGlobalData();
}
Field.prototype.SaveGlobalData = function() {
if (this.mID>=1000000&&this.mID<=1999999) {
this.SetCookieValue();
}
}
Field.prototype.GetCookieValue = function() {
var vals = DeserializeGlobals("GF");
if (vals != null && this.mID in vals)
return Datatype_Factory(vals[this.mID]);
return null;
}
Field.prototype.SetCookieValue = function() {
var vals = DeserializeGlobals("GF");
vals[this.mID] = this.SerializeVal();
SerializeGlobals("GF",vals);
}
Field.prototype.ReadGlobalData = function() {
if (this.mID>=1000000&&this.mID<=1999999) {
if (!("mDCF" in this)) 
this.mDCF=(this.mDOMField)?(this.mObj.getAttribute("ARDCF") != null):((this.mObj&&"dcf" in this.mObj)?(this.mObj.dcf==1):false);
var val = this.GetCookieValue();
if(val!=null) {
if (val.type != this.G().type || val.toPrimitive() != this.G().toPrimitive() ||
(this.mDOMField && this.mHaveStoredData &&  val.toString() != this.GetScreenValAsPrimitive()))
this.DoSet(val); 
}
}
}
Field.prototype.SerializeVal=function() {
var val = this.G();
if ("args" in val)
return {t : val.type , v : val.toPrimitive(), a : val.args()};
else
return {t : val.type , v : val.toPrimitive()};
}
Field.prototype.DeserializeVal=function(valObj) {
this.S(Datatype_Factory(valObj));
}
Field.prototype.G=function() {
return Null;
}
Field.prototype.IsNullKeyword=function() {
if ("GetScreenValAsPrimitive" in this) {
var primVal = this.GetScreenValAsPrimitive();
if (primVal != "") {
var hasKeywords={hasKeyword:false,hasTemporalKeyword:false};
primVal = ExpandString(primVal, 2 | 4, this.mID, this.mDataType, hasKeywords);
if (hasKeywords.hasKeyword && primVal=="") {
return true;
}
}
}
return false;
}
Field.prototype.GetQBEValue=function() {
if (this.IsNullKeyword())
return NullType.KEYWORD_NULL;
return this.G();
}
Field.GetQBEOperator=function(value) {
var re = /^(\<\=|\>\=|\=|!\=|\<\>|\<|\>)(.*)/;
if (re.test(value)) {
return value.replace(re, "$1");
}
return null;
}
Field.prototype.SLoadEntry=function(val) {
this.DoSLoadEntry(val);
this.SaveGlobalData();
}
Field.prototype.DoSLoadEntry=function(val) {
return this.DoSet(val); 
}
Field.prototype.FieldValChanged=function() {
}
Field.prototype.S=function(val) {
if (!("mDCF" in this)) 
this.mDCF=(this.mDOMField)?(this.mObj.getAttribute("ARDCF") != null):((this.mObj&&"dcf" in this.mObj)?(this.mObj.dcf==1):false);
bCheckFirst = !this.mDCF;
if (bCheckFirst)
bCheckFirst = !Field_GetChanged();
else
bCheckFirst = (this.mObj&&"dcf" in this.mObj && this.mObj.dcf==1);
if (bCheckFirst) {
var dt=this.G();
if (dt) {
var dtval;
if (val instanceof Datatype)
dtval=val;
else 
dtval = DatatypeFactories[dt.type](val);
if (dt.EQForSet(dtval) && (!(this.mDOMField && this.mHaveStoredData) || dtval.toString() == this.GetScreenValAsPrimitive()))
return;
} else if (!val)
return;
}
var res = this.DoSet(val);
this.mCursorRange=null;
this.SaveGlobalData();
return res;
}
Field.prototype.DoSet=function(val) {
}
Field.prototype.Validate=function() {
return null;
}
Field.prototype.GName=function() {
if(this.mDOMField) {
return this.mObj.getAttribute("ARDBN");
} else {
return this.mObj.dbn;
}
}
Field.prototype.mTextElement=null;
Field.prototype.mContainFields=false;
Field.prototype.mDOMField=false;
Field.prototype.mHaveVisualCharacteristics=false;
Field.prototype.TrackCaret=function(ele) {
;
;
if("selection" in document&&"createRange" in document.selection) {
if(!ele||ele.nodeType!=1)
return;
var ename=ele.tagName;
if(!(ename=="TEXTAREA"||(ename=="INPUT"&&ele.type.toUpperCase()=="TEXT")))
return;
try {
var range=document.selection.createRange().duplicate();
if(range.parentElement()!=ele)
return;
this.mCursorRange=range;
} catch (ignore) {
}
}
}
Field.prototype.InsertAtCaret=function(ele,val) {
if("setSelectionRange" in ele) { 
var start=ele.selectionStart,end=ele.selectionEnd;
ele.value=ele.value.substr(0,start)+val+ele.value.substr(end);
ele.setSelectionRange(start+val.length,start+val.length);
} else if(this.mCursorRange) 
this.mCursorRange.text=val;
else 
ele.value+=val;
ele.focus();
}
Field.prototype.GLabel=function() {
;
return this.mCFCache.l;
}
Field.prototype.GLabelOrName=function() {
if (this.GLabel().length > 0) {
return this.GLabel();
}
return this.GName();
}
Field.prototype.GColour=function() {
;
if(this.mCFCache.c==null&&this.mID in Defaults)
return Defaults[this.mID].c;
return this.mCFCache.c;
}
Field.prototype.GFont=function() {
;
return this.mCFCache.f;
}
Field.prototype.GAccess=function() {
;
return this.mCFCache.a;
}
Field.prototype.GVis=function() {
;
return this.mCFCache.v;
}
Field.prototype.GMenu=function() {
;
return this.mCFCache.m;
}
Field.prototype.SLabel=function(val) {
;
if(this.mCFCache.l!=val) {
this.mCFCache.l=val;
this.UpdateLabel(val);
}
}
Field.prototype.SColour=function(val) {
;
if(this.mCFCache.c!=val) {
this.mCFCache.c=val;
this.UpdateColour(val);
}
}
Field.prototype.SFont=function(val) {
;
if(this.mCFCache.f!=val) {
this.mCFCache.f=val;
this.UpdateFont(val);
}
}
Field.prototype.SAccess=function(val) {
;
if(this.mCFCache.a!=val) {
this.mCFCache.a=val;
this.UpdateAccess(val);
}
}
Field.prototype.SVis=function(val) {
;
if(this.mCFCache.v!=val) {
this.mCFCache.v=val;
this.UpdateVis(val);
}
}
Field.prototype.SMenu=function(val) {
;
if(this.mCFCache.m!=val) {
this.UpdateMenu(val);
if (val != null && val.length > 2 && 
(val.charAt(0) == '$' && val.charAt(val.length-1) == '$')) {
var idx = val.substring(1, val.length-1);
if (!isNaN(idx)) {
val = ExpandString(val, 1);
}
}
this.mCFCache.m = val;
}
else if ((val in ARMenu.Cache) && !(ARMenu.Cache[val].mMenuData instanceof Array))
ARMenu.Cache[val].mCharFieldMenu = null;
}
Field.prototype.UpdateLabel=function(val) {
var n=this.mTextElement;
;
if(n) {
;
var textNode = n.firstChild;
while (textNode!=null && textNode.nodeType!=3) {
textNode = textNode.nextSibling;
}
if(textNode) {
;
n.removeChild(textNode);    
}
n.appendChild(document.createTextNode(val));
}
else
{
var domObj = this.mObj;
;
if (domObj.firstChild != null &&
domObj.firstChild.nodeType == 1 && 
domObj.firstChild.className.indexOf("btnimgdiv")!= -1
) {
var domImg = domObj.firstChild.firstChild;
if (Boolean(parseInt(domImg.ARALTTXT)) == false)
domImg.ARTXT = val;
var isDisabled = (domObj.className.indexOf("btnd")!=-1)? true : false;
FakeButton_SetAlternative(this.mObj, isDisabled);
}  
}	
}
Field.prototype.UpdateColour=function(val) {
var n=this.mTextElement;
if(!n)
return;
if(val==null) {
if("c" in Defaults[this.mID])
val=Defaults[this.mID].c;
else
val="";
}
n.style.color=val;
}
Field.prototype.UpdateFont=function(val) {
;
var n=this.mTextElement;
if(!n)
return;
var clist=n.className.split(" ");
for(var i in clist) {
if(clist[i].match(/f[0-9]+$/)) {
clist[i]=val;
n.className=clist.join(" ");
return;
}
}
clist.push(val);
n.className=clist.join(" ");
}
Field.prototype.UpdateAccess=function(val) {
}
Field.prototype.UpdateVis=function(val) {
if(!this.mHaveVisualCharacteristics)
return;
this.mObj.style.visibility=(val?"inherit":"hidden");
}
Field.prototype.UpdateMenu=function(val) {
}
Field.prototype.GMenuStyle=function() {
return 1;
}
Field.prototype.DOMFocus=function(evt) {
;
;
return ExecuteWorkflow(8192, this.mID);
}
Field.prototype.DOMBlur=function(evt) {
;
;
return ExecuteWorkflow(256, this.mID);
}
Field.prototype.TracksCaret = false;
Field.prototype.DOMClick=Field.prototype.DOMKeyPress=function(evtinfo) {
;
}
Field.prototype.DOMMouseUp=Field.prototype.DOMMouseDown=Field.prototype.DOMMouseOver=Field.prototype.DOMMouseOut=Field.prototype.DOMKeyDown=Field.prototype.DOMDoubleClick=Field.prototype.DOMKeyUp=function(evtinfo) {
;
}
Field.prototype.Clear=function() {
;
;
var i = this.mID;
if((i>=1000000&&i<=1999999)||
(i>=3000000&&i<=3999999)||
i==1576||i==1575)
return;
this.mObj.v=Null;
this.SetDirty();
}
Field.prototype.DataDefault=function() {
if((this.mID>=1000000&&this.mID<=1999999)||
(this.mID>=3000000&&this.mID<=3999999))
return;
var def=this.GDefault();
if(def!=null)
this.S(def);
}
Field.prototype.GDefault=function() {
if("d" in Defaults[this.mID])
return(new CharType(ExpandString(""+Defaults[this.mID].d, 2)));
else
return(Null);
}
Field.prototype.MouseSelectable=true;
Field.prototype.mHaveStoredData=false;
Field.prototype.IsMouseSelectable=function() {
return this.MouseSelectable;
}
Field.prototype.QueryOK=function() {
return this.mHaveStoredData;
}
function Field_BuildList(l,validate,modifiedonly,noemptys,skipdefaults) {
;
;
;
;
;
var modifiedFields;
if (modifiedonly) {
var trsnap = new FieldSnapshot(true, false, true); 
if (DBSnapshot != null) {
modifiedFields = DBSnapshot.DataDiff(trsnap);
} else {
modifiedOnly = false;
}
}
var errors=[];
var skip=false;
for(var i in Fields) {
var fi=Fields[i];
if(fi.mHaveStoredData) {
var val = fi.G();
if(noemptys && (val==Null||val==CharNull)) 
continue;
var id=fi.mID;
var err = null;
if (validate) {
err = fi.Validate();
}
if(skipdefaults) {
if (fi.EqualsDefaultValue(err))
continue;
}
if (modifiedonly) 
skip = !(((fi.mLastChanged && Field_LastCleared<=fi.mLastChanged) && (id in modifiedFields))||((id in Form.displayOnlyFields)&&!val.isNull));
if (validate && err) {
errors.push(err);
skip=true;
}
if(!skip)
l.AddField(id,val);
}
}
if(errors.length!=0) {
;
CurWFC.status(errors); 
}
for (ii in Form.systemFields) {
l.RemoveField(ii);
}
l.RemoveField(1100);
return l;
}
function Field_GetQBEFieldList() {
var errors=[];
var res = {};
res.fl = new FieldList();
res.ps = null;
for (var i in Fields) {
try {
var fi=Fields[i];
if (fi.mHaveStoredData) {
var id = fi.mID;
var val;
if (fi instanceof DataField) {
val = fi.GetScreenValue().trim(1|2);
if (val.match(SavedSearches.QBEPSP)) {
val = val.substring(1, val.length-1);
if (!ARKWIsKeywordOrEscapedKeyword(val)) {
if (res.ps==null)
res.ps = new Object();
res.ps[id] = val;
continue;
}
}
}
val = fi.GetQBEValue();
if (val instanceof CharType)
val = ARFuncRTrim(val);
if (!val.isNull || val == NullType.KEYWORD_NULL)
res.fl.AddField(id, val);
}
} catch (e) {
errors.push(e);
}
}
if(errors.length!=0) {
;
CurWFC.status(errors); 
}
return res;
}
var DBSnapshot;
function Field_LoadEntry(entry,ignoresnap,clearfields) {
;
;
DDiary.SetDiaryFieldsDeferred(ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), entry);
var req = new NDXGetEntry(ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), ((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""), window.name, entry, [], true);
var res = req.result;
;
if (res instanceof Array) {
var takesnap=!ignoresnap,dt=null,fidmap={},reslen=res.length,snap={},ts=0;
for(var i in res) {
var ri=res[i];
if ("ts" in ri)
ts=ri.ts;
else {
;
fidmap[ri.i]=ri; 
}
}
for(var i in Fields) {
var f=Fields[i];
if(i in fidmap) {
dt=Datatype_Factory(fidmap[i]);
f.SLoadEntry(dt);
} else {
dt=Null;
if(clearfields&&f.mHaveStoredData)
f.Clear();
}
if(takesnap&&f.mHaveStoredData)
snap[i]={d:dt};
f.mCursorRange = null;
}
DBSnapshot=new FieldSnapshot();
DBSnapshot.d=true;
DBSnapshot.mSnap=snap;
DBSnapshot.ts=ts;
}
Field_ClearChanged();
}
Field.prototype.Snapshot=function(data,attrib) {
var o={};
if(data)
o.d=this.G();
if(this.mHaveVisualCharacteristics && attrib) {
o.a=this.mCFCache.a;
o.l=this.mCFCache.l;
o.c=this.mCFCache.c;
o.f=this.mCFCache.f;
o.v=this.mCFCache.v;
o.m=this.mCFCache.m;
}
return o;
}
Field.prototype.Restore=function(snapItem,data,attrib) {
if(data)
this.S(snapItem.d);
;
if(this.mHaveVisualCharacteristics && attrib) {
this.SAccess(snapItem.a);
this.SLabel(snapItem.l);
this.SColour(snapItem.c);
this.SFont(snapItem.f);
this.SVis(snapItem.v);
this.SMenu(snapItem.m);
}
}
Field.prototype.mIsComplexField=false;
function Field_Clear(skipResultsList) {
LogWrite("Field_Clear()");
var skipFid = (skipResultsList)?1020:0;
for(var i in Fields) {
if(i==skipFid)
continue;
Fields[i].Clear();
}
}
var ARFieldROBg="transparent";
function Field_SetROBackground(c) {
ARFieldROBg=c;
for(var i in Fields) {
var fi=Fields[i];
if(fi.mDOMField&&fi.GAccess()==1)
fi.UpdateROColour();
}
}
Field.prototype.UpdateROColour=function() {}
var FieldChanged = 0;
var Field_LastCleared=1;
function Field_GetChanged() {
return FieldChanged;
}
function Field_ClearChanged() {
FieldChanged = 0;
Field_LastCleared++;
DControl_DirtyFlagChanged(0);
}
function Field_ClearChangedFromRunProcess() {
FieldChanged=0;
DControl_DirtyFlagChanged(0);
}
function Field_SetChanged() {
;
if(FieldChanged!=1) {
FieldChanged=1;
DControl_DirtyFlagChanged(1);
}
}
Field.prototype.SetDirty = function() {
;
this.mLastChanged=Field_LastCleared;
if (FieldChanged==1||(this.mDCF))
return;
DControl_DirtyFlagChanged(1);
FieldChanged=1;
}
function Field_Defaults(data, attrs, setro) {
LogWrite("Field_Defaults("+data+","+attrs+","+setro+")");
for(var i in Defaults) {
var fi=Fields[i];
; 
if(data)
fi.DataDefault();
if(attrs&&fi.mHaveVisualCharacteristics) {
var dfi=Defaults[i];
fi.SColour("c" in dfi?dfi.c:null); 
fi.SFont("f" in dfi?dfi.f:"f1"); 
if("l" in dfi) fi.SLabel(dfi.l); 
if("m" in dfi) fi.SMenu(dfi.m);
if("v" in dfi) fi.SVis(dfi.v); 
if("a" in dfi) fi.SAccess(setro?1:dfi.a); 
}
}
}
function Field_ExpandDefaultValues() {
LogWrite("Field_ExpandDefaultValues()");
for(var i in Defaults) {
var dfi=Defaults[i];
if ("d" in dfi) {
if (typeof dfi.d == "string")
dfi.d = ExpandString(dfi.d, 16);
}
}
}
var DummyField=new Field(0,{dbn:""});
function F(id) {
return (id in Fields)?Fields[id]:DummyField;
}
function Field_FindByDBN(fname) { 
for(var i in Fields) {
var fi=Fields[i];
if(fi.mDOMField) {
if (fi.mObj.getAttribute("ARDBN")==fname) {
return fi;
}
} else {
if (fi.mObj.dbn==fname) {
return fi;
}
}
}
return null;
}
function Field_FindByLabel(label) {
for(var i in Fields) {
var fi=Fields[i];
if(fi.mHaveVisualCharacteristics&&fi.GLabel()==label)
return Fields[i];
}
return null;
}
function SetFieldFromDialog(fieldid, value) {
if (fieldid in Fields) {
var copy = {};
weDeepCopy(copy, value);
Fields[fieldid].S(Datatype_Factory(value));
}
}
Field.prototype.GetParent=function() {
if (!("parent" in this)) {
var n = this.mObj.parentNode;
var stopAt = document.body;
var nid;
this.parent=null;
while (n && n != stopAt) {
if(n.nodeType==1&&(nid=n.getAttribute("ARID"))) {
this.parent=Fields[parseInt(nid)];
break;
} else {
n = n.parentNode;
}
}
}
return this.parent;
}
Field.prototype.GetNestedFocusability = function() {
var p = this.GetParent();
return ((this.mDOMField) && (this.GAccess()!=3) 
&& this.GVis() && (p==null || p.GetNestedFocusability()));    
}
Field.prototype.TabableElementSelector=function(ele) {
;
if (ele.tagName=="A" || ele.tagName=="INPUT" || ele.tagName=="TEXTAREA") {
if (!ele.style || ele.style.visibility!="hidden")
return ele;
}
return null;
}
Field.prototype.GetFocusElementForEvent=function(formEvent) {
;
;
if (this.GetNestedFocusability()) {
var ele = formEvent.element;
var stopAt = this.mObj;
while (ele != null) {
var e = this.TabableElementSelector(ele);
if (e) {
return e; 
}
if (ele == stopAt)
break;
ele = ele.parentNode;
}
; 
}
return null;
}
Field.prototype.GetFocusElement = function() {
;
return null;
}
Field.prototype.IsLabelPart = function(e) {
return (e && e.className.indexOf("label")!=-1);
}
Field.prototype.GetSorter = function() {   
return "lhs.localeCompare(rhs)";
}
Field.prototype.EqualsDefaultValue = function(err) {
if (err != null) {
return false;
}
var val=this.G();
var def=this.GDefault();
return (def!=null&&val.EQ(def));
}
Field.prototype.GetType=function() {
;
}
Field.prototype.GetScreenValue=function() {
return this.G().toString();
}

function FieldSnapshot(d,a,hsd) {
if(arguments.length==1) {
;
eval(d);
} else {
this.mSnap={};
if (arguments.length>1) {
;
;
this.d=d;
this.a=a;
if (hsd) {
for(var i in Fields) {
var fi = Fields[i];
if (fi.mHaveStoredData)
this.mSnap[i]=fi.Snapshot(d,a);
}
} else {
for(var i in Fields)
this.mSnap[i]=Fields[i].Snapshot(d,a);
}
}
}
}
FieldSnapshot.prototype.Restore=function() {
for(var i in this.mSnap) {
;
Fields[i].Restore(this.mSnap[i], this.d, this.a);
}
}
FieldSnapshot.prototype.DataDiff = function(other) {
;
;
var ret = {};
var omSnap = other.mSnap;
var tmSnap = this.mSnap;
for (var ii in Fields) {
;
if (ii in tmSnap) {
if (tmSnap[ii].d.Diff(omSnap[ii].d))
ret[ii] = 1;
}
}
return ret;
}
FieldSnapshot.prototype.GetDataForID=function(id) {
;
if (this.mSnap[id])
return this.mSnap[id].d;
else 
return Null;    
}

function FieldList(ids) {
;
this.mFields = new Object();
if (ids instanceof Array) {
;
for (var i = 0; i < ids.length; ++i) {
var id = ids[i];
if (id > 0) { 
var v;
if (id==112||id==104) {
if ("GetScreenValAsPrimitive" in F(id)) {
v=new CharType(F(id).GetScreenValAsPrimitive());
} else {
v=new CharType(" ");
}	
} else {
v=F(id).G();
}
if (v instanceof CharNullType)
v = new CharType(" ");
this.AddField(id, v);
} else 
this.AddField(id, ARKWGetByNegIdx(id));
}
}
}
FieldList.prototype.F = function(id) {
;
return (id in this.mFields) ? this.mFields[id] : Null;
}
FieldList.prototype.AddField = function(id, value) {
;
;
;
this.mFields[id] = value;
}
FieldList.prototype.AddFields1 = function(fields, fieldids) {
;
;
for (var i = 0; i < fields.length && i < fieldids.length; ++i) {
var item = fields[i];
;
this.mFields[fieldids[i]] = Datatype_Factory(item);
}
}
FieldList.prototype.RemoveField=function(fid) {
delete this.mFields[fid];
}
FieldList.prototype.ToArrays = function(fieldids, fieldvals, fieldtypes) {
;
;
;
for (var id in this.mFields) {
var value = this.mFields[id];
;
fieldids.push(parseInt(id));
fieldvals.push(value.toPrimitive());
fieldtypes.push(value.type);
}
}
FieldList.prototype.Query = function(server, schema, qual, multimatch, nomatch, fieldids) {
;
;
;
;
;
;
LogWrite("FieldList.Query(" + qual + ", " + server + ", " + schema + ", " + multimatch + ", " + nomatch + ")");
server = ExpandServerName(server);
schema = ExpandSchemaName(schema);
qual = ExpandQualifier(qual, schema, server);
;
;
;
;
var req = new NDXGetEntryList(ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), server, schema, ((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""), qual.qual, qual.fieldids, qual.fieldvals, qual.fieldtypes, nomatch, multimatch, fieldids);
var res = req.result;
;
ARKWSetLASTCOUNT(res.n);
if ("mids" in res) 
fieldids = res.mids;
if ("f" in res) {
this.AddFields1(res.f, fieldids);
} else if ("l" in res) {
;
;
;
var selected={};
return {n:{f:function(fl) {
;
if (!("v" in selected.result) || selected.result.v == -1)
CurWFC.status(0);
req = new NDXGetEntry(server, schema, ((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""), window.name, res.l.r[selected.result.v].i, fieldids, false);
res = req.result;
;
if (res instanceof Array)
fl.AddFields1(res, fieldids);
else {
;
ARKWSetLASTCOUNT(0);
if (nomatch == 1)
CurWFC.status(9278);
}
}, a:[this]}, c:{f:SelectionPopup, a:[res, selected]}};
} else {
; 
if ((res.n == 0 && nomatch == 2)
|| (res.n > 0 && multimatch == 2)) {
for (var i = 0; i < fieldids.length; ++i)
this.AddField(fieldids[i], Null);
} else {
;
if (res.n > 0)
CurWFC.status(9277);
else
CurWFC.status(9278);
}
}
}
FieldList.PopulateValueAndTypeArrays=function(ids, vals, types) {
for (var ii in ids) {
id = ids[ii];
;
var value;
if (id > 0) {
value = F(id).G();
} else {
value = ARKWGetByNegIdx(id);
}    
;
if (value instanceof CharNullType) {
vals.push(""); 
types.push(4);
} else {
vals.push(value.toPrimitive());
types.push(value.type);
}
}
}
FieldList.prototype.SQLQuery = function(alName, actIndex, multimatch, nomatch, keywordRefs, fieldRefs, maxSqlIdx) {
;
;
;
;
;
;
;
LogWrite("FieldList.SQLQuery(" + multimatch + ", " + nomatch + ", " + keywordRefs + ", " + fieldRefs + ", " + maxSqlIdx + ")");
var keywordVals = new Array();
var keywordTypes = new Array();
FieldList.PopulateValueAndTypeArrays(keywordRefs, keywordVals, keywordTypes);
var fieldVals = new Array();
var fieldTypes = new Array();
FieldList.PopulateValueAndTypeArrays(fieldRefs, fieldVals, fieldTypes);
var req = new NDXGetSQLEntryList(ARKWGetStringByIdx(7), alName, actIndex, nomatch, multimatch, keywordRefs, keywordVals, keywordTypes, fieldRefs, fieldVals, fieldTypes, false);
var res = req.result;
;
if (typeof res == "object") {
ARKWSetLASTCOUNT(res.n);
var sqlIdxs = new Array();
var len = res.l.r[0].d.length;
for (var fid = 1; fid <=len ; fid++) {
sqlIdxs.push(fid);
}
if (res.n == 1) {
; 
this.AddFields1(res.l.r[0].d, sqlIdxs);
} else {
;
;
if (multimatch == 1)
CurWFC.status(9277);
var harr = [];
var numCols = res.l.r[0].d.length;
for (var ii = 1; ii <= numCols ; ii++) {
harr.push(getLocalizedMessage("Column " + ii));
}
res.l.h=harr;
var selected = {};
return { c:{f:SelectionPopup, a:[res, selected]}, 
n: { a:[this], f: function(fl) {
;
if (!("v" in selected.result) || selected.result.v == -1)
CurWFC.status(0);
var row = res.l.r[selected.result.v];
var r = [];
var len = row.d.length;
for (var j = 0; j < len; ++j)
r.push(row.d[j]);
fl.AddFields1(r, sqlIdxs);  
}
}
};
}
} else {
ARKWSetLASTCOUNT(res);
; 
if ((res == 0 && nomatch == 2)
|| (res > 0 && multimatch == 2)) {
} else {
;
if (res > 0)
CurWFC.status(9277);
else
CurWFC.status(9278);
}
}
}
FieldList.prototype.Push = function(qual, server, schema, multimatch, nomatch, likeId, submit) {
;
;
;
;
;
;
;
LogWrite("FieldList.Push(" + qual + ", " + server + ", " + schema + ", " + multimatch + ", " + nomatch + "," + likeId + "," + submit + ")");
server = ExpandServerName(server);
schema = ExpandSchemaName(schema);
qual = ExpandQualifier(qual, schema, server);
;
;
;
var fieldids = new Array();
var fieldvals = new Array();
var fieldtypes = new Array();
this.ToArrays(fieldids, fieldvals, fieldtypes);
;
;
;
var req = new NDXSetEntryList(ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), server, ((submit) ? "" : schema), F(1).G().toString(), qual.qual, qual.fieldids, qual.fieldvals, qual.fieldtypes, nomatch, multimatch, likeId, fieldids, fieldvals, fieldtypes);
var res = req.result;
;
if (res instanceof Object) {
;
if (!submit) 
ARKWSetLASTCOUNT(0);
ARKWSetLASTID(res.id);
} else {
; 
ARKWSetLASTCOUNT(res);
if (res == 0 && nomatch == 1)
CurWFC.status(9278);
else if (res > 0 && multimatch == 1)
CurWFC.status(9364);
}
}
FieldList.prototype.PushEntry = function(server, schema, entries, timestamp) {
;
;
;
;
;
;
LogWrite("FieldList.PushEntry(" + server + ", " + schema + ", " + entries + ", " + timestamp + ")");
server = ExpandServerName(server);
schema = ExpandSchemaName(schema);
;
;
;
var fieldids = new Array();
var fieldvals = new Array();
var fieldtypes = new Array();
this.ToArrays(fieldids, fieldvals, fieldtypes);
;
;
;
var req = new NDXSetEntry(server, schema, window.name, entries, timestamp, fieldids, fieldvals, fieldtypes);
var res = req.result;
;
;
return res;
}
FieldList.SetAllGlobals = function() {
for (var f in Form.globalFields) {
F(Form.globalFields[f]).ReadGlobalData();
}
ARKWGetGlobalKeywords();
}
FieldList.ClearAllGlobals = function() {
deleteCookie("GF", "/");
}

DataField.prototype=new Field(); DataField.prototype.constructor=DataField; DataField.superclass=Field.prototype;;
function DataField(id,n) {
if(arguments.length)
this.init(id,n);
}
DataField.prototype.mDOMField=DataField.prototype.mHaveVisualCharacteristics=true;
DataField.prototype.init=function(id,n) {
this.mDataVal=(this.mDataType==4)?CharNull:Null;
DataField.superclass.init.call(this,id,n);
var o=this.mObj.firstChild;
while(o.nodeType==1 && (o.className && o.className.indexOf("label")==-1) || !o.className)
o=o.firstChild;
this.mTextElement=o;
if (this.mInputNode) {
;
this.mInputNode.onchange=DataField.fvChanged;
}
}
var SACCESSRE=/([ ]*dfro)|([ ]*dfd)/;
DataField.prototype.UpdateAccess=function(val) {
;
;
var disabled=val==3,readonly=val==1;
var start=this.mObj,n=start;
n.className=n.className.replace(SACCESSRE,""); 
if(disabled)
n.className+=" dfd";
while(1) {
if(n.nodeType==1&&(n.tagName=="INPUT"||n.tagName=="TEXTAREA")) {
n.disabled=disabled;
n.readOnly=readonly;
if (n.tagName=="INPUT" && (n.type=="checkbox" || n.type=="radio")) {
n.disabled = disabled | readonly;
}
n.style.backgroundColor=(readonly?ARFieldROBg:"");
} else if (n.nodeType==1&&n.tagName=="DIV" && FakeButton_Find(n)) {
FakeButton_SetDisable(n,disabled);
}
if(n.firstChild)
n=n.firstChild;
else {
while(!n.nextSibling) {
n=n.parentNode;
if(n==start)
return;
}
n=n.nextSibling;
}
}
}
DataField.prototype.UpdateROColour=function() {
var start=this.mObj,n=start;
while(1) {
if (n.nodeType==1) {
if (n.tagName=="INPUT"||n.tagName=="TEXTAREA") {
n.style.backgroundColor=ARFieldROBg;
return;
}
}
if (n.nodeType==1 && (n.tagName=="DIV" || n.tagName=="FIELDSET" || n.tagName=="LEGEND") &&n.firstChild) {
n=n.firstChild;
} else {
while(!n.nextSibling) {
n=n.parentNode;
if(n==start)
return;
}
n=n.nextSibling;
}
}
}
DataField.fvChanged=FormEvent.Trampoline(function(ed) {
var f=Field_FromElement(ed.element);
f.FieldValChanged();
});
DataField.prototype.FieldValChanged=function() {
var primVal = this.GetScreenValAsPrimitive();
if (this.mPrimVal==primVal)
return;
this.mPrimVal=primVal;    
;
if (primVal=="") {
this.mDataVal=(this.mDataType==4)?CharNull:Null;
} else {
var hasKeywords={hasKeyword:false,hasTemporalKeyword:false};
primVal = ExpandString(primVal, 2 | 4, this.mID, this.mDataType, hasKeywords);
if (hasKeywords.hasTemporalKeyword){
this.mDataVal=null;
} else {
if (primVal=="") {
if (hasKeywords.hasKeyword)
this.mDataVal=(this.mDataType==4)?CharNullType.KEYWORD_CHAR_NULL:NullType.KEYWORD_NULL; 
else
this.mDataVal=(this.mDataType==4)?CharNull:Null;
} else {
this.mDataVal = this.ConvertPrimitiveToDataType(primVal);
}
}
}
if (!("mDCF" in this))
this.mDCF=(this.mObj.getAttribute("ARDCF")!=null);
DataField.superclass.SetDirty.call(this);
this.SaveGlobalData();
}
DataField.prototype.G=function() {
;
if (this.mDataVal==null) {
var prim = this.GetScreenValAsPrimitive();
; 
;
prim = ExpandString(prim, 2 | 4, this.mID, this.mDataType);
if (prim=="")
return (this.mDataType==4)?CharNull:Null;
return this.ConvertPrimitiveToDataType(prim);
}
return this.mDataVal;
}
DataField.prototype.GetScreenValAsPrimitive=function() {
;
return this.mInputNode.value;
}
DataField.prototype.SetScreenValue=function(val) {
;
this.mInputNode.value = val;
this.FieldValChanged();
}
DataField.prototype.GetScreenValue=function() {
;
;
return this.mInputNode.value;
}
DataField.prototype.ConvertPrimitiveToDataType=function(val) {
; 
}
DataField.prototype.Clear=function() {
var i=this.mID;
if((i>=1000000&&i<=1999999)||
(i>=3000000&&i<=3999999)||
i==1576||i==1575)
return;
this.mDataVal=(this.mDataType==4)?CharNull:Null;
this.mPrimVal="";
if (this.mNeedSpecialSetToScreen) 
this.SToScreen(this.mDataVal,this.mPrimVal);
else
this.mInputNode.value="";
if (this.mCharEditBox)
CharEditBoxPopup_UpdateText(this.mCharEditBox, this.mPrimVal);
}
DataField.prototype.DoSet=function(dt) {
;
var dtstr;
if (dt.isNull) {
this.mDataVal=(this.mDataType==4)?CharNull:Null;
dtstr="";
} else {    
dt=this.ConvertDTForS(dt);
dtstr=dt.toString();
if (dtstr=="") {
this.mDataVal=(this.mDataType==4)?CharNull:Null;
} else {
if (dt.type==4) {
var hasKeywords={hasKeyword:false,hasTemporalKeyword:false};
var primVal = ExpandString(dtstr, 2 | 4 | 8, this.mID, this.mDataType, hasKeywords);
if (hasKeywords.hasTemporalKeyword) {
this.mDataVal=null; 
} else {
if ((this.mDataType==4) && !hasKeywords.hasKeyword) {
this.mDataVal=dt;
} else {
if (primVal=="") {
this.mDataVal=(this.mDataType==4)?CharNull:Null;
dtstr="";
} else {
this.mDataVal=dt=this.ConvertPrimitiveToDataType(primVal); 
dtstr=dt.toString(); 
}
}
}
} else {
this.mDataVal=dt;
}
}
}
this.mPrimVal=dtstr;
if (this.mNeedSpecialSetToScreen)
return this.SToScreen(dt,dtstr);
this.mInputNode.value=dtstr;
this.mPrimVal=this.mInputNode.value;
if (this.mCharEditBox)
CharEditBoxPopup_UpdateText(this.mCharEditBox, this.mPrimVal);
this.SetDirty(this.mInputNode);
}
DataField.prototype.DoSLoadEntry=function(dt) {
;
var dtstr;
if (dt.isNull) {
this.mDataVal=(this.mDataType==4)?CharNull:Null;
dtstr="";
} else {    
dt = this.ConvertDTForSLE(dt);
dtstr=dt.toString();
if (dtstr=="") {
this.mDataVal=(this.mDataType==4)?CharNull:Null;
} else {
if (dt.type==4) {
var hasKeywords={hasKeyword:false,hasTemporalKeyword:false};
var primVal = ExpandString(dtstr, 2 | 4, this.mID, this.mDataType, hasKeywords);
if (hasKeywords.hasTemporalKeyword) {
this.mDataVal=null; 
} else {
if ((this.mDataType==4) && !hasKeywords.hasKeyword) {
this.mDataVal=dt;
} else {
if (primVal=="") {
this.mDataVal=(this.mDataType==4)?CharNull:Null;
dtstr="";
} else {
this.mDataVal=dt=this.ConvertPrimitiveToDataType(primVal);
dtstr=dt.toString();
} 
}
}
} else {
this.mDataVal=dt;
}
}
}
this.mPrimVal=dtstr;
if (this.mNeedSpecialSetToScreen)
return this.SToScreen(dt,dtstr);
this.mInputNode.value=dtstr;
this.mPrimVal=this.mInputNode.value;
if (this.mCharEditBox)
CharEditBoxPopup_UpdateText(this.mCharEditBox, this.mPrimVal);
this.SetDirty(this.mInputNode);
}
DataField.prototype.DOMKeyPress=function(evt) {
;
if(evt.key==13) 
return ExecuteWorkflow(2,this.mID);
}
DataField.prototype.SetDirty = function(ele) {
if (ele) {
if (CurWFC) {
CurWFC.addDirtyElement(this.mID, ele);
} else {
FormEvent.FireChangeEvent(ele);
}
}
DataField.superclass.SetDirty.call(this);
}
DataField.prototype.GetFocusElement=function() {
if ("mFocusElement" in  this) {
return this.mFocusElement;
}
var start = this.mObj,n=start;
while (1) {
if((n.nodeType==1) && ((n.tagName=="INPUT") || (n.tagName == "TEXTAREA") || (n.tagName == "IMG"))) {
this.mFocusElement = n;
return n;
}
if(n.firstChild) {
n=n.firstChild;
} else {
while(!n.nextSibling) {
n=n.parentNode;
if(n==start) {
this.mFocusElement = null;
return null;
}
}
n=n.nextSibling;
}
}
}
DataField.prototype.TracksCaret = true;
DataField.prototype.mDataType=0;

var ARKWValues = [
{ n:"NULL", t:0, v:null },
{ n:"DEFAULT", t:104, v:ARKWGetFieldDefault },
{ n:"USER", t:0, v:null },
{ n:"TIMESTAMP", t:60, v:ARKWGetTimeStamp },
{ n:"TIME", t:60, v:ARKWGetTime },
{ n:"DATE", t:60, v:ARKWGetDate },
{ n:"SCHEMA", t:0, v:null },
{ n:"SERVER", t:0, v:null },
{ n:"WEEKDAY", t:60, v:ARKWGetWeekday },
{ n:"GROUPS", t:0, v:null },
{ n:"OPERATION", t:2, v:null },
{ n:"HARDWARE", t:0, v:null }, 
{ n:"OS", t:0, v:null }, 
{ n:"DATABASE", t:0, v:null },
{ n:"LASTID", t:6, v:null },
{ n:"LASTCOUNT", t:7, v:null },
{ n:"VERSION", t:0, v:null },
{ n:"VUI", t:0, v:null },
{ n:"GUIDETEXT", t:0, v:null }, 
{ n:"FIELDHELP", t:64, v:null }, 
{ n:"GUIDE", t:40, v:ARKWGetGuide },
{ n:"APPLICATION", t:0, v:null },
{ n:"LOCALE", t:0, v:null },
{ n:"CLIENT-TYPE", t:1, v:null },
{ n:"SCHEMA-ALIAS", t:0, v:null },
{ n:"ROWSELECTED", t:45, v:ARKWGetRowSelected },
{ n:"ROWCHANGED", t:41, v:ARKWGetRowChanged },
{ n:"BROWSER", t:40, v:ARKWGetBrowserVersion },
{ n:"VUI-TYPE", t:0, v:null },
{ n:"TCPPORT", t:1, v:null }, 
{ n:"HOMEURL", t:2, v:null },
{ n:"ROLES", t:0, v:null },
{ n:"EVENTTYPE", t:2, v:null },
{ n:"EVENTSRCWINID", t:2, v:null },
{ n:"CURRENTWINID", t:2, v:null },
{ n:"LASTOPENEDWINID", t:2, v:null },
{ n:"INBULKTRANSACTION", t:1, v:null },
{ n:"FIELDID", t:40, v:ARKWGetFieldIDInFocus },
{ n:"FIELDNAME", t:40, v:ARKWGetFieldNameInFocus },
{ n:"FIELDLABEL", t:40, v:ARKWGetFieldLabelInFocus },
{ n:"SERVERTIMESTAMP", t:60, v:ARKWGetServerTimeStamp },
{ n:"GROUPIDS", t:0, v:null },
{ n:"EVENTDATA", t:2, v:null }
];
var ARKWNameLookup = new Array(ARKWValues.length);
for (var i = 0; i < ARKWValues.length; ++i)
ARKWNameLookup[ARKWValues[i].n] = i;
function ARKWSetup()
{
; 
for (var i = 0; i < arguments.length - 1; i += 2) {
;
; 
ARKWValues[arguments[i]].v = arguments[i + 1];
}
}
function ARKWSet(idx, value)
{
;
; 
;
; 
;
ARKWValues[idx].v = value;
}
function ARKWGetByIdx(idx, fieldid)
{
;
; 
;
var res;
if ((((ARKWValues[idx]).t & 32) != 0))
res = ARKWValues[idx].v(fieldid);
else
res = ARKWValues[idx].v;
;
;
if (res != null) {
if (res instanceof Datatype) {
return res;
} else if ((((ARKWValues[idx]).t & 1) != 0)) {
;
return new IntegerType(res);
} else if ((((ARKWValues[idx]).t & 1) == 0)) {
;
return new CharType(res);
}
}
return Null;
}
function ARKWGetByNegIdx(idx, fieldid)
{
;
idx = (-idx) + 1; 
return ARKWGetByIdx(idx, fieldid);
}
function ARKWGetNameByIdx(idx)
{
;
; 
return ARKWValues[idx].n;
}
function ARKWGetKeywordIdx(aname)
{
;
return ARKWNameLookup[aname];
}
function ARKWGetByName(aname, fieldid)
{
;
return ARKWGetByIdx(ARKWNameLookup[aname], fieldid);
}
function ARKWGetStringByIdx(idx, fieldid)
{
var res = ARKWGetJSNativeByIdx(idx, fieldid);
;
return res;
}
function ARKWGetJSNativeByIdx(idx, fieldid)
{
;
; 
;
var res;
if ((((ARKWValues[idx]).t & 32) != 0))
res = ARKWValues[idx].v(fieldid);
else
res = ARKWValues[idx].v;
;
return res;
}
function ARKWIsKeywordIdx(idx)
{
;
return (idx >= 0 && idx <= 42);
}
function ARKWIsKeywordName(aname)
{
return (typeof ARKWNameLookup[aname] != "undefined");
}
function ARKWIsKeywordOrEscapedKeyword(aname)
{
if ((ARKWIsKeywordName(aname))||(aname.length > 2 && aname.charAt(0) == '\\' && ARKWIsKeywordName(aname.substr(1))))
return true;
return false;
}
function ARKWIsKeywordString(val)
{
if(typeof val == "string" || val instanceof CharType) {
val = val.toString();
if (val.length > 2 && val.charAt(0) == '$' && val.charAt(val.length-1) == '$')
return ARKWIsKeywordName(val.substring(1, val.length-1));
}
return false;
}
function ARKWIsTemporal(idx)
{
;
return (((ARKWValues[idx]).t & 4) != 0);
}
function ARKWIsTemporalString(val)
{
if(typeof val == "string" || val instanceof CharType) {
val = val.toString();
if (val.length > 2) {
val = val.substring(1, val.length-1);
if (typeof ARKWNameLookup[val] != "undefined")
return (((ARKWValues[ARKWNameLookup[val]]).t & 4) != 0);
}
}
return false;
}
function ARKWIsTimeRelated(idx)
{
;
return (((ARKWValues[idx]).t & 16) != 0);
}
function ARKWIsConstant(idx) {
;
return (((ARKWValues[idx]).t & 2) == 0);
}
function ARKWGetTime()
{
return new TODKWType();
}
function ARKWGetTimeStamp()
{
var t = new Date().UnixTimestamp();
return new TimeType(t);
}
function ARKWGetServerTimeStamp()
{
var t = new NDXGetServerTimestamp(ARKWGetStringByIdx(7)).GetResult();
return new TimeType(t);
}
function ARKWGetDate()
{
return new DateKWType();
}
function ARKWGetWeekday()
{
return new WeekdayKWType();
}
function ARKWGetFieldDefault(fieldid) {
;
if (typeof fieldid == "undefined")
return null;
if (fieldid in Defaults && "d" in Defaults[fieldid])
return ExpandString(""+ Defaults[fieldid].d, (F(fieldid) instanceof JColumn) ? 1 : 4);
return null;
}
function ARKWGetFieldIDInFocus() {
return FocusMgr.getFocusedID() + "";
}
function ARKWGetFieldNameInFocus() {
var id = FocusMgr.getFocusedID();
return F(id).GName();
}
function ARKWGetFieldLabelInFocus() {
var id = FocusMgr.getFocusedID();
return F(id).GLabel();
}
function ARKWGetBrowserVersion() {
var uaStr = navigator.userAgent;
var ver = "";
var IE = "IE";
var i = uaStr.indexOf(IE);
if (i != -1 && uaStr.charAt(i + IE.length) == " ") {
var start = i + IE.length + 1;
var end = uaStr.indexOf(";", start);
if (end != -1) {
ver = uaStr.substr(start, end - start);
}
} else if (uaStr.indexOf("Gecko") != -1) { 
ver = "7";
}
if (ver.length <= 0) {
ver = "unknown";
}
return navigator.appName + ver;
}
function ARKWGetGuide() {
if (CurWFC) {
var gs = CurWFC.getGuideState();
if (gs != null) {
;
return gs.g;
}
}
return null;
}
function ARKWGetRowSelected() {
if (CurWFC) {
var gs = CurWFC.getGuideState();
if (gs != null) {
;
if ("table" in gs) 
return gs.table.GetRowSelected(gs.currow);
}
}
return null;
}
function ARKWGetRowChanged() {
if (CurWFC) {
var gs = CurWFC.getGuideState();
if (gs != null) {
;
if ("table" in gs) 
return gs.table.GetRowChanged(gs.currow);
}
}
return null;
}
function ARKWSetLASTID(value) {
ARKWGetGlobalKeywords();
ARKWSet(14, value);
ARKWSetGlobalKeywords();
}
function ARKWSetLASTCOUNT(value) {
ARKWGetGlobalKeywords();
ARKWSet(15, value);
ARKWSetGlobalKeywords();
}
function ARKWSetGlobalKeywords() {
var vals = {};
vals[14] = ARKWValues[14];
vals[15] = ARKWValues[15];
SerializeGlobals("GKW",vals);
}
function ARKWGetGlobalKeywords() {
var vals = DeserializeGlobals("GKW");
if (vals != null) {
for (var idx in vals)
ARKWValues[idx] = vals[idx];
}
}

var ARStateCurrent;
var StateMgr;
function StateMgr_Init() {
ARStateCurrent=0;
StateMgr=new function() {
var ARStateNames = [ "NONE", "CREATE", "DIALOG", "GET", "QUERY", "SET", "SET ALL" ];
var ARStateTitles = [getLocalizedMessage("{0} (NONE)"),getLocalizedMessage("{0} (New)"),"{0} ({1})",getLocalizedMessage("{0} (Display)"),getLocalizedMessage("{0} (Search)"),getLocalizedMessage("{0} (Modify)"),getLocalizedMessage("{0} (Modify All)")];
var OpenWindowStates={
0 : [ 2 ], 
1 : [ 4 ], 
2 : [ 1 ], 
3 : [ 4, 5, false ], 
4 : [ 4, 5, true ], 
5 : [ 4, 5, false ], 
6 : [ 4, 3, false ], 
7 : [ 4, 3, true ], 
8 : [ 4, 3, false ], 
9 : [ 0 ], 
10 : [ 4, 5, false ], 
11 : [ 4, 3, false ]
};
this.OpenWindowStates=OpenWindowStates; 
this.OpenWindowFunctions = {
0 : FormAction_NewSearch, 
1 : FormAction_NewRequest, 
2 : FormAction_NewDialog, 
4 : FormAction_NewSearch
};
var mOpenWindowDetailOnly=false,ARStates=[],mFirstStateChange=true,mInTransition=false;
this.mWindowIsClosed=false;
ARStates[ 'S01' ] = 
[ EventClearFields, EventWindowOpen, EventClearChangeFlag, EventSetDefaults, EventApplyMappings, EventWindowLoaded,EventAfterWindowLoadedSnapshot,EventLoadAppList];
ARStates[ 'S02' ] =
[EventSetDefaults, EventApplyMappings, EventWindowOpen, EventLoadAppList];
ARStates[ 'S03' ] = 
[EventShowResultsList, EventClearFields, EventWindowOpen, EventLoadAppList, EventAfterWindowOpenSnapshot, EventLoadEntry, EventDisplay];
ARStates[ 'S04' ] =
[EventClearFields, EventWindowOpen, EventSetDefaults, EventApplyMappings, EventWindowLoaded, EventLoadAppList];
ARStates[ 'S05' ] =
[EventShowResultsList, EventClearFields, EventWindowOpen, EventLoadAppList, EventAfterWindowOpenSnapshot, EventLoadEntry, EventDisplay];
ARStates[ 'S06' ] =
[EventShowResultsList, EventClearFields, EventWindowOpen, EventLoadAppList];
ARStates[ 'S10' ] =
[ EventWindowClose, EventCheckChangeFlag, EventClearSnapshot, EventClearChangeFlag];
ARStates[ 'S20' ] =
[ EventWindowClose, EventClearSnapshot, EventClearChangeFlag ];
ARStates[ 'S30' ] =
[ EventUndisplay , EventWindowClose, EventClearSnapshot, EventClearChangeFlag, EventHideResultsList]
ARStates[ 'S40' ] =
[ EventWindowClose, EventClearSnapshot, EventClearChangeFlag];
ARStates[ 'S50' ] =
[ EventUndisplay, EventWindowClose, EventCheckChangeFlag, EventClearSnapshot, EventClearChangeFlag, EventHideResultsList ];
ARStates[ 'S60' ] =
[ EventWindowClose, EventCheckChangeFlag, EventClearSnapshot, EventClearChangeFlag, EventHideResultsList ];
ARStates[ 'S33' ] =
[EventUndisplay, EventAfterWindowOpenRestore, EventLoadEntry, EventDisplay];
ARStates[ 'S55' ] =
[EventUndisplay,EventCheckChangeFlag,EventClearChangeFlag,EventAfterWindowOpenRestore, EventLoadEntry, EventDisplay];
ARStates[ 'S61' ]=ARStates[ 'S64' ]=
ARStates[ 'S66' ]=ARStates[ 'S65' ]=
ARStates[ 'S41' ]=ARStates[ 'S44' ]=
ARStates[ 'S45' ]=ARStates[ 'S43' ]=
ARStates[ 'S46' ]=ARStates[ 'S31' ]=
ARStates[ 'S34' ]=ARStates[ 'S51' ]=
ARStates[ 'S54' ]=ARStates[ 'S56' ]=
ARStates[ 'S11' ]=ARStates[ 'S14' ]=
[TransitionState];
this.ARStateChange=ARStateChange; 
function ARStateChange(newstate) {
;
;
LogWrite("ARStateChange " + ARStateNames[ARStateCurrent] + " -> " + ARStateNames[newstate]);
;
mInTransition=true;
var evts = ARStates[(("S" + (ARStateCurrent)) + (newstate))];
var state = { i: 0, cs: ARStateCurrent, ns: newstate };
return {c: {f: ExecuteStateChange, a: [evts, state]},
n: {f: SetCurrentState, a: [state]} };
}
function SetCurrentState(state) {
;
mFirstStateChange=false;
if (state.ab) {
LogWrite("ARStateChange Aborted : Current state is " + ARStateCurrent);
ARKWSet(10, ARStateNames[ARStateCurrent]);
setWindowTitle(ARStateCurrent);
} else {
LogWrite("ARStateChange Complete : Current state is " + state.ns);
if (ARStateCurrent != 0) {
DControl_UpdateFormActionButtons();
Form_UpdateToolbar();
}
}
mInTransition=false;
}
function TransitionState(state) {
;
var none2New = {i:0, cs: 0, ns: state.ns, pas:state };
var cur2None = {i:0, cs: state.cs, ns: 0, nss: none2New, pas:state };
var sc1 = ARStates[(("S" + (state.cs)) + (0))];
var sc2 = ARStates[(("S" + (0)) + (state.ns))];
return {c: {f: ExecuteStateChange, a: [sc1, cur2None]},
n: {f: ExecuteStateChange, a: [sc2, none2New]}};
}
function ExecuteStateChange(events, state) {
;
;
var ind = state.i;
if (state.ab) {
return;
}
;
if ((ind == 0) && (state.cs == 0)) {
ARStateCurrent = state.ns;
ARKWSet(10, ARStateNames[state.ns]);
setWindowTitle(state.ns);
}       
if (ind < events.length) {
state.i++;
return {c: {f: events[ind], a: [state], e:GenericExcHandler, ea:[state, false]}, n: {f: ExecuteStateChange, a: [events, state]}};
}  
}
function abortTransition(state) {
state.ab=1;
if(state.nss)
state.nss.ab=1;
if(state.pas)
state.pas.ab=1;
}
function GenericExcHandler(exc, state, abortStateChange) {
if ((exc instanceof WorkflowException) && exc.mArg && exc.mArg.length > 0) {
if (abortStateChange)
abortTransition(state);
return MessagePopup(exc.mArg);
} else
throw exc;
}
this.InTransition=function() {
return mInTransition;
}
function setWindowTitle(curstate) {
var pre = (curstate==4) ? ARTitles.pluralLong : ARTitles.singleLong;
if (pre=="")
pre=ARKWGetStringByIdx(6);
window.title = document.title = getLocalizedMessage(ARStateTitles[curstate], [pre, ARKWGetStringByIdx(7)]);
}
this.GetToolbarTitle=function() {
var lstr=getLocalizedMessage(ARStateTitles[ARStateCurrent],["",""]);
return lstr.match(/\((.*?)\)/)[1];
}
this.GetActionButtonString=function() {
if(ARStateCurrent==4)
return getLocalizedMessage("Search",null);
else
return getLocalizedMessage("Save",null);
}
var CopiedInParamMappings=false;
function EventApplyMappings(state) {
;
if (window.weArgs != null && "fvlist" in weArgs) {
for (var fv in weArgs.fvlist) {
if (typeof(weArgs.fvlist[fv]) != "function") {
if (fv in Fields) {
var val = Datatype_Factory(weArgs.fvlist[fv]);
if (val instanceof CharType)
val = new CharType(ExpandString(val.toString(), 2 | 4));
Fields[fv].S(val);
} 
}
}
window.weArgs.fvlist = null;
}
if ("olserver" in window.URLParams)
F(1041).S(new CharType(window.URLParams.olserver));
if ("olapp" in window.URLParams)
F(1042).S(new CharType(window.URLParams.olapp));
if(!CopiedInParamMappings) {
var fid;
for(var i in window.URLParams) {
if(i.charAt(0)=='F'&&i.length>1) {
var fid=parseInt(i.substr(1));
if(!isNaN(fid)&&fid>0&&fid in Fields)
Fields[fid].S(new CharType(window.URLParams[i]));
}
}
CopiedInParamMappings=true;
}
}
function EventWindowOpen(state) {
;
LogWrite("EVENT: WindowOpen");
Field_Defaults(0, 1, (state.ns == 3) ? 1 : 0); 
var sysAccess=(state.ns==4)?2:1;
for (ii in Form.systemFields) {
F(ii).SAccess(sysAccess);
}
Field_ClearChanged();
StateMgr.mWindowIsClosed=false;
return {n:{f:ExecuteWorkflow, a:[16384], e:WindowOpenExcHandler, ea:[state]}};
}
function WindowOpenExcHandler(exc, state) {
if (exc instanceof WorkflowException && exc.mArg && exc.mArg.length>0) {
abortTransition(state);
this.mWindowIsClosed=true;
Field_ClearChangedFromRunProcess();
return {n:{f:function() {
return {c:{f:MessagePopup, a:[exc.mArg]},n:{f:ARACTCloseWindow,a:[0]}};
}}};
}
throw exc;
}
var mAfterWindowOpenSnapshot,mAfterWindowLoadedSnapshot;
function EventAfterWindowOpenSnapshot(state) {
;
mAfterWindowOpenSnapshot=new FieldSnapshot(false,true);
}
function EventAfterWindowLoadedSnapshot(state) {
;
mAfterWindowLoadedSnapshot=new FieldSnapshot(false,true);
}
function EventAfterWindowOpenRestore(state) {
;
mAfterWindowOpenSnapshot.Restore();
}
function EventWindowLoaded(state) {
;
LogWrite("EVENT: WindowLoaded");
return ExecuteWorkflow(262144);
}
function EventLoadAppList(state) {
DAppList.Load();
}
this.WindowIsClosing=function(state) {
;
if (this.mWindowIsClosed)
return;
var retObj={n:{f:EventWindowClose,a:[state]}};
if ((ARStateCurrent == 5) || (ARStateCurrent == 3)) {
retObj.c=({f:EventUndisplay, a:[state]});
}
return  retObj;
}
function EventWindowClose(state) {
;
LogWrite("EVENT: WindowClose");
if (state.ab)
return;
return {n:{f:ExecuteWorkflow,a:[32768],e:GenericExcHandler,ea:[state,true]}, 
c:{f:function(){
StateMgr.mWindowIsClosed = true;
}}};
}
this.ClearSnapshot=EventClearSnapshot;
function EventClearSnapshot() {
mAfterWindowOpenSnapshot=mAfterWindowLoadedSnapshot=null;
this.mWindowIsClosed=true;
}
function EventSetDefaults(state) {
;
;
;
LogWrite("EVENT: SetDefaults");
var defaultType = 1;
if (state.ns == 1) {
defaultType = ARPrefsGetAsNumber(20101);
} else if (state.ns == 4) {
defaultType = ARPrefsGetAsNumber(20102);
} else if (state.ns == 2) {
defaultType = 0;
}
if (window.weArgs != null && "wForceClear" in weArgs && weArgs.wForceClear == 1) {
weArgs.wForceClear = 0;
EventClear(true);
if ("fvSetDefaults" in weArgs && weArgs.fvSetDefaults == 1) {
defaultType = 1;
} else {
return;
}
}
;
;    
switch(defaultType) {
case 0: 
LogWrite("Clearing all fields");
return EventClear(true);
case 1:
LogWrite("Setting the fields to default");
return SetDefaults(true);
case 2:
LogWrite("Keeping previous value");
return KeepPrevious(state);
}
return false;
}
function SetDefaults(ccflag, keepPrevDirtyVal) {
var dirty = Field_GetChanged();
Field_Defaults(1, 0, 0); 
if (keepPrevDirtyVal && !dirty){ 
Field_ClearChangedFromRunProcess(dirty); 
}
if (ccflag) {
EventClearChangeFlag();
}
return ExecuteWorkflow(512);
}
this.SetDefaults=SetDefaults;
function KeepPrevious(state) {
if (state.ns==1) {
if (mFirstStateChange) 
return SetDefaults(true);
for (ii in Form.systemFields)
F(ii).Clear();
EventClearChangeFlag(); 
} else if (state.ns==4) {
if (mFirstStateChange)
return EventClear(true);
}
DAttachmentPool_DoEntryChange(false);
return ExecuteWorkflow(512);
}
function EventCheckChangeFlag(state) {
;
LogWrite("EVENT: CheckChangeFlag");
var changed = Field_GetChanged();
if (changed) {
if (state.cs == 1 || state.cs == 5 || state.cs == 6) {
var res = {};
return {c:{f:ConfirmPopup, a:[ getLocalizedMessage("Do you want to save the current request ?"), res, 1 | 8 | 4]},
n:{f:function() {
;
if (!("v" in res.result) || res.result.v == -1) {
abortTransition(state);
if (state.cs==5) {
var t=Fields[1020];
return {c:{t:t,f:t.RestoreResultsListToPrevSelection,a:[]}};
}
} else if (res.result.v == 1) {
var cs = state.cs;
if (state.cs == 1)
return {c:{f: function() {return {c:{f:Submit}}},e:GenericExcHandler,ea:[state,true]} };
if (state.cs == 5 || state.cs == 6)
return {c:{f: function() {return {c:{f:Modify}}},e:GenericExcHandler,ea:[state,true]} };
}
}}};
}
}
}
function EventClearChangeFlag()
{
LogWrite("EVENT: ClearChangeFlag");
Field_ClearChanged();
}
function EventClearFields(state) {
LogWrite("EventClearFields()");
if (state.ns == 5 || state.ns == 6 || state.ns == 3)
Field_Clear(true);
else {
var defaultType=0;
if (state.ns == 1)
defaultType = ARPrefsGetAsNumber(20101);
else if (state.ns == 4)
defaultType = ARPrefsGetAsNumber(20102);
if (defaultType!=2)
Field_Clear(false);
}
}
function EventClear(ccflag) {
LogWrite("EVENT: Clear");
Field_Clear(false);
if (ccflag) {
EventClearChangeFlag();
}
}
function Query() {
;
;
LogWrite("Query function called");
return {c:{f:EventQuery},n:{f:QueryEntry,a:[5, false]}};
}
this.Query=Query; 
function OpenWindowQuery(mode, qual) {    
;
;
;
;
LogWrite("Query function called");
;
;
return {c:{f:EventQuery},n:{f:QueryEntry,a:[OpenWindowStates[mode][1],OpenWindowStates[mode][2],qual]}};
}
this.OpenWindowQuery=OpenWindowQuery; 
function EventQuery()
{
;
LogWrite("EVENT: Query");
return ExecuteWorkflow(1024);
}
function QueryEntry(state, detailonly, qual) {
LogWrite("Query Entry");
;
;
;
;
var t = Fields[1020];
;
mOpenWindowDetailOnly = detailonly;
var arg;
var arg2="";
var searchStr="";
var ps = null;
if (typeof qual == "undefined") {
var qbefl = Field_GetQBEFieldList();
arg = qbefl.fl;
ps = qbefl.ps;
searchStr = F(1005).G().toString();
if (searchStr != "") {
var params = searchStr.match(SavedSearches.PSP);
if (params!=null) {
for (var i=0; i<params.length; i++) {
var val = params[i];
val = val.substring(1, val.length-1);
if (!ARKWIsKeywordOrEscapedKeyword(val)) {
if (ps==null)
ps = new Object();
ps[val] = val;
}
}        
}
arg2 = searchStr;
}
} else {
arg = qual;
}
var res={};
return {c:{f:function(fl) {
if (fl!=null)
return ParamSearchPopup(res, fl);
}, a:[ps]}, n:{f:function(res, searchStr) {
var origStr = searchStr;
if (res && "result" in res && "v" in res.result) {
for (var id in res.result.v) {
var f = Fields[id];
var v = res.result.v[id].toString();
if (f) { 
if (v!="") {
var v = f.FromUIInput(v,false,true);
arg.AddField(id, v);
}
}
else {
id = id.toRegExp();
var reg = new RegExp("\\$" + id + "\\$", "g");
searchStr = searchStr.replace(reg, v);
}
}
}
else if (ps!=null) {
return;
}
if (searchStr!="")
searchStr = new NDXParseAndEncodeQualifier(ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), ARKWGetStringByIdx(17), searchStr).result;
if (userSearches!=null)
userSearches.SaveRecent(arg.mFields, ps, origStr);
if (state < 100) {
return {c:{t:t,f:t.LoadResultsList, a:[state, arg, searchStr, Form.currentFormVuiId]}, n:{f:ARStateChange, a:[state]}};
}
}, a:[res, arg2]}};
}
this.QueryEntry = QueryEntry;
function EventDisplay(state) {
;
LogWrite("EVENT: Display");
return {c:{f:ExecuteWorkflow,a:[16]}, n:{f:DoEntryChange,a:[0],e:GenericExcHandler,ea:[state,false]}};
}
function EventUndisplay(state) {
;
LogWrite("EVENT: Undisplay");
return {c:{f:ExecuteWorkflow,a:[65536],e:UndisplayExcHandler,ea:[state]}, n:{f:DoEntryChange,a:[1]}};
}
function UndisplayExcHandler(exc,state) {
if ((exc instanceof WorkflowException) && exc.mArg && exc.mArg.length > 0) {
abortTransition(state);
var t=Fields[1020];
return {n:{f:function(){
return {c:{f:MessagePopup,a:[exc.mArg]},n:{t:t,f:t.RestoreResultsListToPrevSelection,a:[]}};
}}};
}
throw exc;
}
function DoEntryChange(state) {
;
;
if (state.ab==1)
return;
return {c:{f:DTable_DoEntryChange,a:[state]}, n:{f:DAttachmentPool_DoEntryChange,a:[true]}};
}
function EventLoadEntry(state) {
;
var table = Fields[1020];
;
;
;
var row = table.GetRow();
if (row == -1) {
Field_Clear(true);
Field_ClearChanged();
} else {
;
;
LogWrite("LoadEntry: row=" + row + " id=" + table.mResult.r[row].i);
Field_LoadEntry(table.mResult.r[row].i, false, true);
}
}
function EventShowResultsList(state) {
;
LogWrite("EVENT: Show results list");
if (!Form.UseResultsListPane || !mOpenWindowDetailOnly) {
var table = Fields[1020];
;
table.SVis(true);
}
if (!mOpenWindowDetailOnly&&Form.UseResultsListPane)
ShowResultsListPane();
}
function EventHideResultsList(state) {
;
LogWrite("EVENT: Hide results list");
var table = Fields[1020];
;
table.SVis(false);
if (!mOpenWindowDetailOnly&&Form.UseResultsListPane)
HideResultsListPane();
; 
; 
if (!((state.cs == 5 && state.nss.ns == 6)
|| (state.cs == 6 && state.nss.ns == 5)
|| (state.cs == 6 && state.nss.ns == 6)))
table.Clear();
}
function Submit() {
LogWrite("Submit function called");
;
;
return {c:{f:EventSubmit},n:{f:SubmitEntry}};
}
this.Submit=Submit; 
function EventSubmit() {
LogWrite("EVENT: Submit");
;
return ExecuteWorkflow(4);
}
function SubmitEntry() {
LogWrite("Submit Entry");
;
var fl=Field_BuildList(new FieldList(),true,false,true,true);
fl.Push({qual:""},ARKWGetStringByIdx(7),ARKWGetStringByIdx(6),6,4, false, 1);
CurWFC.setStatus(getLocalizedMessage("Submit Successful: ID = {0}",[ARKWGetStringByIdx(14)]));
EventClearChangeFlag();
var retstk={n:{f:EventAfterSubmit}};
if (ARPrefsGetAsNumber(20109)==1)
retstk.c={f:function() { return MessagePopup([{t:0, m:getLocalizedMessage(9504,[ARKWGetStringByIdx(14)]), n:9504,a:null}]);}};
return retstk;
}
function EventAfterSubmit() {
LogWrite("EVENT: After Submit");
;
if(ARPrefsGetAsNumber(20101)!=2&&mAfterWindowLoadedSnapshot!=null) mAfterWindowLoadedSnapshot.Restore();
var eventfunc = AREventFunction(4096);
if (eventfunc) {
var lastId = ARKWGetStringByIdx(14);
if (lastId != "") { 
var wfcNotes=CurWFC.notes;
CurWFC.notes=[];
Field_LoadEntry(lastId, true, false);
CurWFC.notes=wfcNotes;
}
return {c:{f:ExecuteWorkflow, a:[eventfunc]}, n:{f:AfterSubmitP2}};
}
return {n:{f:AfterSubmitP2}};
}
function AfterSubmitP2() {
LogWrite("After submit phase 2");
;
switch(ARPrefsGetAsNumber(20101)) {
case 1:
return {c:{f:SetDefaults, a:[true]}, n:{f:ExecuteWorkflow, a:[262144]}};
case 2:
for (ii in Form.systemFields)
F(ii).Clear();
EventClearChangeFlag();
break;
case 0:
EventClear(true);
break;
}
return ExecuteWorkflow(262144);
}
function Modify() {
LogWrite("In Modify function");
;
;
if ((ARStateCurrent == 5))
return {c:{f:EventModify}, n:{f:ModifyEntry}};
else {
return {n:{f:ModifyAllEntries}};
}
}
this.Modify=Modify; 
function EventModify() {
LogWrite("EVENT: Modify");
;
return ExecuteWorkflow(8);
}
function ModifyEntry() {
LogWrite("Modify Entry");
;
;
var fl = Field_BuildList(new FieldList(),true,true,false,false);
var entries = [ DBSnapshot.GetDataForID(1).toString() ];
var timestamp = DBSnapshot.ts;
var res = fl.PushEntry(ARKWGetStringByIdx(7),ARKWGetStringByIdx(6),entries,timestamp);
if (res == 0) {
var res = {};
return {c:{f:ConfirmPopup, a:[ WorkflowContext_StatusToString([{n:9299, t:1, m:null, a:null}]), res, 8 | 4]},
n:{f:function() {
;
if (("v" in res.result) && res.result.v == 1) {
fl.PushEntry(ARKWGetStringByIdx(7),ARKWGetStringByIdx(6),entries,0);
return {n:{f:ModifyEntryContinuation}};
} else
return;
}
}};
}
return {n:{f:ModifyEntryContinuation}};
}
function ModifyEntryContinuation() {
EventClearChangeFlag(); 
return {c:{f:EventAfterModify}, n:{f:EventClearChangeFlag}};
}
function ModifyAllEntries() {
LogWrite("Modify All Entries");
;
;
var fl = Field_BuildList(new FieldList(),true,false,true,false);
var table = Fields[1020];
;
var entries = [];
for (var i in table.mLastRowSelections)
entries.push(table.TagFromRowNo(parseInt(i)));
var msg;
if (entries.length == 1)
msg = getLocalizedMessage("This operation will modify 1 entry. Continue?");
else
msg = getLocalizedMessage("This operation will modify {0} entries. Continue?", [entries.length]);
var res = {};
return {c:{f:ConfirmPopup, a:[ msg, res, 4 | 8]},
n:{f:function() {
;
if ("v" in res.result && res.result.v == 1) {
EventClearChangeFlag(); 
var result = fl.PushEntry(ARKWGetStringByIdx(7),ARKWGetStringByIdx(6),entries,0);
;
if (entries.length == 1)
msg = getLocalizedMessage("1 entry modified");
else	
msg = getLocalizedMessage("{0} entries modified", [entries.length]);
CurWFC.setStatus(msg);
}
}}};
}
function EventAfterModify() {
LogWrite("EVENT: After Modify");
;
var wfcNotes=CurWFC.notes; 
CurWFC.notes=[];
Field_LoadEntry(DBSnapshot.GetDataForID(1).toString(), false, false);
CurWFC.notes=wfcNotes;
return ExecuteWorkflow(2048);
}
}
}
function ExecuteWorkflow(evt, id) {
;
; 
;
if (typeof evt == "number")
evt = AREventFunction(evt, id);
if (evt)
return CurWFC.execute({f: evt});
}

var MessageTypes = {
1: { i:"exclamation", m:getLocalizedMessage("BMC Remedy User - Warning") },
0: { i:"info", m:getLocalizedMessage("BMC Remedy User - Note") },
2: { i:"error", m:getLocalizedMessage("BMC Remedy User - Error") },
3: { i:"error", m:getLocalizedMessage("BMC Remedy User - Error") }
};
function MessagePopup(status) {
;
;
var msgstr = WorkflowContext_StatusToString(status);
return weOpenModalPopup((AbsContextPath + "resources/html/MessagePopup.html"),"Message",{title:MessageTypes[status[0].t].m, status:status, msg:msgstr, image:MessageTypes[status[0].t].i, btn:2, appss:GetAppStyleSheet("../../"),acc:0}, {}, [360,150]);
}
function ConfirmPopup(msg, res, buttons) {
;
;
;
;
return weOpenModalPopup((AbsContextPath + "resources/html/MessagePopup.html"),"Confirm",{title:getLocalizedMessage("Confirm Save Request"), image:"exclamation", status:null, msg:msg, btn:buttons, appss:GetAppStyleSheet("../../"), acc:0}, res, [360,150]);
}

var PREFS;
function ARPrefsReplaceAll(newPrefs) {
;
PREFS=newPrefs;
}
function ARPrefsGetAsString(id) {
;
if (!(id in PREFS)) 
return null;
return PREFS[id];
}
function ARPrefsSetAsString(id, val) {
;
;
PREFS[id] = val;
}
function ARPrefsGetAsNumber(id) {
;
if (!(id in PREFS)) 
return null;
var ret=PREFS[id];
return parseInt(ret);
}
function ARPrefsSetAsNumber(id, val) {
;
;
PREFS[id] = val+""; 
}
function ARPrefsSetAsNull(id) {
;
PREFS[id] = null;
}
function ARPrefsSet(id, key, value) {
;
;
if (!key) {
key = "";
}
if (!value) {
value = "";
}
var req = new NDXSetARUserPreference(id, key, value);
return req.result;
}
var VP;
function ARPrefsGet(id, key) {
;
;
if (!(id in PREFS)) {
if (!key) {
key = "";
}
var req = new NDXGetARUserPreference(id, key);
}
var val = PREFS[id];
if (key && val) {
val = val.toString();
VP = new RegExp(key + "=([^\n]*)\n","m");
var params = val.match(VP);
val = params[1];
}
return val;
}
function ARPrefsRefresh(flag) {
;
new NDXRefreshARUserPreferences(flag);
}

NDXRequest.prototype.constructor=NDXRequest;;
function GET_XML_HTTP()
{
var _fo;
try {
_fo=new XMLHttpRequest(); 
} 
catch(e) {
try {
_fo=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
_fo=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
;
}
}
}
return _fo;
}
function NDXRequest(obj) {
if(arguments.length) {
;
this.init(obj);
}
}
NDXRequest.prototype.init=function() {
; 
var buff=[];
buff.push("/");
buff.push(arguments[0]);
buff.push("/");
var typeencoders={
"string": function(b,o) { b.push(o.length); b.push("/"); b.push(o); },
"boolean":function(b,o) { b.push("1"); b.push("/"); b.push(o?"1":"0"); },
"number": function(b,o) { var ns=""+o; b.push(""+ns.length); b.push("/"); b.push(ns); }
};
for(var i=1;i<arguments.length;++i) {
var ai=arguments[i];
if(ai instanceof Array) {
var l=ai.length;
var abuff=[];
abuff.push(l);
abuff.push("/");
if(l>0) {
var encoder=typeencoders[typeof ai[0]]; 
;
for(var j=0;j<l;++j)
encoder(abuff,ai[j]);
}
var buffstr=abuff.join("");
typeencoders["string"](buff,buffstr);
} else
typeencoders[typeof ai](buff,ai);
}
var finalbuff=buff.join("");
finalbuff=(finalbuff.length-1)+finalbuff; 
var retry = false;
do {
var fetcher;
fetcher = GET_XML_HTTP();
;
var finalbuffuri;
if (!retry) {
finalbuffuri=encodeURIComponent(finalbuff);
}
else {
retry = false;
}
var ctxtpath=(AbsContextPath + "BackChannel/"),param="?param=";
;
if(ctxtpath.length+param.length+finalbuffuri.length>2047) 
fetcher.open("POST",ctxtpath,false);
else {
fetcher.open("GET",ctxtpath+param+finalbuffuri,false);
finalbuff=null;
}
fetcher.setRequestHeader("Content-type","text/plain; charset=UTF-8");
try {
var d = new Date();
;
fetcher.send(finalbuff);
} catch(e) {
;
;
;
;
;
;
;
CurWFC.status(9351);
}
var d = new Date();
;
;
;
;
;
if(fetcher.readyState==4&&fetcher.statusText=="OK"&&fetcher.responseText) {
if(fetcher.responseText.indexOf("this.result=") == -1 && fetcher.responseText.indexOf("CurWFC.status") == -1 && fetcher.responseText.indexOf("retry=") == -1){
LogAndAlert(getLocalizedMessage("9389",null,null));
throw new WorkflowException(0,[]);
}
else
eval(fetcher.responseText);
}
else 
CurWFC.status(9351);
} while (retry);
}
NDXRequest.prototype.result=null;
NDXRequest.prototype.GetResult=function() {
;
return this.result;
}
NDXRequest.prototype.Override=function(err) {
var res = confirm(WorkflowContext_StatusToString(err) + "\n" + getLocalizedMessage("Do you wish to override?"));
if (res == false) {
throw new WorkflowException(0,[]);
}
var req = new NDXSetOverride(true);
return true;
}

NDXGetEntryList.prototype=new NDXRequest(); NDXGetEntryList.prototype.constructor=NDXGetEntryList; NDXGetEntryList.superclass=NDXRequest.prototype;;
function NDXGetEntryList(current_server,current_schema,server,schema,app_name,qualification,qual_field_ids,qual_field_values,qual_field_types,no_match_opt,multi_match_opt,fields) {
if(arguments.length) {
;
this.init('GetEntryList',current_server,current_schema,server,schema,app_name,qualification,qual_field_ids,qual_field_values,qual_field_types,no_match_opt,multi_match_opt,fields);
}
}
NDXSetEntryList.prototype=new NDXRequest(); NDXSetEntryList.prototype.constructor=NDXSetEntryList; NDXSetEntryList.superclass=NDXRequest.prototype;;
function NDXSetEntryList(current_server,current_schema,server,schema,cur_entry_id,qualification,qual_field_ids,qual_field_values,qual_field_types,no_match_opt,multi_match_opt,like_id,fields,field_values,field_types) {
if(arguments.length) {
;
this.init('SetEntryList',current_server,current_schema,server,schema,cur_entry_id,qualification,qual_field_ids,qual_field_values,qual_field_types,no_match_opt,multi_match_opt,like_id,fields,field_values,field_types);
}
}
NDXGetEntry.prototype=new NDXRequest(); NDXGetEntry.prototype.constructor=NDXGetEntry; NDXGetEntry.superclass=NDXRequest.prototype;;
function NDXGetEntry(server,schema,app_name,screen_name,entry_id,fields,deferLargeDiary) {
if(arguments.length) {
;
this.init('GetEntry',server,schema,app_name,screen_name,entry_id,fields,deferLargeDiary);
}
}
NDXSetEntry.prototype=new NDXRequest(); NDXSetEntry.prototype.constructor=NDXSetEntry; NDXSetEntry.superclass=NDXRequest.prototype;;
function NDXSetEntry(server,schema,screen_name,entry_ids,timestamp,fields,field_values,field_types) {
if(arguments.length) {
;
this.init('SetEntry',server,schema,screen_name,entry_ids,timestamp,fields,field_values,field_types);
}
}
NDXGetSQLEntryList.prototype=new NDXRequest(); NDXGetSQLEntryList.prototype.constructor=NDXGetSQLEntryList; NDXGetSQLEntryList.superclass=NDXRequest.prototype;;
function NDXGetSQLEntryList(server,action_name,action_idx,no_match_opt,multi_match_opt,keyword_ids,keyword_values,keyword_types,field_ids,field_values,field_types,is_action) {
if(arguments.length) {
;
this.init('GetSQLEntryList',server,action_name,action_idx,no_match_opt,multi_match_opt,keyword_ids,keyword_values,keyword_types,field_ids,field_values,field_types,is_action);
}
}
NDXDeleteEntry.prototype=new NDXRequest(); NDXDeleteEntry.prototype.constructor=NDXDeleteEntry; NDXDeleteEntry.superclass=NDXRequest.prototype;;
function NDXDeleteEntry(server,form,entries) {
if(arguments.length) {
;
this.init('DeleteEntry',server,form,entries);
}
}
NDXCompileQualification.prototype=new NDXRequest(); NDXCompileQualification.prototype.constructor=NDXCompileQualification; NDXCompileQualification.superclass=NDXRequest.prototype;;
function NDXCompileQualification(server,schema,vui,qualification) {
if(arguments.length) {
;
this.init('CompileQualification',server,schema,vui,qualification);
}
}
NDXCompileExternalQualification.prototype=new NDXRequest(); NDXCompileExternalQualification.prototype.constructor=NDXCompileExternalQualification; NDXCompileExternalQualification.superclass=NDXRequest.prototype;;
function NDXCompileExternalQualification(current_server,current_schema,current_vui,remote_server,remote_schema,qualification,qual_field_ids,qual_field_values,qual_field_types) {
if(arguments.length) {
;
this.init('CompileExternalQualification',current_server,current_schema,current_vui,remote_server,remote_schema,qualification,qual_field_ids,qual_field_values,qual_field_types);
}
}
NDXServerRunProcess.prototype=new NDXRequest(); NDXServerRunProcess.prototype.constructor=NDXServerRunProcess; NDXServerRunProcess.superclass=NDXRequest.prototype;;
function NDXServerRunProcess(server,al_name,act_idx,ts,fid,keyword_ids,keyword_vals,keyword_types,field_ids,field_vals,field_types) {
if(arguments.length) {
;
this.init('ServerRunProcess',server,al_name,act_idx,ts,fid,keyword_ids,keyword_vals,keyword_types,field_ids,field_vals,field_types);
}
}
NDXExpandMenu.prototype=new NDXRequest(); NDXExpandMenu.prototype.constructor=NDXExpandMenu; NDXExpandMenu.superclass=NDXRequest.prototype;;
function NDXExpandMenu(name,server,schema,rServer,rSchema,qualification,qual_field_ids,qual_field_values,qual_field_types,field_ids,field_values,field_types,keyword_ids,keyword_vals,keyword_types) {
if(arguments.length) {
;
this.init('ExpandMenu',name,server,schema,rServer,rSchema,qualification,qual_field_ids,qual_field_values,qual_field_types,field_ids,field_values,field_types,keyword_ids,keyword_vals,keyword_types);
}
}
NDXGetMenuDefinition.prototype=new NDXRequest(); NDXGetMenuDefinition.prototype.constructor=NDXGetMenuDefinition; NDXGetMenuDefinition.superclass=NDXRequest.prototype;;
function NDXGetMenuDefinition(name,server) {
if(arguments.length) {
;
this.init('GetMenuDefinition',name,server);
}
}
NDXGetARUserPreference.prototype=new NDXRequest(); NDXGetARUserPreference.prototype.constructor=NDXGetARUserPreference; NDXGetARUserPreference.superclass=NDXRequest.prototype;;
function NDXGetARUserPreference(fieldID,prefKey) {
if(arguments.length) {
;
this.init('GetARUserPreference',fieldID,prefKey);
}
}
NDXSetARUserPreference.prototype=new NDXRequest(); NDXSetARUserPreference.prototype.constructor=NDXSetARUserPreference; NDXSetARUserPreference.superclass=NDXRequest.prototype;;
function NDXSetARUserPreference(fieldID,prefKey,value) {
if(arguments.length) {
;
this.init('SetARUserPreference',fieldID,prefKey,value);
}
}
NDXRefreshARUserPreferences.prototype=new NDXRequest(); NDXRefreshARUserPreferences.prototype.constructor=NDXRefreshARUserPreferences; NDXRefreshARUserPreferences.superclass=NDXRequest.prototype;;
function NDXRefreshARUserPreferences(flag) {
if(arguments.length) {
;
this.init('RefreshARUserPreferences',flag);
}
}
NDXGetURLForForm.prototype=new NDXRequest(); NDXGetURLForForm.prototype.constructor=NDXGetURLForForm; NDXGetURLForForm.superclass=NDXRequest.prototype;;
function NDXGetURLForForm(server,app_name,form,view,fetch_dimensions,win_name,win_arg) {
if(arguments.length) {
;
this.init('GetURLForForm',server,app_name,form,view,fetch_dimensions,win_name,win_arg);
}
}
NDXGetTableEntryList.prototype=new NDXRequest(); NDXGetTableEntryList.prototype.constructor=NDXGetTableEntryList; NDXGetTableEntryList.superclass=NDXRequest.prototype;;
function NDXGetTableEntryList(table_server,table_schema,table_vui_name,table_field_id,server,schema,app_name,start_row,num_rows,sort_order,qualification,qual_field_ids,qual_field_values,qual_field_types) {
if(arguments.length) {
;
this.init('GetTableEntryList',table_server,table_schema,table_vui_name,table_field_id,server,schema,app_name,start_row,num_rows,sort_order,qualification,qual_field_ids,qual_field_values,qual_field_types);
}
}
NDXGetQBETableEntryList.prototype=new NDXRequest(); NDXGetQBETableEntryList.prototype.constructor=NDXGetQBETableEntryList; NDXGetQBETableEntryList.superclass=NDXRequest.prototype;;
function NDXGetQBETableEntryList(table_server,table_schema,table_vui_name,table_field_id,server,schema,app_name,start_row,num_rows,sort_order,field_ids,field_values,field_types,encodedQual,vuiId) {
if(arguments.length) {
;
this.init('GetQBETableEntryList',table_server,table_schema,table_vui_name,table_field_id,server,schema,app_name,start_row,num_rows,sort_order,field_ids,field_values,field_types,encodedQual,vuiId);
}
}
NDXGetGuideServerAndForm.prototype=new NDXRequest(); NDXGetGuideServerAndForm.prototype.constructor=NDXGetGuideServerAndForm; NDXGetGuideServerAndForm.superclass=NDXRequest.prototype;;
function NDXGetGuideServerAndForm(guide_server,guide_name) {
if(arguments.length) {
;
this.init('GetGuideServerAndForm',guide_server,guide_name);
}
}
NDXGetCurrencyExchangeRates.prototype=new NDXRequest(); NDXGetCurrencyExchangeRates.prototype.constructor=NDXGetCurrencyExchangeRates; NDXGetCurrencyExchangeRates.superclass=NDXRequest.prototype;;
function NDXGetCurrencyExchangeRates(server,date) {
if(arguments.length) {
;
this.init('GetCurrencyExchangeRates',server,date);
}
}
NDXGetPushFieldTypes.prototype=new NDXRequest(); NDXGetPushFieldTypes.prototype.constructor=NDXGetPushFieldTypes; NDXGetPushFieldTypes.superclass=NDXRequest.prototype;;
function NDXGetPushFieldTypes(server,form,field_ids) {
if(arguments.length) {
;
this.init('GetPushFieldTypes',server,form,field_ids);
}
}
NDXGetServerTimestamp.prototype=new NDXRequest(); NDXGetServerTimestamp.prototype.constructor=NDXGetServerTimestamp; NDXGetServerTimestamp.superclass=NDXRequest.prototype;;
function NDXGetServerTimestamp(server) {
if(arguments.length) {
;
this.init('GetServerTimestamp',server);
}
}
NDXMarkAlert.prototype=new NDXRequest(); NDXMarkAlert.prototype.constructor=NDXMarkAlert; NDXMarkAlert.superclass=NDXRequest.prototype;;
function NDXMarkAlert(server,schema,ids,read) {
if(arguments.length) {
;
this.init('MarkAlert',server,schema,ids,read);
}
}
NDXParseAndEncodeQualifier.prototype=new NDXRequest(); NDXParseAndEncodeQualifier.prototype.constructor=NDXParseAndEncodeQualifier; NDXParseAndEncodeQualifier.superclass=NDXRequest.prototype;;
function NDXParseAndEncodeQualifier(server,form,view,qualifier) {
if(arguments.length) {
;
this.init('ParseAndEncodeQualifier',server,form,view,qualifier);
}
}
NDXParseAndEvaluateQualifier.prototype=new NDXRequest(); NDXParseAndEvaluateQualifier.prototype.constructor=NDXParseAndEvaluateQualifier; NDXParseAndEvaluateQualifier.superclass=NDXRequest.prototype;;
function NDXParseAndEvaluateQualifier(server,form,view,qualification,qual_field_ids,qual_field_values,qual_field_types) {
if(arguments.length) {
;
this.init('ParseAndEvaluateQualifier',server,form,view,qualification,qual_field_ids,qual_field_values,qual_field_types);
}
}
NDXGetFieldDefaults.prototype=new NDXRequest(); NDXGetFieldDefaults.prototype.constructor=NDXGetFieldDefaults; NDXGetFieldDefaults.superclass=NDXRequest.prototype;;
function NDXGetFieldDefaults(server,form,field_ids) {
if(arguments.length) {
;
this.init('GetFieldDefaults',server,form,field_ids);
}
}
NDXSetOverride.prototype=new NDXRequest(); NDXSetOverride.prototype.constructor=NDXSetOverride; NDXSetOverride.superclass=NDXRequest.prototype;;
function NDXSetOverride(override) {
if(arguments.length) {
;
this.init('SetOverride',override);
}
}
NDXSaveSearch.prototype=new NDXRequest(); NDXSaveSearch.prototype.constructor=NDXSaveSearch; NDXSaveSearch.superclass=NDXRequest.prototype;;
function NDXSaveSearch(name,server,schema,field_ids,field_values,newrecord,changeState,disable,type) {
if(arguments.length) {
;
this.init('SaveSearch',name,server,schema,field_ids,field_values,newrecord,changeState,disable,type);
}
}
NDXDeleteSearch.prototype=new NDXRequest(); NDXDeleteSearch.prototype.constructor=NDXDeleteSearch; NDXDeleteSearch.superclass=NDXRequest.prototype;;
function NDXDeleteSearch(server,schema,names) {
if(arguments.length) {
;
this.init('DeleteSearch',server,schema,names);
}
}
NDXSaveTableSettings.prototype=new NDXRequest(); NDXSaveTableSettings.prototype.constructor=NDXSaveTableSettings; NDXSaveTableSettings.superclass=NDXRequest.prototype;;
function NDXSaveTableSettings(server,schema,vui,table_id,col_ids,col_values,sortOrder) {
if(arguments.length) {
;
this.init('SaveTableSettings',server,schema,vui,table_id,col_ids,col_values,sortOrder);
}
}

var pattern_newLn = /\n/g;
var pattern_carRet = /\r/g;
var pattern_carRetNewLn = /\r\n/g;
var const_newLn = "\n";
var const_carRet = "\r";
var const_carRetNewLn = "\r\n";
function ARFuncSilentFail() 
{
CurWFC.status(0);
}
function ARFuncUpper(val) 
{
;
if (val.isNull)
return val;
return new CharType(val.toString().toUpperCase());
}
function ARFuncLower(val)
{
;
if (val.isNull)
return val;
return new CharType(val.toString().toLowerCase());
}
function ARFuncDate(val)
{
;
if (val.isNull)
return Null;
return new CharType(new TimeType(val.toString()).toString(2));
}
function ARFuncTime(val)
{
;
if (val.isNull)
return Null;
return new CharType(new TimeType(val.toString()).toTOD());
}
function ARFuncMonth(val)
{
;
if (val.isNull)
return Null;
var d = ARDate.parseDateTime(new TimeType(val.toString()).toString());
return new IntegerType(d.GMonth()+1); 
}
function ARFuncDay(val)
{
;
if (val.isNull)
return Null;
var d = ARDate.parseDateTime(new TimeType(val.toString()).toString());
return new IntegerType(d.GDate());
}
function ARFuncYear(val)
{
;
if (val.isNull)
return Null;
var d = ARDate.parseDateTime(new TimeType(val.toString()).toString());
return new IntegerType(d.GYear());
}
function ARFuncWeekday(val)
{
;
if (val.isNull)
return Null;
var d = ARDate.parseDateTime(new TimeType(val.toString()).toString());
return new IntegerType(d.GDay()+1); 
}
function ARFuncHour(val)
{
;
if (val.isNull)
return Null;
var d = ARDate.parseDateTime(new TimeType(val.toString()).toString());
return new IntegerType(d.GHour());
}
function ARFuncMinute(val)
{
;
if (val.isNull)
return Null;
var d = ARDate.parseDateTime(new TimeType(val.toString()).toString());
return new IntegerType(d.GMinute());
}
function ARFuncSecond(val)
{
;
if (val.isNull)
return Null;
var d = ARDate.parseDateTime(new TimeType(val.toString()).toString());
return new IntegerType(d.GSecond());
}
function ARFuncTrunc(val)
{
;
return val.TRUNC();
}
function ARFuncRound(val)
{
;
val = val.ROUND();
if (val.isNull)
return Null;
return new IntegerType(val);
}
function ARFuncConvert()
{
Log("ARFuncConvert() - unsupported");
CurWFC.status(9369);
}
function ARFuncLength(val)
{
return ARFuncLengthC(val);
}
function ARFuncSubstr(string0, num0, num1)
{
return ARFuncSubstrC(string0, num0, num1);
}
function ARFuncLeft(string, num)
{
return ARFuncLeftC(string, num);
}
function ARFuncRight(string, num)
{
return ARFuncRightC(string, num);
}
function ARFuncLTrim(val)
{
;
if (val.isNull)
return val;
var res = val.toString().trim(1, true);
return (res != "") ? new CharType(res) : Null;
}
function ARFuncRTrim(val)
{
;
if (val.isNull)
return val;
var res = val.toString().trim(2, true);
return (res != "") ? new CharType(res) : Null;
}
function ARFuncLPad(string0, num, string1)
{
return ARFuncLPadC(string0, num, string1);
}
function ARFuncRPad(string0, num, string1)
{
return ARFuncRPadC(string0, num, string1);
}
function ARFuncReplace(val0, val1, val2)
{
;
if (val0.isNull || val1.isNull)
return Null;
if (val1.toString() == "") {
return val0;
}
var string0  = val0.toString();
var string1  = val1.toString();
var string2  = val2.toString();
var result = string0;
var newLn = /\n/g;
var carRetNewLn = /\r\n/g;
if(newLn.test(string1)){    
if(carRetNewLn.test(string0)){  
result = string0.replace(carRetNewLn,string2);
} else if(newLn.test(string0)){  
result = string0.replace(newLn,string2);
} else {
}
} else {
var re = new RegExp(string1.toRegExp(),"g");
result = string0.replace(re,string2);
}
return (result != "") ? new CharType(result) : Null;
}
function ARFuncStrstr(string0, string1)
{
return ARFuncStrstrC(string0, string1);
}
function ARFuncMin() {
var args = new Array(arguments.length + 1);
args[0] = "LT";
for (var i = 0; i < arguments.length; ++i)
args[i+1] = arguments[i];
return ARFunc_MinMax.apply(null, args);
}
function ARFuncMax() {
var args = new Array(arguments.length + 1);
args[0] = "GT";
for (var i = 0; i < arguments.length; ++i)
args[i+1] = arguments[i];
return ARFunc_MinMax.apply(null, args);
}
function ARFunc_MinMax(relop) { 
;
;
var result;
for (var i = 1; i < arguments.length; ++i) {
var v = arguments[i];
if (v.isNull) return Null;
if (!result || v[relop](result))
result = v;
}
if (!result)
result = Null;
return result;
}
function ARFunc_ColSumAvg(field, avg) {
;
;
if (field instanceof JColumn) { 
if (field.IsTimeRelatedField())
return Null; 
var table = field.getTable();
;
var count = 0;
var oldrow = table.GetRow();
var result = new RealType(0);
if (field.GetType() == 12) {
var dataField = field.GetDataField();
result = new CurrencyType("0", dataField);
result.mCurCode = dataField.GetDefaultCurrency();
if (dataField.mFunctional == null || dataField.mFunctional[result.mCurCode] == null)
result.mCurCode = null;
result.mPrecision = dataField.GetPrecision(result.mCurCode);
}
for (var i = 0; i < table.GetRows(); ++i) {
table.SetRow(i);
var v = field.G();
if (!v.isNull) {
if (result.mCurCode == null && v.type == 12)
result.mCurCode = v.mCurCode;
result.ADD(result, v);
++count;
}
}
table.SetRow(oldrow);
if (count == 0)
return Null;
if (avg)
result.DIV(result, new RealType(count));
return result;
} else if(field==DummyField) 
return Null;
else
CurWFC.status(9368);
}
function ARFuncColSum(field) {
return ARFunc_ColSumAvg(field, false);
}
function ARFuncColAvg(field) {
return ARFunc_ColSumAvg(field, true);
}
function ARFuncColCount(field) {
;
if (field instanceof JColumn) { 
var table = field.getTable();
;
if (!table.IsRefreshed())
return Null;
var count = 0;
var oldrow = table.GetRow();
for (var i = 0; i < table.GetRows(); ++i) {
table.SetRow(i);
var v = field.G();
if (!v.isNull)
++count;
}
table.SetRow(oldrow);
return new IntegerType(count);
} else if (field instanceof DTable) {
if (!field.IsRefreshed())
return Null;
var rows = field.GetRows();
return new IntegerType(rows);
} else if(field==DummyField) 
return Null;
else
CurWFC.status(9368);
}
function ARFunc_ColMinMax(field, relop) {
;
;
if (field instanceof JColumn) { 
var table = field.getTable();
;
if (table.GetRows() == 0)
return Null;
var oldrow = table.GetRow();
var result;
for (var i = 0; i < table.GetRows(); ++i) {
table.SetRow(i);
var v = field.G();
if (!v.isNull && (!result || v[relop](result)))
result = v;
}
table.SetRow(oldrow);
if (!result)
result = Null;
return result;
} else if(field==DummyField) 
return Null;
else
CurWFC.status(9368);
}
function ARFuncColMin(field) {
return ARFunc_ColMinMax(field, "LT");
}
function ARFuncColMax(field) {
return ARFunc_ColMinMax(field, "GT");
}
function ARFuncDateAdd(datepart, number, date)
{
;
; 
;
if (datepart.isNull || number.isNull || date.isNull)
return Null;
datepart = datepart.toString();
number = new IntegerType(number.toInteger());
date = date.toDate();
if (ARFuncIsDatepartDay(datepart))
return date.ADD(date, number);
else if (ARFuncIsDatepartWeek(datepart))
return date.ADDWEEKS(number);
else if (ARFuncIsDatepartMonth(datepart))
return date.ADDMONTHS(number);
else if (ARFuncIsDatepartYear(datepart))
return date.ADDYEARS(number);
return Null;
}
function ARFuncDateDiff(datepart, startdate, enddate)
{
;
; 
;
if (datepart.isNull || startdate.isNull || enddate.isNull)
return Null;
datepart = datepart.toString();
startdate = startdate.toDate();
enddate = enddate.toDate();
if (ARFuncIsDatepartDay(datepart)) {
return new IntegerType(enddate.toInteger() - startdate.toInteger());
}
else if (ARFuncIsDatepartWeek(datepart)) {
return new IntegerType(Math.floor((enddate.toInteger() - startdate.toInteger())/7));
}
return Null;
}
function ARFuncDateName(datepart, date)
{
;
; 
if (datepart.isNull || date.isNull)
return Null;
datepart = datepart.toString();
var ardate = ARDate.parseDate(date.toString());
if (ardate == null)
return Null;
if (ARFuncIsDatepartMonth(datepart))
return new CharType(ARDate.MonthLabel(ardate.GMonth()));
else if (ARFuncIsDatepartWeekday(datepart))
return new CharType(ardate.DayLong());
return Null;
}
function ARFuncDateNum(datepart, date)
{
;
; 
if (datepart.isNull || date.isNull)
return Null;
datepart = datepart.toString();
var ardate = ARDate.parseDateTime(date.toString());
if (ardate == null)
return Null;
if (ARFuncIsDatepartYear(datepart))
return new IntegerType(ardate.GYear());
else if (ARFuncIsDatepartMonth(datepart))
return new IntegerType(ardate.GMonth()+1);
else if (ARFuncIsDatepartDay(datepart))
return new IntegerType(ardate.GDate());
else if (ARFuncIsDatepartWeek(datepart))
return new IntegerType(ardate.GWeekNumber());
else if (ARFuncIsDatepartWeekday(datepart))
return new IntegerType(ardate.GDay()+1);
return Null;
}
function ARFuncCurrConvert(curVal, type, date)
{
if (curVal.isNull || type.isNull || date.isNull)
return Null;
;
return curVal.CurrConvert(type.toString(), date.toInteger());
}
function ARFuncCurrSetDate(curVal, date)
{
if (curVal.isNull || date.isNull)
return Null;
;
return curVal.CurrSetDate(date.toTime().toInteger());
}
function ARFuncCurrSetType(curVal, type)
{
if (curVal.isNull || type.isNull)
return Null;
;
return curVal.CurrSetType(type);
}
function ARFuncCurrSetValue(curVal, val)
{
if (curVal.isNull || val.isNull)
return Null;
;
return curVal.CurrSetValue(val.toDecimal());
}
function ARFuncLengthC(val)
{
;
if (val.isNull)
return val;
return new IntegerType(val.toString().length);
}
function ARFuncLeftC(val0, val1)
{
;
if (val0.isNull || val1.isNull)
return Null;
var string = val0.toString();
var num    = val1.toInteger();
var res = string.substring(0, num);
return (res != "") ? new CharType(res) : Null;
}
function ARFuncRightC(val0, val1)
{
;
if (val0.isNull || val1.isNull)
return Null;
var string = val0.toString();
var num    = val1.toInteger();
var res = string.substring(string.length - num);
return (res != "") ? new CharType(res) : Null;
}
function ARFuncLPadC(val0, val1, val2)
{
;
if (val0.isNull || val1.isNull || val2.isNull)
return Null;
var string0 = val0.toString();
var num     = val1.toInteger();
var string1 = val2.toString();
if (string1 == "")
return val0;
var result = string1;
var nPad   = num - string0.length;
while (nPad > result.length) {
result += string1;
}
var res = result.substring(0, nPad) + string0;
return (res != "") ? new CharType(res) : Null;
}
function ARFuncRPadC(val0, val1, val2)
{
;
if (val0.isNull || val1.isNull || val2.isNull)
return Null;
var string0 = val0.toString();
var num     = val1.toInteger();
var string1 = val2.toString();
if (string1 == "")
return val0;
var result = string1;
var nPad   = num - string0.length;
while (nPad > result.length) {
result += string1;
}
var res = string0 + result.substring(0, nPad);
return (res != "") ? new CharType(res) : Null;
}
function ARFuncStrstrC(val0, val1)
{
;
if (val0.isNull || val1.isNull)
return Null;
var string0 = val0.toString();
var string1 = val1.toString();
if(string1.indexOf(const_newLn)!= -1 && string0.indexOf(const_carRetNewLn)!= -1)
string0 = string0.replace(pattern_carRet,"");
return new IntegerType(string0.indexOf(string1));
}
function ARFuncSubstrC(val0, val1, val2)
{
;
if (val0.isNull || val1.isNull) {
return Null;
}
var string0 = val0.toString();
var start   = val1.toInteger();
var end     = string0.length;
if (start < 0 || start > end ) {
return Null;
}
if (val2 && val2 instanceof Datatype && !(val2.isNull)) {
var endLen = val2.toInteger();
if (endLen < 0 || (endLen+1) == start) { 
return Null;
}
if (endLen >= start && endLen < end) {
end = endLen;
}
}
var res = string0.substring(start, end+1);
return (res != "") ? new CharType(res) : Null;
}
function ARFuncEncrypt()
{
Log("ARFuncEncrypt() - unsupported");
CurWFC.status(9369);
}
function ARFuncDecrypt()
{
Log("ARFuncDecrypt() - unsupported");
CurWFC.status(9369);
}
function ARFuncIsDatepartYear(datepart)
{
datepart = datepart.toLowerCase();
return (datepart == "year" || datepart == "yyyy" || datepart == "yy");
}
function ARFuncIsDatepartMonth(datepart)
{
datepart = datepart.toLowerCase();
return (datepart == "month" || datepart == "mm" || datepart == "m");
}
function ARFuncIsDatepartDay(datepart)
{
datepart = datepart.toLowerCase();
return (datepart == "day" || datepart == "md" || datepart == "dd");
}
function ARFuncIsDatepartWeek(datepart)
{
datepart = datepart.toLowerCase();
return (datepart == "week" || datepart == "wk" || datepart == "ww");
}
function ARFuncIsDatepartWeekday(datepart)
{
datepart = datepart.toLowerCase();
return (datepart == "weekday" || datepart == "wd");
}

var OpenedMenu=null;
function MenuElement(serial,def,submenumap,encode) {
;
this.mSubMenuMap=submenumap;
this.mDef=def;
this.mSerial=serial;
this.mEncode=encode;
}
MenuElement.prototype.mW=MenuElement.prototype.mH=MenuElement.prototype.mRowH=
MenuElement.prototype.mRowCnt=MenuElement.prototype.mScrollDir=
MenuElement.prototype.mScrollTarget=MenuElement.prototype.mRowsPerScreen=
MenuElement.prototype.mOpenPref=MenuElement.prototype.mMinScrollY=0;
MenuElement.prototype.mElement=MenuElement.prototype.mScrollTimer=
MenuElement.prototype.mHighlightedElement=null;
MenuElement.prototype.mNeedToScroll=false;
MenuElement.prototype.BuildAndMeasure=function(open_pref,parent_element, addClear) {
if(this.mElement!=null)
return; 
;
;
;
var myserial=this.mSerial;
var outer=document.createElement("DIV");
outer.className="MenuOuter";
outer.setAttribute("ARMenuElementSerial",""+myserial);
outer.style.zIndex=this.mZIndex+myserial;
outer.style.left=-2000; 
var content=[];
content.push("<DIV class=MenuScrollUp>&#9650;</DIV><DIV class=MenuTableContainer><TABLE class=MenuTable cellpadding=0 cellspacing=0><TBODY class=MenuTableBody>");
var trstyle="<TR class=MenuTableRow>",trstyledis="<TR class=MenuTableRowDisabled>";
var trmkup="<TD class=MenuEntryName nowrap",tdsubmkup="</TD><TD class=MenuEntrySub ARSubMenu=";
var titlemkup=" title=\"",endq="\"",ctagwq="\">",ctag=">",tdnosubmkup="</TD><TD class=MenuEntryNoSub ARValue=\"",closerow="</TD></TR>";
var rtarr="&#9658;";
for(var i in this.mDef) {
var di=this.mDef[i];
;
;
if (di.v==null)
di.v=di.l; 
if ("s" in di&&di.s==0)
content.push(trstyledis);
else
content.push(trstyle);
content.push(trmkup);
var sub = (typeof di.v!="string");
var l = (this.mEncode?di.l.HTMLEncode(): di.l);
if (sub&&(!("s" in di)||di.s==1)) {
content.push(ctag);
content.push(l);
content.push(tdsubmkup);
content.push(i);
content.push(ctag);
content.push(rtarr);
} else {
content.push(ctag);
content.push(di.l==""?"&nbsp;":l); 
content.push(tdnosubmkup);
content.push(this.mEncode?di.v.HTMLEncode():di.v);
content.push(ctagwq);
}
content.push(closerow);
}
if (addClear) {
content.push(trstyle);
content.push(trmkup);
content.push(ctag);
content.push(getLocalizedMessage("(clear)").HTMLEncode());
content.push(tdnosubmkup);
content.push(ctagwq);
}
content.push("</TBODY></TABLE></DIV><DIV class=MenuScrollDown>&#9660;</DIV>");
outer.innerHTML=content.join("");
document.body.appendChild(outer);
this.mElement=outer;
var scrollup=outer.childNodes[0];
var scrolldown=outer.childNodes[2];
var tablediv=outer.childNodes[1];
;
var table=tablediv.firstChild;
;
var tbody=tablediv.firstChild.firstChild;
;
var w=table.offsetWidth,h=table.offsetHeight;
if(open_pref==3&&w<parent_element.offsetWidth)
w=parent_element.offsetWidth;
table.style.width=scrollup.style.width=scrolldown.style.width=w;
scrollup.style.visibility=scrolldown.style.visibility="hidden";
w+=2; h+=2;
outer.style.width=w;
this.mW=w;
this.mH=h;
var row=tbody.firstChild;
if (row == null) {
this.mRowCnt = 0;
this.mRowH = 0;
return;
}
;
var r2=row;
while(r2.nextSibling&&this.mRowH==0) { 
this.mRowH=r2.nextSibling.firstChild.offsetTop-r2.firstChild.offsetTop;
r2=r2.nextSibling;
}
if(this.mRowH==0)
this.mRowH=row.firstChild.offsetHeight;
;
this.mRowCnt=row.parentNode.childNodes.length;
}
MenuElement.prototype.Scroll=function(dir) {
if(!this.mNeedToScroll)
return; 
;
this.mScrollDir=dir;
this.ScrollTimeout();
}
MenuElement.prototype.ScrollToRow=function(row) {
if(!this.mNeedToScroll)
return; 
;
var idx=0;
for(;row;row=row.previousSibling,idx++);
var startRow=-Math.floor(this.mScrollTarget/this.mRowH);
if(idx<=startRow) {
this.DoScroll((startRow-idx+1)*this.mRowH);
} else if(idx>=startRow+this.mRowsPerScreen) {
var delta=Math.floor(idx-(startRow+this.mRowsPerScreen));
this.DoScroll(-delta*this.mRowH);
}
}
MenuElement.prototype.ScrollTimeout=function() {
;
this.DoScroll(this.mScrollDir*this.mRowH);
var initial=(this.mScrollTimer==null);
this.mScrollTimer=setTimeout("OpenedMenu.mElementStack[OpenedMenu.mElementStack.length-1].ScrollTimeout()",initial?150:20);
}
MenuElement.prototype.DoScroll=function(incr) {
;
this.mScrollTarget+=incr;
this.mScrollTarget=(this.mScrollTarget<this.mMinScrollY?this.mMinScrollY:this.mScrollTarget);
this.mScrollTarget=(this.mScrollTarget>0?0:this.mScrollTarget);
var tablediv=this.mElement.childNodes[1];
;
tablediv.style.top=this.mScrollTarget+20;
}
MenuElement.prototype.EndScroll=function() {
if(this.mScrollTimer!=null) {
clearTimeout(this.mScrollTimer);
this.mScrollTimer=null;
}
}
MenuElement.prototype.Close=function() {
;
;
;
if(this.mScrollTimer!=null)
clearTimeout(this.mScrollTimer);
var e=this.mElement;
;
this.UnHighlightElement();
e.style.visibility="hidden";
OpenedMenu.mElementStack.pop();
if(!OpenedMenu.mElementStack.length)
OpenedMenu.Close(); 
}
function GetMenuElemCoords(parent_element,open_pref,xshift,parentmenuw,memberw) {
;
;
var itel = parent_element;
var res=ComputeElementPosition(itel,document.body,0,0);
var x=res.x;
var y=res.y;
var windowt=document.body.scrollTop; 
var windowl=document.body.scrollLeft;
var windowr=document.body.clientWidth+windowl;
;
var orig_x=x;
if(open_pref==0)
x+=parent_element.offsetWidth+xshift;
else if(open_pref==1)
y+=parent_element.offsetHeight;
else if(open_pref==3)
y+=parent_element.offsetHeight;
else {
;
x=orig_x-(memberw+parentmenuw)+parent_element.offsetWidth+xshift;
}
if(parentmenuw!=0) {
if(x+memberw>windowr&&open_pref!=2) {
open_pref=2;
x=orig_x-(memberw+parentmenuw)+parent_element.offsetWidth+xshift;
} else if(x<windowl&&open_pref!=0) {
open_pref=0;
x=orig_x+(parent_element.offsetWidth+xshift);
}
}
y=(y<windowt?windowt:y);
x=(x<windowl?windowl:x);
if(y<0)y=0;
return {x:x,y:y,open_pref:open_pref};
}
MenuElement.prototype.Open=function(parent_element,open_pref,xshift,parentmenuw,zindex,adjust, addClear) {
;
;
this.mZIndex=zindex;
this.BuildAndMeasure(open_pref,parent_element, addClear);
var xy = GetMenuElemCoords(parent_element,open_pref,xshift,parentmenuw,this.mW);
var x=xy.x,y=xy.y;
if (adjust!=null) {
x+=adjust.x;
y+=adjust.y;
}
this.mOpenPref=xy.open_pref;
this.mNeedToScroll=false;
var node=this.mElement;
var windowt=document.body.scrollTop; 
var windowl=document.body.scrollLeft;
var windowb=document.body.clientHeight+windowt; 
var windowr=document.body.clientWidth+windowl;
var windowh=windowb-windowt;
;
;
var menuh=this.mH<windowh?this.mH:windowh;
if(this.mH>menuh) {
this.mNeedToScroll=true;
node.style.height=menuh;
var uparrow=node.childNodes[0],tablediv=node.childNodes[1],downarrow=node.childNodes[2];
;
uparrow.style.height=downarrow.style.height=20;
uparrow.style.visibility=downarrow.style.visibility="inherit";
tablediv.style.top=20;
var targeth=menuh-20*2-2;
if(targeth<this.mRowH)
targeth=this.mRowH;
targeth-=targeth%this.mRowH;
this.mRowsPerScreen=targeth/this.mRowH;
;
; 
menuh=20*2+targeth+2;
downarrow.style.top=menuh-20-2;
this.mMinScrollY=-((this.mRowCnt-this.mRowsPerScreen)*this.mRowH);
}
if(y+menuh>=windowb)
y=windowb-menuh; 
node.style.height=menuh;
if(x+this.mW>=windowr)
x=windowr-this.mW; 
OpenedMenu.mElementStack.push(this);
node.style.visibility="inherit";
node.style.top=y;
node.style.left=x;
}
MenuElement.prototype.HighlightElement=function(e) {
this.UnHighlightElement();
this.mHighlightedElement=e;
var hv="Hover";
for(var ei=e;ei;ei=ei.nextSibling) {
;
if(ei.className.indexOf(hv)==-1)
ei.className+=hv;
}
OpenedMenu.EnsureTopElement(this.mSerial);
this.focusHighlightedElement();
}
MenuElement.prototype.focusHighlightedElement=function() {
if(this.mFocusTimeout)
clearTimeout(this.mFocusTimeout);
this.mFocusTimeout=null;
var e = this.mHighlightedElement;
}
MenuElement.prototype.CheckOpenSubMenu=function() {
if(this.mHighlightedElement==null)
return;  
var e=this.mHighlightedElement;
if(e.nextSibling.getAttribute("ARSubMenu")) {
var newserial=parseInt(e.nextSibling.getAttribute("ARSubMenu"));
; 
newserial=this.mSubMenuMap[newserial];
if(!OpenedMenu.ElementAtTop(newserial))
OpenedMenu.OpenLevel(newserial,e.nextSibling,
this.mOpenPref==2?2:0,
2,this.mW, false);
}
}
MenuElement.prototype.UnHighlightElement=function() {
if(this.mHighlightedElement==null)
return; 
var e=this.mHighlightedElement;
var hv="Hover";
for(var ei=e;ei;ei=ei.nextSibling) {
;
var idx=ei.className.indexOf(hv);
if(idx!=-1)
ei.className=ei.className.substr(0,idx);
}
this.mHighlightedElement=null;
}
MenuElement.prototype.HandleKeyEvent=function(edata) {
var key=edata.key;
if(key==37) { 
if(this.mSerial!=0) {
this.Close();
if (OpenedMenu && OpenedMenu.mElementStack.length > 0) {
OpenedMenu.mElementStack[OpenedMenu.mElementStack.length-1].focusHighlightedElement();
}
}
} else if(key==38) { 
this.AdvanceHighlight(-1);
} else if(key==39) { 
this.CheckOpenSubMenu();
OpenedMenu.mElementStack[OpenedMenu.mElementStack.length-1].AdvanceHighlight(1); 
} else if(key==40) { 
this.AdvanceHighlight(1);
} else if(key==27) { 
OpenedMenu.Close();
} else if(key==13) { 
this.CheckOpenSubMenu();
OpenedMenu.CheckClick();
} else if (key==9) { 
this.focusHighlightedElement();
} else {
if(key>=32&&key<255) {
this.AdvanceHighlightToCharacter(key);
return true;
}
return false; 
}
return true;
}
MenuElement.prototype.AdvanceHighlightToCharacter=function(cc) {
var e=this.mHighlightedElement;
if(e==null)
return; 
var thechar=String.fromCharCode(cc);
thechar=thechar.toLowerCase();
var row=e.parentNode,start=row,wrap=start.parentNode.childNodes[start.parentNode.childNodes.length-1];
;
do {
var cell=row.firstChild;
;
var txt=cell.firstChild;
if(txt!=null&&txt.length>0&&(txt.data.charAt(0).toLowerCase()==thechar)) {
this.HighlightElement(row.firstChild);
this.ScrollToRow(row);
}
row=row.previousSibling;
if(row==null)
row=wrap;
} while(row!=start);
}
MenuElement.prototype.CheckClick=function() {
var e=this.mHighlightedElement;
if(e==null||e.parentNode==null||e.parentNode.className=="MenuTableRowDisabled")
return null; 
var s=e.nextSibling.getAttribute("ARValue");
return s; 
}
MenuElement.prototype.AdvanceHighlight=function(dir) {
;
var e=this.mHighlightedElement;
if(e==null) 
row=this.mElement.childNodes[1].firstChild.firstChild.firstChild;
else {
var row=e.parentNode;
if(dir==1) {
row=row.nextSibling;
if(row==null) 
row=e.parentNode.parentNode.firstChild;
} else if(dir==-1) {
row=row.previousSibling;
if(row==null) { 
var nl=e.parentNode.parentNode.childNodes;
row=nl[nl.length-1];
}
}
}
;
this.HighlightElement(row.firstChild);
this.ScrollToRow(row);
}
MenuElement.prototype.HandleMouseEvent=function(etype,edata) {
var e=edata.element;
var eclass=e.className;
if(eclass==null)
return;
if(etype==1) {
if(e.tagName!="TD"||eclass.indexOf("MenuEntry")==-1) 
return;
this.EndScroll();
;
e=e.parentNode.firstChild; 
this.HighlightElement(e);
this.CheckOpenSubMenu();
} else if(etype==0) {
if(eclass.indexOf("MenuEntry")!=-1)
OpenedMenu.CheckClick();
} else if(etype==2) {
if(e.tagName!="DIV"&&(eclass!="MenuScrollDown"||eclass!="MenuScrollUp"))
return;
var dir=(eclass=="MenuScrollUp")?1:-1;
OpenedMenu.EnsureTopElement(this.mSerial);
this.Scroll(dir);
} else if(etype==3) {
if(e.tagName!="DIV"&&(eclass!="MenuScrollDown"||eclass!="MenuScrollUp"))
return;
OpenedMenu.EnsureTopElement(this.mSerial);
this.EndScroll();
} else {
;
}
return;
}
MenuElement.isGroupMenu=function(fid) {
return (fid==112||fid==104||(fid>=2000&&fid<=2199));
}
Menu.prototype.constructor=Menu;;
function Menu(menudef) {
if(arguments.length)
this.init(menudef);
}
Menu.prototype.init=function(menudef) {
;
this.mMenuDef=menudef;
this.mElements=[];
this.mElementStack=[];
this.mSerialCnt=0;
this.mZIndex=30100;
this.mField = DummyField;
this.mIFrameStack=[];
this.mXAdjust=0;
this.mYAdjust=0;
}
Menu.prototype.ElementAtTop=function(serial) {
; 
return(this.mElementStack[this.mElementStack.length-1].mSerial==serial);
}
Menu.prototype.Open=function(parent,pref,pIndex, addClear) {
;
;
this.RecurBuild(this.mMenuDef)
if(typeof pIndex=="number")
this.mZIndex=pIndex;
this.mSerialCnt=0;
OpenedMenu=this;
OpenedMenu.OpenLevel(0,parent,pref,0,0, addClear);
}
function Menu_Close() {
if(OpenedMenu!=null)
OpenedMenu.Close();
}
Menu.prototype.Close=function() {
;
for(var i=this.mElementStack.length-1;i>=0;--i)
this.mElementStack[i].Close();
for(var i in this.mElements) {
if(this.mElements[i].mElement!=null)
document.body.removeChild(this.mElements[i].mElement);
}
this.mElements=[];
OpenedMenu=null;
}
Menu.prototype.EnsureTopElement=function(serial) {
var es=this.mElementStack;
;
while(es[es.length-1].mSerial!=serial) {
es[es.length-1].Close();
;
}
;
}
Menu.prototype.CheckClick=function() {
var es=this.mElementStack;
;
var val=es[es.length-1].CheckClick();
if (typeof CharFieldMenu != "undefined" && this instanceof CharFieldMenu && this.mQueryReturnedNoValues && val.length != 0) {
Menu_Close();
return;
}
if(val!=null) {
Menu_Close();
this.HandleSelection(val);
}
}
Menu.prototype.OpenLevel=function(serial,elem,pref,gap,shift, addClear) {
;
;
;
this.mElements[serial].Open(elem,pref,gap,shift,this.mZIndex,
(serial==0?{x:this.mXAdjust,y:this.mYAdjust}:null),
addClear);
}
Menu.prototype.CloseLevel=function() {
;
this.mElementStack[this.mElementStack.length-1].Close();
}
function Menu_DispatchEvent(evtenum,evtdata) {
if(OpenedMenu==null) 
return false; 
if(evtenum==4)
return OpenedMenu.mElementStack[OpenedMenu.mElementStack.length-1].HandleKeyEvent(evtdata);
var e=evtdata.element;
while(e && e != document.body) {
var serial=e.getAttribute("ARMenuElementSerial");
if(e.tagName=="DIV"&&serial&&serial.length>0) {
;
OpenedMenu.mElements[e.getAttribute("ARMenuElementSerial")].HandleMouseEvent(evtenum,evtdata);
return true; 
}
e=e.parentNode;
}
if(evtenum==2 || (evtenum==0)) {
Menu_Close();
}
return false;
}
Menu.prototype.RecurBuild=function(def) {
var myserial=this.mSerialCnt++,submenumap={};
for(var i in def) {
var di=def[i];
;
;
if(typeof di.v!="string") {
submenumap[i]=this.mSerialCnt;
this.RecurBuild(di.v);
}
}
this.mElements[myserial]=new MenuElement(myserial,def,submenumap,MenuElement.isGroupMenu(this.mField.mID));
}
Menu.prototype.contains=function(val, def) {
if (def && def.length > 0) {
for(var i in def) {
var di=def[i];
;
;
if ((val == di.l) || (di.v instanceof Array && this.contains(val, di.v))) {
return true;
}
}
}
return false;
}

CharFieldMenu.prototype=new Menu(); CharFieldMenu.prototype.constructor=CharFieldMenu; CharFieldMenu.superclass=Menu.prototype;;
function CharFieldMenu(menu_data) {
if(arguments.length)
this.init(menu_data);
}
CharFieldMenu.prototype.init=function(menu_data) {
;
CharFieldMenu.superclass.init.call(this,menu_data.mval);
this.mField=null; 
this.mQueryReturnedNoValues = menu_data.novals; 
}
CharFieldMenu.prototype.Open=function(field,adjacent_element, addClear) {
;
this.mField=field;
CharFieldMenu.superclass.Open.call(this,adjacent_element,3,30100, addClear);
}
CharFieldMenu.prototype.HandleSelection=function(val) { 
;
this.mField.HandleMenuSelection(val);
new WorkflowContext({f:ExecuteWorkflow,a:[128, this.mField.mID]});
this.mField=null;
}
function ARMenu(menu_name,menu_data) {
;
;
this.mMenuName=menu_name;
this.mMenuData = ("novals" in menu_data) ? menu_data.mval : menu_data;
this.mCharFieldMenu=null;
if(this.mMenuData!=null && this.mMenuData instanceof Object && "novals" in menu_data)
this.mCharFieldMenu=new CharFieldMenu(menu_data);
ARMenu.Cache[this.mMenuName]=this;
}
ARMenu.Cache={};
function ARMenu_Get(menu_name) {
if(!(menu_name in ARMenu.Cache)) { 
ARMenu.Cache[menu_name]=null; 
new NDXGetMenuDefinition(menu_name,ARKWGetStringByIdx(7)); 
; 
}
if(ARMenu.Cache[menu_name]==null) 
return;
var fetchdef=!(menu_name in ARMenu.Cache);
var charFieldMenu=fetchdef?null:ARMenu.Cache[menu_name].mCharFieldMenu;
if (charFieldMenu==null){
var obj = ARMenu.Cache[menu_name].mMenuData;
var rs = ARKWGetStringByIdx(7),rf = ARKWGetStringByIdx(6),q = { qual:"",fieldids:[],fieldvals:[],fieldtypes:[] };
var fieldids=[],fieldvals=[],fieldtypes=[],keyids=[],keyvals=[],keytypes=[];
;
if ("s" in obj)
rs= ExpandServerName(obj.s);
;
if ("f" in obj)
rf = ExpandSchemaName(obj.f);
;
if ("q" in obj) {
eval("q="+obj.q); 
q = ExpandQualifier(q, rf, rs);
}
if ("ids" in obj) {
fieldids = obj.ids;
FieldList.PopulateValueAndTypeArrays(fieldids, fieldvals, fieldtypes);
}
if ("kwds" in obj) {
keyids = obj.kwds;
FieldList.PopulateValueAndTypeArrays(obj.kwds, keyvals, keytypes);
}
var req = new NDXExpandMenu(menu_name, ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), 
rs, rf, q.qual, q.fieldids, q.fieldvals, q.fieldtypes,
fieldids, fieldvals, fieldtypes, keyids, keyvals, keytypes);
var res = req.result;
;
charFieldMenu = new CharFieldMenu(res);
if ("q" in obj) 
ARKWSetLASTCOUNT(charFieldMenu.mQueryReturnedNoValues ? 0 : res.mval.length);
;
if ("r" in obj&&obj.r == 1) 
ARMenu.Cache[menu_name].mCharFieldMenu = charFieldMenu;
}
return charFieldMenu;
}
function ARMenu_Open(field,menu_name,adjacent_element, addClear) {
;
;
var charFieldMenu = ARMenu_Get(menu_name);
if (charFieldMenu) {
if (charFieldMenu.mMenuDef.length > 0) {
charFieldMenu.Open(field,adjacent_element, addClear);
} else {
window.status = getLocalizedMessage("No Menu Items to Display", null, "Menu Open");
}
} else {
window.status = getLocalizedMessage("No Menu to Display", null, "Menu Open");
}
}

function StatusHistoryPopup(title, hist) {
;
;
;
return weOpenModalPopup((AbsContextPath + "resources/html/StatusHistoryPopup.html"),"StatusHistory",{title:title,history:hist,appss:GetAppStyleSheet("../../")},{},[512,200]);
}

DControl.prototype=new Field(); DControl.prototype.constructor=DControl; DControl.superclass=Field.prototype;;
DOMFieldFactories["Control"]=function(id,n) {
return new DControl(id,n);
}
function DControl(a,b) {
if(arguments.length)
this.init(a,b);
}
DControl.prototype.mDOMField=DControl.prototype.mHaveVisualCharacteristics=true;
DControl.prototype.init=function(a,b) {
DControl.superclass.init.call(this,a,b);
if(this.mObj.firstChild) {
for(var n=this.mObj.firstChild;n;n=n.nextSibling)
if(n.nodeType==1&&n.className.indexOf("btntextdiv")!=-1) {
;
this.mTextElement=n.firstChild;
return;
}
}
}
var FormActionButtonFlags = {
1001 : { c: (1 << 4) | (1 << 2) | (1 << 5) | (1 << 3) | (1 << 6), f:FormAction_Submit },
1002 : { c:(1 << 1) | (1 << 2) | (1 << 5) | (1 << 3) | (1 << 6), f:FormAction_Query },
1003 : { c:(1 << 1) | (1 << 4) | (1 << 2) |   (1 << 3), f:FormAction_Modify },
1006 : { c:(1 << 5) | (1 << 3) | (1 << 6), f:FormAction_Clear },
1007 : { c:(1 << 5) | (1 << 2) | (1 << 3) | (1 << 6), f:FormAction_SetToDefaults },
1008 : { c:0, f:FormAction_ShowHelp },
1009 : { c:(1 << 2), f:FormAction_NewSearch },
1010 : { c:(1 << 2), f:FormAction_NewRequest },
1011 : { c:(1 << 1) | (1 << 4) | (1 << 2) | (1 << 6), f:FormAction_ShowStatusHistory},
1012 : { c:0, f:FormAction_OpenHomePage },
1004 : { c:(1 << 1) | (1 << 4) | (1 << 2) |  (1 << 3), f:FormAction_ModifyAll },
1013 : { c:0, f:FormAction_SavedSearches }
};
var ApplyButtonIDs = {
1 : 1001,
5 : 1003,
6 : 1003
};
DControl.prototype.Clear=function() {}
DControl.prototype.DOMClick=function(evt) {
;
if (this.GAccess()==3)
return;
var workflow = {f:ExecuteWorkflow,a:[ 1, this.mID]};
if (this.mID in FormActionButtonFlags) {
return CurWFC.executeAll([ {f:FormActionButtonFlags[this.mID].f}, workflow]);
} else
return {c:workflow};
}
DControl.prototype.MouseSelectable=false;
DControl.prototype.UpdateAccess=function(val,nocheck) {
;
;
;
if (this.mID in FormActionButtonFlags&&!nocheck&&(FormActionButtonFlags[this.mID].c & (1 << ARStateCurrent)))
return;
if (nocheck) {
this.mCFCache.a=val;
}
FakeButton_SetDisable(this.mObj,(val==3));
}
DControl.prototype.GetFocusElement=function() {
return this.mObj; 
}
DControl.prototype.GetFocusElementForEvent=function(ed) {
if (this.GetNestedFocusability()) {
return this.mObj;
}
return null;
}
DControl.prototype.mHaveStoredData=false;
function DControl_UpdateFormActionButtons() {
for (var id in FormActionButtonFlags) {
if(id in Fields) {
;
var enable = ((FormActionButtonFlags[id].c & (1 << ARStateCurrent)) == 0);
if (id == 1011 && !Fields[15])
enable = false;
Fields[id].UpdateAccess(enable ? 2 : 3, true);
}
}
if("Toolbar_UpdateFormActionButtons" in window)
Toolbar_UpdateFormActionButtons();
DControl_DirtyFlagChanged(FieldChanged);
}
function DControl_DirtyFlagChanged(dirty) {
var id = ApplyButtonIDs[ARStateCurrent];
if (id) {
F(id).UpdateAccess(dirty ? 2 : 3, true);
}
if("Toolbar_DirtyFlagChanged" in window)
Toolbar_DirtyFlagChanged(dirty);
}

DNavBarItem.prototype=new Field(); DNavBarItem.prototype.constructor=DNavBarItem; DNavBarItem.superclass=Field.prototype;;
DOMFieldFactories["NavBarItem"]=function(id,n) {
return new DNavBarItem(id,n);
}
function DNavBarItem(a,b) {
if(arguments.length)
this.init(a,b);
}
DNavBarItem.prototype.mDOMField=DNavBarItem.prototype.mHaveVisualCharacteristics=true;
DNavBarItem.prototype.init=function(a,b) {
DNavBarItem.superclass.init.call(this,a,b);
this.mStatus = this.mObj.getAttribute("status"); 
var parent = this.mObj.parentNode;
if (this.mStatus != null) {
if (this.mObj.nextSibling != null && this.mObj.nextSibling.getAttribute("id") == (this.mID + "-sub"))
this.mChildObj = this.mObj.nextSibling;
this.mTextElement = this.mObj.childNodes[0]; 
} else {
while(parent != null && (parent.tagName == "DIV" || parent.tagName == "DL")) {
if (parent.getAttribute("ARType") == "VertNavBar" || parent.getAttribute("ARType") == "HorzNavBar"){
this.mContainer = F(parent.getAttribute("ARID"));
break;
}
parent = parent.parentNode;
}
if (parent != null && parent.getAttribute("artype")=="HorzNavBar")
this.mTextElement = this.mObj.childNodes[1].childNodes[0]; 
else
this.mTextElement = this.mObj.childNodes[0]; 
if (this.mTextElement!=null&&this.mTextElement.nodeType!=1)
this.mTextElement = null;
;
if (this.mObj.className.match(/\S*NavSelected\S*/) != null)
this.MakeItemVisible();
}
}
DNavBarItem.prototype.Clear=function() {}
DNavBarItem.prototype.DOMClick=function(evt) {
;
if (this.GAccess()==3 || this.mObj.getAttribute("separator") == 1)
return;
this.DOMMouseOut(null); 
if (this.mStatus == null) {
;
var fireWorkflow = (this.mContainer.GetSelected() == this.mID) ? this.mContainer.FireWorkflowOnSelectedItem() : true;
if (this.mContainer.SelectItemOnClick())
this.mContainer.SetSelected(this);
if (fireWorkflow) {
var workflow = {f:ExecuteWorkflow,a:[ 1, this.mID]};
return {c:workflow};
}
} else {
this.SetStatus(this.mStatus=="open" ? "close" : "open");
}
}
DNavBarItem.prototype.SetSelected=function() {
if (this.mObj.getAttribute("status") == null && this.mObj.getAttribute("separator") != 1) { 
this.mContainer.SetSelected(this);
this.MakeItemVisible();
}
}
DNavBarItem.prototype.MakeItemVisible=function() {
var parent, parentId = this.mObj.getAttribute("parentId");
while (parentId != null && parentId > 0) {
parent = F(parentId);
if (parent instanceof DNavBarItem)
parent.SetStatus("open");
parentId = parent.mObj.getAttribute("parentId");
}
}
DNavBarItem.prototype.DOMMouseOver=function(evt) {
if (this.GAccess()==3 || this.mObj.getAttribute("separator") == 1)
return;
var style = (this.mObj.getAttribute("type") == "vert" ? " VNavHover" : " HNavHover");
this.mObj.className = this.mObj.className + style;
}
DNavBarItem.prototype.DOMMouseOut=function(evt) {
if (this.GAccess()==3 || this.mObj.getAttribute("separator") == 1)
return;
var style = (this.mObj.getAttribute("type") == "vert" ? " VNavHover" : " HNavHover");
this.mObj.className = this.mObj.className.replace(style, "");
}
DNavBarItem.prototype.SetStatus=function(status) {
var anchorObj = this.mObj.firstChild;
;
var imgObj = anchorObj.firstChild;
;
if (this.mStatus != "open" && status == "open") {
this.mStatus = "open";
if (imgObj.src.match(/\S*vnav_close2.gif\S*/) != null)
imgObj.src = RelContextPath + "resources/images/vnav_open2.gif";
else
imgObj.src = RelContextPath + "resources/images/vnav_open1.gif";
this.mChildObj.style.display="block";
this.mChildObj.style.visibility="inherit";
} else if (this.mStatus != "close" && status == "close"){
this.mStatus = "close";
if (imgObj.src.match(/\S*vnav_open1.gif\S*/) != null)
imgObj.src = RelContextPath + "resources/images/vnav_close1.gif";
else
imgObj.src = RelContextPath + "resources/images/vnav_close2.gif";
this.mChildObj.style.display="none";
this.mChildObj.style.visibility="hidden";
}
}
DNavBarItem.prototype.UpdateVis=function(val) {
if(!this.mHaveVisualCharacteristics || (val && this.mObj.style.visibility == "inherit") 
|| (!val && this.mObj.style.visibility == "hidden"))
return;
if (this.mChildObj != null && this.mStatus == "open") {
this.mChildObj.style.display=(val?"block":"none");
this.mChildObj.style.visibility=(val?"inherit":"hidden");
}
if (this.mObj.getAttribute("type") == "vert")
this.mObj.style.display=(val?"block":"none"); 
else
this.mObj.style.display=(val?"inline":"none"); 
this.mObj.style.visibility=(val?"inherit":"hidden");
}
DNavBarItem.prototype.MouseSelectable=false;
DNavBarItem.prototype.UpdateAccess=function(val) {
;
;
var style = (this.mObj.getAttribute("type") == "vert" ? " VNavDisabled" : " HNavDisabled");
if (val == 3) {
this.mObj.className += style;
if (this.mStatus == "open")
this.SetStatus("close");
}
else
this.mObj.className = this.mObj.className.replace(style, "");
this.mCFCache.a=val;
}
DNavBarItem.prototype.GetFocusElement=function() {
return this.mObj; 
}
DNavBarItem.prototype.GetFocusElementForEvent=function(ed) {
if (this.GetNestedFocusability()) {
return this.mObj;
}
return null;
}
DNavBarItem.prototype.mHaveStoredData=false;
DNavBarItem.prototype.mContainFields=true;

DVertNavBar.prototype=new Field(); DVertNavBar.prototype.constructor=DVertNavBar; DVertNavBar.superclass=Field.prototype;;
DOMFieldFactories["VertNavBar"]=function(id,n) {
return new DVertNavBar(id,n);
}
function DVertNavBar(a,b) {
if(arguments.length)
this.init(a,b);
}
DVertNavBar.prototype.mDOMField=DVertNavBar.prototype.mHaveVisualCharacteristics=true;
DVertNavBar.prototype.init=function(a,b) {
DVertNavBar.superclass.init.call(this,a,b);
this.mSelected = this.mObj.getAttribute("initValue");
}
DVertNavBar.prototype.Clear=function() {}
DVertNavBar.prototype.DOMClick=function(evt) {
;
if (this.GAccess()==3)
return;
var workflow = {f:ExecuteWorkflow,a:[ 1, this.mID]};
return {c:workflow};
}
DVertNavBar.prototype.MouseSelectable=false;
DVertNavBar.prototype.GetFocusElement=function() {
return this.mObj; 
}
DVertNavBar.prototype.GetFocusElementForEvent=function(ed) {
if (this.GetNestedFocusability()) {
return this.mObj;
}
return null;
}
DVertNavBar.prototype.FireWorkflowOnSelectedItem=function() {
if (this.mObj.getAttribute("workflowOnSelected") == 1)
return true;
else
return false;
}
DVertNavBar.prototype.SelectItemOnClick=function() {
if (this.mObj.getAttribute("selectOnClick") == 1)
return true;
else
return false;
}
DVertNavBar.prototype.GetSelected=function() {
return this.mSelected;
}
DVertNavBar.prototype.SetSelected=function(item) {
if (item.mID == this.mSelected)
return;
if (this.mSelected) {
var obj = F(this.mSelected).mObj;
if ("className" in obj)
obj.className = obj.className.replace("VNavLeaf VNavSelected", "VNavLeaf");
}
item.mObj.className = item.mObj.className.replace("VNavLeaf", "VNavLeaf VNavSelected");
this.mSelected = item.mID;
}
DVertNavBar.prototype.mHaveStoredData=false;
DVertNavBar.prototype.mContainFields=true;

DHorzNavBar.prototype=new Field(); DHorzNavBar.prototype.constructor=DHorzNavBar; DHorzNavBar.superclass=Field.prototype;;
DOMFieldFactories["HorzNavBar"]=function(id,n) {
return new DHorzNavBar(id,n);
}
function DHorzNavBar(a,b) {
if(arguments.length)
this.init(a,b);
}
DHorzNavBar.prototype.mDOMField=DHorzNavBar.prototype.mHaveVisualCharacteristics=true;
DHorzNavBar.prototype.init=function(a,b) {
DHorzNavBar.superclass.init.call(this,a,b);
this.mSelected = this.mObj.getAttribute("initValue");
}
DHorzNavBar.prototype.Clear=function() {}
DHorzNavBar.prototype.DOMClick=function(evt) {
;
if (this.GAccess()==3)
return;
var workflow = {f:ExecuteWorkflow,a:[ 1, this.mID]};
return {c:workflow};
}
DHorzNavBar.prototype.MouseSelectable=false;
DHorzNavBar.prototype.GetFocusElement=function() {
return this.mObj; 
}
DHorzNavBar.prototype.GetFocusElementForEvent=function(ed) {
if (this.GetNestedFocusability()) {
return this.mObj;
}
return null;
}
DHorzNavBar.prototype.FireWorkflowOnSelectedItem=function() {
if (this.mObj.getAttribute("workflowOnSelected") == 1)
return true;
else
return false;
}
DHorzNavBar.prototype.SelectItemOnClick=function() {
if (this.mObj.getAttribute("selectOnClick") == 1)
return true;
else
return false;
}
DHorzNavBar.prototype.GetSelected=function() {
return this.mSelected;
}
DHorzNavBar.prototype.SetSelected=function(item) {
if (item.mID == this.mSelected)
return;
if (this.mSelected) {
var obj = F(this.mSelected).mObj;
obj.className = obj.className.replace("HNavSelected", "HNavItem");
}
item.mObj.className = item.mObj.className.replace("HNavItem", "HNavSelected");
this.mSelected = item.mID;
}
DHorzNavBar.prototype.mHaveStoredData=false;
DHorzNavBar.prototype.mContainFields=true;

DChar.prototype=new DataField(); DChar.prototype.constructor=DChar; DChar.superclass=DataField.prototype;;
JChar.prototype=new Field(); JChar.prototype.constructor=JChar; JChar.superclass=Field.prototype;;
DOMFieldFactories["Char"]=function(id,n) {
return new DChar(id,n);
}
function DChar(id,n) {
if(arguments.length)
this.init(id,n);
}
DChar.prototype.init=function(id,n) {
this.mInputNode=n.childNodes[1];
this.mMaxLen=this.mInputNode.getAttribute("maxLen");
;
DChar.superclass.init.call(this,id,n);
}
DChar.prototype.ConvertPrimitiveToDataType=function(str) {
;
return new CharType(str);
}
DChar.prototype.FromUIInput = function(val, validate, expand) {
if (expand) 
val = ExpandString(val, 2 | 4, this.mID, 10);
val = val.trim(1|2);
if (val == "")
return Null;
return new CharType(val);
}
DChar.prototype.ConvertDTForS=DChar.prototype.ConvertDTForSLE=function(val) {
;
if (val.type==4)
return val;
return new CharType(val.toString());
}
DChar.prototype.UpdateMenu=function(val) {
if (val == null)
return;
var currMenu=this.GMenu();
if ((currMenu && currMenu == "$NULL$") || val == "$NULL$") {
var n = this.mObj.firstChild;
;
while(true) {
if(n.firstChild) {
n=n.firstChild;
} else {
while(!n.nextSibling) {
n=n.parentNode;
if(n==this.mObj) {
return;
}
}
n=n.nextSibling;
}
if (n.className && n.className.indexOf("menu") != -1) {
n.style.visibility=((val == "$NULL$")?"hidden":"inherit");
break;
}
}
}
}
DChar.prototype.UpdateAccess=function(val) {
DChar.superclass.UpdateAccess.call(this, val);
if (this.isDropDown()) {
this.mInputNode.readOnly=true;
}
}
DChar.prototype.DOMKeyPress=function(evt) {
;
if (evt.key==13) {
var ele  = this.mInputNode;
if (evt.shift || (ele.getAttribute("wrap")=="off") || ele.tagName == "INPUT") {
evt.StopDefault();
return {c:{t:this, f:DChar.superclass.DOMKeyPress, a:[evt]}};
} else {
}
} 
else
this.checkLength(evt);
}
DChar.prototype.DOMKeyDown=function(evt) {
;
if (this.GAccess() == 3)
return;
if (evt.key==40 && evt.alt) {
var e=evt.element;
if (e) {
if (this.GMenu()) { 
if (this.GAccess() != 1) { 
return {c:{f:ExecuteWorkflow,a:[64, this.mID]}, n:{a:[e], t:this, f:function(e) {
var ae;
ae = this.isDropDown() ? this.mInputNode : e;
ARMenu_Open(this,this.GMenu(),ae, this.isDropDown());
}}};
}
}
}
} else if(evt.key != 13) {
this.checkLength(evt);
} 
}
DChar.prototype.isDropDown=function() {
return this.mInputNode.getAttribute("mdd")=="1";
}
DChar.prototype.DOMClick=function(evt) {
;
if (this.GAccess() == 3)
return;
var e=FakeButton_Find(evt.element);
if (e) {
if (e.className.indexOf("menu")!=-1&&this.GMenu()) { 
if (this.GAccess() != 1) { 
return {c:{f:ExecuteWorkflow,a:[64, this.mID]}, n:{a:[e], t:this, f:function(e) {
var ae;
ae = this.isDropDown() ? this.mInputNode : e;
ARMenu_Open(this,this.GMenu(),ae, this.isDropDown());
}}};
}
} else if (e.className.indexOf("expand") != -1) {
var val = this.mInputNode.value;
var ro = this.GAccess() == 1;
var maxLen = (ARStateCurrent==4)? 0 : this.mMaxLen;
var ebArgs = {value:val, readonly:ro, maxCharLength:maxLen};
if(!this.mCharEditBox) {
var to = this;
this.mCharEditBox=CharEditBoxPopup(this.mID,ebArgs,function(retObj) {
;
if (retObj.retval) {
var newVal = retObj.retval+"";
if (newVal!=to.mInputNode.value) {
to.SetScreenValue(newVal);
to.SetDirty(to.mInputNode);
}
}
to.mCharEditBox=null;
});
} else
this.mCharEditBox.focus();
}
}
else if (this.isDropDown() && this.GAccess() != 1) {
return {c:{f:ExecuteWorkflow,a:[64, this.mID]}, n:{t:this, f:function() {
ARMenu_Open(this,this.GMenu(),this.mInputNode, this.isDropDown());
}}};
}
}
DChar.prototype.HandleMenuSelection=function(val) {
var ele = this.mInputNode;
;
var mstyle=ele.getAttribute("mstyle");
var curval=ele.value;
if (mstyle==2) {
ele.value=val;
ele.focus();
} else { 
if(curval!=null&&curval!="")
val=" "+val;
this.InsertAtCaret(ele,val);
}
if (curval!=val) {
this.FieldValChanged();
this.SetDirty(ele);
}
}
DChar.prototype.checkLength=function(evt) {
if (ARStateCurrent==4)
return;
if (!evt.shift && !evt.alt && !evt.ctrl && evt.key!=46 && evt.key!=8 && evt.key!=36 && evt.key!=35 
&& evt.key!=39 && evt.key!=37 && evt.key!=45 && this.mMaxLen!=0){
var ele = this.mInputNode;
var selected = false;
if (document.selection) {
var sel = document.selection.createRange().duplicate();
selected = sel.text.length>0;
} else if ("selectionStart" in ele) {
var start=ele.selectionStart,end=ele.selectionEnd;
selected = (start!=end)
}
if (!selected && ele.value.length >= this.mMaxLen) {
evt.StopDefault();
return;
}
}
}
DChar.prototype.mDataType=4;
DChar.prototype.mMaxLen=0;
JFieldFactories["Char"]=function(id,n) {
return new JChar(id,n);
}
function JChar(id,n) {
if(arguments.length)
this.init(id,n);
}
JChar.prototype.G=function() {
;
var val = this.mObj.v;
if (val.isNull || val.toString() == "")
return CharNull;
else if (val.type == 4) 
return val;
else {
this.mObj.v = new CharType(val);
return this.mObj.v;
}
}
JChar.prototype.DoSet=JChar.prototype.DoSLoadEntry=function(val) {
;
var hasKeywords={hasKeyword:false,hasTemporalKeyword:false};
var primVal = ExpandString(val.toString(), 2 | 4 | 8, this.mID, this.mDataType, hasKeywords);
if (hasKeywords.hasTemporalKeyword) {
this.mObj.v=val; 
} else {
if ((this.mDataType==4) && !hasKeywords.hasKeyword) {
this.mObj.v=val;
} else {
this.mObj.v=new CharType(primVal);
}
}
this.SetDirty();
}
DChar.prototype.mHaveStoredData=JChar.prototype.mHaveStoredData=true;

function CharEditBoxPopup(fieldid, arg, cont) {
;
;
;
;
var tpre = (ARStateCurrent == 4) ? ARTitles.pluralLong : ARTitles.singleLong;
if (tpre=="")
tpre=ARKWGetStringByIdx(6);
var title = getLocalizedMessage("{0} ({1}) -- {2}", [tpre, ARKWGetStringByIdx(7), F(fieldid).GLabel()]);
var textAreaTitle	;
if(F(fieldid) instanceof DDiary)
textAreaTitle = getLocalizedMessage("Diary Editor:");
var w=weOpenModelessPopup((AbsContextPath + "resources/html/CharEditBoxPopup.html"),"Editor",{title:title, textAreaTitle:textAreaTitle, arg:arg, appss:GetAppStyleSheet("../../")},cont,[640,480]);
return w;
}
function CharEditBoxPopup_UpdateText(win, text) {
win.UpdateText(text);
}
function CharEditBoxPopup_UpdateHistory(win, text) {
win.UpdateHistory(text);
}

DGroup.prototype=new DChar(); DGroup.prototype.constructor=DGroup; DGroup.superclass=DChar.prototype;;
DOMFieldFactories["Group"]=function(id,n) {
return new DGroup(id,n);
}
function DGroup(id,n) {
if(arguments.length)
this.init(id,n);
}
DGroup.prototype.ConvertPrimitiveToDataType=function(str) {
;
var obj = Group_Validate(this.mID, ExpandString(str,2|4), true); 
return new CharType(obj.v);
}
DGroup.prototype.ConvertDTForS=DGroup.prototype.ConvertDTForSLE=function(val) {
;
var obj = Group_Validate(this.mID, ExpandString(val.toString(),2|4), true); 
if (obj.w) {
CurWFC.status([{t:1,n:9305,m:null,a:this.GLabel()}]);
}
return new CharType(obj.v);
}
DGroup.prototype.SToScreen=function(val, str) {
;
if (val.isNull) {
this.mInputNode.value = "";
} else {
var obj=Group_Validate(this.mID, val.toString(), false); 
if (obj.v) {
this.mInputNode.value = obj.v;
this.SetDirty(this.mInputNode);
}
}
}
DGroup.prototype.Validate=function() {
var obj = Group_Validate(this.mID, ExpandString(this.mInputNode.value,2|4), true); 
if (obj.w) {
return {t:2,n:9305,m:null,a:this.GLabel()};
}
return null;
}
DGroup.prototype.mNeedSpecialSetToScreen=true;
function ValidateGroup(map, label) {
var rtnVal = -1;
if (map[label] != null)
rtnVal = map[label];
return rtnVal;
}
function getGroupId(fid, label) {
var gid = ValidateGroup(GInfo.gNameIdMap, label);
if (gid == -1 && fid != 104) {
gid = ValidateGroup(GInfo.cNameIdMap, label); 
}
return gid;
}
function getRoleId(fid, label) {
if (fid == 112 || 
(fid >= 60000 && fid <= 60999)) { 
for (var i in GInfo.rIdNameMap) { 
if (label == GInfo.rIdNameMap[i]) {
return i;
} 
}
}
return -1;
}
function getLabel(id) {
var label;
var re =/\b\d+\b/; 
if (re.test(id)) {
label = GInfo.getLabel(id);
if (label && label instanceof Object)
return label[0];
}
return label;
}
function IsValidGroup(fid, val, convertToId) {
var id = getRoleId(fid, val);
if(id == -1) 
id = getGroupId(fid, val);
if(id != -1) 
return (convertToId) ? id : val;
if (!convertToId) {
var label = getLabel(val);
if (label)
return label;
}
if (fid != 104) {  
var re =/'[^']*'/;
if (re.test(val))
return val;
}
return (isNaN(val) ? null : val);
}
function Group_Validate_UsingSemiColon(fid, value, convertToId) {
var res = {}, v="", val="";
var param = value.split(";");
if (param != null) {
for (var i = 0; i < param.length; i++) {
var p = param[i].trim(1 | 2);
if (p == "") continue;
val = IsValidGroup(fid, p, convertToId);
if (!val) {
res.w = true; 
val = param[i];
}
if (v != "") {
v += (convertToId) ? ";" : " ";
} 
v += val;
}
if (convertToId) v+=";"; 
}
res.v=v;
return res;
}
function Group_Validate_UsingSpace(fid, value, convertToId) {
var res = {}, v="", val="";
var str = value;
var start=0, end=value.length, param;
while (true) {
if (start > end) {
break;
}
param = str.substring(start, end) + "";
val = IsValidGroup(fid, param.trim(1 | 2), convertToId);
if (!val) { 
var lIdx = param.lastIndexOf(" ");
if (lIdx != -1) {
end = start + lIdx;
continue;
}
res.w = true; 
val = param;
}
if (v != "") {
v += (convertToId) ? ";" : " ";
} 
v += val;
start = end+1;
end = value.length
}
if (convertToId) v+=";"; 
res.v=v;
return res;
}
function Group_Validate(fid, value, convertToId) {
var res={}, v=value;
if (value.length > 0) {
if (value.lastIndexOf(";") != -1) {
return Group_Validate_UsingSemiColon(fid, value, convertToId);
} else if (value.lastIndexOf(" ") != -1) {
return Group_Validate_UsingSpace(fid, value, convertToId);
} else {
var val = IsValidGroup(fid, value, convertToId);
if (val) {
v = val;
if (convertToId) v+=";"; 
} else {
res.w = true; 
}
}
}
res.v=v;
return res;
}
JGroup.prototype=new JChar(); JGroup.prototype.constructor=JGroup; JGroup.superclass=JChar.prototype;;
JFieldFactories["Group"]=function(id,n) {
return new JGroup(id,n);
}
function JGroup(id,n) {
if(arguments.length)
this.init(id,n);
}
JGroup.prototype.G=function() {
;
var val = this.mObj.v;
if (this.mObj.w || val.isNull || val.toString() == "")
return CharNull;
this.mObj.v = new CharType(this.mObj.v);
return this.mObj.v;
}
JGroup.prototype.DoSet=JGroup.prototype.DoSLoadEntry=function(val) {
;
val = val.toString();
var obj = Group_Validate(this.mID, val, true); 
if (obj.w) {
CurWFC.status([{t:1,n:9305,m:null,a:this.GLabel()}]);
}
this.mObj = obj;
this.SetDirty();
}

var DatatypeMap={
"Attachment":11,
"Char":4,
"Currency":12,
"Date":13,
"Decimal":10,
"DefaultKW":1,
"Diary":5,
"Enum":6,
"Group":4,
"Integer":2,
"Null":0,
"Real":3,
"StatusHistory":4,
"TOD":14,
"Time":7
};
JColumn.prototype=new Field(); JColumn.prototype.constructor=JColumn; JColumn.superclass=Field.prototype;;
function JColumn(a,b) {
if(arguments.length)
this.init(a,b);
}
JColumn.prototype.mHaveVisualCharacteristics=true; 
JColumn.prototype.init=function(a,b) {
this.mData = null;
JColumn.superclass.init.call(this,a,b);
this.mCFCache.v=true; 
}
JColumn.prototype.UpdateVis=function(val) {
Fields[this.mObj.pnt].SColVis(this.mObj.dataidx,val);
}
JColumn.prototype.UpdateLabel=function(val) {
Fields[this.mObj.pnt].SColLabel(this.mObj.dataidx,val);
}
JColumn.prototype.instantiateField = function() {
if (!("dataidx" in this.mObj))
return;
;
var t=Fields[this.mObj.pnt];
;
if (t.mResult) {
;
var f = t.mResult.f[this.mObj.dataidx];
;
if (f.t in JFieldFactories) {
if (this.mData) {
var type = f.dt;
if ("t" in this.mData) {
type = this.mData.t;
}
f.v = Datatype_Factory({t:type, v:this.mData.p, a:f.a});
} else
f.v = Null;
this.mField = JFieldFactories[f.t](0,f);
}
}
}
JColumn.prototype.G = function() {
if (!this.mField)
this.instantiateField();
if (this.mField) {
var res = this.mField.G();
return res;
}
return Null;
}
JColumn.prototype.DoSet=JColumn.prototype.DoSLoadEntry=function(val) {
if (!this.mField)
this.instantiateField();
if (this.mField) {
var t=Fields[this.mObj.pnt];
;
if (t instanceof DTreeView)
return;
var row = t.GetRow();
if (row >= 0 && row < t.GetRows()) {
var cf = Field_GetChanged(); 
this.mField.S(val);
if (!cf) Field_ClearChangedFromRunProcess(); 
;
;
;
t.mResult.r[t.GetRow()].mXXXDirty=true;
;
this.mData.p = this.mField.mObj.v;
this.mData.v = this.mField.G().toString();
this.mData.t = (this.mField.mObj.v.isNull) ? 0 : this.mField.mObj.dt;
t.DataChanged();
}
}
}
JColumn.prototype.mHaveStoredData=false;
JColumn.prototype.GDefault=function() {
return null; 
}
JColumn.prototype.Clear=function() {
}
JColumn.prototype.Refresh=function() {
;
if (this.mField) {
var t=Fields[this.mObj.pnt];
;
if (t.mResult) {
;
var f = t.mResult.f[this.mObj.dataidx];
;
if (f.t != this.mField.type) {
delete this.mField;
} else {
}
}
}
}
JColumn.prototype.Update=function(data) {
;
this.mData = data;
if (this.mField) {
if (this.mData) {
var t=Fields[this.mObj.pnt];
;
;
;
var f = t.mResult.f[this.mObj.dataidx];                
;
var type = f.dt;
if ("t" in this.mData) {
type = this.mData.t;
}
this.mField.mObj.v = Datatype_Factory({t:type, v:this.mData.p, a:f.a});
} else
this.mField.mObj.v = Null;
}
}
JColumn.prototype.getTable=function() {
;
var t = F(this.mObj.pnt);
;
return t;
}
JColumn.prototype.GetSorter=function() {   
if (!this.mField)   
this.instantiateField();   
return this.mField.GetSorter();   
} 
JColumn.prototype.IsTimeRelatedField=function() {
if (!this.mField)   
this.instantiateField();
return (this.mField instanceof JDate || this.mField instanceof JTime || this.mField instanceof JTOD);
}
JColumn.prototype.GetType=function() {
if ("dataidx" in this.mObj) {	
var t=Fields[this.mObj.pnt];
;
if (t.mResult) {
;
var f = t.mResult.f[this.mObj.dataidx];
;
if (f.t in DatatypeMap)
return DatatypeMap[f.t];
}
}
return 0;
}
JColumn.prototype.GetDataField=function() {
if (!this.mField)   
this.instantiateField();
return this.mField;
}

DInteger.prototype=new DataField(); DInteger.prototype.constructor=DInteger; DInteger.superclass=DataField.prototype;;
JInteger.prototype=new Field(); JInteger.prototype.constructor=JInteger; JInteger.superclass=Field.prototype;;
DOMFieldFactories["Integer"]=function(id,n) {
return new DInteger(id,n);
}
function DInteger(id,n) {
if(arguments.length)
this.init(id,n);
}
DInteger.prototype.init=function(id,n) {
if (n.getAttribute("ARType") == "Integer")
this.mInputNode = n.childNodes[1].firstChild;
;
if(!this.mInputNode.getAttribute("ARMin"))
this.mInputNode.setAttribute("ARMin",""+-2147483647);
if(!this.mInputNode.getAttribute("ARMax"))
this.mInputNode.setAttribute("ARMax",""+2147483647);
DInteger.superclass.init.call(this,id,n);
}
DInteger.prototype.ConvertPrimitiveToDataType=function(str) {
return this.FromUIInput(str, false, false);
}
DInteger.prototype.FromUIInput = function(val, validate, expand) {
if (expand)
val = ExpandString(val, 2 | 4, this.mID, 2);
if (val == "")
return Null;
if (validate) {
var re =/^[+-]?[0-9]+$/;
if (!re.test(val)) {
throw({t:2,n:9375,m:null,a:"\"" + val + "\": " + this.GLabel()});
}
var test = parseFloat(val);
if (test < -2147483647 || test > 2147483647) {
throw({t:2,n:9272,m:null,a:"" + -2147483647 + "," + 2147483647 + " : " + this.GLabel()});
}
}
return new IntegerType(val);
}
DInteger.prototype.GetQBEValue=function() {
if (this.IsNullKeyword())
return NullType.KEYWORD_NULL;
var val = this.mInputNode.value;
val = ExpandString(val, 2 | 4, this.mID, 2);
if (val == "")
return Null;
var qbeOp = Field.GetQBEOperator(val);
if (qbeOp == null) {
var errs = this.Validate();
if (errs) {
throw (errs);
}
return this.G();
} else {
var valPart = this.FromUIInput(val.substring(qbeOp.length).trim(1), true, false);
return new CharType(qbeOp + valPart.toPrimitive());
}
}
DInteger.prototype.ConvertDTForS=DInteger.prototype.ConvertDTForSLE=function(val) {
;
if (val.isNull || val.type==2)
return val;
var val = val.toInteger();
if (!val.isNull)
val = new IntegerType(val);
return val;
}
DInteger.prototype.DOMMouseOut=function(evt) {
if (this.GAccess() != 2)
return false;
var e=FakeButton_Find(evt.element);
if (e)
this.Spin(0);
}
DInteger.prototype.DOMMouseUp=function(evt) {
if (this.GAccess() != 2)
return false;
var e=FakeButton_Find(evt.element);
if (e) {
this.Spin(0);
new WorkflowContext({f:ExecuteWorkflow,a:[2, this.mID]});
}
}
DInteger.prototype.DOMMouseDown=function(evt) {
if (this.GAccess() != 2)
return false;
var e=FakeButton_Find(evt.element);
if (e) {
if (e.className.indexOf("spinnerup") != -1) 
this.Spin(1, true);
else if (e.className.indexOf("spinnerdown") != -1) 
this.Spin(-1, true);
}
}
DInteger.prototype.DOMKeyDown=function(evt) {
;
if (this.GAccess() != 2)
return;
var key=evt.key;
if (key == 38 || key == 40) {
evt.StopDefault();
this.Spin((key == 38) ? 1 : -1, false);
}
}
function DInteger_DoSpin(id, dir) {
;
;
F(id).Spin(dir, true);
}
DInteger.prototype.Spin = function(dir, autorep) {
;
if (dir == 0) {
if (this.mSpinTimeout) 
clearTimeout(this.mSpinTimeout);
} else {
;
if (autorep)
this.mSpinTimeout = setTimeout("DInteger_DoSpin("+this.mID+","+dir+")",250);
var val = new IntegerType();
val.ADD(this.G(), new IntegerType(dir));
this.S(val);
}
}
DInteger.prototype.Validate=function() {
var node = this.mInputNode;
var min = parseInt(node.getAttribute("ARMin"), 10);
var max = parseInt(node.getAttribute("ARMax"), 10);
try {
var val = this.FromUIInput(node.value,true,true);
return Integer_Validate(this, val, min, max);
} catch (e) {
return e;
}
}
DInteger.prototype.mDataType=2;
JFieldFactories["Integer"]=function(id,n) {
return new JInteger(id,n);
}
function JInteger(id,n) {
if(arguments.length)
this.init(id,n);
}
JInteger.prototype.init=function(id,n) {
JInteger.superclass.init.call(this,id,n);
if(!("min" in this.mObj))
this.mObj.min=-2147483647;
if(!("max" in this.mObj))
this.mObj.max=2147483647;
}
JInteger.prototype.G=function() {
;
var val = this.mObj.v;
if (val.isNull || val.type == 2) 
return val;
else {
this.mObj.v = new IntegerType(val);
return this.mObj.v;
}
}
JInteger.prototype.DoSet=JInteger.prototype.DoSLoadEntry=function(val) {
;
this.mObj.v=val;
this.SetDirty();
}
JInteger.prototype.Validate=function() {
return Integer_Validate(this, this.G(), this.mObj.min, this.mObj.max);
}
JInteger.prototype.GetSorter = function() {
return "(ls=parseInt(lhs),rs=parseInt(rhs),(isNaN(ls)?0:ls)-(isNaN(rs)?0:rs))";
}
DInteger.prototype.mHaveStoredData=JInteger.prototype.mHaveStoredData=true;
function Integer_Validate(field, val, min, max) {
;
;
;
var isDirty = field.mLastChanged && Field_LastCleared<=field.mLastChanged;
if(!isDirty)
return null;
if (!val.isNull) {
val = val.toInteger();
if (val < min || val > max)
return {t:2,n:9272,m:null,a:"" + min + "," + max + " : " + field.GLabel()};
}
return null;
}

DDate.prototype=new DataField(); DDate.prototype.constructor=DDate; DDate.superclass=DataField.prototype;;
Date.prototype.UnixTimestamp = function () {
return Math.floor(this.valueOf() / 1000);
}
DOMFieldFactories["Date"]=function(id,n) {
return new DDate(id,n);
}
function DDate(a,b) {
if(arguments.length)
this.init(a,b);
}
DDate.prototype.init=function(id,n) {
this.mInputNode=n.childNodes[1];
;
DDate.superclass.init.call(this,id,n);
}
DDate.prototype.ConvertPrimitiveToDataType=function(str) {
var d = this.FromUIInput(str,false,false); 
return d;
}
DDate.prototype.GetQBEValue=function() {
if (this.IsNullKeyword())
return NullType.KEYWORD_NULL;
var val = this.mInputNode.value;
val = ExpandString(val, 2 | 4, this.mID, 13);
if (val == "")
return Null;
var qbeOp = Field.GetQBEOperator(val);
if (qbeOp == null) {
var errs = this.Validate();
if (errs) {
throw(errs);
}
return this.G();
} else {
var valPart = this.FromUIInput(val.substring(qbeOp.length).trim(1), true, false);
return new CharType(qbeOp + valPart.toPrimitive());
}
}
DDate.prototype.FromUIInput = function(val, validate, expand) {
if (expand)
val = ExpandString(val, 2 | 4, this.mID, 13);
val = val.trim(1|2);
if (val == "") {
return Null;
}
var dateObj = ARDate.parseDate(val);
if (dateObj == null) {
if (validate && !val.isNumeric()) {
throw({t:2,n:9376,m:null,a:this.GLabel()});
}
val = parseInt(val, 10);
if (isNaN(val))
val = 0; 
else if (val <0)
val = 0;
else if (val > 5373120)
val = 5373120;
} else {
if (validate && dateObj.year == 1582 && dateObj.month == 9 && (dateObj.date > 4 && dateObj.date < 15)) 
throw({t:2,n:9376,m:null,a:this.GLabel()});
val = dateObj.GDays();
}
return new DateType(val);
}
DDate.prototype.ConvertDTForS=DDate.prototype.ConvertDTForSLE=function(val) {
;
if (val.isNull || val.type == 13)
return val;
else if (ARKWIsKeywordString(val))
return new CharType(val.toString());
else {
val = val.toDate();
if (!val.isNull)
val.set(val.toInteger()); 
return val;
}
}
DDate.prototype.Validate=function() {
try {
return Date_Validate(this, this.FromUIInput(this.mInputNode.value,true,true));
} catch (err) {
err.a = this.GLabel();
return err;
}
}
DDate.prototype.mHaveStoredData=true;
DDate.prototype.mDataType=13;
DDate.prototype.DOMClick = function(evt) {
;
if (this.GAccess() == 3)
return;
var e=FakeButton_Find(evt.element);
if (e) {
if (e.className.indexOf("expand") != -1) {
var ro = this.GAccess() == 1;
var popup = new TimePopup(this, false, true, true, ro);
return popup.ShowPopup(e,0,e.offsetHeight);
} else {
this.mInputNode.focus(); 
}
}
}
DDate.prototype.ValidatePopupValue=function(val) {
;
val = new DateType(val.GDays());
return Date_Validate(this, val);
}
DDate.prototype.SetFromPopup = function(val) {
;
this.S(new DateType(val.GDays()));
}
JDate.prototype=new Field(); JDate.prototype.constructor=JDate; JDate.superclass=Field.prototype;; 
JFieldFactories["Date"]=function(id,n) {
return new JDate(id,n);
}
function JDate(a,b) {
if(arguments.length)
this.init(a,b);
}
JDate.prototype.G=function() {
;
;
var val = this.mObj.v;
if (val.isNull || val.type == 13)
return val;
else {
if (val.type == 4)
val = ExpandString(val.toString(), 2 | 4, this.mID, this.mDataType);
this.mObj.v = new DateType(val); 
return this.mObj.v;
}
}
JDate.prototype.DoSet=function(val) {
;
if(val.isNull)
this.mObj.v = Null;
else if (ARKWIsKeywordString(val))
this.mObj.v = new CharType(val.toString());
else {
val=val.toDate();
if (!val.isNull)
val.set(val.toInteger()); 
this.mObj.v = val;            
}
this.SetDirty();
}
JDate.prototype.Validate=function() {
return Date_Validate(this, this.G());
}
function Date_Validate(field, val) {
;
var isDirty = field.mLastChanged && Field_LastCleared<=field.mLastChanged;
if(!isDirty)
return null;
if (!val.isNull) {
;
if (val.valueAdjusted)
return {t:2,n:9376,m:null,a:field.GLabel()};
}
return null;
}
JDate.prototype.mHaveStoredData=true;

DTOD.prototype=new DataField(); DTOD.prototype.constructor=DTOD; DTOD.superclass=DataField.prototype;;
DOMFieldFactories["TOD"]=function(id,n) {
return new DTOD(id,n);
}
function DTOD(a,b) {
if(arguments.length)
this.init(a,b);
}
DTOD.prototype.init=function(id,n) {
this.mInputNode=n.childNodes[1];
;
DTOD.superclass.init.call(this,id,n);
}
DTOD.prototype.ConvertPrimitiveToDataType=function(str) {
return this.FromUIInput(str,false,false); 
}
DTOD.prototype.GetQBEValue=function() {
if (this.IsNullKeyword())
return NullType.KEYWORD_NULL;
var val = this.mInputNode.value;
val = ExpandString(val, 2 | 4, this.mID, 14);
val = val.trim(1|2);
if (val == "")
return Null;
var qbeOp = Field.GetQBEOperator(val);
if (qbeOp == null) {
var errs = this.Validate();
if (errs) {
throw(errs);
}
return this.G();
} else {
var valPart = this.FromUIInput(val.substring(qbeOp.length).trim(1), true, false);
return new CharType(qbeOp + valPart.toPrimitive());
}
}
DTOD.prototype.FromUIInput = function(val, validate, expand) {
if (expand)
val = ExpandString(val, 2 | 4, this.mID, 14);
val = val.trim(1|2);
if (val == "") {
return Null;
}
var dateObj = ARDate.parseTime(val);
if (dateObj == null) {
if (validate && !val.isNumeric()) {
throw({t:2,n:9376,m:null,a:this.GLabel()});
}
val = parseInt(val, 10);
if (isNaN(val))
val = 0; 
else if (val < 24)
val *= 3600;
else if (val > 86399)
val = 86399;
} else {
val = dateObj.GTimeOfDay();
}
return new TODType(val);
}
DTOD.prototype.ConvertDTForS=DTOD.prototype.ConvertDTForSLE=function(val) {
;
if (val.isNull || (val.type == 14 && !(val instanceof TODKWType)))
return val;
else if (ARKWIsKeywordString(val))
return new CharType(val.toString());
else {
return val.toTOD();
}
}
DTOD.prototype.Validate=function() {
try {
return TOD_Validate(this, this.FromUIInput(this.mInputNode.value,true,true));
} catch (err) {
err.a = this.GLabel();
return err;
}
}
DTOD.prototype.DOMClick = function(evt) {
;
if (this.GAccess() == 3)
return;
var e=FakeButton_Find(evt.element);
if (e) {
if (e.className.indexOf("expand") != -1) {
var ro = this.GAccess() == 1;
var popup = new TimePopup(this, true, false, false, ro);
return popup.ShowPopup(e,0,e.offsetHeight);
} else {
this.mInputNode.focus();
}
}
}
DTOD.prototype.HandleMenuSelection = function(tod) {
}
DTOD.prototype.ValidatePopupValue =function(val) {
;
val = new TODType((val.GHour() * 3600) + (val.GMinute() * 60) + val.GSecond());
return TOD_Validate(this, new TODType(val));
}
DTOD.prototype.SetFromPopup =function(val) {
;
this.S(new TODType((val.GHour() * 3600) + (val.GMinute() * 60) + val.GSecond()));
}
DTOD.prototype.mHaveStoredData=true;
DTOD.prototype.mDataType=14;
JTOD.prototype=new Field(); JTOD.prototype.constructor=JTOD; JTOD.superclass=Field.prototype;;
JFieldFactories["TOD"]=function(id,n) {
return new JTOD(id,n);
}
function JTOD(a,b) {
if(arguments.length)
this.init(a,b);
}
JTOD.prototype.G=function() {
;
;
var val = this.mObj.v;
if (val.isNull || val.type == 14)
return val;
else {
if (val.type == 4)
val = ExpandString(val.toString(), 2 | 4, this.mID, this.mDataType);
this.mObj.v = new TODType(val);
return this.mObj.v;
}
}
JTOD.prototype.DoSet=JTOD.prototype.DoSLoadEntry=function(val) {
;
if(val.isNull)
this.mObj.v = Null;
else if (ARKWIsKeywordString(val))
this.mObj.v = new CharType(val.toString());
else
this.mObj.v = val.toTOD();
this.SetDirty();
}
JTOD.prototype.Validate=function() {
var val = this.G();
if (val.isNull)
return null;
return TOD_Validate(this, val);
}
function TOD_Validate(field, val) {
;
var isDirty = field.mLastChanged && Field_LastCleared<=field.mLastChanged;
if(!isDirty)
return null;
if (!val.isNull) {
;
if (val.valueAdjusted)
return {t:2,n:9376,m:null,a:field.GLabel()};
}
return null;
}
JTOD.prototype.mHaveStoredData=true;

DDecimal.prototype=new DataField(); DDecimal.prototype.constructor=DDecimal; DDecimal.superclass=DataField.prototype;;
DOMFieldFactories["Decimal"]=function(id,n) {
return new DDecimal(id,n);
}
function DDecimal(a,b) {
if(arguments.length)
this.init(a,b);
}
DDecimal.prototype.init=function(id,n) {
this.mInputNode=n.childNodes[1];
;
DDecimal.superclass.init.call(this,id,n);
}
DDecimal.prototype.mHaveStoredData=true;
DDecimal.prototype.ConvertPrimitiveToDataType=function(str) {
;
return this.FromUIInput(str,false,false);
}
DDecimal.prototype.GetQBEValue=function() {
if (this.IsNullKeyword())
return NullType.KEYWORD_NULL;
var val = this.mInputNode.value;
val = ExpandString(val, 2 | 4, this.mID, 10);
val = val.trim(1|2);
if (val == "")
return Null;
var qbeOp = Field.GetQBEOperator(val);
if (qbeOp == null) {
var errs = this.Validate();
if (errs) {
throw(errs);
}
return this.G();
} else {
var valPart = this.FromUIInput(val.substring(qbeOp.length).trim(1), true, false);
return new CharType(qbeOp + valPart.toPrimitive());
}
}
DDecimal.prototype.FromUIInput = function(val, validate, expand) {
if (expand) 
val = ExpandString(val, 2 | 4, this.mID, 10);
val = val.trim(1|2);
if (val == "")
return Null;
val = LCDecimalToEn_US(val, validate);
var p = parseInt(this.mInputNode.getAttribute("ARPrecision"));
try {
val = new BigDecimal(val);
if (val.scale() < p)
val = val.setScale(p);
} catch (e) {
if (validate) {
throw({t:2,n:9374,m:null,a:this.GLabel()});
} else {
val = new BigDecimal("0");
}
}
return new DecimalType(val, p);
}
DDecimal.prototype.ConvertDTForS=DDecimal.prototype.ConvertDTForSLE=function(val) {
;
if (val.isNull) {
return val;
} else {
var p = parseInt(this.mInputNode.getAttribute("ARPrecision"));
if (val instanceof DecimalType && val.mPrecision==p) {
return val;
}
return new DecimalType(DecimalType.Round(val.toDecimal(), p), p);
}
}
DDecimal.prototype.GDefault=JDecimal.prototype.GDefault=function() {
if("d" in Defaults[this.mID])
return(new DecimalType(new BigDecimal(Defaults[this.mID].d)));
else
return(Null);
}
DDecimal.prototype.mDataType=10;
DDecimal.prototype.Validate=function() {
var node = this.mInputNode;
var min = new BigDecimal(node.getAttribute("ARMin"));
var max = new BigDecimal(node.getAttribute("ARMax"));
try {
var val = this.FromUIInput(node.value,true,true);
return Decimal_Validate(this, val, min, max);
} catch (err) {
err.a += ": " + this.GLabel();
return err;
}
}
JDecimal.prototype=new Field(); JDecimal.prototype.constructor=JDecimal; JDecimal.superclass=Field.prototype;;
JFieldFactories["Decimal"]=function(id,n) {
return new JDecimal(id,n);
}
function JDecimal(a,b) {
if(arguments.length)
this.init(a,b);
}
JDecimal.prototype.init=function(id, n) {
JDecimal.superclass.init.call(this,id,n);
if(!("p" in this.mObj))
this.mObj.p=2; 
}
JDecimal.prototype.mHaveStoredData=true;
JDecimal.prototype.G=function() {
;
var val = this.mObj.v;
if (val instanceof NullType)
return val;
else if (val.type == 10) { 
val.mPrecision = this.mObj.p; 
return val;
} else {
this.mObj.v = new DecimalType(val, this.mObj.p);
return this.mObj.v;
}
}
JDecimal.prototype.DoSet=JDecimal.prototype.DoSLoadEntry=function(val) {
;
this.mObj.v=val;
this.SetDirty();
}
JDecimal.prototype.Validate=function() {
var val = this.G();
if (val.isNull)
return null;
return Decimal_Validate(this, val, new BigDecimal(this.mObj.min), new BigDecimal(this.mObj.max));
}
function Decimal_Validate(field, val, min, max) {
;
;
var isDirty = field.mLastChanged && Field_LastCleared<=field.mLastChanged;
if(!isDirty)
return null;
val = val.toDecimal();
if (min.compareTo(val) > 0 || max.compareTo(val) < 0)
return {t:2,n:9272,m:null,a:"" + min + "," + max + " : " + field.GLabel()};
return null;
}

DCurrency.prototype=new DataField(); DCurrency.prototype.constructor=DCurrency; DCurrency.superclass=DataField.prototype;;
CurrencyMenu.prototype=new Menu(); CurrencyMenu.prototype.constructor=CurrencyMenu; CurrencyMenu.superclass=Menu.prototype;;
function CurrencyMenu(field, menu_data) {
if (arguments.length)
this.init(field, menu_data);
}
CurrencyMenu.prototype.init = function(field, menu_data) {
CurrencyMenu.superclass.init.call(this, menu_data);
this.mField=field; 
}
CurrencyMenu.prototype.Open = function(adjacent_element) {
;
CurrencyMenu.superclass.Open.call(this, adjacent_element, 3, 30100, false);
}
CurrencyMenu.prototype.HandleSelection = function(val) { 
;
this.mField.HandleMenuSelection(val);
}
DOMFieldFactories["Currency"]=function(id,n) {
return new DCurrency(id,n);
}
DCurrency.prototype.mIsComplexField=true;
function DCurrency(a,b) {
if(arguments.length)
this.init(a,b);
}
DCurrency.prototype.init=function(id,n) {
this.mInputNode=n.childNodes[1];
;
;
var menudef = eval(this.mInputNode.getAttribute("ARAllowableCur"));
this.mAllowable = {};
if(menudef.length==0) {
this.mMenuDef = currencyMenu;
this.mAllowable = currencyCodes;
for (var i in currencyCodes) {
this.mDefaultCurrency = i;
this.mDefaultPrecision = currencyCodes[i].p;
break;
}
}
else {
for (var i = 0; i < menudef.length; ++i) {
;
var label = "";
if (menudef[i].v in currencyCodes) {
label = " - " + currencyCodes[menudef[i].v].l;
}
menudef[i].l = menudef[i].v + label.HTMLEncode();
this.mAllowable[menudef[i].v] = {p : menudef[i].p, l : label};
if (menudef[i].d == "1") {
this.mDefaultCurrency = menudef[i].v;
this.mDefaultPrecision = menudef[i].p;
}
}
this.mMenuDef = menudef;
}
if (this.mMenuDef.length==0) {
this.mDefaultCurrency="";
this.mDefaultPrecision=2;
} 
menudef = eval(this.mInputNode.getAttribute("ARFunctionalCur"));
this.mFunctional = {};
for (var i = 0; i < menudef.length; ++i) {
;
this.mFunctional[menudef[i].v] = menudef[i].p;
}
DCurrency.superclass.init.call(this,id,n);
}
DCurrency.prototype.ConvertPrimitiveToDataType=function(str) {
return this.FromUIInput(str, false, false);
}
DCurrency.prototype.GetQBEValue=function() {
if (this.IsNullKeyword())
return NullType.KEYWORD_NULL;
var val = this.mInputNode.value;
val = ExpandString(val, 2 | 4, this.mID, 12);
val = val.trim(1|2);
if (val == "")
return Null;
var qbeOp = Field.GetQBEOperator(val);
if (qbeOp == null) {
return this.G();
} else {
var valPart = this.FromUIInput(val.substring(qbeOp.length).trim(1), true, false);
return new CharType(qbeOp + valPart.toPrimitive());
}
}
DCurrency.prototype.FromUIInput = function(val, validate, expand) {
if (expand)
val = ExpandString(val, 2 | 4, this.mID, 12);
val = val.trim(1|2);
if (val == "")
return Null;
var re = /.*([A-Z][A-Z][A-Z])\s*$/;
var curCode = "";
if (val.match(re))
{
curCode = val.replace(re, "$1");
}
re = /(.*)[A-Z][A-Z][A-Z]\s*$/;
val = val.replace(re, "$1");
val = val.trim(1|2);
val = LCDecimalToEn_US(val, validate);
try {
val = new BigDecimal(val);
} catch (e) {
if (validate)
throw({t:2,n:9374,m:null,a:"\"" + val + "\""});
else
val = null;
}
if (val != null && curCode == "")
curCode = this.mDefaultCurrency;
var p = this.GetPrecision(curCode);
val = new CurrencyType(val, p);
val.mCurCode = curCode;
if (this.mDate == null || typeof(this.mDate) == "undefined") {
this.mDate = new Date().UnixTimestamp();
}
val.mDate = this.mDate;
val = this.SetFunctionals(val);
return val;
}
DCurrency.prototype.GetPrecision = function(curCode) {
if (curCode in this.mAllowable) {
return this.mAllowable[curCode].p;
}
return 2;
}
DCurrency.prototype.ConvertDTForS=DCurrency.prototype.ConvertDTForSLE=function(val) {
;
if (val.type==12) {
var curCode = val.mCurCode;
if (!curCode || curCode == "")
curCode = this.mDefaultCurrency;
this.mDate = val.mDate;
this.mFunc = {};
val = new CurrencyType(val, this);
val.mValue = ((val.mValue == null) ? null : DecimalType.Round(val.mValue, val.mPrecision));
val.mCurCode = curCode;
val = this.SetFunctionals(val);
return val;
} else if (val.toString() in this.mAllowable) {
return new CharType(val.toString());
} else {
val = val.toCurrency(this);
if (val.mValue == null)
return Null;
if (!val.mCurCode || val.mCurCode == "") {
val.mCurCode = this.mDefaultCurrency; 
val.mPrecision = this.mDefaultPrecision; 
}
val = this.SetFunctionals(val);
return val;
}
}
DCurrency.prototype.SetFunctionals = function(val) {
;
val.mFunc = {};
for (var c in this.mFunctional)
val.mFunc[c] = {p : this.mFunctional[c]};
if (!(val.mCurCode in this.mAllowable))
val = val.CurrConvert(this.mDefaultCurrency, val.mDate, this.GetPrecision(this.mDefaultCurrency));
else
val = val.CurrSetDate(val.mDate);
return val;
}
DCurrency.prototype.mHaveStoredData=true;
DCurrency.prototype.mDataType=12;
DCurrency.prototype.Validate=function() {
var node = this.mInputNode;
var min = new BigDecimal(node.getAttribute("ARMin"));
var max = new BigDecimal(node.getAttribute("ARMax"));
try {
var val = this.FromUIInput(node.value,true,true);
if (val.isNull)
return null;
return Currency_Validate(this, val, min, max);
} catch (err) {
err.n = 9325;
err.a += ": " + this.GLabel();
return err;
}
}
DCurrency.prototype.DOMClick = function(evt) {
;
if (this.GAccess() == 3)
return;
var e=FakeButton_Find(evt.element);
if (e) {
if (e.className.indexOf("menu")!=-1 && this.GAccess()!=1) { 
if (!this.mMenu) {
;
var menudef = this.mMenuDef;
var uimenudef = [];
for (var i = 0; i < menudef.length; ++i) {
;
uimenudef.push({v:menudef[i].l,l:menudef[i].l});
}
this.mMenu = new CurrencyMenu(this, uimenudef);
}
this.mMenu.Open(e);
} else if (e.className.indexOf("expand") != -1) {
if (this.Validate() == null) {
this.S(this.G());
}
new CurrencyPopup(this).ShowPopup(e,0,e.offsetHeight);
} else {
this.mInputNode.focus();
}
}
}
DCurrency.prototype.DOMMouseOver=function(ed) {
var e=ed.element;
while(e&&!(e.tagName=="INPUT"))
e=e.offsetParent;
if(e!=null) {
var val = this.mInputNode.value;
var re = /^(.*)([A-Z][A-Z][A-Z])$/;
if (val.match(re)) {
var code = val.replace(re, "$2");
if (code in this.mAllowable) {
e.setAttribute("title", val.replace(re, "$1") + " " + this.mAllowable[code].l);
} else e.setAttribute("title", val);
} else e.setAttribute("title", val);
}
}
DCurrency.prototype.DOMBlur = function(evt) {
if (this.Validate() == null) {
var val = this.G();
if (!val.isNull)
this.S(val);
}
DCurrency.superclass.DOMBlur.call(this, evt);    
}
DCurrency.prototype.GDefault=JCurrency.prototype.GDefault=function() {
if("d" in Defaults[this.mID])
return new CharType(ExpandString(""+Defaults[this.mID].d, 2));
else {
if ((ARStateCurrent == 1)) {
var pref = ARPrefsGetAsString(20130);
if (pref) {
return(this.IsAllowable(pref) ? new CharType(ARPrefsGetAsString(20130)) : Null);
} else if (this.GetInitialCurrency() != null) {
return(new CharType(this.GetInitialCurrency()));
}
}
return Null;
}
}
DCurrency.prototype.IsAllowable = function(code) {
return code in this.mAllowable;
}
JCurrency.prototype.IsAllowable = function(code) {
return code in this.mObj.a;
}
DCurrency.prototype.GetInitialCurrency = function() {
return this.mInputNode.getAttribute("ic");
}
JCurrency.prototype.GetInitialCurrency = function() {
if ("ic" in this.mObj) {
return this.mObj.ic;
}
return null;
}
CurrencyPopup.prototype=new DIVPopup(); CurrencyPopup.prototype.constructor=CurrencyPopup; CurrencyPopup.superclass=DIVPopup.prototype;;
function CurrencyPopup(field) {
this.mField = field;
CurrencyPopup.superclass.init.call(this,false);
}
CurrencyPopup.prototype.ShowPopup = function(parentelement,ox,oy) {
;
var value = this.mField.G(); 
var val = "<table width=\"100%\" class=\"CurTable\">";
if (typeof(this.mField.mDate) != "undefined" && this.mField != null && this.mField.mDate >= 0 && !value.isNull) {
var t = new TimeType(this.mField.mDate);
val += "<tr><td nowrap colspan=2 height=25px align=top>" + getLocalizedMessage("Value based on {0}", [t.toString()]) + "</td></tr>";
}
for (var c in this.mField.mFunctional) {
val += "<tr><td class=CurSym>" + c + "</td><td class=CurVal>";
if (value.mFunc && typeof(value.mFunc) == "object" && c in value.mFunc && "v" in value.mFunc[c] && value.mFunc[c].v != null) {
var dec = DecimalType.Round(value.mFunc[c].v, value.mFunc[c].p);
val +=  En_USDecimalToLC(dec.toString());
}
val += "</td></tr>";
}
val += "</table>";
this.SetContents(this.mField.GLabel(), val);
CurrencyPopup.superclass.ShowPopup.call(this,parentelement,ox,oy);
}
DCurrency.prototype.HandleMenuSelection = function(cur) {
cur = cur.substring(0, 3);
var val = this.mInputNode.value;
if (val == "") {
this.SetScreenValue(cur);
this.SetDirty(this.mInputNode);
return;
} 
var re = /(.*)[A-Z,a-z][A-Z,a-z][A-Z,a-z]$/
if (val.match(re)) {
val = val.replace(re, "$1");
}
val = val.trim(1|2);
try {
val = new BigDecimal(LCDecimalToEn_US(val));
} catch (err) {
val = null;
}
if (val != null) {
var p = this.mAllowable[cur].p;
val = new DecimalType(val, p).toString() + " " + cur;
} else
val = cur;
this.SetScreenValue(val);
this.SetDirty(this.mInputNode);
}
DCurrency.prototype.IsAllowable = function(code) {
return code in this.mAllowable;
}
JCurrency.prototype=new Field(); JCurrency.prototype.constructor=JCurrency; JCurrency.superclass=Field.prototype;;
JFieldFactories["Currency"]=function(id,n) {
return new JCurrency(id,n);
}
JCurrency.prototype.mIsComplexField=true;
function JCurrency(a,b) {
if(arguments.length)
this.init(a,b);
}
JCurrency.prototype.init=function(id, n) {
JCurrency.superclass.init.call(this,id,n);
if(!("p" in this.mObj))
this.mObj.p=2; 
if (!("a" in this.mObj)) {
this.mObj.a = {};
for (var c in currencyCodes)
{
if (!("d" in this.mObj))
this.mObj.d = c;
this.mObj.a[c] = currencyCodes[c].p;
}
}
}
JCurrency.prototype.mHaveStoredData=true;
JCurrency.prototype.G=function() {
;
var val = this.mObj.v;
if (val.isNull) {
return Null;
}
if (val.type != 12) {
val = new CurrencyType(val, this, true);
}
if (val.mCurCode == null || val.mCurCode == "") {
val.mCurCode = this.mObj.d;
}
if (!(val.mCurCode in this.mObj.a)) {
return Null;
} else {
this.mObj.v.mFunc = {};
for (var c in this.mObj.f) {
this.mObj.v.mFunc[c] = {p : this.mObj.f[c]};
}  
val = val.CurrSetDate(val.getDate());
}
val.mPrecision = this.GetPrecision(val.mCurCode);
return val;
}
JCurrency.prototype.GetDefaultCurrency = function() {
return this.mObj.d;
}
JCurrency.prototype.GetPrecision = function(curCode) {
if ("a" in this.mObj && curCode in this.mObj.a) {
return this.mObj.a[curCode];
}
return 2;
}
JCurrency.prototype.DoSet=JCurrency.prototype.DoSLoadEntry=function(val) {
;
this.mObj.v=val;
this.SetDirty();
}
JCurrency.prototype.IsAllowable = function(code) {
return code in this.mObj.a;
}
JCurrency.prototype.Validate=function() {
var val = this.G();
if (val.isNull)
return null;
return Currency_Validate(this, val, new BigDecimal(this.mObj.min), new BigDecimal(this.mObj.max));
}
function Currency_Validate(field, val, min, max) {
;
;
var isDirty = field.mLastChanged && Field_LastCleared<=field.mLastChanged;
if(!isDirty)
return null;
var dec = val.toDecimal();
if (min.compareTo(dec) > 0 || max.compareTo(dec) < 0)
return {t:2,n:9272,m:null,a:"" + min + "," + max + " : " + field.GLabel()};
if (field.IsAllowable(val.mCurCode)) {
return null;
}
return {t:2, n:9326, m:null, a:"" + field.G().toString() + " : " + field.GLabel()};
}
var CurrencyRatios = {};
function GetExchangeRates(s, t) {
var cached = false;
if (s in CurrencyRatios && t in CurrencyRatios[s])
{
var exp = CurrencyRatios[s][t].expires;
if (exp > new Date().UnixTimestamp())
cached = true;
}
if (cached)
{
return CurrencyRatios[s][t];
}
else
{
var ratios;
if (CurWFC)
ratios = new NDXGetCurrencyExchangeRates(s, t).GetResult();
else {
new WorkflowContext({f:function(){
ratios=new NDXGetCurrencyExchangeRates(s, t).GetResult();
}});
}
if (!(s in CurrencyRatios))
{
CurrencyRatios[s] = {};
}
CurrencyRatios[s][t] = ratios;
return ratios;
}
}
DCurrency.prototype.EqualsDefaultValue = function(err) {
var def = this.GDefault();
if (def == null) {
return false;
}
if ((!("d" in Defaults[this.mID])) && def instanceof CharType) {
return this.mInputNode.value.trim(1|2) == def.toString();
}
return DCurrency.superclass.EqualsDefaultValue.call(this, err);
}

DDiary.prototype=new DataField(); DDiary.prototype.constructor=DDiary; DDiary.superclass=DataField.prototype;;
DOMFieldFactories["Diary"]=function(id,n) {
return new DDiary(id,n);
}
var DiaryFields = [];
function DDiary(a,b) {
if(arguments.length)
this.init(a,b);
DiaryFields.push(this);
}
DDiary.prototype.init=function(id, n) {
this.mInputNode=n.childNodes[1];
;
DDiary.superclass.init.call(this,id,n);
}
DDiary.prototype.ConvertPrimitiveToDataType=function(str) {
;
return new CharType(str);
}
DDiary.prototype.FromUIInput = function(val, validate, expand) {
if (expand) 
val = ExpandString(val, 2 | 4, this.mID, 10);
val = val.trim(1|2);
if (val == "")
return Null;
return new CharType(val);
}
DDiary.prototype.UpdateExpandImage = function(hasData) {
var node = this.mObj.firstChild;
while (node && (!node.firstChild || node.firstChild.tagName != "IMG")) {
node = node.nextSibling;
}
if (node) {
node = node.firstChild;
;
;
if (hasData) {
node.src = node.src.replace(/diary_empty/,"diary_full");
}
else {
node.src = node.src.replace(/diary_full/,"diary_empty");
}
}
}
DDiary.prototype.SetHistory=function(hist) {
if (this.mHistory != hist) {
this.UpdateExpandImage(hist != null);
this.mHistory = hist;
if (this.mCharEditBox)
CharEditBoxPopup_UpdateHistory(this.mCharEditBox, hist==null?"":hist);
}
}
DDiary.prototype.DoSLoadEntry=function(dt) {
if (dt.isNull)
this.SetHistory(null);
DDiary.superclass.DoSLoadEntry.call(this,dt);
}
DDiary.prototype.ConvertDTForSLE=function(val) {
;
this.mDeferred = false;
if (val instanceof DiaryType) {
this.SetHistory(val.toString());
return CharNull;
}
this.SetHistory(null);
return this.ConvertDTForS(val);
}
DDiary.prototype.ConvertDTForS=function(val) {
;
if (val.type==4)
return val;
return new CharType(val.toString());
}
DDiary.prototype.GDefault=function() {
var ret=DDiary.superclass.GDefault.call(this);
this.SetHistory(null);
return ret;
}
DDiary.prototype.Clear = function() {
var i = this.mID;
if((i>=1000000&&i<=1999999)||
(i>=3000000&&i<=3999999)||
i==1576||i==1575)
return;
DDiary.superclass.Clear.call(this);
this.SetHistory(null);
}
DDiary.prototype.mHaveStoredData=true;
DDiary.prototype.GetHistory=function() {
if (!this.mDeferred)
return this.mHistory;
var wfcNotes=CurWFC.notes;
CurWFC.notes=[];
var req = new NDXGetEntry(this.mServer, this.mSchema, ((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""), window.name, this.mEntry, [this.mID], false);
var res = req.result;
CurWFC.notes=wfcNotes;
;
this.mHistory = "";
if (res instanceof Array) {
if (res.length > 0) { 
; 
var dt = Datatype_Factory(res[0]);
if (dt.type==5)
this.SetHistory(dt.toString());
}
}
this.mDeferred = false;
return this.mHistory;
}
DDiary.prototype.DOMClick=function(evt) {
;
if (this.GAccess() == 3)
return;
var e=FakeButton_Find(evt.element);
if (e) {
if (e.className.indexOf("diary") != -1) {
var val = this.mInputNode.value;
var ro = this.GAccess() == 1;
var hist = this.GetHistory();
var ebArgs = {diary:hist, value:val, readonly:ro};
var to = this;
if(!this.mCharEditBox) {
var to = this;
this.mCharEditBox=CharEditBoxPopup(this.mID,ebArgs,function(retObj) {
;
if (retObj.retval) {
var newVal = retObj.retval+"";
if (newVal!=to.mInputNode.value) {
to.SetScreenValue(newVal);
to.SetDirty(to.mInputNode);
}
}
to.mCharEditBox=null;
});
} else
this.mCharEditBox.focus();
}
}
}
DDiary.prototype.DOMKeyPress=function(evt) {
;
if (evt.key==13) {
if (evt.shift || (this.mInputNode.getAttribute("wrap")=="off")) {
evt.StopDefault();
return {c:{t:this, f:DDiary.superclass.DOMKeyPress, a:[evt]}};
} else {
}
}
}
DDiary.prototype.mDataType=4;
JDiary.prototype=new Field(); JDiary.prototype.constructor=JDiary; JDiary.superclass=Field.prototype;;
function JDiary(a,b) {
if(arguments.length)
this.init(a,b);
DiaryFields.push(this);
}
JDiary.prototype.mHaveStoredData=true;
JDiary.prototype.G=function() {
if (this.mDeferred) {
var req = new NDXGetEntry(this.mServer, this.mSchema, ((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""), window.name, this.mEntry, [this.mID], false);
var res = req.result;
;
if (res instanceof Array) {
if (res.length > 0) { 
; 
var dt = Datatype_Factory(res[0]);
this.SLoadEntry(dt);
}
} else {
;
}
this.mDeferred = false;
}
;
var val = this.mObj.v;
if (val.isNull || val.toString() == "")
return CharNull;
else if (val.type == 4) 
return val;
else {
this.mObj.v = new CharType(val);
return this.mObj.v;
}
}
JDiary.prototype.DoSLoadEntry=function(val) {
if (val instanceof DiaryType)
this.mObj.v = Null;
else
this.mObj.v = val;    
this.mDeferred = false;
}
JDiary.prototype.Clear=function() {
this.mDeferred=false;
JDiary.superclass.Clear.call(this);
}
JDiary.prototype.DoSet=function(val) {
;
var hasKeywords={hasKeyword:false,hasTemporalKeyword:false};
var primVal = ExpandString(val.toString(), 2 | 4 | 8, this.mID, this.mDataType, hasKeywords);
if (hasKeywords.hasTemporalKeyword) {
this.mObj.v=val; 
} else {
if ((this.mDataType==4) && !hasKeywords.hasKeyword) {
this.mObj.v=val;
} else {
this.mObj.v=new CharType(primVal);
}
}
this.SetDirty();
this.mDeferred = false;
}
DDiary.prototype.mDeferred=JDiary.prototype.mDeferred=false;
DDiary.prototype.Defer=function(server, schema, entry) {
if (this.mID in Form.displayOnlyFields) {
this.mDeferred = false;
return;
}
this.S(Null);
this.mHistory = "";
this.mServer = server;
this.mSchema = schema;
this.mEntry = entry;
this.mDeferred = true;
this.UpdateExpandImage(true);
}
JDiary.prototype.Defer=function(server, schema, entry) {
if (this.mID in Form.displayOnlyFields) {
this.mDeferred = false;
return;
}
this.S(Null);
this.mServer = server;
this.mSchema = schema;
this.mEntry = entry;
this.mDeferred = true;
}
DDiary.SetDiaryFieldsDeferred=function(server, schema, entry) {
for (var f in DiaryFields)
DiaryFields[f].Defer(server, schema, entry);
}

DReal.prototype=new DataField(); DReal.prototype.constructor=DReal; DReal.superclass=DataField.prototype;;
DOMFieldFactories["Real"]=function(id,n) {
return new DReal(id,n);
}
function DReal(id,n) {
if(arguments.length)
this.init(id,n);
}
DReal.prototype.init=function(id,n) {
this.mInputNode=n.childNodes[1];
;
DReal.superclass.init.call(this,id,n);
}
DReal.prototype.mHaveStoredData=true;
DReal.prototype.mDataType=3;
DReal.prototype.ConvertPrimitiveToDataType=function(str) {
;
return this.FromUIInput(str,false,false);
}
DReal.prototype.GetQBEValue=function() {
if (this.IsNullKeyword())
return NullType.KEYWORD_NULL;
var val = this.mInputNode.value;
val = ExpandString(val, 2 | 4, this.mID, 3);
val = val.trim(1|2);
if (val == "")
return Null;
var qbeOp = Field.GetQBEOperator(val);
if (qbeOp == null) {
var errs = this.Validate();
if (errs) {
throw(errs);
}
return this.G();
} else {
var valPart = this.FromUIInput(val.substring(qbeOp.length).trim(1), true, false);
return new CharType(qbeOp + valPart.toPrimitive());
}
}
DReal.prototype.ConvertDTForS=DReal.prototype.ConvertDTForSLE=function(val) {
;
var p = parseInt(this.mInputNode.getAttribute("ARPrecision"));
if ((val.type==3) && val.mPrecision==p)
return val;
return new RealType(val.toReal(), p);
}
DReal.prototype.GDefault=JReal.prototype.GDefault=function() {
if("d" in Defaults[this.mID])
return(new RealType(Defaults[this.mID].d));
else
return(Null);
}
DReal.prototype.FromUIInput = function(val, validate, expand) {
if (expand)
val = ExpandString(val, 2 | 4, this.mID, 3);
val = val.trim(1|2);
if (val == "")
return Null;
return new RealType(LCRealToEn_US(val, validate), parseInt(this.mInputNode.getAttribute("ARPrecision")));
}
DReal.prototype.Validate=function() {
var node = this.mInputNode;
var min = node.getAttribute("ARMin");
var max = node.getAttribute("ARMax");
try {
var val = this.FromUIInput(node.value,true,true);
return Real_Validate(this, val, min, max);
} catch (err) {
err.a += ": " + this.GLabel();
return err;
}
}
JReal.prototype=new Field(); JReal.prototype.constructor=JReal; JReal.superclass=Field.prototype;;
JFieldFactories["Real"]=function(id,n) {
return new JReal(id,n);
}
function JReal(a,b) {
if(arguments.length)
this.init(a,b);
}
JReal.prototype.init=function(id, n) {
JReal.superclass.init.call(this,id,n);
if(!("p" in this.mObj))
this.mObj.p=6; 
}
JReal.prototype.mHaveStoredData=true;
JReal.prototype.G=function() {
;
var val = this.mObj.v;
if (val instanceof NullType)
return val;
else if (val.type == 3) { 
val.mPrecision = this.mObj.p; 
return val;
} else {
this.mObj.v = new RealType(val, this.mObj.p);
return this.mObj.v;
}
}
JReal.prototype.DoSet=JReal.prototype.DoSLoadEntry=function(val) {
;
this.mObj.v=val;
this.SetDirty();
}
JReal.prototype.Validate=function() {
var val = this.G();
if (val.isNull)
return null;
return Real_Validate(this, val, this.mObj.min, this.mObj.max);
}
function Real_Validate(field, val, min, max) {
;
;
var isDirty = field.mLastChanged && Field_LastCleared<=field.mLastChanged;
if(!isDirty)
return null;
val = val.toReal();
if (val < min || val > max)
return {t:2,n:9272,m:null,a:"" + min + "," + max + " : " + field.GLabel()};
return null;
}

AsyncField.prototype=new Field(); AsyncField.prototype.constructor=AsyncField; AsyncField.superclass=Field.prototype;;
var AsyncFields=[];
function AsyncField(id,obj) {
if(arguments.length)
this.init(id,obj);
}
AsyncField.prototype.init=function(id,n) {
AsyncField.superclass.init.call(this,id,n);
this.mAsyncMode=0;
this.mAsyncDirty=0;
this.mUIInstantiated=false;
this.mAsyncQueue=[];
;
this.SetAsync(1);
if(n.style.visibility=="hidden")
this.SetAsync(1);
var nw=n.offsetParent,notfound=true;
while(nw&&notfound) {
if(nw.nodeType==1&&nw.getAttribute("ARID"))
notfound=false;
else
nw=nw.offsetParent;
}
this.mParentField=null;
if(!notfound) {
var pfid=nw.getAttribute("ARID");
var theparent=F(pfid);
;
if(theparent instanceof DPage) {
this.mParentField=pfid;
this.SetAsync(1);
}
}
this.mAsyncDirty=(1>this.mAsyncDirty?1:this.mAsyncDirty); 
AsyncFields.push(this);
}
AsyncField.prototype.SetAsync=function(async) {
;
;
;
if(this.mAsyncMode==0&&async==1) {
this.mAsyncDirty=0;
} else if(this.mAsyncMode==1&&async==-1) {
this.FlushAsyncQueue();
}
this.mAsyncMode+=async;
}
AsyncField.prototype.FlushAsyncQueue=function() {
}
function AsyncField_IncrAsyncRef(id,incr) {
;
;
for(var i in AsyncFields) {
if(AsyncFields[i].mParentField==id) {
AsyncFields[i].SetAsync(incr);
}
}
}
function AsyncField_DecrAsyncRef() {
for(var i in AsyncFields)
AsyncFields[i].SetAsync(-1);
}

BaseTable.prototype=new AsyncField(); BaseTable.prototype.constructor=BaseTable; BaseTable.superclass=AsyncField.prototype;;
BaseTable.prototype.mFtrObj=BaseTable.prototype.mHdrObj=BaseTable.prototype.mHdrLObj=BaseTable.prototype.mFtrLObj=
BaseTable.prototype.mHdrRObj=BaseTable.prototype.mInnerObj=BaseTable.prototype.mChunkOuter=
BaseTable.prototype.mFtrRObj=BaseTable.prototype.mColHdrObj=BaseTable.prototype.mDataTableObj=null;
BaseTable.prototype.mDOMField=BaseTable.prototype.mHaveVisualCharacteristics=true;
BaseTable.prototype.mDirtyColumns=false;
BTColData.prototype.mWidth=BTColData.prototype.mBarX=BTColData.prototype.mX=0;
BTColData.prototype.mHeader=BTColData.prototype.mBar=BTColData.prototype.mColumn=null;
BTColData.prototype.mSortDir=1;
BTColData.prototype.mPrimarySort=false;
BTColData.prototype.mVisible=true;
function BTColData(datacol) {
this.mDataCol=datacol; 
}
BTColData.prototype.SetVisibility=function(vis,parent) {
;
;
if(vis==this.mVisible)
return;
if(parent.mFixedHeader) {
this.mHeader.style.visibility=(vis?"inherit":"hidden");
this.mBar.style.visibility=(vis?"inherit":"hidden");
}
this.mPrimarySort=false;
this.mVisible=vis;
}
BTColData.prototype.SetLabel=function(label) {
;
if(this.mHeader&&this.mHeader.firstChild)
this.mHeader.firstChild.data=label;
}
BaseTable.prototype.RestoreColData=function(arr) {
if(!arr instanceof Array||arr.length!=this.mColDatas.length)
return;
var vmap={}; 
for(var i in arr) {
if(!(i in this.mColDatas))
return;
var ai=arr[i];
if(!("dc" in ai)||!(ai.dc in this.mColDatas)||!("w" in ai)||!("ps" in ai)||!("sd" in ai))
return;
vmap[this.mColDatas[i].mDataCol]=this.mColDatas[i].mVisible;
}
for(var i in arr) { 
this.mColDatas[i].mDataCol=arr[i].dc;
this.mColDatas[i].mWidth=arr[i].w;
this.mColDatas[i].mPrimarySort=arr[i].ps;
this.mColDatas[i].mSortDir=arr[i].sd;
this.mColDatas[i].mVisible=vmap[arr[i].dc];
}
this.mFirstLayout=true; 
this.ApplyData();
}
BaseTable.prototype.ResetColData=function() {
var a=[],widths=this.GetInitialColumnWidths();
for(var i in this.mColDatas) {
var w=widths[i]<5?5:widths[i];
a[i]={dc:parseInt(i),w:w,ps:false,sd:-1};
}
this.mSortOrder = [];
this.RestoreColData(a);
}
BaseTable.prototype.GetColData=function() {
var res=[];
for(var i in this.mColDatas) {
var cdi=this.mColDatas[i];
res[i]={dc:cdi.mDataCol,w:cdi[i].mWidth,ps:cdi.mPrimarySort,sd:cdi.mSortDir};
}
return res;
}
function BaseTable_DragHandler(di) {
var tname=di.srcElement.getAttribute("ARTableID");
;
Fields[tname].DragHandler(di);
}
BaseTable.prototype.DOMMouseOver=function(ed) {
var e=ed.element;
while(e&&!(e.tagName=="TD"||e.tagName=="DIV"))
e=e.offsetParent;
if(e!=null&&(e.className.indexOf("BaseTableCell")!=-1||e.className.indexOf("BaseTableHeader")!=-1)) {
if(e.scrollWidth<=e.offsetWidth)
e.setAttribute("title","");
else
if(!e.getAttribute("title")) {
if(e.firstChild.nodeType==1&&e.firstChild.firstChild&&e.firstChild.firstChild.nodeType==3) {
e.setAttribute("title",e.firstChild.firstChild.data);
} else if(e.firstChild.nodeType==3) {
e.setAttribute("title",e.firstChild.data);
}
}
}
}
BaseTable.prototype.SyncCaret=function(ed,rowno)
{
if (ed.className!="BaseTableInlineEdit" || this.mCurrentCol==-1)
return;
var rowElem=this.FishOutTR(rowno);
;
var elem=rowElem.childNodes[this.mCurrentCol].lastChild; 
elem.focus();
}
BaseTable.prototype.DOMKeyDown=function(ed) {
;
if(this.mRowsPresent==0)
return;
if(ed.key==13) { 
if(this.mPrimaryRowSelection==null)
return;
ed.StopDefault();
return this.ARDrillDown({x:0,y:this.RowNoFromTag(this.mPrimaryRowSelection)},false);
} else if((ed.key==38||ed.key==40)&&this.mSelRow!=1) {
ed.StopDefault();
var dir=(ed.key==38?-1:1);
var rowno;
if(this.mPrimaryRowSelection==null)
rowno=0;
else
rowno=this.RowNoFromTag(this.mPrimaryRowSelection)+dir;
rowno=(rowno<0?0:rowno);
rowno=(rowno>=this.mRowsPresent?this.mRowsPresent-1:rowno);
var estack=[];
if(ed.shift&&this.mSelRow==0) {
return {c:{f:this.FillSelections,t:this,a:[this.mLastNonShiftedRowSelection,rowno,true]},n:{t:this,f:this.ApplySelections}};
} else {
estack.push({f:function() {this.SyncCaret(ed.element,rowno);},t:this});
estack.push({t:this,f:this.ApplySelections}); 
estack.push({f:this.SetPrimarySelection,t:this,a:[rowno,true,true]});
return {n:estack};
}
} else if((ed.key==65&&ed.ctrl)&&this.mSelRow!=1) { 
ed.StopDefault();
return {c:{f:this.FillAllSelections,t:this},n:{f:this.ApplySelections,t:this}};
}
}
BaseTable.prototype.DragHandler=function(di) {
;
var e=di.srcElement;
var x=di.mx+this.mScrollLeft; 
if(e.className.indexOf("BaseTableBar")!=-1) {
var col=parseInt(e.getAttribute("ARColumnID"));
;
if(di.state==0) { 
var startcol=(this.mColDatas[col].mX+5)-this.mScrollLeft;
di.dragContext.SetDragBounds(startcol,null,startcol+(this.mWidth-11),null);
} else {
if(di.original||(!di.original&&di.state==2)) {
this.mColDatas[col].mWidth+=x-this.mColDatas[col].mBarX;
if(this.mColDatas[col].mWidth<5) 
this.mColDatas[col].mWidth=5;
this.ApplySizes();
this.UpdateScrollOffset();
}
}
} else { 
var col=null;
if(di.state==0) { 
for(var i=0;i<this.mColDatas.length&&col==null;++i)
if(x>=this.mColDatas[i].mX&&x<(this.mColDatas[i].mX+this.mColDatas[i].mWidth)&&this.mColDatas[i].mVisible)
col=i;
this.mColDragInfo={mLeft:-1,mRight:-1,mOrigCol:col,mCol:col};
this.SetColHeaderStyles(false);
} else if(di.state==1) {
var smalldist=999999999,lastviscol=null;
for(var i=0;i<this.mColDatas.length;++i) {
if(this.mColDatas[i].mVisible) {
var dist=Math.abs(x-this.mColDatas[i].mX);
if(dist<smalldist) {
smalldist=dist;
col=i;
}
lastviscol=i;
}
}
if(lastviscol!=null) {
var dist=Math.abs(x-(this.mColDatas[lastviscol].mX+this.mColDatas[lastviscol].mWidth));
if(dist<smalldist) { 
smalldist=dist;
col=lastviscol+1;
for (var i=col; i<this.mColCnt; i++) {
;
col+=1;
}
}
}
;
var right=col-1,left=col; 
while(right in this.mColDatas&&!this.mColDatas[right].mVisible)
--right;
;
this.SetColHeaderStyles(true);
this.mColDragInfo.mLeft=left;
this.mColDragInfo.mRight=right;
this.mColDragInfo.mCol=col;
this.SetColHeaderStyles(false);
} else {
this.SetColHeaderStyles(true);
if(di.state==2) {
var orig=this.mColDragInfo.mOrigCol,newcol=this.mColDragInfo.mCol;
;
var newcols=[];
for(var i=0;i<this.mColCnt;++i) {
if(i==newcol)
newcols.push(this.mColDatas[orig]);
if(i!=orig)
newcols.push(this.mColDatas[i]);
}
if(newcols.length==this.mColCnt-1) 
newcols.push(this.mColDatas[orig]);
;
this.mColDatas=newcols;
this.mDirtyColumns=true;
this.ApplyData();
}
this.mColDragInfo=null;
}
}
}
BaseTable.prototype.SColVis=function(col,vis) {
;
;
;
for(var i=0;i<this.mColCnt;++i) {
if(this.mColDatas[i].mDataCol==col) {
this.mColDatas[i].SetVisibility(vis,this);
this.mDirtyColumns=true;
return;
}
}
;
}
BaseTable.prototype.SColLabel=function(col,lab) {
;
;
;
for(var i in this.mColDatas) {
if(this.mColDatas[i].mDataCol==col) {
this.mColDatas[i].SetLabel(lab);
this.mDirtyColumns=true;
return;
}
}
;
}
BaseTable.prototype.ScaleSizes=function() {
var totw=0,scale=false,scalefactor=1;
for(var i in this.mColDatas) {
if(this.mColDatas[i].mVisible) {
totw+=this.mColDatas[i].mWidth;
;
}
}
scalefactor=this.mWidth/totw;
if(scalefactor==1)
return;
for(var i in this.mColDatas) {
if(this.mColDatas[i].mVisible) {
var cdi=this.mColDatas[i];
cdi.mWidth=Math.floor(cdi.mWidth*scalefactor);
;
}
}
}
BaseTable.prototype.SetColHeaderStyles=function(clear) {
var l=this.mColDragInfo.mLeft,r=this.mColDragInfo.mRight
if(l in this.mColDatas&&this.mColDatas[l].mHeader) this.mColDatas[l].mHeader.className=clear?"BaseTableHeader":"BaseTableHeaderDragL";
if(r in this.mColDatas&&this.mColDatas[r].mHeader) this.mColDatas[r].mHeader.className=clear?"BaseTableHeader":"BaseTableHeaderDragR";
}
function BaseTable(id,n,a,b) {
if(arguments.length)
this.init(id,n,a,b);
}
BaseTable.prototype.Resize=function(width,height) {
;
this.mObj.style.height=height;
if(this.mHdrObj!=null&&this.mFtrObj!=null) {
var theadheight=this.mHdrObj.offsetHeight,tfootheight=this.mFtrObj.offsetHeight;
var innerh=height-theadheight-tfootheight;
if(!this.mHdrLObj.firstChild&&!this.mHdrRObj.firstChild&&this.mChunkOuter==null&&
!this.mObj.getAttribute("AREntRetStr")&&!this.mObj.getAttribute("ARNotRefStr")) {
this.mHdrObj.style.visibility="hidden";
this.mInnerObj.style.top=0;
innerh+=theadheight;
}
this.mFtrObj.style.top=height-tfootheight;
if(!this.mFtrLObj.firstChild&&!this.mFtrRObj.firstChild) {
this.mFtrObj.style.visibility="hidden";
innerh+=tfootheight;
}
if(innerh<0) innerh=0;
this.mInnerObj.style.height=innerh;
this.mObj.style.width=width;
width-=2;
if(width<0) width=0;
this.mInnerObj.style.width=width;
this.mFtrObj.style.width=this.mHdrObj.style.width=width;
;
;
this.mHdrObj.firstChild.style.width=this.mFtrObj.firstChild.style.width=width;
height=innerh;
}
this.mHeight=(height>2?height-2:2);
this.mOuter.style.height=this.mHeight;
if(this.mFixedHeader) {
var innerh=this.mHeight-16;
this.mInner.style.height=(innerh<0?0:innerh);
} else
this.mInner.style.height=this.mHeight;
this.mWidth=(width>2?width-2:2);
this.mOuter.style.width=this.mInner.style.width=this.mWidth;
if(this.mColHdrObj!=null) {
var x=0;
for(var j=0;j<this.mColCnt;++j) {
if(this.mColDatas[j].mVisible)
x+=this.mColDatas[j].mWidth;
}
this.mColHdrObj.style.width=(this.mWidth>x?this.mWidth:x);
this.UpdateScrollOffset();
}
this.ApplySizes();
}
BaseTable.prototype.UpdateScrollOffset=function() {
this.mScrollLeft=this.mInner.scrollLeft;
if(this.mFixedHeader) 
this.mColHdrObj.style.left=-this.mScrollLeft;
}
BaseTable.prototype.MakeTableTitle=function(accStr) {
var accTitle = this.GLabel();
if (accTitle==null) accTitle="";
return accTitle;
}
BaseTable.prototype.InstantiateUI=function(pnt) {
this.mParent=pnt;
var markup=[];
markup.push("<DIV class='BaseTableOuter' draghandler='BaseTable_DragHandler'>");
if(this.mFixedHeader)
this.BuildColumnHeaders(markup);
markup.push("<DIV class='BaseTableInner'></DIV></DIV>");
this.mScrollLeft=0;
this.mParent.innerHTML=markup.join("");
this.mOuter=this.mParent.firstChild;
;
if(this.mFixedHeader) {
this.RefreshHeaderRefs();
this.mInner=this.mOuter.childNodes[1];
;
} else
this.mInner=this.mOuter.firstChild;
if(this.mFixedHeader)
this.mInner.style.top=16;
this.mInner.onscroll=FormEvent.Trampoline(BaseTable_OnScroll);
}
function BaseTable_OnScroll(ed) {
var table=Field_FromElement(ed.element);
if(table)
table.UpdateScrollOffset();
}
BaseTable.prototype.init=function(arid,arn,fixedheader,selrow,scroll) {
;
;
BaseTable.superclass.init.call(this,arid,arn);
this.mSelRow=selrow;
this.mCurrentCol=-1; 
this.mParent=null; 
this.mFixedHeader=fixedheader;
this.mRowsPresent=0; 
this.mFirstLayout=true;
this.mHScroll=scroll;
this.mColDragInfo=null;
this.mLastNonShiftedRowSelection=0;
this.mPrimaryRowSelection=this.mARRowSelection=null;
this.mRowSelections=[];
this.mColDatas=[]; 
var cols=this.GetColumnInfo();
this.mColCnt=cols.length;
for(var i=0;i<this.mColCnt;++i)
this.mColDatas.push(new BTColData(i));
}
BaseTable.prototype.DOMClick=function(ed) {
var e=ed.element;
while(e.nodeType!=1||(e.tagName!="DIV"&&e.tagName!="TR"))
e=e.parentNode;
if(e.className=="BaseTableHeader") {
var col=e.getAttribute("ARDataCol");
var primarycol;
for(var i in this.mColDatas) {
var cdi=this.mColDatas[i];
if(cdi.mDataCol==col) {
if ("dLen" in this.mColInfo[col] && (this.mColInfo[col].dLen==0 || this.mColInfo[col].dLen>255))
return;
primarycol = cdi;
if(!cdi.mPrimarySort)
cdi.mPrimarySort=true;
else
cdi.mSortDir=-cdi.mSortDir;
} else
cdi.mPrimarySort=false;
}
;
return this.Resort(primarycol.mDataCol, primarycol.mSortDir);
} else if(e.tagName=="TR") {
var estack=[]; 
var cell=this.MapUIXY(ed.element);
if(cell==null)
return;
var row=cell.y;
this.mCurrentCol=cell.x;
if(this.mSelRow!=1) {
if(!ed.ctrl&&!ed.shift) {
if(this.mPrimaryRowSelection==null||row!=this.RowNoFromTag(this.mPrimaryRowSelection)) {
estack.push({t:this,f:this.ApplySelections}); 
estack.push({f:this.SetPrimarySelection,t:this,a:[row,true,true]});
}
} else if(this.mSelRow==0) {
estack.push({t:this,f:this.ApplySelections}); 
estack.push({f:function() {this.mLastRowSelection=row;},t:this}); 
if(ed.shift&&ed.ctrl)
estack.push({f:this.FillSelections,t:this,a:[this.mLastRowSelection,row,false]});
else if(ed.shift)
estack.push({f:this.FillSelections,t:this,a:[row, this.mLastNonShiftedRowSelection,true]});
else if(ed.ctrl)
estack.push({f:this.EORSelections,t:this,a:[row]});
}
}
return {n:estack};
}
}
BaseTable.prototype.DOMDoubleClick=function(ed) {
var xy=this.MapUIXY(ed.element);
if(xy==null)
return;
return this.ARDrillDown(xy,false);
}
BaseTable.prototype.GetFocusElementForEvent=function(ed) {
;
var ele = ed.element;
if (this.GetNestedFocusability()) {
if ((ele.tagName == "A") || (ele.tagName=="INPUT") || (ele.tagName=="IMG"))
return ele;
else {
while(ele &&(ele.nodeType!=1||(ele.tagName!="DIV"&&ele.tagName!="TR")))
ele=ele.parentNode;
if (ele && ((ele.className=="BaseTableColHeaders"||ele.className=="BaseTableBar"||ele.className=="BaseTableHeader")||(ele.getAttribute("ARRow") != null)))
return ed.element; 
}
return this.GetFocusElement(); 
}
}
BaseTable.prototype.GetFocusElement=function(){
var row=(this.mPrimaryRowSelection==null)?0:this.RowNoFromTag(this.mPrimaryRowSelection);
var re = this.FishOutTR(row);
if (re==null) {
if (this.mOuter != null)
return this.mOuter;
return this.mObj;
}
return re;
}
BaseTable.prototype.TabableElementSelector=function(ele) {
;
if (ele.tagName=="A") {
var fb = FakeButton_Find(ele);
if (fb!=null)
return FakeButton_TabableElementSelector(fb);
else 
return null;
}
if (ele.tagName=="INPUT") {
var r = ele.parentNode;
while(r.tagName!="TR" && r)
r=r.parentNode;
if (r && r==this.GetFocusElement()) {
return ele;
}    
} else if ((ele.tagName=="TR") && (this.GetFocusElement()==ele))
return ele;
else if (ele.tagName=="TABLE" && ele.className && ele.className=="BaseTable")
return ele;
return null;
}
BaseTable.prototype.MapUIXY=function(e) {
;
var row,col=0,td=null;
while(e&&e.tagName!="TR") {
if(e.tagName=="TD")
td=e;
e=e.parentNode;
}
if(e&&e.getAttribute("ARRow")!=null&&td!=null)
row=parseInt(e.getAttribute("ARRow"));
else
return null; 
if(row>=this.mRowsPresent)
return null;
while(td.previousSibling) {
td=td.previousSibling;
++col;
}
if(col>=this.mColCnt) 
return null;
return{y:row,x:col};
}
BaseTable.prototype.MapUIXToData=function(uix) {
;
var vc=0,i=0;
for(;i<this.mColDatas.length;++i) {
if(this.mColDatas[i].mVisible)
++vc;
if(vc==uix+1)
break;
}
if(vc!=uix+1)
return null; 
return this.mColDatas[i].mDataCol;
}
BaseTable.prototype.FishOutTR=function(row) {
if(row<0||row>=this.mRowsPresent||this.mDataTableObj==null)
return null;
var tbody=this.mDataTableObj.lastChild;
;
;
return tbody.childNodes[row + ((this.mHiddenColHdrPresent) ? 1 : 0)];
}
BaseTable.prototype.TagFromRowNo=function(row) {
;
return row;
}
BaseTable.prototype.RowNoFromTag=function(no) {
return parseInt(no);
}
BaseTable.prototype.ARRowSelected=BaseTable.prototype.ARRowCleared=BaseTable.prototype.ARDrillDown=function(a,b,c) {}
BaseTable.prototype.SetPrimarySelection=function(row,domenuchoice,selectnewentry) {
;
;
var prevSelection=this.mARRowSelection;
this.ClearSelections(true);
;
var tag=this.TagFromRowNo(row);
this.mRowSelections[tag]=true;
this.mPrimaryRowSelection=tag;
this.mLastNonShiftedRowSelection=row;
this.mARRowSelection=row+1;
this.mLastRowSelection=row;
return {n:{t:this,a:[domenuchoice,selectnewentry,prevSelection],f:this.ARRowSelected}};
}
BaseTable.prototype.ClearSelections=function(clearar) {
;
this.mRowSelections=[];
this.mPrimaryRowSelection=null;
if(clearar) {
this.mARRowSelection=0;
this.ARRowCleared();
}
}
BaseTable.prototype.EORSelections=function(row) {
;
;
var rowtag=this.TagFromRowNo(row);
this.mLastNonShiftedRowSelection=row;
if(rowtag in this.mRowSelections) {
var count = 0;
for (var i in this.mRowSelections)
count++;
if (rowtag != this.mPrimaryRowSelection || count == 1) {
delete this.mRowSelections[rowtag];
count--;
}
if(count==0)
this.ClearSelections(true);
} else {
this.mRowSelections[rowtag]=true;
var prevSelected=this.mARRowSelection;
var count = 0;
for (var i in this.mRowSelections)
count++;
if(count==1) {
this.mARRowSelection=row+1;
return {c:{f:this.SetPrimarySelection,t:this,a:[row,true,true]}};
}
}
}
BaseTable.prototype.FillSelections=function(last,row,doclear) {
;
;
;
;
this.ClearSelections(false);
var incr=(last<row?-1:1),origrow=row,done=false;
while(!done) {
this.mRowSelections[this.TagFromRowNo(row)]=true;
row+=incr;
done=(incr==-1)?row<last:row>last;
}
if(this.mPrimaryRowSelection!=null)
delete this.mRowSelections[this.mPrimaryRowSelection];
this.mPrimaryRowSelection=this.TagFromRowNo(origrow);
}
BaseTable.prototype.FillAllSelections=function() {
;
;
if(this.GetData().length==0)
return;
var prevSelected=this.mARRowSelection;
this.mPrimaryRowSelection=null;
var estack=[]; 
estack.push({f:this.ARRowSelected,t:this,a:[false,true,prevSelected]});
estack.push({t:this,f:function() {this.mARRowSelection=(this.mPrimaryRowSelection==null?0:1);}});
estack.push({f:this.FillSelections,t:this,a:[this.GetData().length-1,0,false]});
return {n:estack};
}
BaseTable.prototype.ApplySelections=function() {
var row=this.FishOutTR(0),rowNoMap={};
var count = 0;
if(row!=null) { 
var primrowno=-1;
for(var i in this.mRowSelections) {
rowNoMap[this.RowNoFromTag(i)]="SelSecondary";
count++;
}
if(this.mPrimaryRowSelection!=null) {
primrowno=this.RowNoFromTag(this.mPrimaryRowSelection);
rowNoMap[primrowno]="SelPrimary";
}
var work={},workcnt=0;
for(var i in this.mLastRowSelections) {
if(!(i in rowNoMap)) {
work[i]="";
++workcnt;
}
}
for(var i in rowNoMap) {
if(rowNoMap[i]!=this.mLastRowSelections[i]){
work[i]=rowNoMap[i];
++workcnt;
}
}
if(workcnt>1750) { 
for(var rowcnt=0;row;row=row.nextSibling,++rowcnt)
row.className=(rowcnt in work)?work[rowcnt]:"";
} else { 
var prow=row.parentNode,offset=this.mHiddenColHdrPresent?1:0;
for(var i in work)
prow.childNodes[parseInt(i)+offset].className=work[i];
}
}
this.mLastRowSelections=rowNoMap;
if(primrowno>=0 && this.mObj.style.display != "none") {
var tr=this.FishOutTR(primrowno);
if(tr!=null) {
var th=tr.offsetHeight,ycoord=0,innerh=this.mInner.clientHeight;
;
while(tr!=this.mInner) {
ycoord+=tr.offsetTop;
tr=tr.offsetParent;
;
}
if(ycoord<this.mInner.scrollTop)
this.mInner.scrollTop=ycoord;
else {
var sbot=this.mInner.scrollTop+innerh,ybot=ycoord+th;
if(ybot>=sbot)
this.mInner.scrollTop=ybot-innerh;
}
}
}
if (this.mID == 1020 && this.mFtrRObj) {
var selStr = getLocalizedMessage("{0} rows selected");
selStr=selStr.replace(/\{0\}/,count);
NodeWrite(this.mFtrRObj, selStr);
}
}
BaseTable.prototype.Resort=function(col, dir) {
;
;
this.ApplyData();
}
BaseTable.prototype.BuildColumnHeaders=function(content) {
var cols=this.GetColumnInfo();
;
;
content.push("<DIV class='BaseTableColHeaders'>");
var oc="<DIV class='BaseTableHeader' draggable=1 ARTableID=",mc=" ARDataCol=",ec=">",cc="</DIV>";
var colopen="<DIV class='BaseTableBar' draggable=1 dragHandler='BaseTable_DragHandler' ARTableID=",colmid=" ARColumnID=",colend="><DIV></DIV></DIV>";
for(var i=0;i<this.mColCnt;++i) {
;
if(this.mColDatas[i].mVisible) {
content.push(oc);
content.push(this.mID);
content.push(mc);
content.push(this.mColDatas[i].mDataCol);
content.push(ec);
content.push(cols[this.mColDatas[i].mDataCol].heading);
content.push(cc);
}
}
for(var i=0;i<this.mColCnt;++i) {
if(this.mColDatas[i].mVisible) {
content.push(colopen);
content.push(this.mID);
content.push(colmid);
content.push(i);
content.push(colend);
}
}
content.push("</DIV>");
}
BaseTable.prototype.RefreshHeaderRefs=function() {
this.mColHdrObj=this.mFixedHeader?this.mOuter.firstChild:this.mInner.firstChild;
;
var n=this.mColHdrObj.firstChild;
for(var i=0;i<this.mColCnt;++i) {
if(this.mColDatas[i].mVisible) {
;
this.mColDatas[i].mHeader=n;
n=n.nextSibling;
} else
this.mColDatas[i].mHeader=null;
}
for(var i=0;i<this.mColCnt;++i) {
if(this.mColDatas[i].mVisible) {
;
this.mColDatas[i].mBar=n;
n=n.nextSibling;
} else
this.mColDatas[i].mBar=null;
}
}
BaseTable.prototype.SetDefaultSizes=function() {
;
var cds=this.mColDatas,widths=this.GetInitialColumnWidths();
for(var i=0;i<this.mColCnt;++i) {
cds[i].mWidth=(widths[i]<5?5:widths[i]);
if(i==this.mColCnt-1&&this.mHScroll&&cds[i].mWidth>5*2)
cds[i].mWidth-=5; 
;
}
}
BaseTable.prototype.ApplyData=function() {
var content=[],colmk="<COL />";
if(!this.mFirstLayout&&this.mRowsPresent==0&&this.GetData().length==0&&!this.mDirtyColumns) { 
return;
}
this.mDirtyColumns=false;
if(!this.mFixedHeader)
this.BuildColumnHeaders(content);
content.push("<TABLE title=\"");
content.push(this.MakeTableTitle("").HTMLEncode());
var colbuff=[];
for(var i=0;i<this.mColCnt;++i)
if(this.mColDatas[i].mVisible)
colbuff.push(colmk);
content.push("\" class='BaseTable'><COLGROUP cols="+colbuff.length+">");
content.push(colbuff.join(""));
content.push("</COLGROUP><TBODY>");
if(this.mSortImgs!=null) {
for(var i in this.mSortImgs) {
if(this.mSortImgs[i].getAttribute("ARInDOM")==1) { 
this.mSortImgs[i]=this.mSortImgs[i].parentNode.removeChild(this.mSortImgs[i]);
this.mSortImgs[i].setAttribute("ARInDOM",0);
}
}
}
var primarysort=null;
for(var i in this.mColDatas) {
if(this.mColDatas[i].mPrimarySort) {
primarysort=this.mColDatas[i];
break;
}
}
if(primarysort==null&&this.mColDatas.length>0) {
var sort=this.GetInitialRowSortOrder();
if(sort!=null) {
for(var i in this.mColDatas) {
var ci=this.mColDatas[i];
if(ci.mDataCol==sort.col) {
ci.mPrimarySort=true;
ci.mSortDir=sort.dir;
primarysort=ci;
break;
}
}
}
}
if(primarysort!=null)
this.SetRowSortOrder(primarysort.mDataCol,primarysort.mSortDir);
var data;
if(this.mColDatas.length==0) 
data=[];
else
data=this.GetData();
;
this.mHiddenColHdrPresent=false;
if(data.length>0) {
var colinfo=this.GetColumnInfo();
var colmap={}; 
var premap=[[],[]],postmap=[[],[]],hiddenhdr=[];
var cn="CLASSNAME",cnst1="<TH scope=col >",cnst2="</TH>";
var addrowscope=false;
for(var i=0;i<this.mColCnt;++i) {
if(this.mColDatas[i].mVisible) {
hiddenhdr.push(cnst1);
hiddenhdr.push(colinfo[this.mColDatas[i].mDataCol].heading.HTMLEncode());
hiddenhdr.push(cnst2);
colmap[i]=this.mColDatas[i].mDataCol;
;
var cii=colinfo[colmap[i]];
if(cii.edit==2) {
premap[0][i]="<TD class=\""+cn+"\"><INPUT type=text class=BaseTableInlineEdit value=\"";
postmap[0][i]="\" /></TD>";
} else {
var pretdtag="<TD " + ((!addrowscope)? "scope=\"row\" " : "") ;
pretdtag += ((cii.edit==1)?" style=\"text-align:right\"":"");
pretdtag += " class=\""+cn+" BaseTableStaticText\">";
addrowscope = true;
if(cii.wrap) {
premap[0][i]=pretdtag+"<SPAN>";
postmap[0][i]=((cii.edit==1)?"<a class=\"btn btn3d DropMenu TableBtn\">v</a>":"")+"</SPAN></TD>";
} else {
premap[0][i]=pretdtag+"<NOBR>";
if (cii.edit==3) {
premap[0][i]+=("<input type=checkbox value="+cii.mEnumValue);
}
if (cii.edit==1) 
postmap[0][i]="<a class=\"btn btn3d DropMenu TableBtn\">v</a>";
else if (cii.edit==3)
postmap[0][i]=">&nbsp;"+cii.mEnumLabel; 
else 
postmap[0][i]="";
postmap[0][i]+="</NOBR></TD>"
}
}
}
}
for(var i in premap[0]) {
premap[1][i]=premap[0][i].replace(cn,"BaseTableCell");
premap[0][i]=premap[0][i].replace(cn,"BaseTableCellOdd");
postmap[1][i]=postmap[0][i].replace(cn,"BaseTableCell");
postmap[0][i]=postmap[0][i].replace(cn,"BaseTableCellOdd");
}
var compiler=[];
for(var j=0;j<this.mColCnt;++j) {
if(this.mColDatas[j].mVisible) {
compiler.push("content.push(premap["+j+"]);");
if (colinfo[this.mColDatas[j].mDataCol].edit==3)
compiler.push("content.push(di.d["+colmap[j]+"].v=='"+colinfo[j].mEnumLabel+"'?' CHECKED':' ');");
else
compiler.push("content.push(di.d["+colmap[j]+"].v);");
compiler.push("content.push(postmap["+j+"]);");
}
}
compiler=compiler.join("");
CompileFunction(compiler,"di,content,premap,postmap");
rowfunc=CompiledFunction;
this.mHiddenColHdrPresent=true;
content.push("<TR class=\"hiddentablehdr\">");
content.push(hiddenhdr.join(""));
content.push("</TR>");
var colours=this.GetRowColours();
var closerow="</TR>",endrow=">";
var openrow1="<TR tabindex=0 ARRow=";
if(colours==null) {
for(var i=0;i<data.length;++i) {
content.push(openrow1);content.push(i);content.push(endrow);rowfunc(data[i],content,premap[i&1],postmap[i&1]);content.push(closerow);
}
} else {
var openrows=[];
for(var i in colours)
openrows[i]="<TR tabindex=0 "+colours[i]+" ARRow=";
openrows[-1]=openrow1;
for(var i=0;i<data.length;++i) {
var di=data[i];
;
content.push(openrows[di.rc]);content.push(i);content.push(endrow);rowfunc(data[i],content,premap[i&1],postmap[i&1]);content.push(closerow);
}
}
} 
content.push("</TBODY></TABLE>");
this.mInner.innerHTML=content.join("");
this.mRowsPresent=data.length;
this.mDataTableObj=this.mFixedHeader?this.mInner.firstChild:this.mInner.childNodes[1];
;
if(!this.mFixedHeader) {
this.RefreshHeaderRefs();
this.mDataTableObj.style.top=16;
}
var tbody=this.mDataTableObj.lastChild;
;
;
e=this.mDataTableObj.firstChild.firstChild;
var slow=this.mRowsPresent>=100;
for(var i=0;i<this.mColCnt;++i) { 
if(this.mColDatas[i].mVisible) {
;
var cdi=this.mColDatas[i];
cdi.mColumn=e;
cdi.mBar.setAttribute("dragoriginal",slow?"":"1");
if(cdi.mPrimarySort&&this.mSortImgs!=null) {
;
;
if(cdi.mSortDir==-1) {
cdi.mHeader.appendChild(this.mSortImgs[0]);
this.mSortImgs[0].setAttribute("ARInDOM",1);
} else {
cdi.mHeader.appendChild(this.mSortImgs[1]);
this.mSortImgs[1].setAttribute("ARInDOM",1);
}
}
e=e.nextSibling;
}
else
this.mColDatas[i].mColumn=null;
}
this.ApplySizes();
this.mLastRowSelections={};
this.ApplySelections();
this.mFirstLayout=false;
}
BaseTable.prototype.ApplySizes=function() {
var lastcol=this.mColCnt-1,colinfo=this.GetColumnInfo(),x=0,scrollbarw=0,lastcolw=null;
while(lastcol>=0&&(!this.mColDatas[lastcol].mVisible||this.mColDatas[lastcol].mWidth<=0))
--lastcol;
if(lastcol<0)
return; 
for(var i=0;i<this.mColCnt;++i) {
var cdi=this.mColDatas[i];
if(this.mColDatas[i].mVisible) {
if(cdi.mColumn==null||cdi.mHeader==null) 
return;
;
;
;
cdi.mHeader.style.left=x;
;
cdi.mX=x;
cdi.mBar.style.visibility=(i>=lastcol||cdi.mWidth<=0?"hidden":"inherit");
cdi.mBar.setAttribute("ARColumnID",i);
cdi.mHeader.style.width=cdi.mColumn.style.width=cdi.mWidth;
x+=cdi.mWidth;
cdi.mBarX=x-6;
cdi.mBar.style.left=cdi.mBarX;
}
}
this.mColHdrObj.style.width=(this.mFixedHeader?5000:(x>this.mWidth?x:this.mWidth));
if(this.mHScroll&&x>this.mWidth) { 
{ this.mInner.style.overflowY='auto';this.mInner.style.overflowX='auto'; };
if(this.mRowsPresent==0&&this.mFixedHeader) { 
var td=document.createElement("td");
td.style.width=x;
var tr=document.createElement("tr");
tr.appendChild(td);
this.mDataTableObj.lastChild.appendChild(tr);
}
} else { 
{ this.mInner.style.overflowY='auto';this.mInner.style.overflowX='hidden'; };
this.mInner.scrollLeft=this.mScrollLeft=0;
if(x<this.mWidth) {
if(colinfo[this.mColDatas[lastcol].mDataCol].edit!=0) 
scrollbarw=this.mInner.offsetWidth-this.mInner.clientWidth;
var neww=(this.mColDatas[lastcol].mWidth+(this.mWidth-x)-scrollbarw);
lastcolw=(neww<0?0:neww);
this.mColDatas[lastcol].mColumn.style.width=this.mColDatas[lastcol].mHeader.style.width=this.mColDatas[lastcol].mWidth=lastcolw;
}
}
}
function TableBtn(aname,pnt,xclass,img) {
this.mObj=document.createElement("A");
this.mObj.className=xclass+" btn btn3d TableBtn";
this.mObj.href="javascript:";
if (img!=null) {
var contents = aname+"&nbsp;<img style=border:none alt='' src='"+img+"'>";
this.mObj.innerHTML=contents;
}
else
this.mObj.appendChild(document.createTextNode(aname));
pnt.appendChild(this.mObj);
}
TableBtn.prototype.SetVisibility=function(vis) {
this.mObj.style.visibility=(vis?"inherit":"hidden");
}
TableBtn.prototype.SetAccess=function(state) {
this.mObj.disabled = !state;
FakeButton_SetDisable(this.mObj, this.mObj.disabled);
}

SimpleTable.prototype=new BaseTable(); SimpleTable.prototype.constructor=SimpleTable; SimpleTable.superclass=BaseTable.prototype;;
SimpleTable.prototype.mHaveStoredData=false;
SimpleTable.prototype.MouseSelectable=false;
function SimpleTable(id,n,rowmode, sort, data, buttons) {
if(arguments.length)
this.init(id,n,rowmode, sort, data, buttons);
}
SimpleTable.prototype.init=function(id,n, rowmode, sort, data, buttons) {
;
;
;
this.mResult = data;
this.mSort = sort;
this.mColInfo=[];
for (var i = 0; i < this.mResult.h.length; ++i)
this.mColInfo.push({heading:this.mResult.h[i], wrap:false,edit:0});
var e=document.createElement("div");
e.className="TableHdr";
n.appendChild(e);
this.mHdrObj=e;
e=document.createElement("div");
e.className="TableInner";
n.appendChild(e);
this.mInnerObj=e;
e=document.createElement("div");
e.className="TableFtr";
n.appendChild(e);
this.mFtrObj=e;
this.mHdrObj.innerHTML="<TABLE class='TableHdr' cellpadding=0 cellspacing=0><TBODY><TR><TD NOWRAP VALIGN=middle class='TableHdrL'></TD><TD NOWRAP VALIGN=middle class='TableHdrR'></TD></TR></TBODY></TABLE>";
this.mFtrObj.innerHTML="<TABLE class='TableFtr' cellpadding=0 cellspacing=0><TBODY><TR><TD NOWRAP VALIGN=middle class='TableFtrL'></TD><TD NOWRAP VALIGN=middle class='TableFtrR'></TD></TR></TBODY></TABLE>";
;
var p=this.mHdrObj.firstChild.firstChild.firstChild;
this.mHdrLObj=p.childNodes[0];
this.mHdrRObj=p.childNodes[1];
;
p=this.mFtrObj.firstChild.firstChild.firstChild;
this.mFtrLObj=p.childNodes[0];
this.mFtrRObj=p.childNodes[1];
;
;
this.mSortOrder=[];
this.mCurrentRow = -1;
this.mDisabled=false;
SimpleTable.superclass.init.call(this,id,n,true,rowmode,false);
if (buttons) {
var locs = [this.mHdrObj.firstChild.firstChild.firstChild, this.mFtrObj.firstChild.firstChild.firstChild];
for (var i = 0; i < buttons.length; ++i) {
; 
; 
buttons[i].node=new TableBtn(buttons[i].name,locs[buttons[i].bar].childNodes[buttons[i].loc],buttons[i].name,null);
}
this.mButtons = buttons;
} else
this.mButtons = null;
SimpleTable.superclass.InstantiateUI.call(this,this.mInnerObj);
this.SetDefaultSizes();
this.Resize(n.offsetWidth,n.offsetHeight);
this.ApplyData();
}
SimpleTable.prototype.FindContainingDiv=function(e) {
;
while(e.nodeType!=1||(e.tagName!="DIV"))
e=e.parentNode;
;
return e;
}
SimpleTable.prototype.Clear=function() {
this.S(Null);
}
SimpleTable.prototype.DOMClick=function(ed) {
if(this.mDisabled)
return;
var e = this.FindContainingDiv(ed.element);
if(e.className=="TableHdr"||e.className=="TableFtr") {
e=ed.element;
if(e.tagName!="A")
return;
for (var i = 0; i < this.mButtons.length; ++i) {
if (this.mButtons[i].node.mObj == e) {
return this.mButtons[i].func.call(this,[]);
}
}
return;
}
return SimpleTable.superclass.DOMClick.call(this,ed);
}
SimpleTable.prototype.DOMKeyDown=function(ed) {
;
if(this.mDisabled)
return;
var e = this.FindContainingDiv(ed.element);
if(e.className=="TableHdr"||e.className=="TableFtr")
return; 
return SimpleTable.superclass.DOMKeyDown.call(this,ed);
}
SimpleTable.prototype.GetSelectedRow=function() {
return this.RowNoFromTag(this.mPrimaryRowSelection);
}
SimpleTable.prototype.GetColumnInfo=function() {
return this.mColInfo;
}
SimpleTable.prototype.GetInitialColumnWidths=function() {
return this.mResult.w;
}
SimpleTable.prototype.GetData=function() {
if (this.mResult)
return this.mResult.r;
else
return [];
}
SimpleTable.prototype.SetRowSortOrder=function(col,dir,selections,primaryselection) {
;
if(col==this.mSortOrder.col&&dir==this.mSortOrder.dir)
return null; 
if (!this.mResult)
return null; 
if (!this.mSort)
return null;
var haveselections=false;
if(selections!=null) {
for(var i in selections) {
;
haveselections=true;
this.mResult.r[i].seltag=0;
}
if(primaryselection!=-1)
this.mResult.r[primaryselection].seltag=1;
}
if (col==this.mSortOrder.col&&dir!=this.mSortOrder.dir) { 
this.mResult.r.reverse();
} else { 
this.mResult.r.sort(function(lhs, rhs) {
return lhs.d[col].v.localeCompare(rhs.d[col].v);
});
}
var primary=-1,rows=[],di;
if(haveselections) {
for(var i in this.mResult.r) {
di=this.mResult.r[i];
if("seltag" in di) {
if(di.seltag==1)
primary=i;
rows[i]=1;
delete this.mResult.r[i].seltag;
}
}
}
return {rows:rows,primary:primary};
}
SimpleTable.prototype.GetInitialRowSortOrder=function() {
if (this.mColCnt > 0) {
return {col:0,dir:1};
}
return null;
}
SimpleTable.prototype.GetRowColours=function() {
return null;
}
SimpleTable.prototype.mSortImgs=null;

var TableFields=[];
DTable.prototype=new BaseTable(); DTable.prototype.constructor=DTable; DTable.superclass=BaseTable.prototype;;
DOMFieldFactories["Table"]=function(id,n) {
return new DTable(id,n);
}
DTable.prototype.mHaveStoredData=false;
DTable.prototype.MouseSelectable=false;
function DTable(id,n) {
if(arguments.length)
this.init(id,n);
}
DTable.prototype.MeddleResultsList=function() {
var n=this.mObj;
if(Form.RLReport)
n.setAttribute("ARRepStr",getLocalizedMessage("Report"));
n.setAttribute("ARSelAllStr",getLocalizedMessage("Select all"));
n.setAttribute("ARDeselAllStr",getLocalizedMessage("Deselect all"));
if(Form.RLDelete)
n.setAttribute("ARDeleteStr",getLocalizedMessage("Delete"));
n.setAttribute("ARRefStr",getLocalizedMessage("Refresh"));
n.setAttribute("ARPrefsStr",getLocalizedMessage("Preferences"));
if(parseInt(n.getAttribute("ARChunkButtons"))!=null)
n.setAttribute("AREntRetStr",getLocalizedMessage("Showing {0} - {1} of {3}"));
else
n.setAttribute("AREntRetStr",getLocalizedMessage("{2} entries returned - {3} entries matched"));
}
DTable.prototype.Resize=function(width,height) {
if(this.mAsyncMode) {
this.mAsyncResizePending={w:width,h:height};
this.mAsyncDirty=(1>this.mAsyncDirty?1:this.mAsyncDirty);
} else {
;
this.DoResize(width,height);
}
}
DTable.prototype.DoResize=function(width,height) {
DTable.superclass.Resize.call(this,width,height);
}
DTable.prototype.init=function(id,n) {
if(n.getAttribute("ARCols")=="")
this.mColInfo=this.mColFields=[];
else {
var fields=n.getAttribute("ARCols").split(",");
var dlen=n.getAttribute("ARColDLen").split(",");
var wraps=n.getAttribute("ARColWrap");
;
this.mColInfo=[];
this.mColFields=[];
for(var i=0;i<fields.length;++i) {
;
this.mColFields[i]=Fields[fields[i]];
this.mColInfo.push({heading:this.mColFields[i].mObj.lbl,edit:0,wrap:(wraps==null?false:(wraps.charAt(i)=="1")),dLen:dlen[i]});;
this.mColFields[i].mObj.dataidx=i;
}
}
if(n.getAttribute("ARCSize")!=null)
this.mChunkSize=parseInt(n.getAttribute("ARCSize"));
else
this.mChunkSize=0;
this.mChunkPage=0;
DTable.superclass.init.call(this,id,n,(n.getAttribute("ARFixHdr")=="1"),parseInt(n.getAttribute("ARSelRows")),!parseInt(n.getAttribute("ARAutoFit")));
if(this.mObj.getAttribute("ARDBN")=="CustomResultsList") 
this.MeddleResultsList();
if(this.mID==1020)
this.mCFCache.v=false;
this.mSortOrder=[];
this.mCurrentRow=-1;
this.mDisabled=false;
this.mNotRefreshed=true;
TableFields.push(this);
}
DTable.prototype.InstantiateUI=function() {

var n=this.mObj;
function buildbutton(attr,location,img) {
var string=n.getAttribute("AR"+attr+"Str");
if(string==null||string=="") 
return null;
else
return new TableBtn(string,location,attr,img);
}
this.mSortImgs=[];
this.mSortImgs[0]=n.firstChild;
this.mSortImgs[1]=this.mSortImgs[0].nextSibling;
;
this.mSortImgs[0].setAttribute("ARInDOM",1);
this.mSortImgs[1].setAttribute("ARInDOM",1);
this.mHdrObj=this.mSortImgs[1].nextSibling;
this.mInnerObj=this.mHdrObj.nextSibling;
this.mFtrObj=this.mInnerObj.nextSibling;
;
;
var p=this.mHdrObj.firstChild.firstChild.firstChild;
;
var havechunkbuttons=n.getAttribute("ARChunkButtons")!=null;
this.mHdrLObj=p.firstChild;
var notLoaded = n.getAttribute("ARNotRefStr");
if (notLoaded != null && notLoaded.length > 0)
this.mHdrLObj.innerHTML = notLoaded.HTMLEncode();
if(havechunkbuttons) {
this.mChunkOuter=p.childNodes[1].firstChild;
this.mHdrRObj=p.childNodes[2];
} else {
this.mChunkOuter=null;
this.mHdrRObj=p.childNodes[1];
}
;
p=this.mFtrObj.firstChild.firstChild.firstChild;
this.mFtrLObj=p.firstChild;
this.mFtrRObj=p.childNodes[1];
;
this.mFlushingQueue=0;
DTable.superclass.InstantiateUI.call(this,this.mInnerObj);
if(this.mChunkOuter!=null) {
;
this.mChunkPrevBtn=this.mChunkOuter.firstChild;
;
this.mChunkInput=this.mChunkOuter.childNodes[2];
;
this.mChunkMenuBtn=this.mChunkOuter.childNodes[3];
;
this.mChunkNextBtn=this.mChunkOuter.childNodes[4];
;
} else 
this.mChunkPrevBtn=this.mChunkInput=this.mChunkMenuBtn=this.mChunkNextBtn=null;
this.mBtnReport=buildbutton("Rep",this.mFtrLObj,null);
if(this.mSelRow!=1) {
if(this.mSelRow==0)
this.mBtnSelectAll=buildbutton("SelAll",this.mFtrLObj,null);
else
this.mBtnSelectAll=null;
this.mBtnDeselectAll=buildbutton("DeselAll",this.mFtrLObj,null);
} else
this.mBtnSelectAll=this.mBtnDeselectAll=null;
this.mBtnDelete=buildbutton("Delete",this.mFtrLObj,null);
this.mBtnRead=buildbutton("Read",this.mFtrLObj,null);
this.mBtnUnread=buildbutton("Unread",this.mFtrLObj,null);
this.mBtnPref=buildbutton("Prefs",this.mHdrRObj,RelContextPath+"resources/images/menu_down.gif");
this.mBtnRefresh=buildbutton("Ref",this.mHdrRObj,null);
this.mUIInstantiated=true;
if(!this.mAsyncResizePending)
this.Resize(parseInt(n.style.width),parseInt(n.style.height)); 
;
this.mAsyncDirty=(3>this.mAsyncDirty?3:this.mAsyncDirty);
}
DTableMenu.prototype=new Menu(); DTableMenu.prototype.constructor=DTableMenu; DTableMenu.superclass=Menu.prototype;;
function DTableMenu(menudata,table) {
if(arguments.length)
this.init(menudata,table);
}
DTableMenu.prototype.init=function(menudata,table) {
DTableMenu.superclass.init.call(this,menudata);
this.mTable=table;
this.Open(table.mChunkMenuBtn,1, null, false);
}
DTableMenu.prototype.HandleSelection=function(val) {
;
var iv=parseInt(val);
;
if(iv!=this.mChunkPage) {
this.mTable.mChunkPage=iv;
new WorkflowContext({t:this.mTable,f:this.mTable.Refresh,a:[-1,0,false]});
}
}
DEditMenu.prototype=new Menu(); DEditMenu.prototype.constructor=DEditMenu; DEditMenu.superclass=Menu.prototype;;
function DEditMenu(menudata,element,xy,datax,table) {
if(arguments.length)
this.init(menudata,element,xy,datax,table);
}
DEditMenu.prototype.init=function(menudata,element,xy,datax,table) {
DTableMenu.superclass.init.call(this,menudata);
this.mDataX=datax;
this.mXY=xy;
this.mLastRefreshTime=table.mLastRefreshTime;
this.mTable=table;
this.Open(element,1,null, false);
}
DEditMenu.prototype.HandleSelection=function(val) {
;
if(this.mTable.mLastRefreshTime!=this.mLastRefreshTime)
return; 
new WorkflowContext({t:this, f:function(t) {
var oldrow = this.mTable.GetRow();
this.mTable.SetRow(this.mXY.y);
this.mTable.mColFields[this.mDataX].S(val==""?Null:new EnumType(val));
this.mTable.SetRow(oldrow);
}});
}
DTable.prototype.FindContainingDiv=function(e) {
;
while(e.nodeType!=1||(e.tagName!="DIV"))
e=e.parentNode;
;
return e;
}
DTable.prototype.DOMClick=function(ed) {
;
;
if(this.mDisabled)
return;
var e = this.FindContainingDiv(ed.element);
if(e.className=="TableHdr"||e.className=="TableFtr") {
e=ed.element;
if(e.tagName=="IMG")
e=e.parentNode;
if(e.tagName!="A")
return;
if(this.mBtnRefresh&&e==this.mBtnRefresh.mObj)
return {n:{t:this,f:this.Refresh,a:[-1,0,false]}};
else if(this.mBtnSelectAll&&e==this.mBtnSelectAll.mObj) {
return {n:{f:this.SelectAll,t:this,a:[true]}};
} else if(this.mBtnDeselectAll&&e==this.mBtnDeselectAll.mObj) {
return {n:{f:this.SelectAll,t:this,a:[false]}};
} else if(this.mBtnDelete&&e==this.mBtnDelete.mObj) {
return this.DeleteSelected();
} else if(this.mBtnRead&&e==this.mBtnRead.mObj) {
return this.MarkRead(true);
} else if(this.mBtnUnread&&e==this.mBtnUnread.mObj) {
return this.MarkRead(false);
} else if(this.mBtnReport&&e==this.mBtnReport.mObj) {
return this.Report();
} else if(this.mBtnPref&&e==this.mBtnPref.mObj) {
return this.Preferences(e,this);
}
} else if (e==this.mChunkOuter) {
var e2=ed.element;
if(e2.tagName=="IMG")
e2=e2.parentNode;
if(e2==this.mChunkPrevBtn) {
return {n:{t:this,f:this.NextChunk,a:[-1]}};
} else if(e2==this.mChunkNextBtn) {
return {n:{t:this,f:this.NextChunk,a:[1]}};
} else if(e2==this.mChunkMenuBtn) {
if(!this.mResult)
return; 
var menu=[];
var maxpage=Math.ceil(this.mResult.n/this.mChunkSize);
if(maxpage<=25) {
for(var i=0;i<maxpage;++i)
menu.push({l:""+(i+1),v:""+i});
} else {
var chunks=Math.ceil(maxpage/25);
for(var i=0;i<chunks;++i) {
var base=i*25,end=base+25;
if(end>maxpage)
end=maxpage;
var submenu=[];
for(var j=base;j<end;++j)
submenu.push({l:""+(j+1),v:""+j});
if(submenu.length)
menu.push({l:(base+1)+".."+end,v:submenu});
}
}
new DTableMenu(menu,this);
}
}
var e=ed.element;
if(e.tagName=="A"&&e.className.indexOf("TableBtn")!=-1) {
var xy=this.MapUIXY(e);
if(xy!=null) {
var menu=[],datax=this.MapUIXToData(xy.x);
if(datax==null)
return;
;
;
;
; 
var enums=this.mResult.f[datax].e;
for(var i in enums) 
menu.push({l:enums[i],v:i});
menu.push({l:getLocalizedMessage("(clear)"),v:""}); 
new DEditMenu(menu,ed.element,xy,datax,this);
}
}
else if (e.tagName=="INPUT" && e.type=="checkbox") {
this.DirtyEditableCell(ed.element);
}
return DTable.superclass.DOMClick.call(this,ed);
}
DTable.prototype.DOMKeyPress=function(evt) {
;
;
if(this.mDisabled)
return;
var e=evt.element;
if(e==this.mChunkInput&&evt.key==13) {
;
var newval=parseInt(this.mChunkInput.value);
if(isNaN(newval)||newval<1)
newval=1;
--newval;
if(newval!=this.mChunkPage) {
this.mChunkPage=newval;
;
return {n:{t:this,f:this.Refresh,a:[-1,0,true]}};
}
return;
}
this.DirtyEditableCell(e);
}
DTable.prototype.DOMKeyUp=function(ed) {
this.DirtyEditableCell(ed.element);
}
DTable.prototype.DirtyEditableCell=function(e) {
if(e.tagName=="INPUT") {
var xy=this.MapUIXY(e);
if(xy!=null) {
var oldrow = this.GetRow()
this.SetRow(xy.y);
var olddirty=this.mAsyncDirty; 
var logx=this.MapUIXToData(xy.x);
if(logx!=null) {
if (e.type=="checkbox")
this.mColFields[logx].S(e.checked?new EnumType(e.value):Null);
else
this.mColFields[logx].S(new CharType(e.value),true);
}
this.mAsyncDirty=olddirty;
this.SetRow(oldrow);
}
}
}
DTable.prototype.DOMKeyDown=function(ed) {
;
;
if(this.mDisabled)
return;
if(ed.key==8||ed.key==46) {
var e=ed.element;
this.DirtyEditableCell(e);
}
var e = this.FindContainingDiv(ed.element);
if(e.className=="TableHdr"||e.className=="TableFtr"||e.className=="TableHdrChunk")
return; 
if(ed.key==37&&ed.shift) { 
return {n:{f:this.NextChunk,t:this,a:[-1]}};
} else if(ed.key==39&&ed.shift) { 
return {n:{f:this.NextChunk,t:this,a:[1]}};
} else if(ed.key==116) { 
return {n:{f:this.Refresh,t:this,a:[-1,0,false]}};
} else
return DTable.superclass.DOMKeyDown.call(this,ed);
ed.StopDefault();
}
DTable.prototype.IsMouseSelectable=function(element) {
return (this.MouseSelectable || element.isTextEdit);
}
DTable.prototype.LoadResultsList=function(state, arg, encodedQual, vuiId) {

;
;
this.mResultsListState = state;
this.mChunkPage = 0;
if (!this.mUIInstantiated)
this.GetSortPreference();
return this.RefreshTable(-1, 0, false, function(start, maxrows) {
var req,fieldids=[],fieldvals=[],fieldtypes=[];
if (arg instanceof FieldList) {
;
arg.ToArrays(fieldids, fieldvals, fieldtypes);
req = new NDXGetQBETableEntryList(ARKWGetStringByIdx(7),ARKWGetStringByIdx(6),ARKWGetStringByIdx(17),
this.mID,ARKWGetStringByIdx(7),ARKWGetStringByIdx(6),((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""),start,maxrows,this.mSortOrder,
fieldids,fieldvals,fieldtypes,encodedQual,vuiId);
} else {
for (var i = 0; i < arg.fieldids.length; ++i) {
fieldids.push(arg.fieldids[i]);
fieldvals.push(arg.fieldvals[i]);
fieldtypes.push(arg.fieldtypes[i]);
}
req = new NDXGetTableEntryList(ARKWGetStringByIdx(7),ARKWGetStringByIdx(6),ARKWGetStringByIdx(17),
this.mID,ARKWGetStringByIdx(7),ARKWGetStringByIdx(6),((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""),start,maxrows,this.mSortOrder,
arg.qual,fieldids, fieldvals, fieldtypes);
}
if ("q" in req.result)
eval("this.mQual="+req.result.q);
if (req.result.n == 0) {
if (window.weArgs != null && window.weArgs.suppressNoMatch == true) {
window.weArgs.suppressNoMatch = false; 
throw new WorkflowException(0, []); 
} else if (window.weArgs != null && window.weArgs.noMatchMessage != null) {
var matchMsg = window.weArgs.noMatchMessage;
window.weArgs.noMatchMessage = null;
CurWFC.status([matchMsg]);
throw new WorkflowException(0, []); 
} else {
CurWFC.status([{n:9296,t:1,m:null,a:null}]); 
throw new WorkflowException(0, []); 
}
}
return req;
});
}
DTable.prototype.Refresh=function(startrow,numrows,fromchunk) {

if (this.mID == 1020 && this.mNotRefreshed) {
if(!(ARStateCurrent == 4) || StateMgr.InTransition())
return; 
return {n:{f:FormAction_Query}};
}
var istack=[];
if(this.mID==1020)
istack.push({t:StateMgr,f:StateMgr.ARStateChange,a:[this.mResultsListState]});
istack.push({f:this.RefreshTable,e:weDisplayWFException,t:this,a:[startrow, numrows, fromchunk, function(start, maxrows) {

var server = this.mObj.getAttribute("ARServer");
;
server = ExpandServerName(server);
var schema = this.mObj.getAttribute("ARSchema");
;
schema = ExpandSchemaName(schema);
var qual;
if (typeof this.mQual != "undefined") {
qual = this.mQual;
} else {
qual = this.mObj.getAttribute("ARQual");
;
eval("qual="+qual); 
}
qual = ExpandQualifier(qual, schema, server);
return new NDXGetTableEntryList(ARKWGetStringByIdx(7),ARKWGetStringByIdx(6),ARKWGetStringByIdx(17),
this.mID,server,schema,((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""),start,maxrows,this.mSortOrder,
qual.qual, qual.fieldids, qual.fieldvals, qual.fieldtypes);
}]});
return {n:istack};
}
DTable.prototype.IsRefreshed=function() {
return !this.mNotRefreshed;
}
DTable.prototype.RefreshTable=function(startrow,numrows,fromchunk,datafunc) {
;

;
;
;
;
;
var start,maxrows,oldcurrow=null;
var refreshmode=parseInt(this.mObj.getAttribute("ARSelRefresh"));
if(fromchunk||this.mNotRefreshed||(refreshmode!=0&&
refreshmode!=1)) {
this.ClearSelections(true);
}
if(this.mChunkSize>0) {
;
if(this.mResult) {
var maxpage=Math.ceil(this.mResult.n/this.mChunkSize);
if(this.mChunkPage>=maxpage)
this.mChunkPage=maxpage-1;
}
if(this.mChunkPage<0)
this.mChunkPage=0;
;
start=(startrow >= 0) ? startrow : this.mChunkPage*this.mChunkSize;
maxrows=(numrows > 0) ? numrows : this.mChunkSize;
} else {
start=(startrow >= 0) ? startrow : 0;
maxrows=(numrows > 0) ? numrows : parseInt(this.mObj.getAttribute("ARMaxRows"));
}
;
if (this.mNotRefreshed && this.mSortOrder.length==0) {
var sortorder = this.GetInitialRowSortOrder();
if (sortorder != null) {
this.RebuildSortOrder(sortorder.col, sortorder.dir);
}
}
var req = datafunc.call(this, start, maxrows);
var result = req.result;
;
;
;
;
;
if (result.start!=null)
start = result.start;
if(this.mChunkSize>0)
this.mChunkPage=Math.ceil(start/this.mChunkSize);
if(result.n<start+maxrows)
maxrows=result.n-start;
if(maxrows <= 0)
maxrows=result.r.length;
;
this.mResult = result;
this.mLastRefreshTime=new Date().getTime();
ARKWSetLASTCOUNT(result.n); 
var theidmap=this.mResult.idmap;
for(var i in this.mRowSelections)
if(!(i in theidmap))
delete this.mRowSelections[i];
if(this.mPrimaryRowSelection!=null&&(!(this.mPrimaryRowSelection in theidmap)))
this.mPrimaryRowSelection=null;
this.mARRowSelection=this.mPrimaryRowSelection==null?0:this.RowNoFromTag(this.mPrimaryRowSelection)+1;
this.mLastNonShiftedRowSelection=this.mLastRowSelection=0;
this.SetRow(this.mARRowSelection-1);
var editstr=this.mObj.getAttribute("ARColEdit");
;
if(editstr!=null) {
for(var i=0;i<this.mColCnt;++i) {
if(editstr.charAt(i)=="1") {
if(result.f[i].t.indexOf("Enum")==-1) {
this.mColInfo[i].edit=2;
}
else {
if (result.f[i].et==2) {
this.mColInfo[i].edit=3;
var enums=result.f[i].e;
for (var l in enums) {
this.mColInfo[i].mEnumLabel=enums[l];
this.mColInfo[i].mEnumValue=l;
break;
}
}
else
this.mColInfo[i].edit=1;
}
} else 
this.mColInfo[i].edit=0;
}
}
for(var i=0;i<this.mColFields.length;++i)	
this.mColFields[i].Refresh();
;
this.mAsyncDirty=(3>this.mAsyncDirty?3:this.mAsyncDirty);
var str=this.mObj.getAttribute("AREntRetStr");
if(str!=""&&str!=null) { 
str=str.replace(/\{0\}/,(result.r.length==0?0:start+1));
str=str.replace(/\{1\}/,(result.r.length==0?0:start+maxrows));
str=str.replace(/\{2\}/,result.r.length);
str=str.replace(/\{3\}/,result.n);
}
else if (str==null)
str = "";
;
this.mAsyncQueue.push({action:2,val:str,cval:this.mChunkPage+1});
if(this.mNotRefreshed) {
this.mNotRefreshed=false;
if(this.GetData().length>0) {
var mode=parseInt(this.mObj.getAttribute("ARSelInit"));
if(mode!=2) {
;
if(mode==0) 
return {n:{t:this,f:this.SetPrimarySelection,a:[0, true, false]}};
else 
return {n:{t:this,f:this.SetPrimarySelection,a:[0, false, false]}};
}
}
} else { 
if(this.GetData().length>0) {
if(refreshmode==2)
return {n:{t:this,f:this.S,a:[new IntegerType(1)]}};
else if(refreshmode==3)
return {n:{t:this,f:this.S,a:[new IntegerType(-1)]}};
else if(refreshmode==0) {
var oldrow=this.GetRow();
;
this.SetRow(this.mARRowSelection-1);
return {n:{f:function(table, oldrow) {
if(oldrow>=table.GetData().length)
oldrow=-1;
table.SetRow(oldrow);
}, a:[this, oldrow]},c:{f:function(table,evtid) {
if (table.GetRow()>-1)
ExecuteWorkflow(evtid, table.mID)
}, a:[this,128]}};
}
}
}

}
DTable.prototype.ClearRowChanged=function(row) {

;
if(!this.mResult)
return;
if (row == -1) {
var len=this.GetData().length;
for (var i = 0; i<len; ++i) {
var r=this.mResult.r[i];
if("mXXXDirty" in r)
r.mXXXDirty=false;
}
} else {
;
var r=this.mResult.r[row];
if("mXXXDirty" in r)
r.mXXXDirty=false;
}
}
DTable.prototype.Report=function() {
if(!this.mResult)
return;
;
ReportSelForm = decodeURIComponent(ReportSelForm);
var inmap = {};
var val;
var schema = this.mObj.getAttribute("ARSchema");
;
schema = ExpandSchemaName(schema);
val = new CharType(schema);
inmap[2000035]={t:val.type,v:val.toPrimitive(),a:val.args()};
var server = this.mObj.getAttribute("ARServer");
;
server = ExpandServerName(server);
val=new CharType(server);
inmap[2000036]={t:val.type,v:val.toPrimitive(),a:val.args()};
var qual;
if (typeof this.mQual != "undefined") {
qual = this.mQual;
} else {
qual = this.mObj.getAttribute("ARQual");
;
eval("qual="+qual); 
}
qual = ExpandQualifier(qual, schema, server);
if(qual.qual != "" && qual.fieldids.length > 0)
{
var req = new NDXParseAndEvaluateQualifier(server, schema, "", qual.qual, qual.fieldids, qual.fieldvals, qual.fieldtypes);
;
qual = {qual : req.result, fieldids:[],fieldvals:[],fieldtypes:[]};
}
val=new CharType(qual.qual);
inmap[2000037]={t:val.type,v:val.toPrimitive(),a:val.args()};
var ids = this.GetSelectedRowsByEntryId();
var entryIDS = [];
;
if (ids.length > 0 && ids.length < this.mResult.n) { 
entryIDS.push(ids[0]);
for(var i=1;i<ids.length;i++) {
entryIDS.push(",");
entryIDS.push(ids[i]);
}
}
if(entryIDS.length > 0) {
val= new CharType(entryIDS.join(""));
inmap[2000038]={t:val.type,v:val.toPrimitive(),a:val.args()};
}
val = new CharType(schema);
inmap[2000050]={t:val.type,v:val.toPrimitive(),a:val.args()};
var reportServer = server;
var temp = ARPrefsGetAsString(24002);
if(temp != null && temp.length > 0) {
var semicolonIndex = temp.indexOf(";");
if ( semicolonIndex < 0 ) {
reportServer = temp;
}
else if ( semicolonIndex > 0 ) {
reportServer = temp.substring(0, semicolonIndex);
}
}
return ARACTOpenDialog(reportServer,ReportSelForm,"",1,inmap,null,null,null);
}
DTable.prototype.NextChunk=function(dir) {
;

;
if (this.mChunkSize == 0)
return;
this.mChunkPage+=dir;
return {n:{t:this,f:this.Refresh,a:[-1,0,true]}};
}
DTable.prototype.SelectAll=function(select) {
;
;

;
var estack=[]; 
estack.push({t:this,f:function() {this.mAsyncDirty=(2>this.mAsyncDirty?2:this.mAsyncDirty);}});
if (select) {
estack.push({t:this,f:function() {
;
if(this.mPrimaryRowSelection!=null)
this.SetRow(this.RowNoFromTag(this.mPrimaryRowSelection));
}});
estack.push({t:this,f:this.FillAllSelections});
} else {
estack.push({t:this,f:function() {
this.ClearSelections(true);
;
this.SetRow(-1);
}});
}
return {n:estack};
}
DTable.prototype.Preferences=function(node,tableObj) {
var menu = new TableSettingsMenu(tableObj);
menu.Open(node, 3);
}
DTable.prototype.MarkRead=function(read) {
}
DTable.prototype.GetRowSelected=function(row) {

;
;
row=this.TagFromRowNo(row);
if (this.mPrimaryRowSelection!=null&&row==this.mPrimaryRowSelection)
return 2;
else if (this.mRowSelections[row])
return 1;
return 0;
}
DTable.prototype.GetRowChanged=function(row) {

;
;
;
if(this.mResult.r[row].mXXXDirty)
return 1;
return 0;
}
DTable.prototype.GetRows=function() {
return this.GetData().length;
}
DTable.prototype.GetSelectedRows=function() {

var rows = [];
for (var i in this.mRowSelections)
rows.push(this.RowNoFromTag(i));
rows.sort(function(l,r) { return (l - r); });
return rows;
}
DTable.prototype.SetRow=function(row) {

;
;
this.mCurrentRow=row;
if (row == -1) {
for(var i=0;i<this.mColFields.length;++i)	
this.mColFields[i].Update(null);
} else {
;
for(var i=0;i<this.mColFields.length;++i)	
this.mColFields[i].Update(this.mResult.r[row].d[i]);
}
}
DTable.prototype.GetRow=function() {

return this.mCurrentRow;
}
DTable.prototype.DataChanged=function() {
;
this.mAsyncDirty=(3>this.mAsyncDirty?3:this.mAsyncDirty);
}
DTable.prototype.G=function() {

if(this.mARRowSelection==null)
return Null;
return new IntegerType(this.mCurrentRow + 1);
}
DTable.prototype.DoSet=DTable.prototype.DoSLoadEntry=function(val) {

;
;
;
if (val instanceof Datatype)
val = val.toInteger();
else {
if (val == "")
val = 0;
else
val = parseInt(val);
}
;
var workflow = true;
var highlight = true;
if (val < 0) {
val = -val;
workflow = false;
}
if (val > 100000000) {
val -= 100000000;
highlight = false;
}
var maxrows = this.GetData().length;
if (val > maxrows) {
val = 0;
workflow = false;
highlight = true;
}
if(val == 0) {
this.ClearSelections(true);
this.mAsyncDirty=(2>this.mAsyncDirty?2:this.mAsyncDirty);
} else {
if (this.mARRowSelection == val)
return;
if (highlight) {
return {c:{f:this.SetPrimarySelection,t:this,a:[val-1,workflow,true]},n:{t:this,f:function() {
this.mAsyncDirty=(2>this.mAsyncDirty?2:this.mAsyncDirty);
}}};
} else {
var oldrow = this.GetRow();
CurWFC.AddCallback(this, function(oldrow) {if(oldrow>=this.GetData().length) oldrow=-1; this.SetRow(oldrow);}, [oldrow]);
this.SetRow(val - 1);
if (workflow)
return {n:{f:ExecuteWorkflow,a:[128,this.mID]}};
}
}
}
DTable.prototype.GDefault=function() {
return null;
}
DTable.prototype.Clear=function() {

if(this.mNotRefreshed) {
;
return; 
}
delete this.mResult;
delete this.mResultsListState;
this.SetRow(-1);
this.ClearSelections(true);
;
this.mAsyncDirty=(3>this.mAsyncDirty?3:this.mAsyncDirty);
var str=this.mObj.getAttribute("ARNotRefStr");
if(str==null)
str = "";
this.mAsyncQueue.push({action:2,val:str,cval:0});
this.mNotRefreshed=true;
}
DTable.prototype.FlushAsyncQueue=function() {
;
if(!this.mAsyncDirty)
return;
if(!this.mUIInstantiated) {
this.InstantiateUI();
this.SetDefaultSizesAndOrder();
}
var needscale=false;
try {
++this.mFlushingQueue;
while(this.mAsyncQueue.length) {
var item=this.mAsyncQueue.shift();
;
if(item.action==0) {
;
this.mColFields[item.col].UpdateLabel(item.val);
} else if(item.action==1) {
;
this.mColFields[item.col].UpdateVis(item.val);
needscale=true;
} else if(item.action==2) {
if(this.mHdrLObj!=null){
this.mHdrLObj.innerHTML=item.val.HTMLEncode();
var newTitle = DTable.superclass.MakeTableTitle.call(this,item.val);
if (this.mDataTableObj)
this.mDataTableObj.title = newTitle;
}
if(this.mChunkInput!=null)
this.mChunkInput.value=item.cval;
}
}
;
if(this.mAsyncResizePending)
this.DoResize(this.mAsyncResizePending.w,this.mAsyncResizePending.h);
if(needscale&&!this.mHScroll) {
;
this.ScaleSizes();
}
if(this.mAsyncDirty>=3)
this.ApplyData();
else if(this.mAsyncDirty>=2) 
this.ApplySelections();
this.mAsyncDirty=0;
this.mAsyncResizePending=null;
} finally {
--this.mFlushingQueue;
}

}
DTable.prototype.UpdateAccess=function(val) {

;
;
this.mDisabled=(val==3);
}
DTable.prototype.UpdateVis=function(val) {

var curvis=(this.mObj.style.visibility!="hidden");
if(!curvis&&val) { 
this.SetAsync(-1);
this.mObj.style.visibility="inherit";
} else if(curvis&&!val) { 
this.SetAsync(1);
this.mObj.style.visibility="hidden";
}

}
DTable.prototype.SColLabel=function(datacol,lab) {

;
if(this.mFlushingQueue>0) { 
DTable.superclass.SColLabel.call(this,datacol,lab);
} else { 
this.mColInfo[datacol].heading=lab;
this.mAsyncQueue.push({action:0,col:datacol,val:lab});
this.mAsyncDirty=(3>this.mAsyncDirty?3:this.mAsyncDirty);
}
}
DTable.prototype.SColVis=function(datacol,vis) {

;
if(this.mFlushingQueue>0) { 
DTable.superclass.SColVis.call(this,datacol,vis);
} else { 
this.mAsyncQueue.push({action:1,col:datacol,val:vis});
this.mAsyncDirty=(3>this.mAsyncDirty?3:this.mAsyncDirty);
}
}
DTable.prototype.DOMFocus=function(ed) {
;

return DTable.superclass.DOMFocus.call(this, ed);
}
function DTable_DoEntryChange(state) {
var imode = [];
for (var i = 0; i < TableFields.length; ++i) {
if (TableFields[i].mObj.getAttribute("ARAutoRefresh") && (state==0))
imode.push({t:TableFields[i], f:DTable.prototype.Refresh, a:[-1, 0, false]});
else if ((state==1) && TableFields[i].mID!=1020)
TableFields[i].Clear();
}
if (imode.length > 0)
return CurWFC.executeAll(imode);
}
DTable.prototype.Snapshot=function(data,access,other) {

var o = DTable.superclass.Snapshot.call(this, data, access, other);
;
if (o.d) {
;
o.d = "" + (-o.d);
}
return o;
}
DTable.prototype.RebuildSortOrder=function(col, dir) {
;
;

var sortstr = this.mObj.getAttribute("ARSort");
;
;
if (col == -2)
this.mSortOrder = [];
else
this.mSortOrder = [ col, dir ];
if (sortstr!="") {
var sort = sortstr.split(",");
;
;
for (var i = 0; i < sort.length; i+=2) {
var sortcol = parseInt(sort[i]);
if (sortcol != col) {
var sortdir = parseInt(sort[i+1]);
;
;
this.mSortOrder.push(sortcol);
this.mSortOrder.push(sortdir);
}
}
}
}
DTable.prototype.GetSelectedRowsByEntryId=function() {
;

var entries = [];
for (var i in this.mRowSelections)
entries.push(i);	
return entries;
}
DTable.prototype.DeleteSelected=function() {
;
;

var ids = this.GetSelectedRowsByEntryId();
if (ids.length == 0) 
return;
var msg;
if (ids.length == 1)
msg = getLocalizedMessage("{0} entry selected for deletion", [ids.length]);
else
msg = getLocalizedMessage("{0} entries selected for deletion", [ids.length]);
var res = {};
return {c:{f:ConfirmPopup, a:[ msg, res, 2 | 1]},
n:{t:this,f:function() {
;
if (("v" in res.result) && res.result.v == 1) {
var server = this.mObj.getAttribute("ARServer");
;
server = ExpandServerName(server);
var schema = this.mObj.getAttribute("ARSchema");
;
schema = ExpandSchemaName(schema);
var req = new NDXDeleteEntry(server, schema, ids);
return this.Refresh(-1, 0, false); 
}
}
}};
}
DTable.prototype.Resort=function(col, dir) {
;
;
this.RebuildSortOrder(col, dir);
this.mChunkPage=0;
return this.Refresh(-1, 0, false);
}
DTable.prototype.ApplyData=function() {
DTable.superclass.ApplyData.call(this);
var vis=(this.GetData().length>0);
if(this.mBtnReport) this.mBtnReport.SetVisibility(vis);
if(this.mBtnSelectAll) this.mBtnSelectAll.SetVisibility(vis);
if(this.mBtnDeselectAll) this.mBtnDeselectAll.SetVisibility(vis);
if(this.mBtnDelete) this.mBtnDelete.SetVisibility(vis);
if(this.mBtnRead) this.mBtnRead.SetVisibility(vis);
if(this.mBtnUnread) this.mBtnUnread.SetVisibility(vis);
if(this.mChunkOuter) this.mChunkOuter.style.visibility=(vis?"inherit":"hidden");
if (FocusMgr.mCurFocusID==this.mID&& FocusMgr.mCurFocusElement!=null)
setTimeout(function() {FocusMgr.TryFocus(FocusMgr.mCurFocusElement)}, 0);
}
DTable.prototype.ARRowSelected=function(domenuchoice, selectnewentry,prevSelected) {
;
;
;
LogWrite("ARRowSelected: " + this.mARRowSelection);
this.SetRow(this.mARRowSelection - 1);
; 
var imode = [];
if (domenuchoice) 
imode.push({f:ExecuteWorkflow,a:[128,this.mID]});
if (this.mID == 1020 && selectnewentry) {
;
this.mPrevARSelection=prevSelected;
imode.push({t:StateMgr,f:StateMgr.ARStateChange, a:[this.mResultsListState]});
}
return {n:imode};
}
DTable.prototype.RestoreResultsListToPrevSelection=function() {
;
;
if (this.mPrevARSelection==null || this.mPrevARSelection==0)
return {n:{t:this,f:this.ClearSelections,a:[true]}};
else
return {n:{t:this,f:this.SetPrimarySelection,a:[this.mPrevARSelection-1,false,false]}};
}
DTable.prototype.ARRowCleared=function() {
this.SetRow(-1);
}
DTable.prototype.ARDrillDown=function(xy,fromlink) {
; 
;
; 
if(!this.mObj.getAttribute("ARDrill"))
return ExecuteWorkflow(2,this.mID);
var entryid=this.mResult.r[xy.y].i;
return {n:[{f:function(table) {
return OpenNonModalForm(false,ExpandServerName(table.mObj.getAttribute("ARServer")),
ExpandSchemaName(table.mObj.getAttribute("ARSchema")),"", {
fvlist:null, wMode:4,wForceClear:1,qual:{qual:"4\\1\\1\\1\\2\\4\\" + entryid.length + "\\" + entryid + "\\",fieldids:[],fieldvals:[],fieldtypes:[]}});
},a:[this]},
{f:ExecuteWorkflow,a:[2,this.mID]}]};
}
DTable.prototype.GetColumnInfo=function() {
return this.mColInfo;
}
DTable.prototype.GetInitialColumnWidths=function() {
if(this.mObj.getAttribute("ARColWs")=="")
return [];
var widths=this.mObj.getAttribute("ARColWs").split(",");
for(var i=0;i<widths.length;++i) {
widths[i]=parseInt(widths[i]);
;
}
return widths;
}
DTable.prototype.GetData=function() {
if (this.mResult)
return this.mResult.r;
else
return [];
}
DTable.prototype.TagFromRowNo=function(row) {
;
;
return this.mResult.r[row].i;
}
DTable.prototype.RowNoFromTag=function(tag) {
;
;
;
return this.mResult.idmap[tag];
}
DTable.prototype.SetRowSortOrder=function(col,dir) {
}
DTable.prototype.GetInitialRowSortOrder=function() {
var sortorder = this.mObj.getAttribute("ARSort");
if (sortorder!="") {
var sort=sortorder.split(",");
;
;
return {col:parseInt(sort[0]), dir:parseInt(sort[1])};
}
return null;
}
DTable.prototype.GetRowColours=function() {
if(this.mObj.getAttribute("ARColours"))
return this.mObj.getAttribute("ARColours").split("|");
}
DTable.prototype.GetRowCompiler=function() {
return this.mObj.getAttribute("ARCompiler");
}
DTable.prototype.GetAtBottom=function() {
return this.mObj.getAttribute("ARBottom")!=null;
}
DTable.prototype.SetDefaultSizesAndOrder=function() {
;
var cds=this.mColDatas,widths=this.GetInitialColumnWidths(),cfs=this.mColFields;
for(var i=0;i<this.mColCnt;++i) {
var colId = cfs[cds[i].mDataCol].mID;
if (tablePrefs!=null && colId in tablePrefs.colWs)
cds[i].mWidth=tablePrefs.colWs[colId];
else
cds[i].mWidth=(widths[i]<5?5:widths[i]);
if(i==this.mColCnt-1&&this.mHScroll&&cds[i].mWidth>5*2)
cds[i].mWidth-=5; 
;
}
this.GetSortPreference();
var cols={};
for (var i=0; i<this.mColCnt; i++) 
cols[cfs[cds[i].mDataCol].mID]=cds[i];
if (tablePrefs!=null && this.mID in tablePrefs.colOrd) { 
var newColDatas=[];
var colOrder=tablePrefs.colOrd[this.mID];
for (var ii=0; ii<colOrder.length; ii++) {
var id = colOrder[ii];
if (id in cols) {
newColDatas.push(cols[id]);
delete cols[id];
}
} 
if (newColDatas.length>0) {
for (var id in cols) {
cols[id].mWidth=0;
newColDatas.splice(cols[id].mDataCol,0,cols[id]);
}
;
this.mColDatas=newColDatas;
}
}
}
DTable.prototype.GetSortPreference=function() {
if (tablePrefs!=null && this.mID in tablePrefs.colSort) {
var cfs=this.mColFields,cds=this.mColDatas,cols={},sCol=[];
for (var i=0; i<this.mColCnt; i++) 
cols[cfs[cds[i].mDataCol].mID]=cds[i];
var sort = tablePrefs.colSort[this.mID];
for (var j=0; j<sort.length; j+=2) {
var cd = cols[sort[j]];
if (!cd) {
if (this.mID == 1020) {
for (var k = 0; k < this.mColCnt; k++) {
if (cfs[cds[k].mDataCol].mObj.fid == sort[j]) {
cd = cds[k];
break;
}
}
}
}
if (cd) {
sCol[j] = cd.mDataCol;
sCol[j+1] = sort[j+1];
if (j==0) {
cd.mPrimarySort = true;
cd.mSortDir = sort[j+1];
}
}
}
this.mSortOrder = sCol;
}
}
DTable.prototype.ClearSelections=function(clearar) {
;
DTable.superclass.ClearSelections.call(this,clearar);
if (this.mFtrRObj && this.mID == 1020) {
var selStr = getLocalizedMessage("{0} rows selected");
selStr=selStr.replace(/\{0\}/,0);
NodeWrite(this.mFtrRObj, selStr);
}
}

DTreeView.prototype=new DTable(); DTreeView.prototype.constructor=DTreeView; DTreeView.superclass=DTable.prototype;;
DOMFieldFactories["TreeView"]=function(id,n) {
return new DTreeView(id,n);
}
DTreeView.NULL_VALUE = getLocalizedMessage("[No Value]");
function DTreeView(id,n) {
if(arguments.length)
this.init(id,n);
this.mTreeNode = null;
this.mExpandSelectedNode = false;
this.expandOrCollapse = null;
this.mNullValue = this.mObj.getAttribute("ARNullValue");
if (this.mNullValue == null || this.mNullValue.length == 0)
this.mNullValue = DTreeView.NULL_VALUE;
this.mCols = [];
var sortorder = this.GetInitialRowSortOrder();
if (sortorder != null) {
this.RebuildSortOrder(sortorder.col, sortorder.dir);
}
;
for (var i=0; i<this.mSortOrder.length; i+=2) {
this.mCols.push(this.mSortOrder[i]);
}
if (this.mCols.length <= 0)
this.mCols = [0]; 
this.mRow = -1; 
this.mLevel = this.mCols.length-1; 
this.mIndex = "TN" + TreeNode.NextIndex++;
}
DTreeView.prototype.TabableElementSelector=function(ele) {
;
if(ele.tagName == "DIV" && ele.style && 
ele.style.display != "none" && ele.style.visiblity != "hidden") {
var parent = ele.parentNode;
if(parent != null) {
if(parent.tagName == "DIV" && (!parent.style ||
parent.style.display == "none" || 
parent.style.visibility == "hidden"))
return null;
}
return ele;
}
return null; 
}
DTreeView.prototype.InstantiateUI=function(pnt) {
this.mObj.innerHTML = "<html></html>";
this.mUIInstantiated=true;
}
DTreeView.prototype.BuildTree=function() {
var i, j, k, id, data, val, child;
var prnt = new Array(); 
var prev = new Array(); 
prnt[0] = this.mTreeNode = new TreeNode(this.mIndex, 'RootNode', '');
TreeNode.registerRootNode(this.mTreeNode);
var label = this.GLabel();
if (label != null && label != "") {
id = this.mIndex + "_" + 0 + "_" + -1;
child = new TreeNode(id, label, '');
prnt[0].addChild(child);
prnt[0] = child;
}
data=this.GetData();
;
if (data.length > 0) {
var cols = this.mCols;
var n = cols.length;
var ids, rowdata;
var colours = this.GetRowColours();
for (i=0; i<data.length; i++) {
rowdata = data[i];
for (j=0; j<n; j++) {
val = rowdata.d[cols[j]].v;
if (val == null || val.length==0)
val = this.mNullValue;
if (val != prev[j]) {
ids = [];ids.push(this.mIndex);ids.push("_");ids.push(i);ids.push("_");ids.push(j);
id = ids.join("");
child = new TreeNode(id, val, (rowdata.rc==-1||colours==null?'':colours[rowdata.rc]));
child.startRow = i;
child.endRow = i;
child.column = j;
prnt[j].addChild(child);
prnt[j+1] = child;
prev[j] = val;
prev.length = j+1;
} else if (child.column == j)
child.endRow = i;
prnt[j].endRow = i;
}
}
this.RemoveNulls(this.mTreeNode);
}
}
DTreeView.prototype.RemoveNulls=function(node) {
if (node.hasChilds()) {
var children = node.getChildren();
var allNulls = true;
for (var i=0; i<children.length; i++) {
this.RemoveNulls(children[i]);
if (children[i].getName() != this.mNullValue || children[i].hasChilds())
allNulls = false;
if (children[i].getName() == this.mNullValue && i!=0) {
children[i].makeThisFirstChild();
var parent = children[i].getParent();
var row = parent.endRow;
parent.endRow = parent.startRow;
parent.startRow = row;
}
}
if (allNulls)
node.resetChilds();
}
}
DTreeView.prototype.ApplyData=function() {
if (this.mNotRefreshed) {
this.mTreeNode = null;
this.mObj.innerHTML = "<html></html>";
return;
}
this.mRowsPresent=this.GetData().length;
this.BuildTree();
TreeNode.showTree(this.mTreeNode, this.mObj, RelContextPath + 'resources/'); 
var label = this.GLabel();
if (label != null && label != "" && this.GetData().length > 0)
TreeNode.expandNode(this.mTreeNode.getFirstChild(), false);
this.ApplySelections();
}
DTreeView.prototype.ApplySelections=function() {
if (!this.mTreeNode.isLoaded() || this.GetData().length <= 0)
return;
if (this.mPrimaryRowSelection!=null) {
var selectCount=0;
for(var i in this.mRowSelections)
selectCount++;
if (this.mRowsPresent > 1 && selectCount == this.mRowsPresent)
this.SelectNode(0, -1, false, false, false);
else
this.SelectNode(this.mARRowSelection-1, this.mLevel, false, false, false);
var id = this.mIndex + "_" + this.mRow + "_" + this.mLevel;
TreeNode.selectNodeByID(id);
if (this.mExpandSelectedNode) {
TreeNode.expandNode(TreeNode.findNodeWithID(this.mTreeNode,id), false);
this.mExpandSelectedNode = false;
} else { 
TreeNode.collapseNode(TreeNode.findNodeWithID(this.mTreeNode,id), false);
this.mExpandSelectedNode = false;
}
} else {
this.mRow = -1;
this.mTreeNode.ClearSelection();
}
if (this.expandOrCollapse) {
this.expandOrCollapse.apply(this);
this.expandOrCollapse = null;
}
}
DTreeView.prototype.GetRootNode=function() {
return this.mTreeNode;
}
DTreeView.prototype.SColVis=function(col,vis) {
}
DTreeView.prototype.SColLabel=function(datacol,lab) {
}
DTreeView.prototype.DOMClick=function(ed) {
if(!this.mTreeNode)
return;  
var selectedNode = TreeNode.getSelectedNode(this.mTreeNode);
TreeNode.ClearFocusTimer(this.mTreeNode); 
if (TreeNode.handleSingleClick(ed.element))
ed.StopDefault();
var id = ed.element.id;
if (id.indexOf("title") == 0 && this.GetData().length>0) {
var treeNode = TreeNode.getTreeNode(id.substring(5));
;
if (selectedNode == treeNode)
return;
return this.SelectNode((treeNode.startRow<=treeNode.endRow?treeNode.startRow:treeNode.endRow), treeNode.column, false, true, true);
}
}
DTreeView.prototype.DOMDoubleClick=function(ed) {
if(!this.mTreeNode)
return;  
TreeNode.handleDoubleClick(ed.element);
var id = ed.element.id;
if (id.indexOf("title") == 0) {
var treeNode = TreeNode.getTreeNode(id.substring(5));
if (!treeNode.hasChilds())
return DTreeView.superclass.ARDrillDown.call(this, {y:treeNode.startRow, x:treeNode.column}, false);
}
}
DTreeView.prototype.SelectNode=function(row,level,expand,selectTableRows,fireWorkflow) {
if(!this.mTreeNode)
return;
if (row<0) {
this.mTreeNode.ClearSelection();
return;
}
var node=null;
if (level > this.mCols.length)
level = this.mCols.length;
node = this.FindNode(row, level);
if (node) {
var estack=[]; 
estack.push({t:this,f:this.ApplySelections}); 
if (node.startRow < node.endRow)
this.mRow = node.startRow;
else
this.mRow = node.endRow;
this.mLevel = node.column;
if (expand)
this.mExpandSelectedNode = true;	        
if (selectTableRows) {
if (node.endRow != node.startRow)
estack.push({f:this.FillSelections,t:this,a:[node.endRow,node.startRow,true]});
estack.push({f:this.SetPrimarySelection,t:this,a:[node.startRow,fireWorkflow,true]});
}
return {n:estack};
}
}
DTreeView.prototype.DOMFocus=function(ed) {
if (this.mTreeNode != null) {
var selectedNode = TreeNode.getSelectedNode(this.mTreeNode);
if (selectedNode != null) {
TreeNode.makeNodeVisible(selectedNode);
TreeNode.SetFocusToSelectedNode(this.mTreeNode);
}
else if (this.mTreeNode.getFirstChild() != null)
this.mTreeNode.getFirstChild().SetFocus();
}
return DTable.superclass.DOMFocus.call(this, ed);
}
DTreeView.prototype.GetSelectedColumn=function(levelOrID) {
var result;
if (this.mPrimaryRowSelection==null)
result = Null;
else if (levelOrID == 1) {
if (this.mLevel == -1)
return Null;
else
result = new IntegerType(this.mColFields[this.mCols[this.mLevel]].mID);
} else
result = new IntegerType(this.mLevel + 1);
return result;
}
DTreeView.prototype.IsLeafSelected=function() {
var result = null;
if(this.mTreeNode != null) {
var selectedNode = TreeNode.getSelectedNode(this.mTreeNode);
if (selectedNode.getChildCount() == 0)
result = IntegerType.ONE;
}
if (result == null)
result = IntegerType.ZERO;
return result;
}
DTreeView.prototype.ExpandAll=function() {
if (this.mTreeNode)
TreeNode.expandAll(this.mTreeNode);
else if (!this.mNotRefreshed)
this.expandOrCollapse = this.ExpandAll;
}
DTreeView.prototype.CollapseAll=function() {
if (this.mTreeNode)
TreeNode.collapseAll(this.mTreeNode);
else if (!this.mNotRefreshed)
this.expandOrCollapse = this.CollapseAll;
}
DTreeView.prototype.UpdateLabel=function(val) {
if(!this.mTreeNode)
return;
node = TreeNode.findNodeWithID(this.mTreeNode, this.mIndex + "_" + 0 + "_" + -1);
if (val == null || val == "")
val = this.mNullValue;
if (node != null)
node.changeLabel(val);
}
DTreeView.prototype.DoSet=DTreeView.prototype.DoSLoadEntry=function(val) {
if(!this.mTreeNode)
return DTreeView.superclass.DoSet.call(this, val);
var origVal = val;
if (val instanceof Datatype)
val = val.toInteger();
else {
if (val == "")
val = 0;
else
val = parseInt(val);
}
;
var highlight = true;
if (val < 0)
val = -val;
if (val > 100000000 || val < -100000000)
highlight = false;
if (val == 0 || val > this.GetData().length && val < 100000000) {
this.mTreeNode.ClearSelection();
} else if (highlight) {
var node = this.FindNode(val-1, this.mCols.length-1);
if (node != null) {
if (node.startRow < node.endRow)
this.mRow = node.startRow;
else
this.mRow = node.endRow;
this.mLevel = node.column;
TreeNode.selectNode(node);
}
}
var rtnVal = DTreeView.superclass.DoSet.call(this, origVal);
return rtnVal;
}
DTreeView.prototype.FindNode=function(targetRow, startCol) {
var row = targetRow;
var col = startCol;
var id, node = null;
do {
id = this.mIndex + "_" + row + "_" + col;
node = TreeNode.findNodeWithID(this.mTreeNode, id);
if (node==null)
row--; 
else {
if ((targetRow >= node.startRow && targetRow <= node.endRow) ||
(targetRow <= node.startRow && targetRow >= node.endRow))
break;
}
if (node!=null || row<0) {
row = targetRow;
col--;
}
} while (col>=0); 
return node;
}
DTreeView.prototype.NextChunk=function(dir) {
}
DTreeView.prototype.Report=function() {
}
DTreeView.prototype.ClearRowChanged=function(row) {
}
DTreeView.prototype.Refresh=function(startrow,numrows,fromchunk) {
this.mTreeNode = null; 
this.mObj.innerHTML = "<html></html>";
if(!this.mNotRefreshed) {
var refreshMode = parseInt(this.mObj.getAttribute("ARSelRefresh"));
if(refreshMode == 2 || refreshMode == 3)
this.mLevel = this.mCols.length-1;
}
return DTreeView.superclass.Refresh.call(this, -1, 0, false);
}
DTreeView.prototype.Clear=function() {
this.mLevel = this.mCols.length-1;
return DTreeView.superclass.Clear.call(this);
}
DTreeView.prototype.SelectAll=function(select) {
var label = this.GLabel();
if (label == null || label == "") {
select = false; 
}
return DTreeView.superclass.SelectAll.call(this, select);
}
DTreeView.prototype.DOMKeyPress=function(ed) {
}
DTreeView.prototype.DOMKeyUp=function(ed) {
}
DTreeView.prototype.DOMKeyDown=function(ed) {
;
;
if(this.mDisabled || !this.mTreeNode)
return;
var selectedNodeID = TreeNode.getSelectedNodeID(this.mTreeNode);
var currentNode;
if (ed.element != null && ed.element.id != null) {
currentNode = TreeNode.getTreeNode(ed.element.id.replace("title", ""));
if (currentNode == null)
return;
}
if(ed.key==37) { 
ed.StopDefault();
TreeNode.collapseCurrentNode(this.mTreeNode, currentNode);
} else if(ed.key==39) { 
ed.StopDefault();
TreeNode.expandCurrentNode(this.mTreeNode, currentNode);
} else if(ed.key==38) { 
ed.StopDefault();
TreeNode.selectPrevNode(this.mTreeNode, currentNode);
} else if(ed.key==40) { 
ed.StopDefault();
TreeNode.selectNextNode(this.mTreeNode, currentNode);
} else if(ed.key==32) { 
ed.StopDefault();
TreeNode.selectNodeByID(currentNode.getID());
} else if(ed.key==13) { 
ed.StopDefault();
TreeNode.selectNodeByID(currentNode.getID());
if (!currentNode.hasChilds())
return DTreeView.superclass.ARDrillDown.call(this, {y:currentNode.startRow, x:currentNode.column}, false);
} else {
return;
}
var newSelectedNodeID = TreeNode.getSelectedNodeID(this.mTreeNode);
if (selectedNodeID != newSelectedNodeID) {
var treeNode = TreeNode.getSelectedNode(this.mTreeNode);
TreeNode.SetFocusToSelectedNode(this.mTreeNode);
return this.SelectNode((treeNode.startRow<=treeNode.endRow?treeNode.startRow:treeNode.endRow), treeNode.column, false, true, true);
}
}
DTreeView.prototype.IsMouseSelectable=function(element) {
return false;
}
DTreeView.prototype.DOMMouseOver=function(ed) {
if (this.GAccess()==3)
return;
if (ed.element.id.indexOf("title") == 0)
ed.element.className = ed.element.className + " TreeHover";
}
DTreeView.prototype.DOMMouseOut=function(ed) {
if (this.GAccess()==3)
return;
if (ed.element.id.indexOf("title") == 0)
ed.element.className = ed.element.className.replace(" TreeHover", "");
}

TreeNode.showRootNode = false;
TreeNode.showLines = true;
TreeNode.sortNodes = false;
TreeNode.documentID = window.location.href;
TreeNode.showAllNodesOnStartup = false;
TreeNodes={};
TreeNode.NextIndex = 0;
TreeNode.href = '';
function TreeNode(id,name,color) {
this.id = id;
this.name = (name == null ? 'unset name' : name);
this.childs = new Array();
this.color = color;
}
TreeNode.prototype.parent = null;
TreeNode.prototype.linestring = '';
TreeNode.prototype.nextSibling = null;
TreeNode.prototype.prevSibling = null;
TreeNode.prototype.startRow = 0; 
TreeNode.prototype.endRow = 0; 
TreeNode.prototype.column = -1; 
TreeNode.registerRootNode = function(node) {
node.selectedNode = null;
node.statearray = new Array();
node.loaded = false;
TreeNodes[node.id] = node;
}
TreeNode.prototype.getID = function() {
return this.id;
}
TreeNode.prototype.setName = function(newname) {
this.name = newname;
}
TreeNode.prototype.getName = function() {
return this.name;
}
TreeNode.prototype.addChild = function(childNode) {
var possiblePrevNode = this.childs[this.childs.length - 1]
if (possiblePrevNode) {
possiblePrevNode.nextSibling = childNode;
childNode.prevSibling = possiblePrevNode;
}
this.childs[this.childs.length] = childNode;
childNode.setParent(this);
}
TreeNode.prototype.removeChild = function(childNode) {
var found = false;
for (var i=0;i<this.childs.length;i++) {
if (found) {
this.childs[i] = this.childs[i + 1];
}
if (this.childs[i] == childNode) {
if (i == (this.childs.length - 1)) {
this.childs[i] = null;
}
else {
this.childs[i] = this.childs[i + 1];
}
found = true;
}
}
if (found) {
this.childs.length = this.childs.length-1;
}
}
TreeNode.prototype.makeThisFirstChild = function() {
var parent = this.getParent();
var prev, tn, ns;
if (parent.hasChilds() && parent.childs[0] == this)
return;
else {
prev = this;
prev.prevSibling = null; 
ns = this.nextSibling; 
}
for (var i=0; i<parent.childs.length; i++) {
if (parent.childs[i] == this) {
prev.nextSibling = ns;
parent.childs[i] = prev;
break;
} else {
tn = parent.childs[i];
parent.childs[i] = prev;
prev.nextSibling = tn;
tn.prevSibling = prev;
prev = tn;
}
}
}
TreeNode.prototype.getNodeElement = function() {
return document.getElementById("title" + this.id);
}
TreeNode.prototype.resetChilds = function() {
this.childs = new Array();
}
TreeNode.prototype.hasChilds = function() {
return (this.childs.length > 0);
}
TreeNode.prototype.getChildCount = function() {
return this.childs.length;
}
TreeNode.prototype.getFirstChild = function() {
if (this.hasChilds()) {
return this.childs[0];
}
return null;
}
TreeNode.prototype.getChildren = function() {
return this.childs;
}
TreeNode.prototype.setParent = function(parent) {
this.parent = parent;
}
TreeNode.prototype.getParent = function() {
return this.parent;
}
TreeNode.prototype.getLineString = function() {
return this.linestring;
}
TreeNode.prototype.setLineString = function(string) {
this.linestring = string;
}
TreeNode.getRootNode = function(id) {
;
var parts = id.split("_");
if (parts.length>0)
return TreeNodes[parts[0]];
else
return null;
}
TreeNode.getTreeNode=function(nodeID) {
var rootNode = TreeNode.getRootNode(nodeID);
if (rootNode==null)
return null;
return TreeNode.findNodeWithID(rootNode,nodeID);
}
TreeNode.findNodeWithID=function(node,nodeID) {
if (nodeID == null)
return null;
if (node.getID() == nodeID) {
return node;
}
else {
if (node.hasChilds()) {
for(var i=0;i<node.getChildCount();i++) {
var value = TreeNode.findNodeWithID(node.childs[i],nodeID);
if (value != null) {
return value;
}
}
}
return null;
}
}
TreeNode.prototype.getState=function() {
return TreeNode.getState(this.getID());
}
TreeNode.getState=function(nodeID) {
var root = TreeNode.getRootNode(nodeID);
for(var i=0;i<root.statearray.length;i++) {
if (root.statearray[i]["key"] == nodeID) {
state = root.statearray[i]["state"];
if (state == null || state == '') {
state = 'closed';
}
return state;
}
}
return "closed";
}
TreeNode.writeStates=function(nodeID,newstate) {
var root = TreeNode.getRootNode(nodeID);
var str = '';
var found = false;
for(var i=0;i<root.statearray.length;i++) {
if (root.statearray[i]["key"] == nodeID) {
root.statearray[i]["state"] = newstate;
found = true;
}
if (root.statearray[i]["state"] != null) {
str += root.statearray[i]["key"] + '|' + root.statearray[i]["state"] + ';';
}
}
if (found == false) {
root.statearray[root.statearray.length] = new Array();
root.statearray[root.statearray.length - 1]["key"] = nodeID;
root.statearray[root.statearray.length - 1]["state"] = newstate;
if (newstate != null) {
str += nodeID + '|' + newstate + ';';
}
}
}
var markup, imgOpenNoRootTags, imgOpenNoRootLastTags, imgOpenTags, imgOpenLastTags, imgLineTags, imgWhiteTags, imgTTags, imgTNoRootTags, imgLastnodeTags;
TreeNode.showTree = function(rootNode, container, path) {
TreeNode.href = path;
var imgHref = '<img src="' + TreeNode.href; 
imgOpenNoRootTags = imgHref + 'images/plus_no_root.gif"';
imgOpenNoRootLastTags = imgHref + 'images/plus_last_no_root.gif"';
imgOpenTags = imgHref + 'images/plus.gif"';
imgOpenLastTags = imgHref + 'images/plus_last.gif"';
imgLastnodeTags = imgHref + 'images/lastnode.gif">';
imgLineTags = imgHref + 'images/line.gif">';
imgWhiteTags = imgHref + 'images/white.gif">'; 
imgTTags = imgHref + 'images/t.gif">';
imgTNoRootTags = imgHref + 'images/t_no_root.gif">';
markup = [];
if (rootNode.hasChilds()) {
for(i=0;i<rootNode.childs.length;i++) {
TreeNode.showNode(rootNode, rootNode.childs[i],(i == (rootNode.childs.length -1)), 0, i+1, rootNode.childs.length);
}
} else {
markup.push("<html></html>")
}
var str = markup.join("");
container.innerHTML = str; 
rootNode.loaded = true;
}
TreeNode.prototype.isLoaded = function() {
return this.loaded;
}
TreeNode.showNode = function(rootNode, treeNode, lastNode, level, childNum, numSiblings) {
linestring = treeNode.linestring;
markup.push('<div  id="node'); markup.push(treeNode.id); markup.push('"><nobr>');
for(var y=0;y<linestring.length;y++) {
if (linestring.charAt(y) == 'I') {
markup.push(imgLineTags);
}
else if (linestring.charAt(y) == 'B') {
markup.push(imgWhiteTags);
}
}
var imageTags = null;
var imageAsLink = true;
if (treeNode.hasChilds()) {
if (!TreeNode.showRootNode && (treeNode.parent == rootNode) && (treeNode.parent.getFirstChild() == treeNode)) {
if (!lastNode) {
imageTags = imgOpenNoRootTags;
}
else {
imageTags = imgOpenNoRootLastTags;
}
}
else {
if (!lastNode) {
imageTags = imgOpenTags;
}
else {
imageTags = imgOpenLastTags;
}
}
}
else {
if (!TreeNode.showRootNode && (treeNode.parent == rootNode) && (treeNode.parent.getFirstChild() == treeNode)) {
if (!lastNode) {
imageTags = imgTNoRootTags;
imageAsLink = false;
}
else {
imageTags = imgWhiteTags;
imageAsLink = false;
}
}
else {
if (!lastNode) {
imageTags = imgTTags;
imageAsLink = false;
}
else {
imageTags = imgLastnodeTags;
imageAsLink = false;
}
}
}
if (imageAsLink) {
markup.push(imageTags);
markup.push(' id="handler');
markup.push(treeNode.id);
markup.push('">');
} else {
markup.push(imageTags);
}
markup.push('<a href="javascript:"');
if (!treeNode.hasChilds())
markup.push(treeNode.color);
markup.push(' class="btn treetitle');
if (treeNode.id.indexOf('0_-1') > 0)
markup.push(' treeroot');
markup.push('"');
markup.push(' ID="title'); markup.push(treeNode.id); markup.push('">');
markup.push(treeNode.name);
markup.push('</a></nobr></div>');
if (treeNode.hasChilds()) {
markup.push('<div id="node'); 
markup.push(treeNode.id); 
markup.push('sub" style="display:'); 
markup.push((TreeNode.showAllNodesOnStartup == true ? 'block;' : 'none;'));
markup.push('visibility:');
markup.push((TreeNode.showAllNodesOnStartup == true ? 'inherit;"' : 'hidden;"'));
markup.push('>');
var newChar = '';
if (!lastNode) {
newChar = 'I';
}
else {
newChar = 'B';
}
var n = treeNode.childs.length;
for(var z=0;z<n;z++) {
treeNode.childs[z].linestring = linestring + newChar;
}
for(var z=0;z<n;z++) {
TreeNode.showNode(rootNode, treeNode.childs[z],(z == (n-1)), level+1, z+1, n);
}
markup.push('</div>');
}
else {
markup.push('<div id="node'); markup.push(treeNode.id); markup.push('sub" style="display:none;visibility:hidden;"></div>');
}
}
TreeNode.selectNodeByID=function(nodeID) {
var treeNode = TreeNode.getTreeNode(nodeID);
var rootNode = TreeNode.getRootNode(nodeID);
if (treeNode == null || rootNode == null || !rootNode.loaded)
return;
if (rootNode.selectedNode != null) {
if (rootNode.selectedNode == nodeID) {
return;
}
var oldNodeTitle = document.getElementById('title' + rootNode.selectedNode);
oldNodeTitle.className = 'btn treetitle';
if (oldNodeTitle.id.indexOf('0_-1') > 0)
oldNodeTitle.className = 'btn treetitle treeroot';
}
rootNode.selectedNode = nodeID;
var nodetitle = document.getElementById('title' + rootNode.selectedNode);
nodetitle.className = 'btn treetitleselectedfocused';
if (nodetitle.id.indexOf('0_-1') > 0)
nodetitle.className = 'btn treetitleselectedfocused treeroot';
this.makeNodeVisible(treeNode);
}
TreeNode.makeNodeVisible=function(treeNode) {
var rootNode = TreeNode.getRootNode(treeNode.id);
for(treeNode=treeNode.getParent(); treeNode != rootNode && treeNode != null; treeNode=treeNode.getParent()) {
if (TreeNode.getState(treeNode.id) == "closed") {
TreeNode.handleNode(treeNode.id);
}
}
}
TreeNode.handleNode=function(nodeID) {
var treeNode = TreeNode.getTreeNode(nodeID);	
if (!treeNode.hasChilds()) { 
return;
}
var submenu = document.getElementById('node' + nodeID + 'sub');
var actionimage = document.getElementById('handler' + nodeID);
var firstChildOfRoot = false;
if (actionimage.src.indexOf('_no_root') != -1) {
firstChildOfRoot = true;
}
if (submenu.style.display == 'none') {
TreeNode.writeStates(nodeID,'open');
submenu.style.display = 'block';
submenu.style.visibility = 'inherit';
if (actionimage.src.indexOf('last') == -1) {
actionimage.src = TreeNode.href + 'images/' + ((firstChildOfRoot) ? 'minus_no_root' : (TreeNode.showLines ? 'minus' : 'minus_nolines')) + '.gif';
}
else {
actionimage.src = TreeNode.href + 'images/' + ((firstChildOfRoot) ? 'minus_last_no_root' : (TreeNode.showLines ? 'minus_last' : 'minus_nolines')) + '.gif';
}
}
else {
TreeNode.writeStates(nodeID,'closed');
submenu.style.display = 'none';
submenu.style.visibility = "hidden";
if (actionimage.src.indexOf('last') == -1) {
actionimage.src = TreeNode.href + 'images/' + ((firstChildOfRoot) ? 'plus_no_root' : (TreeNode.showLines ? 'plus' : 'plus_nolines')) + '.gif';
}
else {
actionimage.src = TreeNode.href + 'images/' + ((firstChildOfRoot) ? 'plus_last_no_root' : (TreeNode.showLines ? 'plus_last' : 'plus_nolines')) + '.gif';
}
}
}
TreeNode.expandNode=function(node, recurse) {
; 
if (TreeNode.getState(node.id) == "closed")
TreeNode.handleNode(node.id);
if (recurse) {
for (var i=0;i<node.childs.length;i++)
TreeNode.expandNode(node.childs[i], true);
}
}
TreeNode.expandAll=function(root) {
if (root != null && root.loaded) {
for (var i=0;i<root.childs.length;i++)
TreeNode.expandNode(root.childs[i], true);
}
}
TreeNode.collapseNode=function(node, recurse) {
if (TreeNode.getState(node.id) == "open")
TreeNode.handleNode(node.id);
if (recurse) {
for (var i=0;i<node.childs.length;i++)
TreeNode.collapseNode(node.childs[i], true);
}
}
TreeNode.collapseAll=function(root) {
if (root != null && root.loaded) {
for (var i=0;i<root.childs.length;i++)
TreeNode.collapseNode(root.childs[i], true);
}
}
TreeNode.getSelectedNode=function(root) {
return TreeNode.findNodeWithID(root, root.selectedNode);
}
TreeNode.getSelectedNodeID=function(root) {
return root.selectedNode;
}
TreeNode.prototype.getNextSibling=function() {
var parent = this.getParent();
if (parent != null) {
for (var i=0;i<parent.childs.length;i++) {
if (parent.childs[i] == this && i+1 < parent.childs.length)
return parent.childs[i+1];
}
}
return null;
}
TreeNode.prototype.changeLabel=function(label) {
var id = document.getElementById('title' + this.id);
if (id) {
id.innerHTML = label;
this.name = label;
}
}
TreeNode.selectNode=function(node) {
TreeNode.selectNodeByID(node.getID());
}
TreeNode.handleSingleClick=function(elem) {
var id = elem.id;
if (id.indexOf("title") == 0) {
TreeNode.selectNodeByID(id.substring(5));
} else if (id.indexOf("handler") == 0) {
TreeNode.handleNode(id.substring(7));
} else if (id.indexOf("link") == 0) {
TreeNode.handleNode(id.substring(4));
} else
return false;
return true;
}
TreeNode.handleDoubleClick=function(elem) {
var id = elem.id;
if (id.indexOf("title") == 0) {
TreeNode.handleNode(id.substring(5));    
}
}
TreeNode.prototype.ClearSelection=function() {
if (this.selectedNode != null) {
var oldNodeTitle = document.getElementById('title' + this.selectedNode);
oldNodeTitle.className = 'btn treetitle';
if (oldNodeTitle.id.indexOf('0_-1') > 0)
oldNodeTitle.className = 'btn treetitle treeroot';
}
this.selectedNode = null;
}
TreeNode.expandCurrentNode=function(rootNode, currentNode) {
var state = currentNode.getState();
if (state == 'open') {
if (currentNode.hasChilds()) {
TreeNode.selectNodeByID(currentNode.childs[0].getID());
}
}
else {
TreeNode.handleNode(currentNode.id);
TreeNode.selectNodeByID(currentNode.id);
}
}
TreeNode.collapseCurrentNode=function(rootNode, currentNode) {
var state = currentNode.getState();
if (state == 'closed') {
var parent = currentNode.getParent();
if (parent != null && parent != rootNode) {
TreeNode.selectNodeByID(parent.getID());
}
}
else {
TreeNode.handleNode(currentNode.id);
TreeNode.selectNodeByID(currentNode.id);
}
}
TreeNode.selectPrevNode=function(rootNode, currentNode) {
if (currentNode.prevSibling != null) {
var state = TreeNode.getState(currentNode.prevSibling.getID());
if (state == 'open' && currentNode.prevSibling.hasChilds()) {
var current = currentNode.prevSibling.childs[currentNode.prevSibling.childs.length - 1];
var currentstate = 'open';
while (current.hasChilds() && (TreeNode.getState(current.getID()) == 'open')) {
current = current.childs[current.childs.length - 1];
}
TreeNode.selectNodeByID(current.getID());
}
else {
TreeNode.selectNodeByID(currentNode.prevSibling.getID());
}
}
else {
if (currentNode.getParent() != null && currentNode.getParent() != rootNode) {
TreeNode.selectNodeByID(currentNode.getParent().getID());
}
}
}
TreeNode.selectNextNode=function(rootNode, currentNode) {
var state = currentNode.getState();
if (state == 'open' && currentNode.hasChilds()) {
TreeNode.selectNodeByID(currentNode.childs[0].getID());
}
else {
if (currentNode.nextSibling != null) {
TreeNode.selectNodeByID(currentNode.nextSibling.getID());
}
else {
var parent = currentNode;
while ((parent = parent.getParent()) != rootNode) {
if (parent.nextSibling != null) {
TreeNode.selectNodeByID(parent.nextSibling.getID());
break;
}
}
}
}
}
TreeNode.SetFocusToSelectedNode=function(rootNode) {
var oldNodeTitle = document.getElementById('title' + rootNode.selectedNode);
if (oldNodeTitle != null) {
rootNode.focusTimer = setTimeout(function(){oldNodeTitle.focus()}, 10);
}
}
TreeNode.ClearFocusTimer=function(rootNode) {
if (rootNode.focusTimer != null) {
clearTimeout(rootNode.focusTimer);
rootNode.focusTimer = null;
}
}
TreeNode.prototype.SetFocus=function() {
var title = document.getElementById('title' + this.id);
if (title != null)
setTimeout(function(){title.focus()}, 10);
}

JAttachment.prototype=new Field(); JAttachment.prototype.constructor=JAttachment; JAttachment.superclass=Field.prototype;;
function JAttachment(a,b) {
if(arguments.length)
this.init(a,b);
}
JAttachment.prototype.init=function(a,b) {
JAttachment.superclass.init.call(this,a,b);
}
JAttachment.prototype.G=function() {
return this.mObj.v;
}
JAttachment.prototype.DoSet=JAttachment.prototype.DoSLoadEntry=function(val) {
;
if (val instanceof AttachmentType) {
if (this.mObj.msz && (val.mOrigSize > this.mObj.msz)) {
throw new WorkflowException(0, [{t:2, n:9210, m:null, a:null}]);
}
this.mObj.v = val;
} else if (val instanceof CharType) {
} else {
this.mObj.v=Null;
}
this.updateDisplay();
this.SetDirty();
}
JAttachment.prototype.mHaveStoredData=true;
JAttachment.fileDOSPathParser=/[A-Za-z]:(\\([^\\]+))+$/;
JAttachment.fileUnixPathParser=/(\/([^\/]+))+$/;
JAttachment.fileNetworkPathParser=/\\(\\([^\\]+))+$/;
JAttachment.prototype.updateDisplay=function() {
if (!this.mObj.hdn) {
;
var t = Fields[this.mObj.pnt];
;
var fname;
var size;
if (this.mObj.v.isNull) {
fname=size="";
} else {
;
fname = this.mObj.v.mFileName;
var cf = fname.match(JAttachment.fileDOSPathParser);
if (cf) {
fname=cf[2]; 
}
cf = fname.match(JAttachment.fileUnixPathParser);
if (cf) {
fname = cf[2]; 
}
cf = fname.match(JAttachment.fileNetworkPathParser);
if (cf) {
fname = cf[2]; 
}
size = parseInt(this.mObj.v.mOrigSize);
if (size > 0) {
var kbsz = size >> 10;
if (size & 1023) {
kbsz++;
}
size = kbsz;
}
size += " KB";
}
t.LoadRowContents(this.mID, fname, size);
}
}
JAttachment.prototype.setFromAddPopup=function(id, val) {
;
this.mFromAddValue = val;
}
JAttachment.SUCCESS = new IntegerType(0);
JAttachment.CANCELLED = new IntegerType(1);
JAttachment.FAILED = new IntegerType(2);
JAttachment.prototype.Add=function(result) {
if(typeof result == "undefined")
result = {};
if (this.mObj.v.isNull) {
return this.AddP1(result);
} else {
var res = {};
var msg = getLocalizedMessage("Would you like to replace {0} with new file?", null, "Attachment").replaceArgs(this.mObj.v.mFileName);
return {c:{ f:ConfirmPopup, a:[ msg, res, 4 | 8]},
n:{ t:this, f:function() {
;
if (("v" in res.result) && res.result.v == 1) {
return this.AddP1(result);
}
}}};
}
}
JAttachment.prototype.AddP1=function(result) {
var ret = AttachmentPopup(result, "PopupSF", getLocalizedMessage("File Name", null, "Attachment"),AttachmentType.getKeyForCurrentField(this.mID));
this.mFromAddValue=null; 
return {i:1, n:{ t:this, f:this.AddP2, a:[result]}};
}
JAttachment.prototype.AddP2=function(result) {
var retval = result.result;
if(retval && (typeof retval.v != "undefined")){
this.setFromAddPopup(retval.id, new AttachmentType(retval.v  + ""));
}
if (this.mFromAddValue != null) {
this.AddP3(result);
} else if (retval && (typeof retval.v != "undefined")){
result.result = JAttachment.FAILED;
} else if (retval && (typeof retval.v == "undefined")){
result.result = JAttachment.CANCELLED;
}
}
JAttachment.prototype.AddP3=function(result) {

this.mObj.v = this.mFromAddValue;
this.updateDisplay();
if (!("mDCF" in this)) 
this.mDCF=(this.mObj&&"dcf" in this.mObj)?(this.mObj.dcf==1):false;
this.SetDirty();
this.mFromAddValue=null;
if (result) {
result.result = JAttachment.SUCCESS;
}
}
JAttachment.prototype.Delete=function(result) {
;
if (!this.mObj.v.isNull) {
this.mObj.v=Null;
this.updateDisplay();
this.SetDirty();
if (result) {
result.result = JAttachment.SUCCESS;
}
} else if (result) {
result.result = JAttachment.FAILED;
}
}
JAttachment.displayHTML='<html><head><title>{0}</title></head><body onload=document.forms["ARDF12"].submit()><FORM name=ARDF12 id=ARDF12 method="GET" enctype="application/x-www-form-urlencoded" accept-charset="UTF-8" action="{1}"><input type=hidden name="{2}" value="{3}"/></FORM></body></html>';
JAttachment.prototype.Display=function(result) {
;
if (!this.mObj.v.isNull) {
var title = getLocalizedMessage("Display Attachment", null, "Attachment");
var w=window.open((AbsContextPath + "resources/html/Blank.html"),"_blank","toolbar=no,location=no,resizable=yes,scrollbars=yes,title=" + title);
WorkflowContext.WindowOpened();
w.document.open("text/html");
var act = JAttachment.getAttachServletURL() + "/" + new Date().getTime();
var key = JAttachment.getURLParams("1", this.mObj.v.mDataKey);        
w.document.write(JAttachment.displayHTML.replaceArgs(title, act, "ATTKey", key));
w.document.close();
if (result) {
result.result = JAttachment.SUCCESS;
}
} else if (result) {
result.result = JAttachment.FAILED;
}
}
JAttachment.getURL=function(key) {
;
return "{0}?{1}={2}".replaceArgs(JAttachment.getAttachServletURL(), "ATTKey", JAttachment.getURLParams("1", key));
}
JAttachment.getURLParams=function(cmd, key) {
; 
return "{0}/{1}{2}/{3}".replaceArgs(cmd.length,cmd,key.length, key);
}
JAttachment.saveHTML='<FORM method="POST" action="{0}" enctype="application/x-www-form-urlencoded" accept-charset="UTF-8" target="{1}"><input type=hidden name="{2}" value="{3}"/></FORM>';
JAttachment.prototype.SaveToDisk=function(result) {
if (!this.mObj.v.isNull) {
var e=window.document.createElement("DIV");
;
e.style.top=0;
e.style.left=0;
e.style.zIndex=100001;
e.style.position="absolute";
e.style.display="none";
window.document.body.appendChild(e);
var url = JAttachment.getAttachServletURL();
var target = JAttachment.getSaveFrameTarget();
var key = JAttachment.getURLParams("2", this.mObj.v.mDataKey);
var htmlStr = JAttachment.saveHTML.replaceArgs(url, target, "ATTKey", key);
e.innerHTML= htmlStr;
var form = e.firstChild;
;
form.submit(); 
window.document.body.removeChild(e);
if (result) {
result.result = JAttachment.SUCCESS;
}
} else if (result) {
result.result = JAttachment.FAILED;
}
}
JAttachment.ATTACH_SERVLET=null;
JAttachment.getAttachServletURL=function() {
if (JAttachment.ATTACH_SERVLET == null) {
JAttachment.ATTACH_SERVLET = (AbsContextPath + "servlet/AttachServlet");
}
return JAttachment.ATTACH_SERVLET;
}
JAttachment.saveFrame=null;
JAttachment.getSaveFrameTarget=function() {
if (JAttachment.saveFrame == null) {
JAttachment.saveFrame=window.document.createElement("div");
JAttachment.saveFrame.innerHTML="<IFRAME name=\"{0}\" onload=JAttachment.saveFrameLoaded() src=\"javascript:&quot;&lt;HTML&gt;&lt;/HTML&gt;&quot;\"></IFRAME>".replaceArgs("SaveToDiskIFrame");
JAttachment.saveFrame.style.display="none";
JAttachment.saveFrame.style.top=JAttachment.saveFrame.style.left=0;
JAttachment.saveFrame.style.bottom=JAttachment.saveFrame.style.right=1;
window.document.body.appendChild(JAttachment.saveFrame);
}
return "SaveToDiskIFrame";
}
JAttachment.saveFrameLoaded=function() {
var savefr = window.frames[JAttachment.getSaveFrameTarget()];
try {
if (savefr.document && savefr.document.body) {
if(savefr.document.location.href != "about:blank") {
var al = new AlertPopup();
var errMsg = savefr.window.Msg;
if (!errMsg) {
errMsg = getLocalizedMessage("Failed to perform action");
}
var contents = "<TABLE><TR><TD><textarea readonly rows=2 cols=50 class=\"dat\" style=\"overflow:auto;\">{0}</textarea></TD></TR></TABLE>".replaceArgs(errMsg);
al.SetContents(getLocalizedMessage("Save Error"), contents, "Attachment");
al.ShowCentredPopup();
}
}
} catch (exc) {
var al = new AlertPopup();
var contents = "<TABLE><TR><TD><textarea readonly rows=2 cols=50 class=\"dat\" style=\"overflow:auto;\">{0}</textarea></TD></TR></TABLE>".replaceArgs(getLocalizedMessage(9363));
al.SetContents(getLocalizedMessage("Save Error"), contents, "Attachment");
al.ShowCentredPopup();
}
}

DAttachmentPool.prototype=new SimpleTable(); DAttachmentPool.prototype.constructor=DAttachmentPool; DAttachmentPool.superclass=SimpleTable.prototype;;
DAttachmentPool.prototype.mHaveStoredData = false;
DAttachmentPool.prototype.MouseSelectable = false;
DAttachmentPool.prototype.mSortImgs = null;
var AttachPoolFields=[];
DOMFieldFactories["AttachmentPool"] = function(id,n) {
return new DAttachmentPool(id,n);
}
function DAttachmentPool(a,b) {
if(arguments.length)
this.init(a,b);
}
DAttachmentPool.prototype.init = function(id,n) {
this.mDirty = false; 
DAttachmentPool.superclass.init.call(this, id, n, 2, false,
this.InitData(n), this.InitButton(n));
AttachPoolFields.push(this);
}
DAttachmentPool.prototype.InitData = function(n) {
var args = {}; 
var arColWidth = parseInt(n.getAttribute("ARColW"));
args.h = [n.getAttribute("ARCol0"), n.getAttribute("ARCol1"), n.getAttribute("ARCol2")];
args.w = [arColWidth, arColWidth, arColWidth];
this.mIdRowMap = {}; 
this.mRowIdMap = {}; 
args.r=[]; 
var arRows = eval(n.getAttribute("ARRows"));
for (var i = 0; i < arRows.length; ++i) {
;
var row = [];
var attLabel = (arRows[i].l == null || arRows[i].l == "") ? "&nbsp;" : arRows[i].l;
row.d = [{v:"&nbsp;"}, {v:"&nbsp;"}, 
{v:attLabel}
]; 
args.r.push(row); 
this.mIdRowMap[arRows[i].f] = row;
this.mRowIdMap[i] = arRows[i].f;
}
return args;
}
DAttachmentPool.prototype.InitButton = function(n) {
var buttons = [];
var butName;
butName = n.getAttribute("ARAdd");
if (butName != null) {
this.mBtnAdd = {name:butName, loc:0, bar:1, func:this.UIAdd};
buttons.push(this.mBtnAdd); 
}
butName = n.getAttribute("ARDelete");
if (butName != null) {
this.mBtnDelete = {name:butName, loc:0, bar:1, func:this.UIDelete};
buttons.push(this.mBtnDelete);
}
butName = n.getAttribute("ARDisplay");
if (butName != null) {
this.mBtnDisplay = {name:butName, loc:0, bar:1, func:this.UIDisplay};
buttons.push(this.mBtnDisplay);
}
butName = n.getAttribute("ARSave");
if (butName != null) {
this.mBtnSave = {name:butName, loc:0, bar:1, func:this.UISaveToDisk};
buttons.push(this.mBtnSave);
}
return buttons;
}
DAttachmentPool.prototype.GetValidRow=function() {
if (this.mRowsPresent > 0) {
for (var i = 0; i < this.mRowsPresent; ++i) { 
var r=this.mResult.r[i];
if (r && r.d[0].v != "") { 
return i;
}
}
}
return -1;
}
DAttachmentPool.prototype.GetEmptyRow=function() {
if (this.mRowsPresent > 0) {
for (var i = 0; i < this.mRowsPresent; ++i) { 
var r=this.mResult.r[i];
if (r && r.d[0].v == "") { 
return i;
}
}
}
return -1;
}
DAttachmentPool.prototype.GetEmptyRowIds=function() {
var buf=[];
if (this.mRowsPresent > 0) {
var id;
for (var i = 0; i < this.mRowsPresent; ++i) { 
var r=this.mResult.r[i];
if (r && r.d[0].v == "") { 
id = this.mRowIdMap[i];
buf.push(id);
}
}
}
return buf;
}
DAttachmentPool.prototype.setFromAddPopup=function(id, val) {
;
this.mFromAddID = id;
this.mFromAddValue = val;
}
DAttachmentPool.prototype.Add=function(result) {
var ids = this.GetEmptyRowIds();
if (ids != "") {
if(typeof result == "undefined")
result = {};
var ret = AttachmentPopup(result, "PopupSF", getLocalizedMessage("File Name", null, "Attachment"),AttachmentType.getKeyForPoolField(this.mID, ids));
this.mFromAddID = null; 
this.mFromAddValue = null;
return {i:1, n:{ t:this, f:this.AddP2, a:[result]}};
} else if (result) {
result.result = JAttachment.FAILED;
}
}
DAttachmentPool.prototype.AddP2=function(result) {
var retval = result.result;
if(retval && (typeof retval.v != "undefined")){
this.setFromAddPopup(retval.id, new AttachmentType(retval.v  + ""));
}    
if ( this.mFromAddID != null && this.mFromAddValue != null) {
var fld = F(this.mFromAddID);
;
fld.S(this.mFromAddValue);
this.mFromAddID = this.mFromAddValue = null;
if (result) {
result.result = JAttachment.SUCCESS;
}
} else if (retval  && (typeof retval.v != "undefined")) {
result.result = JAttachment.FAILED;
} else if (retval  && (typeof retval.v == "undefined")) {
result.result = JAttachment.CANCELLED;
}
}
DAttachmentPool.prototype.UIAdd=function() {
var fid = null;
if (this.mPrimaryRowSelection!=null) 
fid = this.mRowIdMap[this.RowNoFromTag(this.mPrimaryRowSelection)];
else {
var idx = this.GetEmptyRow();
if (idx!=-1)
fid = this.mRowIdMap[idx];
}
;
;
var result = {};
return F(fid).Add(result);
}
DAttachmentPool.prototype.Delete=function(result) {
var row = this.GetValidRow(); 
if (row > -1) {
var fid = this.mRowIdMap[row];
;
F(fid).Delete(result);
} else if (result) {
result.result = JAttachment.FAILED;
}
}
DAttachmentPool.prototype.UIDelete=function() {
if (this.mPrimaryRowSelection!=null) {
var fid = this.mRowIdMap[this.RowNoFromTag(this.mPrimaryRowSelection)];
;
F(fid).Delete();
} else {
;
}
}
DAttachmentPool.prototype.Display=function(result) {
var row = this.GetValidRow(); 
if (row > -1) {
var fid = this.mRowIdMap[row];
;
F(fid).Display(result);
} else if (result) {
result.result = JAttachment.FAILED;
}
}
DAttachmentPool.prototype.UIDisplay=function() {
if (this.mPrimaryRowSelection!=null) {
var fid = this.mRowIdMap[this.RowNoFromTag(this.mPrimaryRowSelection)];
;
F(fid).Display();
} else {
;
}
}
DAttachmentPool.prototype.SaveToDisk=function(result) {
var row = this.GetValidRow(); 
if (row > -1) {
var fid = this.mRowIdMap[row];
;
F(fid).SaveToDisk(result);
} else if (result) {
result.result = JAttachment.FAILED;
}
}
DAttachmentPool.prototype.UISaveToDisk=function() {
if (this.mPrimaryRowSelection!=null){
var fid = this.mRowIdMap[this.RowNoFromTag(this.mPrimaryRowSelection)];
;
F(fid).SaveToDisk();
} else {
;
}
}
DAttachmentPool.prototype.ApplyData=function() {    
DAttachmentPool.superclass.ApplyData.call(this);
this.UpdateBtnVis();
}
DAttachmentPool.prototype.LoadRowContents=function(fid, fileName, fileSize) {
; 
; 
var row = this.mIdRowMap[fid];
row.d[0] ={v:fileName};
row.d[1] ={v:fileSize};
if (!this.mDirty) {
;
CurWFC.AddCallback(this, this.CommitRowContents);
this.mDirty = true;
}
}
DAttachmentPool.prototype.CommitRowContents=function() {
if (this.mDirty) {
this.ApplyData();
this.mDirty = false;
}
}
DAttachmentPool.prototype.UpdateVis=function(val) {
var curvis=(this.mObj.style.visibility!="hidden");
if(!curvis&&val) { 
this.mObj.style.visibility="inherit";
} else if(curvis&&!val) { 
this.mObj.style.visibility="hidden";
}
}
DAttachmentPool.prototype.SetBtnAccess=function(state) {
if(this.mBtnAdd) this.mBtnAdd.node.SetAccess(state); 
if (this.mBtnDelete) this.mBtnDelete.node.SetVisibility(state);
if (this.mBtnDisplay) this.mBtnDisplay.node.SetVisibility(state);
if (this.mBtnSave) this.mBtnSave.node.SetVisibility(state);
}
DAttachmentPool.prototype.ARRowSelected=DAttachmentPool.prototype.ARRowCleared=DAttachmentPool.prototype.UpdateBtnVis=function() {
if ((ARStateCurrent == 4)) {
this.SetBtnAccess(false);
} 
else {
var newrow=(this.mPrimaryRowSelection==null?-1:this.RowNoFromTag(this.mPrimaryRowSelection));
if (newrow != -1) {
var r = this.mResult.r[newrow];
if (r && r.d[0].v != "") {
this.SetBtnAccess(true);
if ((ARStateCurrent == 1))  {
if(this.mBtnSave) this.mBtnSave.node.SetVisibility(false);
}
if ((ARStateCurrent == 3))  { 
if(this.mBtnAdd) this.mBtnAdd.node.SetAccess(false);
if (this.mBtnDelete) this.mBtnDelete.node.SetVisibility(false);
}
return;
}
}
if (newrow != -1 || this.GetEmptyRow() != -1) { 
this.SetBtnAccess(false);
if (!(ARStateCurrent == 3))  { 
if(this.mBtnAdd) this.mBtnAdd.node.SetAccess(true);
}
return;
}
this.SetBtnAccess(false);
}
}
DAttachmentPool.prototype.ARDrillDown=function(xy,fromlink) {
if (this.mBtnDisplay)
this.UIDisplay(); 
}
DAttachmentPool.prototype.SetRowSortOrder=function(col,dir,selections,primaryselection) {
}
DAttachmentPool.prototype.Clear=function() {
this.ClearSelections(true);
;
for (var i = 0; i < this.mRowsPresent; ++i) { 
var r=this.mResult.r[i];
if (r) { 
r.d[0].v = "";
r.d[1].v = "";
}
}
this.ApplyData();
this.mDirty = false;	
}
function DAttachmentPool_DoEntryChange(clear) {
for (var i = 0; i < AttachPoolFields.length; ++i) {
;
if(clear) {
AttachPoolFields[i].ClearSelections(true);
}
AttachPoolFields[i].ApplyData();
}
}
DAttachmentPool.prototype.DOMFocus=function(ed) {
var estack=[]; 
if (ed.element != null) {
var row = -1;
if(this.mPrimaryRowSelection != null)
row = this.mPrimaryRowSelection;
row=(row<0&&ed.element.className.indexOf("Add")<0?0:row);
row=(row>=this.mRowsPresent?this.mRowsPresent-1:row);
estack.push({t:this,f:DAttachmentPool.superclass.DOMFocus, a:[ed]}); 
if (row>-1) {
estack.push({t:this,f:this.ApplySelections});
estack.push({t:this,f:this.SetPrimarySelection,a:[row,true,true]});
}
return {n:estack}; 
}
return DAttachmentPool.superclass.DOMFocus.call(this, ed);
}

function AttachmentPopup(result, target, input, key) {
;
var buttons = 1 | 2;
var title = getLocalizedMessage("Add Attachment");
var statusMsg = getLocalizedMessage("Status");
var servlet = "../../servlet/AttachServlet";	
return weOpenModalPopup((AbsContextPath + "resources/html/AttachmentPopup.html"),"Attachment",{title:title, target:target, servlet:servlet, key:key, btn:buttons, appss:GetAppStyleSheet("../../"), input:input, statusLabel:statusMsg}, result, [400,150]);
}

DTime.prototype=new DataField(); DTime.prototype.constructor=DTime; DTime.superclass=DataField.prototype;; 
DOMFieldFactories["Time"]=function(id,n) {
return new DTime(id,n);
}
function DTime(a,b) {
if(arguments.length)
this.init(a,b);
}
DTime.prototype.init=function(id,n) {
this.mInputNode=n.childNodes[1];
;
DTime.superclass.init.call(this,id,n);
}
DTime.prototype.ConvertPrimitiveToDataType=function(str) {
var t = this.FromUIInput(str,false,false); 
return t;
}
DTime.prototype.GetQBEValue=function() {
if (this.IsNullKeyword())
return NullType.KEYWORD_NULL;
var val = this.mInputNode.value;
val = ExpandString(val, 2 | 4, this.mID, 7);
val = val.trim(1|2);
if (val == "")
return Null;
var qbeOp = Field.GetQBEOperator(val);
if (qbeOp == null) {
var errs = this.Validate();
if (errs) {
throw(errs);
}
return this.G();
} else {
var valPart = this.FromUIInput(val.substring(qbeOp.length).trim(1), true, false);
return new CharType(qbeOp + valPart.toPrimitive());
}
}
DTime.prototype.FromUIInput = function(val, validate, expand) {
if (expand)
val = ExpandString(val, 2 | 4, this.mID, 7);
val = val.trim(1|2);
if (val == "")
return Null;
var dateObj = ARDate.parseDateTime(val);
var intVal;
if (dateObj != null)
intVal = dateObj.GTimestamp();
if (dateObj == null || intVal < 0 || intVal > 2147483647) {
if (validate && !val.isNumeric()) {
throw({t:2,n:9376,m:null,a:this.GLabel()});
}
intVal = parseInt(val, 10);
if (isNaN(intVal))
intVal = 0; 
else if (intVal <0)
intVal = 0;
else if (intVal > 2147483647)
intVal = 2147483647;
}
var t = new TimeType(intVal);
t.setDisplayFormat(this.mInputNode.getAttribute("ds"));
return t;
}
DTime.prototype.ConvertDTForS=DTime.prototype.ConvertDTForSLE=function(val) {
;
var df = this.mInputNode.getAttribute("ds");
if (val.isNull || (val.type == 7 && !(val instanceof DateKWType) && val.getDisplayFormat() == df))
return val;
else if (ARKWIsKeywordString(val))
return new CharType(val.toString());
else {
val = new TimeType(val.toTime().toString(df));
val.setDisplayFormat(this.mInputNode.getAttribute("ds"));
return val;
}
}
DTime.prototype.Validate=function() {
try {
return Time_Validate(this, this.FromUIInput(this.mInputNode.value,true,true));
} catch (err) {
err.a = this.GLabel();
return err;
}
}
DTime.prototype.mHaveStoredData=true;
DTime.prototype.mDataType=7;
DTime.prototype.DOMClick = function(evt) {
;
if (this.GAccess() == 3)
return;
var e=FakeButton_Find(evt.element);
if (e) {
if (e.className.indexOf("expand") != -1) {
var ds = this.mInputNode.getAttribute("ds");
var ro = this.GAccess() == 1;
var popup = new TimePopup(this, ds != 2 , ds != 1, false, ro);
return popup.ShowPopup(e,0,e.offsetHeight);
} else {
this.mInputNode.focus();
}
}
}
JTime.prototype=new Field(); JTime.prototype.constructor=JTime; JTime.superclass=Field.prototype;; 
JFieldFactories["Time"]=function(id,n) {
return new JTime(id,n);
}
function JTime(a,b) {
if(arguments.length)
this.init(a,b);
}
JTime.prototype.G=function() {
;
;
var val = this.mObj.v;
if (val.isNull || val.type == 7)
return val;
else {
if (val.type == 4)
val = ExpandString(val.toString(), 2 | 4, this.mID, this.mDataType);
this.mObj.v = new TimeType(val);
return this.mObj.v;
}
}
JTime.prototype.DoSet=function(val) {
;
if(val.isNull)
this.mObj.v = Null;
else if (ARKWIsKeywordString(val))
this.mObj.v = new CharType(val.toString());
else {
val=val.toTime();
this.mObj.v = val;
}
this.SetDirty();
}
JTime.prototype.Validate=function() {
return Time_Validate(this, this.G());
}
DTime.prototype.ValidatePopupValue = function(val) {
;
val = new TimeType(val.GTimestamp());
var err = Time_Validate(this, val);
if (err != null) 
return {t:2,n:9307,m:null,a:"01/01/1970 - 01/19/2038 (GMT) : " + this.GLabel()}; 
return null;
}
DTime.prototype.SetFromPopup = JTime.prototype.SetFromPopup = function(val) {
;
this.S(new TimeType(val.GTimestamp()));
}
function Time_Validate(field, val) {
;
var isDirty = field.mLastChanged && Field_LastCleared<=field.mLastChanged;
if(!isDirty)
return null;
if (!val.isNull) {
;
if (val.valueAdjusted)
return {t:2,n:9376,m:null,a:field.GLabel()};
}
return null;
}
JTime.prototype.mHaveStoredData=true;
JTime.prototype.GetSorter = function() {
return "(ls=parseInt(lhs),rs=parseInt(rhs),(isNaN(ls)?0:ls)-(isNaN(rs)?0:rs))";
}

TimePopup.prototype=new DIVPopup(); TimePopup.prototype.constructor=TimePopup; TimePopup.superclass=DIVPopup.prototype;;
function TimePopup(field, showTime, showDate, showBC, readOnly) {
if (arguments.length)
this.init(field,showTime,showDate, showBC, readOnly);
}
TimePopup.prototype.init=function(field,showTime,showDate, showBC, readOnly) {
;
this.mField = field;
;
;
;
;
;
var e = field.mObj.childNodes[3]; 
TimePopup.superclass.init.call(this,true);
this.mShowTime = showTime
this.mShowDate = showDate;
this.mShowBC = showBC;
this.mReadOnly = readOnly;
if (this.mReadOnly) {
this.Buttons = [
{t : getLocalizedMessage("Cancel"), f : "OnCancel"}
];
}
}
TimePopup.prototype.GetTitleBarHTML = function(label) {
return ""; 
}
TimePopup.UpdateCalendar=function() {
;
TimePopup.prototype.UpdateCalendar.call(OpenDIVPopup);
}
TimePopup.prototype.SetMonth = function(mon) {
this.mDateVal.SMonth(mon);
this.UpdateCalendar();
}
TimePopup.prototype.SetYear = function(year) {
var y = this.mDateVal.GYear();
var newYear = year * ((y < 0) ? -1 : 1);
if (y < 0) newYear++;
this.mDateVal.SYear(newYear);
this.UpdateCalendar();
}
TimePopup.UpdateDay=FormEvent.Trampoline(function(ed) {
var day=ed.element.getAttribute("DAY");
if (day >= 0) {
TimePopup.prototype.SetDay.call(OpenDIVPopup, day);
}
});
TimePopup.prototype.SetDay = function(day) {
this.mDateVal.SDate(parseInt(day));
this.UpdateCalendar();
setTimeout(TimePopup.InitFocus, 1);
}
TimePopup.prototype.UpdateCalendar = function() {
var elems = this.mDiv.getElementsByTagName("SPAN");
;
for (var i=0; i < elems.length; i++) {
if (elems[i].id == "calendar") {
elems[i].innerHTML = this.GetMonthHTML();
return;
}
}
}
TimePopup.prototype.GetLastDayInMonth = function() {
var monthStart = new Date(this.mDateVal.GYear(), this.mDateVal.GMonth(), 1);
monthStart.setDate(32); 
return 32 - monthStart.getDate();
}
TimePopup.prototype.GetMonthHTML = function() {
var htmlVal = [];
htmlVal.push("<table cellspacing=3><tr class=\"daysofweek\">");
for (var i=0; i < 7; i++) {
htmlVal.push("<th scope=\"col\" align=right");
htmlVal.push(">&nbsp;" + ARDate.DayShort(i).substring(0,1).HTMLEncode() + "</th>");
}
htmlVal.push("</tr>");
var d = 1 - new ARDate(this.mDateVal.GYear(), this.mDateVal.GMonth(), 1).GDay();
var end = this.GetLastDayInMonth();
for (var i=0; i<6; i++) {
htmlVal.push("<tr>");
for (var j=0;j<7;j++) {
var mday = (d <= 0 || d > end) ? -1 : d;
if (mday > 0) {
htmlVal.push("<td DAY=\"" + mday + "\" onclick=\"javascript:TimePopup.UpdateDay(arguments[0]);\" class=\"");
if (mday == this.mDateVal.GDate()) {
htmlVal.push("calendaron\" id=\"calendaron\">");
} else if (j==0 || j==6) {
htmlVal.push("weekend\">");
} else {
htmlVal.push("weekday\">");
}
htmlVal.push(mday + "</td>");
} else {
htmlVal.push("<td>&nbsp;</td>");
}
d++;
}
htmlVal.push("</tr>");
}
htmlVal.push("</table>");
return htmlVal.join("");
}
TimePopup.prototype.BuildCalendar = function() {
var htmlVal = "<table width=\"100px\">";
if (this.mShowDate) {
var month = ARDate.MonthLabel(this.mDateVal.GMonth());
htmlVal += "<tr><td rowspan=3>&nbsp;</td><td nowrap colspan=2><table cellpadding=0 cellspacing=0><td width=100 height=24><div style='position:relative;top:0;height:21px;width:105;'>";
htmlVal += "<input ARTB=1 id=\"popupmonth\" readonly class=\"text\" style=\"left:10;height:21px;width:90px\"";
htmlVal += " value=\"" + month + "\"></INPUT>";
htmlVal += "<a class=\"btn btn3d selectionbtn\" style=\"left:80;height:21px;width:20px;\">";
htmlVal += "<img id=\"monthmenu\"class=\"btnimg\" src=\""+RelContextPath+"resources/images/field_menu.gif\"/>";
htmlVal += "</a>"
htmlVal += "</div></td>";
var year = this.mDateVal.GYear();
if (year <= 0) { 
year = Math.abs(year) + 1;
} else {
year = Math.abs(year);
}
htmlVal += "<td height=24 cellpadding=0>";
htmlVal+= "<input ARTB=1 id=\"popupyear\" type=\"text\" class=\"text\" style=\"position:static;height:21px;width:45px\" size=4 maxlength=4 value='" + year + "'></td>";
if (this.mShowBC) {
htmlVal += "<td>";
htmlVal +="<input type=checkbox ARTB=1 ";
if (this.mDateVal.GYear() <= 0) 
htmlVal += "checked ";
htmlVal += "id=\"bc\" name=\"bc\" value=\"BC\"></td><td nowrap>" + getLocalizedMessage("BC") + "</td>";
}
htmlVal += "</table></td><td rowspan=3>&nbsp;</td></tr>";
htmlVal += "<tr><td colspan=2><span id=\"calendar\">" + this.GetMonthHTML(); + "</span></td></tr>";
}
if (this.mShowTime) {
htmlVal += "<tr><td colspan=2>";
this.militaryTime = localeInfo.timeFormatPattern.match(/[iI]/);
var time = new TODType(this.mDateVal.GTimeOfDay());
htmlVal += this.GetTimePopupHTML(time);
htmlVal += "</td></tr>";
}
htmlVal += "</table>";
this.SetContents(null, htmlVal);
}
TimePopup.prototype.GetTimePopupHTML=function(val) {
;
var o = val.getTimeObj(); 
o.h = this.AdjustHour(o.h);
var meridiem = localeInfo.AMPM[0];  
if (!val.isNull && val.toInteger() >= (12 * 3600)) { 
meridiem = localeInfo.AMPM[1]; 
}
var htmlParts = [];
htmlParts["A"] = "<td><input ARTB=1 id=\"meridiem\" class=\"text\" style=\"position:relative; height:20px; ; width:25px; max-width: 25px\" type=\"text\" value=\"" + meridiem + "\" size=3 maxlength=2 > </td>";
htmlParts["H"] = "<td><input ARTB=1 id=\"hr\" class=\"text\" style=\"position:relative; height:20px; width:20px; max-width: 20px\" type=\"text\" value=\"" + o.h + "\" size=2 maxlength=2 > </td>";
htmlParts["I"] = htmlParts["H"];
htmlParts["U"] = "<td><input ARTB=1 id=\"min\" class=\"text\" style=\"position:relative; height:20px; width:20px; max-width: 20px\" type=\"text\" value=\"" + ARDate.zeroPad(o.m) + "\" size=2 maxlength=2 > </td>";
htmlParts["S"] = "<td><input ARTB=1 id=\"sec\" class=\"text\" style=\"position:relative; height:20px; width:20px; max-width: 20px\" type=\"text\" value=\"" + ARDate.zeroPad(o.s) + "\" size=2 maxlength=2 > </td>";
var sep =  "<td><div class=\"label f9\" style=\"position:relative\">" + localeInfo.timeSeparator + "</div> </td>";
var htmlVal = [];
var parts = localeInfo.timeFormatPattern.split(/[^asSuUiIhH]+/);
for (var p in parts) {
p = parts[p].toUpperCase();
if (p.length > 0) {
;
if (p.match(/[U|S]/)) { 
htmlVal.push(sep);
}
htmlVal.push(htmlParts[p]);
}
}    
htmlVal.push("<td><table><tr><td><a href=\"javascript:\" id=\"up\" class=\"btn btn3d spinnerup\" style=\"position:relative; top:0; width:15; left:0; height:9;\"");
htmlVal.push(">");
htmlVal.push("<img id=\"up\" alt=\"\" class=\"btnimg\" src=\""+RelContextPath+"resources/images/spinner_up.gif\" style=\"position:relative; top:2; width:5; left:4;\"></a></td></tr>");
htmlVal.push("<tr><td><a href=\"javascript:\" id=\"down\" class=\"btn btn3d spinnerdown\" style=\"position:relative; left:0; width:15; top:0; height:9\"");
htmlVal.push(">");
htmlVal.push("<img id=\"down\" alt=\"\" class=\"btnimg\" src=\""+RelContextPath+"resources/images/spinner_down.gif\" width=5 height=3 style=\"position:relative; top:2; width:5; left:4;\"></a></td></tr></table></td><td width=\"5px\">&nbsp;</td></tr></table>");
return  "<table><tr>" + htmlVal.join("");
}
TimePopup.prototype.ShowPopup = function(parentelement,ox,oy) {
var val = Null;
var ret = new Object();
if (this.mField.Validate() != null) {
var errCode;
if (!this.mShowDate) {
errCode = 9379;
} else {
errCode = 9380;
}    
ret.c = {f:MessagePopup, a:[new Array({n: errCode, t: 1, m:null, a:null})]};    
} else {
val = this.mField.G();
}
ret.n = {f:function(tpopup, v) {
var date = new ARDate();
if (v.isNull) {
date.STimestamp(new Date().UnixTimestamp());
date.SHour(0);
date.SMinute(0);
date.SSecond(0);
} else if (v instanceof TODType) {
var o = v.getTimeObj();
date.STimestamp((new ARDate(1970, 1, 1, o.h, o.m, o.s)).GTimestamp());
} else if (v instanceof DateType) {
date.SDays(v.toInteger());
} else {
date.STimestamp(new TimeType(v).toInteger());
}
tpopup.mDateVal = date;
tpopup.BuildCalendar();
TimePopup.superclass.ShowPopup.call(tpopup,parentelement,ox,oy);
setTimeout(TimePopup.InitFocus, 1);
}, a:[this, val]};
return ret;
}
TimePopup.InitFocus = function() {
if (OpenDIVPopup) {
TimePopup.prototype.InitFocus.call(OpenDIVPopup);
}
}
TimePopup.prototype.InitFocus = function() {
if (this.mShowDate) {
var elems = this.mDiv.getElementsByTagName("SPAN");
if (!elems) {
return;
}
for (var i=0; i < elems.length; i++) {
if (elems[i].id == "calendar") {
var days = elems[i].getElementsByTagName("TD");
for (var j=0; j < days.length; j++) {
if (days[j].id == "calendaron") {
if("focus" in days[j])
days[j].focus();
}
}
}
}
} else if (this.mShowTime) {
var elems = this.mDiv.getElementsByTagName("INPUT");
if (elems && elems.length > 0) {
if("focus" in elems[0])
elems[0].focus();
}
}
}
TimePopup.prototype.KeyPress = function(edata) {
var element=edata.element,id = element.id;
if (!id) {
return true; 
}
var key  = edata.key;
var cStr = String.fromCharCodeWithNumPad(key);
var v = element.value;
if (id == "popupyear") {
if (!cStr.match("^[0-9]$")) {
return false; 
}
var p = parseInt(v);
if (p >= 1000) {
element.value = cStr;
if("focus" in element)
element.focus();
} else {
element.value = parseInt(v + cStr);
}
this.SetYear(parseInt(element.value));
if("focus" in element)
element.focus();
return false; 
} else if (id == "hr" || id == "min" || id == "sec") {
if (cStr.match("^[0-9]$")) {
var p = parseInt(v);
var c = parseInt(cStr);
if (isNaN(c)) {
c = 0;
}
element.value = (id == "hr") ? this.Validate_Hour(p, c, key) : 
(id == "min") ? this.Validate_Min(p, c, key) :
(id == "sec") ? this.Validate_Sec(p, c, key) : v;
if("focus" in element)
element.focus();
}
return false; 
} else if (id == "meridiem") {
if (localeInfo.AMPM[0].toLowerCase().indexOf(cStr.toLowerCase()) == 0) {
if (element.value != localeInfo.AMPM[0]) {
this.mDateVal.SHour(this.mDateVal.GHour()-12);
}
element.value = localeInfo.AMPM[0];
} else if (localeInfo.AMPM[1].toLowerCase().indexOf(cStr.toLowerCase()) == 0) {
if (element.value != localeInfo.AMPM[1]) {
this.mDateVal.SHour(this.mDateVal.GHour()+12);
}
element.value = localeInfo.AMPM[1];
}
return false; 
}
return TimePopup.superclass.KeyPress.call(this, edata);
}
TimePopup.prototype.KeyDown = function(edata) {
if (edata.key == 9) {
return TimePopup.superclass.KeyDown.call(this, edata);
}
var element=edata.element,id = element.id;
var key=edata.key;
var v = element.value;
if (id == "hr" || id == "min" || id == "sec") {
if (v.indexOf("0") == 0)
v = v.substring(1);
var p = parseInt(v);
var cStr = String.fromCharCodeWithNumPad(key);
var c = parseInt(cStr);
if (isNaN(c)) {
c = 0;
}
element.value = (id == "hr") ? this.Validate_Hour(p, c, key) : 
(id == "min") ? ARDate.zeroPad(this.Validate_Min(p, c, key)) :
(id == "sec") ? ARDate.zeroPad(this.Validate_Sec(p, c, key)) : v;
} else if (id == "popupyear") {
if (key == 46) {
element.value = "";
return false;
}
var p = (v==""? 0 : parseInt(v));
if (key == 38 || key == 40) { 
var y = p + ((key == 38) ? 1 : -1);
y = Math.max(1, y);
element.value = y;
this.SetYear(y);
} else {
var c = parseInt(String.fromCharCodeWithNumPad(key));
if (!isNaN(c)) {
if (p >= 1000) {
element.value = c;
this.SetYear(c); 
} else {
element.value = (v==""? c+"" : (p + "" + c));
this.SetYear(parseInt(p + "" + c));
}
}
}
} else if (id == "meridiem") {
element.value = this.Validate_Meridiem(v);
} else if (element.className.indexOf("calendaron") != -1 && (key == 38 || key == 40 || key == 37 || key == 39)) {
var end = this.GetLastDayInMonth();
var day = this.mDateVal.GDate();
if (key == 38 || key == 40) {
day += (key == 38) ? -7 : 7;
if (day <= 0) {
day = 35 + day;
if (day > end) {
day -= 7;
}
}
if (day > end) {
day = day - 35;
if (day <= 0) {
day += 7;
}
}
} else if (key == 37 || key == 39) {
day += (key == 37) ? -1 : 1;
if (day > end) {
day = 1;
} else if (day <= 0) {
day = end;
}
}
this.SetDay(day);
} else {
return TimePopup.superclass.KeyDown.call(this,edata);
}
return false; 
}
TimePopup.prototype.OnOK = function() {
var err = this.mField.ValidatePopupValue(this.mDateVal);
if (err == null) {
this.mField.SetFromPopup(this.mDateVal);
this.HidePopup();
} else {
new WorkflowContext({f:MessagePopup, a:[new Array(err)]});
}
}
TimePopup.prototype.Validate_Hour = function(prev, curr, key) {
var hr = this.mDateVal.GHour();
if (key == 38) {
hr = (hr+1)%24;
} else if (key == 40) {
hr = (--hr)<0?hr+24:hr;
} else {
if ((key >= 48 && key <= 57) || (key >= 96 && key <= 105)) {
var val = (!isNaN(prev) && (prev == 1 || (prev == 2 && curr <= 3))) ? ((10*prev)+curr) : curr;
hr=parseInt(val);
}
}
this.mDateVal.SHour(hr);
if (!this.militaryTime && (hr==12 || hr==0 || hr==11 || hr==23)) {
var meridiumel=document.getElementById('meridiem');
if (meridiumel)
meridiumel.value = ((hr==0||hr==11)?localeInfo.AMPM[0]:localeInfo.AMPM[1]);
} 
return this.AdjustHour(this.mDateVal.GHour());
}
TimePopup.prototype.AdjustHour = function(hr) {
if (!this.militaryTime) {
if (hr == 0) {
hr = 12;
} else if (hr >= 13) {
hr -= 12;
}
}
return hr;
}
TimePopup.Validate_Min_Sec = function(prev, curr, key) {
if (key == 38) {
return (prev == 59) ? 0 : ++prev;
} else if (key == 40) {
return (prev == 0) ? 59 : --prev;
}
return ((key >= 48 && key <= 57) || (key >= 96 && key <= 105)) ? ((prev <=5) ? ((10*prev)+curr) : curr) : prev;
}
TimePopup.prototype.Validate_Min = function(prev, curr, key) {
this.mDateVal.SMinute(TimePopup.Validate_Min_Sec(prev, curr, key));
return this.mDateVal.GMinute();
}
TimePopup.prototype.Validate_Sec = function(prev, curr, key) {
this.mDateVal.SSecond(TimePopup.Validate_Min_Sec(prev, curr, key));
return this.mDateVal.GSecond();
}
TimePopup.prototype.Validate_Meridiem = function(val) {
if (val == localeInfo.AMPM[0]) {
val = localeInfo.AMPM[1];
this.mDateVal.SHour(this.mDateVal.GHour()+12);
} else {
val = localeInfo.AMPM[0];
this.mDateVal.SHour(this.mDateVal.GHour()-12);
}
return val;
}           
TimePopup.prototype.Click = function(edata) {
var element=edata.element,id = element.id;
if (id && (id == "up" || id == "down")) {
var key = (id=="up") ? 38 : 40; 
var element;
var range=document.selection.createRange().duplicate();
element = range.parentElement();
if (element) {
id = element.id;
var v = element.value;
var p = parseFloat(v);
var val = v;
if (id == "meridiem") {
element.value = this.Validate_Meridiem(v);
} else {
element.value = (id == "hr") ? this.Validate_Hour(p, 0, key) : 
(id == "min") ? ARDate.zeroPad(this.Validate_Min(p, 0, key)) :
(id == "sec") ? ARDate.zeroPad(this.Validate_Sec(p, 0, key)) : v
}
}
} else if (id && (id == "hr" || id == "min" || id == "sec" || id == "meridiem" || id == "popupyear")) {
element.select();
} else if (id && id == "bc") {
var year = this.mDateVal.GYear();
if (year < 0) {
year = Math.abs(year) + 1; 
} else {
year = -year;
}
this.mDateVal.SYear(year);
this.SetYear(Math.abs(this.mDateVal.GYear()));
return true; 
} else if (id && (id == "popupmonth" || id == "monthmenu")) {
var monthel=document.getElementById('popupmonth');
if (!this.mMenu)
this.mMenu = new MonthDropDownMenu(monthel);
this.mMenu.Open(monthel, 3);
}
return false; 
}
MonthDropDownMenu.prototype=new Menu(); MonthDropDownMenu.prototype.constructor=MonthDropDownMenu; MonthDropDownMenu.superclass=Menu.prototype;;
function MonthDropDownMenu(field) {
if (arguments.length)
this.init(field);
}
MonthDropDownMenu.prototype.init = function(field) {
; 
var uimenudef = [];
for (var i=0; i<12; i++)
uimenudef.push({l:ARDate.MonthLabel(i), v: ARDate.MonthLabel(i)});
MonthDropDownMenu.superclass.init.call(this, uimenudef);
this.mField=field; 
}
MonthDropDownMenu.prototype.Open = function(adjacent_element) {
;
MonthDropDownMenu.superclass.Open.call(this, adjacent_element, 3, 100001, false);
}
MonthDropDownMenu.prototype.HandleSelection = function(val) { 
;
this.mField.value = val;
TimePopup.prototype.SetMonth.call(OpenDIVPopup, parseInt(localeInfo.monthsLongMap[val.toLowerCase()]));
}

DTrim.prototype=new Field(); DTrim.prototype.constructor=DTrim; DTrim.superclass=Field.prototype;;
DOMFieldFactories["Trim"]=function(id,n) {
return new DTrim(id,n);
}
function DTrim(a,b) {
if(arguments.length)
this.init(a,b);
}
DTrim.prototype.mDOMField=DTrim.prototype.mHaveVisualCharacteristics=true;
DTrim.prototype.init=function(a,b) {
DTrim.superclass.init.call(this,a,b);
var elems=this.mObj.getElementsByTagName("TD");
if(elems != null)
this.mTextElement=elems[0];
}
DTrim.prototype.Clear=function() {}
DTrim.prototype.UpdateLabel=function(val) {
;
if(!this.mTextElement)
return;
this.mTextElement.innerHTML = this.ReplaceText(val);
}
DTrim.prototype.UpdateAccess=function(val) {
;
;
var disabled = (val == 3);
var n, cl;
if (this.mObj.getAttribute("ARSubType") == 3) {
n = this.mTextElement;
cl = "disabled";
} else {
n = this.mObj;
cl = "trimBorderDisabled";
}
if (disabled) {
var clist = n.className.split(" ");
clist.push(cl);
n.className = clist.join(" ");
} else {
var re = new RegExp(cl);
n.className = n.className.replace(re,"");
}
}
DTrim.prototype.UpdateFont=function(val) {
;
var n=this.mTextElement;
if(!n)
return;
DTrim.superclass.UpdateFont.call(this,val);
}
DTrim.prototype.GetFocusElement=function() {
if (!("mFocusElement" in  this)) {
var elems = this.mObj.getElementsByTagName("TABLE");
if (elems != null) {
this.mFocusElement = elems[0];
} else {
this.mFocusElement = null;
}
}
return this.mFocusElement;
}
DTrim.prototype.ReplaceText=function(text) {
var start = end = 0;
var result = new Array();
var part = new Array();
var urlRegEx = /[a-zA-Z]+:[\/]*(.*)/mg;
var re = new RegExp('<a\s*>?\s*<?\s*h\s*r\s*e\s*f\s*=\s*"([^"]*)"([^>]*)>([^<]*)<\/a>', "mig");
var param = text.match(re);
if (param != null) {
for (var i = 0; i < param.length; i++) {
end  = text.indexOf(param[i], start); 
result.push(text.substring(start, end));
result.push(param[i].replace(re, function (sub, url, options, urlText) {
part.push("<a class=TrimLink href=\"");
if (url) {
if (!(url.match(urlRegEx))) {
url = "http://" + url; 
}
part.push(MassageText(url));
}
part.push("\"");
if (options == null || options.toLowerCase().indexOf("target") == -1) {
options += " target=\"_blank\"";
}
part.push(options);
part.push(">");
if (urlText) {
part.push(MassageText(urlText));
}
part.push("</a>");
return part.join("");
}));
start = end + param[i].length; 
}
}
result.push(MassageText(text.substring(start)));
return result.join("");
}
function MassageText(text) {
var prevEnd = 0;
text = text.replace(/(<BR>)|(&nbsp)|(<)|(>)|(\")(\\n)|(\\s)/gim, function (sub, p0, p1, p2, p3, p4, p5, p6) {
if (p0) return p0;
if (p1) return p1;
if (p2) return "&lt;";
if (p3) return "&gt;";
if (p4) return "&quot;";
if (p5) return "<br>";
if (p6) return "&nbsp;";
});
return text;
}
DTrim.prototype.mHaveStoredData=false;

DView.prototype=new Field(); DView.prototype.constructor=DView; DView.superclass=Field.prototype;;
DOMFieldFactories["View"]=function(id,n) {
return new DView(id,n);
}
function DView(id,n) {
if(arguments.length)
this.init(id,n);
}
DView.prototype.val=Null;
DView.prototype.mDOMField=DView.prototype.mHaveVisualCharacteristics=true;
DView.GlobalFuncRE = /DVF/g;
DView.prototype.init=function(id, n) {
DView.superclass.init.call(this,id,n);
;
this.mFrameHTML = this.mObj.innerHTML.replace(DView.GlobalFuncRE, "F(" + id + ").");
this.mFrameName = this.mObj.firstChild.name;
this.mUpdateTimeout=null;
}
DView.prototype.GetInnerDocument=function() {
var obj=this.mObj.firstChild;
try {
return("contentDocument" in obj)?obj.contentDocument:window.frames[this.mFrameName].document;
} catch(e) { 
return null;
}
}
DView.prototype.mHaveStoredData=false;
DView.URLPAT=new RegExp('^((https?)|(ftps?)|(file)):[\\\\/][\\\\/].*',"i");
DView.prototype.Clear=function(){
var i=this.mID;
if((i>=1000000&&i<=1999999)||
(i>=3000000&&i<=3999999)||
i==1576||i==1575)
return;
return this.S(Null);
}
DView.prototype.DoSet=DView.prototype.DoSLoadEntry=function(val) {
;
if (val.isNull) {
this.val = Null;
} else if (val instanceof CharType) {
this.val = val;
} else if (val instanceof AttachmentType) {
this.val = new CharType(encodeURI(val.toURL()));
} else {
this.val = new CharType(val);
}
if (!this.mModified) {
this.mModified=true;
CurWFC.AddCallback(this, this.setContents,[]);
}
}
DView.prototype.setContents=function() {
var val = this.val.toString();
;
this.mModified=false;
if(this.mUpdateTimeout!=null) {
window.clearTimeout(this.mUpdateTimeout);
this.mUpdateTimeout=null;
}
if (val.match(DView.URLPAT)) {
this.mObj.innerHTML=this.mFrameHTML;
try {
this.mObj.firstChild.src=val;
} catch (err) {
}
} else { 
this.mObj.innerHTML=this.mFrameHTML; 
var timeoutobj=this;
this.mUpdateTimeout=window.setTimeout(function() {
timeoutobj.mUpdateTimeout=null;
var ifrframe=timeoutobj.GetInnerDocument();
if(ifrframe!=null) {
ifrframe.open();
ifrframe.write(val);
ifrframe.close();
}
},50);
}
}
DView.prototype.TabableElementSelector=function(ele) {
if (ele.tagName=="IFRAME") {
return ele;
}
return null;
}
DView.prototype.DOMKeyPress=function(evt) {
;
if (evt.key==13) {
var fr = this.GetInnerDocument();
if(fr!=null&&"focus" in fr) {
setTimeout(function() { fr.focus(); }, 0 );
}
return;
}
}
DView.prototype.ol=function() {
var fr=this.GetInnerDocument();
try {
if (fr&&fr.body&&!(fr.body.style.backgroundColor)) {
var bgcol=(fr.body.currentStyle["backgroundColor"]);
if(bgcol=="#ffffff"||bgcol=="transparent")
fr.body.style.backgroundColor="transparent";
}
} catch (exc) {
}
}
DView.prototype.G=function() {
return this.val;
}
DView.prototype.GetFocusElement=function() {
return this.mObj.firstChild;
}
DView.SendSignalToParent=function(srcID, eventType, eventData) {
ARProcessEvent.Add(eventType+"", eventData+"", srcID+"");
}
DView.prototype.HandleEvent=function(etype, edata) {
var fr = window.frames[this.mFrameName];
if (fr != null && "EventDispatcher" in fr && typeof fr.EventDispatcher.dispatch == "function") {
fr.EventDispatcher.dispatch(etype,edata);
}
}
DView.tabForward=function() {
arJumpOutForward();
}
DView.tabBackward=function() {
arJumpOutBackward();
}

SelectionMenu.prototype=new Menu(); SelectionMenu.prototype.constructor=SelectionMenu; SelectionMenu.superclass=Menu.prototype;;
function SelectionMenu(field, menu_data) {
if (arguments.length)
this.init(field, menu_data);
}
SelectionMenu.prototype.init = function(field, menu_data) {
SelectionMenu.superclass.init.call(this, menu_data);
this.mField=field; 
}
SelectionMenu.prototype.Open = function(adjacent_element) {
;
SelectionMenu.superclass.Open.call(this, adjacent_element, 3, 30100, false);
}
SelectionMenu.prototype.HandleSelection = function(val) { 
;
this.mField.HandleMenuSelection(val);
new WorkflowContext({f:ExecuteWorkflow,a:[2, this.mField.mID]});
}
DEnumSel.prototype=new DataField(); DEnumSel.prototype.constructor=DEnumSel; DEnumSel.superclass=DataField.prototype;;
DOMFieldFactories["EnumSel"]=function(id,n) {
return new DEnumSel(id,n);
}
function DEnumSel(id,n) {
if (arguments.length)
this.init(id,n);
}
DEnumSel.prototype.init = function(id,n) {
var np = n.childNodes[1];
;
this.mInputNode = np.firstChild;
;
var menuStruct = np.getAttribute("ARSelMenu");
var inMenudef = eval(menuStruct);
var menudef = [];
var iOrder = []; 
var mIndex = 0;
for (var i = 0; i < inMenudef.length; ++i) {
if (!("ci" in inMenudef[i]))
mIndex = i;
else
mIndex = inMenudef[i].ci;
menudef[mIndex] = {};
menudef[mIndex].ord = i;
;
menudef[mIndex].v = inMenudef[i].v;
if (!("l" in inMenudef[i]))
menudef[mIndex].l = inMenudef[i].v; 
else
menudef[mIndex].l = inMenudef[i].l;
iOrder[i] = mIndex;
}
this.mMenuDef = menudef; 
this.mOrder = iOrder;
DEnumSel.superclass.init.call(this,id,n);
}
DEnumSel.prototype.GetFocusElement=function() {
return this.mInputNode;
}
DEnumSel.prototype.ConvertPrimitiveToDataType = function(str) {
;
var menudef = this.mMenuDef;
if (str != "") {
str = str.HTMLEncode();
for (var i in menudef) {
if (menudef[i].l == str) {
return new EnumType(i, ExpandString(menudef[i].l, 2 | 4));
}
}
if (!isNaN(str))
{
var menuItem = menudef[str];
if ( menuItem != null) {
return new EnumType(str, ExpandString(menuItem.l, 2 | 4));
}
}
}
return Null;
}
DEnumSel.prototype.ConvertDTForSLE=function(val) {
;
;
;
var menudef = this.mMenuDef;
if (val.type==6) {
var lValue = val.toInteger();
var menuItem = menudef[lValue];
if (menuItem != null)
return new EnumType(lValue, ExpandString(menuItem.l.HTMLDecode(), 2|4));
}
return Null;
}
DEnumSel.prototype.ConvertDTForS=function(val) {
;
;
var menudef = this.mMenuDef;
if (val.type!=6 || typeof val.mLabel!="undefined") {
var v = val.toString().HTMLEncode();
for (var i in menudef) {
if (menudef[i].l == v) {
return new EnumType(i, ExpandString(menudef[i].l, 2|4));
}
}
}
if(val.type==6 || v.isDigits()) {
if (val.type == 4 || val.type == 5) {
if (!v.isNumeric()) 
return Null;
}
var lValue = val.toInteger();
var menuItem = menudef[lValue];
if (menuItem != null)
return new EnumType(lValue, ExpandString(menuItem.l.HTMLDecode(), 2|4));
else
return Null;
} else
return Null;
}
DEnumSel.prototype.DOMClick = function(evt) {
;
if (this.GAccess() != 2)
return;
if (!this.mMenu) {
;
var menudef = this.mMenuDef;
var order = this.mOrder;
var uimenudef = [];
for (var i = 0; i < order.length; i++) {
;
uimenudef.push({v:menudef[order[i]].l,l:menudef[order[i]].l});
}
var CLEARVAL = getLocalizedMessage("(clear)");
uimenudef.push({l:CLEARVAL, v:""});
this.mMenu = new SelectionMenu(this, uimenudef);
}
this.mMenu.Open(this.mObj.childNodes[1]);
}
DEnumSel.prototype.GetFirst = function() {
var mOrder = this.mOrder;
return mOrder[0];
}
DEnumSel.prototype.GetLast = function() {
var order = this.mOrder;
return order[order.length-1];
}
DEnumSel.prototype.GetNext = function(val) {
var order = this.mOrder;
var menuDef = this.mMenuDef;
var index = menuDef[val].ord;
if (index != null) {
index++;
if (index >= order.length)
return -1;
else
return order[index];
}
return -1;
}
DEnumSel.prototype.GetPrev = function(val) {
var order = this.mOrder;
var menuDef = this.mMenuDef;
var index = menuDef[val].ord;
if (index != null) {
index--;
if (index < 0)
return -1;
else
return order[index];
}
return -1;
}
DEnumSel.prototype.DOMKeyDown = function(evt) {
;
if (this.GAccess() != 2)
return;
;
var key = evt.key;
if (key == 38 || key == 40 || key == 37 || key == 39) {
var val = this.G();
if (val.isNull)
val = (key == 38 || key == 37)? this.GetLast(): this.GetFirst();
else {
val = val.toInteger();
val = (key == 38 || key == 37)? this.GetPrev(val) : this.GetNext(val);
}
if (val == -1)
this.S(Null);
else
this.S(new EnumType(val, ExpandString(this.mMenuDef[val].l,2|4)));
evt.StopDefault(); 
return ExecuteWorkflow(2,this.mID);
}
}
DEnumSel.prototype.HandleMenuSelection = function(val) {
var ie = this.mInputNode;
ie.value = val;
this.FieldValChanged();
this.SetDirty(ie);
}
DEnumSel.prototype.UpdateAccess=function(val) {
DEnumSel.superclass.UpdateAccess.call(this,val);
this.mInputNode.readOnly=1;
}
DEnumSel.prototype.DOMFocus=function(ed) {
var node = this.mObj.childNodes[1];
var dat = node.className.indexOf("dat");
if (dat != -1) {
this.mDAT = 1;
node.className = node.className.replace(/(\s*dat)/g, "");
}
return DEnumSel.superclass.DOMFocus.call(this, ed);
}
DEnumSel.prototype.DOMBlur=function(ed) {
if (this.mDAT) {
delete this.mDAT;
this.mObj.childNodes[1].className += " dat";
}
return DEnumSel.superclass.DOMBlur.call(this, ed);
}
DEnumSel.prototype.mHaveStoredData=true;
DEnumSel.prototype.mDataType=6;
DEnum.prototype=new DataField(); DEnum.prototype.constructor=DEnum; DEnum.superclass=DataField.prototype;;
DOMFieldFactories["Enum"]=function(id,n) {
return new DEnum(id,n);
}
function DEnum(id,n) {
if(arguments.length)
this.init(id,n);
}
DEnum.prototype.init=function(id,n) {
this.mSelected = null;    
this.mSelectedIdx = null; 
this.mNumIndexes = 0;
this.mNumToAlias={};	
this.mAliasToNode={};
this.mLabelToNode={}; 
this.iterate(function(n, idx) {
var alias=n.nextSibling.firstChild.data;
alias = alias.replaceNBSP();
this.mNumToAlias[n.value]=alias;
this.mAliasToNode[alias]=n;
var lab=n.getAttribute("ARValue");
if (lab)
this.mLabelToNode[lab]=n;
this.mNumIndexes++;
if (n.checked) {
;
this.mSelected = n;
this.mSelectedIdx = n.value;  
}
}, n);
DEnum.superclass.init.call(this,id,n);
}
DEnum.prototype.clear = function() {
if (this.mSelected != null) { 
;
this.mSelected.checked = false; 
this.mSelected = null;
this.mSelectedIdx = null;
}
;
}
DEnum.prototype.iterate = function(callback, node) {
;
;
var n = node ? node : this.mObj.childNodes[1];
;
var idx = 0;
var start = n;
while (1) {
if (n.nodeType == 1 && n.tagName == "INPUT") {
idx = n.value;
var res = callback.call(this, n, idx);
if (typeof res != "undefined")
return res;
}
if (n.firstChild) {
n = n.firstChild;
} else {
while (!n.nextSibling) {
n = n.parentNode;
if (n == start)
return;
}
n = n.nextSibling;
}
}
}
DEnum.prototype.GetScreenValAsPrimitive=function() {
if (this.mSelectedIdx!=null)
return this.mSelectedIdx;
return "";
}
DEnum.prototype.GetScreenValue=function() {
if (this.mSelectedIdx==null)
return "";
return this.mNumToAlias[this.mSelectedIdx];
}
DEnum.prototype.ConvertPrimitiveToDataType = function(val) {
if (this.mSelectedIdx != null) {
;
return new EnumType(this.mSelectedIdx, ExpandString(this.mNumToAlias[this.mSelectedIdx], 2|4));
}
return Null;
}
DEnum.prototype.ConvertDTForSLE=function(val) {
;
var v=val.toInteger();
if (v in this.mNumToAlias)
return new EnumType(v,ExpandString(this.mNumToAlias[v],2|4));
else
return Null;
}
DEnum.prototype.ConvertDTForS=function(val) {
;
if (val.type!=6 || typeof val.mLabel!="undefined") {
var v = val.toString();
var n=this.mAliasToNode[v]; 
if (n) { 
;
return new EnumType(n.value,ExpandString(this.mNumToAlias[n.value],2|4));
} 
}
if(val.type==6 || v.isDigits()) {
if (val.type == 4 || val.type == 5) {
if (!v.isNumeric()) 
return Null;
}
v = val.toInteger();
if (v in this.mNumToAlias) {
return new EnumType(v,ExpandString(this.mNumToAlias[v],2|4));
}
}
return Null;
}
DEnum.prototype.SToScreen=function(val, str) {

var curSel = this.mSelected;
this.clear(); 
if (val.isNull) {
this.SetDirty(curSel);
} else {
var alias=this.mNumToAlias[val.mValue];
;
var n=this.mAliasToNode[alias];
;
n.checked=true;
this.mSelected=n;
this.mSelectedIdx=n.value;
this.SetDirty(n);
}
}
DEnum.prototype.TabableElementSelector=function(ele) {
;
if (ele.tagName=="INPUT") {
if (this.mSelected==ele)
return ele;
var n = this.getFirst();
if (n && this.mSelected == null && n == ele)
return ele;
}
return null;
}
DEnum.prototype.GetFocusElementForEvent=function(formEvent) {
;
if (this.GetNestedFocusability()) {
var ele=formEvent.element;
if (ele.tagName=="LABEL") {
ele=ele.previousSibling; 
if (ele==null)
return null;
}
if (ele.tagName=="INPUT")
return ele;
else
return DEnum.superclass.GetFocusElementForEvent.call(this,formEvent);
}
return null;
}
DEnum.prototype.DOMClick = function(evt) {
;
if (this.GAccess() != 2)
return;
var ele=evt.element;
var last = this.mSelected;
this.mSelected = null;
this.mSelectedIdx = null;
if ((ele.tagName=="INPUT") && (last==ele))
last.checked=false; 
else {
for (var ii in this.mAliasToNode) {
var n = this.mAliasToNode[ii];
;
if (n.checked && this.mSelected == null) { 
this.mSelected=n;
this.mSelectedIdx=n.value;
} else {
n.checked=false; 
}
}
}
if (this.mSelected!=last) {
this.FieldValChanged();
this.SetDirty((this.mSelected!=null)?this.mSelected:last);
return ExecuteWorkflow(2, this.mID);
}
}
DEnum.prototype.GetFocusElement = function() {
if (this.mSelected) {
return this.mSelected;
} else {
return DEnum.superclass.GetFocusElement.call(this);
}
}
DEnum.prototype.getPrev = function(n) {
if (n.tagName !="INPUT")
return null;
var enumVal = n.value;
var prevIndex = null;
for (var i in this.mNumToAlias) {
if (i == enumVal) {
break;
}
else {
prevIndex = this.mNumToAlias[i];
}			
}
if (prevIndex == null)
return this.getLast();
else
return this.mAliasToNode[prevIndex];
}
DEnum.prototype.getNext = function(n) {
if (n.tagName !="INPUT")
return null;
var enumVal = n.value;
var nextIndex = null;
var getNextIndex = false;
for (var i in this.mNumToAlias) {
if (i == enumVal) {
getNextIndex = true;
}
else if (getNextIndex == true) {
nextIndex = this.mNumToAlias[i];
break;
}			
}
if (nextIndex != null)
return this.mAliasToNode[nextIndex];
else	
return this.getFirst();
}
DEnum.prototype.getFirst = function() {
for (var i in this.mAliasToNode) {
return this.mAliasToNode[i];
}
return null;
}
DEnum.prototype.getLast = function() {
var last = null;
for (var i in this.mAliasToNode) {
last = this.mAliasToNode[i];
}
return last;
}
DEnum.prototype.DOMKeyDown = function(evt) {
;
if(this.GAccess() != 2)
return;
var key = evt.key;
if (key == 37 || key == 39) {
var val = this.G();
var newVal = null;
if (val.isNull) {
newVal = this.getFirst();
;
}
else {
if (key == 37)
newVal = this.getPrev(this.mAliasToNode[this.mNumToAlias[val.mValue]]);
else
newVal = this.getNext(this.mAliasToNode[this.mNumToAlias[val.mValue]]);
;
}
newVal = newVal.value;
this.S(new EnumType(newVal));
evt.StopDefault(); 
return ExecuteWorkflow(2,this.mID);
}
}
DEnum.prototype.MouseSelectable=false;
DEnum.prototype.mDataType=6;
DEnum.prototype.mNeedSpecialSetToScreen=true;
JEnum.prototype=new Field(); JEnum.prototype.constructor=JEnum; JEnum.superclass=Field.prototype;;
JFieldFactories["Enum"]=function(id,n) {
return new JEnum(id,n);
}
function JEnum(id,n) {
if(arguments.length)
this.init(id,n);
}
JEnum.prototype.G=function() {
;
var val = this.mObj.v;
if (val.isNull)
return val;
else {
var v = val.toString();
for (var i in this.mObj.e) {
if (this.mObj.e[i] == v) {
this.mObj.v = new EnumType(i, v);
return this.mObj.v;
}
}
if(val.type==6 || v.isDigits()) {
if (val.type == 4 || val.type == 5) {
if (!v.isNumeric()) 
return Null;
}
v = val.toInteger();
for (var i in this.mObj.e) {
if (i == v) {
this.mObj.v = new EnumType(v, this.mObj.e[v]);
return this.mObj.v;
}
}
}
this.mObj.v = Null;
return Null;
}
}
JEnum.prototype.ConvertDTForS=function(val) {
;
var v = val.toString();
if (val.type!=6 || typeof val.mLabel!="undefined") {
for (var i in this.mObj.e) {
if (this.mObj.e[i] == v) {
return new EnumType(i, v);
}
}
}
if(val.type==6 || v.isDigits()) {
if (val.type == 4 || val.type == 5) {
if (!v.isNumeric()) 
return Null;
}
v = val.toInteger();
for (var i in this.mObj.e) {
if (i == v) {
return new EnumType(v, this.mObj.e[v]);
}
}
}
return Null;
}
JEnum.prototype.DoSet=JEnum.prototype.DoSLoadEntry=function(val) {
;
if(val.isNull)
this.mObj.v = Null;
else if (ARKWIsKeywordString(val))
this.mObj.v = new CharType(val.toString());
else {
this.mObj.v = this.ConvertDTForS(val);            
}
this.SetDirty();
}
DEnum.prototype.mHaveStoredData=JEnum.prototype.mHaveStoredData=true;
JEnum.prototype.GetEnumValues = function () {
;
return this.mObj.e;
}
JEnum.prototype.GetSorter = function() {   
return "(ls=parseInt(lhs),rs=parseInt(rhs),(isNaN(ls)?0:ls)-(isNaN(rs)?0:rs))";   
}

DPageHolder.prototype=new AsyncField(); DPageHolder.prototype.constructor=DPageHolder; DPageHolder.superclass=AsyncField.prototype;;
DOMFieldFactories["PageHolder"]=function(id,n) {
return new DPageHolder(id,n);
}
function DPageHolder(id,n) {
if(arguments.length)
this.init(id,n);
}
DPageHolder.prototype.mDOMField=DPageHolder.prototype.mHaveVisualCharacteristics=true;
DPageHolder.prototype.init=function(id,n) {
DPageHolder.superclass.init.call(this,id,n);
var c=this.mObj;
this.mTabs=[];
this.mChildren=[];
this.mMissingBorderObj=null;
this.mTabH=parseInt(c.getAttribute("ARMaxH"));
var bh=parseInt(this.mObj.style.height)-this.mTabH;
;
for(var n=c.firstChild;n;n=n.nextSibling) {
if(n.nodeType==1) {
if(n.className=="TabChildMissingBorder")
this.mMissingBorderObj=n;
else if(n.className.indexOf("TabChild")==0) {
this.mChildren.push(n);
n.style.top=this.mTabH;
n.style.height=bh;
} else if(n.className.indexOf("OuterOuterTab")==0){
for(var p=n.firstChild;p;p=p.nextSibling)
if(p.nodeType==1 && p.className=="OuterTab") 
this.mTabs.push(p);
} 
else if (n.className.indexOf("OuterOuterTab")!=0){ 
n.style.zIndex=parseInt(n.style.zIndex)+5000; 
n.style.top=parseInt(n.style.top)+this.mTabH+1; 
n.style.left=parseInt(n.style.left)+1; 
}
}
}
;
this.mItems=this.mTabs.length;
this.mSelectedTab=-1;
}
DPageHolder.prototype.SelectTab=function(tab) {
if(tab!=this.mSelectedTab) {
this.mSelectedTab=tab;
this.mAsyncDirty=(1>this.mAsyncDirty?1:this.mAsyncDirty);
}
}
DPageHolder.prototype.FlushAsyncQueue=function() {
if(!this.mAsyncDirty)
return;
this.DoLayout();

}
DPageHolder.prototype.DoLayout=function() {
var cw=0,firstsel=-1,needrefocus=false;
for(var i=0;i<this.mItems;++i) {
var tabn=this.mTabs[i],boxn=this.mChildren[i];
if(tabn.className.indexOf("OuterTabSelected")!=-1) {
tabn.style.width="";
tabn.className=tabn.className.replace(/OuterTabSelected/,"OuterTab");
boxn.style.visibility="hidden";
AsyncField_IncrAsyncRef(boxn.getAttribute("ARID"),1);
}
nw=tabn.offsetWidth;
if(this.mTabH==0)
tabn.style.visibility="hidden";
else
tabn.style.top=1;
tabn.style.zIndex=1;
tabn.style.left=cw;
;
; 
if(boxn.getAttribute("ARVisibility")=="hidden") {
tabn.style.visibility="hidden";
tabn.style.display="none";
if(this.mSelectedTab==i)
needrefocus=true;
boxn.style.left=i*2000; 
} else {
boxn.style.left=0;
cw+=nw;
if(this.mTabH!=0)
{
tabn.style.visibility="inherit";
tabn.style.display="block";
}
if(firstsel==-1) 
firstsel=i;
}
}
if(needrefocus||this.mSelectedTab==-1)
this.mSelectedTab=firstsel;
if(this.mSelectedTab==-1) {
if(this.mMissingBorderObj!=null) this.mMissingBorderObj.style.visibility="hidden";
return;
} else {
if(this.mMissingBorderObj!=null) this.mMissingBorderObj.style.visibility="inherit";
}
var tabn=this.mTabs[this.mSelectedTab],boxn=this.mChildren[this.mSelectedTab];
tabn.style.top=(this.mTabH==0?-1000:1); 
tabn.style.zIndex=3;
; 
boxn.style.visibility="inherit";
tabn.className=tabn.className.replace(/OuterTab/,"OuterTabSelected");
AsyncField_IncrAsyncRef(boxn.getAttribute("ARID"),-1);
}
DPageHolder.prototype.UpdateVis=function(val) {

var curvis=(this.mObj.style.visibility!="hidden");
if(!curvis&&val) { 
this.SetAsync(-1);
this.mObj.style.visibility="inherit";
} else if(curvis&&!val) { 
this.SetAsync(1);
this.mObj.style.visibility="hidden";
}

}
DPageHolder.prototype.G=function() {
if(this.mSelectedTab==-1) {
for (var ii=0;ii<this.mChildren.length;ii++) {
if (this.mChildren[ii].getAttribute("ARVisibility")!="hidden") {
return new CharType(this.mChildren[ii].getAttribute("ARDBN"));
}
}
return Null;
}
if (typeof this.mSelectedTab != "undefined")
return new CharType(this.mChildren[this.mSelectedTab].getAttribute("ARDBN"));
return Null;
}
DPageHolder.prototype.DoSet=DPageHolder.prototype.DoSLoadEntry=function(val) {
;
val=val.toString();
for(var i=0;i<this.mItems;++i) {
var boxn = this.mChildren[i];
if(boxn.getAttribute("ARDBN")==val
&& boxn.getAttribute("ARVisibility")!="hidden") {
this.SelectTab(i);
return;
}
}
}
DPageHolder.prototype.TabableElementSelector=function(ele) {
;
if (ele.tagName=="A") {
var curTab = ele.parentNode.parentNode;
;
if (this.mTabs[this.mSelectedTab == -1 ? 0 : this.mSelectedTab] == curTab)
return ele;
}
return null;
}
DPageHolder.prototype.GetTabForID=function(fieldID) {
;
var fidStr = fieldID+"";
for(var i=0;i<this.mItems;++i)
if(this.mTabs[i].getAttribute("ARTabID")==fidStr)
return this.mTabs[i];
;
return null;
}
DPageHolder.prototype.GetTabIndexForID=function(fieldID) {
;
var fidStr = fieldID+"";
for(var i=0;i<this.mItems;++i)
if(this.mTabs[i].getAttribute("ARTabID")==fidStr)
return i;
;
return null;
}
DPageHolder.prototype.GetFocusElementForEvent=function(ed) {
if (this.GetNestedFocusability()) {
var ele = ed.element;
for(var i=0;i<this.mItems;++i)
{	
if(this.mTabs[i]==ele|| this.mTabs[i].childNodes[2]==ele || this.mTabs[i].childNodes[2].childNodes[0]==ele)
return this.mTabs[i].childNodes[2].childNodes[0];
}
}
return null;
}
DPageHolder.prototype.DOMKeyDown=function(ed) {
;
var newTabId = -1;
if (ed.key==39) {
for (var ii=this.mSelectedTab+1;ii<this.mTabs.length;ii++) {
if (this.mChildren[ii].getAttribute("ARVisibility")!="hidden") {
newTabId = this.mTabs[ii].getAttribute("ARTabID");
break; 
}
}
} else if (ed.key==37) {
var ii=(this.mSelectedTab>0)?this.mSelectedTab-1:((this.mTabs.length>0)?0:-1);
for (;ii>=0;ii--) {
if (this.mChildren[ii].getAttribute("ARVisibility")!="hidden") {
newTabId = this.mTabs[ii].getAttribute("ARTabID"); 
break;
}
}
}
if (newTabId > 0) {
;
newTabId = parseInt(newTabId);
return {c:{t:FocusMgr, f:FocusMgr.SetFocusToField, a:[newTabId]}};
}
}
DPageHolder.prototype.DOMFocus=function(ed) {
;
var ele=ed.element;
if(ele.tagName=="A")
ele=ele.parentNode.parentNode;
return {c:{f:ExecuteWorkflow, a:[8192, this.mID]},
n:{t:this, f:this.domFocusP2, a:[ele]}};
}
DPageHolder.prototype.domFocusP2=function(ele) {
var prevID = (this.mSelectedTab != -1) ? parseInt(this.mChildren[this.mSelectedTab].getAttribute("ARID")) : -1;
;
var nextID = (ele.className.indexOf("TabChild")==0) ? parseInt(ele.getAttribute("ARID"))
: ele.className.indexOf("Tab")==0? parseInt(ele.parentNode.getAttribute("ARTabID")): parseInt(ele.getAttribute("ARTabID"));
if ((prevID != nextID) && (prevID!= -1) && (prevID == FocusMgr.mCurFocusID) ) {
return {c:{f:ExecuteWorkflow,a:[256, prevID]},
n:{t:this, f:this.domFocusP3, a:[nextID], e:this.focusExceptionHandler, ea:[this.mSelectedTab]}};
} else {
return {n:{t:this, f:this.domFocusP3, a:[nextID], e:this.focusExceptionHandler, ea:[this.mSelectedTab]}};
}
}
DPageHolder.prototype.focusExceptionHandler=function(exception, prevTab) {
;
this.SelectTab(prevTab); 
throw exception;
}
DPageHolder.prototype.domFocusP3=function(nextID) {
;
var nextIDStr = nextID+"";
for(var i=0;i<this.mItems;++i) {
if(this.mTabs[i].getAttribute("ARTabID") == nextIDStr) {
var prevTab = this.mSelectedTab;
this.SelectTab(i);
return {c:{f:ExecuteWorkflow, a:[256, this.mID]},
n:{t:this, f:this.domFocusP4, a:[nextID], e:this.focusExceptionHandler, ea:[prevTab]}};
}
}
;
}
DPageHolder.prototype.domFocusP4=function(nextID) {
return {c:{f:ExecuteWorkflow, a:[8192, nextID]}};
}
DPageHolder.prototype.DOMBlur=function(ele) {
}
DPageHolder.prototype.GetFocusElement=function(){
return this.mSelectedTab != -1 ? this.mTabs[this.mSelectedTab].childNodes[2].childNodes[0]
: this.mTabs.length > 0 ? this.mTabs[0].childNodes[2].childNodes[0] : null;
}
DPageHolder.prototype.getFocusElementForTab=function(fieldID){
;
var te = this.GetTabForID(fieldID);
if (te != null) {
return te.childNodes[2].childNodes[0];
}
return null;
}
DPageHolder.prototype.Clear=function() { }
DPageHolder.prototype.mHaveStoredData=false;
DPageHolder.prototype.MouseSelectable=false;
DPageHolder.prototype.mContainFields=true;

DPage.prototype=new Field(); DPage.prototype.constructor=DPage; DPage.superclass=Field.prototype;;
DOMFieldFactories["Page"]=function(id,n) {
return new DPage(id,n);
}
function DPage(id,n) {
if(arguments.length)
this.init(id,n);
}
DPage.prototype.mDOMField=DPage.prototype.mHaveVisualCharacteristics=true;
DPage.prototype.init=function(id,n) {
this.mParentObj=F(parseInt(n.parentNode.getAttribute("ARID")));
DPage.superclass.init.call(this,id,n);
this.mTextElement=this.mParentObj.GetTabForID(this.mID).childNodes[2].childNodes[0];
}
DPage.prototype.SelectPageDueToFocusInChildField=function() {
;
var tabIdx=this.mParentObj.GetTabIndexForID(this.mID)
this.mParentObj.SelectTab(tabIdx);
}
DPage.prototype.UpdateFont=function(val) {
DPage.superclass.UpdateFont.call(this,val);
if(this.mParentObj)this.mParentObj.mAsyncDirty=(1>this.mParentObj.mAsyncDirty?1:this.mParentObj.mAsyncDirty);
}
DPage.prototype.UpdateLabel=function(val) {
DPage.superclass.UpdateLabel.call(this,val);
if(this.mParentObj)this.mParentObj.mAsyncDirty=(1>this.mParentObj.mAsyncDirty?1:this.mParentObj.mAsyncDirty);
}
DPage.prototype.UpdateVis=function(val) {
this.mObj.setAttribute("ARVisibility",val?"visible":"hidden");
if(this.mParentObj)this.mParentObj.mAsyncDirty=(1>this.mParentObj.mAsyncDirty?1:this.mParentObj.mAsyncDirty);
}
DPage.prototype.GetFocusElementForEvent = function(ed) {
return this.mParentObj.GetFocusElementForEvent(ed);
}
DPage.prototype.TabableElementSelector=function(ele) {
return null; 
}
DPage.prototype.DOMFocus=function(ed) {
;
return {c:{t:this.mParentObj, f:this.mParentObj.DOMFocus, a:[ed]}};    
}
DPage.prototype.Clear=function(){};
DPage.prototype.GetFocusElement=function() {
return this.mParentObj.getFocusElementForTab(this.mID);
}
DPage.prototype.mHaveStoredData=false;
DPage.prototype.mContainFields=true;

JStatusHistory.prototype=new JChar(); JStatusHistory.prototype.constructor=JStatusHistory; JStatusHistory.superclass=JChar.prototype;;
function JStatusHistory(id,n) {
if(arguments.length)
this.init(id,n);
}
JStatusHistory.prototype.G=function() {
var res = JStatusHistory.superclass.G.call(this);
if (res.isNull)
return Null;
return new StatusHistoryType(res);
}
JStatusHistory.prototype.mIsComplexField=true;

function arInvokeGuide(server, guideName) {
if (typeof server != "string" || typeof guideName != "string") {
return;
}
if (CurWFC)
return CurWFC.execute({f:ARACTCallGuide,a:[server,guideName,true]});
else
new WorkflowContext({f:ARACTCallGuide,a:[server,guideName,true]});
}
function ARACTCallGuide(server, guidename, hidden, tableid, selectedonly) {
;
;
;
;
;
LogWrite("ARACTCallGuide(" + server + ", " + guidename + ", " +  hidden + ", " + tableid + ", " + selectedonly + ")");
server = ExpandServerName(server);
guidename = ExpandGuideName(guidename);
var jsguidename = "AREVTGuide" + guidename.ARToJSIdentifier();
if (jsguidename in window) {
var gs = CurWFC.getGuideState();
;
if (gs && gs.g == guidename)
return;
var guidecontext = { g:guidename };
var imode = {c:{}, n:{f:ARACTCallGuideCont, e:ARACTCallGuideException}};
if (tableid) {
;
var table = F(tableid);
if (table instanceof DTable) {
guidecontext.table = table;
guidecontext.row = 0;
guidecontext.oldrow = table.GetRow();
guidecontext.selected = selectedonly ? table.GetSelectedRows() : null;
guidecontext.func = window[jsguidename];
imode.c.f = ARACTRunLoopGuide;
} else
return;
} else
imode.c.f = window[jsguidename];
CurWFC.enterGuide(guidecontext);
return imode;
} else {
var req = new NDXGetGuideServerAndForm(server, guidename);
var guide = req.GetResult();
if (guide.server == ARKWGetStringByIdx(7) && guide.form == ARKWGetStringByIdx(6)) {
var msg = getLocalizedMessage(9372,[guidename]);
throw new WorkflowException(0, [{t : 2, n: 9372, m:msg, a:null}]);
}
return OpenNonModalForm(false,guide.server,guide.form,guide.view,
{wMode : 2, runGuide : {server : server, guidename : guidename, hidden : hidden, tableid : tableid, selectedonly : selectedonly}});
}
}
function ARACTCallGuideException(exception) {
if (typeof exception != "object" || !(exception instanceof WorkflowException))
throw exception;
;
;
ARACTCallGuideCont();
switch (exception.mCode) {
case 3:
return;
case 4:
if (CurWFC.getGuideState() == null) {
return;
}
default:
throw exception;
}
}
function ARACTCallGuideCont() {
;
var gs = CurWFC.getGuideState();
if (gs.table) {
if (gs.oldrow >= gs.table.GetData().length)
gs.oldrow = -1;
gs.table.SetRow(gs.oldrow);
}
CurWFC.exitGuide();
}
function ARACTRunLoopGuide() {
var gs = CurWFC.getGuideState();
; 
;
if (gs.selected != null) {
;
while (gs.selected[gs.row] < gs.table.GetRows()) {
LogWrite("LoopGuide: selrow " + gs.selected[gs.row] + "/" + gs.selected.length + "/" + gs.table.GetRows());
gs.currow = gs.selected[gs.row];
gs.table.SetRow(gs.currow);
++gs.row;
var res = CurWFC.execute({f:gs.func});
if (res) {
LogWrite("ARACTRunLoopGuide: imode interrupt signalled");
return {i:1, n:{f:ARACTRunLoopGuide}};
}
}
} else {
while (gs.row < gs.table.GetRows()) {
LogWrite("LoopGuide: row " + gs.row + "/" + gs.table.GetRows());
gs.currow = gs.row;
gs.table.SetRow(gs.currow);
++gs.row;
var res = CurWFC.execute({f:gs.func});
if (res) {
LogWrite("ARACTRunLoopGuide: imode interrupt signalled");
return {i:1, n:{f:ARACTRunLoopGuide}};
}
}
}
}

function ARACTSetVisibility(fieldid, visibility)
{
;
;
if (fieldid==1020 && Form.UseResultsListPane)
return;
LogWrite("ARACTSetVisibility(" + fieldid + ", " + visibility + ")");
F(fieldid).SVis(visibility ? true : false);
}
function ARACTSetAccess(fieldid, access)
{
;
;
;
LogWrite("ARACTSetAccess(" + fieldid + ", " + access + ")");
F(fieldid).SAccess(access);
}
function ARACTSetLabelColour(fieldid, colour)
{
;
;
LogWrite("ARACTSetLabelColour(" + fieldid + ", " + colour + ")");
F(fieldid).SColour(colour);
}
function ARACTSetLabel(fieldid, labelname)
{
;
;
LogWrite("ARACTSetLabel(" + fieldid + ", \"" + labelname + "\")");
labelname = ExpandString(labelname, 1);
F(fieldid).SLabel(labelname);
}
function ARACTSetFont(fieldid,font)
{
;
;
LogWrite("ARACTSetFont(" + fieldid + ", \"" + font + "\")");
F(fieldid).SFont(font);
}
function ARACTSetMenu(fieldid, menuname)
{
;
;
LogWrite("ARACTSetMenu(" + fieldid + ", \"" + menuname + "\")");
F(fieldid).SMenu(menuname);
}
function ARACTTableRefresh(fieldid)
{
;
;
LogWrite("ARACTTableRefresh(" + fieldid + ")");
var table = F(fieldid);
if (table instanceof DTable)
return table.Refresh(-1,0,false);
}
function ARACTExpandCollapseTreeLevels(fieldid, flag)
{
;
;
LogWrite("ARActExpandCollapseTreeLevels(" + fieldid + ", " + flag + ")");
var field = F(fieldid);
if (field instanceof DTreeView) {
if (flag == 1)
field.ExpandAll();
else if (flag == 2)
field.CollapseAll();
}
}
function ARACTSetFocus(fieldid)
{
;
;
LogWrite("ARACTSetFocus(" + fieldid + ")");
return {n:{t:FocusMgr, f:FocusMgr.SetFocusToField, a:[fieldid]} };
}
function ARACTIndirectChangeField(func, fieldid) 
{
;
;
var field=F(fieldid).G().toString();
field = field.trim(1 | 2);
if (field.isNumeric()) {
fieldid = parseInt(field);
var args = new Array(arguments.length - 1);
args[0] = fieldid;
for (var i = 1; i < arguments.length - 1; ++i)
args[i] = arguments[i + 1];
return func.apply(null, args); 
}
}

function ARACTCloseWindow(closeall)
{
;
LogWrite("ARACTCloseWindow(" + closeall + ")");
return {c:{f:weDisplayWFNotes,a:[window]}, n:{f:ARACTCloseWindowP2,a:[closeall]}};
}
function ARACTCloseWindowP2(closeall)
{
var abort = {};
return {c:{t:StateMgr,f:StateMgr.WindowIsClosing, a:[abort]},n:{f:function(closeall,abortclose) {
if (!abortclose.ab)
{
StateMgr.mWindowIsClosed = true;
if (closeall == 0)
{
if (weAmDialogue(window.name))
{
weCloseDialogue(window.weDialogueReturnValue);
}
else
{
weCloseWindow(window, true);
}
}
else
{
var theOpener = window;
var pnt = theOpener; 
while (pnt) {
pnt = theOpener.weGetOpener();
if (pnt) {
if (!pnt.closed)
theOpener = pnt;
else
break; 
}
}
weCloseAllWindows(theOpener, true, null);
}
throw new WorkflowException(0, []); 
}
}, a:[closeall, abort]}};
}

function ARACTCommit()
{
LogWrite("ARACTCommit()");
if ((ARStateCurrent == 2)) {
try{ 
var testOpener = window.weGetOpener().name;
}
catch(e){ 
LogAndAlert("Cannot commit changes because opener window has been closed.")
return null;
} 
if (weArgs != null && "fvout" in weArgs) {
var dlgOut = new FieldList();
for (var item in Fields) {
var val = {t : Fields[item].G().type, v : Fields[item].G().toPrimitive()};
dlgOut.AddField(item, Datatype_Factory(val));
}
var myOpener = window.weGetOpener();
for (var item in weArgs.fvout) {
if (typeof(weArgs.fvout[item]) != "function") {
LogWrite("Committing field " + item + " back to parent with value " + weArgs["fvout"][item]);
var value = eval(weArgs["fvout"][item]);
myOpener.SetFieldFromDialog(item, {t : value.type, v : value.toPrimitive()});
}
}
}
} else {
return FormAction_GenericApply();
}   
}

function ARACTExitGuide(closeall)
{
;
LogWrite("ARACTExitGuide(" + closeall + ")");
if (ARKWGetStringByIdx(20) == null)
return;
if (closeall)
throw new WorkflowException(4);
else
throw new WorkflowException(3);
}

function ARACTGoto(level) {
;
LogWrite("ARACTGoto(" + level + ")");
if (level < 0)
level = 0; 
else if (level > 1000)
level = 1000 + 1;
throw new WorkflowException(1, level);
}

function ARACTGotoGuideLabel(label) {
;
LogWrite("ARACTGotoGuideLabel(" + label + ")");
ARGotoGuideLabel(label);
}

function ARACTMessage(type, num, msg)
{
;
;
;
LogWrite("Message [" + num + "] " + msg);
msg = ExpandString(msg, 1 | 2 | 4 | 8);
var thestatus = [ { t:type, n:num, m:msg, a:null } ]; 
if (type == 2 || type == 3) {
CurWFC.status(thestatus);
} else {
var ret={n:{f:ARACTMessageP2,a:[thestatus]}};
if (CurWFC.notes.length >0) {
ret.c={f:MessagePopup,a:[CurWFC.notes]};
}
return ret;
}
}
function ARACTMessageP2(thestatus) {
CurWFC.notes = [];
window.focus();
return MessagePopup(thestatus);	
}
function ARACTPrompt(type, num, msg)
{
;
;
;
msg = ExpandString(msg, 1 | 2 | 4 | 8);
window.status = getLocalizedMessage(msg, null);
if (type == 2 || type == 3) {
CurWFC.status(0);
}
}

function continueModal(obj) {
CurWFC.resume()    
}
function ARACTOpenDialog(server,schema,viewname,closebox,inmap,outmap,epGuideServer,epGuideName) {
;
;
;
;
;
;
;
;
LogWrite("ARACTOpenDialog(" + server + ", " + schema + ", " + viewname + ", " + closebox + ", " + inmap + "," + epGuideServer + "," + epGuideName + ")");
server = ExpandServerName(server);
schema = ExpandGuideName(schema);
viewname = ExpandString(viewname, 1|2|4);
var res=new NDXGetURLForForm(server, ((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""), schema, viewname,true,"","").GetResult();
var dims;
if(res.dims==null)
dims=null;
else {
;
dims=res.dims.split(",");
;
dims[0]=parseInt(dims[0]);
dims[1]=parseInt(dims[1]);
}
LogWrite("Opening dialog: " + res.url);
for (var i in inmap) {
LogWrite("Field " + i + " input value " + inmap[i]);
}
var oargs = {cb : closebox, fvlist : inmap, fvout : outmap} ;
if (epGuideName) {
;
oargs.runGuide = { server: epGuideServer, guidename: epGuideName, hidden: false};
}
var w = window.weOpenDialogue(res.url,"FormDialog",oargs,continueModal,dims);
if (w)
ARKWSet(35,w.name);
return {i:1};
}

function OpenNonModalForm(inself,server,form,view,args) {
;
;
;
if(inself&&weAmDialogue(window.self.name)) 
inself=false;
var wname=inself?window.self.name:(""+new Date().getTime());
var argkey=server.toLowerCase()+form+wname;
var argstr=weDeepSerialiseVariable(args);
var url=new NDXGetURLForForm(server,((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""),form,view,false,argkey,argstr).GetResult().url;
ARKWSet(35,wname);
return {c:{f:weDisplayWFNotes,a:[window]}, n:{f:function(win) {
if(inself) {
try { win.open(url,win.name); } catch(e) {} 
win.arWindowType="Form"; 
WorkflowContext.WindowOpened();
return win.self;
}
win.weOpen(url,wname,"Form",null,null);
}, a:[window]}};
}
function arInvokeForm(server, schema, mode) {
if (typeof server != "string" || typeof schema != "string" || (typeof mode !="number" && typeof mode!="string"))
return;
if (typeof mode=="string") {
mode=mode.toLowerCase().trim(1|2);
if ("new"==mode||"submit"==mode)
mode=2;
else if ("search"==mode||"query"==mode)
mode=1;
else if ("display"==mode)
mode=11;
else
mode=1;
}
if (CurWFC)
return CurWFC.execute({f:ARACTOpenWindow,a:[server,schema,"","Current",0,null,mode,null,null]});
else
new WorkflowContext({f:ARACTOpenWindow,a:[server,schema,"","Current",0,null,mode,null,null]});
}
function ARACTOpenWindow(server, schema, viewname, targetLocation, setDefaults, inmap, windowMode, epGuideServer, epGuideName) {
;
;
;
;
;
;
LogWrite("ARACTOpenWindow(" + server + ", " + schema + ", " + viewname + ", " + targetLocation + ", " + inmap + ", " + windowMode + "," + epGuideServer + "," + epGuideName + ")");
var d = new Date();
;
;
;
;
server = ExpandServerName(server);
schema = ExpandGuideName(schema);
if ((typeof __tmp_app == "undefined") && (server=="" || schema==""))
throw new WorkflowException(0, []); 
viewname = ExpandString(viewname, 1|2|4);
var argobj={fvlist : inmap, wMode : windowMode, wForceClear : 1, fvSetDefaults : setDefaults};
if (epGuideName) {
;
argobj.runGuide = { server: epGuideServer, guidename: epGuideName, hidden: false};
}
if (IsTargetLocationViewField(targetLocation, server, schema, viewname, argobj))
return;
targetLocation = ExpandString(targetLocation, 1|2|4);
return {c:{f:OpenNonModalForm,a:[targetLocation.compareToIgnoreCase("Current"),server,schema,viewname,argobj]}, n:{f:function(targetLocation, win) {
if (targetLocation == "Current" && !weAmDialogue(win.self.name))
throw new WorkflowException(0, []); 
},a:[targetLocation, window]}};
}
function ARACTOpenQueryWindow(server, schema, viewname, targetLocation, windowMode, qual, noMatchContinue, noMatchCustomMessage, suppressEmpty, sortorder, epGuideServer, epGuideName, result) {
;
;
;
;
;
;
;
;
;
;
;
;
LogWrite("ARACTOpenQueryWindow(" + server + ", " + schema + ", " + viewname + ", " + targetLocation + ", " + windowMode + ", " + qual + ", " + noMatchContinue + ", " + noMatchCustomMessage + ", " + suppressEmpty + sortorder + "," + epGuideServer + "," + epGuideName + "," + result + ")");
server = ExpandServerName(server);
schema = ExpandGuideName(schema);
if (server=="" || schema=="")
throw new WorkflowException(0, []); 
qual = ExpandQualifier(qual, schema, server);
viewname = ExpandString(viewname, 1|2|4);
var req = new NDXGetEntryList(ARKWGetStringByIdx(7), ARKWGetStringByIdx(6),server, schema, ((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""), qual.qual, qual.fieldids, qual.fieldvals, qual.fieldtypes, 1, 1, [1]);
var res = req.result;
;
;
if (res.n == 0 && suppressEmpty) {
if (result)
result.v = 1;
return;
}
if (noMatchCustomMessage==null)
noMatchCustomMessage = {t:1,m:"",n:9296,a:""};
noMatchCustomMessage.m = ExpandString(noMatchCustomMessage.m, 1 | 2 | 4 | 8);
var oargs = {wMode : windowMode, wForceClear : 1, qual:qual, sort:sortorder, suppressNoMatch:noMatchContinue, noMatchMessage:noMatchCustomMessage};
if (epGuideName) {
;
oargs.runGuide = { server: epGuideServer, guidename: epGuideName, hidden: false};
}
if (IsTargetLocationViewField(targetLocation, server, schema, viewname, oargs)) {
result.v=0;
return;
}
targetLocation = ExpandString(targetLocation, 1|2|4);
return {c:{f:OpenNonModalForm,a:[targetLocation.compareToIgnoreCase("Current"),server,schema,viewname,oargs]}, n:{f:function(res, noMatchContinue, noMatchCustomMessage, targetLocation, win, result) {
if (res.n == 0 && !noMatchContinue && noMatchCustomMessage.t == 2)
CurWFC.status(0, []);
if (targetLocation == "Current" && !weAmDialogue(win.self.name))
throw new WorkflowException(0, []); 
if (result)
result.v = 0;
return;
},a:[res, noMatchContinue, noMatchCustomMessage, targetLocation, window, result]}};
}
function ARACTOpenReportWindow(server, schema, viewname, targetLocation, windowMode, qual, noMatchContinue, suppressEmpty, sortorder, repParams, epGuideServer, epGuideName, alname, actionIdx, alModTime) {
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
LogWrite("ARACTOpenReportWindow(" + server + ", " + schema + ", " + viewname + ", " + targetLocation + ", " + windowMode + ", " + qual + ", " + noMatchContinue + ", " + suppressEmpty + ", " + sortorder + ", " + repParams + "," + epGuideServer + "," + epGuideName + "," + alname + ", " + actionIdx + ", " + alModTime + ")");
server = ExpandServerName(server);
schema = ExpandGuideName(schema);
if (server=="" || schema=="")
throw new WorkflowException(0, []); 
viewname = ExpandString(viewname, 1|2|4);
targetLocation = ExpandString(targetLocation, 1|2|4);
var destination = "";
if (repParams.dt)
destination = ExpandString(repParams.dt, 1 | 2 | 4);
var sepIndex = destination.indexOf(":");
if (sepIndex != -1)
destination = destination.substr(0, sepIndex+2);
if (destination != "to-file: " && destination != "to-screen: ")
destination = "to-screen: ";
var finalbuff = CreateReportParms(server, schema, viewname, targetLocation, windowMode, qual, noMatchContinue, suppressEmpty, sortorder, repParams, alname, actionIdx, alModTime);
var inNew = (targetLocation != "Current");
if (destination == "to-file: ")
ReportToFile(finalbuff, server);
else
ReportToScreen(inNew, finalbuff, server);    	
return 0;
}
function IsTargetLocationViewField(fid, server, schema, viewname, argobj) {
var re = /^VF([0-9]+)$/
if (re.test(fid)) {
var f = F(fid.substring(2));
if (f instanceof DView) {
var argkey=server.toLowerCase() + schema + f.mFrameName;
var argstr=weDeepSerialiseVariable(argobj);
var url=new NDXGetURLForForm(server,((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""),schema,viewname,false,argkey,argstr).GetResult().url;
var loc = document.location;
var abs = loc.protocol + "//" + loc.hostname;
if (loc.port)
abs += ":" + loc.port;
abs += url;
f.S(new CharType(abs));
return true;
}
}
return false;
}
function MakeReportKey(key)
{
;
return "{0}/{1}".replaceArgs(key.length, key);
}
function MakeReportIntKey(key)
{
;
var intStr = key + "";
return "{0}/{1}".replaceArgs(intStr.length, intStr);
}
function CreateReportParms(server, schema, viewname, targetLocation, windowMode, qual, noMatchContinue, suppressEmpty, sortorder, repParams, alname, actionIdx, alModTime)
{
var keylist = [];
var thekey;
var expStr; 
keylist.push((schema != null)? MakeReportKey(schema) : "0/");
keylist.push((server != null)? MakeReportKey(server) : "0/");
keylist.push((viewname != null)? MakeReportKey(viewname) : "0/");
if (repParams.ty) {
expStr = ExpandString(repParams.ty, 1 | 2 | 4);
keylist.push((expStr != null)? MakeReportKey(expStr) : "0/");
}
else
keylist.push("0/");
if (repParams.na) {
expStr = ExpandString(repParams.na, 1 | 2 | 4);
keylist.push((expStr != null)? MakeReportKey(expStr) : "0/");	   
}
else 
keylist.push("0/");
if (repParams.op) {
expStr = ExpandString(repParams.op, 1 | 2 | 4);
keylist.push((expStr != null)? MakeReportKey(expStr) : "0/");
}
else
keylist.push("0/");	
if (repParams.id) {
expStr = ExpandString(repParams.id, 1 | 2 | 4);
keylist.push((expStr != null)? MakeReportKey(expStr) : "0/");
}
else
keylist.push("0/");	
if (repParams.or) {
expStr = ExpandString(repParams.or, 1 | 2 | 4);
keylist.push((expStr != null)? MakeReportKey(expStr) : "0/");
}
else
keylist.push("0/");	
if (repParams.dt) {
expStr = ExpandString(repParams.dt, 1 | 2 | 4);
keylist.push((expStr != null)? MakeReportKey(expStr) : "0/");
}
else
keylist.push("0/");	
keylist.push((alname != null)? MakeReportKey(alname) : "0/");
keylist.push((actionIdx != null)? MakeReportIntKey(actionIdx) : "0/");
keylist.push((alModTime != null)? MakeReportKey(alModTime) : "0/");
if (repParams.lc) {
expStr = ExpandString(repParams.lc, 1 | 2 | 4);      
keylist.push((expStr != null)? MakeReportKey(expStr) : "0/");
}
else
keylist.push("0/");	
if (repParams.cs) {
expStr = ExpandString(repParams.cs, 1 | 2 | 4);      
keylist.push((expStr != null)? MakeReportKey(expStr) : "0/");
}
else
keylist.push("0/");	
if(qual != null) {
qual = ExpandQualifier(qual, schema, server);
if(qual.qual != "" && qual.fieldids.length > 0)
{
var req = new NDXParseAndEvaluateQualifier(server, schema, viewname, qual.qual, qual.fieldids, qual.fieldvals, qual.fieldtypes);
;
qual = {qual : req.result, fieldids:[],fieldvals:[],fieldtypes:[]};
}
keylist.push((qual.qual != null) ? MakeReportKey(qual.qual) : "0/");
}
else
keylist.push("0/");
if(sortorder != null && sortorder.length > 0) {
var sortStr = sortorder.join(":");
keylist.push(MakeReportKey(sortStr));
}
else
keylist.push("0/");
return keylist.join("");
}
function ReportToScreenCurrent(repParms, server) {
var w = window.document.createElement("DIV");
;
w.style.top=0;
w.style.left=0;
w.style.zIndex=100001;
w.style.position="absolute";
w.style.display="none";
window.document.body.appendChild(w);
var displayHTML='<FORM method="POST" action="{0}" enctype="application/x-www-form-urlencoded" accept-charset="UTF-8" target="{1}"><input type=hidden name="{2}" value="{3}"/><input type=hidden name="{4}" value="{5}"/></FORM>';
var url = (AbsContextPath + "servlet/ReportServlet");
var htmlStr = displayHTML.replaceArgs(url, "_parent", "REPPARM", repParms.HTMLEncode(), "server", server);
w.innerHTML= htmlStr;
var form = w.firstChild;
;
form.submit(); 
window.document.body.removeChild(w);
}
function ReportToScreenNew(repParms, server) {
var wname = "ReportWin" + new Date().getTime();
var w = open("", wname, "menubar=yes,toolbar=no,location=no,resizable=yes,scrollbars=yes");
WorkflowContext.WindowOpened();
w.arWindowType = "Report";
var doc = w.document;
doc.open("text/html");
var displayHTML ='<html><head></head><body onload=document.forms["RPTDIS70"].submit()><FORM name=RPTDIS70 id=RPTDIS702 method="POST" enctype="application/x-www-form-urlencoded" accept-charset="UTF-8" action="{0}"><input type=hidden name="{1}" value="{2}"/><input type=hidden name="{3}" value="{4}"/></FORM></body></html>';
var url = (AbsContextPath + "servlet/ReportServlet");
doc.write(displayHTML.replaceArgs(url, "REPPARM", repParms.HTMLEncode(), "server", server));
doc.close();
}
function ReportToScreen(inNew, repParms, server)
{
if (inNew)
ReportToScreenNew(repParms, server);
else
ReportToScreenCurrent(repParms, server);	
}
function GetSaveFrameTarget(){
var saveFrame = window.frames["exportSaveFrame"];
if (saveFrame == null) {
var exportSaveFrame=window.document.createElement("div");
exportSaveFrame.innerHTML="<IFRAME name=\"{0}\" onload=saveFrameLoaded() src=\"javascript:&quot;&lt;HTML&gt;&lt;/HTML&gt;&quot;\"></IFRAME>".replaceArgs("exportSaveFrame");
exportSaveFrame.style.display="none";
exportSaveFrame.style.top=exportSaveFrame.style.left=0;
exportSaveFrame.style.bottom=exportSaveFrame.style.right=1;
window.document.body.appendChild(exportSaveFrame);
}
return "exportSaveFrame";
}
function saveFrameLoaded() {
var savefr = window.frames[GetSaveFrameTarget()];
try {
if (savefr.document && savefr.document.body) {
if(savefr.document.location.href != "about:blank") {
var al = new AlertPopup();
var errMsg = savefr.window.Msg;
if (!errMsg) {
errMsg = getLocalizedMessage("Failed to perform Action");
}
var contents = "<TABLE><TR><TD><textarea readonly rows=2 cols=50 class=\"dat\" style=\"overflow:auto;\">{0}</textarea></TD></TR></TABLE>".replaceArgs(errMsg);
al.SetContents(getLocalizedMessage("Report Error"), contents, "Reporting");
al.ShowCentredPopup();
}
}
} catch (exc) {
var al = new AlertPopup();
var contents = "<TABLE><TR><TD><textarea readonly rows=2 cols=50 class=\"dat\" style=\"overflow:auto;\">{0}</textarea></TD></TR></TABLE>".replaceArgs(AR_ERROR_RPT_CANNOT_EXP_FILE);
al.SetContents(getLocalizedMessage("Report Error"), contents, "Reporting");
al.ShowCentredPopup();
}
}
function ReportToFile(repParms, server)
{
var w = window.document.createElement("DIV");
;
w.style.top=0;
w.style.left=0;
w.style.zIndex=100001;
w.style.position="absolute";
w.style.display="none";
window.document.body.appendChild(w);
var saveHTML='<FORM method="POST" action="{0}" enctype="application/x-www-form-urlencoded" accept-charset="UTF-8" target="{1}"><input type=hidden name="{2}" value="{3}"/><input type=hidden name="{4}" value="{5}"/></FORM>';
var url = (AbsContextPath + "servlet/ReportServlet");
var target = GetSaveFrameTarget();
var htmlStr = saveHTML.replaceArgs(url, target, "REPPARM", repParms.HTMLEncode(), "server", server);
w.innerHTML= htmlStr;
var form = w.firstChild;
;
form.submit(); 
window.document.body.removeChild(w);
}

var ARRPValues = {
"GET-CHANGE-FLAG" : { t:2, f:ARProcessGetChangeFlag },
"JAVASCRIPT" : { t:7, f:ARProcessJavascript },
"PERFORM-ACTION-ACTIVE-LINK" : { t:5, f:ARProcessActionActiveLink },
"PERFORM-ACTION-ADD-ATTACHMENT" : { t:7, f:ARProcessAddAttach },
"PERFORM-ACTION-APPLY" : { t:5, f:ARProcessApply },
"PERFORM-ACTION-DELETE-ATTACHMENT" : { t:3, f:ARProcessDeleteAttach },
"PERFORM-ACTION-EXIT-APP" : { t:5, f:ARProcessExitApp },
"PERFORM-ACTION-GET-FIELD-LABEL" : { t:2, f:ARProcessGetFieldLabel }, 
"PERFORM-ACTION-GET-PREFERENCE" : { t:2, f:ARProcessGetPreference },
"PERFORM-ACTION-GO-HOME" : { t:1, f:ARProcessGoHome },
"PERFORM-ACTION-HOME-FIELD-REFRESH" : { t:1, f:ARProcessHomeFieldRefresh },
"PERFORM-ACTION-NEXT" : { t:5, f:ARProcessResultsListNext },
"PERFORM-ACTION-OPEN-ATTACHMENT" : { t:3, f:ARProcessDisplayAttach },
"PERFORM-ACTION-OPEN-URL" : { t:1, f:ARProcessOpenURL },
"PERFORM-ACTION-PREV" : { t:5, f:ARProcessResultsListPrev },
"PERFORM-ACTION-REFRESH-PREFERENCE" : { t:1, f:ARProcessRefreshPreference },
"PERFORM-ACTION-SAVE-ATTACHMENT" : { t:3, f:ARProcessSaveAttach },
"PERFORM-ACTION-SEND-EVENT" : { t:1, f:ARProcessSendEvent },
"PERFORM-ACTION-SET-PREFERENCE" : { t:1, f:ARProcessSetPreference },
"PERFORM-ACTION-TABLE-CLEAR" : { t:1, f:ARProcessTableClear },
"PERFORM-ACTION-TABLE-CLEAR-ROWCHANGED" : { t:1, f:ARProcessTableClearRowChanged },
"PERFORM-ACTION-TABLE-DESELECTALL" : { t:5, f:ARProcessTableDeselectAll },
"PERFORM-ACTION-TABLE-NEXT-CHUNK" : { t:5, f:ARProcessTableNextChunk },
"PERFORM-ACTION-TABLE-PREV-CHUNK" : { t:5, f:ARProcessTablePrevChunk },
"PERFORM-ACTION-TABLE-REFRESH" : { t:5, f:ARProcessTableRefresh },
"PERFORM-ACTION-TABLE-REPORT" : { t:5, f:ARProcessTableReport },
"PERFORM-ACTION-TABLE-SELECTALL" : { t:5, f:ARProcessTableSelectAll },
"PERFORM-ACTION-TABLE-GET-SELECTED-COLUMN" : { t:2, f:ARProcessTableGetSelectedColumn },
"PERFORM-ACTION-TABLE-SELECT-NODE" : { t:7, f:ARProcessTableSelectNode },
"PERFORM-ACTION-TABLE-IS-LEAF-SELECTED" : { t:6, f:ARProcessTableIsLeafSelected },
"SET-CHANGE-FLAG" : { t:1, f:ARProcessSetChangeFlag },
"SET-RO-COLOR" : { t:1, f:ARProcessSetROColour },
"PERFORM-ACTION-NAV-FIELD-SET-SELECTED-ITEM" : { t:1, f:ARProcessNavFieldSetSelectedItem },
"APPLICATION-COPY-FIELD-VALUE" : { t:2, f:ARProcessCopyFieldValue }
};
function ARACTProcess(process, source, result) {
;
;
LogWrite("ARACTProcess(\"" + process + "\", " + source + ")");
process = ExpandString(process, 1 | 2 | 4 | 16 | 8);
process = process.trim(1 | 2);
var ci = process.search(/\s/);
var command = (ci > 0) ? process.substring(0, ci).toUpperCase()
: process.toUpperCase();
LogWrite("Process: " + command);
if ((command in ARRPValues) || (((ci=process.indexOf(":"))>0)&& ((command=process.substring(0,ci).toUpperCase())=="JAVASCRIPT"))) {    
var proc = ARRPValues[command];
if ((proc.t & source) != 0) {
process = (ci>0)?process.substring(ci+1).trim(1):"";
if ((((proc).t & 4) != 0)) {
;
if ((source & 2) && (((proc).t & 2) != 0)) {
;
return {c:{f:proc.f, a:[process, result]}};
} else {
return {c:{f:proc.f, a:[process]}};
}
} else {
if ((((proc).t & 2) != 0)) {
var result = {};
proc.f(process, result);
;
return result.result;
} else {
proc.f(process);
return;
}
}
} else {
if ((source & 2) != 0)
CurWFC.status(9281);
else {
CurWFC.status(9300);
}
}
}
CurWFC.status(9366);
}
function ARACTServerProcess(alName, actionIdx, ts, fid, keywordRefs, fieldRefs) {
;
;
;
;
;
;
var server = ARKWGetStringByIdx(7);
var fieldvals = new Array();
var fieldtypes = new Array();
FieldList.PopulateValueAndTypeArrays(fieldRefs, fieldvals, fieldtypes);
var keyvals = new Array();
var keytypes = new Array();
FieldList.PopulateValueAndTypeArrays(keywordRefs, keyvals, keytypes);
var req = new NDXServerRunProcess(server, alName, actionIdx, ts, fid, keywordRefs, keyvals, keytypes, fieldRefs, fieldvals, fieldtypes);
;
if (req.result == "")
return Null;
else 
return new CharType(req.result);
}
function ARProcessError(args) {
Log("Process not implemented");
CurWFC.status(9215);
}
function ARProcessSetChangeFlag(args) {
var flag = 0;
if (typeof args != "undefined") {
flag = parseInt(args);
}
if (isNaN(flag) || (flag == 0))
Field_ClearChangedFromRunProcess();
else    
Field_SetChanged();
}
function ARProcessGetChangeFlag(args, result) {
;
result.result =  Field_GetChanged() ? IntegerType.ONE : IntegerType.ZERO;
}
function ARByteToHex(thebyte) {
;
return ((thebyte < 16) ? "0" : "") + thebyte.toString(16);
}
function ARProcessSetROColour(args) {
;
var values = args.split(",");
if (values.length == 3) {
var r = parseInt(values[0]);
var g = parseInt(values[1]);
var b = parseInt(values[2]);
if (!isNaN(r) && !isNaN(g) && !isNaN(b)) {
var colour = "#" + ARByteToHex(r) + ARByteToHex(g) + ARByteToHex(b);
Field_SetROBackground(colour);
}
}
}
function ARProcessActionActiveLink(args) {
;
var param = args.match(/\b([0-9]+)\b/g);
if (param != null) {
var func = AREventFunction(param[0], param[1]);
if (func)
return func();
}
}
function ARProcessJavascript(args, result) {
;
var res = eval(args);
if (res && typeof res == "object" && ("i" in res || "n" in res || "c" in res))
return res;
else if (typeof result == "object")
result.result=new CharType(res);
}
function ARProcessGetFieldLabel(args, result) {
;
;
result.result = Null;
var id = parseInt(args);
if (!isNaN(id)) {
var label = F(id).GLabel();
if (label == " ")
label = "";
if (label != null)
result.result = new CharType(label);
}
}
function ARProcessRefreshPreference(args) {
;
var flag = parseInt(args);
if (!isNaN(flag)) {
ARPrefsRefresh(flag);
}
}
var GPSP = /([0-9]+)(-((\"(([^\"]|(\"\"))*)\"?)|(\S+)))?/;var REPDBQ = /\"\"/g; 
function ARProcessGetPreference(args, result) {
;
var params = args.match(GPSP);
if (!params || params[1] == "") {
result.result = new CharType("");
return;
}
var prefKey = (params[5] == "") ? params[8] : params[5];
if (prefKey && params[7] && params[7]!="")
prefKey = prefKey.replace(REPDBQ, "\"");
var res = ARPrefsGet(parseInt(params[1]), prefKey);
result.result = (res == null) ? new CharType("") : new CharType("" + res);
}
function ARProcessHomeFieldRefresh() {
DAppList.Refresh();
}
function ARProcessGoHome() {
FormAction_OpenHomePage();
}
var URLRE = /[a-zA-Z]+:[\/]*(.*)/mg;
function ARProcessOpenURL(args) {
;
if (args != "") {
var values = args.split(" ");
if (values.length > 0 && values.length <= 2) {
var wname;
if (values.length==1 || values[0].compareToIgnoreCase("new")) {
wname = (""+new Date().getTime());
} else if (values[0].compareToIgnoreCase("current")) {
wname = window.self.name;
}
if (wname) {
var url = (values.length==1) ? values[0] : values[1];
url = url.replace(/(\")|(\\")/g, ""); //"
var match = url.match(URLRE);
if (match || url.indexOf("www.") == 0) {
if (!match) url = "http://" + url; 
window.weOpen(url,wname,"URL",null,null);
ARKWSet(35,wname);
}
}
}
}
}
function ARProcessExitApp() {
FieldList.ClearAllGlobals();
var dirty = false;
var theOpener = window;
var pnt = theOpener; 
var winList = weGetAllWindows();
for(var i in winList) {
if ((winList[i].ARStateCurrent==1 || winList[i].ARStateCurrent==5) && winList[i].Field_GetChanged()) {
dirty = true;
break;
}
}
while (pnt) {
pnt = theOpener.weGetOpener();
if (pnt && !pnt.closed) {
if (!pnt.weGetOpener)
break; 
theOpener= pnt;
}
else
break;
}
var stack = {};
var res = {};
if (dirty) {
var res = {};
var msg = getLocalizedMessage("Your changes have not been saved or sent.  Do you really want to close the window?");
stack.c = {f:ConfirmPopup, a:[msg, res, 4 | 8]};
}
stack.n = {f:ExitApp, a:[dirty, res, winList, theOpener]};
return stack;
}
function ExitApp(dirty, res, winList, theOpener) {
var stack={};
if (CurWFC.notes.length>0)
stack.c = {f:MessagePopup, a:[CurWFC.notes]};
stack.n = {f:function(){
CurWFC.notes=[];
if (!dirty || (("v" in res.result) && res.result.v == 1)) {
if (dirty) {
for(var i in winList)
winList[i].Field_ClearChangedFromRunProcess();
}
weCloseAllWindows(theOpener, true, (AbsContextPath + "servlet/LogoutServlet"));
throw new WorkflowException(0, []);
}
}};
return stack;
}
function GetAttachField(args) {
;
var values = args.split(" ");
if (values.length > 0) {
var fid = parseInt(values[0]); 
;
var f = F(fid);
if (f && (f instanceof JAttachment || f instanceof DAttachmentPool)) {
return f;
}
}
return null;
}
function ARProcessAddAttach(args, result) {
LogWrite("Add Attach");
var f = GetAttachField(args);
if (f) {
return f.Add(result);
} else if (result) {
result.result = JAttachment.FAILED;
}
}
function ARProcessDeleteAttach(args, result) {
LogWrite("Delete Attach");
var f = GetAttachField(args);
if (f) {
return f.Delete(result);
} else if (result) {
result.result = JAttachment.FAILED;
}
}
function ARProcessDisplayAttach(args, result) {
LogWrite("Display Attach");
var f = GetAttachField(args);
if (f) {
return f.Display(result);
} else if (result) {
result.result = JAttachment.FAILED;
}
}
function ARProcessSaveAttach(args, result) {
LogWrite("Save Attach");
var f = GetAttachField(args);
if (f) {
return f.SaveToDisk(result);
} else if (result) {
result.result = JAttachment.FAILED;
}
}
var SPSP=/([0-9]+)(-((\"(([^\"]|(\"\"))*)\"?)|(\S+)))?(\s+(.*))?/;
function ARProcessSetPreference(args) {
;
var params = args.match(SPSP);
if (!params || params[1] == "") {
return;
}
var prefKey = (params[5]=="") ? params[8] : params[5];
if (prefKey && params[7] && params[7]!="")
prefKey = prefKey.replace(REPDBQ, "\"");
var val = params[10] ? params[10] : "";
ARPrefsSet(parseInt(params[1]), prefKey, val);
}
function ARProcessApply(args) {
return FormAction_GenericApply();
}
function ARProcessGetTableField(args) {
;
var id = parseInt(args); 
if (!isNaN(id)) {
var table = F(id);
if (table instanceof DTable)
return table;
}
return null;
}
function ARProcessTableClear(args) {
var table = ARProcessGetTableField(args);
if(table)
table.Clear();
}
function ARProcessTableClearRowChanged(args) {
var table = ARProcessGetTableField(args);
if (table) {
;
var gs = CurWFC.getGuideState();
if (gs != null) {
;
if ("table" in gs) { 
table.ClearRowChanged(gs.currow);
return;
}
}
table.ClearRowChanged(-1);
}
}
function ARProcessTableRefresh(args) {
var table = ARProcessGetTableField(args);
if (table) {
var start = -1;
var size = 0;
args = args.split(/\s/);
if (args.length > 1) {
var num = parseInt(parseFloat(args[1]));
if (!isNaN(num)) {
start = num - 1;
if (start < 0)
start = 0;
}
if (args.length > 2) {
var num = parseInt(parseFloat(args[2]));
if (!isNaN(num)) {
size = num;
if (size < 0)
size = 0;
}
}
}
return table.Refresh(start,size,false);
}
}
function ARProcessTableSelectAll(args) {
var table = ARProcessGetTableField(args);
if (table)
return table.SelectAll(true);
}
function ARProcessTableDeselectAll(args) {
var table = ARProcessGetTableField(args);
if (table)
return table.SelectAll(false);
}
function ARProcessTableNextChunk(args) {
var table = ARProcessGetTableField(args);
if (table)
return table.NextChunk(1);
}
function ARProcessTablePrevChunk(args) {
var table = ARProcessGetTableField(args);
if (table)
return table.NextChunk(-1);
}
function ARProcessTableReport(args) {
var table = ARProcessGetTableField(args);
if (table)
return table.Report();
}
function ARProcessResultsListPrev(args) {
var rl = F(1020);
if (rl) {
var row = rl.G().toInteger();
if (row != -1) {
row -= 1;
if (row < 1)
row = rl.GetRows();
return {n:{f:rl.S, t:rl, a:[new IntegerType(row)]}};
}
}
}
function ARProcessResultsListNext(args) {
var rl = F(1020);
if (rl) {
var row = rl.G().toInteger();
if (row != -1) {
row += 1;
if (row > rl.GetRows())
row = 1;
return {n:{f:rl.S, t:rl, a:[new IntegerType(row)]}};
}
}
}
function ARProcessTableGetSelectedColumn(args, result) {
result.result = Null;
var field = ARProcessGetTableField(args);
if (field instanceof DTreeView) {
var levelOrID = 0;
args = args.split(/\s/);
if (args.length > 1) {
var num = parseInt(parseFloat(args[1]));
if (!isNaN(num) && num == 1)
levelOrID = 1;
}
result.result = field.GetSelectedColumn(levelOrID);
}
}
function ARProcessTableSelectNode(args) {
var field = ARProcessGetTableField(args);
if (field instanceof DTable) {
var row = 0;
var level = -1;
var expand = 0;
args = args.split(/\s/);
if (args.length > 1) {
var num = parseInt(parseFloat(args[1]));
if (!isNaN(num))
row = num;
if (args.length > 2) {
var num = parseInt(parseFloat(args[2]));
if (!isNaN(num) && num > level)
level = num;
if (args.length > 3) {
var num = parseInt(parseFloat(args[3]));
if (!isNaN(num) && num == 1)
expand = 1;
}
}
}
if (field instanceof DTreeView){
if (row == 0)
return field.S("0");
else if (level == -1 || (row > 100000000 || row < -100000000))
return field.S(row + "");
else if (row < 0)
return field.SelectNode(-row-1, level-1, expand, true, false);
else 
return field.SelectNode(row-1, level-1, expand, true, true);
}
else
return field.S(row + ""); 
}
}
function ARProcessTableIsLeafSelected(args, result) {
var field = ARProcessGetTableField(args);
if (field instanceof DTreeView)
result.result = field.IsLeafSelected();
else
result.result = IntegerType.ZERO;
}
var ARProcessSendEvent_CmdlineParser=new RegExp("\\s*((\\\"(([^\"]|(\"\"))*)\\\"\\s*)|([^\\s]*))","g");
function ARProcessSendEvent(str) {
str=str.trim(1|2);
if(str.length==0)return;
var matcher;
var args=["","",""]; 
ARProcessSendEvent_CmdlineParser.lastIndex=0; 
for (var ii=0; ii < args.length && (matcher=ARProcessSendEvent_CmdlineParser.exec(str)); ii++) {
args[ii]=matcher[3]?(matcher[5]? matcher[3].replace(REPDBQ,"\""):matcher[3]):matcher[6];
}
if(args[0]==""||args[1]=="")return;
ARProcessEvent.DeliverEvent(args[0],args[1],args[2]);
}
function ARProcessNavFieldSetSelectedItem(args) {
;
var fieldId = parseInt(args);
if (!isNaN(fieldId) && F(fieldId) instanceof DNavBarItem) {
F(fieldId).SetSelected();
}
}
var CPEX=/([0-9]+)(\s+)([0-9]+)/;
function ARProcessCopyFieldValue(args, result) {
;
var params = args.match(CPEX);
if (params==null) {
result.result = new IntegerType(1);
return;
}
var tgtid = params[1];
var srcid = params[3];
if (srcid in Fields && tgtid in Fields) {
F(tgtid).S((F(srcid).G()));
result.result = new IntegerType(0);
}
else 
result.result = new IntegerType(1);
}

function ARACTSQL(alName, actIndex, keywordRefs, fieldRefs) {
;
;
;
;
LogWrite("ARACTSQL(\"" + alName +"\"," + actIndex + ", " + keywordRefs + ", " + fieldRefs + ")");
var keywordVals = new Array();
var keywordTypes = new Array();
FieldList.PopulateValueAndTypeArrays(keywordRefs, keywordVals, keywordTypes);
var fieldVals = new Array();
var fieldTypes = new Array();
FieldList.PopulateValueAndTypeArrays(fieldRefs, fieldVals, fieldTypes);
var req = new NDXGetSQLEntryList(ARKWGetStringByIdx(7), alName, actIndex, 3, 6, keywordRefs, keywordVals, keywordTypes, fieldRefs, fieldVals, fieldTypes, true);
var res = req.result;
;
}

function ARACTSetAllFields(fields)
{
;
LogWrite("ARACTSetAllFields()");
; 
if ((ARStateCurrent == 1) || (ARStateCurrent == 5) || (ARStateCurrent == 6)) {
fields.RemoveField(6);
fields.RemoveField(5);
fields.RemoveField(3);
fields.RemoveField(1);
}
for (var field in fields.mFields) {
;
; 
; 
F(field).S(fields.mFields[field]);
}
}

function SelectionPopup(arg, res) {
;
;
;
;
;
;
;
arg.title = getLocalizedMessage("Selection list");
arg.appss = GetAppStyleSheet("../../");
return weOpenModalPopup((AbsContextPath + "resources/html/SelectionPopup.html"),"Selection",arg,res, [640,320]);
}

DDisplay.prototype=new DView(); DDisplay.prototype.constructor=DDisplay; DDisplay.superclass=DView.prototype;;
DOMFieldFactories["Display"]=function(id,n) {
return new DDisplay(id,n);
}
function DDisplay(a,b) {
if(arguments.length)
this.init(a,b);
}
DDisplay.prototype.init=function(id, n) {
DDisplay.superclass.init.call(this,id,n);
this.DataDefault();
}
DDisplay.prototype.mHaveStoredData=false;
DDisplay.prototype.GDefault=function() {
this.val=Null; 
if("d" in Defaults[this.mID])
return(new CharType(ExpandString(""+Defaults[this.mID].d, 2)));
return null;
}
DDisplay.URLTypeParamsRE = new RegExp("[?|&]([^=]*)=([^&]*)","g"); 
DDisplay.RegularParamsRE = new RegExp("\\s*([^=\\s,]+)\\s*=((\\s*([^\",]+\\\"[^\"]*\\\")\\s*)|(\\s*\\\"(([^\"]|(\"\"))*)\\\"\\s*)|([^,]*))(,|$)","g"); 
DDisplay.HTTPPAT = new RegExp("^https?:[\\\\/][\\\\/].*","i");
DDisplay.CURRENTSERVER = new RegExp("^((%40)|@)$");
DDisplay.replaceRegExpSuffix=")=[^&]*"; 
DDisplay.PLUGIN_CONTEXT="plugins/";
DDisplay.PLUGIN_CONTEXT_SUFF="/params";
DDisplay.PluginNameReplaceRE=new RegExp("(.*/)"+DDisplay.PLUGIN_CONTEXT+"[^/]+"+DDisplay.PLUGIN_CONTEXT_SUFF);
DDisplay.prototype.DoSet=DDisplay.prototype.DoSetLoadEntry=function(val) {
;
if (val.isNull) {
return; 
} else {
val = val.toString();
}
var propValPairs = {};
var repRECons = [];
if (val.match(DDisplay.HTTPPAT)) {
var matcher;
while (matcher = DDisplay.URLTypeParamsRE.exec(val)) {
repRECons.push("("+matcher[1]+")");
propValPairs[matcher[1].toLowerCase()]=matcher[2];
}
} else {
var matcher;
while (matcher = DDisplay.RegularParamsRE.exec(val)) {
repRECons.push("("+matcher[1]+")");
propValPairs[matcher[1].toLowerCase()]=encodeURIComponent(matcher[4] ? matcher[4] : (matcher[6] ? (matcher[8] ? matcher[6].replace(/\"\"/g,"\"") : matcher[6]) : matcher[9]));
}
}
if (repRECons.length > 0) {
var sval = propValPairs["server"];
if (sval && sval.match(DDisplay.CURRENTSERVER)) { 
propValPairs["server"]=encodeURIComponent(ARKWGetStringByIdx(7));
}
var repREStr = "[?|&](" + repRECons.join("|");
repREStr+=DDisplay.replaceRegExpSuffix;
var newStr;
var firstSet;
if (this.val.isNull) {
sval=propValPairs["plugin"];
;
delete propValPairs["plugin"];
newStr = (AbsContextPath + DDisplay.PLUGIN_CONTEXT+sval+DDisplay.PLUGIN_CONTEXT_SUFF+"?");
propValPairs["fieldid"]=this.mID;
sval=((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : "");
if (sval!="") {
propValPairs["appname"]=encodeURIComponent(sval);
}
firstSet = true;
} else {
firstSet = false;
sval=propValPairs["plugin"];
newStr=this.val.toString();
if (sval) {
newStr = newStr.replace(DDisplay.PluginNameReplaceRE, "$1"+DDisplay.PLUGIN_CONTEXT+sval+DDisplay.PLUGIN_CONTEXT_SUFF);
delete propValPairs["plugin"];
}
newStr = newStr.replace(new RegExp(repREStr,"gi"), function(fullVal, prop) {
var pval = propValPairs[prop];
delete propValPairs[prop];
return fullVal.charAt(0) + prop + "=" + pval;
});
}
var tailCons=[];
for (var ii in propValPairs) {
tailCons.push(ii + "=" + propValPairs[ii]);
}
if (tailCons.length > 0) {
if (!firstSet) {
newStr+="&";
}
newStr+=tailCons.join("&");
}
DDisplay.superclass.DoSet.call(this, new CharType(newStr));
}
}
DDisplay.fbDrillDown = function(server, schema, viewname, qual) {
new WorkflowContext({f:ARACTOpenQueryWindow, a:[server, schema, viewname, "New", 10, qual, 1, null, 0, [], null, null, null,{}]});
}

DAppList.prototype=new DView(); DAppList.prototype.constructor=DAppList; DAppList.superclass=DView.prototype;;
DOMFieldFactories["AppList"]=function(id,n) {
return new DAppList(id,n);
}
function DAppList(a,b) {
if(arguments.length)
this.init(a,b);
}
DAppList.prototype.init=function(id, n) {
;
DAppList.superclass.init.call(this, id, n);
this.loaded = false;
}
DAppList.Load=function() {
var af = Fields[1575];
if (af && !af.loaded) {
DAppList.Refresh();
}
}
DAppList.Refresh=function() {
var af = Fields[1575];
if (af) {
var subset;
if (""+ 1576 in Fields) {
subset=Fields[1576].G().toString();
} else {
subset=null;
}
var server = encodeURIComponent(ARKWGetStringByIdx(7));
var schema = encodeURIComponent(ARKWGetStringByIdx(6));
var view = encodeURIComponent(ARKWGetStringByIdx(17));
var html = (AbsDocumentPath + "AppList.html");
if (subset!=null && subset!="") {
html+="?AppListSubset="+encodeURIComponent(subset);
} 
af.loaded=true;
DAppList.superclass.DoSet.call(af, new CharType(html));
}
}
DAppList.prototype.DoSet=DAppList.prototype.DoSLoadEntry=function(val) {
}
DAppList.prototype.ol=function() {
var fr = window.frames[this.mFrameName];
;
try {
if (fr.document && fr.document.body) {
if (!(fr.document.body.style.backgroundColor)) {
fr.document.body.style.backgroundColor="transparent";
}
var errMsg = fr.window.Msg;
if (errMsg) {
var af = Fields[1575];
if (af) {
DAppList.superclass.DoSet.call(af, new CharType("<html><body>" + getLocalizedMessage(errMsg) + "</body></html>"));
}
}
}
} catch (exc) {
}
}
DAppList.prototype.mHaveStoredData=false;
function arInvokeEntryPoint(server, epGuideName) {
if (typeof server != "string" || typeof epGuideName != "string") {
return;
}
var af = Fields[1575];
if (!af.mFrameName)
return;
var fr=window.frames[af.mFrameName];
if (!fr)
return;
server=ExpandServerName(server);
epGuideName=ExpandGuideName(epGuideName);
var fname="CallARG"+(epGuideName+server).ARToJSIdentifier()+"EPFunc";
if (fname in fr) {
return fr[fname](true);
} else
return;
}
function doEval(str) {
return eval(str);
}

function ParseInvalidNumberInLocaleAsBestWeCan(val, re) {
if (val == null || val == "")
return val;
val = val.replace(re, "$1");
var res = "", i;
for (i=0;i<val.length;i++) {
if (val.charAt(i) == localeInfo.lcDecimalSep) {
res += ".";
} else if (val.charAt(i) != localeInfo.lcThousandSep)
res += val.charAt(i);
}
return "" + parseFloat(res);
}
function LCRealToEn_US(val, validate) {
var decre = localeInfo.lcDecimalSep;
if (decre == ".") decre = "\\.";
var re = new RegExp("^\\s*[+-]?\\d*(" + decre + "\\d+)?\\s*$");
if (!val.match(re)) {
re = new RegExp("^\\s*[+-]?\\d*(" + decre + "\\d+)?[Ee][+-]?\\d+\\s*$");
if (!val.match(re)) {
if (validate) {
throw({t:2,n:9373,m:null,a:"\"" + val + "\""});
} else {
var re = new RegExp("^\\s*([+-]?\\d*(" + decre + "\\d+)?)(.*)");
return ParseInvalidNumberInLocaleAsBestWeCan(val, re);
}
}
}
var res = "", i;
for (i=0;i<val.length;i++) {
if (val.charAt(i) == localeInfo.lcDecimalSep) {
res += ".";
} else if (val.charAt(i) == localeInfo.lcThousandSep) {
res += ",";
} else res += val.charAt(i);
}
return res;
}
function En_USRealToLC(val) {
var res = "", i;
for (i=0;i<val.length;i++) {
if (val.charAt(i) == ".") {
res += localeInfo.lcDecimalSep;
} else if (val.charAt(i) == ",") {
res += localeInfo.lcThousandSep;
} else res += val.charAt(i);
}
return res;
}
function En_USDecimalToLC(val) {
var res = val.replace(".", localeInfo.lcDecimalSep);
var T='', L=res.length-1, C, j, P = res.indexOf(localeInfo.lcDecimalSep)-1;
if (P<0) P=L;
for (j=0; j<=L; j++) {
T+=C=res.charAt(j);
if ((j < P) && ((P-j)%3 == 0) && (C != '-')) T+=localeInfo.lcThousandSep;
}
return T;
}
function LCDecimalToEn_US(val, validate) {
var decre = localeInfo.lcDecimalSep;
if (decre == ".") decre = "\\.";
var thsnre = localeInfo.lcThousandSep;
if (thsnre == ".") thsnre = "\\.";
var re = new RegExp("^\\s*[+-]?\\d*(" + thsnre + "\\d\\d\\d)*(" + decre + "\\d+)?\\s*$");
if (!val.match(re)) {
if (validate) {
throw({t:2,n:9374,m:null,a:"\"" + val + "\""});
} else {
re = new RegExp("^\\s*([+-]?[\\d*" + thsnre + "]+(" + decre + "\\d+)?)(.*)");
return ParseInvalidNumberInLocaleAsBestWeCan(val, re);
}
}
var res = "", i;
for (i=0;i<val.length;i++) {
if (val.charAt(i) == localeInfo.lcDecimalSep) {
res += ".";
} else if (val.charAt(i) == localeInfo.lcThousandSep) {
} else res += val.charAt(i);
}
return res;
}

DIVPopup.prototype.constructor=DIVPopup;;
var OpenDIVPopup = null;
function DIVPopup(modal) {
if (arguments.length)
this.init(modal);
}
DIVPopup.prototype.init = function(modal) {
;
;
this.mDiv = null;
this.mModal = modal;
this.mX=this.mY=0;
this.mIFrame = null;
}
DIVPopup.FindPopup = function(element)
{
if (OpenDIVPopup != null) { 
while (element && element != document.body) { 
if (element == OpenDIVPopup.mDiv)
return OpenDIVPopup;
element=element.parentNode;
}
if (!OpenDIVPopup.mModal) {
OpenDIVPopup.HidePopup();
return null;
}
}
return null; 
}
DIVPopup.prototype.KeyDown = function(edata) {
if (OpenDIVPopup.mModal) {
if (edata.key == 27 && typeof(OpenDIVPopup.OnCancel) == "function") {
OpenDIVPopup.OnCancel();
return false;
} 
if ((edata.key == 13 || edata.key == 32) && edata.element.getAttribute("DIVBTN")) {
edata.element.click();
return false;
} 
}
if (edata.key == 9) {
this.DoTab(edata, !edata.shift);
edata.SetKeyCode(505);
return false;
}
return true;
}
DIVPopup.prototype.Click=DIVPopup.prototype.KeyPress=function(edata) {
return false;
}
DIVPopup.prototype.HidePopup = function() {
document.body.removeChild(this.mDiv);
OpenDIVPopup = null;
if (this.mModal) {
weEnableStuff();
}
}
DIVPopup.prototype.ShowPopup = function(parentelement,ox,oy) {
;
;
var w = this.mDiv.childNodes[0].offsetWidth;
var h = this.mDiv.childNodes[0].offsetHeight;
this.mDiv.style.width = w;
this.mDiv.style.height = h;
this.mDiv.style.zIndex = 100001;
if (this.mModal)
weDisableStuff(); 
OpenDIVPopup = this;
var windowt=document.body.scrollTop;
var windowl=document.body.scrollLeft;
var windowb=document.body.clientHeight+windowt;
var windowr=document.body.clientWidth+windowl;
;
;
var res=ComputeElementPosition(parentelement,document.body,ox,oy);
var x=res.x,y=res.y;
y=(y<windowt?windowt:y);
y=(y+h>=windowb?windowb-h:y);
y=(y<0?0:y);
x=(x<windowl?windowl:x);
x=(x+w>=windowr?windowr-w:x);
x=(x<0?0:x);
this.mDiv.style.left=this.mX=x;
this.mDiv.style.top=this.mY=y;
this.mDiv.style.visibility='inherit';
this.mTabStops = [];
this.ComputeTabStops(this.mDiv);
var addWidth = Math.max(x + w - windowr, 0);
var addHeight = Math.max(y + h - windowb, 0);
if (addWidth > 0 || addHeight > 0)
window.resizeBy(addWidth, addHeight);
}
DIVPopup.prototype.ComputeTabStops = function(element) {
if ("getAttribute" in element && element.getAttribute("ARTB")) {
this.mTabStops.push(element);
}
if (element.childNodes && element.childNodes.length > 0) {
for (var i=0; i < element.childNodes.length; i++) {
this.ComputeTabStops(element.childNodes[i]);
}
}
}
DIVPopup.prototype.ShowCentredPopup=function() {
var windowt=document.body.scrollTop;
var windowl=document.body.scrollLeft;
var windowb=document.body.clientHeight+windowt;
var windowr=document.body.clientWidth+windowl;
;
;
var w=Math.floor(this.mDiv.firstChild.offsetWidth/2),h=Math.floor(this.mDiv.firstChild.offsetHeight/2);
var x=windowl+(windowr-windowl)/2-w;
var y=windowt+(windowb-windowt)/2-h;
return this.ShowPopup(document.body,x,y);
}
DIVPopup.prototype.Buttons = [
{t : getLocalizedMessage("OK"), f : "OnOK"},
{t : getLocalizedMessage("Cancel"), f : "OnCancel"}
];
DIVPopup.prototype.ButtonSpacing = 5;
DIVPopup.prototype.WriteModalButtons = function() {
var val = [];
val.push("<tr><td align=center class=DIVPopupButtons>");
val.push("<table><tr>");
for (var i in this.Buttons) {
var w = this.Buttons[i].w;
val.push("<td width=\"" + w + "\" height=\"29\">");
val.push("<a ARTB=1 DIVBTN=1 TABINDEX=0 onclick=\"OpenDIVPopup." + this.Buttons[i].f + "();\" class=\"btn btn3d\" style=\"position:relative; left:0; height:19; top:0; \"");
val.push(">");
val.push("<div class=\"btntextdiv f1\" style=\"position:relative; top:2; left:0; height:19;\">&nbsp;&nbsp;");
val.push(this.Buttons[i].t + "&nbsp;&nbsp;</div>");
val.push("</a>");
val.push("</td><td width=\"" + this.ButtonSpacing + "\" height=\"19\">&nbsp;</td>");
}
val.push("</tr><tr><td height=\"10\"></td></tr></table></td></tr>");
return val.join("");
}
DIVPopup.prototype.OnOK =function() {
this.HidePopup();    
}
DIVPopup.prototype.OnCancel = function() {
this.HidePopup();
}
DIVPopup.prototype.PopupBodyStyle = "DIVPopupBody";
DIVPopup.prototype.GetTitleBarHTML = function(label) {
return "<tr><td><table class=\"DIVPopupTitleBar\" width=\"100%\"><tr><td align=left nowrap>" + label.HTMLEncode() + "&nbsp;&nbsp;&nbsp;</td></tr>";
}
DIVPopup.prototype.SetContents = function(label, contents) {
this.CreateDIV();
var val = "<table class=DIVPopup cellspacing=0 cellpadding=0>";
val += this.GetTitleBarHTML(label);
val += "<tr><td class=\"" + this.PopupBodyStyle + "\"><P>" + contents + "<P></td></tr>";
if (this.mModal) {
val += this.WriteModalButtons();
}
val += "</table>";
this.mDiv.innerHTML = val;    
}
DIVPopup.prototype.CreateDIV = function() {
if (!this.mDiv) {
var e=document.createElement("DIV");
e.className="DIVPopup";
e.style.top=this.mY;
e.style.left=this.mX;
e.style.zIndex=100001;
document.body.appendChild(e);
this.mDiv = e;
}
}
AlertPopup.prototype=new DIVPopup(); AlertPopup.prototype.constructor=AlertPopup; AlertPopup.superclass=DIVPopup.prototype;;
AlertPopup.prototype.Buttons = [
{t : getLocalizedMessage("OK"), w : 50, f : "OnOK"},
];
function AlertPopup() {
AlertPopup.superclass.init.call(this,true);
}
DIVPopup.prototype.DoTab = function(ed, next) {
var tabstop = 0;
var element = ed.element;
if (element && element.getAttribute("ARTB")) {
for (var n=0; n < this.mTabStops.length; n++) {
if (this.mTabStops[n] == ed.element) {
tabstop = n + (next ? 1 : -1);
if (tabstop >= this.mTabStops.length) {
tabstop = 0;
} else if (tabstop < 0) {
tabstop = this.mTabStops.length - 1;
}
}
}
}
if (tabstop in this.mTabStops) {
var ele = this.mTabStops[tabstop];
setTimeout(function() {ele.focus()}, 0);
}    
}

function ARDate(yr,mth,dt,hr,min,sec) {
if (arguments.length)
this.init(yr,mth,dt,hr,min,sec);
}
ARDate.prototype.year = -1;
ARDate.prototype.month = -1;
ARDate.prototype.date = -1;
ARDate.prototype.hour = 0;
ARDate.prototype.minute = 0;
ARDate.prototype.second = 0;
ARDate.prototype.day = -1;
ARDate.prototype.ampm = -1;
ARDate.prototype.era = 1; 
ARDate.prototype.jera = -1;
ARDate.prototype.init=function(yr,mth,dt,hr,min,sec) {
this.year = yr;
this.month = mth;
this.date = dt;
this.hour = hr;
this.minute = min;
this.second = sec;
}
ARDate.prototype.GYear=function() {
;
return this.year;
}
ARDate.prototype.GMonth=function() {
;
return this.month;
}
ARDate.MonthLabel=function(mon) {
;
return localeInfo.monthsLong[mon];
}
ARDate.DayShort=function(day) {
;
return localeInfo.daysShort[day];
}
ARDate.prototype.DayLong=function() {
return localeInfo.daysLong[this.GDay()];
}
ARDate.prototype.GDate=function() {
;
return this.date;
}
ARDate.prototype.GHour=function() {
;
return this.hour;
}
ARDate.prototype.GMinute=function() {
;
return this.minute;
}
ARDate.prototype.GSecond=function() {
;
return this.second;
}
ARDate.prototype.GTimeOfDay=function() {
return (this.GHour() * 3600) + (this.GMinute() * 60) + this.GSecond();
}
ARDate.prototype.GDay=function() {
if (this.day == -1)
{
var ard1 = new ARDate(1995, 0, 1, 0, 0, 0, 0);
var diff = ard1.GDays() - this.GDays();
if (diff >= 0)
this.day = (7 - (diff % 7)) % 7;
else
this.day = (-diff) % 7;
}
;
return this.day;
}
ARDate.prototype.GAMPM=function() {
;
return this.ampm;
}
ARDate.prototype.GEra=function() {
;
return this.era;
}
ARDate.prototype.SYear=function(val) {
;
this.year = val;
}
ARDate.prototype.SMonth=function(val) {
;
this.month = val;
}
ARDate.prototype.SDate=function(val) {
;
this.date = val;
}
ARDate.prototype.SHour=function(val) {
;
this.hour = val;
}
ARDate.prototype.SMinute=function(val) {
;
this.minute = val;
}
ARDate.prototype.SSecond=function(val) {
;
this.second = val;
}
ARDate.prototype.SDay=function(val) {
;
this.day = val;
}
ARDate.prototype.SAMPM=function(val) {
;
this.ampm = val;
}
ARDate.prototype.SEra=function(val) {
;
this.era = val;
}
ARDate.prototype.GDays=function() {
var numDays = 0;
var a = parseInt((13 - this.month)/12);
var y = this.year + 4800 - a;
var m = this.month + 12*a - 2;
if ((this.year < 1582) || (this.year == 1582 && this.month < 9) ||
(this.year == 1582 && this.month == 9 && this.date <= 4)) {
numDays = this.date + parseInt((153*m + 2)/5) + y*365 + parseInt(y/4) - 32083; 
}
else {
numDays = this.date + parseInt((153*m + 2)/5) + y*365 + parseInt(y/4) - parseInt(y/100) + parseInt(y/400) - 32045;
}    
return numDays;   
}
ARDate.prototype.SDays=function(numDays) {
var a=0, b=0, c=0, d=0, e=0, m=0;
if (numDays < 2299161) {
c = numDays + 32082;
}
else {
a = numDays + 32044;
b = parseInt((4*a + 3)/146097);
c = a - parseInt((b*146097)/4);
}
d = parseInt((4*c + 3)/1461);
e = c - parseInt((1461*d)/4);
m = parseInt((5*e + 2)/153);
this.year = b*100 + d - 4800 + parseInt(m/10);
this.month = m + 2 - 12*parseInt(m/10);
this.date = e - parseInt((153*m + 2)/5) + 1;
if ( this.year <= 0 ) 
{
this.era = 0;
}
}
ARDate.prototype.GWeekNumber=function() {
var a = 0, b = 0, c = 0;
var days = this.GDays();
a = (days + 31741 - (days % 7)) % 146097 % 36524 % 1461;
b = Math.floor(a/1460);
c = ((a-b) % 365) + b;
c = Math.floor(c/7)+1;
return c;
}
ARDate.prototype.GTimestamp=function() {
if (this.GEra() == 0)
return -1;
var dateObj = new Date(this.year, this.month, this.date, this.hour, this.minute, this.second, 0);
var browserOffset = dateObj.getTimezoneOffset() * 60000; 
var tzRules = ARDate.GetTimezoneRules(this.year);
var realOffset = tzRules.offset;
;
var ts = dateObj.valueOf();
var adjustedts = ts-browserOffset-realOffset;
this.SDay(dateObj.getDay());
var dst = this.inDST();
if (dst == -1)
{
return -1;
}
else if (dst == 0)
adjustedts -= tzRules.dstSavings;
adjustedts += (ARDate.getTimeinMS(this.hour, this.minute, this.second) - ARDate.getTimeinMS(dateObj.getHours(), dateObj.getMinutes(), dateObj.getSeconds()));
return adjustedts/1000;
}
ARDate.prototype.STimestamp=function(ts) {
;
var dateObj = new Date(ts*1000);
this.init(dateObj.getFullYear(),dateObj.getMonth(),dateObj.getDate(),dateObj.getHours(),dateObj.getMinutes(),dateObj.getSeconds());
this.SDay(dateObj.getDay());
var browserOffset = dateObj.getTimezoneOffset() * 60000; 
var tzRules = ARDate.GetTimezoneRules(this.year);
var realOffset = tzRules.offset;
var timeAdjustment = browserOffset + realOffset;
this.adjustTime(timeAdjustment);
if (this.inDST() != 1)
this.adjustTime(tzRules.dstSavings);  
}
ARDate.prototype.adjustTime=function(ts) {
if (ts == 0) return;
ts = ts/1000;
var s = ts % 60;
var m = ((ts - s) % 3600)/60;
var h = (ts-s-(m*60))/3600;
var maxDays = ARDate.getDaysInMonth(this.month, this.year);
this.second += s;
this.minute += m;
this.hour += h;
if (ts > 0)
{
if (this.second > 59)
{
this.second -= 60;
this.minute++;
}
if (this.minute > 59)
{
this.minute -= 60;
this.hour++;
}
if (this.hour > 23)
{
this.hour -= 24;
this.date++;
this.day++;
if (this.day > 6)
this.day -= 7;
}
if (this.date > maxDays)
{
this.date -= maxDays;
this.month++;
}
if (this.month > 11)
{
this.month -= 12;
this.year++;
}
}
else
{
if (this.second < 0)
{
this.second += 60;
this.minute--;
}
if (this.minute < 0)
{
this.minute += 60;
this.hour--;
}
if (this.hour < 0)
{
this.hour += 24;
this.date--;
this.day--;
if (this.day < 0)
this.day += 7;
}
if (this.date < 0)
{
this.date += maxDays;
this.month--;
}
if (this.month < 0)
{
this.month += 12;
this.year--;
}
}
}
ARDate.prototype.inDST=function() {
var tzRules = ARDate.GetTimezoneRules(this.year);
if (tzRules.useDaylight)
{
var startMonth = tzRules.startMonth;
var endMonth = tzRules.endMonth;
var isAfter = this.isAfterDSTStart();
var isBefore = this.isBeforeDSTEnd();
if (isAfter == -1)
return -1;
if (isAfter==0 && isBefore==0 && endMonth>startMonth)
return 0;
if (endMonth<startMonth && (isAfter==0 || isBefore==0)) 
return 0;
}
return 1;
}
ARDate.prototype.isAfterDSTStart=function() {
var tzRules = ARDate.GetTimezoneRules(this.year);
var startMonth = tzRules.startMonth;
if (this.month > startMonth)
return 0;
if (this.month < startMonth)
return 1;
var time = ARDate.getTimeinMS(this.hour, this.minute, this.second);
var startDate = tzRules.startDay;
var startTime = tzRules.startTime;
if (tzRules.startTimeMode == 2)
startTime += tzRules.offset;
var startDayOfWk = tzRules.startDayOfWeek - 1;
if (tzRules.startDayOfWeek == 0) 
{	
if (this.date > startDate)
return 0;
else if (this.date == startDate)
{ 
if (time >= startTime+tzRules.dstSavings)
return 0;
else if (time >= startTime && time < startTime+tzRules.dstSavings)
return -1;
}
}
else if (startDate == -1)
{
var lastDayinMonth = ARDate.getDaysInMonth(this.month, this.year);
if (this.day == startDayOfWk)
{
if ((this.date+7) > lastDayinMonth)
{
if (time >= startTime+tzRules.dstSavings)
return 0;
else if (time >= startTime && time < startTime+tzRules.dstSavings)
return -1;
}
}
else
{
var deltaDays = ARDate.daysCount(this.day, startDayOfWk);
if (this.date + deltaDays > lastDayinMonth)
return 0;
}
}
else if (startDate > 0)
{
if (this.date >= startDate)
{
if (this.day == startDayOfWk)
{
if ((this.date-7) >= startDate)
return 0;
else
{
if (time >= startTime+tzRules.dstSavings)
return 0;
else if (time >= startTime && time < startTime+tzRules.dstSavings)
return -1;
}
}
else
{
var deltaDays = ARDate.daysCount(startDayOfWk, this.day);
if ((this.date-deltaDays) >= startDate)
return 0;
}
}
return 1;
}
return 1;
}
ARDate.prototype.isBeforeDSTEnd=function() {
var tzRules = ARDate.GetTimezoneRules(this.year);
var endMonth = tzRules.endMonth;
if (this.month < endMonth)
return 0;
if (this.month > endMonth)
return 1;
var time = ARDate.getTimeinMS(this.hour, this.minute, this.second);
var endDate = tzRules.endDay;
var endTime = tzRules.endTime;
var startDate = tzRules.startDay;
if (tzRules.endTimeMode == 2)
endTime += tzRules.offset;
var endDayOfWk = tzRules.endDayOfWeek - 1;
var startDayOfWk = tzRules.startDayOfWeek - 1;
if (tzRules.endDayOfWeek == 0) 
{	
if (this.date < endDate)
return 0;
else if (this.date == endDate && time <= endTime)
return 0;
}
else if (endDate == -1)
{	
var lastDayinMonth = ARDate.getDaysInMonth(this.month, this.year);
if (this.day == endDayOfWk)
{
if ((this.date+7) <= lastDayinMonth || time <= (endTime-tzRules.dstSavings))
return 0;
}
else
{
var deltaDays = ARDate.daysCount(this.day, endDayOfWk);
if ((this.date+deltaDays) <= lastDayinMonth)
return 0;
}
}
else if (endDate > 0)
{
if (this.date < endDate)
return 0;
if (this.day == endDayOfWk)
{
if ((this.date-7) < endDate && time < (endTime-tzRules.dstSavings))
return 0;
}
else
{
var deltaDays = ARDate.daysCount(endDayOfWk, this.day);
if ((this.date-deltaDays) < endDate)
return 0;
}
}
return 1;
}
ARDate.prototype.validateDate=function(type, digitsInYear) {
if (this.year == -1 || this.month == -1 || this.date == -1)
return false;
var maxDays = ARDate.getDaysInMonth(this.month, this.year);
if (this.date > maxDays)
return false;
if (this.hour < 12 && this.ampm == 1)
this.hour += 12;
else if (this.hour == 12 && this.ampm == 0)
this.hour = 0;
if (type != 13)
this.adjustYear();
else
this.adjustYearForDateField(digitsInYear);
return true;
}
ARDate.prototype.adjustYear=function() {
if (this.jera != -1 && localeInfo.name == "ja_JP")
{
if (this.jera == 0)
this.year += 1925;
else if (this.jera == 1)
this.year += 1988;
}
else
{
if (this.year >= 70 && this.year <= 138)
this.year += 1900;
else if (this.year <= 38)
this.year += 2000;
}
}
ARDate.prototype.adjustYearForDateField=function(digitsInYear) {
if (this.jera != -1 && localeInfo.name == "ja_JP")
{
if (this.jera == 0)
this.year += 1925;
else if (this.jera == 1)
this.year += 1988;
}
if (this.era == 0) 
this.year -= ((2*this.year)-1);
else if (digitsInYear <= 2 && this.year >= 0 && this.year <= 33)
this.year += 2000;
else if (digitsInYear <= 2 && this.year > 33 && this.year < 100)
this.year += 1900;
}
ARDate.prototype.populate=function(pattern, input, type) {
;
var plen = pattern.length;
var digitsInYear = 0;
var ii = 1;
for (var i=0; i<plen; i++)
{
var ch = pattern.charAt(i);
if (!this.validateValue(ch, input[ii++]))
return false;
if (ch == 'y')
{
digitsInYear = input[ii-1].length;
if (type == 13 || type == 7) {
var valid = this.validateValue('G', input[ii]);
if (!valid && type == 13)
return false;
}
ii++;
}
}
return this.validateDate(type, digitsInYear);
}
ARDate.prototype.validateValue=function(ch, value) {
value = value.toLowerCase();
switch(ch)
{
case 'y':
var val = parseInt(parseFloat(value));
if (isNaN(val))
return false;
this.SYear(val);
return true;
case 'M':
if (value in localeInfo.monthsShortMap)
{
this.SMonth(localeInfo.monthsShortMap[value]);
return true;
}	
if (value in localeInfo.monthsLongMap)
{
this.SMonth(localeInfo.monthsLongMap[value]);
return true;
}	
return false;
case 'm':
var val = parseInt(parseFloat(value));
if (isNaN(val))
return false;
val -= 1;
if (val < 0 || val > 11)
return false;
this.SMonth(val);
return true;
case 'd':
var val = parseInt(parseFloat(value));
if (isNaN(val))
return false
if (val < 0 || val > 31)
return false;
this.SDate(val);
return true;
case 'E':
if (value in localeInfo.daysShortMap)
{
this.SDay(localeInfo.daysShortMap[value]);
return true;
}	
if (value in localeInfo.daysLongMap)
{
this.SDay(localeInfo.daysLongMap[value]);
return true;
}	
return false;
case 'a':
if (value in localeInfo.AMPMMap)
{
this.SAMPM(localeInfo.AMPMMap[value]);
return true;
}
return false;
case 'z':
if (value.length == 3 || value.indexOf("gmt") == 0)
return true;
return false;
case 'G':
var len = localeInfo.eras.length;
value = value.trim(1|2);
if (value.length == 0)
return true;
for (var i=0; i<len; i++)
{
if (value == localeInfo.eras[i].toLowerCase())
{
this.SEra(i);
return true;
}
else
{
var val = value.replace(/\./g, '');
var eraVal = localeInfo.eras[i].toLowerCase().replace(/\./g, '');
if (val == eraVal)
{
this.SEra(i);
return true;
}
else if (val == "bc")
{
this.SEra(0);
return true;
}
}
}
if (localeInfo.name == "ja_JP")
{
len = localeInfo.jeras.length;
for (var i=0; i<len; i++)
{
if (value == localeInfo.jeras[i].toLowerCase())
{
this.jera = i;
return true;
}
}
}
return false;
case 'h':
var val = parseInt(parseFloat(value));
if (isNaN(val))
return false;
if (value < 0 || value > 23)
return false;
this.SHour(val);
return true;
case 'u':
var val = parseInt(parseFloat(value));
if (isNaN(val))
return false;
if (value < 0 || value > 59)
return false;
this.SMinute(val);
return true;
case 's':
var val = parseInt(parseFloat(value));
if (isNaN(val))
return false;
if (value < 0 || value > 59)
return false;
this.SSecond(val);
return true;		
}
return false;
}
ARDate.prototype.format=function(pattern, dataType) {
;
var switches = "adDeEGhHiImMnNsSuUyYzZ";
var arr = pattern.split("");
var len = arr.length;
var result = new Array(len);
var idx = 0;
var inQuote = false;
var beforeEra = new RegExp("^zh|^ja|^ko").exec(localeInfo.name);
while (arr[idx]) 
{
if (arr[idx] == "'") 
{
if ((idx+1) < len && arr[idx+1] == "'") 
{
result.push("'");
idx++;
}
else 
{
inQuote = !inQuote;
}
++idx;
}
else if (!inQuote && switches.indexOf(arr[idx]) > -1) 
{
switch (arr[idx])
{
case 'a':
this.GHour()>=12 ? result.push(localeInfo.AMPM[1]) : result.push(localeInfo.AMPM[0]);
break;
case 'd':
result.push(this.GDate());
break;
case 'D':
result.push(ARDate.zeroPad(this.GDate()));
break;
case 'e':
result.push(localeInfo.daysShort[this.GDay()]);
break;
case 'E':
result.push(localeInfo.daysLong[this.GDay()]);
break;
case 'G':
result.push(localeInfo.eras[this.GEra()]);
if (this.jera != -1)
result.push(" " + localeInfo.jeras[this.jera]);
break;
case 'h':
var h = this.GHour();
if (h == 0)
result.push(12);
else
h>12 ? result.push(h-12) : result.push(h);
break;
case 'H':
var h = this.GHour();
if (h == 0) h = 12;
else if (h > 12) h -= 12;
result.push(ARDate.zeroPad(h));
break;
case 'i':
result.push(this.GHour());
break;
case 'I':
result.push(ARDate.zeroPad(this.GHour()));
break;
case 'm':
result.push(localeInfo.monthsShort[this.GMonth()]);
break;
case 'M':
result.push(localeInfo.monthsLong[this.GMonth()]);
break;
case 'n':
result.push(this.GMonth()+1);
break;
case 'N':
result.push(ARDate.zeroPad(this.GMonth()+1));
break;
case 's':
result.push(this.GSecond());
break;
case 'S':
result.push(ARDate.zeroPad(this.GSecond()));
break;
case 'u':
result.push(this.GMinute());
break;
case 'U':
result.push(ARDate.zeroPad(this.GMinute()));
break;
case 'y':
var yr = this.GYear();
var yrStr = "";
if (dataType != 13) {
yrStr = (yr+"").substr(2);
}
else {
if (yr <= 0) {
if (pattern.indexOf('G') < 0)
yrStr = (beforeEra) ? 
localeInfo.eras[0] + " " + ARDate.zeroPadYear(yr*(-1)+1) : 
ARDate.zeroPadYear(yr*(-1)+1) + " " + localeInfo.eras[0];
else
yrStr = ARDate.zeroPadYear(yr*(-1)+1);
}
else
yrStr = ARDate.zeroPadYear(yr);
}
result.push(yrStr);
break;
case 'Y':
var yr = this.GYear();
var yrStr = yr+"";
if (dataType == 13) {
if (yr <= 0) {
if (pattern.indexOf('G') < 0)
yrStr = (beforeEra) ?
localeInfo.eras[0] + " " + ARDate.zeroPadYear(yr*(-1)+1) :
ARDate.zeroPadYear(yr*(-1)+1) + " " + localeInfo.eras[0];
else
yrStr = ARDate.zeroPadYear(yr*(-1)+1);
}
else {
yrStr = ARDate.zeroPadYear(yr);
}
}
result.push(yrStr);
break;
case 'z':
if (this.inDST() == 0)
result.push(tzNames[1]);
else
result.push(tzNames[0]);
break;
case 'Z':
break;		
}
idx++;
}
else 
{
result.push(arr[idx++]);
}
}
return result.join("");
}
ARDate.daysCount=function(start, end) {
return (end >= start) ? end-start : (7-start+end);
}
ARDate.isLeapYear=function(year) {
return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0));
}
ARDate.getTimeinMS=function(hrs, mins, secs) {
return (hrs*3600000) + (mins*60000) + (secs*1000);
}
ARDate.zeroPad=function(val) {
;
return (val < 10) ? "0"+val : val;
}
ARDate.zeroPadYear=function(input)
{
var result="";
var nPad   = 4 - (input+"").length;
while (nPad > 0) {
result += "0";
nPad--;
}
return result+input;
}
ARDate.getDaysInMonth=function(month, year) {
;
;
if (month == 1 && ARDate.isLeapYear(year))
return ARDate.daysinMonth[month]+1;
return ARDate.daysinMonth[month];		
}
ARDate.daysinMonth=[31,28,31,30,31,30,31,31,30,31,30,31];
ARDate.parseDateTime=function(dateInput) {
;
for (var i in localeInfo.parsePatterns)
{
var exp = new RegExp(localeInfo.parsePatterns[i]);
var result = exp.exec(dateInput);
if (result != null)
{
var dateObj = new ARDate();
if (dateObj.populate(localeInfo.normalizedPatterns[i], result, 7))
return dateObj;
}	
}
return ARDate.parseTime(dateInput);
}
ARDate.parseDate=function(dateInput) {
;
var regexp = new RegExp("^" + localeInfo.eras[0] + "\\s*");
var newInput = dateInput.replace(regexp, "");
var beforeEra = newInput != dateInput;
dateInput = newInput;
for (var i in localeInfo.parseDatePatterns)
{
var exp = new RegExp(localeInfo.parseDatePatterns[i]);
var result = exp.exec(dateInput);
if (result != null)
{
var normPattern = localeInfo.normalizedDatePatterns[i];
var dateObj = new ARDate();
if (beforeEra) {
dateObj.SEra(0);
}
if (dateObj.populate(normPattern, result, 13))
{
return dateObj;
}
}	
}
}
ARDate.parseTime=function(timeInput) {
var patternMatch = false;
var dateObj = new Date(); 
var dateObj = new ARDate(dateObj.getFullYear(), dateObj.getMonth(), dateObj.getDate(), 0, 0, 0);
for (var i in localeInfo.parseTimePatterns)
{
var exp = new RegExp(localeInfo.parseTimePatterns[i]);
var result = exp.exec(timeInput);
if (result != null) 
{
var normPattern = localeInfo.normalizedTimePatterns[i];
if (dateObj.populate(normPattern, result, 14))
{
return dateObj;
} else {
patternMatch = true;
}
}
}    
return null;
}
ARDate.getDateObject = function(days) {
;
var v = parseInt(days);
if (v < 0) v=0;
if (v > 5373120) v=5373120;
var dateObj = new ARDate();
dateObj.SDays(v);
return dateObj;
}
ARDate.ARCustomDateSetup=function(arg1, arg2, arg3, arg4) {
localeInfo.parseDatePatterns.splice(0, 0, arg1);
localeInfo.normalizedDatePatterns.splice(0, 0, arg2);
localeInfo.parsePatterns.splice(0, 0, arg1);
localeInfo.normalizedPatterns.splice(0, 0, arg2);
localeInfo.parsePatterns.splice(0, 0, arg3);
localeInfo.normalizedPatterns.splice(0, 0, arg4);
}
ARDate.ARCustomTimeSetup=function(regExpPattern, normPattern) {
localeInfo.parseTimePatterns.splice(0, 0, regExpPattern);
localeInfo.normalizedTimePatterns.splice(0, 0, normPattern);
}
ARDate.ARSetDateTimeFormat=function(datePattern, timePattern) {
localeInfo.dateFormatPattern = datePattern;
localeInfo.timeFormatPattern = timePattern;
}
ARDate.GetTimezoneRules=function(year){
for (var i in timezoneRules) {
if (year >= timezoneRules[i].startYear || !("startYear" in timezoneRules[i]))
return timezoneRules[i];
}
}

SearchBarMenu.prototype=new Menu(); SearchBarMenu.prototype.constructor=SearchBarMenu; SearchBarMenu.superclass=Menu.prototype;;
function SearchBarMenu(field) {
if (arguments.length)
this.init(field);
}
SearchBarMenu.prototype.init = function(field) {
var uimenudef = [];
if (Form.SearchBarMenuDef.length > 0) {
uimenudef.push({l:getLocalizedMessage("Fields").JScriptEncode(), v: Form.SearchBarMenuDef});
}
if (Form.SearchBarEnumFields.length > 0) {
uimenudef.push({l:getLocalizedMessage("Selection Values").JScriptEncode(), v : Form.SearchBarEnumFields});
}
var keywords = [];
for (var k in ARKWValues) {
keywords.push({v:"$" + ARKWValues[k].n + "$", l:ARKWValues[k].n});
}
keywords.sort(function(a, b) {return a.l.toLowerCase().localeCompare(b.l.toLowerCase());})
uimenudef.push({l:getLocalizedMessage("Keywords").JScriptEncode(), v:keywords});
uimenudef.push({l:getLocalizedMessage("Currency Codes").JScriptEncode(), v:currencyMenu});
SearchBarMenu.superclass.init.call(this, uimenudef);
this.mField=field; 
}
SearchBarMenu.prototype.Open = function(adjacent_element) {
;
SearchBarMenu.superclass.Open.call(this, adjacent_element, 3, 30100, false);
}
SearchBarMenu.prototype.HandleSelection = function(val) { 
;
this.mField.InsertAtCaret(val);
}
DSearchBar.prototype=new Field(); DSearchBar.prototype.constructor=DSearchBar; DSearchBar.superclass=Field.prototype;;
DSearchBar.prototype.Snapshot=DSearchBar.prototype.Restore=function() {}
DSearchBar.prototype.mDOMField=DSearchBar.prototype.mHaveVisualCharacteristics=true;
DOMFieldFactories["SearchBar"]=function(id,n) {
return new DSearchBar(id,n);
}
function DSearchBar(id,n) {
if(arguments.length)
this.init(id,n);
}
DSearchBar.prototype.mID = 1005;
DSearchBar.prototype.height = 100;
DSearchBar.buttons=[["(",")",'\"'],["+","-","*","/","%"],["=","!=","&lt;","&gt;","&lt=","&gt=","LIKE"],["AND","OR","NOT"]];
function CreateAdvancedSearchBar() {
var f=F(1005);
var e=f.mObj;
var btn=[];
btn.push(e.innerHTML);
btn.push("<table class=SearchBarOperators width=100%><tr height=20>");
var sbut=DSearchBar.buttons;
btn.push("<td>&nbsp;</td>"); 
var tds="<td class=SearchBarButtonCell>";
var as="<a href=javascript: style='text-align:center;position:static;width:28px;height:19px;padding-top:1px' class='btn btn3d'";
var etag=">";
var tdae="</a></td>";
var ecell="<td>&nbsp;</td>";
for(var i in sbut) {
for(var j in sbut[i]) {
btn.push(tds);
btn.push(as);            
btn.push(etag);
btn.push(sbut[i][j]);
btn.push(tdae);
}
btn.push(ecell); 
}
btn.push("</tr></table>");
btn.push("<table class=SearchBarInput width=100%><tr>");
btn.push("<td width><textarea style='width:99%;height:21;' class=sr cols='' wrap=off rows=1 ");
btn.push("id=arid" + 1005);
btn.push("></textarea></td>");
btn.push("<td width=70>");
btn.push("<a href=javascript: style='position:static;height:19px;width:70px;text-align:center' class='btn btn3d menu'");
btn.push(">");
btn.push(getLocalizedMessage("Fields") + "&nbsp;<img style=border:none alt='' src='"+RelContextPath+"resources/images/menu_down.gif'></a></td></tr></table>");
e.innerHTML = btn.join("");
}
DSearchBar.prototype.DOMClick = function(evt) {
;
if (this.GAccess() == 3)
return;
var e=FakeButton_Find(evt.element);
if (e) {
if(e.className.indexOf("menu")!=-1) { 
if (!this.mMenu)
this.mMenu = new SearchBarMenu(this);
this.mMenu.Open(e, 3);
} else {
var str=e.firstChild.data;
if(str!='"'&&str!='%') 
str=" "+str+" ";
this.InsertAtCaret(str);
}
}
}
DSearchBar.prototype.DOMKeyPress = function (evt) {
;
if (evt.key==13) {
evt.StopDefault();
}
}
DSearchBar.prototype.GetEditor = function() {
return this.mObj.getElementsByTagName("textarea")[0];
}
DSearchBar.prototype.SVis=function(val) {
DSearchBar.superclass.SVis.call(this, val);
if (QBPane&&QBPane.GVis()!=val) {
QBPane.SVis(val);
FormPane.Layout();
if (val == true) {
Form.LastFormFID = 0;
}
}
}
DSearchBar.prototype.VisClick=function(val) {
this.mKeepOpen = !this.GVis();
this.SVis(!this.GVis());
}
DSearchBar.prototype.InsertAtCaret = function(val) {
var editbox = this.GetEditor();
editbox.focus(); 
DSearchBar.superclass.InsertAtCaret.call(this,editbox,val);
new WorkflowContext({t:FocusMgr, f:FocusMgr.SetFocusToField, a:[this.mID]});
}
DSearchBar.prototype.TracksCaret = true;
DSearchBar.prototype.Clear=function() {
this.GetEditor().value="";
}
DSearchBar.prototype.DoSet=DSearchBar.prototype.DoSLoadEntry=function(val) {
;
this.GetEditor().value = val.toString();
}
DSearchBar.prototype.G = function() {
var val = this.GetEditor().value;
val = val.trim(1 | 2);
if (val == "") return Null;
return new CharType(this.GetEditor().value);
}
DSearchBar.prototype.GetFocusElement = function() {
return this.GetEditor();   
}

DateKWType.prototype=new TimeType(); DateKWType.prototype.constructor=DateKWType; DateKWType.superclass=TimeType.prototype;;
function DateKWType() {
this.init();
}
DateKWType.prototype.init = function() {
var t = new Date().UnixTimestamp();
var dateString = new TimeType(t).toString(2);
this.mValue = new TimeType(dateString).toInteger();
}
DateKWType.prototype.toString = function () {
return TimeType.getDateTimeString(this.mValue, 2);
}

TODKWType.prototype=new TODType(); TODKWType.prototype.constructor=TODKWType; TODKWType.superclass=TODType.prototype;;
function TODKWType() {
this.init();
}
TODKWType.prototype.init = function() {
this.mTimestamp = new Date().UnixTimestamp();
TODKWType.superclass.init.call(this, new TimeType(this.mTimestamp).toTOD());
}
TODKWType.prototype.toInteger = function() {
;
return this.mTimestamp;
}
TODKWType.prototype.toDecimal = function() {
;
return new IntegerType(this.toInteger()).toDecimal();
}
TODKWType.prototype.toReal = function() {
;
return this.mTimestamp;
}
TODKWType.prototype.toDate = function() {
return new DateType(new TimeType(this.toInteger()).toDate());
}
TODKWType.prototype.toTOD = function() {
return new TODType(this.mValue);
}

WeekdayKWType.prototype=new Datatype(); WeekdayKWType.prototype.constructor=WeekdayKWType; WeekdayKWType.superclass=Datatype.prototype;; 
function WeekdayKWType() {
this.init();
}
WeekdayKWType.prototype.init = function() {
var t = new Date().UnixTimestamp();
var dateString = new TimeType(t).toDate();
this.mValue = new TimeType(dateString).toInteger();
}
WeekdayKWType.prototype.isNull = false;
WeekdayKWType.prototype.toInteger = function() {
;
var dateObj  = new ARDate();
dateObj.STimestamp(this.mValue);
return dateObj.GDay();
}
WeekdayKWType.prototype.toDecimal = function() {
;
return new IntegerType(this.toInteger()).toDecimal();
}
WeekdayKWType.prototype.toReal = function() {
;
return this.toInteger();
}
WeekdayKWType.prototype.toString = function (a) {
var dateObj  = new ARDate();
dateObj.STimestamp(this.mValue);
return dateObj.DayLong();
}
WeekdayKWType.prototype.toPrimitive = function () {
;
return this.mValue.toString();
}
WeekdayKWType.prototype.toTOD = function() {
;
return new TimeType(this.mValue).toTOD();
}
WeekdayKWType.prototype.toTime = function() {
;
return new TimeType(this.mValue);
}
WeekdayKWType.prototype.toDate = function() {
;
return new DateType(new TimeType(this.mValue).toDate());
}
WeekdayKWType.prototype.EQ = function(a) {
return new CharType(this.toString()).EQ(a);
}
WeekdayKWType.prototype.NE = function(a) {
return new CharType(this.toString()).NE(a);
}
WeekdayKWType.prototype.LT = function(a) {
return new CharType(this.toString()).LT(a);
}
WeekdayKWType.prototype.LE = function(a) {
return new CharType(this.toString()).LE(a);
}
WeekdayKWType.prototype.GT = function(a) {
return new CharType(this.toString()).GT(a);
}
WeekdayKWType.prototype.GE = function(a) {
return new CharType(this.toString()).GE(a);
}
WeekdayKWType.prototype.LIKE = function(a) {
return new CharType(this.toString()).LIKE(a);
}

DefaultKWType.prototype=new Datatype(); DefaultKWType.prototype.constructor=DefaultKWType; DefaultKWType.superclass=Datatype.prototype;;
DatatypeFactories[1] = function(val) {
return new DefaultKWType(val);
}
function DefaultKWType(a) {
if(arguments.length && !(typeof a == "undefined"))
this.init(a);
}
DefaultKWType.prototype.init = function(val) {
;
if (val instanceof Datatype) {
;
this.mValue = val.toChar();
} else if (typeof val == "string")
this.mValue = val;
else
this.mValue = val;
}
DefaultKWType.prototype.type = 1;
DefaultKWType.prototype.isNull = false;
DefaultKWType.prototype.toString = function() {
;
return this.mValue;
}
DefaultKWType.prototype.toPrimitive = function() {
;
return this.mValue;
}

DAlertList.prototype=new DTable(); DAlertList.prototype.constructor=DAlertList; DAlertList.superclass=DTable.prototype;;
DOMFieldFactories["AlertList"]=function(id,n) {
return new DAlertList(id,n);
}
function DAlertList(id,n) {
if(arguments.length)
this.init(id,n);
}
DAlertList.prototype.init=function(id,n) {
DAlertList.superclass.init.call(this,id,n);
;
if (AlertInfo.servers.length == 0) {
;
;
AlertInfo.servers.push(ExpandServerName(this.mObj.getAttribute("ARServer")));
AlertInfo.schemas.push(ExpandSchemaName(this.mObj.getAttribute("ARSchema")));
}
}
DAlertList.prototype.InstantiateUI=function() {
DAlertList.superclass.InstantiateUI.call(this);
if (ARPrefsGetAsNumber(24001) != 0) {
NodeWrite(this.mFtrRObj, this.mObj.getAttribute("ARAutoRefStr"));
var al = this;
setInterval(function() { new WorkflowContext([{f:al.Refresh, t:al, a:[-1,0,false]}]); }, ARPrefsGetAsNumber(24001) * 60 * 1000);
}
}
DAlertList.prototype.Refresh=function(startrow,numrows,fromchunk) {

;
return this.RefreshTable(startrow, numrows, fromchunk, function(start, maxrows) {

var qual = this.mObj.getAttribute("ARQual");
;
eval("qual="+qual); 
var results = [];
for (var i = 0; i < AlertInfo.servers.length; ++i) {
qual = ExpandQualifier(qual, AlertInfo.schemas[i], AlertInfo.servers[i]);
res = new NDXGetTableEntryList(ARKWGetStringByIdx(7),ARKWGetStringByIdx(6),ARKWGetStringByIdx(17),
this.mID,AlertInfo.servers[i], AlertInfo.schemas[i],((ARKWGetStringByIdx(21) != null) ? ARKWGetStringByIdx(21) : ""),start,maxrows,
[], qual.qual, qual.fieldids, qual.fieldvals, qual.fieldtypes);
results[i] = res.result;
}
var serveridx = F(718).mObj.dataidx;
var result = {f:results[0].f,r:[],idmap:{}};
var id = 0;
for (var i = 0; i < results.length; ++i) {
for (var j = 0; j < results[i].r.length; ++j) {
var tag=results[i].r[j].i+AlertInfo.servers[i]; 
var newrow = {eid:results[i].r[j].i, aid:i, i:tag, d:results[i].r[j].d,rc:results[i].r[j].rc};
if (newrow.d[serveridx].p == "@")
newrow.d[serveridx].p=newrow.d[serveridx].v=AlertInfo.servers[i];
result.r.push(newrow);
result.idmap[tag] = id;
++id;
}
}
result.n = id;
return {result:result};
});
}
DAlertList.prototype.ARDrillDown=function(xy,fromlink) {
; 
;
; 
if(!this.mObj.getAttribute("ARDrill"))
return ExecuteWorkflow(2,this.mID);
var oldrow = this.GetRow();
this.SetRow(xy.y);
var server = F(718).G().toString();
var schema = F(717).G().toString();
var request = F(716).G().toString();
this.SetRow(oldrow);
if (schema == "" || request == "") {
schema = DAlertList.findSchemaName(server);
if (schema == "" && server != "")
{
var idx = server.indexOf(".");
if (idx != -1)
{
schema = DAlertList.findSchemaName(server.substring(0,idx));
}
}
;
request = this.mResult.r[xy.y].eid;
}
return {n:[{f:function(table) {
return OpenNonModalForm(false,server,schema,"", {
fvlist:null, wMode:4,wForceClear:1,qual:{qual:"4\\1\\1\\1\\2\\4\\" + request.length + "\\" + request + "\\",fieldids:[],fieldvals:[],fieldtypes:[]}});
},a:[this]},
{f:ExecuteWorkflow,a:[2,this.mID]}]};
}
DAlertList.findSchemaName=function(server) {
for (var i = 0; i < AlertInfo.servers.length; ++i) {
if (AlertInfo.servers[i] == server) {
return AlertInfo.schemas[i];
}
}
return "";
}
DAlertList.prototype.GetSelectedAlerts = function() {
var ids = this.GetSelectedRows();
var alerts = [];
for (var i = 0; i < AlertInfo.servers.length; ++i)
alerts[i] = [];
if (ids.length > 0) {
for (var i = 0; i < ids.length; ++i)
alerts[this.mResult.r[ids[i]].aid].push(this.mResult.r[ids[i]].eid);
}
return alerts;
}
DAlertList.prototype.MarkRead=function(read) {

;
;
; 
var alerts = this.GetSelectedAlerts();
for (var i = 0; i < AlertInfo.servers.length; ++i) {
if (alerts[i].length > 0)
new NDXMarkAlert(AlertInfo.servers[i], AlertInfo.schemas[i], alerts[i], read);
}
return this.Refresh(-1, 0, false); 
}
DAlertList.prototype.DeleteSelected=function() {
;
; 

var alerts = this.GetSelectedAlerts();
for (var i = 0; i < AlertInfo.servers.length; ++i) {
if (alerts[i].length > 0)
new NDXDeleteEntry(AlertInfo.servers[i], AlertInfo.schemas[i], alerts[i]);
}
return this.Refresh(-1, 0, false); 
}
DAlertList.prototype.Resort=function(col, dir) {
return DTable.superclass.Resort.call(this, col, dir);
}
DAlertList.prototype.GetInitialRowSortOrder=function() {
var sortorder = this.mObj.getAttribute("ARSort");
if (sortorder!="") {
DAlertList.superclass.GetInitialRowSortOrder.call(this);
} else 
return {col:-1,dir:1};
}
DAlertList.prototype.SetRowSortOrder=function(col,dir) {
;
if(this.mSortOrder.length>=2&&col==this.mSortOrder[0]&&dir==this.mSortOrder[1])
return null; 
if (!this.mResult)
return null; 
if (this.mSortOrder.length == 2 && col==this.mSortOrder[0]&&dir!=this.mSortOrder[1]) { 
this.RebuildSortOrder(col, dir);
this.mResult.r.reverse();
} else { 
this.RebuildSortOrder(col, dir);
var sortfunc = ["var ls,rs,"];
for (var i = 0; i < this.mSortOrder.length + 2; i+=2) {
var sortcol = this.mSortOrder[i];
if (i >= this.mSortOrder.length || sortcol == -1) {
sortfunc.push("v=l.i.localeCompare(r.i);");
} else {
var sortdir = this.mSortOrder[i+1];
var sorter = this.mColFields[sortcol].GetSorter();
sorter = sorter.replace(/([lr])hs/g, function (sub, p1) { return (((p1=="l") ^ (sortdir==1)) ? "r" : "l") + ".d[" + sortcol + "].p";});
sortfunc.push("v=" + sorter + ";");
}
if (i == this.mSortOrder.length - 2)
sortfunc.push("return v;");
else
sortfunc.push("if(v!=0) return v;");
}
sortfunc = sortfunc.join("");
CompileFunction(sortfunc,"l,r",{});
var sorter=CompiledFunction;
this.mResult.r.sort(sorter);
}
var idmap = {};
var rows = this.mResult.r;
for (var i = 0; i < rows.length; ++i)
idmap[rows[i].i] = i;
this.mResult.idmap = idmap;
}

function ARProcessEvent(etype,edata,srcw) {
this.mEventType=etype;
this.mEventData=edata;
this.mSrcWinID=srcw;
}
ARProcessEvent.MIncomingQ=[];
ARProcessEvent.Add=function(type,data,srcid) {
window.self.ARProcessEvent.MIncomingQ.push(new ARProcessEvent(type,data,srcid));
}
ARProcessEvent.InitKeywordsEtc=function() {
ARKWSet(34,window.name);
ARKWSet(35,window.name);
if(AREventFunction(1048576)) {
setInterval(function() {
var q=ARProcessEvent.MIncomingQ,dead=[];
for(var i in q) {
var qi=q[i];
ARKWSet(33,qi.mSrcWinID);
ARKWSet(32,qi.mEventType);
ARKWSet(42,qi.mEventData);
new WorkflowContext({f:ExecuteWorkflow,a:[1048576]});
dead.push(i);
}
for(var i in dead)
delete ARProcessEvent.MIncomingQ[dead[i]];
},200);
}
}
ARProcessEvent.MFieldIDRE=/^F([0-9]+)$/;
ARProcessEvent.DeliverEvent=function(cmd,etype, edata) {
var winlist=[];
var fa;
if(cmd=="@")
winlist.push(weGetOpener());
else if(cmd=="#")
winlist=weGetChildWindows();
else if(cmd=="*")
winlist=weGetAllWindows();
else if ((fa=cmd.match(ARProcessEvent.MFieldIDRE))!=null) {
var fid = fa[1];
if (fid in Fields) {
if ("HandleEvent" in Fields[fid])
Fields[fid].HandleEvent(etype, edata);
}
} else
winlist.push(weGetWindowByName(cmd));
for(var i in winlist) {
var wi=winlist[i];
if(wi!=null&&wi&&!wi.closed&&"ARProcessEvent" in wi) {
wi.ARProcessEvent.Add(etype,edata,window.name);
}
}
}

SearchesMenu.prototype=new Menu(); SearchesMenu.prototype.constructor=SearchesMenu; SearchesMenu.superclass=Menu.prototype;;
function SearchesMenu() {
this.init();
}
SearchesMenu.prototype.init = function() {
var menudef = [];    
SearchesMenu.superclass.init.call(this, menudef);
}
SearchesMenu.prototype.Open = function(adjacent_element, pref) {
var RunDefinedMenuDef = [];
var RunSavedMenuDef = [];
var RunRecentMenuDef = [];
var LoadDefinedMenuDef = [];
var LoadSavedMenuDef = [];
var LoadRecentMenuDef = [];
this.mMenuDef = []; 
for (var j=0; j<Form.DefinedSearch.length; j++) {
RunDefinedMenuDef.push({l:Form.DefinedSearch[j].l.HTMLEncode(), v:"SavedSearches.LoadSearch(Form.DefinedSearch["+j+"].v, true)"});
LoadDefinedMenuDef.push({l:Form.DefinedSearch[j].l.HTMLEncode(), v:"SavedSearches.LoadSearch(Form.DefinedSearch["+j+"].v, false)"});
}
var name;
for (name in userSearches.Saved) {
if (search = userSearches.Saved[name].disable==0) {  
var val = "SavedSearches.LoadSearch(userSearches.Saved['"+name.EscapeQuote()+"']";
val = val.HTMLEncode();
RunSavedMenuDef.push({l:name.HTMLEncode(), v:val+", true)"});
LoadSavedMenuDef.push({l:name.HTMLEncode(), v:val+", false)"});
}
}
for (var i in userSearches.Recent) {
var label = userSearches.Recent[i].l.HTMLEncode();
RunRecentMenuDef.push({l:label, v:"SavedSearches.LoadSearch(userSearches.Recent["+i+"].v, true)"});
LoadRecentMenuDef.push({l:label, v:"SavedSearches.LoadSearch(userSearches.Recent["+i+"].v, false)"});
}
this.mMenuDef.push({l:getLocalizedMessage("Run Defined").JScriptEncode(), v: (RunDefinedMenuDef.length==0?"":RunDefinedMenuDef), s:(RunDefinedMenuDef.length==0?0:1)});
this.mMenuDef.push({l:getLocalizedMessage("Run My Searches").JScriptEncode(), v: (RunSavedMenuDef.length==0?"":RunSavedMenuDef), s:(RunSavedMenuDef.length==0?0:1)});
this.mMenuDef.push({l:getLocalizedMessage("Run Recent").JScriptEncode(), v: (RunRecentMenuDef.length==0?"":RunRecentMenuDef), s:(RunRecentMenuDef.length==0?0:1)});
this.mMenuDef.push({l:getLocalizedMessage("Load Defined").JScriptEncode(), v: (LoadDefinedMenuDef.length==0?"":LoadDefinedMenuDef), s:(LoadDefinedMenuDef.length==0?0:1)});
this.mMenuDef.push({l:getLocalizedMessage("Load My Searches").JScriptEncode(), v: (LoadSavedMenuDef.length==0?"":LoadSavedMenuDef), s:(LoadSavedMenuDef.length==0?0:1)});
this.mMenuDef.push({l:getLocalizedMessage("Load Recent").JScriptEncode(), v: (LoadRecentMenuDef.length==0?"":LoadRecentMenuDef), s:(LoadRecentMenuDef.length==0?0:1)});
this.mMenuDef.push({l:getLocalizedMessage("Save Search ...").JScriptEncode(), v:"SaveSearch", s:(userSearches.lastSearch==null?0:1)});
this.mMenuDef.push({l:getLocalizedMessage("Manage My Searches ...").JScriptEncode(), v:"ManageSearch", s:1});
SearchesMenu.superclass.Open.call(this, adjacent_element, pref, 30100, false);
}
SearchesMenu.prototype.HandleSelection = function(val) {
;
if (val == "SaveSearch")
new WorkflowContext ({f:this.OpenSaveSearchPopup});
else if (val == "ManageSearch")
new WorkflowContext ({f:this.OpenManageSearchPopup});
else
eval(val);
}
SearchesMenu.prototype.OpenSaveSearchPopup = function() {
var menuDef = [];
for (var name in userSearches.Saved) {
menuDef.push(name.HTMLEncode());
}
var res = {};
return {n:{f:function() {
;
if ("v" in res.result) {
var name = res.result.v;
if (name!=null && name.length>0) {
return {n:{f:function() {
var newsearch = ((name in userSearches.Saved)? false: true);
var req = new NDXSaveSearch(name.toString(), ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), userSearches.lastSearch.ids, userSearches.lastSearch.vals, newsearch, false, 0, 1);
if (req.GetResult()) {
userSearches.Saved[name] = {"ids":userSearches.lastSearch.ids, "vals":userSearches.lastSearch.vals, "disable":0};
userSearches.lastSearch = null;
}
}},
c:{f:function() { if (userSearches.lastSearch == null)
return {c:{t:StateMgr,f:StateMgr.QueryEntry, a:[100, false]}} 
}}
}
}
}
}, a:[res]}, c:{f:function() {
return SaveSearchPopup(res, menuDef);
}}};
}
SearchesMenu.prototype.OpenManageSearchPopup = function() {
var res = {};
var data = {};
data.h = [getLocalizedMessage("Search Name"), getLocalizedMessage("State")];
data.r = [];
var name;
for (name in userSearches.Saved) {
data.r.push({"i":name,d:[{v:name},{v:(userSearches.Saved[name].disable==1?getLocalizedMessage("Disable"):getLocalizedMessage("Enable"))}]});
}
return {n:{f:function() {
;
if ("v" in res.result && res.result.v!=-1) {
var deleted = [];
var modified = {};
var name;
for (name in userSearches.Saved) {
if (!(name in res.result.v))
deleted.push(name);
else if (userSearches.Saved[name].disable!=res.result.v[name])
modified[name]=res.result.v[name];
}
if (deleted.length > 0) {
var req = new NDXDeleteSearch(ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), deleted);
if (req.GetResult()) {
for (var i=0; i<deleted.length; i++)
delete userSearches.Saved[deleted[i]];
}
}
for (name in modified) {
var req = new NDXSaveSearch(name.toString(), ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), [], [],false, true, modified[name], 1);
if (req.GetResult())
userSearches.Saved[name].disable = modified[name];
}
}
}, a:[res]}, c:{f:function() {
return ManageSearchPopup(res, data);
}}};
}
function SavedSearches(n) {
this.RecentSize = n;
}
SavedSearches.prototype.lastSearch = null;
SavedSearches.prototype.Saved = null;
SavedSearches.prototype.Recent = [];
SavedSearches.prototype.RecentSize; 
SavedSearches.PSP = /\${1}[^\$]+\${1}/g;
SavedSearches.QBEPSP = /^\${1}[^\$]+\${1}$/g;
SavedSearches.prototype.SaveRecent = function(qbefields, paramsearchflds, advbarStr) {
this.lastSearch = {};
this.lastSearch.ids=[];
this.lastSearch.vals=[];
var label=[];
var id;
var first = true;
for (id in qbefields) {
var f = F(id);
;
this.lastSearch.ids.push(parseInt(id));
var v = f.GetScreenValue();
this.lastSearch.vals.push(v);
if (f instanceof DataField) {
if (!first)
label.push(",");
first = false;
var l = f.GLabel();
if (l=="")
l = f.GName();
label.push(l);
label.push("=");
label.push(v);
}
}
for (id in paramsearchflds) {
if (id.isNumeric()) {
this.lastSearch.ids.push(parseInt(id));
this.lastSearch.vals.push('$'+paramsearchflds[id]+'$');
}
}
if (advbarStr.length>0) {
this.lastSearch.ids.push(1005);
this.lastSearch.vals.push(advbarStr);
if (!first)
label.push(",");
label.push(advbarStr);
}   
if (paramsearchflds==null) {
label = label.join("");
var len = label.length;
if (len==0)
label = getLocalizedMessage("<No Search Criteria>");
else if (len > 65)
label = label.substr(0, 65);
var exists = false;
for (var i=0; i<this.Recent.length; i++) {
if (this.Recent[i].l==label) {
if (this.Recent[i].v.ids.length == this.lastSearch.ids.length &&
this.Recent[i].v.ids.toString() == this.lastSearch.ids.toString() &&
this.Recent[i].v.vals.toString() == this.lastSearch.vals.toString()) {
exists = true;
break;
}
}
}
if (!exists) {
try {
var req;
if (this.Recent.length>=this.RecentSize) {
req = new NDXDeleteSearch(ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), []);
if (req.GetResult()) {
this.Recent.pop();
}
}
;
req = new NDXSaveSearch(label, ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), this.lastSearch.ids, this.lastSearch.vals, true, false, 0, 0);
if (req.GetResult())
this.Recent.splice(0, 0, {l:label, v:this.lastSearch});
} catch (ignore) {
}
}
}
}
SavedSearches.LoadSearch = function(search, run) {
;
;
;
new WorkflowContext({f:function() {
var stk={};
stk.c={f:FormAction_NewSearch};
stk.n = {f:function() {
Field_Clear(false);
for (var i=0; i<search.ids.length; i++) {
if (search.ids[i] in Fields) {
var f = Fields[search.ids[i]];
if (search.ids[i]==1005) {
f.SVis(true);
f.S(new CharType(search.vals[i]));
} else {
var val = search.vals[i];
if (val.match(SavedSearches.QBEPSP))
f.SetScreenValue(val);
else {
var op=null;
op = Field.GetQBEOperator(val);
if (op!=null)
val = val.substring(op.length).trim(1);
val = Datatype_Factory({"t":4,"v":val,a:{}});
f.S(val);
if (op!=null) 
f.SetScreenValue(op+f.GetScreenValAsPrimitive());
}
}
}
}
if (run)
return FormAction_Query();
}}
return stk;
}});
}

TableSettingsMenu.prototype=new Menu(); TableSettingsMenu.prototype.constructor=TableSettingsMenu; TableSettingsMenu.superclass=Menu.prototype;;
function TableSettingsMenu(tableObj) {
this.init(tableObj);
}
TableSettingsMenu.prototype.init = function(tableObj) {  
var menudef = [];  
this.mTableObj = tableObj;
SearchesMenu.superclass.init.call(this, menudef);
}
TableSettingsMenu.prototype.Open = function(adjacent_element, pref) {
var showColsMenu=[];
var hideColsMenu=[];
this.mMenuDef = []; 
var colData = this.mTableObj.mColDatas;
for (var i=0; i<colData.length; i++) {
if (!colData[i].mVisible)
continue;
if (colData[i].mWidth==0)
showColsMenu.push({l:colData[i].mHeader.firstChild.data.HTMLEncode(),v:"this.showColumn("+i+")"});
else
hideColsMenu.push({l:colData[i].mHeader.firstChild.data.HTMLEncode(),v:"this.hideColumn("+i+")"});
}
this.mMenuDef.push({l:getLocalizedMessage("Add Column").JScriptEncode(), v:(showColsMenu.length==0?"":showColsMenu), s:(showColsMenu.length==0?0:1)});
this.mMenuDef.push({l:getLocalizedMessage("Remove Column").JScriptEncode(), v:(hideColsMenu.length<=1?"":hideColsMenu), s:(hideColsMenu.length<=1?0:1)});
this.mMenuDef.push({l:getLocalizedMessage("Reset").JScriptEncode(),v:"this.reset()", s:1});
this.mMenuDef.push({l:getLocalizedMessage("Save").JScriptEncode(),v:"this.save()", s:(tablePrefs==null?0:1)});
this.mXAdjust=1;
this.mYAdjust=1;
TableSettingsMenu.superclass.Open.call(this, adjacent_element, pref, 30100, false);
}
TableSettingsMenu.prototype.HandleSelection = function(val) {
eval(val);
}
TableSettingsMenu.prototype.showColumn = function(index) {
;
var widths=this.mTableObj.GetInitialColumnWidths();
this.mTableObj.mColDatas[index].mWidth=(widths[index]<5?5:widths[index]);
if (!this.mTableObj.mHScroll) 
this.mTableObj.ScaleSizes(); 
this.mTableObj.ApplySizes();
this.mTableObj.UpdateScrollOffset();
}
TableSettingsMenu.prototype.hideColumn = function(index) {
;
var lastcol=this.mTableObj.mColCnt-1;
while(lastcol>=0&&(!this.mTableObj.mColDatas[lastcol].mVisible || this.mTableObj.mColDatas[lastcol].mWidth<=0))
--lastcol;
if (index == lastcol) {
var previousCol = index-1;
while (previousCol>=0 && (!this.mTableObj.mColDatas[previousCol].mVisible || this.mTableObj.mColDatas[previousCol].mWidth<=0))
previousCol--;
this.mTableObj.mColDatas[previousCol].mWidth += this.mTableObj.mColDatas[index].mWidth;
}
this.mTableObj.mColDatas[index].mWidth=0;
this.mTableObj.ApplySizes();
this.mTableObj.UpdateScrollOffset();
}
TableSettingsMenu.prototype.reset = function() {
this.mTableObj.ResetColData();
if (!this.mTableObj.mNotRefreshed)
new WorkflowContext ({t:this.mTableObj, f:this.mTableObj.Resort, a:[-2, 1]})
}
TableSettingsMenu.prototype.save = function() {
var colids = [];
var colwidths = [];
var colData = this.mTableObj.mColDatas;
var colFlds = this.mTableObj.mColFields;
for (var i=0; i<colData.length; i++) {
colids.push(colFlds[colData[i].mDataCol].mID);
colwidths.push(colData[i].mWidth);
}
var sortOrder = this.mTableObj.mSortOrder;
;
var sortStr = ""
if (sortOrder.length>0) {
sortStr = (sortOrder.length/2) + "|";
for (var i=0; i<sortOrder.length; i+=2) {
sortStr += (sortOrder[i+1]<0? "-"+colFlds[sortOrder[i]].mID : "+"+colFlds[sortOrder[i]].mID) + "|";
}
}
var req = new NDXSaveTableSettings(ARKWGetStringByIdx(7), ARKWGetStringByIdx(6), ARKWGetStringByIdx(17), this.mTableObj.mID , colids, colwidths, sortStr);
}
TableSettingsMenu.prototype.mTableObj;

function SaveSearchPopup(res, menuDef) {
;
var title = getLocalizedMessage("Save or Redefine Search");	
var label = getLocalizedMessage("Search Name");	
var description = getLocalizedMessage("Enter a new name, or select a saved search to redefine");
return weOpenModalPopup((AbsContextPath + "resources/html/SaveSearchPopup.html"),"SaveSearch",{title:title, appss:GetAppStyleSheet("../../"), label:label, name:name, menu:menuDef, desc:description}, res, [400,150]);
}

function ManageSearchPopup(res, data) {
;
var title = getLocalizedMessage("Manage Search");	
return weOpenModalPopup((AbsContextPath + "resources/html/ManageSearchPopup.html"),"ManageSearch",{title:title, appss:GetAppStyleSheet("../../"), l:data}, res, [400,250]);
}

function ParamSearchPopup(res, fieldlist) {
;
var label = getLocalizedMessage("Enter Search Values");	
var title = getLocalizedMessage("Parameterized Search");
var cnt = 0;
for (var id in fieldlist) {
cnt++;
}
var height = (cnt * 25) + 125;
return weOpenModalPopup((AbsContextPath + "resources/html/ParamSearchPopup.html"),"ParameterizedSearch",{appss:GetAppStyleSheet("../../"), title:title, label:label, fl:fieldlist}, res, [500,height]);
}


