/* wig.skcip
fsSplit    	4544	21.28%	625ms	812.5ms	0.179ms	0ms	78.125ms	lite20gg.js (line 1039)
nsFromOjText	1904	15.43%	453.125ms	453.125ms	0.238ms	0ms	250ms	lite20gg.js (line 7798)
TOsplit	        16204	6.38%	187.5ms	187.5ms	0.012ms	0ms	78.125ms	lite20gg.js (line 1033)
srcDecode	480	6.38%	187.5ms	218.75ms	0.456ms	0ms	187.5ms	lite20gg.js (line 1333)
decodeInst	1440	6.38%	187.5ms	2296.875ms	1.595ms	0ms	250ms	lite20gg.js (line 3422)
popDecode	240	4.79%	140.625ms	984.375ms	4.102ms	0ms	250ms	lite20gg.js (line 1058)
TOwif    	1440	3.72%	109.375ms	156.25ms	0.109ms	0ms	15.625ms	lite20gg.js (line 3369)
wigSbyId	224	3.19%	93.75ms	781.25ms	3.488ms	0ms	93.75ms	lite20gg.js (line 5702)
evtMouseMoveA	169	2.66%	78.125ms	78.125ms	0.462ms	0ms	15.625ms	lite20gg.js (line 7052)
insert  	113	2.13%	62.5ms	62.5ms	0.553ms	0ms	15.625ms	lite20gg.js (line 4625)
EdQdbDecodeStat	1440	2.13%	62.5ms	62.5ms	0.043ms	0ms	15.625ms	lite20gg.js (line 4280)
bldDataList	2	2.13%	62.5ms	2437.5ms	1218.75ms	0ms	2437.5ms	lite20gg.js (line 4956)
TOwin	        178	2.13%	62.5ms	93.75ms	0.527ms	0ms	15.625ms	lite20gg.js (line 6586)
decodeActHdr	240	2.13%	62.5ms	62.5ms	0.26ms	0ms	15.625ms	lite20gg.js (line 985)
*/
<!--hide 
/*
  Owin - Page (window,document,body)
  Onav - Navigation
  Ojax - Ajax transfers
  Owig - Edit question
  Owif - Field of edit question
  Otmr - Tmo requirement
  Otmo - Tmo control
  Otmi - Field of Tmo control
  Olnk - Url splitup
  Opid - Pick identification, encoded form stored on control choice
  OSrc - pick list source, nsa search result or recent/full population
  Oparse - Serially parsed string
  Delimiter usage
  W  - components within Y encoding ( no nesting )
  X  - ??? 
  Y  - length encoding eg Y5Yabcde
  Z  - ojtext ??
*/
var gEvents = '';
var elCurTbm = null;
var gDropFromTdEl = null;
var gFromL1Tr = null;
var gMouseClientX = 0;
var gMouseClientY = 0;
var gStartCnt = 0;
var gResetCnt = 4;
var gToElTbh = null;
var gOnTbm = null;
var gCopOnEl = null;
var gOnCopB = false;
var gSlideBackB = false;
var gTypeNolois = null;
var gJustUp = false;
var gPin = 'p';
var gNoPin = 'n';
var gWindowHeight = 0;
var gspWindowWidth = 0;
var gTestMsg = '/common/wtest.html';
var gThisCaseB = false;
var gNeedConfirmB = true;
var gTimeOutId = 0;
//
var fileTypes=[ "bmp","gif","png","jpg","jpeg" ];
var gModWin = null;
var cals = new Array();
//
//
var KXnoStNoChange = 0;
var KXnoStMinimized = 1;
var KXnoStClosed = 2;
var KXnoStOpen = 3;
//
var gNod1 = null;
var gRefocusEl = null;
var gLogS = "";
var gFocusTextEl = null;
var gBlurUnoEl = null;
var gOpenRootIdEl = null;
var gOpenSelfIdEl = null;
var gDragIdEl = null;
var gXnoCnt = 20; // size of uno select list
//
// var gHideFs = "\x1E"; // FS
var gXnoStartN = 1;
//
var gSetFocusB = false;  // trap onclick resulting from text onfocus
var gNsaSearchS = "";
var gNsaReSearchS = "";
var gKeyTargEl = null;
var gTimeOutCnt = 0; // retry count server busy with prior nsa requist 
//
var EKscliAll = 0;
var EKscliPart = 1;
var EKscliSearch = 2;
var EKscliToMany = 3;
//
var KSearchNotReqd = 0;
var KSearchByPrefix = 1;  
var KSearchByWord = 2; 
var gAOkel = [];
//
var gDragHelper = null;
var gDragFromEl = null;
var gDragOfsX = 0;
var gDragOfsY = 0;
//
var gKreqShow = 1;
var gKreqEdit = 2; 
var gKreqClone = 3; 
var gKreqNew = 4; 
var gKreqNew2 = 5; 
var gKreqRemove = 6; 
var gKreqCheck = 7; 
//
var gKptNewWindow = 1;
var gKptReplace = 2;
var gKptNext = 3;
//
var gEventCnt = 0;
var gbldRequiredN = 0;
function KXnoStS( i_KXnoSt ) {
  var aS = '';
  if ( i_KXnoSt === KXnoStMinimized ) { aS = 'KXnoStMinimized'; }
  else if ( i_KXnoSt === KXnoStClosed ) { aS = 'KXnoStClosed'; }
  else if ( i_KXnoSt === KXnoStOpen ) { aS = 'KXnoStOpen'; }
  else { aS = 'KXnoSt:' + i_KXnoSt; }
  return aS;
  }
/* Events ************************** */
// href links
function evtHref( iKjsl, iPartS, iP1, iP2 ) { 
  var aOwin = new TOwin( null, null );
  var aUrl = document.location.href;
  var aOlnk = new TOlnk( aUrl );
  var bUrl, els, el;
  if ( iKjsl === aOlnk.EKjslNone ) {
    // nsJsUrl("' + b_VString + '")
    toPageLoc( iPartS );
    }
  else if ( iKjsl === aOlnk.EKjslInst ) {
    bUrl = aOlnk.replaceInst( iPartS );
    var inxEf = aOlnk.queryStr.indexOf( '&ef=' );
    if ( inxEf > 0  ) {
      alert( 'abandon current edit:' + aOlnk.queryStr );
      var inxEf2 = aOlnk.queryStr.indexOf( '&', inxEf );
      aOlnk.queryStr = aOlnk.queryStr.substr( 0, inxEf ) 
      + aOlnk.queryStr.substr( inxEf2, aOlnk.queryStr.length-inxEf2 );
      alert( 'after:' + aOlnk.queryStr );
      }
    if ( aOlnk.queryStr !== '' ) { bUrl += '?' + aOlnk.queryStr; }
    // alert( 'bUrl:' + bUrl );
    toPageExt( bUrl, false );
    }
  else if ( iKjsl === aOlnk.EKjslView ) {
    bUrl = aUrl.substr( 0, aOlnk.opPosn+1 ) + iPartS  
    + aUrl.substr( aOlnk.qualPosn, aUrl.length-aOlnk.qualPosn );
    toPageExt( bUrl, false );
    }
  else if ( iKjsl === aOlnk.EKjslEdit ) {
    bUrl = iPartS + '&ed='+ gRevision + '&mf=' + edModeFlags();
    document.location = bUrl; // leaves 2 of same in history after new
    }
  else if ( iKjsl === aOlnk.EKjslBookMark ) {
    var aOreq = new TOreq( aOwin );
    aOreq.Kreq = gKreqNew;
    aOreq.urlS = iPartS;
    aOreq.efS = '';
    aOreq.Kpt = gKptNext; // NOT gKptNewWindow, not window refresh after done
    aOreq.directB = true;
    aOreq.extraParS = '&dta=' + document.location.href.nsToOjText(); 
    aOreq.extraParS += '&bkh=' + gHeadingS.nsToOjText(); 
    aOreq.issue(); 
    }
  else if ( iKjsl === aOlnk.EKjslOperation ) {
    gOjax.asDoQs( iPartS, iP1 );
    }
  else if ( iKjsl === aOlnk.EKjslOfsiteLoged ) {
    //function ofUrl( iUrl, iMacro, iVend, iTitle ) {
    gOjax.asDoQs( '?v=' + iP1, '/zzAd.html' , '&t=' + iP2 );
    //exchangeReq( 'http://' + document.location.host + '/zzAd.html?v=' + iP1 
    //+ '&t=' + iP2 );
    toPageExt( iPartS );
    }
  }
//
// window/document/body onXXX events
function evtWindow( iEvent ) {
  var returnB = null;
  var evt = (iEvent) ? iEvent : event;
  gEvents += ' ' + evt.type;
  if ( evt.type !== "mousemove" ) {
    defaultStatus = 'b1 ' + evt.type;
    }
  var aOwin = new TOwin( this, evt );
  // alert( "evtWindow evt.type:" + evt.type );
  if ( evt.type === "load" ) {
    aOwin.evtMainLoad();
    }
  else if ( evt.type === "beforeunload" ) {
    aOwin.evtMainUnLoad();
    }
  else if ( evt.type === "resize" ) {
    aOwin.evtResizing();
    }
  else if ( evt.type === "scroll" ) {
    aOwin.evtNsgChkMore();
    }
  else if ( evt.type === "pageshow" ) {
    aOwin.evtPageShow();
    }
  else if ( evt.type === "mousemove" ) {
    returnB = aOwin.evtMouseMoveA();
    }
  else if ( evt.type === "focus" ) {
    if ( ( gModWin !== null ) && ( gModWin.closed === false ) ) {
      setTimeout("finishChecking()", 50 );
      }
    returnB = true;
    }
  if ( returnB !== null ) { return returnB; }
  }
//
// navigational events onXXX and href
function navEvt( iEl, iEv, iP1, iP2, iP3, iP4 ) {
  var aOnav = new TOnav();
  var returnB = true;
  if ( iEl === null ) { // href group
    if ( iEv === 1 ) {
      aOnav.evtNsdClickOnTbh( iP1, iP2 );
      returnB = null;
      // returnB = false;
      }
    }
  else {
    if ( typeof window.event != "undefined" ) { 
      aOnav.evt = window.event; 
      aOnav.targEl = aOnav.evt.srcElement;
      }
    else { 
      aOnav.evt = iEv; 
      aOnav.targEl = aOnav.evt.target;
      }
    aOnav.charCode = (aOnav.evt.charCode) ? aOnav.evt.charCode :((aOnav.evt.which) ? aOnav.evt.which : aOnav.evt.keyCode);
    if ( iEl.name == "userCookie" ) {
      aOnav.evtNsgStyClick( "c1", iEl.id );
      }
    else if ( iEl.name == "nameToolBar" ) {
      aOnav.evtNsgStyClick( "style", iEl.id );
      }
    else if (( iEl.tagName == "INPUT" )&&( iEl.type == "password" )) {
      if ( aOnav.charCode === 13 || aOnav.charCode === 3 ) {
        aOnav.evtLogOnOff( iEl.parentNode.parentNode, true, false ); // logOn not completed
        aOnav.evt.returnValue = false;
        }
      }
    else if (( iEl.tagName == "INPUT" )
    &&(( iEl.name == "logOn" )||( iEl.name == "logOff" )) ) {
      aOnav.evtLogOnOff( iEl.parentNode.parentNode, ( iEl.name == "logOn" ), false ); // logOn not completed
      }
    }
  if ( returnB !== null ) { return returnB; }
  }
function withinDrop( iEl ) {
  var matchB = false;
  var nxEl = iEl;
  while ( nxEl !== null ) {
    if ( nxEl.id === "idDivXnoDrop" ) { 
      matchB = true; 
      nxEl = null;
      }
    else {
      nxEl = nxEl.parentNode;
      }
    }
  return matchB;
  }
function makeTargOwig( iOwin, iTargEl, iFullB ) {
  var aOwig = null;
  var bOwig = null;
  iOwin.getWigPosns( iTargEl );
  if ( iOwin.rootIdEl !== null ) { 
    aOwig = new TOwig();
    aOwig.fromIdEl( iOwin, iOwin.rootIdEl, iFullB ); 
    if ( aOwig.fullB === true ) { aOwig.summary(); }
    aOwig.Qtype = aOwig.getQtype();
    // bOwig = aOwig.getSubOwig( iOwin.winPathEl );
    if ( iOwin.winPathEl !== null ) {
      var aN = parseInt( iOwin.winPathEl.value, 10 );
      var wigS = wigSbyId( aOwig.rootIdEl.value, aN );
      bOwig = new TOwig();
      bOwig.groupN = aN; // ?? inx-1;
      bOwig.recMakeOwig( null, aOwig.Owin, wigS, false );
      bOwig.selfIdEl = iOwin.clickIdEl;
      bOwig.rootIdEl = iOwin.rootIdEl;
      bOwig.navB = ( aOwig.selfIdEl.id.indexOf( "idEfG" ) !== 0 );
      bOwig.groupN = aOwig.groupN;
      bOwig.groupEl = bOwig.selfIdEl.parentNode;
      // get up groupEl etc
      if ( bOwig.fullB === true ) { bOwig.summary(); }
      bOwig.Qtype = bOwig.getQtype();
      }
    else { bOwig = aOwig; }
    // aOwig.rootOWig = bOwig;
    }
  return bOwig;
  }
//
// edit page+control events
function edEvtXnoAll( iEv ) {
  defaultStatus = 'a1';
  var aReturnB = true;
  var aEv, aTargEl, aOwif;
  var escS = "";
  if ( typeof window.event != "undefined" ) { 
    aEv = window.event; 
    aTargEl = aEv.srcElement;
    }
  else { 
    aEv = iEv; 
    aTargEl = aEv.target;
    }
  defaultStatus += 'a2';
  var aOwin = new TOwin( null, aEv );
  var bS = '';
  if (( aTargEl.tagName !== 'FORM' )
  && ( aTargEl.tagName !== 'BODY' )) {
    bS = " innerHTML:" + aTargEl.innerHTML;
    }
/*
  EdLog( aEv.type 
  + " tag " + aTargEl.tagName + " class " + aTargEl.className
  + " withinDrop " + withinDrop( aTargEl )
  + " gOpenRootIdEl:" + ( gOpenRootIdEl !== null ) + bS
  );
*/
/* */
  var aOwig = makeTargOwig( aOwin, aTargEl, true );
  gThisCaseB = false;
  if ( aEv.type === "mousedown" ) { 
    if ( aOwig !== null ) {
      defaultStatus += "BBBBB" + aOwig.Qtype + aOwig.EQtypeEno;
      // alert( "aa " + defaultStatus );
      if ( aOwig.Qtype === aOwig.EQtypeEno ) {
        // alert( "bb " + defaultStatus );
        aOwig.getGenerated( aTargEl, KXnoStNoChange, 0 );
        if ( ( aOwig.tdEl !== null )&&( aTargEl.className === "zEnoOrder" ) ) {
          // alert( "cc " + defaultStatus );
          gDragIdEl = aOwig.selfIdEl;
          gDragFromEl = aOwig.tdEl;
          aReturnB = false;
          var mX = aOwin.evt.clientX + aOwin.spScrollLeft();
          var mY = aOwin.evt.clientY + aOwin.spScrollTop();
          gDragOfsX = mX - aOwin.spGetOffsetLeft( gDragFromEl, null );
          gDragOfsY = mY - aOwin.spGetOffsetTop( gDragFromEl, null );
          if ( gDragHelper === null ) {
            gDragHelper = document.createElement('DIV');
            gDragHelper.style.cssText = 'position:absolute;'; 
            document.body.appendChild( gDragHelper );
            gDragHelper.onmouseup = edDragMouseUp;
            gDragHelper.innerHTML = gDragFromEl.innerHTML;
            gDragHelper.className = gDragFromEl.className;
            gDragFromEl.style.visibility = "hidden";
            }
          gDragHelper.style.left = aOwin.evt.clientX + aOwin.spScrollLeft() - gDragOfsX;
          gDragHelper.style.top = aOwin.evt.clientY + aOwin.spScrollTop() - gDragOfsY;
          }
        }
      }
    }
  gEventCnt++;
  if ( aEv.type !== "mousedown" ) { 
    if ( (( aOwig === null )||( aOwig.rootIdEl != gOpenRootIdEl )) 
    && ( gOpenRootIdEl !== null ) ) {
      // alert( "aOwig:" + aOwig + " gOpenRootIdEl:" + gOpenRootIdEl );
      if ( aOwig !== null ) {
        /*jsl:pass*/
        // alert( "aOwig.rootIdEl != gOpenRootIdEl:" + ( aOwig.rootIdEl != gOpenRootIdEl ) );
        }
      var closeOwig = makeTargOwig( aOwin, gOpenRootIdEl, true );
      closeOwig.toKXnoSt( KXnoStMinimized );
      }
    }
  if ( aOwig ) {
    defaultStatus = gEventCnt + ' ' + aEv.type 
    + " tag " + aTargEl.tagName 
    + " class " + aTargEl.className
    + " idEl " + ( aOwig.selfIdEl !== null )
    + " aOwig " + ( aOwig !== null )
    + " is gOpenRootIdEl " + ( aOwig.rootIdEl === gOpenRootIdEl )
    + " gOpenRootIdEl " + ( gOpenRootIdEl !== null )
    ;
    }
  if ( aEv.type === "focus" ) {
    defaultStatus += "x20"; 
    if ( aTargEl.className ) {
      if ( aTargEl.className.indexOf("zEdText") === 0 ) {
        aOwif = aOwig.getOwifFromEl( aTargEl );
        aOwig.evtTextFocus( aOwif, aTargEl, aEv.type === "focus" );
        }
      else if ( aTargEl.className.indexOf("zEdUText") === 0 ) {
        // alert( "zEdUText focus" ); 
        aOwig.toKXnoSt( KXnoStOpen );
        // aOxno.evtXnoFocus( aTargEl, aEv, KXnoStOpen );
        }
      }
    }
  else if ( aOwig !== null ) {
    defaultStatus += "x30"; 
    if ( aTargEl.parentNode ) {
      defaultStatus += "x32" + ( gBlurUnoEl !== null ); 
      if ( aTargEl.parentNode.tagName == "A" ) {
        aTargEl = aTargEl.parentNode;
        }
      if ( aEv.type === "change" ) { 
        defaultStatus += "x35"; 
        aOwif = aOwig.getOwifFromEl( aTargEl );
        aOwif.evtOnChangeTA( aTargEl );
        }
      if ( aEv.type === "keyup" ) { 
        defaultStatus += "x40"; 
        aOwig.evtXnoKeyUp( aEv, aTargEl ); 
        }
      else if ( aEv.type === "click" ) { 
        defaultStatus += "x60"; 
        // alert( defaultStatus );
        aReturnB = aOwig.evtXnoClick( aEv, aTargEl ); 
        }
      }
    if ( gBlurUnoEl !== null ) { 
      var bOwig = makeTargOwig( aOwin, gBlurUnoEl, true );
      // alert( "cc " + defaultStatus );
      bOwig.toKXnoSt( KXnoStMinimized );
      // bOwig.blurXnoEl();
      }
    gSetFocusB = false;
    }
  else if (( aTargEl.tagName == "INPUT" )
  && ( aTargEl.type == "radio" )
  &&( aTargEl.name == "upSel" )) {
    if( aEv.type === "click"  ){
      aOwin.evtTickImage( aTargEl.value );
      }
    }
  else if ( ( aTargEl.tagName == "INPUT" ) 
  && ( aTargEl.type == "button" ) ) {
    if( aEv.type === "click"  ){
      if ( aTargEl.name == "EdSubmit0" ) {
        aOwin.doCheck();
        }
      else if ( aTargEl.name == "EdSubmit1" ) {
        aOwin.doCommit();
        aReturnB = false;
        }
      else if ( aTargEl.name == "EdSubmit2" ) {
        aOwin.doAbort();
        }
      else if ( aTargEl.name == "remImage" ) {
        aOwin.fileRemove( "image", false);
        }
      else if ( aTargEl.name == "remImageAll" ) {
        aOwin.fileRemove( "image", true);
        }
      else if ( aTargEl.name == "remOther" ) {
        aOwin.fileRemove( "other", false);
        }
      else if ( aTargEl.name == "remAllOther" ) {
        aOwin.fileRemove( "other", true);
        }
      else if ( aTargEl.name == "remAllOther" ) {
        aOwin.fileRemove( "other", true);
        }
      }
    }
  else if ( ( aTargEl.tagName == "INPUT" ) 
  && ( aTargEl.type == "file" ) ) {
    if ( aTargEl.name == "UpFileImage" ) {
      if ( aEv.type == "change" ) { aOwin.evtUpFile( aTargEl, true ); }
      if ( aEv.type == "keypress" ) { aOwin.evtUpFile( aTargEl, true ); }
      }
    else if ( aTargEl.name == "UpFileOther" ) {
      if ( aEv.type == "change" ) { aOwin.evtUpFile( aTargEl, false ); }
      if ( aEv.type == "keypress" ) { aOwin.evtUpFile( aTargEl, false ); }
      }
    }
  defaultStatus += " return" + aReturnB; 
/*
  EdLog( aEv.type 
  + " tag " + aTargEl.tagName + " class " + aTargEl.className
  + " innerHTML:" + aTargEl.innerHTML 
  + " withinDrop:" + withinDrop( aTargEl )
  + " gOpenRootIdEl:" + ( gOpenRootIdEl !== null )
  + " aReturnB:" + aReturnB
  );
*/
  if ( gThisCaseB === true ) { alert( "edEvtXnoAll" ); }
  return aReturnB;
  }
TOwig.prototype.evtXnoKeyUp = function ( iEv, iTargEl ) {
  // alert( "evtXnoKeyUp:" + iTargEl.tagName);
  var iOwig = this;
  var aOwif;
  defaultStatus += "x40"; 
  if (( iTargEl.tagName == "INPUT" )
  && ( iTargEl.type == "text" )) {
    defaultStatus += "x50"; 
    if ( iTargEl.className.indexOf("zEdText") === 0 ) {
      defaultStatus += "x55"; 
      // aOwif = iOwig.getOwifFromEl( iTargEl );
      iOwig.fiOrdOwif(true,true); 
      aOwif = iOwig.nxOrdOwif();
      iOwig.evtTcoTextChange( aOwif, iTargEl );
      }
    else {
      iOwig.capture( true, KXnoStOpen );
      iOwig.searchS = iOwig.realSearchS( iTargEl );
      if (( iOwig.Qtype === iOwig.EQtypeUno ) && ( iOwig.Owin.enterKeyB === true )
      &&( iOwig.EdKcipChk( iOwig.EKcipEdRequist ) === true ) ) {
        toPageExt( searchUrl( iOwig.searchS ) ); // ????
        }
      else { 
        gXnoStartN = 1;
        // EdLog( "set Timout" );
        if ( gTimeOutId !== 0 ) {
          clearTimeout( gTimeOutId );
          // EdLog( "clearTimeout:" + gTimeOutId );
          }
        gKeyTargEl = iTargEl;
        iOwig.searchS = iOwig.realSearchS( gKeyTargEl );
        var aS = 'Wait search:';
        var msCnt = 300;
        if (( iOwig.EdKcipChk( iOwig.EKcipManyPot ) === true )
        && ( iOwig.searchS.indexOf( ' ' ) === -1 ))  {
          aS = 'Enter first word:';
          msCnt = 1000;
          }
        gNsaReSearchS = iOwig.searchS;
        if (( gNsaSearchS === "" ) 
        && ( iOwig.getKSearch( iOwig ) === KSearchNotReqd )) { msCnt = 100; }
        if ( gNsaSearchS === "" ) {
          // alert( "A" );
          if ( iOwig.needDrop() === true ) {
            iOwig.getMakeDrop();
            }
          iOwig.msgOnlyList( aS + iOwig.searchS );
          }
        gTimeOutCnt = 0;
        gTimeOutId = setTimeout( xnoKeyTimeOut, msCnt );
        }
      }
    }
  else if (( iTargEl.tagName == "TEXTAREA" )
  && ( iTargEl.className.indexOf("zEdText" ) === 0 ) ) {
    // aOwif = iOwig.getOwifFromEl( iTargEl );
    iOwig.fiOrdOwif(true,true); 
    aOwif = iOwig.nxOrdOwif();
    iOwig.evtTcoTextChange( aOwif, iTargEl );
    }
  };
function xnoKeyTimeOut() {
  var aOwin = new TOwin( null, null );
  var aOwig = makeTargOwig( aOwin, gKeyTargEl, true );
  aOwig.capture( true, KXnoStOpen );
  var bigB = aOwig.EdKcipChk( aOwig.EKcipManyPot );
  gTimeOutId = 0;
  aOwig.searchS = aOwig.realSearchS( gKeyTargEl );
  var matchSS;
  // EdLog( "keyTimeOut searchS:" + aOwig.searchS
  // + " aOxno.potsOk():" + aOxno.potsOk() 
  // + " gNsaSearchS:" + gNsaSearchS );
  if ( gNsaSearchS === "" ) {
    var aKsearch = aOwig.getKSearch( );
    if ( aKsearch === KSearchNotReqd ) {
      // no search in progress or needed
      // alert( "C aOwig.searchS:" + aOwig.searchS );
      aOwig.bldRequired( 1 ); 
      // alert( "D" );
      }
    else { // no search in progress, but required
      gNsaSearchS = aOwig.searchS;
      gOjax.nsaWigId = null;
      if ( aOwig.selfIdEl === aOwig.rootIdEl ) {
        gOjax.nsaWigId = aOwig.selfIdEl.id;
        }
      gOjax.wigSelfIdN = aOwig.selfIdN;
      gOjax.cnnAllocN = aOwig.cnnAllocN;
      // alert( "aOwig.newUrlS:" + aOwig.newUrlS )
      var bigS = "0";
      if ( aKsearch === KSearchByWord ) { bigS = "1"; }
      var fullUrlS = '';
      if ( aOwig.newUrlS !== '/' ) { // not nav
        var aOlnk = new TOlnk( aOwig.newUrlS );
        aOlnk.typeS = aOwig.typeS;
        fullUrlS = aOlnk.toStr( false );
        }
      gOjax.asDoQs( "?op=nsa", fullUrlS
      , "&xx=1&schText=" + aOwig.searchS.nsToOjText()
      + "&schULoop=10000" + "&schUMatch=50" + "&big=" + bigS );
      }
    }
  else { // search in progress
    var prSearchSS = gNsaSearchS.split( " " );
    matchSS = aOwig.searchS.split(" ");
    if ( withinPrior( bigB, matchSS, prSearchSS ) === false ) { 
      gTimeOutCnt++;
      if ( gTimeOutCnt > 20 ) {
        alert( "Server not responding to Nsa requist. Search:" + gNsaSearchS ); 
        }
      else {
        gTimeOutId = setTimeout( xnoKeyTimeOut, 100 ); // reschedule keyTimeOut
        }
      }
    }
  }
//
//
// odds and end events
function banSearch( ) { // do banner search
  toPageLoc( "/G/0/1/search.htm?" 
  + window.document.getElementById( "zSearchTxt" ).value );
  }
function nsBanSearchKey( iEvent ) {
  var evt = (iEvent) ? iEvent : event;
  var charCode = (evt.charCode) ? evt.charCode :((evt.which) ? evt.which : evt.keyCode);
  if ( charCode == 13 || charCode == 3 ) { 
    banSearch( );
    return false;
    }
  else {
    return true;
    }
  }
/* nav system - hinting */
function nshSetHints( hintStr ) { 
  var aOwin = new TOwin( null, null );
  aOwin.setCookie( 'hints', hintStr );
  }
//
/* End Events *********************** */
function nsdInitTbm( elTbm, elTbh ) { // set up mouse actioning on toolbar
  elTbm.elTbh = elTbh;
  if ( elTbh ) {
    elTbh.elTbm = elTbm;
    }
  }
function nsFixNav( w, iErr, iN ) {
  // defaultStatus += 'nsFixNav-1';
  var aOnav = new TOnav();
  var I=0;
  for ( I=1; I<200; I++ ){
    var elTbm = w.document.getElementById( "idTbm" + I );
    var elTbh = w.document.getElementById( "idTbh" + I );
    if ( elTbm ) { nsdInitTbm( elTbm, elTbh ); }
    }
  var bodyEls = document.getElementsByTagName("BODY");
  var tableEls = document.getElementsByTagName("TABLE");
  for ( I=1; I<tableEls.length; I++ ){
    var tableEl = tableEls[I];
    if ( tableEl.className == 'zPres3' ) {
      tableEl.className = 'zPres3a';
      }
    }
/*  
  if ( w.document.styleSheets ) {
    w.document.styleSheets[w.document.styleSheets.length-1].addRule(
    ".zPres3 td", "border-style:solid" ); 
    // alert( 'fix stylesheet 2' );
    }
*/
  // defaultStatus += ',2';
  resetExchange();
  }
if ( typeof document.layers == 'undefined' ) {
  window.onload = evtWindow;
  window.onbeforeunload = evtWindow;
  window.onresize = evtWindow;
  window.onscroll = evtWindow;
  document.onmousemove = evtWindow;
  }
function finishChecking() {
  if ( ( gModWin !== null ) && ( gModWin.closed === false) ) { 
    gModWin.focus(); 
    }
  }
function resetTimer() {
  if ( gStartCnt < 1 ) { setTimeout( "pcTc()", 50 ); }
  gStartCnt = gResetCnt;
  }
function pcTc() {  // display or clear menu after mouse stationary timeout
  gStartCnt--; 
  if ( gStartCnt > 0 ) { setTimeout( "pcTc()", 50 ); }
  } 
function toPageLoc( iUrl, iTarget ) { // go to url within site
  var aS = '';
  if ( iUrl.substr( 0, 10 ) == 'javascript' ) { aS = iUrl; }
  else { aS = 'http://' + document.location.host + iUrl; }
  if ( iTarget ) { window.open( aS, null, iTarget ); }
  else { document.location.href = aS; }
  }
function toPageExt( iUrl, iTarget ) { // go to url within site
  if ( iTarget ) { window.open( iUrl, iTarget ); }
  else { document.location.href = iUrl; }
  }
function pcChkLoaded() {
  if ( window.tabLoaded === false ) { setTimeout('pcChkLoaded()', 300 ); }
  else if ( window.upOk === true ) { document.location.reload( true ); }
  else { alert( 'exchange rx update Bad' ); }
  }
/* size,posn primatives */
function edInlineBlockS() {
  if ( document.getElementById && !document.all ) { return "-moz-inline-box"; }
  else { return "inline-block"; }
  }
function edKeyPress( iEl ) {
//  if ( iEl.className != 'zEdText1' ) {
//    edOnChange( iEl );
//    }
  }
function asModalWin( iS ) {
  return window.open( iS, '_blank', 'scrollbars=yes,resizable=yes,status=yes' );
  } 
function edModeFlags() {
  var flags = 0;
  var stayEl = document.getElementById( 'idEdStay' );
  if ( ( stayEl ) && ( stayEl.checked === true ) ) { flags = (flags + 1); }
  return flags;
  }
function winTest( ) {
  var subW = window.open( gTestMsg, '_blank'
  , 'directories=0,location=0,menubar=1,toolbar=0' );
  }
function urlOk( iUrl ) {
  return true;
  }
function resetExchange() {
//  var exEl = document.getElementById( 'exchange' );
//  exEl.src = '/common/exchange.html';
  } 
/* The following function creates an XMLHttpRequest object... */
function createReqObj() {
  var hasActiveX=false; 
  try{ 
    if(( window.ActiveXObject )&&( ! window.XMLHttpRequest)) { 
      hasActiveX = true; // IE 7 has native support
      } 
    } 
  catch (oError) {
    }
  if ( hasActiveX === true ) {
    var AVersions 
    = [ "MSXML2.DOMDocument.5.0"
    , "MSXML2.DOMDocument.4.0"
    , "MSXML2.DOMDocument.3.0"
    , "MSXML2.DOMDocument"
    , "MSXML2.DOMDocument"
    , "Microsoft.XmlDom"
    , "Microsoft.XMLHTTP"  ];
    var req = null;
    var reqInx = -1;
    for ( var i=0; i<AVersions.length; i++) {
      try {
        req = new ActiveXObject( AVersions[i] );
        reqInx = i;
        i = AVersions.length; 
        }
      catch (oError) {
        }
      }
    if ( reqInx > 0 ) {
      alert( "createReqObj:" + AVersions[reqInx] );
      }
    else {
      alert( 'createReqObj not found' );
      }
    }
  else {
    try{ 
      if ( XMLHttpRequest ) { 
        req = new XMLHttpRequest(); 
        // alert( 'Non ActiveX XMLHttpRequest found' );
        }
      } 
    catch(oError) { 
      alert( 'Non ActiveX XMLHttpRequest not found' );
      } 
    }
  return req;
  }
function hitch(obj, meth) {
  return function () {
    return meth.apply(obj, arguments); 
    };
  }
function nsOnLoad( iEl, iS ) {  // exchange frame onload
/*
  if ( frames["exchange"] ) {
    if ( gLoadNav === true ) {
      if ( gOjax.xh === null ) { // also do this on short urls
        frames["exchange"].location.replace( gUriTitle + iS );
        defaultStatus+='Nsa-req ';
        }
      else {
        gOjax.asDoQs( "?op=nsa" + iS, '', "&xx=1" );
        defaultStatus+='Nsa-req# ';
        }
      gLoadNav = false;
      }
    else {
      defaultStatus += 'Nsa-2 ';
      }
    }
  else {
    defaultStatus+="loadNav exchange not found";
    }
*/
  }
// extract widget group details for DOM
function EdLog( iS ) {
  if ( ! EdLog.Alog ) { EdLog.Alog = new Array(); }
  if ( EdLog.Alog.length > 100 ) { EdLog.Alog.splice( 0, 1 ); }
  var aS, SS, bSS, cS, arg, aLog;
  if (( EdLog.Alog.length > 1 )
  && ( EdLog.caller )
  && (EdLog.Alog[ EdLog.Alog.length-1 ].arguments == EdLog.caller.arguments)) {
    aLog = EdLog.Alog[ EdLog.Alog.length-1 ];
    }
  else {
    aLog = new Object();
    EdLog.Alog[ EdLog.Alog.length ] = aLog;
    aLog.arguments = EdLog.caller.arguments;
    aLog.AtextS = new Array();
    }
  aLog.AtextS[aLog.AtextS.length] = iS;
  if ( EdLog.caller ) { // not opera
    var aCaller = EdLog.caller;
    var logS = "";
    while ( aCaller ) {
      aS = aCaller.toString();
      SS = aS.split( "{" );
      bSS = SS[0].split( "function " );
      cS = bSS[1] + " ";
      for ( var i=0,l=aCaller.arguments.length; i<l; i++ ) {
        arg = aCaller.arguments[i];
        cS += ", " + arg;
        }
      if ( logS === "" ) { logS = cS; }
      else { logS = cS + " =&gt; " + logS; }
      aCaller = aCaller.caller;
      } 
    // logS = "<h5>" + logS + "</h5>&nbsp;&nbsp;" + iS.edHtmlEsc();
    }
  else {
    logS = "";
    }
  aLog.chainS = logS;
  // gLogS += logS;
  }
TOwin.prototype.getWigPosns = function ( iSelEl ) { 
  var aOwin = this;
  var paEl = iSelEl.parentNode;
  var doneB = false;
  var oEl = null;
  var fcEl;
  aOwin.winPathEl = null;
  aOwin.clickIdEl = null;
  while (( doneB === false )&&( paEl )&&( paEl !== null )) {
    if (( paEl.tagName === "TD" )
    && ( paEl.childNodes[0].tagName === "INPUT" )
    && ( paEl.childNodes[0].id )
    && ( paEl.childNodes[0].id.indexOf( "idEfG" ) === 0 )) {
      oEl = paEl.childNodes[0];
      doneB = true;
      }
    else if ( // ( paEl.tagName === "DIV" ) && span incase of connection drops
    ( paEl.childNodes[0].tagName === "INPUT" )
    && ( paEl.childNodes[0].id )
    && ( paEl.childNodes[0].id.indexOf( "idNg" ) === 0 )) { 
      oEl = paEl.childNodes[0];
      doneB = true;
      }
    else if ( paEl.className === "zDivXnoDrop" ) {
      oEl = gOpenRootIdEl;
      // alert( "getWigPosns" + oEl.outerHTML );
      doneB = true;
      }
    else {
      fcEl = paEl.previousSibling;
      if ( ( fcEl !== null )
      && ( fcEl.tagName === "INPUT" )
      && ( fcEl.name === "nestPath" ) ) {
        aOwin.winPathEl = fcEl;
        aOwin.clickIdEl = fcEl;
        }
      }
    paEl = paEl.parentNode;
    } 
  aOwin.rootIdEl = oEl;
  if ( aOwin.clickIdEl === null ) { aOwin.clickIdEl = aOwin.rootIdEl; }
  };
//
function EdEfChk( iN, iEf ) {
  var ss = iEf.split( ' ' );
  if ( ss.length > 1 ) {
    alert( 'EdEfChk ' + iN + ' spaces ' + ss.length + ' ' + iEf );
    }
  }
function EdBugSol( iIndent ) {
  var oS = '\n  ';
  for ( var j=0;j<iIndent;j++ ) {
    oS += '   ';
    }
  return oS;
  }
function EdXor( iAB, iBB ) {
  return ( iAB || iBB ) && ( ! ( iAB && iBB ) );
  }
//
// call prior to element deletion to fix IE leakage
function purge(d) {
  var Els = d.getElementsByTagName("SELECT");
  var i,l,aEl;
  for ( i=0,l=Els.length;i<l;i++ ) {
    Els[i].onchange = null;
    }
  Els = d.getElementsByTagName("INPUT");
  for ( i=0,l=Els.length;i<l;i++ ) {
    aEl = Els[i];
    if ( aEl.type == "text" ) {
      aEl.onchange = null;
      aEl.onfocus = null;
      aEl.onblur = null;
      }
    }
  Els = d.getElementsByTagName("TEXTAREA");
  for ( i=0,l=Els.length;i<l;i++ ) {
    aEl = Els[i];
    aEl.onchange = null;
    aEl.onfocus = null;
    aEl.onblur = null;
    }
  }
//
/* ******************************* */ 
//
// operates in parent context
function EdUpdateFromChild( igEl, iIdfEl, iOpid, iInstName, iOwin ) {
  var aOwif, nxOwif;
  var aOwin = new TOwin( null, null );
  var aOwig = makeTargOwig( aOwin, iIdfEl, true );
  var edsub = iOwin.submitStr( aOwig, iInstName );
  // need to remove order + Hoj ??
  iOpid.einS = edsub.combStr.substr( 2, edsub.combStr.length-4 );
  if ( iOpid.Exno === aOwig.EXnoDataNew ) {
    iOpid.tentN = aOwig.allocTentN();
    iOpid.Exno = aOwig.EXnoData;
    }
  aOwif = aOwig.getInstOwif( iOpid, false );
  if ( aOwig.EdKcipChk( aOwig.EKcipUnique ) === true )  {
    if ( aOwig.uniqOwif !== aOwif ) { 
      aOwig.uniqOwif.aStD.nowSelectB = false;
      if ( aOwig.uniqOwif.needed() === false ) {
        aOwig.Otmr.tmiUpdateNotNeeded( aOwig.uniqOwif, aOwif.wifEl );
        }
      }
    }
  if ( aOwif === null ) { 
    aOwif = aOwig.addNewOwif( null );
    aOwif.insertB = true;
    }
  else {
    aOwif.insertB = false;
    }
  aOwif.Opid = iOpid;
  aOwif.curTextS = iInstName;
  aOwif.aStD.nowSelectB = true;
  aOwig.saveAll( );
  aOwif.refreshB = true;
  // aOwif.insertB = insertB;
  aOwif.insertPrOwif = null;
  if ( aOwif.insertB === true ) {
    for ( aOwig.fiOrdOwif(true,true); (nxOwif=aOwig.nxOrdOwif()); ) {
      if ( nxOwif.aStD.carryB === true ) { 
        aOwif.insertPrOwif = nxOwif;
        aOwig.laOwif();
        }
      }
    }
  // alert( "einS:" + aOwif.Opid.einS + " iEdsub.combStr:" + iEdsub.combStr 
  // + " aOwif.insertB:" + aOwif.insertB + " aOwif.insertPrOwif:" + aOwif.insertPrOwif );
  // page update
  aOwig.summary();
  aOwig.toKXnoSt( KXnoStMinimized );
  return aOwig; 
  }
function TOprf( iCnnAllocN, iOwif, iIAOwif ) {
  var aOprf = this;
  aOprf.cnnAllocN = iCnnAllocN;
  aOprf.Owif = iOwif;
  aOprf.IAOwif = iIAOwif;
  }
TOwig.prototype.toQtypeS = function( iQtype ) {
  var aOwig = this;
  aOwig.paOwig = null;
  aOwig.subInx = 0;
  var aS = '';
  if ( iQtype === aOwig.EQtypeTmo ) { aS = 'QtypeTmo'; }
  else if ( iQtype === aOwig.EQtypeTco ) { aS = 'QtypeTco'; }
  else if ( iQtype === aOwig.EQtypeUno ) { aS = 'QtypeUno'; }
  else if ( iQtype === aOwig.EQtypeEno ) { aS = 'QtypeEno'; }
  else if ( iQtype === aOwig.EQtypeCno ) { aS = 'QtypeCno'; }
  else { aS = 'Qtype:' + iQtype; }
  return aS;
  };
TOwig.prototype.decodeActHdr = function decodeActHdr( iS ) {
  var aOwig = this;
  var agSS = iS.split('W');
  aOwig.selfIdN = 0;
  aOwig.SKcip = "";
  aOwig.cnnAllocN = 0;
  aOwig.widthEmS = '';
  aOwig.typeS = "";
  aOwig.newUrlS = "";
  aOwig.abIdS = "";
  aOwig.Kisu = aOwig.EKisuNone;
  aOwig.titleS = "";
  aOwig.titleImgS = "";
  var inxSS;
  var bS = "";
  for ( inxSS = 0; inxSS< agSS.length; inxSS++ ) {
    bS = agSS[inxSS];
    if ( inxSS === 0 ) { aOwig.selfIdN = parseInt( bS, 10 ); } // includes order + httm
    else if ( inxSS === 1 ) { aOwig.SKcip = bS; } // includes order + httm
    else if ( inxSS === 2 ) { aOwig.typeS = bS; } 
    else if ( inxSS === 3 ) { aOwig.cnnAllocN = parseInt( bS, 10 ); } 
    else if ( inxSS === 4 ) { 
      if( bS != '0' ){ aOwig.widthEmS = bS; }
    } 
    else if ( inxSS === 5 ) { aOwig.newUrlS = bS.split('?')[0]; }
    else if ( inxSS === 6 ) { aOwig.abIdS = bS; }
    else if ( inxSS === 7 ) { aOwig.Kisu = parseInt( bS, 10 ); }
    else if ( inxSS === 8 ) { aOwig.titleS = bS.nsFromOjText(); }
    else if ( inxSS === 9 ) { aOwig.titleImgS = bS.nsFromOjText(); }
    if ( isNaN( aOwig.selfIdN ) ) { alert( 'Nan:' +  iS ); bomb(); }
    }
  };
TOpog.prototype.decodePotHdr = function ( iS ) {
  var aOpog = this;
  var agSS = iS.split('W'); // extra blank on end
  aOpog.newUrlS = "";
  var inxSS;
  var bS = "";
  var aOsrc;
  aOpog.AOsrc = new Array();
  var l=agSS.length-1; // skip blank on end
  for ( inxSS = 0; inxSS<l; inxSS++ ) {
    bS = agSS[inxSS];
    if ( inxSS === 0 ) { aOpog.typeS = bS; } // includes order + httm
    else if ( inxSS === 1 ) { aOpog.newUrlS = bS; }
    else if ( inxSS === 2 ) { aOpog.recentN = parseInt( bS, 10 ); }
    else {
      aOsrc = new TOsrc();
      aOsrc.srcDecode( bS );
      aOpog.AOsrc[ aOpog.AOsrc.length ] = aOsrc;
      }
    }
  };
function fsSplit( iS ) {
  var aSS = [];
  var inx1 = iS.indexOf( 'Y' );
  var inx2, inx3, nS;
  var l=iS.length;
  // if( inx1=== -1 ){ aSS[0] = iS; }
  while (( inx1 !== -1 )&&( inx1 < l )) {
    inx2 = iS.indexOf( 'Y', inx1+1 );
    nS = iS.substring( inx1+1, inx2 );
    inx3 = inx2 + parseInt( nS, 10 ) + 1;
    aSS[aSS.length] = iS.substring( inx2+1, inx3 );
    inx1 = inx3;
    }
  return aSS;
  }
TOpog.prototype.popDecode = function popDecode( iOwin, iOwig, iS, iSortB, iCnnAllocN ) {
  // iOwig is null for search results
  var aOpog = this;
  // alert( " popDecode " + iS );
  var epSS = fsSplit( iS );
  aOpog.decodePotHdr( epSS[0] );
  epSS.splice( 0, 1 ); // no header
  // if ( iSortB === true ) {
  //  epSS.sort();
  //  }
  var i,l,aOwif,aOPrf;
  for ( i=0,l=epSS.length; i<l; i++ ) {
    aOwif = new TOwif( iOwig, iCnnAllocN );
    aOwif.decodeInst( iOwin, epSS[ i ] );
    aOpog.AOwif[ aOpog.AOwif.length ] = aOwif;
    if ( aOwif.aStD === null ) { aOwif.EdQdbDecodeState( "00000" ); }
    if ( aOwif.curTextS === null ) { aOwif.curTextS = aOwif.origTextS; }
    // give ein reference to aOwig
    aOPrf = new TOprf( iCnnAllocN, aOwif, aOpog.AOwif.length-1 );
    aOwif.Oein.AOprf[ aOwif.Oein.AOprf.length ] = aOPrf;
    // aOwig.addNewOwif( aOwif );
    }
  };
TOwig.prototype.txtFromPot = function( iOwif ) {
  var i, nxOwif;
  var aS = '';
  var aOwig = this;
  for ( i=0; (nxOwif=aOwig.Opog.AOwif[i++]); ) {
    if (( iOwif.instKtjS === nxOwif.instKtjS )
    && ( iOwif.Opid.hojS === nxOwif.Opid.hojS )) {
      aS = nxOwif.origTextS;
      }
    }
  return aS;
  };
TOwig.prototype.recMakeOwig = function( iPaOwif, iOwin, iValS, iFullB ) {
  var i,l,inx,nxEl,aS,idgValueS,aOwif,bOwif,aOPrf;
  var aOwig = this;
  aOwig.Owin = iOwin;
  aOwig.paOwif = iPaOwif;
  aOwig.refreshAllB = false;
  aOwig.refocusB = false;
  aOwig.actAOwif = [];
  aOwig.notNeededOwif = null;
  aOwig.widthEmS = '';
  aOwig.uniqNowOwif = null;
  // aOwig.navB = false;
  aOwig.startN = 0; 
  aOwig.fullN = 0;
  aOwig.moveTrEl = null;
  aOwig.fullB = iFullB;
  nxEl = null;
  if ( iPaOwif === null ) { iOwin.a1Date = new Date( ).valueOf(); }
  if ( iValS === "" ) {
//    alert( 'TOwig aOwig.selfIdEl === null' );
    aOwig.newUrlS = null;
    aOwig.abIdS = "";
    }
  else {
//    if ( iFullB === false ) {
//      aOwig.SKcip = iValS.split( 'W' )[1];
//      if ( iPaOwif === null ) { iOwin.a2Date = new Date( ).valueOf(); }
//      }
    aOwig.Opog = null; // ?? iOwin.potAOpog[ aOwig.cnnAllocN ]; IF EXISTING DONT ADD AGAIN
    // alert( " recMakeOwig " + iValS );
    var fSS = fsSplit( iValS );
    if ( iPaOwif === null ) { iOwin.a2Date = new Date( ).valueOf(); }
    aOwig.decodeActHdr( fSS[0] );
    if ( aOwig.Kisu !== aOwig.EKisuComplex ) { aOwig.fullB = true; }
    if ( aOwig.fullB === true ) {
      if ( ! aOwig.Opog ) { 
        aOwig.Opog = new TOpog();
        iOwin.potAOpog[ aOwig.cnnAllocN ] = aOwig.Opog;
        }
      if ( iPaOwif === null ) { iOwin.a3Date = new Date( ).valueOf(); }
      if ( aOwig.navB === false ) {
        aOwig.epHideEl = document.getElementById( 'idEp' + aOwig.cnnAllocN );
        }
      else {
        aOwig.epHideEl = document.getElementById( 'idNp' + aOwig.cnnAllocN );
        }
      aOwif = null;
      var boxSS = null;
  /* */
      // make potential array
      if ( aOwig.epHideEl !== null ) {
        aOwig.Opog.popDecode( aOwig.Owin, aOwig, nthWigS( aOwig.epHideEl, 0 ), true, aOwig.cnnAllocN );
        }
      // else { bomb(); }
      if ( iPaOwif === null ) { iOwin.a4Date = new Date( ).valueOf(); }
      // make actual array
      for ( i=1,l=fSS.length; i<l; i++ ) {
        aOwif = new TOwif( aOwig, aOwig.groupN ); 
        aOwig.actAOwif[ aOwig.actAOwif.length ] = aOwif;
        aOwif.decodeInst( aOwig.Owin, fSS[ i ] );
        aOwif.curOrderN = i;
        if ( aOwif.origTextS === '' ) { // try getting from pots
          aOwif.origTextS = aOwig.txtFromPot( aOwif );
          }
        if ( aOwif.aStD === null ) { aOwif.EdQdbDecodeState( "00000" ); }
        if ( aOwif.curTextS === null ) { aOwif.curTextS = aOwif.origTextS; }
        }
      var nxOwif;
//      aOwig.Otmr.entryBoxNode = null;
      aOwig.Otmr.unspecNode = null;
      aOwig.Otmr.buttonsNode = null;
      aOwig.Otmr.messageNode = null;
      // aOwig.groupEl = aOwig.selfIdEl.parentNode;
      if ( aOwig.groupEl !== null ) { // HERE ???
        for ( i=0; nxEl=aOwig.groupEl.childNodes[i++]; ) {
          if ( ( nxEl.className ) && ( nxEl.className.substr( 0, 4 )=='zWid' ) ) {
            nxOwif = aOwig.getOwifFromEl( nxEl );
            if ( nxOwif !== null ) {
              nxOwif.wifEl = nxEl;
              nxEl = nxEl.childNodes[0];
              if ( nxEl && ( nxEl.className ) 
              && ( nxEl.className.substr( 0, 4 ) == 'zWid' ) ) {
                nxOwif.wifEl = nxEl;
                }
              }
            else {
              aOwig.specialNode( nxEl );
              }
            }
          }
        var inputEls = aOwig.groupEl.getElementsByTagName( "INPUT" );
        for ( i=0; nxEl=inputEls[i++]; ) {
          if (( nxEl.type == "BUTTON" )
          &&( nxEl.className.substr( 0, 6 ) == "zEdNew" ) ) {
            aOwig.newButEl = nxEl;
            }
          }
        }
      if ( aOwig.abIdS !== "" ) {
        var aOeih = new TOeih();
        aOeih.decode( aOwig.abIdS );
        aOwig.subHojS = aOeih.paHojS;
        }
      else {
        aOwig.subHojS = ""; // nav wig ?
        }
      aOwig.uniqOwif = null; 
      if ( aOwig.EdKcipChk( aOwig.EKcipUnique ) === true ) {
        for ( aOwig.fiActOwif(); (aOwif=aOwig.nxActOwif()); ) {
          // defaultStatus += i + ': ' + aOwif.aStD.nowSelectB + ' ';
          // if ( aOwif.aStD === null ) { aOwif.EdQdbDecodeState( "00000" ); }
          if ( aOwif.aStD.nowSelectB === true ) { 
            aOwig.uniqOwif = aOwif; 
            }
          }
        }
      aOwig.Qtype = aOwig.getQtype();
      }
    }
  };
function TOeih( ) { 
  var aOeih = this;
  aOeih.orderN = 0;
  aOeih.subjHojS = '';
  aOeih.aN = 0;
  aOeih.bN = 0;
  aOeih.typeNoloi = 0;
  aOeih.paHojS = '';
  aOeih.nameS = '';
  aOeih.efS = ''; // if full ei
  }
function TOstrip( iS ) {
  var aOstrip = this;
  aOstrip.S = iS;
  }
TOstrip.prototype.strip = function( iC ){ 
  var aOstrip = this;
  var inx = aOstrip.S.indexOf( iC );
  var aS = '';
  if ( inx != -1 ) {
    aS = aOstrip.S.substring( 0, inx );
    aOstrip.S = aOstrip.S.substring( inx+1, aOstrip.S.length );
    }
  else {
    aS = aOstrip.S;
    aOstrip.S = '';
    }
  return aS;
  };
TOeih.prototype.decode = function( iS ){ 
  var aOeih = this;
  var aOstrip = new TOstrip( iS );
  // var SS = iS.split('X',7);
  aOeih.orderN = parseInt( aOstrip.strip('X'), 10 );
  aOeih.subjHojS = aOstrip.strip('X');
  aOeih.aN = parseInt( aOstrip.strip('X'), 10 );
  aOeih.bN = parseInt( aOstrip.strip('X'), 10 );
  aOeih.typeNoloi = parseInt( aOstrip.strip('X'), 10 );
  aOeih.paHojS = aOstrip.strip('X');
  if ( aOstrip.S !== '' ) {
    var bSS = aOstrip.S.EdSplitBrack();
    aOeih.nameS = bSS[0].nsFromOjText();
    if ( bSS[1] ) {
      // alert( "bSS.length:" + bSS.length + " bSS[1]" + bSS[1] );
      aOeih.efS = '';
      for( var i=1; i< bSS.length; i++ ){
    	aOeih.efS += "(" + bSS[i] + ")";
    	}
      }
    }
  };
TOeih.prototype.encode = function( iIncNameB ){ 
  var aOeih = this;
  var aS = "";
  aS += aOeih.orderN + "X";
  aS += aOeih.subjHojS + "X";
  aS += aOeih.aN + "X";
  aS += aOeih.bN + "X";
  aS += aOeih.typeNoloi + "X";
  aS += aOeih.paHojS;
  if ( iIncNameB === true ) {
    aS += "X(" + aOeih.nameS.nsToOjText() + ")";
    }
  if ( aOeih.efS !== "" ) { 
    aS += aOeih.efS;
    }
  return aS;
  };
function TOtmr( iOwig ) { 
  var aOtmr = this;
  aOtmr.Owig = iOwig;
  }
function TOtco( iOwig ) { 
  var aOtco = this;
  aOtco.Owig = iOwig;
  }
function TOwig() { 
  var aOwig = this;
  aOwig.Owin = null;
  aOwig.paOwif = null;
  aOwig.refreshAllB = false;
  aOwig.refocusB = false;
  aOwig.actAOwif = [];
  aOwig.notNeededOwif = null;
  aOwig.widthEmS = '';
  aOwig.uniqNowOwif = null;
  // aOwig.navB = false;
  aOwig.startN = 0; 
  aOwig.fullN = 0;
  aOwig.groupEl = null;
  aOwig.newButEl = null;
  aOwig.selfIdEl = null;  
  aOwig.rootIdgEl = null;
  aOwig.Otmr = new TOtmr( aOwig );
  aOwig.Otco = new TOtco( aOwig );
  aOwig.paOwig = null;
  aOwig.nxActIOwif = -1;
  aOwig.subInx = -1;
  aOwig.actOwil = null;
  aOwig.potOwil = null;
  aOwig.cnoOwil = null;
  aOwig.headDivEl = null;
  aOwig.dropImageEl = null;
  aOwig.xnoPageReqButEl = null;
  aOwig.textEl = null;
  aOwig.newlyOpenB = false;
  aOwig.prKnoSt = KXnoStMinimized;
  aOwig.searchS = '';
  }
TOwig.prototype.fromIdEl = function( iOwin, iIdfEl, iFullB ) { // full false for summary only
  if ( ! iIdfEl ) { alert( "TOwig( null )" ); }
  var aOwig = this;
  aOwig.rootIdEl = iIdfEl;
  aOwig.selfIdEl = iIdfEl;
  var valS = "";
  aOwig.navB = ( aOwig.selfIdEl.id.indexOf( "idEfG" ) !== 0 );
  if ( iIdfEl ) { valS = nthWigS( iIdfEl, 0 ); }
  if ( aOwig.selfIdEl.id.indexOf( "idNg" ) === 0 ) { 
    aOwig.groupN = aOwig.selfIdEl.id.substr( 4, aOwig.selfIdEl.id.length - 4 );
    }
  else { 
    aOwig.groupN = aOwig.selfIdEl.id.substr( 5, aOwig.selfIdEl.id.length - 5 ); 
    }
  aOwig.groupEl = aOwig.selfIdEl.parentNode;
  // alert( "fromIdEl call recMakeOwig " + valS );
  // if ( valS.indexOf( "undefine" ) !== -1 ) { bomb(); }
  aOwig.recMakeOwig( null, iOwin, valS, iFullB );
  };
function TOsrc() {
  var aOsrc = this;
  aOsrc.Kscli = EKscliAll;
  aOsrc.searchS = '';
  }
TOsrc.prototype.srcDecode = function srcDecode( iS ) {
  var aOsrc = this;
  var aS = iS.substring( 0, 1 );
  aOsrc.Kscli = parseInt( aS, 10 );
  if (( aOsrc.Kscli === EKscliSearch )
  ||( aOsrc.Kscli === EKscliToMany )) {
    aS = iS.substring( 1, iS.length );
    aOsrc.searchS = aS.nsFromOjText();
    }
  };
TOsrc.prototype.srcEncode = function srcEncode( ) {
  var aOsrc = this;
  var aS = "";
  aS += aOsrc.Kscli;
  if (( aOsrc.Kscli === EKscliSearch )
  ||( aOsrc.Kscli === EKscliToMany )) {
    aS += aOsrc.searchS.nsToOjText();
    }
  return aS;
  };
TOwig.prototype.getQtype = function getQtype() {
  var iOwig = this;
  var nonEmptyB = true;
  var manyB = true;
  if ( iOwig.fullB === true ) {
    nonEmptyB = ( iOwig.Opog.AOwif.length+iOwig.actAOwif.length > 0 );
    manyB = (iOwig.Opog.AOwif.length > 20 );
    }
  var aQtype = iOwig.EQtypeTmo;
  var needXnoB = false;
  if ( ( iOwig.EdKcipChk( iOwig.EKcipNameIsId ) === true ) 
  || ( iOwig.EdKcipChk( iOwig.EKcipText ) === true) ) {
    aQtype = iOwig.EQtypeTco; // text control
    // aQtype = iOwig.EQtypeTmo;
    }
  else if ( ( iOwig.EdKcipChk( iOwig.EKcipEdRequist ) === true )
  && ( iOwig.EdKcipChk( iOwig.EKcipUnique ) === false ) ) { 
    if ( iOwig.EdKcipChk( iOwig.EKcipCompact ) === true ) {
      aQtype = iOwig.EQtypeCno;
      }
    else {
      aQtype = iOwig.EQtypeEno;
      }
    }
  else {
    needXnoB = nonEmptyB && 
     ( ( iOwig.EdKcipChk( iOwig.EKcipCompact ) === true )
     || ( iOwig.EdKcipChk( iOwig.EKcipOrderable ) === true )
     || ( iOwig.EdKcipChk( iOwig.EKcipMemberEdit ) === true )
     || ( iOwig.EdKcipChk( iOwig.EKcipMemberClone ) === true )
     || ( iOwig.EdKcipChk( iOwig.EKcipMemberRemove ) === true )
     );
    needXnoB = needXnoB || ( iOwig.EdKcipChk( iOwig.EKcipClosed ) === false );
    if ( iOwig.EdKcipChk( iOwig.EKcipUnique ) === true ) {
      if ( ( iOwig.EdKcipChk( iOwig.EKcipPots ) === true )           
      && (( manyB === true ) 
      || ( iOwig.EdKcipChk( iOwig.EKcipCompact ) === true ))
      || ( needXnoB === true )
      ) {
        // iOwig.summary();
        aQtype = iOwig.EQtypeUno;
        }
      }
    else { // non unique
      // Eno possible
      if ( ( ( manyB === true )&&(iOwig.EdKcipChk( iOwig.EKcipEdRequist ) === false ))
      || ( needXnoB === true ) ) {
        aQtype = iOwig.EQtypeEno;
        }
      }
    }
  return aQtype;
  };
TOwig.prototype.specialNode = function specialNode( iEl ) {
  var iOwig = this;
  var specB = true;
/*
  if ( iEl.className.indexOf( 'zEntryBox' ) > -1 ) { // 4th Last slot ( optional )
    iOwig.entryBoxNode = iEl;
    }
  else 
*/
  if ( iEl.className.indexOf( 'zUnspec' ) > -1 ) { // 3rd last slot ( optional )
    iOwig.Otmr.unspecNode = iEl;
    }
  else if ( iEl.className.indexOf( 'zMsgWif' ) > -1 ) { // 2nd last slot ( optional )
    iOwig.Otmr.messageNode = iEl;
    }
  else if ( iEl.className.indexOf( 'zGroupButs' ) > -1 ) { // last slot ( optional )
    iOwig.Otmr.buttonsNode = iEl;
    }
  else {
    specB = false;
    }
  return specB;
  };
TOwig.prototype.EKisuNone = 0;  // used ??
TOwig.prototype.EKisuView = 1;  // change of view
TOwig.prototype.EKisuSubjInst = 2;  // change instance
TOwig.prototype.EKisuLinks = 3;  // change all
TOwig.prototype.EKisuSKvli = 4;  // change of SKvli
TOwig.prototype.EKisuType = 5;  // change of Type/Httm
TOwig.prototype.EKisuComplex = 6;  // Httm or Hvtm
TOwig.prototype.EKisuHttmRoleInst = 7;
TOwig.prototype.EKisuHttmTypeNull = 8;
TOwig.prototype.EKisuVfaInst = 9;
TOwig.prototype.EKisuBookMark = 10;
TOwig.prototype.EEKisuOther = 11;
//
TOwig.prototype.EKcipEdit = 0;
TOwig.prototype.EKcipPots = 1;
TOwig.prototype.EKcipClosed = 2;
TOwig.prototype.EKcipManditory = 3;
TOwig.prototype.EKcipSwitch = 4;
TOwig.prototype.EKcipUnique = 5;
TOwig.prototype.EKcipSecDisp = 6;
TOwig.prototype.EKcipNewOnly = 7;
TOwig.prototype.EKcipNoDel = 8;
TOwig.prototype.EKcipOrderable = 9;
TOwig.prototype.EKcipEdRequist = 10;
TOwig.prototype.EKcipManyPot = 11;
//
TOwig.prototype.EKcipText = 12;
TOwig.prototype.EKcipNumeric = 13;
TOwig.prototype.EKcipDate = 14;
TOwig.prototype.EKcipTRef = 15;
TOwig.prototype.EKcipNameIsId = 16;
//
TOwig.prototype.EKcipUp = 17;
TOwig.prototype.EKcipDown = 18;
TOwig.prototype.EKcipOrder = 19;
TOwig.prototype.EKcipCompact = 20;
TOwig.prototype.EKcipCollapse = 21;
TOwig.prototype.EKcipSeperateDrop = 22;
TOwig.prototype.EKcipPerLine = 23;
TOwig.prototype.EKcipNonInstHdr = 24;
//
TOwig.prototype.EKcipMemberShow = 25;
TOwig.prototype.EKcipMemberEdit = 26;
TOwig.prototype.EKcipMemberClone = 27;
TOwig.prototype.EKcipMemberRemove = 28;
TOwig.prototype.EKcipMemberNew = 29;
TOwig.prototype.EKcipAllNone = 30;
TOwig.prototype.EKcipTypeCount = 31;
//
TOwig.prototype.EKcipChange = 32;
TOwig.prototype.EKcipSwChange = 33;
TOwig.prototype.EKcipUnchecked = 34;
TOwig.prototype.EKcipFailed = 35;
TOwig.prototype.EKcipMissMand = 36;
TOwig.prototype.EKcipSubChange = 37;
TOwig.prototype.EKcipSubUnchecked = 38;
//
TOwig.prototype.EKcipQualInst = 39;
TOwig.prototype.EKcipQualAssoc = 40;
TOwig.prototype.EKcipTitle = 41;
TOwig.prototype.EKcipEditable = 42;
//
// TOtmr.prototype.EKCntrIdBox = 1;  // small entry box for instance identification
// TOtmr.prototype.EKCntrTextArea = 2;  // text editing area
// TOtmr.prototype.EKCntrEmptyEntryBox = 5;  // empty id box, becomes gKCntrIdBox on text entry
TOtmr.prototype.EKCntrTentLink = 1;  // link to newly (not commited) instance
TOtmr.prototype.EKCntrPermLink = 2;  // link to commited instance
// keep following in order of display
TOtmr.prototype.EKCntrUnSpec = 3;    // "none" choice for unique selection
TOtmr.prototype.EKCntrMessage = 4;  // exception message
//
TOwig.prototype.EQtypeTmo = 1;  // open list tick boxs
TOwig.prototype.EQtypeTco = 2;  // text control
TOwig.prototype.EQtypeUno = 3;  // xNo control - unique
TOwig.prototype.EQtypeEno = 4;  // xNo control - non unique
TOwig.prototype.EQtypeCno = 5;  // xNo control - checkbox dropdown
//
TOwig.prototype.EXnoData = 0;
TOwig.prototype.EUnoUnspec = 1;
TOwig.prototype.EXnoNew = 2;
TOwig.prototype.EUnoMove = 3;
TOwig.prototype.EUnoWait = 4;
TOwig.prototype.EEnoActAllNone = 5;
TOwig.prototype.EUnoPosAllNone = 6;
TOwig.prototype.EXnoCollapse = 7;
TOwig.prototype.EXnoDataNew = 8; // insert new returned entry 
TOwig.prototype.ECnoButs = 9; // cno all/none/done buttons
TOwig.prototype.EXnoPageReq = 10;
//
TOwig.prototype.EKefvNone = 0;
TOwig.prototype.EKefvTest = 1; // unVerificated - yellow
TOwig.prototype.EKefvNak = 2; // verified Fail
TOwig.prototype.EKefvAck = 3; // verified Ok
//
TOwig.prototype.getInstOwif = function getInstOwif( iOpid, iMatchEinB ) {
  var iOwig = this;
  var aOwif;
  var rOwif = null;
/*
  var aS = "iOpid.einS:" + iOpid.einS
  + " iMatchEinB:" + iMatchEinB
  + " iOpid.tentN:" + iOpid.tentN
  + " iOpid.hojS:" + iOpid.hojS;
*/
  if ( iOpid.Exno === iOwig.EXnoDataNew ) {
    /*jsl:pass*/
    }
  else {
    for ( iOwig.fiActOwif(); (aOwif=iOwig.nxActOwif()); ) {
/*
      aS += ' aOwif.Opid.hojS:' + aOwif.Opid.hojS
      + ' aOwif.Opid.einS ' + aOwif.Opid.einS 
      + ' aOwif.Opid.tentN:' + aOwif.Opid.tentN;
*/
      if (( aOwif.Opid.hojS == iOpid.hojS )&&( aOwif.Opid.tentN == iOpid.tentN )) {
        if ( ( iMatchEinB === false ) || ( aOwif.Opid.einS == iOpid.einS ) ) {
          rOwif = aOwif;
          }
        }
      }
//    alert( aS + " ( rOwif === null ):" + ( rOwif === null ) );
    if ( rOwif === null ) { 
      for ( iOwig.fiPotOwif(); (aOwif=iOwig.nxPotOwif()); ) {
        if (( aOwif.Opid.hojS == iOpid.hojS )&&( aOwif.Opid.tentN == iOpid.tentN )) {
          if ( ( iMatchEinB === false ) || ( aOwif.Opid.einS == iOpid.einS ) ) {
            rOwif = new cloneObject( aOwif );
            iOwig.actAOwif[ iOwig.actAOwif.length ] = rOwif;
            // EdLog( 'add actual length:' + iOwig.actAOwif.length + " aOwif.Opid.hojS " + aOwif.Opid.hojS );
            }
          }
        }
      }
    }
  return rOwif;
  };
function cloneObject(what) {
  var i;
  for ( i in what) {
    this[i] = what[i];
    }
  }
//  
// thru all actual/delta/pot in order  
TOwig.prototype.fiOrdOwif = function fiOrdOwif( iIncActualB, incSearchB ) {
  var aOwig = this;
  aOwig.ordAOwif = [];
  aOwig.nxOrdIOwif = 0;
  var bOwif, aIAOwif,inxAOprf,aOprf;
  // add pots first
  var inxAOwif, nxOwif, inxActAOwif, nxActOwif;
  // EdLog( "aOwig.Opog.AOwif:" + aOwig.Opog.AOwif.length ); 
  var uC;
  if ( incSearchB === true ) { uC = aOwig.Opog.AOwif.length; }
  else { uC = aOwig.Opog.recentN; }
  for ( inxAOwif=0; (inxAOwif<uC); inxAOwif++ ) {
    nxOwif = aOwig.Opog.AOwif[inxAOwif];
    if ( nxOwif.aStD === null ) { nxOwif.EdQdbDecodeState( "00000" ); }
    if ( nxOwif.curTextS === null ) { nxOwif.curTextS = nxOwif.origTextS; }
    aOwig.ordAOwif[ aOwig.ordAOwif.length ] = nxOwif;
    }
  // EdLog( "fiOrdOwif-10 inxAOwif:" + inxAOwif + " uC:" + uC 
  // + " incSearchB:" + incSearchB );
  // actuals modify or add to list
  if ( iIncActualB === true ) {
    for ( inxAOwif=0; (nxOwif=aOwig.actAOwif[inxAOwif++]); ) {
      if ( nxOwif.aStD === null ) { nxOwif.EdQdbDecodeState( "00000" ); }
      if ( nxOwif.curTextS === null ) { nxOwif.curTextS = nxOwif.origTextS; }
      aIAOwif = aOwig.ordAOwif.length;
      // to end of list OR replacing prior potential
      if ( nxOwif.Oein ) {
        for ( inxAOprf=0; (aOprf=nxOwif.Oein.AOprf[inxAOprf++]); ) {
          if ( aOprf.cnnAllocN === aOwig.cnnAllocN ) { 
            aIAOwif = aOprf.IAOwif;
            }
          }
        }
      aOwig.ordAOwif[ aIAOwif ] = nxOwif;
      }
    }
  // EdLog( "fiOrdOwif-20 aOwig.ordAOwif.length:" + aOwig.ordAOwif.length );
  //  EdLog( aS );
  };
TOwig.prototype.laOrdOwif = function laOrdOwif() {
  var aOwig = this;
  aOwig.nxOrdIOwif = aOwig.ordAOwif.length;
  };
TOwig.prototype.nxOrdOwif = function nxOrdOwif() {
  var aOwig = this;
  var aOwif = aOwig.ordAOwif[ aOwig.nxOrdIOwif ];
  if ( typeof aOwif === 'undefined' ) { aOwif = null; }
  else { aOwig.nxOrdIOwif++; }
  return aOwif;
  };
//  
// thru all actual/delta no particular order  
TOwig.prototype.fiActOwif = function fiActOwif() {
  var aOwig = this;
  aOwig.nxActIOwif = 0;
  };
TOwig.prototype.laActOwif = function laActOwif() {
  var aOwig = this;
  aOwig.nxActIOwif = aOwig.actAOwif.length;
  };
TOwig.prototype.nxActOwif = function nxActOwif() {
  var aOwig = this;
  var aOwif = aOwig.actAOwif[ aOwig.nxActIOwif ];
  if ( typeof aOwif === 'undefined' ) { aOwif = null; }
  else { aOwig.nxActIOwif++; }
  return aOwif;
  };
//  
// thru all pots no particular order  
TOwig.prototype.fiPotOwif = function fiPotOwif() {
  var aOwig = this;
  aOwig.nxPotIOwif = 0;
  };
TOwig.prototype.laPotOwif = function laPotOwif() {
  var aOwig = this;
  aOwig.nxPotIOwif = aOwig.Opog.AOwif.length;
  };
TOwig.prototype.nxPotOwif = function nxPotOwif() {
  var aOwig = this;
  var aOwif = aOwig.Opog.AOwif[ aOwig.nxPotIOwif ];
  if ( typeof aOwif === 'undefined' ) { aOwif = null; }
  else { aOwig.nxPotIOwif++; }
  return aOwif;
  };
//
TOwig.prototype.addNewOwif = function addNewOwif( iOwif ) {
  var aOwig = this;
  var aOwif;
  if ( iOwif === null ) { aOwif = new TOwif( aOwig, aOwig.groupN ); }
  else { 
    aOwif = iOwif; 
    }
  aOwig.actAOwif[ aOwig.actAOwif.length ] = aOwif;
  return aOwif;
  };
TOwig.prototype.swapOwif = function swapOwif( iAOwif, iBOwif, iAfterB ) {
  var aOwig = this;
  var i,l,aOwif;
  var fromInx = -1;
  var toInx = -1;
  for ( i=0,l=aOwig.actAOwif.length; i<l; i++ ) {
    aOwif=aOwig.actAOwif[i];
    if ( aOwif === iAOwif ) { fromInx = i; }
    if ( aOwif === iBOwif ) { toInx = i; }
    }
  // alert( "fromInx:" + fromInx + " toInx:" + toInx + " iAfterB" + iAfterB
  // + " iAOwif:" + iAOwif + " iBOwif:" + iBOwif );
  if ( iAfterB === true ) { toInx++; }
  if (( fromInx !== toInx )&&( fromInx > -1 )&&( toInx >- 1 )) {
    aOwig.actAOwif.splice(fromInx,1);
    if ( toInx>fromInx ) { toInx--; }
    aOwig.actAOwif.splice( toInx, 0, iAOwif );
    }
  };
TOwig.prototype.EdKcipChk = function EdKcipChk( iKcip ) {
  var aOwig = this;
  return ( aOwig.SKcip.substr( iKcip, 1 ) == '1' );
  };
TOwig.prototype.EdKcipSet = function EdKcipChk( iKcip, iB ) {
  var aOwig = this;
  var aSKcipS = aOwig.SKcip;
  while ( aSKcipS.length < iKcip ) { aSKcipS += '0'; }
  aOwig.SKcip = aSKcipS.substr( 0, iKcip );
  if ( iB === true ) { aOwig.SKcip += '1'; } else { aOwig.SKcip += '0'; }
  aOwig.SKcip += aSKcipS.substr( iKcip+1, aSKcipS.length );
  };
TOwig.prototype.EdFindWithinGroupEl = function EdFindWithinGroupEl( iEl ) {
  var aOwig = this;
  var nxEl = iEl;
  var prEl = iEl;
  var doneB = false;
  // defaultStatus = nxEl.tagName;
  while ( doneB === false ) {
    if ( nxEl.tagName == "NOBR" ) { 
      prEl = nxEl; 
      nxEl = nxEl.parentNode; 
      }
    else if ((nxEl.className)&&( nxEl.className.substr( 0, 4 )=='zWid' )) { 
      prEl = nxEl; 
      nxEl = nxEl.parentNode; 
      }
    else if (( nxEl.id ) && ( nxEl.id.substr( 0, 5 )=='idEfG' ) ) { 
      prEl = nxEl; 
      nxEl = nxEl.parentNode; 
      }
    else { doneB = true; }
    }
  return prEl;
  };
TOwig.prototype.bldNestIdEl = function( iOwif, iSubOwig ) {
  var iOwig = this;
  var nod1 = document.createElement('input');
  nod1.type = "hidden";  
  nod1.name = "nestPath";
  nod1.value = iSubOwig.selfIdN;
  return nod1;
  };
//
// build outer levels of Xno
// if iDropB create as new absolute positioned div
// 
TOwig.prototype.zWigQualS = function( iQtype, iKXnoSt ) {
  var iOwig = this;
  var bS = "";
  if ( iQtype === iOwig.EQtypeEno ) { bS = "zEno"; }
  else if ( iQtype === iOwig.EQtypeUno ) { bS = "zUno"; }
  else if ( iQtype === iOwig.EQtypeCno ) { bS = "zCno"; }
  else { alert( "bldEnoAll Qtype wrong:" + iOwig.toQtypeS(iQtype) ); }
  if ( iKXnoSt === KXnoStOpen ) { bS += ' zOpen'; }
  else if ( iKXnoSt === KXnoStClosed ) { bS += ' zClosed'; }
  return bS;
  };
TOwig.prototype.bldXnoShell = function bldXnoShell( nod1, iDropB ) {
  var iOwig = this;
  var nod2A, nod2B, nod2C;  // nod2 inners
  var nxOWif = null;
  var aS = "";
/*
  alert( "EKcipCollapse:" + iOwig.EdKcipChk( iOwig.EKcipCollapse ) 
  + " EKcipNonInstHdr:" + iOwig.EdKcipChk( iOwig.EKcipNonInstHdr )
  + " wigKXnoSt:" +  iOwig.wigKXnoSt
  + " Qtype:" + iOwig.Qtype 
  );
*/
  if ( iOwig.needHdrInst() === true ) {
    nod2A = gAOkel[KEdUspan].insert(nod1); 
    nod2A.className = "zEdUSpan" + iOwig.EKefvNone;
    nod2A.style.cursor = "pointer";
    nod2A.insertBefore( document.createTextNode(iOwig.uniqNowOwif.curTextS), null );
    // alert( "bldXnoShell-10 " );
    }
  else if ( iOwig.needHdrText() === true ) {
    nod2A = gAOkel[KEdUspan].insert(nod1); 
    nod2A.className = "zEdUSpan" + iOwig.EKefvNone;
    nod2A.style.cursor = "pointer";
    var bS = "";
    if ( iOwig.titleImgS !== "" ) { 
      // get EKcipUnchecked ??
      if ( iOwig.titleImgS.indexOf( "filter" ) !== -1 ) { 
        iOwig.dropImageEl = iOwig.Owin.nscCloneImg( 'filter' );
        }
      else if ( iOwig.titleImgS.indexOf( "black" ) !== -1 ) { 
        iOwig.dropImageEl = iOwig.Owin.nscCloneImg( 'down' );
        }
      else {
        iOwig.dropImageEl = iOwig.Owin.nscCloneImg( 'ctm' );
        }
      iOwig.dropImageEl.alt = iOwig.titleS;
      if (( iOwig.EdKcipChk( iOwig.EKcipUnchecked ) === true ) 
      || ( iOwig.EdKcipChk( iOwig.EKcipSubUnchecked ) === true )
      || ( iOwig.chkSubKcip( iOwig.EKcipUnchecked ) === true )
      ) { 
        iOwig.dropImageEl.className = 'zDropIcon1';
        }
      else {
        iOwig.dropImageEl.className = 'zDropIcon0';
        }
      nod2A.insertBefore( iOwig.dropImageEl, null );
      }
    else {
      if ( iOwig.titleS !== "" ) { bS = iOwig.titleS; }
      else if ( iOwig.uniqNowOwif ) { bS = iOwig.uniqNowOwif.curTextS; }
      else { bS = 'No Value'; }
      nod2A.insertBefore( document.createTextNode(bS), null );
      }
    // alert( "bldXnoShell-20 " + nod2A.outerHTML
    // + " iOwig.uniqNowOwif.curTextS " + iOwig.uniqNowOwif.curTextS 
    // + " iOwig.titleS " + iOwig.titleS
    // );
    }
  else if (( iOwig.wigKXnoSt === KXnoStMinimized )&&( iOwig.EdKcipChk( iOwig.EKcipCollapse ) === true)) {
    gThisCaseB = true;
    nod2B = gAOkel[KUnoCnoSpanIP].insert(nod1); 
    iOwig.bldXnoInputText( true, nod2B );
    gThisCaseB = false;
    // alert( "bldXnoShell-30 " );
    }
  else if (( iOwig.Qtype === iOwig.EQtypeEno )
  ||( iOwig.Qtype === iOwig.EQtypeUno )
  ||( iOwig.Qtype === iOwig.EQtypeCno )) { 
    // inline block with 2 or 3 divs
    nod2A = gAOkel[KUnoCnoControl].insert(null); 
    // nod2A.style.display = edInlineBlockS();
    if ( iOwig.needActual( iDropB ) === true ) {
      nod2B = gAOkel[KUnoCnoPots].insert(nod2A); 
      iOwig.bldXnoLstHolder( nod2B, iOwig.listSuffix( false ) ); // "Ena"
      }
    // next part - input box
    if ( ( iDropB === true ) && ( iOwig.Qtype === iOwig.EQtypeUno )
    && ( iOwig.EdKcipChk( iOwig.EKcipSeperateDrop ) === true ) ) {
      // search box in header
      /*jsl:pass*/
      }
    else {
      nod2B = gAOkel[KUnoCnoIP].insert(nod2A); 
      if ( iOwig.needSearch() ) {
        if ( iOwig.needUspan() ) {
          iOwig.uSpanText( nod2B ); 
          }
        else { 
          iOwig.uTextBox( false, nod2B );  // iActiveB=false
          }
        }
      }
    // next part - potentials
    nod2B = gAOkel[KUnoCnoPots].insert(nod2A); 
    nod2B.style.display = "none";
    iOwig.bldXnoLstHolder( nod2B, iOwig.listSuffix( true ) );
    //
    nod1.insertBefore( nod2A, null );
    }
  return nod1;
  };
TOwig.prototype.needSearch = function ( ) {
  var aOwig=this;
  var searchB = (( aOwig.Qtype !== aOwig.EQtypeUno )
  && ( aOwig.EdKcipChk( aOwig.EKcipCollapse ) === true )
  && ( aOwig.EdKcipChk( aOwig.EKcipPots ) === true )
  && ( aOwig.Qtype === aOwig.EQtypeEno ))
  || ( aOwig.EdKcipChk( aOwig.EKcipNonInstHdr ) === false );
  return searchB && ( aOwig.EdKcipChk( aOwig.EKcipNewOnly ) === false );         
  };
function getCurOwig( iOwin, iRootOwig ) {
  var bOwig;
  if ( gOpenSelfIdEl !== gOpenRootIdEl ) {
    var aRootOwig = null;
    if ( iRootOwig === null ) {
      aRootOwig = new TOwig();
      aRootOwig.fromIdEl( iOwin, gOpenRootIdEl, true );
      }
    else { aRootOwig = iRootOwig; }

    var aN = parseInt( gOpenSelfIdEl.value, 10 );
    var wigS = wigSbyId( gOpenRootIdEl.value, aN );
    bOwig = new TOwig();
    bOwig.groupN = aN; // ?? inx-1;
    bOwig.recMakeOwig( null, iOwin, wigS, false );

    // bOwig = aRootOwig.getSubOwig( gOpenSelfIdEl );
    bOwig.selfIdEl = gOpenSelfIdEl;
    bOwig.groupEl = bOwig.selfIdEl.parentNode;
    }
  else {
    // alert( 'not subOwig ' + gOpenSelfIdEl.value );
    bOwig = new TOwig();
    bOwig.fromIdEl( iOwin, gOpenSelfIdEl, true );
    }
  return bOwig;
  }
TOwig.prototype.toKXnoSt = function toKXnoSt( iKXnoSt ) {
  // defaultStatus += " toKXnoSt:" + iKXnoSt;
  var aOwig = this;
  var bOwig;
  var aOwin = aOwig.Owin;
  aOwig.getDropHeader( aOwig.rootIdEl );
  if ( aOwig.dropImageEl ) {
    if ( iKXnoSt === KXnoStMinimized ) { aOwig.dropImageEl.alt = aOwig.titleS; }
    else { aOwig.dropImageEl.alt = ''; }
    }
  if ( iKXnoSt !== KXnoStMinimized ) {
    // something else at same level open ?
    if (( gOpenSelfIdEl !== null ) && ( gOpenSelfIdEl !== aOwig.selfIdEl )
    && ( gOpenSelfIdEl !== aOwig.rootIdEl )) {
      bOwig = getCurOwig( aOwin, aOwig.paOwig );
      bOwig.rootIdEl = aOwig.rootIdEl;
      bOwig.toKXnoSt( KXnoStMinimized );
      // alert( 'closed brother' );
      }
    }
  // if ( aOwig.rootIdEl !== aOwig.selfIdEl ) {
    // alert( "toKXnoSt on sub:" + aOwig.selfIdEl.parentNode.innerHTML );
    // }
  aOwig.capture( true, iKXnoSt );
  var divEl;
  aOwig.summary();
  gBlurUnoEl = null;  // ??? checked below
  // EdLog( "gOpenRootIdEl Cleared" );
  gXnoStartN = 1;
  if ( ( iKXnoSt === KXnoStMinimized )
  && ( aOwig.Qtype === aOwig.EQtypeUno )
  && ( aOwig.potOwil.divEl.style.display != "none" ) ) {
    aOwig.potOwil.divEl.style.display = "none";
    }
  aOwig.newlyOpenB = ( iKXnoSt === KXnoStOpen ) && ( aOwig.prKXnoSt !== KXnoStOpen );
  if ( aOwig.newlyOpenB === true ) {
    aOwig.searchS = '';
    if ( aOwig.EdKcipChk( aOwig.EKcipNonInstHdr ) === true ) {
      aOwig.textEl = null;
      }
    if ( gBlurUnoEl !== null ) { 
      aOwig.Owin.getWigPosns( gBlurUnoEl );
      if ( aOwig.Owin.rootIdEl !== aOwig.rootIdEl ) {
        bOwig = makeTargOwig( aOwig.Owin, gBlurUnoEl, true );
        bOwig.toKXnoSt( KXnoStMinimized );
        gBlurUnoEl = null;
        }
      }
    aOwig.setFocusB = true;
    }
  else if ( iKXnoSt !== KXnoStOpen ) {
    aOwig.unFocusB = true;
    }
  aOwig.bldRequired( 2 );
  aOwig.Owin.pageButsPerState( );
  };
TOwig.prototype.editGroup = function editGroup( ) {
  var iOwig=this;
  var aOwif;
  var aS = "";
  var bS = "";
  for ( iOwig.fiActOwif(); (aOwif=iOwig.nxActOwif()); ) {
    aOwif.nowState();
    if ( aOwif.aStD.nowSelectB === true ) {
      bS += '(' + aOwif.Opid.hojS + ')';
      aS += aOwif.encodeEin(); // 
      }
    }
  if ( aS !== "" ) {
    var aOlnk = new TOlnk( iOwig.newUrlS );
    var fullUrlS = aOlnk.replaceInst( '(' + bS + ')', true );
    var aOreq = new TOreq( iOwig.Owin );
    aOreq.Kreq = gKreqEdit;
    aOreq.urlS = fullUrlS;
    aOreq.efS = aS;
    aOreq.Kpt = gKptNewWindow;
    aOreq.issue(); 
    }
  };
TOwig.prototype.loneUniq = function loneUniq( ) {
  var iOwig=this;
  return iOwig.EdKcipChk( iOwig.EKcipUnique )
  && ( iOwig.EdKcipChk( iOwig.EKcipSecDisp ) === false )
  // && ( iOwig.EdKcipChk( iOwig.EKcipPots ) === false )
  && (( iOwig.EdKcipChk( iOwig.EKcipClosed ) === true )
    || ( iOwig.EdKcipChk( iOwig.EKcipNameIsId ) === true )
    || ( iOwig.EdKcipChk( iOwig.EKcipNumeric ) === true )
    || ( iOwig.EdKcipChk( iOwig.EKcipText ) === true )
    )
  && ( (iOwig.actAOwif.length+iOwig.Opog.AOwif.length) === 1 );
  };
//
// update status part of iOwig.SKcip
TOwig.prototype.updateStatusSKcip = function updateStatusSKcip( ) {
  var iOwig=this;
  var Ocuf = new Object();
  Ocuf.changeB = false;
  Ocuf.uncheckedB = false;
  Ocuf.swChangeB = false;
  Ocuf.missMandB = false;
  Ocuf.selCnt = 0;
  var nxOwif = null;
  for ( iOwig.fiActOwif(); (nxOwif=iOwig.nxActOwif()); ) {
    nxOwif.OcufUpdate( Ocuf );
    }
  if ( ( Ocuf.selCnt === 0 ) 
  && ( iOwig.EdKcipChk( iOwig.EKcipManditory ) === true ) ) {
    Ocuf.missMandB = true;
    }
  iOwig.EdKcipSet( iOwig.EKcipChange, Ocuf.changeB );
  iOwig.EdKcipSet( iOwig.EKcipUnchecked, Ocuf.uncheckedB );
  iOwig.EdKcipSet( iOwig.EKcipSwChange, Ocuf.swChangeB );
  iOwig.EdKcipSet( iOwig.EKcipMissMand, Ocuf.missMandB );
  };
function getWigSelfId( iWigS ) {
  var wifSS = fsSplit( iWigS );
  var hdrS = wifSS[0];
  var nS = hdrS.substring( 0, hdrS.indexOf( 'W' ) );
  var nN = parseInt( nS, 10 );
  return nN;
  }
TOwig.prototype.saveAll = function saveAll( ) {
  var bOwig, bOwigS,nxOwif,cOwigS,rootOwigS;
  var iOwig=this;
  iOwig.updateStatusSKcip();
  bOwigS = yyStr( iOwig.encodeActHdr() );
  for ( iOwig.fiActOwif(); ( nxOwif=iOwig.nxActOwif()); ) {
    bOwigS += yyStr( nxOwif.encodeInst() );
    }
  // var rootOwig = makeTargOwig( iOwig.Owin, iOwig.rootIdEl, true );
  var doneB = false;
  var rS = '';
  var wigSS = fsSplit( iOwig.rootIdEl.value );
  // alert( 'yyStr( cS )' + yyStr( cS ) + ' iOwig.selfId:' + iOwig.selfIdN + ' ' + (iOwig.selfIdN===18) );
  var changeB = false;
  var uncheckB = false;
  for ( var i=0,l=wigSS.length; i<l; i++ ) {
    if ( iOwig.selfIdN !== getWigSelfId( wigSS[i] ) ) {
      cOwigS = wigSS[i];
      }
    else {
      cOwigS = bOwigS;
      doneB = true;
      }
    if ( i !== 0 ) {
      bOwig = new TOwig();
      bOwig.groupN = i;
      bOwig.SKcip = fsSplit( cOwigS )[0].split('W')[1]; // much faster than below ??
      // bOwig.recMakeOwig( null, iOwig.Owin, cOwigS, false );
      if ( bOwig.EdKcipChk( bOwig.EKcipChange) === true ) { changeB = true; }
      if ( bOwig.EdKcipChk( bOwig.EKcipUnchecked) === true ) { uncheckB = true;}
      }
    if ( i === 0 ) { rootOwigS = cOwigS; }
    else { rS += yyStr( cOwigS ); }
    }
  // alert( 'iOwig.selfId:' + iOwig.selfIdN + ' rS:' + rS + ' cS:' + cS );
  //if ( gThisCaseB === true ) { alert( 'changeB:' + changeB + ' uncheckB:' + uncheckB ); }
  iOwig.rootIdEl.value 
  = yyStr( iOwig.combinedRootWigS( rootOwigS, changeB, uncheckB ) ) + rS;
  if ( doneB === false ) { bomb(); }
  };
TOwig.prototype.combinedRootWigS = function( iRootWigS, iChangeB, iUncheckB ) {
  var iOwig = this;
  var bOwig = new TOwig();
  bOwig.groupN = 0;
  bOwig.SKcip = fsSplit( iRootWigS )[0].split('W')[1]; // much faster than below ??
  // bOwig.recMakeOwig( null, iOwig.Owin, iRootWigS, false );
  bOwig.EdKcipSet( bOwig.EKcipSubChange, iChangeB );
  bOwig.EdKcipSet( bOwig.EKcipSubUnchecked, iUncheckB );
  // alert( 'changeB:' + changeB + ' uncheckB:' + uncheckB );
  return replaceStatus( fsSplit( iRootWigS ), bOwig.SKcip );
  };
function yyStr( iS ) {
  return 'Y' + iS.length + 'Y' + iS;
  }
//
TOwig.prototype.encodeActHdr = function encodeActHdr( ) {
  var iOwig = this;
  var aS = iOwig.selfIdN + 'W';
  aS += iOwig.SKcip + 'W';
  aS += iOwig.typeS + 'W';
  aS += iOwig.cnnAllocN + 'W';
  aS += iOwig.widthEmS + 'W';
  aS += iOwig.newUrlS + 'W';
  aS += iOwig.abIdS + 'W';
  aS += iOwig.Kisu + 'W';
  aS += iOwig.titleS + 'W';
  aS += iOwig.titleImgS + 'W';
  return aS;
  };
TOpog.prototype.encodePogHdr = function encodePogHdr( ) {
  var iOpog = this;
  var aS = iOpog.typeS + 'W';
  aS += iOpog.newUrlS + 'W';
  aS += iOpog.recentN + 'W';
  var inx, aOsrc;
  for ( inx = 0; (aOsrc=iOpog.AOsrc[inx++]); ) {
    aS += aOsrc.srcEncode() + 'W';
    }
  return aS;
  };
function replaceStatus( iWifSS, iSKcip ){ 
  var iOwig = this;
  var newWigS = '';
  var hdrS,i,j,aSSl,fldS,wifS,aSS;
  var l = iWifSS.length;
  for ( i=0; i<l; i++) {
    wifS = iWifSS[i];
    if ( i === 0 ) { // hdr not wif
      aSS = wifS.split('W');
      hdrS = '';
      aSSl = aSS.length-1; // skip blank on end
      for ( j=0; j<aSSl; j++ ) {
        fldS = aSS[j];
        if ( j === 1 ) { hdrS += iSKcip + 'W'; }
        else { hdrS += fldS + 'W'; }
        }
      newWigS += yyStr( hdrS );
      }
    else {
      newWigS += yyStr( wifS );
      }
    }
  return newWigS;
  }
TOwig.prototype.saveNewHdr = function saveNewHdr( ){ 
  var iOwig = this;
  var wigS,wifSS,hdrS,nS,nN;
  var changeB = false;
  var uncheckB = false;
  var bOwig;
  iOwig.updateStatusSKcip();
  var newValS = '';
  var rootWigS = '';
  var bS = iOwig.rootIdEl.value;
  var wigsSS = fsSplit( bS );
  var l = wigsSS.length;
  for ( var i=0; i<l; i++) {
    wigS = wigsSS[i];
    wifSS = fsSplit( wigS );
    hdrS = wifSS[0];
    nS = hdrS.substring( 0, hdrS.indexOf( 'W' ) );
    nN = parseInt( nS, 10 );
    if ( isNaN( nN ) ) { bomb(); }
    if ( iOwig.selfIdN === nN ) {
      wigS = replaceStatus( wifSS, iOwig.SKcip );
      }
    if ( i === 0 ) { rootWigS = wigS; }
    else { 
      newValS += yyStr( wigS ); 
      bOwig = new TOwig();
      // bOwig.groupN = i;
      bOwig.SKcip = wifSS[0].split('W')[1]; // much faster than below ??
      // bOwig.recMakeOwig( null, iOwig.Owin, wigS, false );
      if ( bOwig.EdKcipChk( bOwig.EKcipChange) === true ) { changeB = true; }
      if ( bOwig.EdKcipChk( bOwig.EKcipUnchecked) === true ) { uncheckB = true;}
      }
    }
  iOwig.rootIdEl.value 
  = yyStr( iOwig.combinedRootWigS( rootWigS, changeB, uncheckB ) ) + newValS;
  };
TOwig.prototype.chkSubKcip = function ( iKcip ){ 
  var iOwig = this;
  var wigS, bOwig;
  var changeB = false;
  var wigsSS = fsSplit( iOwig.rootIdEl.value );
  for ( var i=1; (wigS = wigsSS[i++]); ) {
    bOwig = new TOwig();
    bOwig.SKcip = fsSplit( wigS )[0].split('W')[1]; // much faster than below ??
    if ( bOwig.EdKcipChk( iKcip ) === true ) { changeB = true; }
    }
  return changeB;
  };
// 
// collect population stats to base layout/choice details apon
TOwig.prototype.summary = function summary( ) {
  var iOwig = this;
  iOwig.selectCnt = 0;
  iOwig.DbSelectCnt = 0;
  iOwig.carryCnt = 0;
  // var loneUniqB = iOwig.loneUniq();
  var nxOwif = null;
  iOwig.uniqNowOwif = null;
  iOwig.uniqDbOwif = null;
  iOwig.uniqCycleOwif = null;
  if ( iOwig.fullB === true ) {
    for ( iOwig.fiActOwif(); (nxOwif=iOwig.nxActOwif()); ) {
      if ( nxOwif.aStD.nowSelectB === true ) { 
        iOwig.uniqNowOwif = nxOwif;
        iOwig.selectCnt++; 
        }
      if ( nxOwif.aStD.DbSelectB === true ) { 
        iOwig.uniqDbOwif = nxOwif;
        iOwig.DbSelectCnt++; 
        }
      if ( nxOwif.aStD.cycleSelectB === true ) { 
        iOwig.uniqCycleOwif = nxOwif;
        }
      if ( nxOwif.aStD.carryB === true ) { iOwig.carryCnt++; }
      }
    iOwig.tickBoxB = ! ( ( iOwig.EdKcipChk( iOwig.EKcipNameIsId ) === true )
    && ( ( iOwig.EdKcipChk( iOwig.EKcipUnique ) === true ) ) );
    if ( iOwig.Opog.AOwif.length+iOwig.actAOwif.length < 1 ) { iOwig.tickBoxB = false; }
    iOwig.uniqueKefv = iOwig.EKefvNone; 
    if ( iOwig.EdKcipChk( iOwig.EKcipUnique ) ) {
      if ( iOwig.uniqNowOwif !== null ) {
        if ( iOwig.uniqNowOwif == iOwig.uniqCycleOwif ) {
          iOwig.uniqueKefv = iOwig.uniqNowOwif.aStD.Kefv; 
          }
        else {
          iOwig.uniqueKefv = iOwig.EKefvTest; 
          }
        }
      else if ( iOwig.EdKcipChk( iOwig.EKcipManditory ) === true ) {
        iOwig.uniqueKefv = iOwig.EKefvNak; 
        }
      else if ( iOwig.uniqCycleOwif !== null ) {
        iOwig.uniqueKefv = iOwig.EKefvTest; 
        }
      } 
    //
    iOwig.Otmr.getNeeds( iOwig );
    }
  };
TOtmr.prototype.getNeeds = function ( iOwig ) {
  var iOtmr = this;
  var loneUniqB = iOwig.loneUniq();
  iOtmr.checkboxB = false;
  if ( iOwig.EdKcipChk( iOwig.EKcipText ) === false ) {
    if ( iOwig.EdKcipChk( iOwig.EKcipUnique ) ) {
      if ( loneUniqB === true ) { iOtmr.checkboxB = true; }
      else if ( iOwig.Opog.AOwif.length+iOwig.actAOwif.length === 0 ) { iOtmr.checkboxB = true; }
      else { iOtmr.checkboxB = false; }
      }
    else {
      iOtmr.checkboxB = true;
      }
    }
  iOtmr.needUnspecB = false;
  // iOtmr.needEntryBoxB = false;
  iOtmr.needMessageB = false;
  if ( loneUniqB === false ) {
    var manditoryB = iOwig.EdKcipChk( iOwig.EKcipManditory );
    // determine unspec
    if (( iOtmr.checkboxB === false ) 
    && ( iOwig.EdKcipChk( iOwig.EKcipText ) === false ) ) {
      if ( manditoryB === false ) { 
        iOtmr.needUnspecB = true;
        }
      else if ( iOwig.selectCnt === 0 ) {
        iOtmr.needUnspecB = true;
        } 
      }
/*
    // determine entrybox
    iOtmr.needEntryBoxB = ( iOwig.EdKcipChk( iOwig.EKcipClosed ) === false )
    && ( iOwig.EdKcipChk( iOwig.EKcipText ) === false )
    && ( iOwig.EdKcipChk( iOwig.EKcipNewOnly ) === false )
    && ( ( iOwig.EdKcipChk( iOwig.EKcipUnique ) === false )
      ||( iOwig.carryCnt === 0 ) );
*/
    }
  iOtmr.needMessageB = ( manditoryB === true ) 
  && ( iOwig.selectCnt === 0 )
  && ( iOtmr.checkboxB === true )
  // && ( iOtmr.needEntryBoxB === false )
  && ( iOwig.EdKcipChk( iOwig.EKcipText ) === false );
  };
//
function TOtmo( iOwig ) {
  var aOtmo = this;
  aOtmo.AOtmi = [];
  var i, nxEl, aOtmi;
  for ( i=0; nxEl=iOwig.groupEl.childNodes[i++]; ) {
    if (( nxEl.className )
    && ( nxEl.className.indexOf( 'zWid' ) > -1 )) {
      aOtmi = new TOtmi( nxEl );
      aOtmo.AOtmi[ aOtmo.AOtmi.length ] = aOtmi;
      iOwig.specialNode( nxEl );
      }
    }
  }
TOtmo.prototype.getOtmi = function getOtmi( iOwif ) {
  var iOtmo = this;
  var aOtmi = null;
  var i, nxOtmi, aOwfid, aOpid;
  for ( i=0; (nxOtmi=iOtmo.AOtmi[i++]); ) {
    if ( nxOtmi.hideEl ) {
      aOpid = new TOpid();
      aOpid.decode( nxOtmi.hideEl.value );
      if ( ( aOpid.hojS == iOwif.Opid.hojS ) 
      // && ( aOpid.einS == iOwif.Opid.einS )
      && ( aOpid.tentN == iOwif.Opid.tentN ) ) { aOtmi = nxOtmi; }
      }
    }
  return aOtmi;
  };
TOtmr.prototype.bldTmoAll = function bldTmoAll( ) {
  var iOtmr = this;
  var iOwig = iOtmr.Owig;
  var aOtmi,nxOtmi;
  var insertPrNode = null;
  var nxOwif;
  var i,aOwfid;
  var aOtmo = new TOtmo( iOwig );
  var aEl = null;
  //
  // EdLog( "bldTmoAll groupN " + iOwig.groupN );
  //
  if ( gThisCaseB === true ) { alert( "A1" ); }
  for ( iOwig.fiOrdOwif(true,false); (nxOwif=iOwig.nxOrdOwif()); ) {
    nxOwif.Kcntr = iOtmr.getKcntr(nxOwif);
    // EdLog( "bldTmoAll nxOwif.Kcntr:" + nxOwif.Kcntr );
    nxOwif.nowState();
    aOtmi = aOtmo.getOtmi( nxOwif );
    if ( nxOwif.insertB === true ) {
      insertPrNode = null;
      if ( nxOwif.insertPrOwif ) {
        insertPrNode = nxOwif.insertPrOwif.wifEl;
        if ( insertPrNode.parentNode.className.substr( 0, 4 )=='zWid') {
          insertPrNode = insertPrNode.parentNode;
          }
        }
      if ( insertPrNode === null ) { insertPrNode = iOtmr.tmiGetInsPr( 1 ); }
      iOtmr.bldTmiAll( nxOwif, iOwig.nxOrdIOwif===1, insertPrNode );
      }
    else if (( iOwig.refreshAllB === true )||( nxOwif.refreshB === true )) {
      // rebuilds inner part only
      if ( aOtmi !== null ) {
        nxOwif.wifEl = aOtmi.Nod2;
        aOtmi.Nod2.innerHTML = "";
        iOtmr.bldTmiInner( nxOwif, aOtmi.Nod2 );
        nxOwif.nod1 = aOtmi.Nod1;
        nxOwif.nod2 = aOtmi.Nod2;
        nxOwif.markTemp();
        nxOwif.refreshB = false;
        }
      }
    else if ( iOwig.EdKcipChk( iOwig.EKcipText ) === false ) {
      nxOwif.redoTickBoxB = false;
      var newTickEl = nxOwif.bldTick( iOtmr.checkboxB );
      aOtmi.tickEl.parentNode.replaceChild( newTickEl, aOtmi.tickEl );
      }
    }
  // add or remove "unspec"
  iOwig.unspecOwif = iOtmr.tmiAddRemove( iOtmr.needUnspecB, iOtmr.unspecNode
  , iOtmr.EKCntrUnSpec );
  if ( iOwig.unspecOwif !== null ) { iOtmr.unspecNode = iOwig.unspecOwif.wifEl; }
  else { iOwig.Otmr.unspecNode = null; }
  // add or remove "entry box"
  // EdLog( "bldTmoAll groupN:" + iOwig.groupN 
  // + " iOtmr.needEntryBoxB:" + iOtmr.needEntryBoxB );
  // add or remove "message"
  iOwig.messageOwif = iOtmr.tmiAddRemove( iOtmr.needMessageB, iOtmr.messageNode
  , iOtmr.EKCntrMessage );
  if ( iOwig.messageOwif !== null ) {
    iOtmr.messageNode = iOwig.messageOwif.wifEl;
    }
  else {
    iOtmr.messageNode = null;
    }
  var bOtmo = new TOtmo( iOwig );
  // set check state, DONT work when making tick nodes ?
  if ( ( iOwig.EdKcipChk( iOwig.EKcipUnique ) === true ) ) {
    if ( iOwig.uniqNowOwif ) {
      iOwig.uniqNowOwif.tmiSetSelect( bOtmo );
      }
    }
  else {
    for ( iOwig.fiActOwif(); (nxOwif=iOwig.nxActOwif()); ) {
      nxOwif.tmiSetSelect( bOtmo );
      }
    }
  //  
  if ( iOwig.unspecOwif ) { iOwig.unspecOwif.tmiSetSelect( bOtmo ); }
  };
TOtco.prototype.bldTcoAll = function bldTcoAll( ) {
  var iOtco = this;
  var iOwig = iOtco.Owig;
  var insertPrNode = null;
  var nxOwif = null;
  var i,aOwfid;
  var aEl = null;
  //
  iOwig.fiOrdOwif(true,false); 
  nxOwif=iOwig.nxOrdOwif();
  if ( nxOwif === null ) {
    nxOwif = new TOwif( iOwig, iOwig.groupN );
    alert( "bldTcoAll NO Owif" );
    }
  nxOwif.nowState();
  insertPrNode = null;
  iOtco.nod1 = document.createElement('div');
  iOtco.nod1.className = 'zWidDiv';
  iOtco.nod2 = iOtco.nod1;
  iOtco.wifEl = iOtco.nod2;
  iOtco.bldTcoInner2( nxOwif, iOtco.nod2 );
  iOwig.groupEl.insertBefore( iOtco.nod1, insertPrNode );
  };
TOtmr.prototype.tmiGetInsPr = function tmiGetInsPr( iKcntr ) {
  var iOtmr = this;
  var iOwig = iOtmr.Owig;
  var insPrNode = null;
  if ( insPrNode === null ) {
    if ( iKcntr < iOtmr.EKCntrUnSpec ) { insPrNode = iOtmr.unspecNode; }
    }
  if ( insPrNode === null ) {
    if ( iKcntr < iOtmr.EKCntrMessage ) { insPrNode = iOtmr.messageNode; }
    }
  if ( insPrNode === null ) {
    insPrNode = iOtmr.buttonsNode;
    }
  return insPrNode;
  };
TOtmr.prototype.tmiRemove = function tmiRemove( iNode ) {
  var iOtmr = this;
  var iOwig = iOtmr.Owig;
  var aNode = iNode;
  // defaultStatus = "EdTmiRemove";
  if ( aNode.parentNode != iOwig.groupEl ) {
    aNode = aNode.parentNode; // get top zWid
    // defaultStatus += " to parent ";
    }
  var bNode = aNode.previousSibling;
  if ( ( bNode ) && ( bNode.nodeType == 3 ) ) {
    // defaultStatus += " del text ";
    iOwig.groupEl.removeChild( bNode );
    }
  else { 
    bNode = aNode.nextSibling;
    if ( ( bNode ) && ( bNode.nodeType == 3 ) ) {
      // defaultStatus += " del text ";
      iOwig.groupEl.removeChild( bNode );
      }
    }
  purge( aNode );
  iOwig.groupEl.removeChild( aNode );
  // defaultStatus += "\n\n aNode:" + aNode.innerHTML;
  // alert( defaultStatus );
  };
//
// builds eno select list, excluding choices
TOwig.prototype.bldXnoLstHolder = function bldXnoLstHolder( iPaEl, iS ) {
  var tableEl = gAOkel[KXnoListTable].insert(null); 
  var theadEl = gAOkel[KTableHead].insert(tableEl); 
  var tbodyEl = gAOkel[KTableBody].insert(tableEl);
  // tbodyEl.style.paddingLeft = 0; // TEST
  tbodyEl.className = "zSelTBody" + iS;
  iPaEl.insertBefore( tableEl, null );
  return tableEl;
  };
TOwig.prototype.refreshTmo = function( iUpdateButsB ) {
  var iOwig = this;
  var aQtype = iOwig.getQtype();
  if ( aQtype !== iOwig.Qtype ) {
    // alert( "change of Qtype prior:" + iOwig.Qtype + " now:" + iOwig.toQtypeS(aQtype) );
    // down with old
    var cEl;
    while ( (cEl=iOwig.groupEl.childNodes[1]) ) { // leave first = input hidden
      iOwig.groupEl.removeChild( cEl );
      }
    iOwig.Qtype = aQtype;
    iOwig.bldWig( null, -1 ); // up with new
    } 
  else {
    iOwig.summary(); 
    if ( gThisCaseB === true ) { alert( "in refresh " + iOwig.toQtypeS(iOwig.Qtype) ); }
    // rebuild required
    if ( gThisCaseB === true ) { alert( "call bldTmoAll" ); }
    iOwig.Otmr.bldTmoAll();
    }
  if ( iUpdateButsB === true ) {
    iOwig.Owin.pageButsPerState( );
    }
  };
TOwig.prototype.refreshTco = function( iUpdateButsB ) {
  var iOwig = this;
  var aQtype = iOwig.getQtype();
  if ( aQtype !== iOwig.EQtypeTco ) {
    alert( "refreshTco bad aQtype:" + aQtype );
    } 
  else {
    iOwig.summary(); 
    iOwig.Otco.bldTcoAll();
    }
  if ( iUpdateButsB === true ) {
    iOwig.Owin.pageButsPerState( );
    }
  };
TOwig.prototype.promptText = function promptText( ) {
  var iOwig = this;
  var aS = "";
  if ( iOwig.EdKcipChk( iOwig.EKcipNameIsId ) === true ) {
    aS = "Enter value";
    }
  else if ( iOwig.Qtype === iOwig.EQtypeUno ) { 
    if ( iOwig.Opog === null ) { aS = "Missing pot"; }
    else if ( iOwig.Opog.AOwif.length > 0 ) { aS = "Click to select one"; }
    else { aS = "Search for one"; } 
    }
  else if ( iOwig.Qtype === iOwig.EQtypeEno ) { 
    if ( iOwig.EdKcipChk( iOwig.EKcipCollapse ) === true ) {
      aS = "Refine selection list"; 
      }
    else {
      aS = "Click for selection list";
      } 
    }
  else if ( iOwig.Qtype === iOwig.EQtypeCno ) { 
    aS = "cNo Header ???";
    }
  else { 
    aS = "Enter name (existing)";
    }
  return aS;
  };
TOwig.prototype.bldXnoInputText = function bldXnoInputText( iActiveB, iPaNod ) {
  var iOwig = this;
  var aKefv;
  var bS;
  var vS = "";
  var nodA, aEl;
  purge( iPaNod );
  while ( (aEl=iPaNod.childNodes[0]) ) {
    iPaNod.removeChild( aEl );
    }
  if (( iOwig.EdKcipChk( iOwig.EKcipNewOnly ) === true )
  && ( iOwig.Qtype === iOwig.EQtypeEno )) {
    /*jsl:pass*/
    }
  else if ( iOwig.needUspan() ) {
    iOwig.uSpanText( iPaNod );
    }
  else if ( ( iOwig.Qtype !== iOwig.EQtypeUno ) && ( iActiveB === false )
  && ( iOwig.EdKcipChk( iOwig.EKcipCollapse ) === true ) ) { 
    // aS += "<span class=\"zEdCollapse\">Collapsed</span>";
    // alert( aS );
    /*jsl:pass*/
    }
  else {
    iOwig.uTextBox( iActiveB, iPaNod );
    }
  return nodA;
  };
TOwig.prototype.uSpanText = function ( iPaNod ) {
  var iOwig = this;
  var aKefv, nodA;
  var aEl;
  var bS = "";
  purge( iPaNod );
  while ( (aEl=iPaNod.childNodes[0]) ) {
    iPaNod.removeChild( aEl );
    }
  if ( iOwig.EdKcipChk( iOwig.EKcipSeperateDrop ) === false ) {
    bS = iOwig.titleS;
    aKefv = iOwig.EKefvNone; 
    }
  else {
    if ( iOwig.uniqNowOwif ) { 
      aKefv = iOwig.uniqNowOwif.nowKefvFn(); 
      bS = iOwig.uniqNowOwif.curTextS;
      }
    else { 
      aKefv = iOwig.EKefvNone; 
      bS = "??? No Selection ???";
      }
    }
  nodA = gAOkel[KEdUspan].insert( iPaNod ); 
  nodA.className = "zEdUSpan" + aKefv;
  nodA.style.cursor = "pointer";
  // nodA.onfocus = edEvtXnoAll;
  // nodA.onblur = edEvtXnoAll;
  // nodA.innerText = bS.edHtmlEsc();
  nodA.insertBefore( document.createTextNode(bS.edHtmlEsc()), null );
  };
TOwig.prototype.uTextBox = function ( iActiveB, iPaNod ) {
  var iOwig = this;
  var aKefv;
  var aEl;
  var vS = "";
  purge( iPaNod );
  while ( (aEl=iPaNod.childNodes[0]) ) {
    iPaNod.removeChild( aEl );
    }
  if ( iOwig.Qtype === iOwig.EQtypeUno ) { 
    aKefv = iOwig.EKefvNone;
    if ( iOwig.uniqNowOwif ) {
      vS = iOwig.uniqNowOwif.curTextS;
      aKefv = iOwig.uniqNowOwif.nowKefvFn();
      }
    else if ( iOwig.EdKcipChk( iOwig.EKcipManditory ) === true ) { 
      aKefv = iOwig.EKefvNak;
      }
    if ( ( iActiveB === false ) && ( vS === "" )) { 
      if ( aKefv === iOwig.EKefvNone ) { aKefv = 4; }
      else { aKefv = 5; }
      vS = iOwig.promptText( );
      }
    if ( gThisCaseB === true ) { alert( "bldXnoInputText-30" ); }
    }
  else {
    if ( iActiveB === false ) {
      vS = iOwig.promptText( );
      aKefv = 4; // KefvNone;
      if ( iOwig.EdKcipChk( iOwig.EKcipMissMand ) === true ) { 
        aKefv = 5; 
        }
      }
    else {
      vS = "";
      aKefv = iOwig.EKefvNone;
      }
    }
  var nodA = gAOkel[KXnoUText].insert( iPaNod ); 
  nodA.className = "zEdUText" + aKefv;
  nodA.value = vS;
  };
TOtmr.prototype.tmiAddRemove = function tmiAddRemove( iNeedB, iNode, iKcntr ) {
  var iOtmr = this;
  var iOwig = iOtmr.Owig;
  // add or remove "entry box"
  var oOwif = null;
  var aKefv;
  if ( ( iNeedB === true ) != ( iNode !== null ) ) {
    if ( iNeedB === true ) {
      var insPrNode = iOtmr.tmiGetInsPr( iKcntr );
      var firstB = ( iOwig.actAOwif.length === 0 );
      oOwif = new TOwif( iOwig, iOwig.groupN );
      oOwif.Kcntr = iKcntr;
      oOwif.nowState();
      var aNode = iOtmr.bldTmiAll( oOwif, firstB, insPrNode );
      oOwif.wifEl = aNode;
      }
    else {
      iOtmr.tmiRemove( iNode );
      }
    }
  else {
    if ( iNeedB === true ) { // possible change of Kefv
      var nowSelectB = ( iOwig.selectCnt === 0 );
      aKefv = iOwig.EKefvNone;
      if ( nowSelectB === true ) {
        aKefv = iOwig.uniqueKefv;
        }
      else if ( iKcntr == iOtmr.EKCntrUnSpec ) {
        aKefv = iOwig.EKefvNone;
        if ( iOwig.DbSelectCnt != iOwig.selectCnt ) { aKefv = iOwig.EKefvTest; }
        }
      var aOtmi = new TOtmi( iNode );
      if ( iKcntr == iOtmr.EKCntrUnSpec ) {
        aOtmi.updateKefv( aKefv, nowSelectB );
        }
      }
    }
  return oOwif;
  };
TOwig.prototype.allocTentN = function allocTentN() {
  var iOwig = this;
  var nxTentN = 1;
  var nxOwif;
  for ( iOwig.fiOrdOwif(true,true); (nxOwif=iOwig.nxOrdOwif()); ) {
    if ( ! ( nxTentN > nxOwif.Opid.tentN ) ) { nxTentN = nxOwif.Opid.tentN + 1; }
    // EdLog( "allocTentN nxOwif.Opid.tentN:" + nxOwif.Opid.tentN + " nxTentN:" + nxTentN );
    }
  return nxTentN;
  };
TOwig.prototype.getOwifFromEl = function getOwifFromEl( iEl ) {
  var iOwig = this;
  var aOwif = null;
  var hideEl = null;
  var paEl = iEl.parentNode;
  if ( paEl.tagName == "NOBR" ) { paEl = paEl.parentNode; }
  for ( var i=0;i<paEl.childNodes.length;i++ ) {
    var nxEl = paEl.childNodes[i];
    if ( nxEl.className == "zHide1" ) { hideEl = nxEl; }
    }
  if ( hideEl !== null ) { 
    var aOpid = new TOpid();
    aOpid.decode( hideEl.value );
    // var aOwfid = new TOwfid( hideEl.value.EdSplitBrack()[0] );
    aOwif = iOwig.getInstOwif( aOpid, true );
    }
  return aOwif;
  };
function getOkel( iClassNameS ) {
  var aOkel, rOkel;
  rOkel = null;
  for ( var i=1; aOkel=gAOkel[i++]; ) {
    if ( aOkel.classNameS === iClassNameS ) {
      rOkel = aOkel;
      rOkel.Kel = i-1;
      }
    }
  return rOkel;
  }
TOwig.prototype.evtXnoClick = function evtXnoClick( iEv, iTargEl ) {
  // alert( "evtXnoClick:" + iTargEl.tagName);
  var iOwig = this;
  var efS, escS, elG, nxOwig;
  var aOwif, aKXnoSt;
  var fullUrlS;
  var aReturnB = true;
  var aTargEl = iTargEl;
  if ( aTargEl.tagName == "IMG" ) { aTargEl = aTargEl.parentNode; }
  var wifIdS = "";
  var bOwig = this;
  if ( iEv.altKey === true ) {
    // iOwig.Owin.connectQual();
    if ( aTargEl.className == "zEdShowBut" ) {
      aTargEl = aTargEl.previousSibling;
      }
    iOwig.Owin.pageStats();
    // missing manditory display text
    var mmS = "";
    for ( var inx=0; inx<iOwig.Owin.AmmGN.length; inx++ ) { 
      elG = window.document.getElementById( 'idEfG' + iOwig.Owin.AmmGN[ inx ] );
      nxOwig = makeTargOwig( iOwig.Owin, elG, true );
      mmS += " " + iOwig.Owin.AmmGN[ inx ]
      + nxOwig.EdBugAllToS( false, null, elG );
      }
    escS = iOwig.EdBugAllToS( true, null, aTargEl );
    escS += "<br/><h3>Page Summary:</h3><ul>"
    + "<li>Missing manditories:" + iOwig.Owin.missMandCnt + mmS + "</li>"
    + "<li>Switchs changed:" + iOwig.Owin.swChangeCnt + "</li>"
    + "<li>Questions answered:" + iOwig.Owin.changeCnt + "</li>"
    + "<li>Questions answered (unchecked):" + iOwig.Owin.uncheckedCnt + "</li>"
    + "</ul>";
    var w=window.open( "", "_blank" );
    w.document.write( escS );
    aReturnB = false;
    }
/*
  else if (( iEv.ctrlKey === true )&&( iEv.ctrlLeft === false )) {
    // right control key for test only
    gOjax.cnnAllocN = iOwig.cnnAllocN;
    gOjax.asDoQs( "?op=nsa", iOwig.newUrlS, "&xx=1&sch=p" );
    }
*/
  else if ( aTargEl.tagName == "A" ) {
    if (( aTargEl.href == "#")||( iEv.shiftKey === true )) {
      aOwif = iOwig.getOwifFromEl( aTargEl );
      // efS = iOwif.encodeEin(); // '(n' + aOwif.Opid.einS + 'n)';
      var aOreq = new TOreq( iOwig.Owin );
      if ( aOwif.Opid.hojS === "" ) {
        aOreq.urlS = iOwig.newUrlS;
        aOreq.Kreq = gKreqNew;
        }
      else {
        var aOlnk = new TOlnk( iOwig.newUrlS );
        aOreq.urlS = aOlnk.replaceInst( aOwif.Opid.hojS, true );
        aOreq.Kreq = gKreqEdit;
        }
      // aOreq.efS = aOwif.encodeEin();
      // aOreq.Opid = aOwif.Opid;
      aOreq.Owif = aOwif;
      aOreq.Kpt = gKptNewWindow;
      aOreq.issue();
      aReturnB = false;
      }
    }  
  else if ( aTargEl.tagName == "INPUT" ) {
    if ( aTargEl.disabled === false ) {
      if ( aTargEl.type == "button" ) {
        var aOkel = getOkel( aTargEl.className );
        if (aOkel!==null) {
          aReturnB = aOkel.operateBut( iOwig, aTargEl, iEv );
          }
        }
      else if (( aTargEl.type == "radio" )||( aTargEl.type == "checkbox" )) {
        if ( aTargEl.className.indexOf("zEdPre") === 0 ) {
          if ( typeof iOwig.Otmr.checkboxB === 'undefined' ) {
            alert( "evtXnoClick iOwig.Otmr.checkboxB:" + iOwig.Otmr.checkboxB );
            }
          if ( iOwig.Qtype === iOwig.EQtypeTmo ) {
            aOwif = iOwig.getOwifFromEl( aTargEl );
            iOwig.evtTmiTick( aOwif, aTargEl );
            }
          else {
            // alert( aTargEl.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.innerHTML );
            // QtypeCno here // alert( "iOwig.Qtype:" + iOwig.Qtype );
            /*jsl:pass*/
            }
          }
        }
      else if ( aTargEl.type == "text" ) {
        if ( aTargEl.className.indexOf("zEdUText") === 0 ) {
          defaultStatus += 'y40 ';
          if ( iOwig.EdKcipChk( iOwig.EKcipCollapse ) === true ) {
            // alert( "zEdUText" );
            /*jsl:pass*/
            // defaultStatus += 'y50a ';
            }
          else if ( gSetFocusB ) { // job already done via focus
            gSetFocusB = false;
            defaultStatus += 'y50b ';
            // EdLog( "zEdUText click, clear gSetFocusB" );
            }
          else {
            iOwig.capture( true, KXnoStMinimized );
            if ( iOwig.prKnoSt !== KXnoStMinimized ) {
              // open/closed to minimized
              iOwig.toKXnoSt( KXnoStMinimized );
              defaultStatus += 'y50c ';
              }
            else {
              // minimized to open
              iOwig.toKXnoSt( KXnoStOpen );
              defaultStatus += 'y50d ';
              }
            }
          }
        }
      }
    }
  else if (( aTargEl.tagName == "SPAN" )
  &&( aTargEl.className.indexOf("zCnoSpan") === 0 )) {
    defaultStatus += "x62"; 
    var cbEl = aTargEl.getElementsByTagName("input")[0];
    cbEl.checked = ! cbEl.checked;
    }
  else if (( aTargEl.tagName == "SPAN" )
  &&( aTargEl.className.indexOf("zEdUSpan") === 0 )) {
    defaultStatus += "x63"; 
    aKXnoSt = KXnoStOpen;
    iOwig.getDropHeader( iOwig.rootIdEl );
    if ( gOpenSelfIdEl === iOwig.selfIdEl ) {  // assume = current
      aKXnoSt = KXnoStMinimized;
      }
    iOwig.toKXnoSt( aKXnoSt );
    }
  else if (( aTargEl.tagName == "SPAN" )
  &&( aTargEl.className.indexOf("zEdCollapse") === 0 )) {
    defaultStatus += "x64"; 
    aKXnoSt = KXnoStOpen;
    if ( gOpenSelfIdEl === iOwig.selfIdEl ) {  // assume = current
      aKXnoSt = KXnoStMinimized;
      }
    iOwig.toKXnoSt( aKXnoSt );
    // alert( "click zEdCollapse" );
    }
  else {
    defaultStatus += "x65"; 
    iOwig.getGenerated( aTargEl, KXnoStNoChange, 0 );
    if ( iOwig.tdEl ) {
      var aKefv = iOwig.tdEl.className.substring( 6, iOwig.tdEl.className.length );
      iOwig.evtClickXni( aKefv, iOwig.tdEl
      , iOwig.getElOwif( iOwig.tdEl ), iOwig.getOpid( iOwig.tdEl ).Exno ); 
      }
    }
  return aReturnB;
  };
TOwig.prototype.getGenerated = function ( iEl, iKXnoSt, iTargOwig ) {
  var iOwig = this;
  var aTargEl = iEl;
  while ((aTargEl!==null)&&( aTargEl.tagName != "TD" )&&(aTargEl.tagName != "TABLE")) {
    aTargEl = aTargEl.parentNode;
    }
  if ( aTargEl === null ) { // within drop ??
    iOwig.capture( true, iKXnoSt );
    }
  else if (( aTargEl.tagName == "TD" )&&( aTargEl.className.indexOf("zEdPre") === 0 )) {
    if ( aTargEl.className.indexOf("zEdPre") === 0 ) {
      iOwig.capture( true, iKXnoSt );
      iOwig.tdEl = aTargEl;
      }
    }
  };
TOkel.prototype.operateBut = function ( iOwig, aTargEl, iEv ) {
  var aOkel = this;
  var aReturnB = true;
  var aOpid;
  var reqOwif = null;
  var aKreq = 0;
  // alert( "operateBut " + aTargEl.innerHTML );
  var efS = "";
  if (( aOkel.Kel > KUnoMove1-1 ) && ( aOkel.Kel < KUnoMove4+1 )) {
    var SS,i,nxEl;
    var bOpid = new TOpid();
    iOwig.capture( true, KXnoStOpen );
    for ( i=0; nxEl=aTargEl.parentNode.parentNode.childNodes[i++]; ) {
      if (( nxEl.tagName ) && ( nxEl.tagName == "INPUT" )
      && ( nxEl.type == "hidden" )) {
        bOpid.decode( nxEl.value );
        }
      }
    iOwig.evtUnoMove( iEv, aOkel.Kel, bOpid.startN, bOpid.endN );
    if ( iOwig.textEl ) { iOwig.textEl.focus(); }
    gBlurUnoEl = null;
    aReturnB = false;
    }
  else if (( aOkel.Kel > KXnoActAll-1 ) && ( aOkel.Kel < KXnoPosNone+1 )) {
    iOwig.capture( true, KXnoStOpen );
    var setB = (( aOkel.Kel === KXnoActAll ) || ( aOkel.Kel === KXnoPosAll ));
    if (( aOkel.Kel === KXnoActAll ) || ( aOkel.Kel === KXnoActNone )) {
      iOwig.setClearAll( iOwig.actOwil, setB );
      }
    else {
      iOwig.setClearAll( iOwig.potOwil, setB );
      }
    }
  else if (( aOkel.Kel === KCnoAll ) || ( aOkel.Kel === KCnoNone ) 
  || ( aOkel.Kel === KCnoDone ) ) {
    iOwig.capture( true, KXnoStOpen );
    iOwig.cnoOperate( aOkel.Kel );
    }
  else if ( aOkel.Kel === KToPoss ) { 
    iOwig.capture( true, KXnoStClosed );
    iOwig.evtEnoMoveSelection( aTargEl, iEv, false );
    }
  else if ( aOkel.Kel === KToAct ) { 
    iOwig.capture( true, KXnoStClosed );
    iOwig.evtEnoMoveSelection( aTargEl, iEv, true );
    if ( iOwig.EdKcipChk( iOwig.EKcipCollapse ) === false ) {
      gBlurUnoEl = iOwig.potOwil.divEl;
      }
    }
  else if ( aOkel.Kel === KXnoPageReq ) {
    // iOwig.capture( true, KXnoStNoChange );
    aKreq = gKreqShow;
    reqOwif = null; //  iOwig.evtEnoButShow( iEv );
    }
  else if ( aOkel.Kel === KXnoDropClose ) {
    iOwig.toKXnoSt( KXnoStMinimized );
    }
  else if (( aOkel.Kel === KEnoShow )||( aOkel.Kel === KEnoEdit )
  ||( aOkel.Kel === KEnoClone )||( aOkel.Kel === KEnoRemove )) { 
    iOwig.capture( true, KXnoStNoChange );
    if ( aOkel.Kel === KEnoShow ) { aKreq = gKreqShow; }
    else if ( aOkel.Kel === KEnoEdit ) { aKreq = gKreqEdit; }
    else if ( aOkel.Kel === KEnoClone ) { aKreq = gKreqClone; }
    else if ( aOkel.Kel === KEnoRemove ) { aKreq = gKreqRemove; }
    // remove ??
    reqOwif = iOwig.evtEnoButShow( iEv );
    }
  else if ( aOkel.Kel === KUnoShow ) { 
    iOwig.summary();
    reqOwif = iOwig.uniqNowOwif;
    aKreq = gKreqShow; 
    }
  else if ( aOkel.Kel === KUnoEdit ) { 
    iOwig.summary();
    reqOwif = iOwig.uniqNowOwif;
    aKreq = gKreqEdit; 
    }
  else if ( aOkel.Kel === KUnoClone ) { 
    iOwig.summary();
    reqOwif = iOwig.uniqNowOwif;
    aKreq = gKreqClone; 
    }
  else if ( aOkel.Kel === KXnoNew ) {
    iOwig.summary();
    reqOwif = iOwig.uniqNowOwif;
    aKreq = gKreqNew; 
    // aReturnB = iOwig.uniqNowOwif.evtKreq( gKreqNew ); 
    }
  else if ( aOkel.Kel === KUnoRemove ) {
    iOwig.summary();
    alert( "zUnoRemoveBut" );
    }
  else if ( aOkel.Kel === KEdNew ) { 
    if ( iEv.shiftKey === true ) {
      iOwig.editGroup();
      }
    else {
      aKreq = gKreqNew2;
      }
    aReturnB = false;
    }
  if ( aKreq !== 0 ) {
    defaultStatus = 'ob';
    var aOreq = new TOreq( iOwig.Owin );
    aOreq.Kreq = aKreq;
    // 
    var aOlnk;
    if ( iOwig.Kisu === iOwig.EKisuNone ) { aOlnk = new TOlnk( iOwig.newUrlS ); }
    else if ( iOwig.Kisu === iOwig.EKisuSubjInst ) { aOlnk = new TOlnk( document.location.href ); }
    else if ( iOwig.Kisu === iOwig.EKisuComplex ) { aOlnk = new TOlnk( document.location.href ); }
    if ( aKreq === gKreqClone ) { 
      aOlnk.viewS = "g" + aOlnk.viewS; // g = KvinvClone
      }
    if ( aKreq === gKreqShow ) {
      defaultStatus = 'ob2';
      aOlnk.httmUpdateB = false;
      aOlnk.Ohttms = decodeHttmAll( aOlnk.typeS );
      iOwig.Owin.ctmToOlnk( aOlnk );
      if ( aOlnk.httmUpdateB === true ) {
        // alert( 'pre aOlnk.typeS:' + aOlnk.typeS );
        aOlnk.typeS = encodeHttmAll( aOlnk.typeS, aOlnk.Ohttms );
        // alert( 'post aOlnk.typeS:' + aOlnk.typeS );
        }
      // alert( "KUnoShow ctmS:" + aOlnk.ctmS );
      }
    if ( reqOwif !== null ) {
      aOreq.urlS = aOlnk.replaceInst( reqOwif.Opid.hojS, true );
      }
    else {
      aOreq.urlS = aOlnk.toStr( false );
      }
    // 
    if ( aKreq === gKreqNew2 ) {
      aOreq.Opid = new TOpid();
      aOreq.Opid.init( iOwig.groupN, iOwig.EXnoDataNew, '', '', 0, 0, 0 );
      aOreq.Kpt = gKptNewWindow;
      aOreq.issue();
      }
    else if ( aKreq === gKreqNew ) {
      if ( iOwig.EdKcipChk( iOwig.EKcipEdRequist ) === true ) {
        aOreq.directB = true;
        aOreq.Kpt = gKptNext;
        aOreq.issue();
        // var bUrl = iOwig.newUrlS + '?se=' + gSesNoloi + '&ed='+ gRevision + '&mf=' + edModeFlags();
        // document.location = bUrl; // leaves 2 of same in history after new
        }
      else {
        aOreq.urlS = iOwig.newUrlS;
        aOreq.efS = '';
        aOreq.Kpt = gKptNewWindow;
        aOreq.issue();
        aReturnB = false;
        }
      }
    else if ( aKreq === gKreqShow ) { 
      if ( reqOwif !== null ) {
        if ( reqOwif.Opid.hojS === "" ) { alert( 'Ops No instance' ); }
        // else { toPageExt( aOreq.urlS, ( iOwig.Kisu === iOwig.EKisuNone ) ); }
        aOreq.efS = reqOwif.encodeEin();
        aOreq.directB = ( reqOwif.Opid.einS === "" );
        }
      else {
        aOreq.efS = '';
        aOreq.directB = true;
        }
      if ( iOwig.Kisu === iOwig.EKisuNone ) { aOreq.Kpt = gKptNewWindow; }
      // if ( aKreq === gKreqShow ) {
        // alert( "KUnoShowaOreq.urlS:" + aOreq.urlS );
        // }
      // defaultStatus += ' preIs';  
      aOreq.issue();
      }
    else if (( aKreq === gKreqEdit )||( aKreq === gKreqClone )) { 
      if ( iOwig.EdKcipChk( iOwig.EKcipEdRequist ) === true ) { // edit from non edit
        aOreq.efS = '';
        aOreq.directB = true;
        // aOreq.Kpt = gKptReplace;
        aOreq.issue();
        // var bUrl = fullUrlS + '?se=' + gSesNoloi + '&ed='+ gRevision + '&mf=' + edModeFlags();
        // document.location = bUrl; // leaves 2 of same in history after new
        }
      else { 
        // aOreq.efS = reqOwif.encodeEin();
        // aOreq.Opid = reqOwif.Opid;
        aOreq.Owif = reqOwif;
        aOreq.Kpt = gKptNewWindow;
        aOreq.issue();
        }
      }
//    var aB = reqOwif.evtKreq( aKreq );
//    if ( aKreq === gKreqNew ) { aReturnB = aB; }
    }
  return aReturnB;
  };
TOwig.prototype.addCtm = function( ioOlnk ) {
  var aOwig = this;
  var aOwif,nxOwig,aOHoj;
  var newOwif = null;
  var oldOwif = null;
  // ioOlnk.ctmS += ' wigId:' + aOwig.selfIdN;
  // alert( 'addCtm' + ( aOwig.Kisu === aOwig.EKisuVfaInst ) );
  for ( aOwig.fiActOwif(); (aOwif=aOwig.nxActOwif()); ) {
    if (( aOwif.aStD.nowSelectB !== aOwif.aStD.DbSelectB  )
    || ( aOwif.curTextS !== aOwif.origTextS )) { // change    
      if ( aOwig.Kisu == aOwig.EKisuVfaInst ) {
        // ignore neg change, unique manditory, pos change override.
        if ( ( aOwif.aStD.nowSelectB === true )
        || ( aOwig.EdKcipChk( aOwig.EKcipUnique ) === false ) 
        || ( aOwig.EdKcipChk( aOwig.EKcipMaditory ) === false ) 
        ) {  // for unique manditory only ?
          ioOlnk.ctmS += '('; 
          if ( aOwif.aStD.nowSelectB === true ) { ioOlnk.ctmS += 't'; }
          else { ioOlnk.ctmS += 'f'; }
          ioOlnk.ctmS 
          += aOwif.EdQdbCodeKtj( aOwif.EKtjabId, aOwig.abIdS, "0" )
          + aOwif.EdQdbCodeKtj( aOwif.EKtjCurName
          , aOwif.curTextS.nsToOjText(), aOwif.origTextS.nsToOjText() )
          + aOwif.EdQdbCodeKtj( aOwif.EKtjSubInst, aOwif.subInstN, "0" )
          + aOwif.EdQdbCodeKtj( aOwif.EKtjInst, aOwif.Opid.hojS, "0" );
          ioOlnk.ctmS += ')'; 
          }
        }
      if (( aOwig.Kisu == aOwig.EKisuHttmRoleInst )
      || ( aOwig.Kisu == aOwig.EKisuHttmTypeNull )) { // edit httm term
        if ( aOwif.aStD.nowSelectB === true ) { newOwif = aOwif; }
        else { oldOwif = aOwif; }
        }
      }
    }
  if ( newOwif !== null ) { // displace old one
    aOHoj = new THoj( newOwif.Opid.hojS );
    ioOlnk.Ohttms.seqN = 0;
    aOwig.editHttm( newOwif, ioOlnk.Ohttms, ioOlnk, aOHoj );
    }
  else if ( oldOwif !== null ) { // need to delete
    ioOlnk.Ohttms.seqN = 0;
    aOwig.editHttm( oldOwif, ioOlnk.Ohttms, ioOlnk, null );
    } 
  };
TOwig.prototype.editHttm = function( iOwif, iOhttms, ioOlnk, iOHoj ) {
  var aOwig = this;
  var aOhttm = null;
  var matchB;
  var aOeih, aOHoj;
  for ( var i=0; (aOhttm = ioOlnk.Ohttms.AOhttm[i++]); ) {
    if ( aOhttm.subOhttms !== null ) {
      // alert( 'editHttm-10 i:' + i );
      aOwig.editHttm( iOwif, aOhttm.subOhttms, ioOlnk, iOHoj );
      }
    else {
      ioOlnk.Ohttms.seqN++;  
      aOeih = new TOeih();
      aOeih.decode( aOwig.abIdS );
      if ( aOwig.Kisu === aOwig.EKisuHttmRoleInst ) {
        aOHoj = new THoj( aOeih.subjHojS );
        matchB = ( aOhttm.ttmNoloi === aOHoj.ojNoloi )
        && ( aOhttm.ttmI0sl === aOHoj.ojI0sl );
        if ( matchB === true ) {
          if ( iOHoj !== null ) {
            aOhttm.OHoj = iOHoj;
            }
          else {
            aOhttm.ttmNoloi = 0;
            aOhttm.ttmI0sl = 0;
            }
          ioOlnk.httmUpdateB = true;
          }
        }
      else if ( aOwig.Kisu === aOwig.EKisuHttmTypeNull ) {
        matchB = ( ioOlnk.Ohttms.seqN === aOeih.orderN );
        if ( matchB === true ) {
          ioOlnk.httmUpdateB = true;
          if ( iOHoj !== null ) {
            aOhttm.ttmNoloi = iOHoj.ojNoloi;
            aOhttm.ttmI0sl = 1;
            }
          else {
            aOhttm.ttmNoloi = 0;
            aOhttm.ttmI0sl = 0;
            }
          }
        }
      }
    }
  };
TOwin.prototype.ctmToOlnk = function( ioOlnk ) {
  var aOwin = this;
  var dataEls = document.getElementsByTagName( 'INPUT' );
  var inx,aEl,aOwig;
  var wigsSS, j, wigS;
  if ( ioOlnk !== null ) { ioOlnk.ctmS = ""; }
  var changeB = false;
  for ( inx=0; aEl=dataEls[inx++]; ) {
    if ( ( aEl.id ) && ( aEl.id.substr( 0, 4 ) == 'idNg' ) ) {
      wigsSS = fsSplit( aEl.value );
      for ( j=0; wigS=wigsSS[j++]; ) {
        aOwig = new TOwig();
        aOwig.groupN = inx-1;
        aOwig.SKcip = fsSplit( wigS )[0].split('W')[1]; // much faster than below ??
        // aOwig.recMakeOwig( null, aOwin, wigS, false );
        // if 1st Owig indicates subs unchanged terminate
        if (( j === 1 ) 
        && ( aOwig.EdKcipChk( aOwig.EKcipSubChange) === false )){
          wigsSS = [];
          }
        // action change
        if ( aOwig.EdKcipChk( aOwig.EKcipChange) === true ) {
          if ( ioOlnk !== null ) { 
            aOwig.recMakeOwig( null, aOwin, wigS, true );
            aOwig.addCtm( ioOlnk ); 
            }
          changeB = true;
          }
        }
      }
    }
  return changeB;
  };
TOwig.prototype.moveButFix = function moveButFix() {
  var iOwig = this;
  var moveSpanEl,moveTdEl,i,nxEl;
  if ( iOwig.moveTrEl !== null ) {
    moveTdEl = iOwig.moveTrEl.childNodes[0];
    moveSpanEl = moveTdEl.childNodes[0];
    var spare = moveTdEl.offsetWidth - moveSpanEl.offsetWidth - 2;
    if ( spare > 0 ) {
      for ( i=0; nxEl=moveSpanEl.childNodes[i++]; ) {
        if (( nxEl.tagName ) 
        && ( nxEl.tagName == "INPUT" ) && ( nxEl.type == "button" )) {
          nxEl.style.width = ( nxEl.offsetWidth + ( spare/4 )) + "px";
          }
        }
      }
    }
  };
TOwig.prototype.packageXni = function ( iUnoN, ilevelN, iAEl, iTdClassNameS
, iColSpanN, iOpid ) {
  var iOwig = this;
  if ( iOwig.uColm < ( iAEl.length+1 ) ) {
    iOwig.uColm = iAEl.length+1;
    }
  var simpleB = ( iAEl.length === 1 );
  var trNode = document.createElement('tr');
  var tdNode = document.createElement('td');
  if ( iUnoN != iOwig.EUnoMove ) { tdNode.style.cursor = "pointer"; }
  trNode.insertBefore( tdNode, null );
  tdNode.className = iTdClassNameS;
  tdNode.style.paddingLeft = 0; // TEST
  tdNode.insertBefore( iAEl[0], null );
  if ( ( simpleB === true ) 
  && (( iOwig.EdKcipChk( iOwig.EKcipQualInst ) === true ) 
  || ( iOwig.EdKcipChk( iOwig.EKcipQualAssoc ) === true ) )
  ) {
    tdNode.colSpan = 2;
    }
  if ( ( simpleB === true ) 
  && ( iOwig.uColm > 1 )
  ) {
    tdNode.colSpan = iOwig.uColm;
    }
  var hidNode = document.createElement('input');
  hidNode.type = "hidden";
  hidNode.value = iOpid.encode(true);
  tdNode.insertBefore( hidNode, null );
  //
  if ( simpleB === false ) {
    for ( var i=1; i<iAEl.length; i++ ) {
      tdNode = document.createElement('td');
      tdNode.className = iTdClassNameS;
      tdNode.style.paddingLeft = 0; // TEST
      trNode.insertBefore( tdNode, null );
      tdNode.insertBefore( iAEl[i], null );
      }
    // if ( iSp2El !== null ) { tdNode.insertBefore( iSp2El, null ); }
    // if ( iSp3El !== null ) { tdNode.insertBefore( iSp3El, null ); }
    }
  if ( ( iColSpanN ) && ( iColSpanN > 1 ) ) {
    tdNode.colSpan = tdNode.colSpan + iColSpanN - 1;
    }
  // if ( iAEl.length > 1 ) { alert( trNode.innerHTML ); }
  return trNode;
  };
// 
// change of focus on id box
// add or remove prompt text if need be
TOwig.prototype.evtTextFocus = function evtTextFocus( iOwif, iEl, iFocusB ) {
  var aOwif = iOwif;
  var aOwig = this;
  if ( iFocusB === true ) { 
    gFocusTextEl = iEl;
    if ( iEl.className == "zEdText4" ) {
      iEl.className = "zEdText0";
      iEl.value = "";
      }
    if ( iEl.className == "zEdText5" ) {
      iEl.className = "zEdText2";
      iEl.value = "";
      }
    }
  else {
    gFocusTextEl = null;
    if ( ( aOwif === null ) && ( iEl.value === "" ) ) {
      if ( iEl.className == "zEdText0" ) { iEl.className = "zEdText4"; }
      else { iEl.className = "zEdText5"; }
      iEl.value = aOwig.promptText( );
      }
    }
  };
TOwig.prototype.evtTcoTextChange = function evtTcoTextChange( iOwif, iEl ) {
  var aOwif = iOwif;
  var aOwig = this;
  var aStD, aKefv;
  aOwif.aStD.nowSelectB = true;
  aOwif.curTextS = iEl.value;
  var textS = aOwif.origTextS;
  aStD = aOwif.aStD;
  if ( textS === iEl.value ) {
    iEl.className = "zEdText" + aStD.Kefv;
    aStD.nowSelectB = aStD.cycleSelectB;
    // alert( 'evtTcoTextChange match textS:' + textS 
    // + ' aOwif.origTextS:' + aOwif.origTextS 
    // + ' aStD.nowSelectB:' + aStD.nowSelectB );
    }
  else {
    aKefv = aOwig.EKefvTest;
    if ( ( iEl.value === "" )
    && ( aOwig.EdKcipChk( aOwig.EKcipManditory ) === true ) 
    ) { aKefv = aOwig.EKefvNak; }
    iEl.className = "zEdText" + aKefv;
    aStD.nowSelectB = true;
    // alert( 'evtTcoTextChange mismatch textS:' + textS 
    // + ' aOwif.origTextS:' + aOwif.origTextS 
    // + ' aStD.nowSelectB:' + aStD.nowSelectB );
    }
  aOwig.saveAll( );
  aOwig.summary(); 
  aOwig.capture( true, KXnoStOpen ); // trigger dropIcon change
  aOwig.Owin.pageButsPerState();
  };
TOwig.prototype.EdBugBtoS = function EdBugBtoS( iKcip, iPosS ) {
  var iOwig = this;
  var S = "";
  if ( iOwig.EdKcipChk( iKcip ) === true ) { S += "<b>" + iPosS + "</b>"; } 
  else { S += iPosS; } 
  return S + " ";
  };
TOwig.prototype.EdBugLineS = function EdBugLineS( iAA ) {
  var iOwig = this;
  var i,aA,j;
  var aS = "";
  for ( i=0; aA=iAA[i++]; ) {
    aS += "<li>";
    for ( j=0; j<aA.length; j++ ) {
      if ( j === 0 ) { aS += "<i>" + aA[j] + "</i>"; }
      else { aS += ":" + aA[j]; }
      }
    aS += "</li>";
    }
  return aS;
  };
TOwig.prototype.EdBugElToS = function EdBugElToS( iEl, iNameS ) {
  var iOwig = this;
  var aS = "<li>";
  aS += iNameS + "<br/>";
  if ( iEl ) {
    aS += iOwig.EdBugShowEl( iEl, 1 );
    aS += " RAW:" + iEl.innerHTML.edHtmlEsc();
    }
  return aS + "</li>";
  };
TOwig.prototype.EdBugShowEl = function EdBugShowEl( iEl, iLev ) {
  var iOwig = this;
  var ELEMENT_NODE = 1;
  var ATTRIBUTE_NODE = 2;
  var TEXT_NODE = 3;
  var CDATA_SECTION_NODE = 4;
  var ENTITY_REFERENCE_NODE = 5;
  var ENTITY_NODE = 6;
  var PROCESSING_INSTRUCTION_NODE = 7;
  var COMMENT_NODE = 8;
  var DOCUMENT_NODE = 9;
  var DOCUMENT_TYPE_NODE = 10;
  var DOCUMENT_FRAGMENT_NODE = 11;
  var NOTATION_NODE = 12;
  var aS = "";
  var i,j,nxEl,atr;
  for ( i=0; i<iLev; i++ ) { aS += "&nbsp;&nbsp;&nbsp;&nbsp;"; }
  if ( iEl.nodeType === ELEMENT_NODE ) {
    var tagName = iEl.tagName.toLowerCase();
    aS += "&lt;" + tagName;
    for ( i=0; (atr=iEl.attributes[i++]); ) { // atributes
      if (( atr.specified )||( atr.name == "value")) {
        aS += " " + atr.name + "=\"" + atr.value + "\"";
        }
      }
    if ( iEl.childNodes.length > 0 ) {
      aS += "&gt;<br/>";
      for ( j=0; nxEl=iEl.childNodes[j++]; ) {
        aS += iOwig.EdBugShowEl( nxEl, iLev+1 );
        }
      for ( i=0; i<iLev; i++ ) { aS += "&nbsp;&nbsp;&nbsp;&nbsp;"; }
      aS += "&lt;/" + tagName + "&gt;";
      }
    else {
      aS += "&nbsp;/&gt;";
      }
    }
  else if ( iEl.nodeType === ATTRIBUTE_NODE ) {
    aS += " ATTRIBUTE_NODE";
    }
  else if ( iEl.nodeType === TEXT_NODE ) {
    aS += " TEXT_NODE:" + iEl.data;
    }
  else if ( iEl.nodeType === CDATA_SECTION_NODE ) {
    aS += " CDATA_SECTION_NODE:" + iEl.data;
    }
  else if ( iEl.nodeType === ENTITY_REFERENCE_NODE ) {
    aS += " ENTITY_REFERENCE_NODE";
    }
  else if ( iEl.nodeType === ENTITY_NODE ) {
    aS += " ENTITY_NODE";
    }
  else if ( iEl.nodeType === PROCESSING_INSTRUCTION_NODE ) {
    aS += " PROCESSING_INSTRUCTION_NODE";
    }
  else if ( iEl.nodeType === COMMENT_NODE ) {
    aS += " COMMENT_NODE:" + iEl.data;
    }
  else if ( iEl.nodeType === DOCUMENT_NODE ) {
    aS += " DOCUMENT_NODE";
    }
  else if ( iEl.nodeType === DOCUMENT_TYPE_NODE ) {
    aS += " DOCUMENT_TYPE_NODE";
    }
  else if ( iEl.nodeType === DOCUMENT_FRAGMENT_NODE ) {
    aS += " DOCUMENT_FRAGMENT_NODE";
    }
  else if ( iEl.nodeType === NOTATION_NODE ) {
    aS += " NOTATION_NODE";
    }
  aS += "<br/>";
  return aS;
  };
TOwig.prototype.debugOwigS = function( ) {
  var iOwig = this;
  var S = "";
  var aS = iOwig.EdBugBtoS( iOwig.EKcipPots, "Pots" );
  aS += iOwig.EdBugBtoS( iOwig.EKcipClosed, "Closed" );
  aS += iOwig.EdBugBtoS( iOwig.EKcipManditory, "Manditory" );
  aS += iOwig.EdBugBtoS( iOwig.EKcipSwitch, "Switch" );
  aS += iOwig.EdBugBtoS( iOwig.EKcipUnique, "Unique" );
  aS += iOwig.EdBugBtoS( iOwig.EKcipSecDisp, "SecDisp" );
  aS += iOwig.EdBugBtoS( iOwig.EKcipNewOnly, "NewOnly" );
  aS += iOwig.EdBugBtoS( iOwig.EKcipNoDel, "NoDel" );
  //
  var bS = iOwig.EdBugBtoS( iOwig.EKcipChange, "Change" );
  bS += iOwig.EdBugBtoS( iOwig.EKcipSwChange, "SwChange" );
  bS += iOwig.EdBugBtoS( iOwig.EKcipUnchecked, "Unchecked" );
  bS += iOwig.EdBugBtoS( iOwig.EKcipFailed, "Failed" );
  bS += iOwig.EdBugBtoS( iOwig.EKcipMissMand, "MissMand" );
  bS += iOwig.EdBugBtoS( iOwig.EKcipSubChange, "SubChange" );
  bS += iOwig.EdBugBtoS( iOwig.EKcipSubUnchecked, "SubUnChecked" );
  // 
  var cS = iOwig.EdBugBtoS( iOwig.EKcipText, "Text");
  cS += iOwig.EdBugBtoS( iOwig.EKcipNumeric, "Numeric" );
  cS += iOwig.EdBugBtoS( iOwig.EKcipNameIsId, "NameIsId" );
  //
  var dS = iOwig.EdBugBtoS( iOwig.EKcipPerLine, "PerLine" );
  dS += iOwig.EdBugBtoS( iOwig.EKcipSeperateDrop, "SeperateDrop" );
  dS += iOwig.EdBugBtoS( iOwig.EKcipCompact, "Compact" );
  dS += iOwig.EdBugBtoS( iOwig.EKcipCollapse, "Collapse" );
  //
  var eS = iOwig.EdBugBtoS( iOwig.EKcipMemberShow, "MemberShow");
  eS += iOwig.EdBugBtoS( iOwig.EKcipMemberEdit, "MemberEdit" );
  eS += iOwig.EdBugBtoS( iOwig.EKcipMemberClone, "MemberClone" );
  eS += iOwig.EdBugBtoS( iOwig.EKcipMemberRemove, "MemberRemove" );
  eS += iOwig.EdBugBtoS( iOwig.EKcipAllNone, "SelectAllNone" );
  //
  S += iOwig.EdBugLineS( 
  [[ "SKcip association", aS ] 
  ,[ "SKcip instance", cS ] 
  ,[ "SKcip layout", dS ] 
  ,[ "SKcip Ops", eS ] 
  ,[ "SKcip Derived", bS ] 
  ,[ "SKcip string", iOwig.SKcip ]
  ,[ "Tab spacing Ems", iOwig.widthEmS ]
  ,[ "Type+httms", iOwig.typeS ]
  ,[ "New url", iOwig.newUrlS ]
  ,[ "abId", iOwig.abIdS ]
  ,[ "cnnAllocN", iOwig.cnnAllocN ]
  ,[ "iOwig.Kisu", iOwig.Kisu ]
  ] );
  // + "</ul>";
  return S;
  };
TOwig.prototype.debugOwifs = function debugOwifs( ) {
  var iOwig = this;
  var nxOwif, nxOwig;
  var aS = "";
  var i=0;
  if ( iOwig.SKcip ) {
    aS += iOwig.debugOwigS();
    aS += "<ul>";
    for ( iOwig.fiOrdOwif(true,false); (nxOwif=iOwig.nxOrdOwif()); ) {
      aS += "<li>";
      aS += nxOwif.curTextS;
      aS += "</li>";
/*
      if (nxOwif.AOwig.length > 0 ) {
        aS += "<ul>";
        for ( i=0; (nxOwig=nxOwif.AOwig[i++]); ) {
          aS += "<li>embedded Owig:" + (i) + "</li>";
          aS += "<ul>" + nxOwig.debugOwifs() + "</ul>";
          }
        aS += "</ul>";
        }
*/
      }
    aS += "</ul>";
    }
  else {
    aS += "No SKcip ??";
    }
  return aS;
  };
TOwig.prototype.EdBugAllToS = function EdBugAllToS( iLogB, iOwif, iEl ) {
  var iOwig = this;
  var nxOsplit, i, l, j, fSS, aLog, aTextS, S = "";
  if ( iLogB === true ) {
    if ( EdLog.Alog ) {
      if ( EdLog.Alog.length > 0 ) {
        S = "<h3>Log</h3><ul>";
        for ( i=0; aLog=EdLog.Alog[i++]; ) {
          S += "<li>" + aLog.chainS + "</li><ul>";
          for ( j=0; aTextS=aLog.AtextS[j++]; ) {
            S += "<li>" + aTextS.edHtmlEsc() + "</li>";
            }
          S += "</ul>";
          }
        S += "</ul>";
        }	
      EdLog.Alog.length = 0;
      }
    }
  if ( iOwig.epHideEl !== null ) {
    S += "<h3>Pick List:</h3><ul>"; 
    fSS = fsSplit( nthWigS( iOwig.epHideEl, 0 ) );
    fSS.splice( 0, 1 ); // no header
    // fAOsplit.sort();
    for ( i=0,l=fSS.length; i<l; i++ ) {
      S += iOwig.EdBugLineS( [[ "wifS", fSS[i] ]] );
      }
    S += "</ul>";
    }
  S += "<h3>Per question data:</h3>" 
  + "format: t=name n=ein a=editedName s=state i=hoj w=contentType u=contentUrl"
  + "<ul>";
  fSS = fsSplit( wigSbyId( iOwig.rootIdEl.value, iOwig.selfIdN ) );
  l = fSS.length;
  for ( i=1; i<l; i++ ) {
    S += iOwig.EdBugLineS( [["wifS:",fSS[i]]] );
    }
  S += "</ul>";
  S += "<h3>Decoded Per question data:</h3>" 
  + "<ul>";
  S += iOwig.debugOwifs();
  S += "</ul>";
  S += "<h3>Derived this question:</h3><ul>"
  + iOwig.EdBugLineS( [[ "Entry count active", iOwig.actAOwif.length ]
  , [ "Entry count pog", iOwig.Opog.AOwif.length ]
  , [ "Unique Kefv", iOwig.uniqueKefv ]
  , [ "Lone Unique:", iOwig.loneUniq() ]
  , [ "Qtype:", iOwig.toQtypeS(iOwig.Qtype) ]
  ] )
  + "</ul>";
//  + "\n  Empty entry box:" + iOwig.Otmr.needEntryBoxB
  if ( iOwif !== null ) {
    S += "<h3>This choice:</h3><ul>"
    + iOwig.EdBugLineS( [[ "nowKefv",iOwif.nowKefv ]
    ,[ "DbSelectB", iOwif.aStD.DbSelectB ]
    ,[ "nowSelectB", iOwif.aStD.nowSelectB ]
    ,[ "cycleSelectB", iOwif.aStD.cycleSelectB ]
    ,[ "carryB", iOwif.aStD.carryB ]
    ,[ "Kefv(0=None,1=Test,2=Nak,3=Ack)", iOwif.aStD.Kefv ]
    ,[ "curTextS", iOwif.curTextS ]
    ,[ "origTextS", iOwif.origTextS ]
    ,[ "inst Noloi+I0sl", iOwif.Opid.hojS ]
    ,[ "KcontentType(0=text,1=image,2=icon)", iOwif.KcontentType ]
    ,[ "srcUrlS", iOwif.srcUrlS ]
    ,[ "einS", iOwif.Opid.einS ]
    ,[ "Ein split", iOwif.Opid.einS.EdBugEinDecodeS( 1 ) ]
    ] )
    + "</ul>";
    }
  //
  iOwig.Qtype = iOwig.getQtype();
  if ( iEl !== null ) {
    var aOtmi = new TOtmi( iEl.parentNode );
    S += "<h3>Choice bits:</h3>";
    S += "<ul>";
    S += iOwig.EdBugElToS( iOwig.groupEl, "All" );
    S += iOwig.EdBugElToS( aOtmi.Nod1, "Nod1" );
    S += iOwig.EdBugElToS( aOtmi.Nod2, "Nod2" );
    S += iOwig.EdBugElToS( aOtmi.nobrEl, "nobr" );
    S += iOwig.EdBugElToS( aOtmi.tickEl, "tickEl" );
    S += iOwig.EdBugElToS( aOtmi.taEl, "taEl" );
    S += iOwig.EdBugElToS( aOtmi.butEl, "butEl" );
    S += iOwig.EdBugElToS( aOtmi.hideEl, "hideEl" );
    S += iOwig.EdBugElToS( aOtmi.linkEl, "linkEl" );
    S += iOwig.EdBugElToS( aOtmi.selectEl, "selectEl" );
    var divEl = window.document.getElementById( "idDivXnoDrop" );
    S += iOwig.EdBugElToS( divEl, "idDivXnoDrop" );
    S += "</ul>";
    }
  return S;
  };
TOwig.prototype.bldWig = function bldWig( iPaOwif, iSubInx ) {
  var iOwig = this;
  //
  if ( iPaOwif !== null ) { iOwig.paOwig = iPaOwif.Owig; }
  else { iOwig.paOwig = null; }
  iOwig.subInx = iSubInx;
  if ( iPaOwif !== null ) {
    var nestIdEl = iOwig.bldNestIdEl( iPaOwif, iOwig ); 
    iOwig.groupEl.insertBefore( nestIdEl, null );
    }
  //
  var nxOwif;
  // EdLog( "iOwig.groupN:" + iOwig.groupN + " Qtype:" + iOwig.toQtypeS(iOwig.Qtype) 
  // + " EKcipNameIsId:" + iOwig.EdKcipChk( iOwig.EKcipNameIsId ) );
  if ( iOwig.Qtype == iOwig.EQtypeTco ) {
    for ( iOwig.fiOrdOwif(true,false); (nxOwif=iOwig.nxOrdOwif()); ) {
      nxOwif.insertB = true;
      nxOwif.insertPrOwif = null;
      }
    iOwig.refreshTco( false ); // tmo
    iOwig.saveNewHdr();
    }
  else if ( iOwig.Qtype == iOwig.EQtypeTmo ) {
    for ( iOwig.fiOrdOwif(true,false); (nxOwif=iOwig.nxOrdOwif()); ) {
      nxOwif.insertB = true;
      nxOwif.insertPrOwif = null;
      }
    iOwig.refreshTmo( false ); // tmo
    iOwig.saveNewHdr();
    }
  else if (( iOwig.Qtype === iOwig.EQtypeUno )
  ||( iOwig.Qtype === iOwig.EQtypeEno )
  ||( iOwig.Qtype === iOwig.EQtypeCno ) ) {
    gbldRequiredN++;
    iOwig.summary();
    if ( iOwig.Qtype !== iOwig.EQtypeCno ) { 
      iOwig.saveNewHdr(); 
      }
    // defaultStatus += 'c*';
    iOwig.prepOwils( KXnoStMinimized );
    var wigEl;
    if (( iPaOwif !== null ) || ( iOwig.EdKcipChk( iOwig.EKcipCollapse ) )){ wigEl = document.createElement('span'); }
    else { wigEl = document.createElement('div'); }
    wigEl.className = 'zWidDiv ' + iOwig.zWigQualS( iOwig.Qtype, iOwig.wigKXnoSt );
    iOwig.groupEl.insertBefore( wigEl, null );
    iOwig.bldXnoShell( wigEl, false );  // drop = false
    iOwig.capture( false, iOwig.wigKXnoSt );
    // alert( "bldXnoWig " + wigEl.outerHTML );
    iOwig.bldRequired( 3 );
    // iOwig.bldXnoWig( iPaOwif, iSubInx ); 
    }
  else {
    alert( "iOwig.Qtype:" + iOwig.toQtypeS(iOwig.Qtype) );
    }
  };

TOwig.prototype.imedKisu = function imedKisu( ) {
  var iOwig = this;
  return (( iOwig.Kisu !== iOwig.EKisuSubjInst )
  && ( iOwig.Kisu !== iOwig.EKisuNone ));
  };
/* ********************* */
function TOwif( iOwig, iGroupN ) {
  var newOwif = this;
  newOwif.Opid = new TOpid();
  newOwif.Opid.init( iGroupN, 0, '', '', 0, 0, 0 );
  newOwif.Opid.tentN = 0;
  newOwif.Owig = iOwig;
  newOwif.aStD = new Object();
  newOwif.aStD.DbSelectB = false;
  newOwif.aStD.nowSelectB = false;
  newOwif.aStD.Kefv = 0; // iOwig.EKefvNone;
  newOwif.aStD.cycleSelectB = false;
  newOwif.aStD.carryB = false;
  newOwif.curTextS = '';
  newOwif.origTextS = '';
  newOwif.KcontentType = newOwif.EKcontentTypeText;
  newOwif.srcUrlS = '';
  newOwif.insertB = false;
  newOwif.refreshB = false;
  newOwif.redoTickBoxB = false;
  newOwif.origOrderN = 0;
  newOwif.curOrderN = 0;
//  newOwif.AOwig = [];
  newOwif.AOwgc = [];
  }
TOwif.prototype.EKcontentTypeText = 0;
TOwif.prototype.EKcontentTypeImg = 1;
TOwif.prototype.EKcontentTypeIcon = 2;
//
TOwif.prototype.EKtjState = 's';
TOwif.prototype.EKtjOrigName = 'o';
TOwif.prototype.EKtjEin = 'n';
TOwif.prototype.EKtjTentN = 'm';
TOwif.prototype.EKtjCurName = 'a';
TOwif.prototype.EKtjInst = 'i';
TOwif.prototype.EKtjContentType = 'w';
TOwif.prototype.EKtjSrcUrl = 'u';
TOwif.prototype.EKtjSubInst = 'j';
TOwif.prototype.EKtjSubAssoc = 'b';
TOwif.prototype.EKtjHttm = 't';
TOwif.prototype.EKtjHvtm = 'v';
TOwif.prototype.EKtjIsrc = 'k';
TOwif.prototype.EKtjWig = 'g';
TOwif.prototype.EKtjOrder = 'q';
TOwif.prototype.EKtjWigId = 'I';
TOwif.prototype.EKtjPotId = 'P';
TOwif.prototype.EKtjType = 'T';
TOwif.prototype.EKtjabId = 'A';
TOwif.prototype.EKtjKisu = 'K';

// text area data change
TOwif.prototype.evtOnChangeTA = function evtOnChangeTA( iEl ) {
  var aOwif = this;
  var aOwig = aOwif.Owig;
//  aOwif.aStD.nowSelectB = true;
//  aOwif.curTextS = iEl.value;
//  EdQdbSave( aOwig, aOwif, true, false );
//  aOwig.refresh( true );
  };
//
TOwif.prototype.decodeInst = function decodeInst( iOwin, iOwifS ) {
  var stDate = new Date( ).valueOf();
  var aOwif = this;
  var aS, aN;
  // var aOwifS = iOwifS.substr( 1, iOwifS.length-2 );
  var aOwifS = iOwifS;
//   var boxSS = aOwifS.EdSplitBrack();
  var boxSS = aOwifS.split('W');
// 0
  var i,nxS,Ktj;
  // should all these be initialized ?
  aOwif.origTextS = "";
  aOwif.curTextS = null; // "";
  aOwif.aStD = null;
  aOwif.Opid.einS = ""; 
  aOwif.Opid.hojS  = ""; 
  aOwif.Opid.tentN = 0; 
  aOwif.srcUrlS = ""; 
  aOwif.KcontentType = "0"; 
  aOwif.subInstN = 0;
  aOwif.subAssocN = 0;
  aOwif.instKtjS = ''; 
  aOwif.Isrc = 0;
  var eDate = new Date( ).valueOf();
  iOwin.diTime1 += ( eDate - stDate );
// 0
  for ( i=0; (nxS=boxSS[i++]); ) {
    aS = nxS.substring( 1, nxS.length );
    Ktj = nxS.substring( 0, 1 );
    if ( Ktj === aOwif.EKtjOrigName ) { 
      aOwif.origTextS = aS.nsFromOjText();
      // aOwif.curTextS = aOwif.origTextS;
      }
    else if ( Ktj === aOwif.EKtjState ) { 
      aOwif.EdQdbDecodeState( aS );
      }
    else if ( Ktj === aOwif.EKtjCurName ) { 
      aOwif.curTextS = aS.nsFromOjText(); 
      }
    else if ( Ktj === aOwif.EKtjEin ) { 
      aOwif.Opid.einS = aS; 
      }
    else if ( Ktj === aOwif.EKtjTentN ) { 
      aOwif.Opid.tentN = parseInt( aS,10 ); 
      }
    else if ( Ktj === aOwif.EKtjIsrc ) { 
      aOwif.Isrc = parseInt( aS,10 ); 
      }
    else if ( Ktj === aOwif.EKtjOrder ) { 
      aOwif.origOrderN = parseInt( aS,10 ); 
      }
    else if ( Ktj === aOwif.EKtjInst ) { 
      aOwif.Opid.hojS = aS; 
      aOwif.instKtjS = Ktj; 
      }
    else if ( Ktj === aOwif.EKtjHttm ) { 
      aOwif.Opid.hojS = aS; 
      aOwif.instKtjS = Ktj; 
      }
    else if ( Ktj === aOwif.EKtjHvtm ) { 
      aOwif.Opid.hojS = aS; 
      aOwif.instKtjS = Ktj; 
      }
    else if ( Ktj === aOwif.EKtjSrcUrl ) { 
      aOwif.srcUrlS = aS.nsFromOjText(); 
      }
    else if ( Ktj === aOwif.EKtjContentType ) { 
      aOwif.KcontentType = aS; 
      }
    else if ( Ktj === aOwif.EKtjSubInst ) { 
      aOwif.subInstN = aS; 
      }
    else if ( Ktj === aOwif.EKtjSubAssoc ) { 
      aOwif.subAssocN = aS; 
      }
    else if ( Ktj === aOwif.EKtjWig ) { 
      aN = parseInt( aS, 10 );
      aS = wigSbyId( aOwif.Owig.rootIdEl.value, aN );
      if ( aS === '' ) { bomb(); }
      var bOwig = new TOwig();
      // alert( "decodeInst call recMakeOwig" );
      bOwig.recMakeOwig( aOwif, iOwin, aS, true ); // fullB 
      // aOwif.AOwig[aOwif.AOwig.length] = bOwig;
      aOwif.AOwgc[aOwif.AOwgc.length] = new T_Owgc( aN, bOwig, aOwif.Owig.rootIdEl, aOwif );
  eDate = new Date( ).valueOf();
  iOwin.diTime1 += ( eDate - stDate );
      }
    else {
      alert( "EdQdbEncodeInst Decoding unexpected Ktj:" + Ktj + " nxS:" + nxS );
      bomb();
      }
    }
// 173
  eDate = new Date( ).valueOf();
  iOwin.diTime2 += ( eDate - stDate );
  iOwin.diCnt++;
  aOwif.Oein = iOwin.getOein( aOwif.instKtjS, aOwif.Opid.hojS, true );
// 281
  aOwif.refreshB = false;
  aOwif.insertB = false;
  };
function T_Owgc( iIdN, iOwig, iRootIdEl, iOwif ) {
  var aOwgc = this;
  aOwgc.idN = iIdN;
  aOwgc.Owig = iOwig;
  aOwgc.rootIdEl = iRootIdEl;
  aOwgc.Owif = iOwif;
  }
TOwif.prototype.encodeInst = function encodeInst( ) {
  var iOwif = this;
  var aS;
  aS = "";
  aS += iOwif.EdQdbCodeKtj( iOwif.EKtjOrigName, iOwif.origTextS.nsToOjText(), "" );
  aS += iOwif.EdQdbCodeKtj( iOwif.EKtjState, iOwif.EdQdbEncodeState(), "00000" );
  aS += iOwif.EdQdbCodeKtj( iOwif.EKtjCurName, iOwif.curTextS.nsToOjText()
  , iOwif.origTextS.nsToOjText() );
  aS += iOwif.EdQdbCodeKtj( iOwif.EKtjEin, iOwif.Opid.einS, "" ); 
  aS += iOwif.EdQdbCodeKtj( iOwif.instKtjS, iOwif.Opid.hojS, "" );
  aS += iOwif.EdQdbCodeKtj( iOwif.EKtjTentN, iOwif.Opid.tentN, "0" );
  aS += iOwif.EdQdbCodeKtj( iOwif.EKtjSrcUrl, iOwif.KcontentType, "0" );
  aS += iOwif.EdQdbCodeKtj( iOwif.EKtjSubInst, iOwif.subInstN, "0" );
  aS += iOwif.EdQdbCodeKtj( iOwif.EKtjSubAssoc, iOwif.subAssocN, "0" );
  var nxOwgc;
  for ( var i=0; (nxOwgc=iOwif.AOwgc[i++]); ) {
    aS += iOwif.EdQdbCodeKtj( iOwif.EKtjWig, nxOwgc.idN, "-1" );
    }
  return aS;
  };
TOwif.prototype.EdQdbCodeKtj = function EdQdbCodeKtj( iKtjC, iS, iDefaultS ) {
  var iOwif = this;
  var aS = "";
  if ( iS !== iDefaultS ) {
    aS = iKtjC + iS + 'W'; 
    }
  return aS;
  };
TOwif.prototype.tmiSetSelect = function tmiSetSelect( iOtmo ) {
  var iOwif = this;
  if (( iOwif )&&( iOwif.aStD.nowSelectB === true )) {
    var aOtmi = iOtmo.getOtmi( iOwif );
    if ( aOtmi.tickEl ) {
      aOtmi.tickEl.checked = true;
      }
    }
  };
TOwif.prototype.needed = function needed( ) {
  var iOwif = this;
  iOwif.neededB = true;
  if (( iOwif.aStD.carryB === true ) && ( iOwif.aStD.nowSelectB === false )) {
    iOwif.neededB = false;
    }
  return iOwif.neededB;
  };
TOtmr.prototype.tmiUpdateNotNeeded = function tmiUpdateNotNeeded( iOwif, iNod2 ) {
  var iOtmr = this;
  var iOwig = iOtmr.Owig;
  var nxOwif;
  var matchB = false;
  for ( iOwig.fiActOwif(); (nxOwif=iOwig.nxActOwif()); ) {
    if ( nxOwif == iOwif ) {
      matchB = true;
      iOwig.actAOwif.splice( iOwig.nxActIOwif-1, 1 ); 
      iOwig.nxActIOwif--;
      }
    }
  iOwig.refreshAllB = true;
//  EdLog( "a iOwif.nod2" + iOwif.Nod2 + " iOwif.wifEl:" + iOwif.wifEl );
//  if ( iNod2 ) {
//    iOwif.wifEl = ;
//    }
  if ( iNod2 ) {
    // EdLog( "b" );
    iOtmr.tmiRemove( iNod2 );
    }
  iOwig.updateStatusSKcip();
  };
//
// build html for iOWif choice, includes layout container
// insert into group after insertPrNode
TOtmr.prototype.bldTmiAll = function bldTmiAll( iOwif, iFirstB, insertPrNode ) {
  // EdLog( "bldTmiAll" );
  var iOtmr = this;
  var iOwig = iOwif.Owig;
  if (( insertPrNode ) && ( insertPrNode.previousSibling )) {
    if ( insertPrNode.previousSibling.nodeType == 3 ) {
      insertPrNode = insertPrNode.previousSibling;
      }
    }
  iOtmr.bldTmiOuter( iOwif ); // layout container
  iOtmr.bldTmiInner( iOwif, iOwif.nod2 );
  if ( ( iOwig.EdKcipChk( iOwig.EKcipPerLine ) === false ) 
  && ( iOwig.widthEmS === '' )
  && ( ! iFirstB ) ) {
    var txtNod=document.createTextNode( "\240| " );
    iOwig.groupEl.insertBefore( txtNod, insertPrNode );
    }
  iOwig.groupEl.insertBefore( iOwif.nod1, insertPrNode );
  return iOwif.nod1;
  };
//
// iOwif = null for special
// iEntryBoxB = special is entry box, else "unspec"
TOtmr.prototype.bldTmiOuter = function bldTmiOuter( iOwif ) {
  // EdLog( "bldTmiOuter" );
  var iOtmr = this;
  var iOwig = iOwif.Owig;
  iOwif.nod1 = null;  // outer of possible pair
  iOwif.nod2 = null;  // inner or same as nod1
  if ( iOwig.EdKcipChk( iOwig.EKcipPerLine ) === true ) { 
    iOwif.nod1 = document.createElement('div');
    iOwif.nod1.className = 'zWidDiv';
    iOwif.nod2 = iOwif.nod1;
    }
  else if ( iOwig.widthEmS === '' ) { 
    iOwif.nod1 = document.createElement('span');
    iOwif.nod1.className = 'zWidSpan';
    iOwif.nod2 = iOwif.nod1;
    }
  else {
    iOwif.nod1 = document.createElement('span');
    iOwif.nod1.className = 'zWidInBSpan'; 
    iOwif.nod1.style.display = edInlineBlockS(); 
    iOwif.nod1.style.width = 1*(iOwig.widthEmS) + 'em'; 
    iOwif.nod2 = document.createElement('div');
    iOwif.nod2.className = "zWidInBDiv";
    iOwif.nod2.style.width = 1*(iOwig.widthEmS) + 'em';
    iOwif.nod1.insertBefore( iOwif.nod2, null );
    }
  // control proper
  if ( iOtmr.dataControl(iOwif) === true ) {
    iOwif.wifEl = iOwif.nod2;
    iOwif.markTemp();
/*
    if ( iOwif.Opid.einS != "" ) {
      iOwif.nod1.className += ' zNewInst'; 
      if ( iOwif.nod1 != iOwif.nod2 ) { iOwif.nod2.className += ' zNewInst'; }
      }
*/
    }
  else {
    var aS;
//    if ( iOwif.Kcntr == iOtmr.EKCntrEmptyEntryBox ) { aS = 'zEntryBox'; } else 
    if ( iOwif.Kcntr == iOtmr.EKCntrMessage ) { aS = 'zMsgWif'; }
    else { aS = 'zUnspec'; }
    iOwif.nod1.className += ' ' + aS; 
    if ( iOwif.nod1 != iOwif.nod2 ) { iOwif.nod2.className += ' ' + aS; }
    }
  }; 
TOtmr.prototype.dataControl = function dataControl(iOwif) {
  var iOtmr = this;
  return ( 
//  ( iOwif.Kcntr == iOtmr.EKCntrIdBox )
//  || ( iOwif.Kcntr == iOtmr.EKCntrTextArea ) ||
  ( iOwif.Kcntr == iOtmr.EKCntrTentLink )
  || ( iOwif.Kcntr == iOtmr.EKCntrPermLink ) );
  };
TOtmr.prototype.bldTmiInner = function bldTmiInner( iOwif, iPaEl ) {
  // EdLog( "bldTmiOuter" );
  var iOtmr = this;
  var iOwig = iOwif.Owig;
  var aPaEl = iPaEl;
  if ( ( iOwig.EdKcipChk( iOwig.EKcipPerLine ) === false ) 
  && ( iOwig.widthEmS === '' ) ) { 
    if ( ( ! document.getElementById ) || ( document.all ) ) {
      // mozzila ? 
      aPaEl = document.createElement('nobr'); 
      iPaEl.insertBefore( aPaEl, null );
      }
    }
  if ( ( iOwif.Kcntr != iOtmr.EKCntrMessage )
  && ( iOwig.EdKcipChk( iOwig.EKcipText ) === false ) ) {
    var newTickEl = iOwif.bldTick( iOwig.Otmr.checkboxB );
    aPaEl.insertBefore( newTickEl, null );
    }
  aPaEl.insertBefore( iOtmr.bldTmiKcntr(iOwif), null );
  var hNode = document.createElement('input');
  hNode.type="hidden";
  hNode.className = "zHide1";
  // hNode.value= "*(" + iOwig.wifId( iOwif, false ) + ")";
  iOwif.Opid.groupN = iOwig.selfIdN;
  hNode.value= iOwif.Opid.encode(true);
  iPaEl.insertBefore( hNode, null );
  iOwif.checkedB = ( iOwif.aStD.nowSelectB === true );
  };
//
// case where entry box droped leaving nothing selected
// revert to cycle or database selection
TOtmr.prototype.tmiBoxDropFix = function tmiBoxDropFix( iOwif ) {
  var iOtmr = this;
  var iOwig = iOwif.Owig;
  if ( ( iOwif !== null )&&( iOwif.neededB === false ) ) {
    if ( iOwig.EdKcipChk( iOwig.EKcipUnique ) === true ) {
      iOwig.summary();
      var cOwif = null;
      if ( iOwig.uniqCycleOwif !== null ) { cOwif = iOwig.uniqCycleOwif; }
      else if ( iOwig.uniqDbOwif !== null ) { cOwif = iOwig.uniqDbOwif; }
      if ( cOwif !== null ) {
        cOwif.aStD.nowSelectB = true;
        iOwig.saveAll( );
        }
      }
    // alert( "set refocus" );
    }
  };
TOwif.prototype.nowState = function( ) {
  var iOwif = this;
  var iOwig = iOwif.Owig;
  if ( iOwif.Kcntr === iOwig.Otmr.EKCntrUnSpec ) {
    iOwif.curTextS = '';
    iOwif.aStD.nowSelectB = ( iOwig.selectCnt === 0 );
    if ( ( iOwig.EdKcipChk( iOwig.EKcipManditory ) === true ) 
    && ( iOwig.selectCnt === 0 )
    && ( iOwif.aStD.nowSelectB === true ) ) { iOwif.nowKefv = iOwig.EKefvNak; }
    else { iOwif.nowKefv = iOwig.uniqueKefv; }
    }
/*
  else if ( iOwif.Kcntr === iOwig.Otmr.EKCntrEmptyEntryBox ) {
    iOwif.nowKefv = iOwig.EKefvNone;
    if ( ( iOwig.EdKcipChk( iOwig.EKcipManditory ) === true ) 
    && ( iOwig.selectCnt === 0 )
    && ( iOwig.Otmr.needUnspecB === false ) ){ iOwif.nowKefv = iOwig.EKefvNak; }
    iOwif.curTextS = '';
    iOwif.aStD.nowSelectB = false;
    }
*/
  else {
    iOwif.nowKefv = iOwig.EKefvNone;
    if ( iOwig.EdKcipChk( iOwig.EKcipUnique ) === true ) {
      if ( iOwif == iOwig.uniqNowOwif ) { iOwif.nowKefv = iOwig.uniqueKefv; }
      else if ( iOwif == iOwig.uniqDbOwif ) { iOwif.nowKefv = iOwig.uniqueKefv; }
      else { iOwif.nowKefv = iOwig.EKefvNone; }
      }
    else {
      iOwif.nowKefv = iOwif.nowKefvFn();
      }
    }
  };
TOtmr.prototype.getKcntr = function( iOwif ) {
  var iOtmr = this;
  var iOwig = iOwif.Owig;
  var aKcntr = 0;
  if ( iOwig.EdKcipChk( iOwig.EKcipNameIsId ) === true ) { alert( "getKcntr EKCntrIdBox" ); }
  else if ( iOwig.EdKcipChk( iOwig.EKcipText ) === true ) { alert( "getKcntr EKCntrTextArea" ); }
  if ( iOwif.Opid.einS !== '' ) { aKcntr = iOtmr.EKCntrTentLink; }
  else if ( iOwif.aStD.carryB === false ) { aKcntr = iOtmr.EKCntrPermLink; }
  else {alert( "getKcntr EKCntrIdBox-2" ); }
  return aKcntr;
  };
TOwif.prototype.bldTick = function( iCheckboxB ) {
  var iOwif = this;
  var iOwig = iOwif.Owig;
  var tNode = document.createElement('input');
  if ( iOwig.tickBoxB === false ) { tNode.style.display = "none"; }
  if ( iCheckboxB === true ) {
    if (( iOwig.EdKcipChk( iOwig.EKcipNoDel ) === true ) 
    && ( iOwif.aStD.carryB === false )) {
      tNode.disabled = true;
      }
    tNode.type = "checkbox";
    }
  else {
/*
    if ( iOwif.Kcntr == iOwig.Otmr.EKCntrEmptyEntryBox ) {
      tNode.disabled = true;
      }
*/
    tNode.type = "radio";
    tNode.name = "idEfG" + iOwig.groupN;
    }
  tNode.value = iOwif.Opid.hojS; // used ?? inxOwif; 
  tNode.className = "zEdPre" + iOwif.nowKefv;
  return tNode;
  };
TOtmr.prototype.bldTmiKcntr = function( iOwif ) {
  var iOtmr = this;
  var iOwig = iOwif.Owig;
  var aNode, bNode, cNode;
  // alert( "bldTmiKcntr iOwif.Kcntr:" + iOwif.Kcntr + " groupN " + iOwig.groupN );
  if ( iOwif.Kcntr == iOtmr.EKCntrUnSpec ) {
    aNode = gAOkel[ KUnspec ].insert(null);
    bNode = document.createTextNode('unspecified');
    aNode.insertBefore( bNode, null );
    }
  else if ( iOwif.Kcntr == iOtmr.EKCntrMessage ) {
    aNode = gAOkel[ KEdMessage ].insert(null);
    bNode = document.createTextNode('Need one or more');
    aNode.insertBefore( bNode, null );
    }
  else if (( iOwif.Kcntr == iOtmr.EKCntrTentLink )||( iOwif.Kcntr == iOtmr.EKCntrPermLink )) {
    // link
    aNode = document.createElement( "a" );
    if ( iOwif.Kcntr == iOtmr.EKCntrPermLink ) {
      var aOlnk = new TOlnk( iOwig.newUrlS );
      var botUrlS = aOlnk.replaceInst( iOwif.Opid.hojS, false );
      var fullUrlS = aOlnk.replaceInst( iOwif.Opid.hojS, true );
      aNode.href = fullUrlS;
      aNode.target = "_blank";
      }
    else { // newly created or edited perm
      aNode.href = "#";
      }
    bNode = document.createElement( "span" );
    aNode.insertBefore( bNode, null );
    bNode.className = "zLink";
    var classS = "";
    if ( iOwif.KcontentType == iOwif.EKcontentTypeText ) {
      cNode = document.createTextNode( iOwif.curTextS );
      bNode.insertBefore( cNode, null );
      }
    else if ( iOwif.KcontentType == iOwif.EKcontentTypeImg ) {
      classS = "zImg";
      }
    else if ( iOwif.KcontentType == iOwif.EKcontentTypeIcon ) {
      classS = "zIcon";
      }
    if ( classS !== '' ) {
      cNode = document.createElement( "img" );
      cNode.src = iOwif.srcUrlS;
      cNode.alt = iOwif.curTextS.edHtmlEsc();
      cNode.className = classS;
      bNode.insertBefore( cNode, null );
      }
    }
  return aNode;  
  };
TOtco.prototype.bldTcoInner2 = function( iOwif, iPaEl ) {
  var iOtco = this;
  var iOwig = iOwif.Owig;
  var aPaEl = iPaEl;
  aPaEl.insertBefore( iOtco.bldTcoInner(iOwif), null );
  var hNode = document.createElement('input');
  hNode.type="hidden";
  hNode.className = "zHide1";
  // hNode.value= "*(" + iOwig.wifId( iOwif, false ) + ")";
  hNode.value= iOwif.Opid.encode(true);
  iPaEl.insertBefore( hNode, null );
  iOwif.checkedB = ( iOwif.aStD.nowSelectB === true );
  };
TOtco.prototype.bldTcoInner = function( iOwif ) {
  var iOtco = this;
  var iOwig = iOwif.Owig;
  var aNode, bNode, cNode;
  // alert( "bldTmiKcntr iOwif.Kcntr:" + iOwif.Kcntr + " groupN " + iOwig.groupN );
  if ( iOwig.EdKcipChk( iOwig.EKcipNameIsId ) === true ) {
    var aKefv = iOwif.nowKefv;
    var aS = iOwif.curTextS;
    if ( iOwif.curTextS === "" ) { 
      if ( ( iOwif.nowKefv === 0 )
      && ( iOwig.EdKcipChk( iOwig.EKcipManditory ) === false ) ) { aKefv = 4; }
      else { aKefv = 5; }
      aS = iOwig.promptText( );
      }
    // EdLog( " EKCntrEmptyEntryBox aKefv:" + aKefv + " aS:" + aS 
    // + " iOwif.curTextS:" + iOwif.curTextS 
    // + " iOwif.nowKefv:" + iOwif.nowKefv );
    aNode = gAOkel[ KEmptyEntry ].insert(null);
    aNode.className = "zEdText" + aKefv;
    aNode.onfocus = edEvtXnoAll;
    // aNode.onblur = edEvtXnoAll;
    aNode.value = aS; 
    }
  else if ( iOwig.EdKcipChk( iOwig.EKcipText ) === true ) {
    var wikiS = iOwif.curTextS.EdWikiString();
    aNode = document.createElement('textarea');
    aNode.cols="48";
    aNode.rows="6";
    aNode.onchange = edEvtXnoAll;
    aNode.className = "zEdText" + iOwif.nowKefv;
    bNode = document.createTextNode( wikiS );
    aNode.insertBefore( bNode, null );
    // oS += "<input type=\"hidden\" value=\"" + iOwif.nowKefv + "(" + wikiS + ")\" >";
    }
  else {
    alert( "bldTcoInner NOT EKcipText or EKcipNameIsId" );
    }
  return aNode;  
  };
TOwif.prototype.nonWiki = function( iS ) {
  var iOwif = this;
  var oS = '';
//  var ss = iS.split( String.fromCharCode( 13, 10 ) );
  var ss = iS.split( String.fromCharCode( 13 ) );
  var inx,l;
  for ( inx=0,l=ss.length; inx<l; inx++ ) {
    if ( ss[inx] === '' ) {
      oS += String.fromCharCode( 10 );
      }
    else {
      oS += ss[inx];
      }
    }
  return oS;
  };
TOwif.prototype.markTemp = function( ) {
  var iOwif = this;
  var inx = iOwif.nod1.className.indexOf( "zNewInst" );
  if ( iOwif.Opid.einS !== "" ) {
    if ( inx == -1 ) { 
      if ( iOwif.nod1.className === "" ) {
        iOwif.nod1.className = 'zNewInst'; // Xno case on tr ?
        }
      else {
        iOwif.nod1.className += ' zNewInst'; 
        }
      }
    }
  else {  
    if ( inx != -1 ) { iOwif.nod1.className = iOwif.nod1.className.substr( 0, inx ); }
    }
  if ( iOwif.nod1 != iOwif.nod2 ) { iOwif.nod2.className = iOwif.nod1.className; }
  };
TOwig.prototype.uniqChangeSelected = function( iOwif ) {
  var iOwig = this;
  if ( iOwig.uniqOwif !== null ) {
    iOwig.uniqOwif.neededB = true;
    iOwig.uniqOwif.aStD.nowSelectB = false;
    }
  iOwig.uniqOwif = iOwif;
  if ( iOwif !== null ) {
    iOwif.aStD.nowSelectB = true;
    }
  iOwig.saveAll( );
  };
TOwif.prototype.encodeEin = function() {
  var aOwif = this;
  var aOeih = new TOeih();
  if ( aOwif.Opid.einS !== "" ) {
    aOeih.decode( aOwif.Opid.einS );
    aOeih.orderN = aOwif.curOrderN;
    aOeih.subjHojS = aOwif.Opid.hojS;
    // encEinS += aOwif.curOrderN + 'X' + aOwif.Opid.hojS + 'X' + aOwif.Opid.einS;
    // encEinS += aOwif.Opid.einS;
    }
  else { 
    aOeih.paHojS = aOwif.Opid.hojS;
    aOeih.subjHojS = aOwif.Opid.hojS;
    // encEinS += '0X' + aOwif.Opid.hojS + 'X' + '0X0X0X'+ aOwif.Opid.hojS + 'X()'; 
    }
  var encEinS = '(n' + aOeih.encode(true) + 'n)';
  // alert( "B aOeih.encode(true):" + aOeih.encode(true) );
  return encEinS;
  };
TOwif.prototype.nowKefvFn = function nowKefvFn() {
  var iOwif = this;
  var iOwig = iOwif.Owig;
  var nowKefv = iOwif.aStD.Kefv;
  if ( ( iOwif.aStD.cycleSelectB != iOwif.aStD.nowSelectB ) 
  && ( ( nowKefv == iOwig.EKefvNone )||( nowKefv == iOwig.EKefvAck ) ) ) {
    nowKefv = iOwig.EKefvTest;
    }
  if ( nowKefv == iOwig.EKefvNone ) {
    if (( iOwig.EdKcipChk( iOwig.EKcipNameIsId ) )
    || ( iOwig.EdKcipChk( iOwig.EKcipText )) ) { 
      if ( iOwif.curTextS != iOwif.origTextS ) {
        nowKefv = iOwig.EKefvTest;
        }
      }
    }
  return nowKefv;
  };
// get <mainInst>
TOwif.prototype.toEf = function toEf( ioEdsub ) {
  var iOwif = this;
  var iOwig = iOwif.Owig;
  var hojS;
/*   
  BNF
     ein=(<mainInst>){(<subInst>)}
     subInst=<preamble>(<ein>)
     mainInst={<ef>+}
     preamble=<id>x(<name>)
     ef = [t|f][t|f]<inst>:<httm> } { real Efs }
     ef = [s]<file> } { specials , ie upload file }
*/
  var prText2 = iOwif.origTextS;
  EdEfChk( 3, iOwif.Opid.einS );
  var newTextS = iOwif.curTextS;
  var nowKefv = iOwif.nowKefvFn();
  var posB = true;
  if (( nowKefv == iOwig.EKefvTest ) || ( nowKefv == iOwig.EKefvNak )) { 
    ioEdsub.checkB = true; 
    }
  if ( iOwif.Opid.einS !== "" ) {
    // ein for sub instance
    ioEdsub.eeStr += '(j' + iOwif.encodeEin() + 'j)';
    }
  else if (( nowKefv != iOwig.EKefvNone )
  |(( iOwif.curOrderN !== iOwif.origOrderN )&&( iOwif.curOrderN !== 0 )&&( iOwif.origOrderN !== 0 ))) {
    // ef term on subject instance
    if ( iOwif.Opid.hojS === '' ) { // text oj
      var textS = iOwif.curTextS;
      if (( textS === "" )&&(iOwif.curTextS !== "" )) {
        textS = iOwif.curTextS;
        posB = false;
        }
      if ( iOwig.EdKcipChk( iOwig.EKcipNameIsId ) === false ) { 
        textS = iOwif.nonWiki( textS ); 
        }
      hojS = gLitStrKoi + '0a' // idS = 0 a=KojmNone 
      + 'Z' + textS.nsToOjText();
      }
    else { 
      hojS = iOwif.Opid.hojS; 
      }
    var nChar = 'f';  // new
    if ( iOwif.aStD.Kefv === iOwig.EKefvTest ) { nChar = 't'; }
    if ( iOwif.aStD.nowSelectB === false ) { posB = ! posB; }
    var sChar = 'f';
    if ( posB === true ) { sChar = 't'; }
    var aOlnk = new TOlnk( iOwig.newUrlS );
    ioEdsub.efStr += sChar + nChar + hojS + 'X' + iOwif.curOrderN + 'X' + aOlnk.typeS + '+';
    // <not><new><inst>X<order>X<type>
    ioEdsub.HojS = iOwig.subHojS;
    ioEdsub.abIdS = iOwig.abIdS;
    }
  };
//
// click on radio/check box
TOwig.prototype.evtTmiTick = function evtTmiTick( iOwif, iEl ) {
  var aOwif = iOwif;
  var aOwig = this; // aOwif.Owig;
  var aOtmi = new TOtmi( iEl.parentNode );
  // EdLog( "A aOwig.actAOwif.length:" + aOwig.actAOwif.length );
  if ( iEl.type == 'checkbox' ) {
    if ( aOwif !== null ) {
      aOwif.aStD.nowSelectB = ! aOwif.aStD.nowSelectB;
      if ( aOwif.needed() ) {
        aOwif.refreshB = true;
        }
      else { 
        aOwig.notNeededOwif = aOwif;
        }
      }
    }
  else {
    if (( aOwig.uniqOwif !== aOwif )&&( aOwig.uniqOwif !== null )) { 
      aOwig.uniqOwif.aStD.nowSelectB = false;
      if ( aOwig.uniqOwif.needed() ) {
        aOwig.uniqOwif.refreshB = true;
        }
      else {
        aOwig.notNeededOwif = aOwig.uniqOwif;
        }
      }
    if ( aOwif !== null ) {
      aOwif.aStD.nowSelectB = true;
      aOwif.refreshB = true;
      }
    }
  // EdLog( "B aOwig.actAOwif.length:" + aOwig.actAOwif.length );
  if ( aOwig.notNeededOwif !== null ) {
    aOwig.Otmr.tmiUpdateNotNeeded( aOwig.notNeededOwif, aOtmi.Nod2 ); // aOwif.wifEl );
    }
  // EdLog( "C aOwig.actAOwif.length:" + aOwig.actAOwif.length );
  aOwig.saveAll();
  aOwig.summary();
  aOwig.refreshTmo( true );
  return false;
  };
//
// line items within multi/uno select list
// includes choice instances, dummy choices( search,new,unspec ) 
// and position within list control.
TOwif.prototype.bldXniData = function bldXniData( iPossibleB ) {
  var iOwif = this;
  var iOwig = iOwif.Owig;
  var butNode, txtNode, aS;
  var tdClassNameS = "";
  var aAEl = [];
  aAEl[0] = document.createElement('span');
  // var s2El = null;
  // var s3El = null;
  var selectEl = null;
  var curOptionN;
  if ( iOwig.Qtype === iOwig.EQtypeCno ) {
    // iOwig.Otmr.checkboxB = true;
    var aNode = iOwif.bldTick( true );
    aAEl[0].insertBefore( aNode, null );
    aAEl[0].className = "zCnoSpan";
    // alert( "iOwig.Kisu:" + iOwig.Kisu + " iOwig.EKisuSKvli:" + iOwig.EKisuSKvli );
//    if ( iOwig.Kisu === iOwig.EKisuSKvli ) {
      // aNode.checked = true;
//      }
    // alert( s1El.parentNode.parentNode.innerHTML );
    }
  else {
    if ( iOwig.EdKcipChk( iOwig.EKcipUnique ) === true ) {
      if ( iOwif.aStD.DbSelectB === false ) { 
        tdClassNameS = "zEdPre4"; // pick list entry
        }
      else { 
        tdClassNameS = "zEdPre" + iOwif.aStD.Kefv; 
        }
      }
    else {
      iOwif.nowState();
      if (( iOwif.aStD.nowSelectB === false ) 
      && ( iOwif.aStD.DbSelectB === false )
      && ( iOwif.aStD.cycleSelectB === false )
      ) { 
        tdClassNameS = "zEdPre4"; // pick list entry
        }
      else { 
        tdClassNameS = "zEdPre" + iOwif.nowKefv; 
        }
      }
    }
  txtNode = document.createTextNode( iOwif.curTextS );
  if ( ( iOwig.Qtype === iOwig.EQtypeEno ) && ( iPossibleB === false )
  && ( iOwig.EdKcipChk( iOwig.EKcipOrderable ) === true ) 
  ) {
    var aEl = document.createElement('span');
    aEl.className = "zEnoOrder";
    aEl.style.cursor = "n-resize"; // "move";
    var text2El = document.createTextNode( "" + (iOwig.matchCnt+1) + "- " );
    aEl.insertBefore( text2El, null );
    aAEl[0].insertBefore( aEl, null );
    }
  aAEl[0].insertBefore( txtNode, null );
  //
  var i,nxS,Ktj,nxOwgc,bEl;
  for ( i=0; (nxOwgc=iOwif.AOwgc[i++]); ) {
    aEl = document.createElement('span');
    aEl.className = "zNestWig";
    bEl = document.createElement('span');
    aAEl[i] = bEl;
    bEl.insertBefore( aEl, null );
    nxOwgc.Owig.groupEl = aEl;
    nxOwgc.Owig.rootIdEl = iOwig.rootIdEl;
    nxOwgc.Owig.bldWig( iOwif, i-1 );
    // alert( "bldXniData i:" + i + " outerHTML:" + aAEl[i].outerHTML );
    }
  //
  iOwig.matchCnt++;
  iOwig.fullN = 0;
  var aOpid = new TOpid();
  aOpid.init( iOwig.groupN, 0, iOwif.Opid.hojS, '', 0, 0, 0 );
  var trNode = iOwig.packageXni( 0, 0, aAEl, tdClassNameS, 1, iOwif.Opid );
  if ( iOwif !== null ) {
    iOwif.nod1 = trNode;
    iOwif.nod2 = trNode;
    iOwif.markTemp();
    }
  return trNode;
  };
function TOpid() {
  var aOpid = this;
  aOpid.init( 0, 0, '', '', 0, 0, 0 );
  }
TOpid.prototype.init = function init( iGroupN, iExno, iHojS, iEinS, iTentN, iStartN, iEndN ) {
  var aOpid = this;
  aOpid.groupN = iGroupN;
  aOpid.Exno = iExno;
  aOpid.hojS = iHojS;
  aOpid.einS = iEinS;
  aOpid.tentN = iTentN;
  aOpid.startN = iStartN;
  aOpid.endN = iEndN;
  };
TOpid.prototype.encode = function encode( iDoEinB ) {
  var aOpid = this;
  var aS = "";
  //if ( aOpid.groupN !== 0 ) {
    aS += aOpid.groupN + 'X'; // 0
    aS += aOpid.Exno + 'X'; // 1
    aS += aOpid.hojS + 'X'; // 2
    aS += aOpid.tentN + 'X'; // 3
    aS += aOpid.startN + 'X'; // 4
    aS += aOpid.endN; // 5
    if ( iDoEinB === true ) { aS += 'X' + aOpid.einS; } // 6 use textN for external id
   // }
  return aS;
  };
TOpid.prototype.decode = function decode( iS ) {
  var aOpid = this;
  var aS;
  var aOstrip = new TOstrip( iS );
  aOpid.groupN = 0;
  if ( aOstrip.S !== "" ) {
    aOpid.groupN = parseInt( aOstrip.strip('X'), 10 );
    }
  if ( aOstrip.S !== "" ) {
    aOpid.Exno = parseInt( aOstrip.strip('X'), 10 );
    aOpid.hojS = aOstrip.strip('X');
    aOpid.tentN = parseInt( aOstrip.strip('X'), 10 );
    aOpid.startN = parseInt( aOstrip.strip('X'), 10 );
    aOpid.endN = parseInt( aOstrip.strip('X'), 10 );
    aOpid.einS = aOstrip.S;
    }
  else {
    aOpid.init( aOpid.groupN, 0, "", "", 0, 0, 0 );
    }
/*
  alert( "TOpid.prototype.decode iS:" + iS
  + " aOpid.groupN:" + aOpid.groupN
  + " aOpid.Exno:" + aOpid.Exno
  + " aOpid.hojS:" + aOpid.hojS
  + " aOpid.tentN:" + aOpid.tentN
  + " aOpid.startN:" + aOpid.startN
  + " aOpid.endN:" + aOpid.endN
  + " aOpid.einS:" + aOpid.einS
  );
*/
  };
TOpid.prototype.show = function() {
  var aOpid = this;
  var aS = "Opid( groupN:" + aOpid.groupN
  + " Exno:" + aOpid.Exno
  + " hojS:" + aOpid.hojS
  + " tentN:" + aOpid.tentN
  + " startN:" + aOpid.startN
  + " endN:" + aOpid.endN
  + " einS:" + aOpid.einS
  + " )";
  };
function addOption( iSelEl, iS, iN, iSelectN ) {
  var optionEl = document.createElement('option');
  var txtNode = document.createTextNode( iS );
  optionEl.value = iN;
  optionEl.selected = ( iN === iSelectN );
  optionEl.insertBefore( txtNode, null );
  iSelEl.insertBefore( optionEl, null );
  }
TOwif.prototype.OcufUpdate = function OcufUpdate( iOcuf ) {
  var iOwif = this;
  var iOwig = iOwif.Owig;
  var aKefv = iOwif.nowKefvFn();
  //if ( gThisCaseB === true ) { 
  //  alert( "OcufUpdate " + aKefv + " nowSelectB " + iOwif.aStD.nowSelectB ); 
  //  }
//  if ( gThisCaseB === true ) { 
//    alert( "aKefv:" + aKefv 
//    + " iOwif.aStD.Kefv:" + iOwif.aStD.Kefv
//    + " iOwif.aStD.cycleSelectB:" + iOwif.aStD.cycleSelectB
//    + " iOwif.aStD.nowSelectB:" + iOwif.aStD.nowSelectB );
//    }  // 0 true,true
  if ( aKefv === iOwig.EKefvTest ) {
    iOcuf.changeB = true;
    iOcuf.uncheckedB = true;
    if ( iOwig.EdKcipChk( iOwig.EKcipSwitch ) === true ) { 
      iOcuf.swChangeB = true;
      }
    } 
  else if ( aKefv === iOwig.EKefvAck ) {
    iOcuf.changeB = true;
    } 
  else if ( aKefv === iOwig.EKefvNak ) {
    iOcuf.changeB = true;
    } 
  else if ( iOwif.Opid.einS !== "" ) {
    iOcuf.changeB = true;
    }
  if ( iOwif.aStD.nowSelectB === true ) { 
    iOcuf.selCnt++;
    // defaultStatus += iOcuf.selCnt;
    }
  };
TOwif.prototype.EdQdbEncodeState = function EdQdbEncodeState() {
  var iOwif = this;
  var iStD = iOwif.aStD;
  var aS = '' + iStD.Kefv;
  if ( iStD.DbSelectB === true ) { aS += '1'; } else { aS += '0'; }
  if ( iStD.cycleSelectB === true ) { aS += '1'; } else { aS += '0'; }
  if ( iStD.nowSelectB === true ) { aS += '1'; } else { aS += '0'; }
  if ( iStD.carryB === true ) { aS += '1'; } else { aS += '0'; }
  return aS;
  };
TOwif.prototype.EdQdbDecodeState = function EdQdbDecodeState( iS ) {
  var iOwif = this;
  var iOwig = iOwif.Owig;
  var stD = new Object();
  stD.Kefv = iS.charCodeAt( 0 ) - '0'.charCodeAt( 0 );
  stD.DbSelectB = ( iS.substr( 1, 1 ) == '1' );
  stD.cycleSelectB = ( iS.substr( 2, 1 ) == '1' );
  stD.nowSelectB = ( iS.substr( 3, 1 ) == '1' );
  stD.carryB = true;
  if ( iS.length > 4 ) { stD.carryB = ( iS.substr( 4, 1 ) == '1' ); }
  iOwif.aStD = stD;
  // return stD;
  };
/* *********************** */
function TOwil( iOwig, iPotB ) {
  var iOwil = this;
  iOwil.Owig = iOwig; 
  iOwil.Owin = iOwig.Owin; 
  iOwil.tableEl = null; 
  iOwil.divEl = null; 
  iOwil.selEl = null; 
  iOwil.potB = iPotB;
  }
function EdXnoToOxnoRecurse( iOwig, iEl, iOwil ) {
  var nxEl = null;
  var subEl = null;
  var i=0;
  var aOwil = iOwil;
  if ( (iOwil)&&( iEl.className.indexOf("zWid") === 0 ) 
  && ( iOwil.selEl !== null ) ) {
    /*jsl:pass*/ // nested controls
    }
  else {
    for ( i=0; nxEl=iEl.childNodes[i++]; ) {
      if ( nxEl.className ) {
        if ( nxEl.className === "zXnoInputPar" ) {
          iOwig.headDivEl = nxEl;
          }
        }
      if ( ( nxEl.tagName == "TBODY" )
      && ( nxEl.className.indexOf("zSelTBody") === 0 ) ) {
        var qualS = nxEl.className.substr( 9, 3 );
        if (( qualS === "Uno" )||( qualS === "Enp" )) { aOwil = iOwig.potOwil; }
        else if ( qualS === "Cno" ) { aOwil = iOwig.cnoOwil; }
        else if ( qualS === "Ena" ) { aOwil = iOwig.actOwil; }
        aOwil.selEl = nxEl; 
        aOwil.tableEl = nxEl.parentNode; 
        aOwil.divEl = aOwil.tableEl.parentNode; // ?? may not be div
        }
      else if ( nxEl.tagName == "SPAN" ) {
        if ( nxEl.className == "zUnoSearchText" ) {
          iOwig.unoSearchTextEl = nxEl; // reqd?
          }
        else if ( nxEl.className == "zXnoTypeCount" ) {
          iOwig.xnoTypeCountEl = nxEl;
          }
        }
      else if ( nxEl.tagName == "INPUT" ) {
        if ( nxEl.type == "checkbox" ) {
          iOwig.cbEl = nxEl;
          }
        else if ( nxEl.type == "text" ) {
          iOwig.textEl = nxEl;
          }
        else if ( nxEl.type == "button" ) {
          if ( nxEl.className == "zUniFind" ) {
            iOwig.uniFindButEl = nxEl;
            }
          else if ( nxEl.className == "zUniNew" ) {
            iOwig.uniNewButEl = nxEl;
            }
/*
          else if ( nxEl.className == "zXnoPageReq" ) {
            iOwig.xnoPageReqButEl = nxEl;
            }
*/
          }
        }
      else if ( nxEl.tagName == "TD" ) {
        if ( nxEl.className == "zTdEnoMove" ) { iOwil.moveTdEl = nxEl; } 
        else if ( nxEl.className == "zTdEnoActions" ) { iOwig.enoActionsTdEl = nxEl; }
        }
      if ( nxEl.nodeType == 1 ) { // element
        EdXnoToOxnoRecurse( iOwig, nxEl, aOwil );
        }
      }
    }
  }
TOwig.prototype.prepOwils = function ( iKXnoSt ) {
  var iOwig = this;
  iOwig.wigKXnoSt = iKXnoSt;
  iOwig.actOwil = null;
  iOwig.potOwil = null;
  iOwig.potOwil = null; 
  iOwig.cnoOwil = null; 
  if ( iOwig.Qtype === iOwig.EQtypeUno ) {
    iOwig.potOwil = new TOwil( iOwig, false ); 
    }
  else if ( iOwig.Qtype === iOwig.EQtypeEno ) {
    iOwig.potOwil = new TOwil( iOwig, true ); 
    iOwig.actOwil = new TOwil( iOwig, false );
    }
  else if ( iOwig.Qtype === iOwig.EQtypeCno ) {
    iOwig.cnoOwil = new TOwil( iOwig, true ); 
    }
  };
TOwig.prototype.getOwil = function ( iActualB ) { 
  var aOwig = this;
  var aOwil;
  if ( iActualB === true ) { 
    if ( aOwig.actOwil === null ) { aOwig.actOwil = new TOwil( aOwig, false ); }
    aOwil = aOwig.actOwil; 
    }
  else {
    if ( aOwig.Qtype === aOwig.EQtypeUno ) {
      if ( aOwig.potOwil === null ) { aOwig.potOwil = new TOwil( aOwig, false ); }
      aOwil = aOwig.potOwil; 
      }
    else if ( aOwig.Qtype === aOwig.EQtypeEno ) {
      if ( aOwig.potOwil === null ) { aOwig.potOwil = new TOwil( aOwig, true ); }
      aOwil = aOwig.potOwil; 
      }
    else if ( aOwig.Qtype === aOwig.EQtypeCno ) {
      if ( aOwig.cnoOwil === null ) { aOwig.cnoOwil = new TOwil( aOwig, true ); }
      aOwil = aOwig.cnoOwil; 
      }
    }
  return aOwil;
  };
TOwig.prototype.needActual = function ( iDropB ) { 
  var aOwig = this;
  var aB = ( aOwig.Qtype === aOwig.EQtypeEno )
  && (( aOwig.EdKcipChk( aOwig.EKcipNonInstHdr ) === false )||( iDropB===true));
  aB = aB || ( aOwig.EdKcipChk( aOwig.EKcipNewOnly ) === true );
  return aB;
  };
TOwig.prototype.needUspan = function () { 
  var aOwig = this;
  var aB = ( aOwig.imedKisu() === true ) 
  && ( aOwig.EdKcipChk( aOwig.EKcipSeperateDrop ) === true )
  && (( aOwig.Qtype === aOwig.EQtypeUno )||( aOwig.Qtype === aOwig.EQtypeCno ))
  && ( aOwig.wigKXnoSt === KXnoStMinimized );
  return aB;
  };
  
TOwig.prototype.needHdrText = function () { 
  var aOwig = this;
  var aB = 
  // aOwig.EdKcipChk( aOwig.EKcipCollapse ) && 
  ( aOwig.EdKcipChk( aOwig.EKcipNonInstHdr ) === true )
  && ( aOwig.wigKXnoSt === KXnoStMinimized );
  return aB;
  };

TOwig.prototype.needHdrInst = function () { 
  var aOwig = this;
  var aB = ( aOwig.EdKcipChk( aOwig.EKcipCollapse ) )
  && ( aOwig.Qtype !== aOwig.EQtypeUno ) 
  && ( aOwig.EdKcipChk( aOwig.EKcipNonInstHdr ) === false )
  && ( aOwig.wigKXnoSt === KXnoStMinimized );
  return aB;
  };
TOwig.prototype.listSuffix = function ( iPotB ) { 
  var aOwig = this;
  var aS = "";
  if ( aOwig.Qtype === aOwig.EQtypeUno ) { aS = "Uno"; }
  else if ( aOwig.Qtype === aOwig.EQtypeEno ) { 
    if ( iPotB === true ) { aS = "Enp"; }
    else { aS = "Ena"; }
    }
  else { aS = "Cno"; }
  return aS;
  };
TOwig.prototype.needDrop = function () { 
  var aOwig = this;
  var aB = ( aOwig.navB === true ) 
  && ( aOwig.EdKcipChk( aOwig.EKcipSeperateDrop ) === true )
  // && ( aOwig.EdKcipChk( aOwig.EKcipCollapse ) === true )
  && ( aOwig.wigKXnoSt !== KXnoStMinimized );
  return aB;
  };
TOwig.prototype.recMarkOwig = function ( iOpenOwig ) {
  var aOwig = this;
  if ( aOwig.rootIdEl === aOwig.selfIdEl ) {
    aOwig.wigKXnoSt = KXnoStOpen;
    }
  else {
    aOwig.wigKXnoSt = KXnoStClosed;
    }
  var nxOwif, nxOwgc, i;
  for ( aOwig.fiActOwif(); (nxOwif=aOwig.nxActOwif()); ) {
    for ( i=0; (nxOwgc=nxOwif.AOwgc[i++]); ) {
      nxOwgc.Owig.recMarkOwig( iOpenOwig );
      }
    }
  };
// 
TOwig.prototype.capture = function ( iBuiltB, iKXnoSt ) { // assumes xno built
  var iOwig = this;
  var rootOwig;
  iOwig.prepOwils( iKXnoSt );
  var i=0;
  var nxEl;
  for ( i=0; nxEl=iOwig.groupEl.childNodes[i++]; ) {
    if (( nxEl.className )
    && ( nxEl.className.indexOf( 'zWid' ) > -1 )) {
      iOwig.nod2 = nxEl;
      iOwig.prKXnoSt = KXnoStMinimized;
      if ( nxEl.className.indexOf( 'zOpen' ) > -1 ) { iOwig.prKXnoSt = KXnoStOpen; }
      else if ( nxEl.className.indexOf( 'zClosed' ) > -1 ) { iOwig.prKXnoSt = KXnoStClosed; }
      }
    }
  if ( iOwig.selfIdEl !== iOwig.rootIdEl ) {
    if ( iOwig.rootIdEl ) {
      iOwig.getDropHeader( iOwig.rootIdEl );
      }
    }
  EdXnoToOxnoRecurse( iOwig, iOwig.nod2, null );
  if ( iBuiltB === true ) {
    if ( ( iOwig.navB === true ) 
    && ( iOwig.EdKcipChk( iOwig.EKcipSeperateDrop ) === true ) ) { 
      var divEl = window.document.getElementById( "idDivXnoDrop" );
      if ( divEl !== null ) { 
        EdXnoToOxnoRecurse( iOwig, divEl, null );
        }
      }
    }
  iOwig.xnoPageReqButEl = document.getElementById( "idPageReqBut" );
  if ( iOwig.xnoPageReqButEl !== null ) {
    iOwig.xnoPageReqButEl.disabled = ! iOwig.Owin.ctmToOlnk( null );
    // alert( "disabled " + iOwig.xnoPageReqButEl.disabled );
    }
  if ( iOwig.dropImageEl !== null ) {
    rootOwig = new TOwig();
    rootOwig.fromIdEl( iOwig.Owin, iOwig.rootIdEl, false );
    if ( rootOwig.EdKcipChk( rootOwig.EKcipSubUnchecked ) === true ) { 
      iOwig.dropImageEl.className = "zDropIcon1";
      }
    else { 
      iOwig.dropImageEl.className = "zDropIcon0";
      }
    }
  if ( iOwig.textEl ) {
    iOwig.searchS = iOwig.realSearchS( iOwig.textEl );
    }
  };
TOwig.prototype.getDropHeader = function( iIdEl ) {
  var aOwig = this;
  var nxEl;
  var els = iIdEl.nextSibling.getElementsByTagName( "IMG" );
  for ( var i=0; nxEl = els[i++]; ) {
    if ( nxEl.className.indexOf( "zDropIcon" ) === 0 ) { aOwig.dropImageEl = nxEl; }
    // alert( nxEl.outerHTML + ( nxEl.className.indexOf( "zDropIcon" ) === 0 ) );
    }
  };
TOwig.prototype.cnoOperate = function( iKel ) {
  var aOwig = this;
  if ( aOwig.needDrop() === true ) {
    aOwig.getMakeDrop();
    }
  var listEl = aOwig.cnoOwil.selEl;
//  alert( "innerHTML:" + listEl.innerHTML );
  var els = listEl.getElementsByTagName( "input" );
//  alert( "els.length:" + els.length );
  var inx, el;
  var val = 0;
  if ( iKel === KCnoSet ) { 
    var aUrl = document.location.href;
    var aOlnk = new TOlnk( aUrl );
    }
  for ( inx=0; (el=els[inx++]); ) {
    if ( el.type === 'checkbox' ) {
      if ( iKel === KCnoAll ) { el.checked = true; }
      else if ( iKel === KCnoSet ) { 
        el.checked = (( aOlnk.SKvliN & parseInt( el.value, 10 ) ) === 0 ); 
        }
      else if ( iKel === KCnoNone ) { el.checked = false; }
      else if ( iKel === KCnoDone ) { 
        if ( el.checked === false ) { val += parseInt( el.value, 10 ); }
        }
      }
    }
  if ( iKel === KCnoDone ) {
    if ( aOwig.Kisu === aOwig.EKisuSKvli ) { aOwig.SKvliOperate( val ); }
    else { alert( "zCnoDone aOwig.Kisu:" + aOwig.Kisu ); } 
    }
  };
TOwig.prototype.SKvliOperate = function SKvliOperate( iSKvli ) { 
  var aUrl = document.location.href;
  var aOlnk = new TOlnk( aUrl );
  aOlnk.SKvliN = iSKvli;
//  alert( 'aOlnk.encodeView( )' + aOlnk.encodeView() 
//  + " iSKvli:" + iSKvli 
//  + " aOlnk.KvinvS:" + aOlnk.KvinvS 
//  + " aOlnk.viewN:" + aOlnk.viewN );
  var bUrlS = aUrl.substr( 0, aOlnk.opPosn+1 ) + aOlnk.encodeView()  
  + aUrl.substr( aOlnk.qualPosn, aUrl.length-aOlnk.qualPosn );
  toPageExt( bUrlS, false );
  };
TOwig.prototype.realSearchS = function realSearchS( iEl ) {
  var aOwig = this;
  var searchS = "";
  if (( iEl ) 
  && ( iEl.className != "zEdUText4" )&&( iEl.className != "zEdUText5" )) {
    searchS = iEl.value;
    }
  return searchS;
  };
TOwig.prototype.bldXniControl = function bldXniControl( iUnoN, iS ) {
  var iOwig = this;
  var colSpanN = 1;
  var d1El, d2El, tdEls, tdEl;
  var butNode, txtNode, aS, spanNode;
  var tdClassNameS = "";
  var bN = iUnoN; // packageXni parameter, variable meaning
//  if ( iUnoN == iOwig.EEnoPosList ) { spanNode = document.createElement('div');}
//  else { spanNode = document.createElement('span'); }
  spanNode = document.createElement('span');
  if ( iUnoN == iOwig.EEnoActAllNone ) { 
    gAOkel[ KXnoActAll ].insert(spanNode);
    gAOkel[ KXnoActNone ].insert(spanNode);
    }
  else if ( iUnoN == iOwig.EUnoPosAllNone ) {
    gAOkel[ KXnoPosAll ].insert(spanNode);
    gAOkel[ KXnoPosNone ].insert(spanNode);
    }
  else if ( ( iUnoN == iOwig.EXnoNew )||( iUnoN == iOwig.EUnoUnspec )) {
    tdClassNameS = "zEdPre5";
    if ( iUnoN == iOwig.EXnoNew ) {
      if ( iOwig.matchCnt === 0 ) { aS = "none - New"; }
      else { aS = "other - New"; }
      }
    else if ( iUnoN == iOwig.EUnoUnspec ) {
      if ( iOwig.EdKcipChk( iOwig.EKcipManditory ) === true ) { 
        tdClassNameS = "zEdPre6"; 
        }
      aS = "Unspecified";
      }
    txtNode = document.createTextNode( aS );
    spanNode.insertBefore( txtNode, null );
    }
  else if ( iUnoN == iOwig.ECnoButs ) {
    gAOkel[ KCnoAll ].insert(spanNode);
    gAOkel[ KCnoNone ].insert(spanNode);
    gAOkel[ KCnoDone ].insert(spanNode);
    }
  else if ( iUnoN == iOwig.EUnoMove ) {
    gAOkel[ KUnoMove1 ].insert(spanNode).disabled = ( iOwig.startN == 1 );
    gAOkel[ KUnoMove2 ].insert(spanNode).disabled = ( iOwig.startN == 1 );
    //
    aS = " " + iOwig.startN + "-" + iOwig.endN + " of " + iOwig.fullN + ". ";
    txtNode = document.createTextNode( aS );
    spanNode.insertBefore( txtNode, null );
    //
    gAOkel[ KUnoMove3 ].insert(spanNode).disabled = ( iOwig.endN > (iOwig.fullN-1) );
    gAOkel[ KUnoMove4 ].insert(spanNode).disabled = ( iOwig.endN > (iOwig.fullN-1) );
    bN = iOwig.startN;
    }
  else if ( iUnoN == iOwig.EUnoWait ) {
    txtNode = document.createTextNode( iS );
    spanNode.insertBefore( txtNode, null );
    }
  else if ( iUnoN == iOwig.EXnoPageReq ) {
    iOwig.xnoPageReqButEl = gAOkel[ KXnoPageReq ].insert(spanNode);
    iOwig.xnoPageReqButEl.disabled = ! iOwig.Owin.ctmToOlnk( null );
    iOwig.xnoPageReqButEl.id = 'idPageReqBut';
    gAOkel[ KXnoDropClose ].insert(spanNode);
    if ( iOwig.EdKcipChk( iOwig.EKcipTypeCount ) === true ) {
      iOwig.xnoTypeCountEl = gAOkel[ KXnoTypeCount ].insert(spanNode);
      setInnerText( iOwig.xnoTypeCountEl, " " + gSubjInstCount + " Found" );
      }
    }
  else if ( iUnoN == iOwig.EXnoTypeCount ) {
    // iOwig.xnoPageReqButEl.disabled = ! iOwig.Owin.ctmToOlnk( null );
    // iOwig.xnoPageReqButEl.id = 'idPageReqBut';
    gAOkel[ KXnoDropClose ].insert(spanNode);
    }
  // var hidS = "";
  var aOpid = new TOpid();
  aOpid.init( iOwig.groupN, iUnoN, '', '', 0, iOwig.startN, iOwig.fullN );
  var trNode = iOwig.packageXni( iUnoN, 0, [ spanNode ]
  , tdClassNameS, colSpanN, aOpid );
  return trNode;
  };
function TOkel( iTagNameS, iTypeS, iValueS, iClassNameS, iDisableB ) {
  var aOkel = this;
  aOkel.tagNameS = iTagNameS;
  aOkel.typeS = iTypeS;
  aOkel.valueS = iValueS;
  aOkel.classNameS = iClassNameS;
  aOkel.disableB = iDisableB;
  } 
TOkel.prototype.insert = function ( iWithinEl ) {
  var iOkel = this;
  var aEl = document.createElement( iOkel.tagNameS );
  if ( iOkel.typeS !== "" ) { aEl.type = iOkel.typeS; }
  if ( iOkel.valueS !== "" ) { aEl.value = iOkel.valueS; }
  if ( iOkel.classNameS !== "" ) { aEl.className = iOkel.classNameS; }
  if ( iOkel.disabledB === false ) { aEl.disabled = iOkel.disabledB; }
  if ( iWithinEl !== null ) { iWithinEl.insertBefore( aEl, null ); }
  return aEl;
  };
TOwig.prototype.bldRequired = function bldRequired( iN ){ 
  // defaultStatus += " bldRequired";
  defaultStatus += 'A';
  var aOwig = this;
  var aOwil;
  var xS = "bldRequired-10 cnnAllocN:" + aOwig.cnnAllocN
  + " groupN:" + aOwig.groupN
  + " " + KXnoStS(aOwig.wigKXnoSt) + " " + aOwig.toQtypeS( aOwig.Qtype );
  + " aOwig.searchS:" + aOwig.searchS;
  if ( aOwig.unFocusB ) { xS += " uFocus"; } 
  if ( aOwig.actOwil ) { xS += " actOwil"; }
  if ( aOwig.newlyOpenB ) { xS += " newlyOpenB"; }
  if ( aOwig.setFocusB ) { xS += " setFocusB"; }
  if ( window.document.getElementById( "idDivXnoDrop" ) !== null ) { xS += " idDivXnoDrop"; }
  // EdLog( xS );
  if ( aOwig.Qtype === aOwig.EQtypeCno ) { aOwil = aOwig.cnoOwil; }
  else { aOwil = aOwig.potOwil; }
  // var hideDivEl = aOwil.divEl; 
  if ( aOwig.needDrop() === true ) {
    aOwig.getMakeDrop();
    }
  //
  var aS;
  if ( aOwig.unFocusB === true ) { // delay hidding table until possible selection click done 
    gBlurUnoEl = aOwil.divEl; 
    } 
  if ( aOwig.needActual( aOwig.needDrop() ) === true ) {  
    if ( aOwig.Qtype === aOwig.EQtypeUno ) { aOwig.potOwil.bldXnoList( ); }
    else { aOwig.actOwil.bldXnoList( ); }
    if ( aOwig.Qtype === aOwig.EQtypeEno ) {
      aOwig.bldEnoButs();
      aOwig.sideEffect( aOwig.actOwil ); 
      }
    }
  xS += aOwig.needSearch() + ' ' + (aOwig.newlyOpenB === true)
  + ' KXnoSt:' + aOwig.wigKXnoSt 
  + ' qType:' + aOwig.Qtype
  + ' headDiv:' + ( aOwig.headDivEl );
  if (  ((aOwig.needSearch())&&(aOwig.newlyOpenB === true))
  || (  ( aOwig.wigKXnoSt === KXnoStMinimized )
    &&( aOwig.Qtype !== aOwig.EQtypeCno ) &&(aOwig.headDivEl) )
  ) {
    xS += 'a1';
    if ( aOwig.textEl ) {
      xS += 'a2';
      // prompt currently showing ?
      var promptB = ( aOwig.textEl.className == "zEdUText4" ) 
      || ( aOwig.textEl.className == "zEdUText5" ); 
      //
      aOwig.uTextBox( aOwig.wigKXnoSt !== KXnoStMinimized, aOwig.headDivEl ); // active=
      if ( aOwig.wigKXnoSt !== KXnoStMinimized ) {
        xS += 'a3';
        aOwig.textEl = aOwig.headDivEl.childNodes[0];
        aOwig.textEl.value = aOwig.searchS;
        aOwig.searchS = aOwig.realSearchS( aOwig.textEl );
        // EdLog( "bldRequired-20 aOwig.searchS:" + aOwig.searchS );
        }
      }
    }
  if ( gThisCaseB === true ) { alert( xS ); gThisCaseB=false; }
  // defaultStatus += 'C';
  if (( aOwig.Qtype === aOwig.EQtypeUno )
  ||( aOwig.Qtype === aOwig.EQtypeEno )) { // controls that can have pot list 
    aOwig.potOwil.bldXnoList( ); 
    if ( aOwig.wigKXnoSt === KXnoStOpen ) { 
      aOwig.potOwil.divEl.style.display = "block"; 
      if ( aOwig.Qtype === aOwig.EQtypeUno ) {
        aOwig.moveButFix();
        if ( aOwig.uniqNowOwif ) {
          var matchSS = aOwig.searchS.split(" ");
          var matchB = searchMatch( true, matchSS, aOwig.uniqNowOwif.curTextS );
          if ( matchB === false ) { aOwig.uniqNowOwif = null; }
          }
        aOwig.bldUnoActualButs();
        }
      }
    }
  // defaultStatus += 'E';
  if ( ( aOwig.wigKXnoSt === KXnoStMinimized ) 
  && ( aOwig.Qtype === aOwig.EQtypeUno ) 
  && ( aOwig.navB === true ) ) {
    aOwig.bldUnoActualButs();
    }
  if (( aOwig.Qtype === aOwig.EQtypeCno ) && ( aOwig.newlyOpenB === true )){ 
    // defaultStatus = " bld Cno" + iOwig.cnoOwil.selEl;
    // alert( "pre cno" );
    aOwig.cnoOwil.divEl.style.display = "block"; 
    aOwig.cnoOwil.bldXnoList( ); 
    defaultStatus += "Z";
    // alert( 'built cno ' + xS );
    }
  if ( aOwig.setFocusB === true ) {
    if ( aOwig.textEl !== null ) {
      aOwig.textEl.select();
      aOwig.textEl.focus();
      }
    gSetFocusB = true;
    }
  if (( aOwig.wigKXnoSt === KXnoStMinimized )
  && ( aOwig.rootIdEl === aOwig.selfIdEl )) {
    var divEl = window.document.getElementById( "idDivXnoDrop" );
    if ( divEl ) { aOwig.Owin.bodyAbsDiv.removeChild( divEl ); }
    }
  // defaultStatus += 'G';
  gOpenRootIdEl = aOwig.rootIdEl;
  gOpenSelfIdEl = aOwig.selfIdEl;
  if ( aOwig.wigKXnoSt === KXnoStMinimized ) { 
    if ( gOpenSelfIdEl === gOpenRootIdEl ) { 
      gOpenRootIdEl = null; 
      }
    gOpenSelfIdEl = gOpenRootIdEl; 
    }
  gBlurUnoEl = null;
  defaultStatus += 'Z';
  };
TOwil.prototype.getSelected = function getSelected( iAlertB ) {
  var iOwil = this;
  var aSelEl = iOwil.selEl;
  var trEl,nxEl,inx,aOwig;
  iOwil.selOwif = null;
  var i = 0;
  iOwil.selCnt = 0;
  iOwil.selTdEl = null;
  if ( aSelEl !== null ) {
    for ( i=0; trEl=aSelEl.childNodes[i++]; ) {
      nxEl = trEl.childNodes[0]; // tr -> td
      inx = nxEl.className.indexOf( "zXnoSelected" );
      if ( inx != -1 ) { 
        iOwil.selTdEl = nxEl;
        iOwil.selCnt++; 
        }
      }
    if ( iOwil.selCnt == 1 ) {
      iOwil.selOwif = iOwil.Owig.getElOwif( iOwil.selTdEl );
      }
    else if ( iOwil.selCnt === 0 ) {
      if ( iAlertB === true ) { alert( "None selected." ); }
      }
    else {
      if ( iAlertB === true ) { alert( "More than one selected" ); }
      }
    }
  };
TOwig.prototype.sideEffect = function sideEffect( iOwil ) {
  // var iOxno = this;
  var iOwig = this;
  var hN;
  // var aS = '1';
  var bodyEls = document.getElementsByTagName("BODY");
  if ( bodyEls[ 0 ].style.visibility == 'visible' ) {
    // aS += '2';
    if ( iOwig.Qtype !== iOwig.EQtypeUno ) {
      // aS += '3';
      if (( iOwil.moveTdEl ) && ( iOwil.moveTdEl.childNodes[0] ) ) {
        // aS += '4-';
        iOwil.moveTdEl.childNodes[0].style.height = "";
        hN = iOwil.moveTdEl.offsetHeight;
        // aS += '4-' + hN + " " + iOwil.moveTdEl.childNodes[0].innerHTML + " ";
        if ( hN > 0 ) { iOwil.moveTdEl.childNodes[0].style.height = hN + "px"; }
        }
      }
    }
  // alert( aS );
  };
function searchMatch( iPossibleB, iMatchSS, iS ) {
  var matchB = true;
  var j, aMatchS, escS;
  if ( iPossibleB === true ) {
    for ( j=0; aMatchS=iMatchSS[j++]; ) {
      if ( matchB === true ) {
        escS = aMatchS.replace(/([\[\]{}()*+?.\\^$|\-])/g,"\\$1");	
        var re = new RegExp("(^| )"+escS,"i" );
        var r = iS.search(re);            
        matchB = ( r > -1 );
        }
      }
    }
  return matchB;
  }
//
// build xno operations list for level
// - may be actual or potential
// - data/selection choice
// - includes operation entries ( eg new )
TOwil.prototype.bldOpsList = function bldOpsList( iOwig, iActiveB, iListEl, iPartListB ) {
  var iOwil = this;
  var aEl;
  if ( iOwig.Qtype === iOwig.EQtypeCno ) {
    aEl = iOwig.bldXniControl( iOwig.ECnoButs );
    iListEl.insertBefore( aEl, null );
    }
  else {
    var actualB = ( iOwig.Qtype === iOwig.EQtypeEno )
    && ( iOwil === iOwig.actOwil );
    if ( iOwil.atEndB === true ) {
      // new
      if ( actualB === true ) {
        if ( iOwig.EdKcipChk( iOwig.EKcipNewOnly ) === true ) {
          aEl = iOwig.bldXniControl( iOwig.EXnoNew );
          iListEl.insertBefore( aEl, null );
          }
        if ( iOwig.Kisu === iOwig.EKisuComplex ) {
          aEl = iOwig.bldXniControl( iOwig.EXnoPageReq );
          iListEl.insertBefore( aEl, null );
          }
        }
      else {
        if ( ( iOwig.EdKcipChk( iOwig.EKcipSecDisp ) === true ) 
        && ( iPartListB === true ) ) {
          aEl = iOwig.bldXniControl( iOwig.EXnoNew );
          iListEl.insertBefore( aEl, null );
          }
        }
      if ( iOwig.Qtype === iOwig.EQtypeUno ) {
        // unspec
        if (( iOwig.EdKcipChk( iOwig.EKcipManditory ) === false )
        || ( iOwig.selectCnt === 0 )
        ) { 
          aEl = iOwig.bldXniControl( iOwig.EUnoUnspec );
          iListEl.insertBefore( aEl, null );
          }
        }
      }
    }
  };
//
TOwig.prototype.getMakeDrop = function ( ) {
  var iOwig = this;
  var rootOwig;
  var divEl = window.document.getElementById( "idDivXnoDrop" );
  if ( divEl === null ) { 
    // divEl = iOwig.bldXnoContainer( iOwig.Qtype, true, false ); // drop=true; nest = false
    divEl = gAOkel[ KXnoDrop ].insert(iOwig.Owin.bodyAbsDiv);
    divEl.id = 'idDivXnoDrop';
    divEl.style.position = "absolute";
    iOwig.bldXnoShell( divEl, true ); // make xno drop=true
    // alert( "getMakeDrop" + divEl.innerHTML );
    EdXnoToOxnoRecurse( iOwig, divEl, null ); 
    // alert( divEl.innerHTML );
    }
  var left = iOwig.Owin.spGetOffsetLeft( iOwig.nod2, null );
  if ( left > ( iOwig.Owin.bodyAbsDiv.offsetWidth - 250 ) ) {
    left = ( iOwig.Owin.bodyAbsDiv.offsetWidth - 250 );   
    if ( left < 0 ) { left = 0; } 
    }
  divEl.style.left = left + "px";
  divEl.style.top = iOwig.Owin.spGetOffsetTop( iOwig.nod2, null ) 
  + iOwig.nod2.offsetHeight + "px";
  };
function withinPrior( iBigB, iSearchSS, iPrSearchSS ) {
  // is iSearchSS within iPrSearchSS, equal or longer
  var okB, inxP, inx, aS, bS, lowInx;
  var rB = true;  // within prior till evidence found
  if ( iBigB === true ) {
    if ( iPrSearchSS.length > 0 ) {
      rB = ( iSearchSS[0].toLowerCase() === iPrSearchSS[0].toLowerCase() );  
      }
    lowInx = 1;
    }
  else {
    lowInx = 0;
    }
  for ( inxP=lowInx; (aS=iPrSearchSS[inxP++]); ) {
    // must be longer or equal term in iSearchSS
    okB = false;
    for ( inx=lowInx; (bS=iSearchSS[inx++]); ) {
      if( bS.indexOf(aS)=== 0 ) { okB = true; }
      }
    if ( okB === false ) { rB = false; }
    }
  return rB;
  }
TOwig.prototype.getKSearch = function getKSearch( ) {
  var aOwig = this;
  var bigB = aOwig.EdKcipChk( aOwig.EKcipManyPot );
  var aKsearch;
  if ( bigB === true ) { aKsearch = KSearchByWord; }
  else { aKsearch = KSearchByPrefix; }
  if ( aOwig.searchS === "" ) { aKsearch = KSearchNotReqd; }
  else {
    var searchSS = aOwig.searchS.split(" ");
    var aOsrc = aOwig.includingOsrc( bigB, searchSS );
    if ( aOsrc !== null ) {
      aKsearch = KSearchNotReqd;
      }
    else {
      aOsrc = aOwig.excludingOsrc( bigB, searchSS );
      if ( aOsrc !== null ) {
        aKsearch = KSearchNotReqd;
        }
      }
    }
  return aKsearch;
  };
TOwig.prototype.includingOsrc = function includingOsrc( iBigB, iSS ) {
  var iOwig = this;
  var inx, aOsrc, prSearchSS;
  var rOsrc = null;
  for ( inx=0; (aOsrc=iOwig.Opog.AOsrc[inx++])&&(rOsrc===null); ) {
    if ( aOsrc.Kscli === EKscliSearch ) {
      if ( iSS.length === 0 ) { 
        rOsrc = aOsrc;
        } 
      else {
        prSearchSS = aOsrc.searchS.split(" ");
        if ( withinPrior( iBigB, iSS, prSearchSS ) === true ) {
          rOsrc = aOsrc;
          }
        }
      }
    }
  return rOsrc;
  };
TOwig.prototype.excludingOsrc = function excludingOsrc( iBigB, iSS ) {
  var iOwig = this;
  var inx, aOsrc, prSearchSS;
  var rOsrc = null;
  for ( inx=0; (aOsrc=iOwig.Opog.AOsrc[inx++])&&(rOsrc===null); ) {
    if ( aOsrc.Kscli === EKscliToMany ) {
      prSearchSS = aOsrc.searchS.split(" ");
      if ( withinPrior( iBigB, prSearchSS, iSS ) === true ) {
        rOsrc = aOsrc;
        }
      }
    }
  return rOsrc;
  };
//
// build xno data list for level
// - may be actual or potential
// - includes within list movement controls ( n to m of X )
// - includes select all/none buts
// - excludes operation entries ( eg new )
TOwil.prototype.bldDataList = function bldDataList( iListEl, iPartListB ) {
  var iOwil = this;
  var iOwig = iOwil.Owig;
  var aPossibleB = ( iOwil.potB === true ) || ( iOwig.Qtype === iOwig.EQtypeUno );
  var nxOwif = null;
  var matchB = false;
  var aEl = null;
  var firstEl = null;
  var trN = 0;
  var searchB = false;
  var fullN = 0; // within population NOT display
  var endN = gXnoStartN-1;
  var lastN = gXnoStartN+gXnoCnt;
  var matchSS = iOwig.searchS.split(" ");
  iOwig.moveTrEl = null;
  iOwig.matchCnt = 0;
  iOwig.uColm = 1; // colms reqd for imbeded Owigs, initial value
  var dS = " aPossibleB:" + aPossibleB 
  + " Qtype:" + iOwig.toQtypeS(iOwig.Qtype) 
  + " matchSS[0]:" + matchSS[0] + " matchSS[1]:" + matchSS[1];
  if ( aPossibleB === false ) {
    for ( iOwig.fiActOwif(); (nxOwif=iOwig.nxActOwif()); ) {
      dS += '+';
      if ( ( iOwig.Qtype === iOwig.EQtypeUno ) || ( nxOwif.aStD.nowSelectB === true ) ) {
        fullN++;
        endN++;
        trN++;
        aEl = nxOwif.bldXniData( aPossibleB );
        if ( firstEl === null ) { firstEl = aEl; }
        iListEl.insertBefore( aEl, null );
        }
      }
    }
  else {
    dS += '?pogLength:' + iOwig.Opog.AOwif.length + " actAOwif.length:" + iOwig.actAOwif.length;
    var incActualB = true; // true for conDrop ??? iOwig.EdKcipChk( iOwig.EKcipNonInstHdr ) === false ;
    for ( iOwig.fiOrdOwif(incActualB,(iOwig.searchS !== "")); (nxOwif=iOwig.nxOrdOwif()); ) {
      dS += '*';
      // dS += " carry:" + nxOwif.aStD.carryB;
      if ( nxOwif.aStD.carryB === false ) {
        dS += '!' + nxOwif.curTextS;
        nxOwif.nowState();
        matchB = searchMatch( aPossibleB, matchSS, nxOwif.curTextS );
        // dS += " matchB:" + matchB;
        if ( matchB === true ) {
          dS += '^';
          // dS += " " + nxOwif.aStD.nowSelectB + ":" + aPossibleB;
          if ( ( iOwig.Qtype !== iOwig.EQtypeEno ) || ( nxOwif.aStD.nowSelectB === false ) ) {
            dS += '%';
            fullN++;
            if ( ( iPartListB === false )
            || ( ( !(fullN < gXnoStartN) )&&( fullN < lastN ) )
            ) {
              endN++;
              trN++;
              aEl = nxOwif.bldXniData( aPossibleB );
              dS += '@' + aEl.innerHTML;
              if ( firstEl === null ) { firstEl = aEl; }
              iListEl.insertBefore( aEl, null );
              }
            }
          }
        }
      }
    }
  if ( gThisCaseB === true ) { alert( dS ); }
  if ( trN > 0 ) {
    iOwil.moveTdEl = gAOkel[KTdEnoMove].insert( firstEl );
    iOwil.moveTdEl.rowSpan = trN;
    // 9999
    if ( iOwig.Qtype === iOwig.EQtypeEno ) {
      var tdEl = gAOkel[KTableData].insert(firstEl);
      tdEl.rowSpan = trN;
      if ( iOwil.potB === false ) { tdEl.className = "zTdEnoActions"; }
      else { tdEl.className = "zTdEnoFromPos"; }
      }
    }
  // "move within population" control  
  if ( iPartListB === true ) {
    if (( gXnoStartN > 1 )||( endN != fullN )) {
      iOwig.startN = gXnoStartN;
      iOwig.endN = endN;
      iOwig.fullN = fullN;
      iOwig.moveTrEl = iOwig.bldXniControl( iOwig.EUnoMove );
      iListEl.insertBefore( iOwig.moveTrEl, firstEl );
      }
    }
  if (( iOwig.Qtype !== iOwig.EQtypeUno )&&(( endN - gXnoStartN ) > 1 )) {
    if ( iOwig.EdKcipChk( iOwig.EKcipAllNone ) === true ) {
      if ( aPossibleB === true ) { aEl = iOwig.bldXniControl( iOwig.EUnoPosAllNone ); }
      else { aEl = iOwig.bldXniControl( iOwig.EEnoActAllNone ); }
      iListEl.insertBefore( aEl, null );
      }
    }
  if (( iOwig.Qtype === iOwig.EQtypeCno )
  &&( iOwig.Kisu === iOwig.EKisuSKvli )) {
    iOwig.cnoOperate( KCnoSet );
    }
  iOwil.atEndB = ( endN == fullN );
  // if ( gThisCaseB === true ) { alert( 'bldDataList-99 iActiveB:' + iActiveB ); }
  };
//
// build/rebuild level of xno list, and associated buttons,adviceText.
TOwil.prototype.bldXnoList = function bldXnoList( ) {
  var iOwil = this;
  var iOwig = iOwil.Owig;
  var listEl = iOwil.selEl;
  var aEl;
  if ( listEl ) {
    defaultStatus += 'D';
    purge( listEl );
    while ( (aEl=listEl.childNodes[0]) ) {
      listEl.removeChild( aEl ); 
      }
    // EdLog( " iOwil.potB:" + iOwil.potB + " " + KXnoStS( iKXnoSt )
    // + " iOwig.searchS:" + iOwig.searchS );
    var aPossibleB = ( iOwil.potB === true ) || ( iOwig.Qtype === iOwig.EQtypeUno );
    if ( ( aPossibleB === true )&&( iOwig.wigKXnoSt !== KXnoStOpen ) ) {
      /*jsl:pass*/
      // defaultStatus += 'E';
      }
    else if ( ( iOwig.Qtype !== iOwig.EQtypeUno ) 
    && ( iOwig.wigKXnoSt === KXnoStMinimized )
    && ( iOwig.EdKcipChk( iOwig.EKcipCollapse ) === true )) { 
      /*jsl:pass*/
      }
    else {
      // build pick list
      // show full list of eno actuals
      // EdLog( "bldXnoList-50 iOwil.potB:" + iOwil.potB + " " + KXnoStS( iKXnoSt )
      // + " aOwig.searchS:" + iOwig.searchS );
      defaultStatus += 'C1';
      iOwil.bldDataList( listEl, aPossibleB );
      iOwil.bldOpsList( iOwig, iOwig.wigKXnoSt !== KXnoStMinimized, listEl, aPossibleB );
      defaultStatus += 'C2';
      // alert( listEl.outerHTML );
      }
    defaultStatus += '+';
    }
  };
//
// use pot list to display pending message
TOwig.prototype.msgOnlyList = function ( iWaitS ) {
  var iOwig = this;
  var listEl = iOwig.potOwil.selEl;
  var aEl;
  if ( listEl ) {
    purge( listEl );
    while ( (aEl=listEl.childNodes[0]) ) {
      listEl.removeChild( aEl ); 
      }
    aEl = iOwig.bldXniControl( iOwig.EUnoWait, iWaitS );
    listEl.insertBefore( aEl, null );
    }
  };
TOwig.prototype.bldUnoActualButs = function bldUnoActualButs() {
  var iOwig = this;
  var aEl, bEl, selEl, nxOwif;
  // get selection count
  // EdLog( "Start" );
  var actOwil = iOwig.potOwil;
  actOwil.getSelected( false );
  // remove current buttons, text 
  var paEl = iOwig.headDivEl;
  // EdLog( "paEl" + paEl.outerHTML );
  if ( paEl !== null ) {
    while ( (aEl=paEl.childNodes[1]) ) { // assume input text is first
      // EdLog( "remove " + aEl.tagName );
      paEl.removeChild( aEl );
      }
    if ( iOwig.uniqNowOwif !== null ) {
      // EdLog( "iOxno.inxOwif:" + iOxno.inxOwif 
      // + " iOwig.uniqNowOwif.Opid.hojS:" + iOwig.uniqNowOwif.Opid.hojS );
      if (( iOwig.uniqNowOwif.Opid.hojS !== "" ) 
      ) { 
        if (( iOwig.EdKcipChk( iOwig.EKcipMemberShow ) === true )
        || ( iOwig.Kisu === iOwig.EKisuSubjInst ) ) {
          if (( iOwig.Kisu === iOwig.EKisuSubjInst )
          && ( iOwig.uniqNowOwif.Opid.hojS == iOwig.Owin.ownOlnk.HojS )) {
            /*jsl:pass*/ // on current instance  
            }
          else {
            gAOkel[ KUnoShow ].insert(paEl);
            }
          }
        //
        if ( iOwig.EdKcipChk( iOwig.EKcipMemberEdit ) === true ) {
          iOwig.xnoEditButEl = gAOkel[ KUnoEdit ].insert(paEl);
          }
        //
        if ( iOwig.EdKcipChk( iOwig.EKcipMemberClone ) === true ) {
          iOwig.xnoCloneButEl = gAOkel[ KUnoClone ].insert(paEl);
          }
        if ( iOwig.EdKcipChk( iOwig.EKcipMemberRemove ) === true ) {
          iOwig.xnoRemoveButEl = gAOkel[ KUnoRemove ].insert(paEl);
          }
        }
      }
    if ( iOwig.EdKcipChk( iOwig.EKcipMemberNew ) === true ) {
      iOwig.xnoNewButEl = gAOkel[ KXnoNew ].insert(paEl);
      }
    }
  };
TOwil.prototype.addButs = function( iOwig ) {
  var aOwil = this;
  var aEl;
  if ( aOwil.moveTdEl ) {
    while ( (aEl=aOwil.moveTdEl.childNodes[0]) ) {
      aOwil.moveTdEl.removeChild( aEl );
      }
    if ( aOwil.selCnt > 0 ) {
      if ( aOwil.potB === true ) {
        gAOkel[ KToAct ].insert( aOwil.moveTdEl );
        }
      else if ( ( iOwig.EdKcipChk( iOwig.EKcipNoDel ) === false ) 
      //&& ( iOwig.EdKcipChk( iOwig.EKcipNewOnly ) === false ) 
      ){
        gAOkel[ KToPoss ].insert( aOwil.moveTdEl );
        }
      }
    }
  };
TOwig.prototype.bldEnoButs = function bldEnoButs() {
  // var iOxno = this;
  var iOwig = this;
  var aEl, bEl, selEl, nxOwif;
  // get selection count
  iOwig.actOwil.getSelected( false );
  iOwig.potOwil.getSelected( false );
  // remove current move and action buttons 
  if ( iOwig.enoActionsTdEl ) {
    while ( (aEl=iOwig.enoActionsTdEl.childNodes[0]) ) {
      iOwig.enoActionsTdEl.removeChild( aEl );
      }
    }
  // add move buttons
  iOwig.actOwil.addButs( iOwig );
  iOwig.potOwil.addButs( iOwig );
  // add possible action buttons
  if ( iOwig.actOwil.selCnt === 1 ) { // + iOxno.potOwil.selCnt 
    if ( iOwig.EdKcipChk( iOwig.EKcipMemberShow ) === true ) {
      gAOkel[ KEnoShow ].insert( iOwig.enoActionsTdEl );
      }
    if ( iOwig.EdKcipChk( iOwig.EKcipMemberEdit ) === true ) {
      gAOkel[ KEnoEdit ].insert( iOwig.enoActionsTdEl );
      }
    if ( iOwig.EdKcipChk( iOwig.EKcipMemberClone ) === true ) {
      gAOkel[ KEnoClone ].insert( iOwig.enoActionsTdEl );
      }
    if ( iOwig.EdKcipChk( iOwig.EKcipMemberRemove ) === true ) {
      gAOkel[ KEnoRemove ].insert( iOwig.enoActionsTdEl );
      }
    }
  if ( iOwig.EdKcipChk( iOwig.EKcipMemberNew ) === true ) {
    gAOkel[ KXnoNew ].insert( iOwig.enoActionsTdEl );
    }
  };
//
// click on one of displayed instances or buttons/prompt
TOwig.prototype.updateTypeCount = function( ) {
  var aOwig = this;
  var aUrlS = document.location.href;
  var aOlnk = new TOlnk( aUrlS );
  aOlnk.httmUpdateB = false;
  aOlnk.Ohttms = decodeHttmAll( aOlnk.typeS );
  aOwig.Owin.ctmToOlnk( aOlnk );
  if ( aOlnk.httmUpdateB === true ) {
    // alert( 'pre aOlnk.typeS:' + aOlnk.typeS );
    aOlnk.typeS = encodeHttmAll( aOlnk.typeS, aOlnk.Ohttms );
    var fullUrlS = aOlnk.toStr( true );
    // alert( 'do qop=nsa' + fullUrlS );
    gOjax.nsaWigId = null;
    if ( aOwig.selfIdEl === aOwig.rootIdEl ) {
      gOjax.nsaWigId = aOwig.selfIdEl.id;
      }
    gOjax.wigSelfIdN = aOwig.selfIdN;
    gOjax.cnnAllocN = aOwig.cnnAllocN;
    gOjax.asDoQs( "?op=nsa", fullUrlS
    , "&xx=1" + "&schULoop=10000" + "&schUMatch=10000" + "&schCount=1");
    }
  };
//
// click on one of displayed instances or buttons/prompt
TOwig.prototype.evtClickXni = function evtClickXni( iKefv, iTargEl, iOwif, iEXno ) {
  var aOwig = this;
  var aOwif = iOwif;
  var doneB = false;
  defaultStatus += 'x81';
  var j,nxOwil,aUrl,aOlnk,bUrlS,aS;
  // 
  if (( aOwig.imedKisu() === true )&&( aOwig.Qtype === aOwig.EQtypeUno )) {
    defaultStatus += 'x82';
    // instance for actioniong NOT selection
    // do not update control in this case
    if ( aOwig.Kisu === aOwig.EKisuView ) {
      aUrl = document.location.href;
      aOlnk = new TOlnk( aUrl );
      bUrlS = aUrl.substr( 0, aOlnk.opPosn+1 ) + aOwif.Opid.hojS  
      + aUrl.substr( aOlnk.qualPosn, aUrl.length-aOlnk.qualPosn );
      toPageExt( bUrlS, false );
      doneB = true;
      }
    else if ( aOwig.Kisu === aOwig.EKisuSKvli ) {
      aOwig.SKvliOperate( parseInt( aOwif.Opid.hojS, 10 ) );
      doneB = true;
      }
    else if ( aOwig.Kisu === aOwig.EKisuOther ) {
      alert( "click KisuOther" );
      }
    else if ( aOwig.Kisu === aOwig.EKisuLinks ) {
      if ( iKefv != aOwig.KefvNone ) {
        toPageExt( aOwif.Opid.hojS, false );
        doneB = true;
        }
      else {
        // alert( "click KisuLinks - same page" );
        /*jsl:pass*/
        }
      }
    }
  defaultStatus += 'x83';
  // alert( "evtClickXni - A iOwif:" + iOwif );
  if ( doneB === false ) {
    // Selection instance or button/prompt.
    if ( iEXno == aOwig.EXnoCollapse ) { // click on search
      // alert( "EXnoCollapse" );
      aOwig.toKXnoSt( KXnoStOpen );
      }
    else if ( iEXno == aOwig.EXnoNew ) { // click on new
      if ( aOwig.textEl ) {
        aOwig.textEl.className = "zEdUText" + aOwig.EKefvTest;
        }
      if ( aOwig.Qtype === aOwig.EQtypeUno ) {
        aOwig.bldUnoActualButs();
        }
      else {
        aOwig.bldEnoButs();
        }
      // var wifIdS = aOwig.wifId( null, false );
      // aOwig.Owin.startCheck( '', aOwig.newUrlS, aOpid, '' );
      var aOreq = new TOreq( aOwig.Owin );
      aOreq.Kreq = gKreqNew;
      aOreq.urlS = aOwig.newUrlS;
      aOreq.efS = '';
      aOreq.Opid = new TOpid();
      aOreq.Opid.init( aOwig.groupN, aOwig.EXnoDataNew, '', '', 0, 0, 0 );
      aOreq.Kpt = gKptNewWindow;
      aOreq.issue();
      }
    else if ( iEXno == aOwig.EUnoUnspec ) { // unspec prompt
      if ( aOwig.EdKcipChk( aOwig.EKcipManditory ) === false ) { 
        aOwig.textEl.className = "zEdUText4"; 
        }
      else { aOwig.textEl.className = "zEdUText5"; }
        aOwig.uniqChangeSelected( null );
        aOwig.summary();
      aOwig.textEl.value = aOwig.promptText( );
      // alert( 'unspec' );
      aOwig.bldUnoActualButs();
      }
    else if ( iOwif !== null ) { // click on choice
      if ( aOwig.Qtype === aOwig.EQtypeUno ) {
        aOwig.uniqChangeSelected( iOwif );
        aOwig.summary();
        }
      if ( aOwig.Qtype === aOwig.EQtypeUno ) {
        aOwig.textEl.value = aOwif.curTextS;
        var aKefv = iKefv; // bomb(); alert( "iKefv:" + iKefv );
        if ( aKefv == 4 ) { aKefv = aOwig.EKefvTest; }
        aOwig.textEl.className = "zEdUText" + aKefv;
        aOwig.bldUnoActualButs();
        }
      else {
        aOwig.getSwapSel( iTargEl, true, true ); // swap state unconditionaly
        aOwig.bldEnoButs();
        aOwig.sideEffect( aOwig.actOwil );
        aOwig.sideEffect( aOwig.potOwil );
        gBlurUnoEl = null;
        }
      }
    gBlurUnoEl = null;
    if ( aOwig.Qtype === aOwig.EQtypeUno ) {
      aOwig.toKXnoSt( KXnoStMinimized );
      if ( aOwig.Kisu === aOwig.EKisuNone ) {
        aOwig.Owin.pageButsPerState( );
        }
      if (( aOwig.Kisu === aOwig.EKisuHttmRoleInst ) 
      || ( aOwig.Kisu === aOwig.EKisuHttmTypeNull )) {
        var rootOwig = getCurOwig( aOwig.Owin, null );
        if ( rootOwig.EdKcipChk( rootOwig.EKcipTypeCount ) === true ) {
          aOwig.updateTypeCount( );
          }
        }
      }
    }
  };
function searchUrl( iS ) {
  var aUrl = document.location.href;
  var aOlnk = new TOlnk( aUrl );
  var templateS = gSearchTemplateS;
  var fPosn = templateS.indexOf( '|', 1 );
  var preS = templateS.substr( 0, fPosn );
  var postS = templateS.substr( fPosn+1, templateS.length );
  var replaceS = preS + iS.nsToOjText() + postS;
  var inx1 = aOlnk.typeS.indexOf( preS );
  var inx2 = -1;
  if ( inx1 > -1 ) { inx2 = aOlnk.typeS.indexOf( postS ); }
  if ( inx2 > -1 ) { 
    aOlnk.typeS = aOlnk.typeS.slice( 0, inx1 ) + replaceS 
    + aOlnk.typeS.slice( inx2 + postS.length );
  } else {
    aOlnk.typeS += replaceS;
  }
  //
  var bUrlS = aOlnk.toStr( true );
  return bUrlS;
  }
TOwig.prototype.getSwapSel = function getSwapSel( iEl, iSwapB, iUnCondB ) {
  var iOwig = this;
  var inx = iEl.className.indexOf( "zXnoSelected" );
  var selB = ( inx != -1 );
//  alert( "getSwapSel inx:" + inx + " swapB:" + iSwapB 
//  + " iUnCondB:" + iUnCondB + " iEl.className:" + iEl.className );
  if ( ( iSwapB === true )
  &&(( iUnCondB === true )||( selB === true ))
  ){
    if ( selB === true ) { iEl.className = iEl.className.substr( 0, inx ); }
    else { iEl.className += " zXnoSelected"; }
    }
  return selB;
  };
TOwig.prototype.getOpid = function getOpid( iEl ) {
  // var iOxno = this;
  var iOwig = this;
  var SS;
  var aHojS;
  var aOpid = new TOpid();
  if ( ( iEl.tagName == "TD" )
  && ( iEl.className.indexOf( "zEdPre" ) != -1 ) ) {
    var subEl,j;
    for ( j=0; subEl=iEl.childNodes[j++]; ) {
      if ( ( subEl.tagName == "INPUT" )
      && ( subEl.type == "hidden" ) ) { aOpid.decode( subEl.value ); }
      }
    }
  else { 
    alert( "getOpid iEl.tagName:" + iEl.tagName
    + " iEl.className:" + iEl.className );
    }
  return aOpid;
  };
TOwig.prototype.getElOwif = function getElOwif( iEl ) {
  var iOwig = this;
  iOwig.elOwif = null;
  var SS;
  var aHojS;
  var aOwfid = new Object();
  if ( ( iEl.tagName == "TD" )
  && ( iEl.className.indexOf( "zEdPre" ) != -1 ) ) {
    var subEl,j;
    for ( j=0; subEl=iEl.childNodes[j++]; ) {
      // alert( "subEl.tagName:" + subEl.tagName );
      if ( ( subEl.tagName == "INPUT" )
      && ( subEl.type == "hidden" )
      ) {
        var aOpid = new TOpid();
        aOpid.decode( subEl.value );
        iOwig.elOwif = iOwig.getInstOwif( aOpid, true );
        }
      }
    }
  else { 
    alert( "getElOwif iEl.tagName:" + iEl.tagName
    + " iEl.className:" + iEl.className );
    }
  return iOwig.elOwif;
  };
TOwig.prototype.setClearAll = function setClearAll( iOwil, iSetB ) {
  var iOwig = this;
  var i, inx, nxEl, trEl;
  for ( i=0; trEl=iOwil.selEl.childNodes[i++]; ) {
    nxEl = trEl.childNodes[0]; // tr -> td
    if ( nxEl.className.indexOf("zEdPre") === 0 ) {
      inx = nxEl.className.indexOf( "zXnoSelected" );
      if ( ( inx != -1 ) !== iSetB ) { 
        iOwig.getSwapSel( nxEl, true, true );
        }
      }
    }
  iOwig.bldEnoButs();
  if ( iOwig.Qtype === iOwig.EQtypeEno ) { iOwig.sideEffect( iOwil ); }
  gBlurUnoEl = null;
  };
TOwig.prototype.evtUnoMove = function evtUnoMove( iEv, iKel, iStartN, iEndN ) {
  var iOwig = this;
  var n = iStartN;
  if ( iKel === KUnoMove1 ) { n = 1; } // first
  else if ( iKel === KUnoMove2 ) {  // prior
    n = n - gXnoCnt;
    if ( n < 1 ) { n = 1; }
    }
  else if ( iKel === KUnoMove3 ) { // next
    n = n + gXnoCnt;
    }
  else if ( iKel === KUnoMove4 ) { // last
    n = iEndN - gXnoCnt + 1;
    }
  gXnoStartN = n;
  iOwig.searchS = iOwig.realSearchS( iOwig.textEl );
  iOwig.bldRequired( 4 ); 
  };
//
// Browse/Edit/Clone to selected Eno entry (actual or pot) 
// Eno only, NOT Uno
TOwig.prototype.evtEnoButShow = function evtEnoButShow( iEv ) {
  var aOwig = this;
  var aEv = iEv;
  aOwig.actOwil.getSelected( false );
  aOwig.potOwil.getSelected( false );
  // count selected
  var aOwif = null;
  var selCnt = 0;
  if ( aOwig.potOwil.selOwif !== null ) { 
    aOwif = aOwig.potOwil.selOwif; 
    selCnt++;
    }
  if ( aOwig.actOwil.selOwif !== null ) { 
    aOwif = aOwig.actOwil.selOwif; 
    selCnt++;
    }
  if ( selCnt === 0 ) { alert( "None selected." ); }
  else if ( selCnt !== 1 ) { 
    alert( "More than one selected" );
    aOwif = null;
    }
  return aOwif;
  };
TOwig.prototype.evtEnoMoveSelection = function evtEnoMoveSelection( iEl, iEv, iAddB ) {
  var aOwig = this;
  var fromSelEl, toSelEl;
  var fromOwil, toOwil;
  var aEv = iEv;
  if ( iAddB === true ) {
    fromOwil = aOwig.potOwil;
    toOwil = aOwig.actOwil;
    }
  else {
    toOwil = aOwig.potOwil;
    fromOwil = aOwig.actOwil;
    }
  fromSelEl = fromOwil.selEl;
  toSelEl = toOwil.selEl;
  var trEl,nxEl,aOwif = null;
/*
  var aS = "";
  for ( aOwig.fiOwif(); aOwif=aOwig.nxOwif(); ) {
    aS += " " + aOwif.curTextS + ":" + aOwif.aStD.nowSelectB;
    }
  EdLog( aS );
  aS = "";
*/
  var i=0;
  for ( i=0; trEl=fromSelEl.childNodes[i++]; ) {
    nxEl = trEl.childNodes[0]; // tr -> td
    if ( aOwig.getSwapSel( nxEl, true, false ) === true ) {
      aOwif = aOwig.getElOwif( nxEl );
      aOwif.aStD.nowSelectB = iAddB;
      }
    }
  aOwig.saveAll();
  gXnoStartN = 1;
  aOwig.bldRequired( 5 ); 
  // alert( 'post closed' );
  aOwig.Owin.pageButsPerState( );
  };
/* ************************************* */
function TOjax() {
  var aOjax = this;
  aOjax.Owin = new TOwin( null, null );
  aOjax.xh = null;
  var hasActiveX=false; 
  try{ 
    if ((window.ActiveXObject)&&( ! window.XMLHttpRequest)) { 
      hasActiveX = true;
      } 
    } 
  catch(oError) { } 
//  if (navigator.appName == "Microsoft Internet Explorer") {
  if ( hasActiveX === true ) {
    aOjax.xh = new ActiveXObject("Microsoft.XMLHTTP");
    }
  else { 
    try{ 
      if ( XMLHttpRequest ) { 
        aOjax.xh = new XMLHttpRequest();
        if ( aOjax.xh.overrideMimeType ) {
          aOjax.xh.overrideMimeType('text/xml');
          // See note below about this line(????????????)
          }
        }
      } 
    catch(oError) { } 
    }
  }
TOjax.prototype.asDoQs = function( iOps, iAltUrlS, iDataS ) {
  var aOjax = this;
  if ( iOps !== '' ) {
    var locnS = document.location.href;
    var inxId = locnS.indexOf( '?' );
    if ( inxId > 0 ) {
      locnS = locnS.substr( 0, inxId );
      }
    inxId = locnS.lastIndexOf( '/' );
    if ( inxId < ( locnS.length-1 ) ) { // not last char
      inxId = locnS.lastIndexOf( '.', inxId );
      if ( inxId == -1 ) { 
        locnS += '/'; 
        }
      }
    var toS = '';
    if ( iAltUrlS === '' ) { toS = locnS + iOps; }
    else { toS = iAltUrlS + iOps; }
    if ( aOjax.xh !== null ) {
      aOjax.makeReq( toS, iDataS, aOjax.qopDone );
      }
    else {
      if ( iDataS ) { toS += iDataS; }
      try { 
        var date = new Date();
        var aUrl = toS + '&ti=' + date.getTime();
        frames["exchange"].location.replace( aUrl );
        }
      catch(e){
        alert( 'Failed to send request, url length ' + toS.length 
        + ' probably exceeds browsers capacity'  );
        }
      // exchangeReq( toS );
      }
    // alert( 'asDoQs iOps:' + iOps + ' iAltUrlS:' + iAltUrlS );
    }
  };
TOjax.prototype.makeReq = function( iUrlS, iDataS, iReplyHandle ) {
  var aOjax = this;
  if ( iDataS === '' ) {
    aOjax.xh.open( 'get', iUrlS );
    }
  else {
    // gOjax.xh.abort();
    aOjax.xh.open( 'post', iUrlS );
    aOjax.xh.setRequestHeader( 'Content-Type'
    , 'application/x-www-form-urlencoded' );
    aOjax.xh.setRequestHeader( 'qop', '1' );
    // alert( 'makeReq2' );
    }
  aOjax.xh.onreadystatechange = hitch( aOjax, iReplyHandle );
  if ( iDataS === '' ) { aOjax.xh.send(null); }
  else { aOjax.xh.send( iDataS ); }
  };
// gOjax reply
TOjax.prototype.qopDone = function() {
  var aOjax = this;
  var aS;
//  alert( 'qopDone' + aOjax.xh.readyState + ' ' + aOjax.xh.readyState )
  if ( aOjax.xh.readyState == 4 ){ 
    var response = aOjax.xh.responseText;
//    alert( response );
//    alert( typeof aOjax.xh.responseXml === 'undefined' );
//    alert( 'content type ' + aOjax.xh.getResponseHeader("Content-Type") );
    if ( aOjax.xh.status != 200 ) {
      // BAD server state
      if ( aOjax.xh.status === 12029 ) {
        alert( 'Server not running' );
        }
      else {
        alert( aOjax.xh.responseText + ' Status:' + aOjax.xh.status );
        }
      } 
    else {
      if ( typeof aOjax.xh.responseXml  === 'undefined' ) {
        // for mozzila, should not be required, Content-Type text/xml
        if ( typeof DOMParser != 'undefined' ) {
          var parser = new DOMParser();
          var doc = parser.parseFromString( aOjax.xh.responseText, "text/xml" );
          aOjax.XMLDoc = doc.documentElement;
          }
        else {
          var xmlDocument = new ActiveXObject("Microsoft.XMLDOM");
          xmlDocument.loadXML(aOjax.xh.responseText);
          aOjax.XMLDoc = xmlDocument;
          }
        }
      else {
        //    defaultStatus = response;
        if ( ( aOjax.xh.responseXml )
        && ( aOjax.xh.responseXml.documentElement === null ) 
        && ( aOjax.xh.responseStream) ) {
          aOjax.xh.responseXml.load( aOjax.xh.responseStream );
          }
        aOjax.XMLDoc = aOjax.xh.responseXml.documentElement;
        }
      if ( ! aOjax.XMLDoc ) {
        alert( "Server response ill-formed:" + response );
        }
      var qopS = aOjax.xmlElVal( 'qop' );
      if ( qopS == 'nsa' ) { // pop list
        // alert( "response:" + response );
        var bS = aOjax.xmlElVal( 'param' );
        // alert( "aOjax.xmlElVal( 'param' )" + bS );
        var cnnAllocN = aOjax.cnnAllocN;
        qopNsaReply( aOjax, bS, cnnAllocN );
        }
      else if ( qopS == 'cmt' ) { // commit
        aOjax.updateReply();
        }
      else if ( qopS == 'lon' ) { // log on (off)
        aOjax.logUpReply( window, false ); 
        }
//      else if ( qopS == 'nin' ) { // navigation instance
//        alert( 'have nin reply' );
//        }
      else if (( qopS == 'del' )||( qopS == 'dir' )) { // upManage
//        alert( response );
        aOjax.qopReply( window, qopS );
        }
      else if ( qopS == 'reg' ) { // register url fragment reply ?
        var kpt = parseInt( aOjax.xmlElVal( 'kpt' ), 10 );
        var Kreq = parseInt( aOjax.xmlElVal( 'kreq' ), 10 );
        var argS = '?op=';
        if ( Kreq === gKreqShow ){ argS += "show"; }
        else { argS += "chk"; }
        // + aOjax.xmlElVal( 'reqOp' ) 
        argS += '&se=' + gSesNoloi 
        + '&iqb=' + aOjax.xmlElVal( 'data' ) 
        + '&kr=' + aOjax.xmlElVal( 'kreq' ) 
        + '&qbv=' + aOjax.xmlElVal( 'qbv' ); 
        // alert( response );
        toPageKpt( aOjax.xmlElVal( 'reqUrl' ) + argS, kpt, '&par=' + aOjax.xmlElVal( 'par' ) );
        }
      }
    }
  };
function toPageKpt( iUrlS, iKpt, iParArgS ) {
  // alert( "toPageKpt iUrlS:" + iUrlS + " iKpt:" + iKpt + " iParArgS:" + iParArgS );
  if ( iKpt === gKptNewWindow ) { 
    // aS = aOjax.xmlElVal( 'reqUrl' ) + argS + '&par=' + aOjax.xmlElVal( 'par' ); 
    gModWin = asModalWin( iUrlS + iParArgS );
    }
  else if ( iKpt === gKptReplace ) {
    document.location.replace( iUrlS );
    }
  else if ( iKpt === gKptNext ) {
    document.location = iUrlS;
    }
  }
function savePog( bOpog, epHideEl ) {
  var aS,cS,bOwif;
  var bS = yyStr( bOpog.encodePogHdr());
  var inx,l;
  for ( inx=0,l=bOpog.AOwif.length; inx<l; inx++ ) {
    bOwif = bOpog.AOwif[inx];
    aS = bOwif.encodeInst();
    cS = aS; // '(' + aS + ')';
    bS += yyStr( cS ); 
    }
  // alert("savePog " + bS );
  epHideEl.value = yyStr( bS );
  }
function nthWigS( iHideEl, iN ) {
  var aOwig = this;
  var nN, nS, aS = '';
  var bS = iHideEl.value;
  var wigsSS = fsSplit( bS );
  if ( wigsSS[iN] ) { aS = wigsSS[iN]; }
  else { bomb(); }
  return aS;
  }
function wigSbyId( iHideS, iIdN ) {
  var aOwig = this;
  var nN, nS, hdrS, aS = '';
  var wigsSS = fsSplit( iHideS );
  var l = wigsSS.length;
  for ( var i=0; i<l; i++) {
    hdrS = fsSplit( wigsSS[i] )[0];
    nS = hdrS.substring( 0, hdrS.indexOf( 'W' ) );
    nN = parseInt( nS, 10 );
    if ( isNaN( nN ) ) { bomb(); }
    if ( iIdN === nN ) {
      aS = wigsSS[i];
      }
    }
  return aS;
  }
function mergePots( iOjax, iS, iOwin, iCnnAllocN, loopLimitB, matchLimitB  ) {
  var searchS = iOjax.xmlElVal( 'schText' );
  var aOsrc;
  var epHideEl = document.getElementById( 'idEp' + iCnnAllocN );
  if ( ! epHideEl ) {
    epHideEl = document.getElementById( 'idNp' + iCnnAllocN );
    }
  var bOpog = new TOpog();
  //
  bOpog.popDecode( iOwin, null, nthWigS( epHideEl, 0 ), false, iCnnAllocN );
  // alert( 'loopLimitB:' + loopLimitB + ' matchLimitB:' + matchLimitB );
  // EdLog( iS );
  if ( ( loopLimitB || matchLimitB ) === false ) {
    // aOpog - new from reply, bOpog = current
    var aOpog = new TOpog();
    aOpog.popDecode( iOwin, null, iS, false, iCnnAllocN );
    // merge new + current into current. ( use current if duplicate )
    var inx,l,aOwif,aOprf,j,matchOprf,selfJ;
    for ( inx=0,l=aOpog.AOwif.length; inx<l; inx++ ) {
      aOwif = aOpog.AOwif[inx];
      // aOwif.Oein.AOprf[ aOwif.Oein.AOprf.length ] = aOPrf;
      matchOprf = null;
      selfJ = -1;
      for ( j=0; (aOprf=aOwif.Oein.AOprf[j++]); ) {
        if ( aOprf.cnnAllocN === iCnnAllocN ) {
          if ( aOprf.Owif !== aOwif ) { matchOprf = aOprf; } // in other list
          else { selfJ = j-1; }
          }
        }
      if ( matchOprf !== null ) {
        aOwif.Oein.AOprf.splice( selfJ, 1 );
        // remove self entry
        }
      else {
        // add entry to current list 
        aOwif.Oein.AOprf[selfJ].IAOwif = bOpog.AOwif.length;
        bOpog.AOwif[ bOpog.AOwif.length ] = aOwif;
        }
      }
    // add new OSrc to current list
    for ( inx=0; (aOsrc=aOpog.AOsrc[inx++]); ) {
      bOpog.AOsrc[bOpog.AOsrc.length] = aOsrc;
      }
    }
  else {
    aOsrc = new TOsrc( );
    aOsrc.Kscli = EKscliToMany;
    aOsrc.searchS = searchS;
    var OsrcInx = bOpog.AOsrc.length;
    var bOsrc;
    for ( inx=0; (bOsrc=bOpog.AOsrc[inx++]); ) {
      if ( bOsrc.searchS === aOsrc.searchS ) { OsrcInx = inx-1; }
      }
    bOpog.AOsrc[OsrcInx] = aOsrc;
    // save it
    }
  savePog( bOpog, epHideEl );
}
function setInnerText( iEl, iS ) {
  if ( iEl.innerText != undefined ) { iEl.innerText = iS; }
  else { iEl.textContent = iS; }
  }
function getInnerText( iEl ) {
  if ( iEl.innerText != undefined ) { return iEl.innerText; }
  else { return iEl.textContent; }
  }
function qopNsaReply( iOjax, iS, iCnnAllocN ) {
  var aOwin = new TOwin( null, null );
  var loopLimitB = ( iOjax.xmlElVal( 'loopLimitB' ) !== '0' );
  var matchLimitB = ( iOjax.xmlElVal( 'matchLimitB' ) !== '0' );
  if ( iOjax.xmlElVal( 'schCount' ) !== '0' ) {
    var aOwig = getCurOwig( aOwin, null );
    aOwig.capture( true, KXnoStOpen );
    // alert( 'qopNsaReply-5 resCount:' + iOjax.xmlElVal( 'schResCount' ) 
    // + ' xnoTypeCountEl:' + aOwig.xnoTypeCountEl );
    gSubjInstCount = parseInt( iOjax.xmlElVal( 'schResCount' ), 10 );
    if ( aOwig.xnoTypeCountEl ) {
      setInnerText( aOwig.xnoTypeCountEl, " " + gSubjInstCount + " Found" );
      }
    else {
      alert( 'qopNsaReply-7 resCount:' + iOjax.xmlElVal( 'schResCount' ) 
      + ' xnoTypeCountEl:' + aOwig.xnoTypeCountEl );
      }
    }
  else {
    mergePots( iOjax, iS, aOwin, iCnnAllocN, loopLimitB, matchLimitB  );
    var aOwig = getCurOwig( aOwin, null );
    aOwig.capture( true, KXnoStOpen );
    // update display
    if ( ( loopLimitB || matchLimitB ) === true ) {
      // record failure
      // add new OSrc to current list
      if ( aOwig.needDrop() === true ) {
        aOwig.getMakeDrop();
        }
      // re search check
      if (( gNsaReSearchS !== "" ) && ( gNsaReSearchS !== gNsaSearchS ) ) {
        aOwig.msgOnlyList( 'Search Again for:' + gNsaReSearchS );
        gNsaSearchS = "";
        gNsaReSearchS = "";
        xnoKeyTimeOut();
        }
      else {
        var aS;
        if ( loopLimitB === true ) { aS = 'Loop limit ' + iOjax.xmlElVal( 'schULoop' ) + ' exceeded.'; }
        else { aS = 'Match limit ' + iOjax.xmlElVal( 'schUMatch' ) + ' exceeded.'; }
        aOwig.msgOnlyList( aS );
        gNsaSearchS = "";
        gNsaReSearchS = "";
        }
      }
    else {
      gNsaSearchS = "";
      gNsaReSearchS = "";
      aOwig.bldRequired( 6 ); 
      }
    }
  }
// control flow nsIsCheck or nsIsCancel
TOjax.prototype.xmlElVal = function( iS ) {
  var iOjax = this;
  var tags = iOjax.XMLDoc.getElementsByTagName(iS);
  var aS = '';
  if ( ( tags ) && ( tags.length > 0 ) && ( tags[0].firstChild ) ) {
    aS = tags[0].firstChild.data;
    }
  return aS; 
  };
TOjax.prototype.xmlElValN = function( iS ) {
  var iOjax = this;
  var tags = iOjax.XMLDoc.getElementsByTagName(iS);
  var aN = 0;
  if ( ( tags ) && ( tags.length > 0 ) && ( tags[0].firstChild ) ) {
    aN = parseInt( tags[0].firstChild.data, 10 );
    }
  return aN; 
  };
TOjax.prototype.xmlElValA = function( iS, iSubS ) {
  var iOjax = this;
  var tags = iOjax.XMLDoc.getElementsByTagName(iS);
  var aA = new Array();
  if ( ( tags ) && ( tags.length > 0 ) ) {
    var aEl = tags[0];
    var bEl = null;
    var subTags = aEl.getElementsByTagName(iSubS);
    for ( var i=0; i<subTags.length; i++ ) {
      bEl = subTags[i].firstChild;
      if ( bEl ) { aA[aA.length] = bEl.data; }
      }
    }
  return aA; 
  };
//
// edit completion, action server reply, from gOjax reply
TOjax.prototype.updateReply = function() {
  var iOjax = this;
  var iOk = iOjax.xmlElVal( 'success' )=='1';
  var iToUrl = iOjax.xmlElVal( 'toUrl' );
  var iInstStr = iOjax.xmlElVal( 'inst' );
  var aOwin = new TOwin( null, null );
  if ( iOk === true ) { 
    if ( gParId === "" ) {
      // alert( "updateReplyXX iOk:" + iOk + " gParId:" + gParId );
      var aS='';
      if ( iToUrl ) { aS = iToUrl; }
      else { aS = document.location.href; }
      var aaS = aS.split("?");
      var sRev = iOjax.Owin.getCookie( 'sRev' ); 
      if ( sRev === "" ) { sRev = 2; }
      sRev++;
      iOjax.Owin.setCookie( 'sRev', sRev ); 
      var stayEl = document.getElementById( 'idEdStay' );
      if ( ( stayEl ) && ( stayEl.checked === true ) ) {
        alert( 'stay' );
        gRevision++;
        aS = aaS[0] + '?se=' + gSesNoloi + '&ed=' + gRevision
        + '&mf=' + edModeFlags();
        document.location.replace( aS );
        }
      else {
        if ( ( iToUrl ) && ( iToUrl !== '' ) ) {
          // document.location.replace( iToUrl );
          aOwin.setCookie( 'toUrlS', iToUrl ); 
          aOwin.doAbort();
          }
        else {
          document.location.replace( '/common/doneEdit.html' );
          }
        }
      }
    else {
      // ef from url ?
      // var edsub = EdSubmitStr( );
      // alert( '?? edsub.combStr ' + edsub.combStr );
      aOwin.childCommit( iInstStr );
      }
    }
  else { 
    aOwin.doCheck();
    }
  resetExchange();
};
TOwin.prototype.logout = function( ) {
  var aOwin = this;      
  aOwin.clearCookie( 'skey' ); 
  aOwin.clearCookie( 'sRev' );
  aOwin.clearCookie( 'sNoloi'); 
  aOwin.clearCookie( 'sAuthCache' ); 
  aOwin.clearCookie( 'reload' );
  };
TOjax.prototype.logUpReply = function( w, iViaExcB ) {
  var iOjax = this;
  var iKeyS = iOjax.xmlElVal( 'ses' );
  var iNoloiS = iOjax.xmlElValN( 'sNoloi' );
  var iCode = iOjax.xmlElValN( 'KCheckUserResult' );
  var iUserS = iOjax.xmlElVal( 'userName' );
  var iOn = iOjax.xmlElValN( 'logOn' );
  var aToUrl = iOjax.xmlElVal( 'toUrl' );
  var msgS = 'logUpReply iCode:' + iCode;
  var okB = false;
  if ( iOn === 0 ) {
    msgS = 'Bye ' + iUserS;
    iOjax.Owin.logout(); 
    okB = true;
    }
  else {
    if ( iCode === 0 ) { msgS = 'Invalid user name or password'; }
    else if ( iCode === 1 ) { msgS = 'Licence limit exceeded'; }
    else if ( iCode === 2 ) { msgS = 'Account limit exceeded'; }
    else if ( iCode === 3 ) { msgS = 'Single limit exceeded'; }
    else if ( iCode === 5 ) { msgS = 'Cant log off guest'; }    
    else { // UrSuccess
      iOjax.Owin.setCookie( 'skey', iKeyS ); // same option as cookie
      iOjax.Owin.setCookie( 'sNoloi', iNoloiS ); // same option as cookie
      iOjax.Owin.setCookie( 'sRev', '2' ); // 1=edit page
      okB = true;
      msgS = 'Welcome ' + iUserS;
      }
    }
//  alert( 'logUpReply okB ' + okB + ' iCode ' + iCode + ' msgS ' + msgS
//  + 'aToUrl:' + aToUrl );
  if ( okB === false ) { alert( msgS ); }
  var aOnav = new TOnav();
  var cnt = 0;
  var pEl = 1;
  while ( pEl ) {
    cnt++; 
    pEl = w.document.getElementById( 'idLogOn' + cnt );
    if ( pEl ) {
      // alert( 'logUpReply-5 ' + pEl.tagName ); 
      if ( okB === true ) {
        aOnav.evtLogOnOff( pEl, iOn !== 0, true );
        }
      }
    }
  // reload page after log on/off
  if ( iViaExcB === true ) {
    var exEl = document.getElementById( 'exchange' );
    exEl.src = '/common/exchange.html';
//  resetExchange();
    }
  if ( okB === true ) {
    w.setTimeout("logUpComplete('" + aToUrl + "')", 20 );
    }
  };
function logUpComplete( iToUrl ) {
  if ( iToUrl === '' ) { document.location.reload( true ); }
  else { document.location.replace( iToUrl ); }
  }
//
// Uploading related qop reply, generated source for file list
function edExtQopReply( w, qopS, iSuccess, iDirAS, iCurS, iFileTypeS ) { // via exchange
  var aOwin = new TOwin( null, null );
  if (( qopS == 'upl' )||( qopS == 'dir' )||( qopS == 'del' )) {
    // alert( 'edExtQopReply reply ' + qopS + ' ' + iSuccess 
    // + ' iDirAS.length ' + iDirAS.length + ' iCurS:' + iCurS ); 
    var aS = '';
    if ( iDirAS.length === 0 ) {
      aS = 'None';
      }
    else {
      var fileS = iCurS;
      if (( fileS == '.' )||( fileS === '' )) {
        var selectedEl = document.getElementById( 'idUpSelFile' );
        if ( selectedEl ) { fileS = selectedEl.value; }
        }
      var foundB = false;
      for ( var i=0; i<iDirAS.length; i++ ) {
        if ( iDirAS[i] == fileS ) { foundB = true; }
        }
      for ( i=0; i<iDirAS.length; i++ ) {
        aS += aOwin.bldUploadLine( iDirAS[i] == fileS, iFileTypeS, iDirAS[i].edHtmlEsc()
        , iDirAS[i] );
//        alert( 'image:' + iDirAS[i] + ' selected:' + fileS + ' ' + aS );
        }
      aS += aOwin.bldUploadLine( foundB===false, iFileTypeS, '', 'None' );
      }
    var aEl = document.getElementById( 'idUpView' );
    if ( aEl !== null ) {
      aEl.innerHTML = aS;
      }
    }
  resetExchange();
  }
//
// Uploading related qop reply, generated source for file list
TOjax.prototype.qopReply = function( w, qopS ) {
  var iOjax = this;
  var iSuccess = iOjax.xmlElValN(  'success' ) === 1;
  var iDirAS = iOjax.xmlElValA( 'dir', 'dirEntry' );
  var iCurS = iOjax.xmlElVal( 'file' );
  var iFileTypeS = iOjax.xmlElVal( 'fileType' );
  var eEl;
  var aOwin = new TOwin( null, null );
  if (( qopS == 'upl' )||( qopS == 'dir' )||( qopS == 'del' )) {
//    alert( 'edExtQopReply reply ' + qopS + ' ' + iSuccess 
//    + ' iDirAS.length ' + iDirAS.length + ' iCurS:' + iCurS ); 
    var aS = '';
    if ( iDirAS.length === 0 ) {
      aS = 'None';
      }
    else {
      var fileS = iCurS;
      if (( fileS == '.' )||( fileS === '' )) {
        var selectedEl = document.getElementById( 'idUpSelFile' );
        if ( selectedEl ) { fileS = selectedEl.value; }
        }
      var foundB = false;
      var i,dirS;
      for ( i=0; dirS=iDirAS[i++]; ) {
        if ( dirS == fileS ) { foundB = true; }
        }
      for ( i=0; dirS=iDirAS[i++]; ) {
        aS += aOwin.bldUploadLine( dirS == fileS, iFileTypeS, dirS.edHtmlEsc(), dirS );
//        alert( 'image:' + iDirAS[i] + ' selected:' + fileS + ' ' + aS );
        }
      aS += aOwin.bldUploadLine( foundB===false, iFileTypeS, '', 'None' );
      }
    var aEl = document.getElementById( 'idUpView' );
    if ( aEl !== null ) {
      aEl.innerHTML = aS;
      }
    }
  resetExchange();
  };
/* **************************************** */
function TOtmi( iEl ) {
  var aOtmi = this;
  aOtmi.EdTmiFindNod12( iEl );
  if ( aOtmi.Nod2 !== null ) {
    aOtmi.EdTmiGetOtmiRecursive( aOtmi.Nod2 );
    }
  // return Otmi;
  }
TOtmi.prototype.EdTmiFindNod12 = function( iEl ) {
  var aOtmi = this;
  aOtmi.Nod1 = null;
  aOtmi.Nod2 = null;
  var nxEl = iEl;
  var doneB = false;
  while ( doneB === false ) {
    if ((nxEl.className)&&( nxEl.className.substr( 0, 4 )=='zWid' )) { 
      doneB = true;
      if ((nxEl.parentNode.className)
      && ( nxEl.parentNode.className.substr( 0, 4 )=='zWid' )) { 
        aOtmi.Nod1 = nxEl.parentNode;
        aOtmi.Nod2 = nxEl;
        }
      else if ((nxEl.childNodes[0].className)
      && ( nxEl.childNodes[0].className.substr( 0, 4 )=='zWid' )) { 
        aOtmi.Nod1 = nxEl;
        aOtmi.Nod2 = nxEl.childNodes[0];
        }
      else {
        aOtmi.Nod1 = nxEl;
        aOtmi.Nod2 = nxEl;
        }
      }
    nxEl = nxEl.parentNode; 
    doneB = ( nxEl === null );
    }
  };
TOtmi.prototype.EdTmiGetOtmiRecursive = function( iEl ) {
  var iOtmi = this;
  var nxEl,i;
  for ( i=0;nxEl=iEl.childNodes[i++]; ) {
    if ( nxEl.nodeType == 1 ) {
      if ( nxEl.tagName == "INPUT" ) {
        if (( nxEl.type == "checkbox" )||( nxEl.type == "radio" )) {
          iOtmi.tickEl = nxEl;
          }
        else if ( nxEl.type == "text" ) {
          iOtmi.textEl = nxEl;
          }
        else if ( nxEl.type == "button" ) {
          iOtmi.butEl = nxEl;
          }
        else if ( nxEl.type == "hidden" ) {
          iOtmi.hideEl = nxEl;
          }
        }
      else if ( nxEl.tagName == "TEXTAREA" ) {
        iOtmi.taEl = nxEl;
        }
      else if ( nxEl.tagName == "A" ) {
        iOtmi.linkEl = nxEl;
        }
      else if ( nxEl.tagName == "SELECT" ) {
        iOtmi.selectEl = nxEl;
        }
      else if ( nxEl.tagName == "NOBR" ) {
        iOtmi.nobrEl = nxEl;
        }
      iOtmi.EdTmiGetOtmiRecursive( nxEl, iOtmi );
      }
    }
  };
TOtmi.prototype.updateKefv = function( iKefv, iSelectB ) {
  var aOtmi = this;
  if ( aOtmi.textEl ) {
    aOtmi.textEl.className = "zEdText" + iKefv;
    }
  if ( aOtmi.tickEl ) {
    aOtmi.tickEl.className = "zEdPre" + iKefv;
    aOtmi.tickEl.checked = iSelectB;
    }
  };
TOtmi.prototype.setTextClass = function( iKefv ) {
  var iOtmi = this;
  var aKefv;
  var focusedB = ( gFocusTextEl == iOtmi.textEl );
  var promptB = (( iOtmi.textEl.className == "zEdText4" )
  ||( iOtmi.textEl.className == "zEdText5" ));
  if ( promptB === true ) { // currently prompt
    if ( focusedB === true ) { // prompt not reqd
      iOtmi.textEl.value = "";
      aKefv = iKefv;
      }
    else { // prompt reqd
      if ( iKefv === 0 ) { aKefv = 4; }
      else if ( iKefv == 2 ) { aKefv = 5; }
      else { alert( "EdTmiSetTextClass-20 iKefv:" + iKefv 
      + " was " + iOtmi.textEl.className ); }
      }
    }
  else {
    aKefv = iKefv;
    }
  iOtmi.textEl.className = "zEdText" + aKefv;
  };
/* ********************** */
function TOnav() {
  var aOnav = this;
  aOnav.Owin = new TOwin( null, null );
  }
//
TOnav.prototype.leftFix = function() {
  var iOnav = this;
  var tdEl = document.getElementById( 'idCbdLeftBar' );
  if ( tdEl ) {
    if ( tdEl.childNodes.length > 0 ) {
      var asDivEl = tdEl.childNodes[0];
      if ( asDivEl.childNodes.length > 0 ) {
        var divEl = asDivEl.childNodes[0];
        if ( divEl.childNodes.length > 0 ) {
          for ( var i=0; i<divEl.childNodes.length; i++ ) {
            var sectEl = divEl.childNodes[i];
            if ( sectEl.childNodes.length > 0 ) {
              var xEl = sectEl.childNodes[0];
              if ( xEl.childNodes.length > 0 ) {
                var tableEl = xEl.childNodes[0];
                iOnav.tableFix( tableEl );
                }
              }
            }
          }
        }
      }
    }
  };
TOnav.prototype.tableFix = function( iTableEl ) {
  var iOnav = this;
  var bodyEl, trEl, tdEl, aEl, bEl, aNst, i, aChar, cloneEl;
  if ( iTableEl.childNodes.length > 0 ) {
    bodyEl = iTableEl.childNodes[0];
    for ( i=0; i<bodyEl.childNodes.length; i++ ) {
      trEl = bodyEl.childNodes[i];
      if ( trEl.childNodes.length > 0 ) {
        tdEl = trEl.childNodes[0];
        if ( tdEl.childNodes.length > 0 ) {
          aEl = tdEl.childNodes[0];
          if ( aEl.tagName ) {
            if ( aEl.className === 'zOptionsSpan' ) {
              bEl = aEl.childNodes[0];
              if (( bEl.nodeType === 1 ) && ( bEl.tagName == 'INPUT' )) {
                aChar = bEl.value.substr( 0, 1 );
                // alert( 'aEl.className Ok:' + ( aEl.className === 'zOptionsSpan' );    
                if ( aEl.childNodes.length == 1 ) {
                  cloneEl = iOnav.Owin.nscCloneImg( aChar );
                  if ( cloneEl ) {
                    aEl.insertBefore( cloneEl, null );
                    }
                  }
                aNst = iOnav.nsMakeNst( tdEl );
                }
              }
            }
          }
        }
      }
    }
  };
//
TOnav.prototype.showTbm = function( elTbh, elTbm ) {
  var iOnav = this;
  var elTbDiv = document.getElementById( "idTbDiv" );
  var elCrumbDiv = document.getElementById( "idCrumbDiv" );
  if ( elTbm.cellSpacing == 1 ) {
    iOnav.tableFix( elTbm );
    elTbm.cellSpacing = 0;
    }
  elTbm.style.left = iOnav.Owin.spGetOffsetLeft( elTbh, null ) + "px";
  elTbm.style.top = iOnav.Owin.spGetOffsetTop( elCrumbDiv, null ) + elCrumbDiv.offsetHeight + "px";
//  alert( 'nsdShowTbm set width');
  elTbm.style.width = "250px"; // opera needs this ?
  var cow = elCrumbDiv.offsetWidth;
  elTbm.style.visibility = "visible";
  var elIdBodyAbs = document.getElementById("idBodyAbs");
  if ( elCrumbDiv ) {
    var uClean = cow - elTbm.offsetWidth;
    if ( iOnav.Owin.spGetOffsetLeft( elTbh, null ) > uClean ) {
      if ( uClean < 0 ) { uClean = 0; }
      elTbm.style.left = uClean + "px";
      }
    }
  elCurTbm = elTbm;
  };
//
function nsdTbDown( iN ) { // hide dropdown
  var aOnav = new TOnav();
  aOnav.nsdTbDown( iN );
  }
TOnav.prototype.nsdTbDown = function( iN ) {
  var iOnav = this;
  if ( elCurTbm !== null ) {
    if ( gJustUp === true ) { gJustUp = false; }
    else {
      elCurTbm.style.visibility = "hidden";
      elCurTbm = null;
/*
      if ( elCur2Tbm !== null ) {
        elCur2Tbm.style.visibility = "hidden";
        elCur2Tbm = null;
        gDropFromTdEl = null;
        if ( gFromL1Tr !== null ) { 
          gFromL1Tr.className = 'zNsTrOff';
          gFromL1Tr = null; 
          }
        }
*/
      }
    }
  };
//
// change state of style option and cookie
TOnav.prototype.evtNsgStyClick = function( cookStr, idStr ) {
  var iOnav = this;
  var el = window.document.getElementById( idStr );
  iOnav.Owin.setCookie( cookStr, el.value );
  var c1 = iOnav.Owin.getCookie( cookStr );
  if ( el.value == c1 ) { 
    location.reload(); 
    }
  else {
    alert( "Sorry this feature requires cookies to enabled <" + el.value + "><" + c1 + ">" );
    }
  };
// show or hide toolbar menu(dropdown)
TOnav.prototype.evtNsdClickOnTbh = function( seq, iInput ) {
  alert( "evtNsdClickOnTbh" );
  var iOnav = this;
  var elTbh = document.getElementById( "idTbh" + seq );
  if ( elCurTbm != elTbh.elTbm ) { 
    iOnav.nsdTbDown( 1 );
    // alert( "evtNsdClickOnTbh-10a" );
    iOnav.showTbm( elTbh, elTbh.elTbm );
    // alert( "evtNsdClickOnTbh-10b" );
    gJustUp = false;
    if ( iInput ) {
      gJustUp = true; // aparently stll reqd, data entry box only ?
      // alert( "evtNsdClickOnTbh-10c" );
      }
    }
  else if ( elCurTbm == elTbh.elTbm ) { 
    // alert( "evtNsdClickOnTbh-20" );
    iOnav.nsdTbDown( 2 );
    }
  else {
    // alert( "evtNsdClickOnTbh-30" );
    iOnav.showTbm( elTbh, elTbh.elTbm );
    } 
  };
TOnav.prototype.evtLogOnOff = function( iEl, iOnB, iCompleteB ) {
  var iOnav = this;
  var aOlogParts = iOnav.logParts( iEl );
  if ( iCompleteB === true ) {
    if ( iOnB === true ) {
      aOlogParts.lofEl.style.display = 'none';
      aOlogParts.lonEl.style.display = 'block';
      }
    else {
//      if ( document.execCommand ) { document.execCommand("ClearAuthenticationCache"); }
      aOlogParts.lonEl.style.display = 'none';
      aOlogParts.lofEl.style.display = 'block';
      }
    }
  else {
    if ( iOnB === true ) {
      gOjax.asDoQs( '?op=lon', ''
      , '&usr=' + aOlogParts.userEl.value + '&pas=' + aOlogParts.passEl.value );
      }
    else {
      gOjax.asDoQs( '?op=lof', '', '&xxx=1' );
      }
    }
  };
TOnav.prototype.logParts = function( iEl ) {
  var iOnav = this;
  var part = new Object();
  part.msgEl = null;
  part.userEl = null;
  part.passEl = null;
  part.lonEl = null;
  part.lofEl = null;
  var divCnt = 0;
  for ( var Inx=0; Inx<iEl.childNodes.length; Inx++ ) {
    var aEl = iEl.childNodes[ Inx ];
    if ( aEl.tagName == 'SPAN' ) { 
      part.msgEl = aEl;
      }
    else if ( aEl.tagName == 'DIV' ) {
      divCnt++;
      if ( divCnt == 1 ) { part.lonEl = aEl; }
      else if ( divCnt == 2 ) { part.lofEl = aEl; }
      for ( var bInx=0; bInx<aEl.childNodes.length; bInx++ ) {
        var bEl = aEl.childNodes[ bInx ];
        if ( ( bEl.tagName )&&( bEl.tagName == 'INPUT' ) ) {
          if ( bEl.type == 'text' ) { part.userEl = bEl; }
          else if ( bEl.type == 'password' ) { part.passEl = bEl; }
          }
        }
      }
    }
  return part;
  };
//
TOnav.prototype.nsMakeNst = function( iTdEl ) {
  var iOnav = this;
  var aNst = new Object();
  aNst.identEl = null;
  aNst.imgEl = null;
  aNst.altSpanEl = null;
  aNst.ddIdEl = null;
  aNst.tdEl1 = iTdEl;
  aNst.tdEl2 = iTdEl.nextSibling;
  var trEl = iTdEl.parentNode;
  aNst.tbodyEl = trEl.parentNode;
  aNst.httmS = ''; 
  aNst.typeS = ''; 
  aNst.subId = ''; 
  // aNst.KnsType = ''; 
  aNst.textEl = null;  // KnsTypeRange or ..Id
  aNst.labelS = ''; // ditto
  var tableEl = trEl.parentNode.parentNode;
  var aEl = tableEl.nextSibling;
  if ( ( aEl ) && ( aEl.tagName == 'INPUT' ) ) {
    if ( aEl.id.substr( 0, 5 ) !== 'idEfG' ) {
      aNst.ddIdEl = aEl;
      var ss=aEl.value.split('|');
      aNst.parId=ss[0];
      aNst.prefixS=ss[1];
      }
    }
  for ( var i=0; i<trEl.childNodes.length; i++ ) {
    var tdEl = trEl.childNodes[i];
    for ( var j=0; j<tdEl.childNodes.length; j++ ) {
      aEl = tdEl.childNodes[j];
      if ( ( j==1 ) && ( aEl.tagName == 'SPAN' ) ) {
        aNst.altSpanEl = aEl;
        }
      for ( var k=0; k<aEl.childNodes.length; k++ ) {
        var kEl = aEl.childNodes[k];
        if ( kEl.tagName ) {
          if ( ( kEl.tagName == 'INPUT' ) && ( kEl.type == 'hidden' ) ) {
            if ( ! aNst.identEl ) { aNst.identEl = kEl;}
            }
          if ( kEl.tagName == 'IMG' ) { aNst.imgEl = kEl; }
          }
        }
      if ( aEl.nodeType == 3 ) { aNst.labelS = aEl.nodeValue; }
      else if (( aEl.tagName == 'INPUT' ) && ( aEl.type == 'text' ) ) {
        aNst.textEl = aEl;
        }
      }
    }
  if ( aNst.identEl ) {
    var bSs = aNst.identEl.value.split( '|' );
    aNst.tickC = bSs[0];
    if ( bSs[1] ) { aNst.subId = bSs[1]; } 
    if ( bSs[2] ) { aNst.Knsx = bSs[2]; } 
    if ( bSs[3] ) { aNst.httmS = bSs[3]; }
    if ( bSs[4] ) { aNst.typeS = bSs[4]; } 
    }
  return aNst;
  };
TOnav.prototype.nstHttm = function( iFormS, iRepS ) {
  var iOnav = this;
  var aS = iRepS.nsToOjText();
  var re, bS;   
  re = /Z.*/g;
  bS = iFormS.replace( re, 'Z' + aS + ')' );
  return bS;  
  };
TOnav.prototype.nshHintFix = function() {
  var iOnav = this;
  var swEl = null;
  var h = iOnav.Owin.getCookie('hints');
  if ( h === '' ) { h = gDefaultHints; }
  if ( h !== '' ) {
    swEl = document.getElementById( 'idHintSwOne' );
    if ( swEl ) {
      if ( h.substr( h.length-1, 1 )=='d' ) {
        swEl.checked = false;
        }
      else {
        var index = h.length - 2 - ( gKHint >> 2 );
        var hex = iOnav.nshHexOfChar( h, index );
        var mask = 1 << ( gKHint & 3 );
        swEl.checked = ( ( hex & mask ) !== 0 );
        }
      }
    swEl = document.getElementById( 'idHintSwAll' );
    if ( swEl ) {
      swEl.checked = ( h.substr( h.length-1, 1 )=='e' );
      }
    swEl = document.getElementById( 'idHintSwPause' );
    if ( swEl ) {
      swEl.checked = ( h.substr( h.length-1, 1 )=='e' );
      }
    }
  };
TOnav.prototype.nshHintMod = function( iHintStr, iBitNo, iSet, iSwEl ) {
  var iOnav = this;
  var pre = '';
  if ( iBitNo == -1 ) {
    pre  = iHintStr.substr( 0, iHintStr.length-1 );
    if ( iSet === true ) { return pre + 'e'; }
    else { return pre + 'd'; }
    }
  else {
    var index = iHintStr.length - 2 - ( iBitNo >> 2 );
    var hex = iOnav.nshHexOfChar( iHintStr, index );
    var bitPosn = iBitNo & 3;
    var mask = 1 << bitPosn;
    if ( iSwEl.checked===true ) { hex = hex | mask; }
    else { hex = hex & (~mask); }
    var aC = iOnav.nshCharOfHex( hex );
    pre = iHintStr.substr( 0, index );
    var post = iHintStr.substr( index+1, iHintStr.length-1 );
    return pre + aC + post;
    }
  };
TOnav.prototype.nshHexOfChar = function( iStr, iIndex ) {
  var iOnav = this;
  var cc = iStr.charCodeAt(iIndex);
  var val = 0;
  if ( cc > 64 ) { val = cc - 55; }
  else { val = cc - 48; }
  return val;
  };
TOnav.prototype.nshCharOfHex = function( iHex ) {
  var iOnav = this;
  var cc = 0;
  if ( iHex > 9 ) { cc = iHex + 55; }
  else { cc = iHex + 48; }
  return String.fromCharCode(cc);
  };
/* ************************** */  
// split operation url into components
function TOlnk( iHref ) { // split operation url into components
  var aOlnk = this; // new Object();
  // defaultStatus += ' TOlnk';
  aOlnk.HRef = iHref;
  aOlnk.aPosn = 0;
  aOlnk.qualPosn = 0;
  aOlnk.opPosn = 0;
  aOlnk.instPosn = 0;
  aOlnk.ePosn = 0;
  while ( aOlnk.aPosn != -1 ) {
    aOlnk.ePosn = aOlnk.instPosn;
    aOlnk.instPosn = aOlnk.opPosn;
    aOlnk.opPosn = aOlnk.qualPosn;
    aOlnk.qualPosn = aOlnk.aPosn;
    aOlnk.aPosn = aOlnk.HRef.indexOf( '/', aOlnk.aPosn+1 );
    }
  aOlnk.dotPosn = aOlnk.HRef.indexOf( '.', aOlnk.qualPosn );
  aOlnk.qPosn = aOlnk.HRef.indexOf( '?' );
  aOlnk.preInstStr = aOlnk.HRef.substr( 0, aOlnk.instPosn );
  aOlnk.instStr = aOlnk.HRef.substr( aOlnk.instPosn+1, aOlnk.opPosn-aOlnk.instPosn-1 );
  aOlnk.viewS = aOlnk.HRef.substr( aOlnk.opPosn+1, aOlnk.qualPosn-aOlnk.opPosn-1 );
  aOlnk.qualStr = aOlnk.HRef.substr( aOlnk.qualPosn+1, aOlnk.dotPosn-aOlnk.qualPosn-1 );
  aOlnk.KvinvS = "";
  var aOparse = new TOparse( aOlnk.viewS );
  aOlnk.KvinvS = aOparse.getAlpha();
  aOlnk.viewN = aOparse.extractN();
  aOlnk.SKOpQualN = 0;
  aOlnk.OpNoloi = 0;
  aOlnk.OpArg = 0;
  aOlnk.SKvliN = 0;
  aOlnk.ctmS = aOparse.extractY();
  var cS;
  while ( aOparse.S !== "" ) {
    cS = aOparse.getAlpha();
    if ( cS === "f" ) { 
      aOparse.S = "";
      }
    else {
      if ( cS === "a" ) { aOlnk.SKOpQualN = aOparse.extractN(); }
      else if ( cS === "b" ) { aOlnk.OpNoloi = aOparse.extractN(); } 
      else if ( cS === "c" ) { aOlnk.OpArg = aOparse.extractN(); }
      else if ( cS === "d" ) { aOlnk.SKvliN = aOparse.extractN(); }
      else { 
        aOparse.extractN(); 
        aOparse.S = ""; // prevent looping ??
        }
      }
    }
//
  aOlnk.typeS = "";
  var SS = aOlnk.instStr.split( 'x' );
  if ( SS.length > 1 ) { aOlnk.typeS = SS[1]; }
  aOlnk.HojS = SS[0];
//
  aOlnk.queryStr = '';
  if ( aOlnk.qPosn > 0 ) {
    aOlnk.queryStr = aOlnk.HRef.substr( aOlnk.qPosn+1, aOlnk.HRef.length-aOlnk.qPosn-1 );
    }
  //  ../inst/op/qual.htm
  }
TOlnk.prototype.encodeView = function encodeView() {
  var aOlnk = this;
  var aS = aOlnk.KvinvS + aOlnk.viewN;
  if ( aOlnk.ctmS !== "" ) {
    aS += yyStr( aOlnk.ctmS );
    }
  if ( aOlnk.SKOpQualN !== 0 ) { aS += 'a' + aOlnk.SKOpQualN; }
  if ( aOlnk.OpNoloi !== 0 ) { aS += 'b' + aOlnk.OpNoloi; }
  if ( aOlnk.OpArg !== 0 ) { aS += 'c' + aOlnk.OpArg; }
  if ( aOlnk.SKvliN !== 0 ) { aS += 'd' + aOlnk.SKvliN; }
  aOlnk.viewS = aS;
  return aS;
  };
//
// replace instance within url, disgard query, carry type if iFullB
TOlnk.prototype.replaceInst = function( iInstS, iFullB ) {
  var iOlnk = this;
  var queryStr = iOlnk.queryStr;
  var qualStr = iOlnk.qualStr;
  var bTypeS = '';
  var aInstS = iInstS;
  var SS = iOlnk.instStr.split( 'x' );
  if ( SS.length > 1 ) { bTypeS = 'x' + SS[1]; }
  if ( iFullB === false ) { bTypeS = ''; }
  if ( iInstS.substr( 0, 1 ) == 'e' ) { // noloi + possible I0sl
    var restS = iInstS.substr( 1, iInstS.length );
    SS = restS.split( 'z' );
    aInstS = SS[ 0 ];
    if ( SS.length > 1 ) { qualStr = qualStr.substr( 0, 1 ) + SS[ 1 ]; }
    }
  var bUrlS = iOlnk.preInstStr + '/' + aInstS + bTypeS + '/' 
  + iOlnk.encodeView()
  // + iOlnk.viewS 
  + '/' + qualStr + '.htm';
  return bUrlS;
  };
TOlnk.prototype.EKjslNone = 0;
TOlnk.prototype.EKjslType = 1; // delta type on current page
TOlnk.prototype.EKjslInst = 2; // delta inst on current page
TOlnk.prototype.EKjslView = 3; // delta view on current page
TOlnk.prototype.EKjslEdit = 4; // edit page
TOlnk.prototype.EKjslOperation = 5;
TOlnk.prototype.EKjslOfsiteLoged = 6;
TOlnk.prototype.EKjslBookMark = 7;
// 
TOlnk.prototype.toStr = function toStr( iNoIndexB ) {
  var iOlnk = this;
  var preInstStr = iOlnk.preInstStr;
  if ( iNoIndexB === true ) {
    preInstStr = preInstStr.slice( 0, preInstStr.length-2 ) + "/G";
    }
  var bUrlS = preInstStr + '/' + iOlnk.HojS;
  if ( iOlnk.typeS !== "" ) {
    bUrlS += "x" + iOlnk.typeS;
    }
  bUrlS += '/' + iOlnk.encodeView() // iOlnk.viewS 
  + '/' + iOlnk.qualStr + '.htm';
  return bUrlS;
  };
/* ****************** */
function TOwin( iW, iEvt ) {
  var aOwin = this;
  aOwin.AOein = [];
  aOwin.potAOpog = [];
  var bodyEls = document.getElementsByTagName("BODY");
  aOwin.bodyEl = bodyEls[0];
  aOwin.bodyAbsDiv = document.getElementById("idBodyAbs");
  if ( iW !== null ) { aOwin.win = iW; }
  else { aOwin.win = window; }
  aOwin.evt = iEvt;
  aOwin.charCode = 0;
  aOwin.enterKeyB = false;
  if ( iEvt !== null ) {
    aOwin.charCode = (aOwin.evt.charCode) ? aOwin.evt.charCode 
    :((aOwin.evt.which) ? aOwin.evt.which :aOwin.evt.keyCode);
    aOwin.enterKeyB = (aOwin.charCode == 13 || aOwin.charCode == 3);
    }
  // defaultStatus += ' TOwin';
  aOwin.ownOlnk = new TOlnk( document.location.href );
  }
TOwin.prototype.setCookie = function( sName, sValue) {  // same option as cookie
  // var kill_date = new Date("January 1, 1970");
  // document.cookie = sName + "=x;expires=" + kill_date.toGMTString();path="/"
  var date = new Date();
  var currYear = date.getYear();
  if ( currYear < 1000 ) {
    if ( currYear >= 100 ) { currYear -= 100; }
    currYear += 2000;
    }
  date.setYear( currYear + 1 );
  document.cookie = sName + "=" + escape(sValue) + "; expires=" 
  + date.toGMTString() + '; path=/';
  };
TOwin.prototype.clearCookie = function( sName ) {
  var date = new Date();
  var currYear = date.getYear();
  if ( currYear < 1000 ) {
    if ( currYear >= 100 ) { currYear -= 100; }
    currYear += 2000;
    }
  date.setYear( currYear - 1 );
  document.cookie = sName + "=; expires=" + date.toGMTString() + '; path=/';
  };
TOwin.prototype.getCookie = function getCookie( sName ) { // get option value from cookie
  var c = document.cookie;
  var oS = "";
  var nv;
  if ( c ) {
    var cs = c.split(";");
    var i = 0;
    while( i<cs.length ) {
      nv = cs[i].split( "=" );
      if ( nv[0].indexOf(sName) != -1 ) { if ( nv[1] ) {oS = nv[1];} }
      i++;
      }
    }
  return unescape( oS );
  };
TOwin.prototype.spWindowHeight = function spWindowHeight() {
  var iOwin = this;
  var aHeight = 0;
  if ( typeof( window.innerWidth ) == "number" ) { //Non-IE
    aHeight = window.innerHeight;
    }
  else if ( document.documentElement &&
  ( document.documentElement.clientHeight ) ) { //IE 6+ in compliant mode
    aHeight = document.documentElement.clientHeight;
    }
  else if ( document.body && ( document.body.clientHeight ) ) {//IE 4 compatible
    aHeight = document.body.clientHeight;
    }
  return aHeight;
  };
TOwin.prototype.spWindowWidth = function spWindowWidth() {
  var iOwin = this;
  var aWidth = 0;
  if ( typeof( window.innerWidth ) == "number" ) { //Non-IE
    aWidth = window.innerWidth;
    }
  else if ( document.documentElement &&
  ( document.documentElement.clientWidth ) ) { //IE 6+ in compliant mode
    aWidth = document.documentElement.clientWidth;
    }
  else if ( document.body && ( document.body.clientWidth ) ) {//IE 4 compatible
    aWidth = document.body.clientWidth;
    }
  return aWidth;
  };
//
// get absolute posn top
TOwin.prototype.spGetOffsetTop = function spGetOffsetTop( iEl, iRootEl ) {
  var iOwin = this;
  var ofs = 0;
  if ( ( iEl ) && ( iEl != iRootEl ) ) {
    ofs = iEl.offsetTop + iOwin.spGetOffsetTop( iEl.offsetParent, iRootEl );
    }
  return ofs;
  };
// 
// get absolute posn left
TOwin.prototype.spGetOffsetLeft = function spGetOffsetLeft( iEl, iRootEl ) {
  var iOwin = this;
  var ofs = 0;
  if ( ( iEl ) && ( iEl != iRootEl ) ) {
    ofs = iEl.offsetLeft + iOwin.spGetOffsetLeft( iEl.offsetParent, iRootEl );
    }
  return ofs;
  };
TOwin.prototype.evtMainUnLoad = function evtMainUnLoad() {
  var iOwin = this;
  purge( iOwin.bodyEl );
  };
TOwin.prototype.evtMainLoad = function evtMainLoad() {
  var iOwin = this;
  var ss;
  var nxOwil;
  defaultStatus += 'ml-1';
  iOwin.win.onpageshow = evtWindow; // firefox
  if ( history.navigationMode ) { history.navigationMode='compatible'; } // opera
  if ( iOwin.win.name === "testPrint" ) {
    alert( "evtMainLoad testPrint" );
    // display in fixed size window, suitable to print
    /*
    var tpWindow=window.open(document.location,"testPrint"
    , "width=600,height=400"
    + ",toolbar=no,location=no,directories=no,status=no"
    + ",scrollbars=yes,menubar=yes,resizable=no,top=0,left=0"
    );  
    */
    }
  else {
    // alert( "evtMainLoad" );
    var sRev = iOwin.getCookie( 'sRev' ); 
    var skey = iOwin.getCookie( 'skey' );
    var sNoloi = iOwin.getCookie( 'sNoloi' );
//    if ( ( sNoloi !== null ) && ( sNoloi !== "" ) && ( sNoloi != gSesNoloi ) 
//    && ( gSesNoloi === 0 ) ) {
//      alert( 'Caution, you are not loged on.'
//      + ' Session may have timed out or server restarted.' );
//      SetCookie( 'sNoloi', '' )
//      }
    window.onfocus = evtWindow; // chkModal;
    var wrongB = ( ( sRev !== null ) && ( sRev !== "" ) && ( sRev != gRevision ) 
    && ( gRevision != 1 ) )
    || ( ( sNoloi !== null ) && ( sNoloi !== "" ) && ( sNoloi != gSesNoloi ) 
    && ( gSesNoloi !== 0 ) );  // gSesNoloi = 0 = guest
//    alert( "wrongB:" + wrongB + " gSesNoloi:" + gSesNoloi + " sNoloi:" + sNoloi
//    + " gRevision:" + gRevision + " sRev:" + sRev );
    var doneB = false;
    var reloadS;
    var aToUrlS = iOwin.getCookie( 'toUrlS' ); 
    if ( aToUrlS !== "" ) {
      iOwin.clearCookie( 'toUrlS' );
      document.location.replace( aToUrlS ); 
      doneB = true;
      }
    else if ( wrongB === true ) {
      reloadS = iOwin.getCookie( 'reload' );
      // session and wrong revision
      // alert( 'About to refresh. sRev:' + sRev + ' gRevision:' + gRevision );
      if ( reloadS !== "" ) { 
        if ( gSesNoloi === 0 ) {
          alert( "Can not continue current session, now logging off.\n\n"
          + "To avoid this please log off at end of each session.\n\n"
          + "May also result from:\n"
          + "- Server restart or fault.\n" 
          + "- Incorrect cache control setting on your machine.\n" );
          } 
        else {
          alert( "Can not get page for expected session.\n"
          + "Expected Session(EditRevision):" + sNoloi + "(" + sRev + ")"
          + " page Session(EditRevision):" + gSesNoloi + "(" + gRevision + ")" 
          + " reloadS: " + reloadS 
          + "\n\n Please report numbers and time to check against server log."
          );
        }
        iOwin.logout(); 
        // doneB = true;
        }
      else {
        iOwin.setCookie( 'reload', 'caseA' );
        document.location.reload( true );
        doneB = true;
        }
      }
    else if ( ( ( sRev === null ) || ( sRev === "" ) ) && ( gRevision !== 0 ) 
    && ( gSesNoloi !== 0 ) ) { // gSesNoloi=0 for MWS
      // no session but session page
      // alert( 'no session but session page sRev ' + sRev 
      // + ' gRevision ' + gRevision + 'gSesNoloi' + gSesNoloi );
      ss=document.location.href.split("?");
      if ( ss[1] ) {
        document.location.replace( ss[0] ); 
        doneB = true;
        }
      else { 
        reloadS = iOwin.getCookie( 'reload' );
        if ( reloadS !== "" ) { 
          alert( "Failed to get non session page./n"
          + "Expected Session(EditRevision):" + sNoloi + "(" + sRev + ")"
          + "Got page with Session(EditRevision):" + gSesNoloi + "(" + gRevision + ")" 
          + "reloadS:" + reloadS );
          iOwin.clearCookie( 'reload' );
          doneB = true;
          }
        else {
          document.location.reload( true ); 
          doneB = true;
          }
        }
      }
    if ( doneB === false ) {
      //
      iOwin.clearCookie( 'reload' );
      defaultStatus += ',2';
      // action cookies
      var cook = iOwin.getCookie( "style" );
      var el = null;
      if ( ( cook & 1 ) !== 0 ) {
        el = window.document.getElementById( "idNight" );
        if ( el ) { el.checked = true; }
        }
      if ( ( cook & 2 ) !== 0 ) {
        el = window.document.getElementById( "idTbOpt" );
        if ( el ) { el.checked = true; }
        }
      // setup toolbar
      for ( var I=1; I<200; I++ ){
        var elTbm = document.getElementById( "idTbm" + I );
        var elTbh = document.getElementById( "idTbh" + I );
        if ( elTbm ) { nsdInitTbm( elTbm, elTbh ); }
        }
      defaultStatus += ',3';
      iOwin.setCookie( 'from', gPageSeq + '+' + gHintTarg );
      defaultStatus += ',4';
/*
      iOwin.bodyEl.ondragstart = edEvtXnoAll;
      iOwin.bodyEl.ondragend = edEvtXnoAll;
      iOwin.bodyEl.ondragdrop = edEvtXnoAll;
      iOwin.bodyEl.ondragenter = edEvtXnoAll;
      iOwin.bodyEl.ondragleave = edEvtXnoAll;
      iOwin.bodyEl.ondragover = edEvtXnoAll;
*/
      var aEl = document.getElementById("idBotAd");
      if ( aEl ) { aEl.style.display = "none"; }
      // size and posn tables
      gWindowHeight = 0;
      gspWindowWidth = 0; // indicate size changed
      defaultStatus += ',5';
      // if ( false ) { asMakeUrl( ); }
      defaultStatus += ',6';
//      iOwin.bodyEl.style.visibility = 'visible';
      iOwin.nsFixInlineBlock();
      defaultStatus += ',7';
      // nsFixEdInlineBlock();
      defaultStatus += ',8';
      iOwin.asLinkFix();
      iOwin.nsfDateFix( ); // calander stuff .indexOf("Microsoft")!= -1)
      // if (navigator.appName.indexOf("Microsoft") === -1 ) {
        // alert( navigator.appName );
        iOwin.evtResizing( ); 
      //   }
      defaultStatus += ',8c';
      var aDate = new Date( ).valueOf();
      //
      iOwin.formInit();
      defaultStatus += ',8d';
      iOwin.wigNav();
      var bDate = new Date( ).valueOf();
      defaultStatus += ',9 (' + (bDate-aDate) + ')';
      // ex nav load
      var aOnav = new TOnav();
      aOnav.leftFix();
      defaultStatus += ',10';
      //  gNisc = aOnav.nsNewNisc();
      defaultStatus += ',11';
      aOnav.nshHintFix();
      defaultStatus += ',12';
// ??      if ( gLoadNav === false ) { nsFixNav( window, 0, 0 ); }
      defaultStatus += ',13';
      // alert( defaultStatus );
      aEl = document.getElementById( 'idBotMeat' );
      if ( aEl ) { aEl.style.display = 'none'; }
      iOwin.bodyEl.style.visibility = 'visible';
      var selEl = null;
      var tbEls = document.getElementsByTagName( "TBODY" );
      for ( var inx=0; inx<tbEls.length; inx++ ) {
        selEl = tbEls[inx];
        if ( selEl.className.indexOf("zSelTBody") === 0 ) {  
          iOwin.getWigPosns( selEl );
          if ( iOwin.rootIdEl !== null ) {  // need to do wigNav ?
            var aOwig = makeTargOwig( iOwin, selEl, true );
            aOwig.capture( false, KXnoStMinimized );
            if ( aOwig.Qtype === aOwig.EQtypeEno ) {
              if ( aOwig.actOwil == selEl ) { // do once only not on possibles
                aOwig.sideEffect( aOwig.actOwil );
                aOwig.sideEffect( aOwig.potOwil );
                }
              }
            }
          }
        }
      var upFormEl = document.getElementById( 'UpForm' );
      if ( upFormEl !== null ) {
        ss=upFormEl.action.split('?'); // get filetype
        gOjax.asDoQs( '?op=dir', '/upManage', '&' + ss[1] );
        }
      }
    }
  var aS = gUescS.nsToOjText();
  var bS = aS.nsFromOjText();
  if ( bS !== gUescS ) { 
    alert( 'nsFromOjText fail:' + + gUescS + ' -> ' + aS + ' -> ' + bS );
    }
  };
TOwin.prototype.evtResizing = function evtResizing() {
  var iOwin = this;
  var i, div;
  // iOwin.nshRedArrow();
  var txtEls = document.getElementsByTagName("COL");
  if ( ( iOwin.spWindowWidth() != gspWindowWidth )
  || ( iOwin.spWindowHeight() != gWindowHeight ) ) {
    gWindowHeight = iOwin.spWindowHeight();
    gspWindowWidth = iOwin.spWindowWidth();
    }
  var aHeight = iOwin.spWindowHeight();
  // display scrollable down indicator
  iOwin.evtNsgChkMore();
  // page footer positioning
  var elIdFooter = document.getElementById("idFooter");
  if ( elIdFooter ) {
    var elIdBodyAbs = document.getElementById("idBodyAbs");
    aHeight = aHeight - elIdFooter.offsetHeight; // desired posn if > content size
    if ( aHeight > elIdBodyAbs.offsetHeight ) {
      elIdFooter.style.position = "absolute";
      elIdFooter.style.top = aHeight;
      }
    else {
      elIdFooter.style.position = "";
      }
    }
  var divs = document.getElementsByTagName('div');
  var sizeDiv = null;
  for( i=0; div = divs[i++]; ){ 
    if ( div.className == 'zScaleDiv9' ) { sizeDiv = div; }
    if ( div.className == 'zScaleDiv1' ) {
      iOwin.barColmWidthSet( div, sizeDiv );
      }
    }
  // allign left of table presentation with IT logic
  };
// 
TOwin.prototype.spElemPosn = function spElemPosn( iEl ) {
  function spInitHxy( iX, iY ) {
    this.x = iX; // + window.document.body.clientLeft;
    this.y = iY; // + window.document.body.clientTop;      
    }     
  var iOwin = this;
  var totY = 0;
  var totX = 0;
  for ( var ell=iEl; (ell); ell=ell.offsetParent ) {
    if ( ell.tagName != 'BODY' ) { // for IE
      totY += ell.offsetTop;
      totX += ell.offsetLeft;
      }
    }
  var bodyAbsEl = window.document.getElementById( 'idBodyAbs' ); // for NS
  var Hxy = new spInitHxy( totX - bodyAbsEl.offsetTop, totY - + bodyAbsEl.offsetLeft );      
  return Hxy;
  };
// 
TOwin.prototype.nscCloneImg = function nscCloneImg( iTickC ) {
  var iOwin = this;
  var inx = 0;
  if ( iTickC == 't' ) { inx = 1; }
  else if ( iTickC == 'b' ) { inx = 2; }
  else if ( iTickC == 'd' ) { inx = 3; }
  else if ( iTickC == 'c' ) { inx = 4; }
/*
  else if ( iTickC == gPin ) { inx = 5; }
  else if ( iTickC == gNoPin ) { inx = 6; }
  else if ( iTickC == 'star' ) { inx = 7; }
  else if ( iTickC == 'down' ) { inx = 8; }
  else if ( iTickC == 'right' ) { inx = 9; }
  else if ( iTickC == 'arrowY' ) { inx = 10; }
*/
  else if ( iTickC == 'ctm' ) { inx = 5; }
  else if ( iTickC == 'filter' ) { inx = 6; }
  else if ( iTickC == 'down' ) { inx = 7; }
  var imageEl = null;
  if ( inx !== 0 ) {
    var imageC = 0;
    var aEl = document.getElementById( 'idImageBank' );
    for ( var i=0; i<aEl.childNodes.length; i++ ) {
      var bEl = aEl.childNodes[i];
      if ( bEl.tagName == 'IMG' ) {
        imageC++;
        if ( imageC == inx ) { imageEl = bEl; }
        }
      }
    }
  var cloneEl = null;
  if ( imageEl ) {
    cloneEl = imageEl.cloneNode( imageEl );
    }
  return cloneEl;
  };
// get distance page scrolled verticaly
TOwin.prototype.spScrollTop = function spScrollTop() {
  var iOwin = this;
  var y = 0;
  if ( document.all ) { 
    y = window.document.body.scrollTop + document.documentElement.scrollTop; 
    }
  else { y = window.pageYOffset; }                
  return y;
  };
// get distance page scrolled verticaly
TOwin.prototype.spScrollLeft = function spScrollLeft() {
  var iOwin = this;
  var x = 0;
  if ( document.all ) { 
    x = window.document.body.scrollLeft + document.documentElement.scrollLeft; 
    }
  else { x = window.pageXOffset; }                
  return x;
  };
TOwin.prototype.evtNsgChkMore = function evtNsgChkMore() {
  var iOwin = this;
  if ( typeof document.all != 'undefined' ) { 
    var aHeight = iOwin.spWindowHeight();
    var elIdBodyAbs = document.getElementById("idBodyAbs");
    var elIdMore = document.getElementById("idMore");
    // defaultStatus = '%1 ' + iOwin.spScrollTop( ) + ';' + aHeight + ';' + window.pageYOffset;
    if ( elIdMore ) {
      // defaultStatus += '*1';
      if ( aHeight < ( elIdBodyAbs.offsetHeight - iOwin.spScrollTop( ) ) ) {
        // can scroll further 
        // defaultStatus += '*2';
        elIdMore.style.position = "absolute";
        elIdMore.style.top = aHeight - elIdMore.offsetHeight + iOwin.spScrollTop( );
        elIdMore.style.visibility = "visible";
        }
      else {
        // defaultStatus += '*3';
        elIdMore.style.visibility = "hidden";
        }
      }
    }
  };
function mouseCoords(ev){
  if(ev.pageX || ev.pageY){
    return {x:ev.pageX, y:ev.pageY};
    }
  return {
    x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
   //  y:ev.clientY + document.body.scrollTop  - document.body.clientTop
    y:ev.clientY + document.body.scrollTop
    };
  }	
function edDragMouseUp( iEvent ) {
  var evt = (iEvent) ? iEvent : event;
  var aOwin = new TOwin( null, evt );
  var aOwig = makeTargOwig( aOwin, gDragIdEl, true );
  aOwig.getGenerated( gDragFromEl, KXnoStMinimized, null ); // KXnoStOpen ??
  var tableEl = gDragFromEl.parentNode.parentNode;
  var i,trEl,tdEl,tdX,tdLY,tdUY,afterB,bOwif,startOk,endOk;
  var overInx = -1;
  var mY = aOwin.evt.clientY + aOwin.spScrollTop();
  for ( i=0; (trEl=tableEl.childNodes[i++]); ) {
    // tdX = aOwin.spGetOffsetTop( tdEl, null );
    tdEl = trEl.childNodes[0];
    tdLY = aOwin.spGetOffsetTop( tdEl, null );
    tdUY = tdLY + tdEl.offsetHeight;
    startOk = (( mY > (tdLY-1) )||( i===1 ));
    endOk = ( mY < (tdUY+1) )||( i===tableEl.childNodes.length );
    if ( startOk && endOk ) {
      overInx = i-1; 
      afterB = ( (( mY - tdLY )*2) > tdEl.offsetHeight );
      bOwif = aOwig.getElOwif( tdEl );
      }
    }
  var aOwif = aOwig.getElOwif( gDragFromEl );
  aOwig.swapOwif( aOwif, bOwif, afterB );
//  if ( overInx > -1 ) { alert( "overInx:" + overInx + "aOwif" + aOwif + "bOwif" + bOwif + " " + (aOwif===bOwif)) ; }
  aOwig.saveAll( );
  if ( gDragHelper !== null ) {
    gDragFromEl.style.visibility = "";
    document.body.removeChild( gDragHelper );
    gDragHelper.onmouseup = null;
    gDragHelper = null;
    }
  aOwig.summary();
  aOwig.toKXnoSt( KXnoStMinimized );
  gDragIdEl = null;
  gDragFromEl = null;
  }
TOwin.prototype.evtMouseMoveA = function evtMouseMoveA() {
  var iOwin = this;
  var returnB = true;
  gMouseClientX = iOwin.evt.clientX;  
  gMouseClientY = iOwin.evt.clientY;   
  if ( gDragFromEl ) {
    gDragHelper.style.left = iOwin.evt.clientX + iOwin.spScrollLeft() - gDragOfsX;
    gDragHelper.style.top = iOwin.evt.clientY + iOwin.spScrollTop() - gDragOfsY;
    returnB = false;
    }
  else {
    resetTimer();
    if ( gSlideBackB === true ) {
      var el2 = document.getElementById( "bbut" );
      var y1 = iOwin.evt.clientY - el2.offsetHeight/2;
      if ( y1 < 0 ) { y1 = 0; }
      if (( y1 + el2.offsetHeight ) > window.document.body.offsetHeight ){
        y1 = window.document.body.offsetHeight - el2.offsetHeight;
        }
      if ( document.all ) {
        y1 = y1 + window.document.body.scrollTop;
        el2.style.cursor = "pointer";  // hand ?
        }
      else { 
        y1 = y1 + window.pageYOffset;
        el2.style.cursor = "pointer"; 
        }  
      el2.style.top = y1 + "px";
      }
    }
  // defaultStatus = "gDragFromEl:" + gDragFromEl + " x " + iOwin.evt.clientX;
  return returnB;
  };
TOwin.prototype.evtPageShow = function evtPageShow() {
  var iOwin = this;
  if ( iOwin.evt.persisted ) {
    if ( ( sRev !== null ) && ( sRev !== "" ) && ( sRev != gRevision ) 
    && ( gRevision != 1 ) ) {
      // session and wrong revision
      // alert( 'About to refresh. sRev:' + sRev + ' gRevision:' + gRevision );
      document.location.reload( true );
      }
    }
  };
TOwin.prototype.asLinkFix = function asLinkFix() {
  var iOwin = this;
  var els = null;
  var Inx = 0;
  var cnt = 0;
//  applet, div, frameSet, span, table, td.
/*
  var aEl = null;
  els = document.body.getElementsByTagName( 'INPUT' );
  for ( Inx=0; Inx<els.length; Inx++ ) {
    var aEl = els[ Inx ];
    defaultStatus += aEl.tabIndex;
    aEl.tabIndex = Inx;
    }
  els = document.body.getElementsByTagName( 'DIV' );
  for ( Inx=0; Inx<els.length; Inx++ ) {
    var aEl = els[ Inx ];
    aEl.tabIndex = -1;
    }
  els = document.body.getElementsByTagName( 'TABLE' );
  for ( Inx=0; Inx<els.length; Inx++ ) {
    var aEl = els[ Inx ];
    aEl.tabIndex = -1;
    }
  els = document.body.getElementsByTagName( 'TD' );
  for ( Inx=0; Inx<els.length; Inx++ ) {
    var aEl = els[ Inx ];
    aEl.tabIndex = -1;
    }
*/
  var urlS = '';
  var targS = '';
  var ss = null;
  els = document.body.getElementsByTagName( 'SPAN' );
  for ( Inx=0; Inx<els.length; Inx++ ) {
    var spanEl = els[ Inx ];
    if ( spanEl.className == 'zJsl' ) {
      targS = '';
      ss = spanEl.title.split( '|' );
      urlS = ss[0];
      if ( ( ss.length > 1 ) && ( ss[1] !== '' ) ) {
        targS = ' target="' + ss[1] + '"';
        }
      spanEl.innerHTML = '<a href="' + urlS + '"' + targS + '>'
      + spanEl.innerHTML + '</a>';
      cnt++;
      }
    }
  // alert( 'asLinkFix-1 spans' + els.length + ' cnt ' + cnt );
  cnt = 0;
  els = document.body.getElementsByTagName( 'A' );
  for ( Inx=0; Inx<els.length; Inx++ ) {
    var aEl = els[ Inx ];
    if ( aEl.className == 'zNJsl' ) {
      if ( aEl.title !== '' ) { 
        aEl.href = aEl.title; 
        }
      cnt++;
      }
    }
  // alert( 'asLinkFix-2 spans' + els.length + ' cnt ' + cnt );
  };
TOwin.prototype.nsFixInlineBlock = function nsFixInlineBlock() {
  var iOwin = this;
  var div = null;
  var pEl = null;
  var elSpan = null;
  var elReplace = null;
  var aS = '';
  var detectS = navigator.userAgent.toLowerCase();
  var i, spanEl, divEl, childEl;
  var divs = document.getElementsByTagName('div');
  for( i=0; i<divs.length; i++ ){ 
    div = divs[i];
    if ( div.className == 'zInBDiv' ) {
      // create span around it
      elSpan=document.createElement("SPAN");
      elSpan.className='zInBlock';
      elSpan.style.display = edInlineBlockS();
      elSpan.style.width = div.style.width;
      elReplace = div.parentNode.replaceChild(elSpan,div);
      elSpan.insertBefore( div, null ); // at end
      }
    // if ( div.className == 'zScaleDiv1' ) {
      // iOwin.barColmWidthSet( div );
    //  }
    }
  var spanEls = document.getElementsByTagName('span');
  for( i=0; i<spanEls.length; i++ ){ 
    spanEl = spanEls[i];
    if ( spanEl.className.indexOf( "zNsItemSpan" ) === 0 ) {
      spanEl.style.display = edInlineBlockS();
      divEl = document.createElement("DIV");
      while ( (childEl=spanEl.childNodes[0]) ){ 
        spanEl.removeChild( childEl );
        divEl.insertBefore( childEl, null ); // at end
        }
      spanEl.insertBefore( divEl, null ); // at end
      }
    }
  };
TOwin.prototype.getSectUsage = function( iAEl ) {
  var aOwin = this;
  var uInx = iAEl.length-1; 
  var lastEl = iAEl[uInx];
  var uX = aOwin.spGetOffsetLeft( lastEl, null ) + lastEl.offsetWidth;
  var firstEl = iAEl[0];
  var lX = aOwin.spGetOffsetLeft( firstEl, null );
  var deltaX = ( uX - lX ) / uInx;
  var uSectUsage = 0;
  var sectUsage, nxW, i, aEl;
  for ( i=0; i<=uInx; i++ ) { 
    aEl=iAEl[i];
    nxW = aEl.childNodes[0].childNodes[0].offsetWidth;
    if ( ( i === 0 ) || ( i === uInx ) ) {
      sectUsage = nxW / (deltaX/2);
      // aS +=  ' A sectUsage:' + sectUsage + ' nxW:' + nxW + 'deltaX/2' + deltaX/2 + '\n';   
      }
    else {
      sectUsage = nxW / deltaX;
      // aS +=  ' B sectUsage:' + sectUsage + ' nxW:' + nxW + 'deltaX' + deltaX + '\n';   
      }
    if ( uSectUsage < sectUsage ) {
      uSectUsage = sectUsage;      
      }
    }
  // aS +=  ' uSectUsage:' + uSectUsage;   
  return uSectUsage;
  };
TOwin.prototype.barColmWidthSet = function( iDiv, iSizeDiv ) {
  var aOwin = this;
  var tdEl = iDiv;
  var AEl = [];
  var nxEl;
  var aS;
  for ( var j=0; nxEl=iDiv.childNodes[j++]; ) {
    if ( nxEl.nodeType === 1 ) {
      AEl[ AEl.length ] = nxEl;
      }
    }
  // remove any modifications
  if ( AEl !== [] ) {
    while ( tdEl.tagName != "TD" ) { tdEl = tdEl.parentNode; }
    var divEls = tdEl.getElementsByTagName( "DIV" );
    var i,aEl,width;
    for ( i=0; ( aEl=AEl[i++] ); ) { 
      if ( aEl.childNodes ) { // exclude possible text nodes
        aEl.childNodes[0].style.display = 'block';
        }
      }
    iSizeDiv.style.width = "100%";
    // determine max scale section usage/overuse
    var usage = aOwin.getSectUsage( AEl );
    // alert( 'usage:' + usage );
    // keep usage < 0.8 by droping alternate markers OR expanding total size
    if ( usage > 1.6 ) { // need to expand total width
      // alert( "iSizeDiv.offsetWidth:" + iSizeDiv.offsetWidth + " to " + iSizeDiv.offsetWidth * ( usage/1.6 ) );
      iSizeDiv.style.width = "" + ( iSizeDiv.offsetWidth * ( usage/1.6 ) ) + "px";
      // alert( "new iSizeDiv.offsetWidth:" + iSizeDiv.offsetWidth + " iSizeDiv.style.width " + iSizeDiv.style.width);
      }
    if ( usage > 0.8 ) { // remove alternate scale markings
      for ( i=0; ( aEl=AEl[i++] ); ) { 
        if ( ( i % 2 ) === 0 ) {
          aS = getInnerText( aEl.childNodes[0] );
          if ( ( aS !== "0" ) && ( aS !== "*" ) ) { // leave 0 and *
            aEl.childNodes[0].style.display = 'none';
            }
          }
        }
      }
    }
  };
TOwin.prototype.evtDragOver = function() {
  var iOwin = this;
  iOwin.evt.returnValue = false;
/*
  defaultStatus = 'dragOver' + iOwin.evt.dataTransfer.getData("URL") + ' ' 
  // + iOwin.evt.dataTransfer.getData("TEXT") 
  + iOwin.evt.srcElement.tagName 
  + ' ' + iOwin.evt.srcElement.innerHTML;
*/
  };
TOwin.prototype.nsfDateFix = function nsfDateFix() {
  var iOwin = this;
  var parEl, el, subEl, i;
  var inxCal = 0;
  var els = document.getElementsByName( 'nameDate' );
  for ( var inx=0; inx<els.length; inx++ ) {
    el = els[ inx ];
    parEl = el.parentNode;
    for ( i=0; i<parEl.childNodes.length; i++ ) {
      subEl = parEl.childNodes[i];
      if ( subEl.tagName == 'INPUT' ) {
        if ( subEl.type == 'text' ) {
          inxCal++;
          cals[ inxCal ] = new calendar1( subEl );
          el.href = 'javascript:cals[' + inxCal + '].popup();';
          }
        }
      }
    }
  };
TOwin.prototype.getOein = function getOein( iInstKtjS, iInstS, iNewB ) {
  var iOwin = this;
  var einKeyS = iInstKtjS + iInstS;
  var aOein = iOwin.AOein[ einKeyS ];
  if ( ! aOein ) {
    if ( iNewB === true ) {
      aOein = new TOein( iInstKtjS, iInstS );
      iOwin.AOein[ einKeyS ] = aOein;
      }
    else { aOein = null; }
    }
  return aOein;
  };
/* *********************** edit related */
TOwin.prototype.doCheck = function() {
  var aOwin = this;
  var s = '';
  var edsub = aOwin.submitStr();
  var efStr = edsub.combStr;
  if ( gParId !== '' ) { s = '&par=' + gParId + s; }
  // aOwin.startCheck( efStr, '', gParId, gQbKey );
  var aOpid = new TOpid();
  aOpid.decode( gParId );
  // aOwin.startCheck( efStr, '', aOpid, gQbKey );
  var aOreq = new TOreq( aOwin );
  aOreq.Kreq = gKreqCheck;
  aOreq.urlS = document.location.href.split("?")[0];
  aOreq.efS = efStr;
  aOreq.qbKey = gQbKey;
  aOreq.Opid = aOpid;
  aOreq.Kpt = gKptReplace;
  aOreq.issue(); 
  };
//
// Abort edit button,onclick
TOwin.prototype.doAbort = function() {
  var aOwin = this;
  if ( gParId !== '' ) { 
    if ( window.opener ) { 
      var w = window.opener;
      w.gModWin = null;
      }
    window.close();
    }
  else {
    document.location.replace( '/common/cancelEdit.html' );
    if ( history.length > 0 ) { 
      history.go(-1); }
    else {
      if ( window.opener ) { window.close(); }
      }
    }
  };
TOwin.prototype.doCommit = function() {
  var aOwin = this;
  var s = '';
  var edsub;
  if ( gParId !== '' ) { // subwindow commit 
    edsub = aOwin.submitStr( );
    if ( edsub.checkB === true ) { // red or yellow stuff
      // alert( 'edEvtCommit-1 edsub.checkB ' + edsub.checkB 
      // + 'combStr' + edsub.combStr );
      defaultStatus = 'Checking prior exit';
      s = '&par=' + gParId + '&ef=' + edsub.combStr + '&mf=' + edModeFlags();
      gOjax.asDoQs( '?op=cko', '', s );
      }
    else {
      // alert( 'edEvtCommit-2 edsub.checkB ' + edsub.checkB 
      // + 'combStr' + edsub.combStr + 'gInstName' + gInstName );
      aOwin.childCommit( gInstName );
      }
    }
  else { 
    edsub = aOwin.submitStr();
    var efStr = edsub.combStr;
    if ( gParId !== '' ) { s = '&par=' + gParId + s; }
    s = '&ef=' + efStr + '&mf=' + edModeFlags();
    gOjax.asDoQs( '?op=cmt', '', s );
    }
  };
TOwin.prototype.submitStr = function( iOwig, iNameS ) {
  var aOwin = this;
  var aS;
  var edsub = new Object();
  edsub.checkB = false;
  edsub.combStr = '';
  edsub.efStr = '';
  // for each object
  edsub.moreOjB = true;
  edsub.inxG = 0;
  while( edsub.moreOjB === true ) {
    edsub.curHojS = '';
    aS = aOwin.submitHoj( edsub ); // get next HOj and return ef terms
    if ( aS !== '' ) {
      var aOeih = new TOeih();
      if ( iOwig ) {
        aOeih.decode( iOwig.abIdS );
        aOeih.nameS = iNameS;
        // preambS = iOwig.abIdS + 'X(' + encodeURIComponent( iNameS ) + ')';
        }
      else {
        // preambS = '0X' + edsub.curHojS + 'X' + '0X0X0X'+ edsub.curHojS + 'X(subjectInstance)';
        aOeih.paHojS = edsub.curHojS;
        aOeih.subjHojS = edsub.curHojS;
        aOeih.nameS = 'subjectInstance';
        // aa = bb /cc;
        }
      edsub.combStr += '(n' + aOeih.encode(true) + aS + 'n)';
      // alert( "A aOeih.encode(true):" + aOeih.encode(true) );
      }
    }
  return edsub;
  };
TOwin.prototype.pageButsPerState = function pageButsPerState() {
  var aOwin = this;
  aOwin.pageStats();
/*
  EdLog( "aOwin.groupN:" + aOwin.groupN
  + " aOwin.swChangeCnt:" + aOwin.swChangeCnt
  + " aOwin.changeCnt:" + aOwin.changeCnt
  + " aOwin.missMandCnt:" + aOwin.missMandCnt
  );
*/
  if ( aOwin.groupN > 1 ) {
    var aButS = 'Check';
    if ( aOwin.swChangeCnt > 0 ) { aButS = 'Continue'; }
    var aChkEls = document.getElementsByName( 'EdSubmit0' );
    for ( var i=0;i<aChkEls.length;i++ ) {
      var chkEl = aChkEls[i];
      chkEl.value = aButS;
      chkEl.disabled = ( aOwin.changeCnt === 0 );
      }
    // 
    var submitEnableB = ( aOwin.changeCnt > 0 ) && ( aOwin.missMandCnt === 0 );
    aOwin.pageButUpdate( ( aOwin.swChangeCnt === 0 ), submitEnableB );
    //
    }
  };
TOwin.prototype.pageButUpdate = function( iDisplayB, iEnableB ) {
  var aOwin = this;
  var submitSpanEl,submitEl,inx;
  var aSubmitEls = document.getElementsByName( 'EdSubmit1' );
  for ( inx=0; submitEl=aSubmitEls[inx++]; ) {
    submitSpanEl = submitEl.parentNode;
    if ( iDisplayB === false ) {
      submitSpanEl.style.display = 'none';
      }
    else {
      submitSpanEl.style.display = 'inline';
      submitEl.disabled = ( ! iEnableB );
      }
    }
  };
TOwin.prototype.submitHoj = function( ioEdSub ) {
  var aOwin = this;
  var elG = null;
  var InxI = 0;
  var aOwig = null;
  var aOwif = null;
  var combS = '';
  ioEdSub.moreOjB = false;
  ioEdSub.efStr = '';
  ioEdSub.eeStr = '';
  var moreB = true;
  // var aS = '';
  while ( moreB === true ) {
    moreB = false;
    // each question, advance ioEdSub.inxG only if for subject instance
    elG = window.document.getElementById( 'idEfG' + (ioEdSub.inxG+1) );
    if ( elG ) {
      aOwig = makeTargOwig( aOwin, elG, true );
      // aS += aOwig.subHojS + '!' + ioEdSub.curHojS + ' ';
      if ( ioEdSub.curHojS === '' ) { ioEdSub.curHojS = aOwig.subHojS; }
      if ( ioEdSub.curHojS !== aOwig.subHojS ) {
        // ioEdSub.curHojS = aOwig.subHojS;
        ioEdSub.moreOjB = true;
        }
      else {
        ioEdSub.inxG++;
        moreB = true;
        }
      }
    if ( moreB === true ) {
      for ( aOwig.fiActOwif(); (aOwif=aOwig.nxActOwif()); ) {
        aOwif.toEf( ioEdSub );
        }
      }
    // alert( elG + ' ' + ioEdSub.inxG + ' moreB ' + moreB 
    // + ' length ' + aOwig.AHwif.length
    // + ' ee ' + ioEdSub.eeStr + ' ef ' + ioEdSub.efStr );
    }
  // assumed only one Ein on file upload pages
  var selEl = document.getElementById( 'idUpSelFile' );
  if ( ( selEl ) && ( selEl.value !== '' ) ) {
    // ioEdSub.efStr += 's' + encodeURIComponent(selEl.value) + '+';
    ioEdSub.efStr += 's' + selEl.value.nsToOjText() + '+';
    }
  if ( ( ioEdSub.efStr !== '' ) || ( ioEdSub.eeStr !== '' ) ) {
    combS = '(f' + ioEdSub.efStr + 'f)';
    if ( ioEdSub.eeStr !== '' ) { combS += '(i' + ioEdSub.eeStr + 'i)'; }
    }
  return combS;
  };
TOwin.prototype.childCommit = function( iInstName ) {
  var aOwin = this;
  var w = null;
  if ( window.opener ) { w = window.opener; }
  else { alert( 'parent window closed' ); }
  if ( w ) {
    var aOpid = new TOpid();
    aOpid.decode( gParId );
    var idGEl = w.document.getElementById( 'idEfG' + aOpid.groupN );
    // alert( "gParId:" + gParId + " aOpid.Exno:" + aOpid.Exno );
    w.EdUpdateFromChild( null, idGEl, aOpid, iInstName, aOwin );
    w.gModWin = null;
    window.close();
    }
  };
TOwin.prototype.formInit = function() {
  var aOwin = this;
  var formEl = document.getElementById( 'idEdForm' );
  if ((formEl) && (formEl.elements)){
	  var inx,aEl,aOwig;
	  for ( inx=0; aEl=formEl.elements[inx++]; ) {
	    if ( ( aEl.id ) && ( aEl.id.substr( 0, 5 ) == 'idEfG' ) ) {
	      aOwig = makeTargOwig( aOwin, aEl, true );
	      // EdLog( aEl.id );
	      aOwig.bldWig( null, -1 );
	      }
	    }
	  aOwin.pageButsPerState( );
	  }
	};
TOwin.prototype.wigNav = function wigNav() {
  var aOwin = this;
  var dataEls = document.getElementsByTagName( 'INPUT' );
  var inx,aEl,aOwig;
  for ( inx=0; aEl=dataEls[inx++]; ) {
    if ( ( aEl.id ) && ( aEl.id.substr( 0, 4 ) == 'idNg' ) ) {
      var aDate = new Date( ).valueOf();
      aOwin.diTime1 = 0;
      aOwin.diTime2 = 0;
      aOwin.diCnt = 0;
      aOwig = makeTargOwig( aOwin, aEl, false ); // full = false
      var bDate = new Date( ).valueOf();
      if ((bDate-aDate)>400) {
        defaultStatus += ',8e(' + (bDate-aDate) + ' diTime:' + aOwin.diTime1 + '/' + aOwin.diTime2
        + ' diCnt:' + aOwin.diCnt;
        }
/*
        defaultStatus += ',8e(' + (bDate-aDate) // + ' ' + (cDate-bDate) + ')'
        + ' a1*:' + (aOwin.a1Date-aDate)
         + ' a2:' + (aOwin.a2Date-aDate)
         + ' a3*:' + (aOwin.a3Date-aDate)
         + ' a4:' + (aOwin.a4Date-aDate)
        }
*/      
      aOwig.bldWig( null, -1 );
      var cDate = new Date( ).valueOf();
      }
    }
  };
//
// select from upload directory list
TOwin.prototype.evtTickImage = function( iS ) {
  var aOwin = this;
  var inx = iS.indexOf( "|" );
  var aFileTypes = iS.substring( 0, inx );
  var aValS = iS.substring( inx+1, iS.length );
  var selectedEl = document.getElementById( 'idUpSelFile' );
  selectedEl.value = aValS;
  // alert( " selectedEl.value:" + selectedEl.value + " iS:" + iS );
  if ( aFileTypes == 'image' ) {
    var aS = '';
    if ( aValS !== '' ) {
      aS = '<img src="/upload/image/' + encodeURIComponent( aValS )
      + '" alt="selected uploaded image"  />';
      }
    var aEl = document.getElementById( 'idUpImage' );
    purge( aEl );
    aEl.innerHTML = aS;
    var butEl = document.getElementById( 'idUpButs' );
    if ( aS === '' ) { butEl.style.display = 'none'; }
    else { butEl.style.display = 'block'; }
    }
  aOwin.pageButsPerState();
  };
TOwin.prototype.bldUploadLine = function( iSelB, iFileTypeS, iValueS, iTextS ) {
  var aOwin = this;
  var selS = '';
  var aS = iFileTypeS + '|' + iValueS;
  if ( iSelB ) { 
    selS = 'checked'; 
    aOwin.evtTickImage( aS );
    }
  aS = '<div><input type="radio" name="upSel"' + '" value="' + aS + '" ' + selS 
  + ' />' + iTextS + '</div>';
  return aS;
  };
TOwin.prototype.pageStats = function() {
  var aOwin = this;
  var aOwig;
  aOwin.changeCnt = 0;
  aOwin.uncheckedCnt = 0;
  aOwin.swChangeCnt = 0;
  aOwin.missMandCnt = 0;
  var selEl = document.getElementById( 'idUpSelFile' );
  if ( ( selEl ) && ( selEl.value !== '' ) ) {
    aOwin.uncheckedCnt++;
    aOwin.changeCnt++;
    }
  var elG = null;
  var moreB = true;
  var inx = 0;
  var SKcip = '';
  aOwin.groupN = 0;
  aOwin.AmmGN = [];
  while ( moreB === true ) {
    aOwin.groupN++;
    elG = window.document.getElementById( 'idEfG' + aOwin.groupN );
    moreB = ( elG !== null );
    if ( moreB === true ) {
//      aOwig = makeTargOwig( aOwin, elG );
      aOwig = new TOwig();
      aOwig.fromIdEl( aOwin, elG, false );
      // inx = elG.value.indexOf( '(' );
      // SKcip = elG.value.substr( 0, inx );
      if ( aOwig.EdKcipChk( aOwig.EKcipMissMand ) === true ) { 
        aOwin.missMandCnt++; 
        aOwin.AmmGN[ aOwin.AmmGN.length ] = aOwin.groupN;
        }
      if ( aOwig.EdKcipChk( aOwig.EKcipChange ) === true ) { 
        aOwin.changeCnt++; 
        }
      if ( aOwig.EdKcipChk( aOwig.EKcipSwChange ) === true ) { 
        aOwin.swChangeCnt++; 
        }
      if ( aOwig.EdKcipChk( aOwig.EKcipUnchecked ) === true ) { 
        aOwin.uncheckedCnt++; 
        }
      }
    }
  // return aOwin;
  };
TOreq.prototype.issue = function() {
  // alert( 'issue' );
  var aOreq = this;
  defaultStatus += 'is';
  var aOwin = aOreq.Owin;
  if ( aOreq.Owif !== null ) {
    aOreq.efS = aOreq.Owif.encodeEin();
    aOreq.Opid = aOreq.Owif.Opid;
    }
  var argS = '&mf=' + edModeFlags() + '&se=' + gSesNoloi 
  + '&kr=' + aOreq.Kreq + '&kpt=' + aOreq.Kpt + aOreq.extraParS;
  if ( aOreq.efS !== "" ) { argS += '&ef=' + aOreq.efS;}
  if ((aOreq.Opid !== null)&&( aOreq.Opid.groupN !== 0 )) { argS += '&par=' + aOreq.Opid.encode(false); }
  if (( aOreq.Kreq === gKreqNew )&&( aOreq.directB === true )) {
    toPageKpt( aOreq.urlS + '?ed='+ gRevision + argS, aOreq.Kpt, "" ); // iParArgS = ""
    // document.location = aOreq.urlS + '?ed='+ gRevision + argS; // leaves 2 of same in history after new
    }
  else if (( aOreq.Kreq === gKreqShow )&&( aOreq.directB === true )) {
    toPageKpt( aOreq.urlS, aOreq.Kpt, "" ); // iParArgS = ""
    // if ( aOreq.Kpt === gKptNewWindow ) { window.open( aOreq.urlS, '_blank' ); }
    // else { document.location.href = aOreq.urlS; }
    }
  else if ( aOreq.directB === true ) {
    toPageKpt( aOreq.urlS + '?ed='+ gRevision + argS, aOreq.Kpt, "" ); // iParArgS = ""
    // leaves 2 of same in history after new
    }
  else if ( gOjax.xh === null ) { // also do this on short urls
    toPageKpt( aOreq.urlS + '?op=chk' + argS, "" ); // iParArgS = ""
    // document.location.replace( aOreq.urlS + '?op=chk' + argS );
    }
  else {
    if ( aOreq.qbKeyS === '' ) { aOreq.qbKeyS = aOwin.allocQbKey(); }
    var bS = '?op=reg&dta=' + aOreq.qbKeyS + '&rUrl=' + aOreq.urlS + '&kpt=' + aOreq.Kpt + '&kr=' + aOreq.Kreq; // + '&se=' + gSesNoloi 
    if ( aOreq.Kreq === gKreqShow ) { bS += '&rOp=show'; }
    else { bS += '&rOp=chk'; }
    if ( aOreq.Opid !== null ) { bS += '&rPar=' + aOreq.Opid.encode(false); }
    gOjax.asDoQs( bS, '', argS );
    }
  };
TOwin.prototype.allocQbKey = function() {
  var aOwin = this;
  var rKey = aOwin.getCookie( 'rKey' ); 
  if ( rKey === '' ) { rKey = '1'; }
  var rKeyN = parseInt( rKey, 10 );
  rKeyN++;
  aOwin.setCookie( 'rKey', rKeyN ); 
  return 'a' + rKey;
  };
function TOreq( iOwin ) {
  var aOreq = this;
  aOreq.urlS = '';
  aOreq.Opid = null;
  aOreq.efS = '';
  aOreq.qbKeyS = '';
  aOreq.Owin = iOwin;
  aOreq.Owif = null;
  aOreq.directB = false;
  aOreq.Kpt = gKptNext;
  aOreq.extraParS = ''; 
  }
TOwin.prototype.fileRemove = function fileRemove( iS, iAllB ) {
  var aOwin = this;
  if ( iAllB === false ) {
    var ufEl = document.getElementById( 'idUpSelFile' );
    if ( ( ufEl ) && ( ufEl.value !== '' ) ) {
      gOjax.asDoQs( '?op=del', '/upManage', '&fty=' + iS 
      + '&dta=' + encodeURIComponent( ufEl.value ) );
      }
    else {
      alert( 'No Image to remove' );
      }
    }
  else {
    gOjax.asDoQs( '?op=del', '/upManage', '&fty=' + iS + '&dta=*' );
    }
  };
/* */
TOwin.prototype.evtUpLoad = function evtUpLoad( iEl ) {
  var aOwin = this;
  if ( aOwin.targEl.tagName == "INPUT" ) {
    var className = aOwin.targEl.className;
    alert( aOwin.targEl.type + " " + aOwin.targEl.name );
    if (( aOwin.targEl.type == "radio" )&&( aOwin.targEl.name == "upSel" )) {
      aOwin.evtTickImage( aOwin.targEl.value );
      }
    }
  };
/* */
TOwin.prototype.evtUpFile = function evtUpFile( iEl, imageB ) {
  var aOwin = this;
  var fileS = iEl.value;
  var extS=fileS.substring(fileS.lastIndexOf(".")+1,fileS.length).toLowerCase();
  var okB = false;
  var i;
  for ( i=0; i<fileTypes.length; i++) {
    if ( fileTypes[i]==extS ) {okB = true;}
    }
  if ( imageB === false ) { okB = ! okB; }
  if ( okB === false ) { 
    if ( imageB === true ) { 
      var aS = '';
      for ( i=0; i<fileTypes.length; i++) {
        aS += fileTypes[i] + ' ';
        }
      alert( 'File types accepted ( ' + aS + ' ).' );
      }
    else {
      alert( 'File types not accepted.' );
      }
    }
  else {
    var aForm = document.forms['UpForm'];
    aForm.submit();
    }
  };	
TOwin.prototype.evtUpKey = function( iEl, imageB ) {
  var aOwin = this;
  var charCode = (aOwin.evt.charCode) ? aOwin.evt.charCode :((aOwin.evt.which) ? aOwin.evt.which :aOwin.evt.keyCode);
  if (charCode == 13 || charCode == 3) { iEl.blur(); }
  };
function decodeHttmAll( iTypeS ) {
  var inx = iTypeS.indexOf( '(' ); 
  var bS;
  // alert( 'decodeHttmAll:' + iTypeS );
  var aOhttms = null;
  if ( inx !== -1 ) {      
    var aOparse = new TOparse( iTypeS.substr( inx ) );
    aOhttms = new TOhttms( aOparse );
    }  
  return aOhttms;
  }
function encodeHttmAll( iTypeS, iOhttms ) {
  var inx = iTypeS.indexOf( '(' ); 
  var aS = iTypeS.substr( 0, inx );
  aS += iOhttms.encode( );
  return aS;
  }
TOhttms.prototype.encode = function( ) {
  var aOhttms = this;
  var aOhttm;
  var aS = '';
  for ( var i=0; (aOhttm=aOhttms.AOhttm[i++]); ) {
    aS += aOhttm.encode();
    }
  return aS;
  };
TOhttm.prototype.encode = function( ) {
  var aOhttm = this;
  var aS = '';
  if (( aOhttm.ttmNoloi !== 0 ) || ( aOhttm.ttmI0sl !== 0 )) {
    aS = '(';
    aS += String.fromCharCode( aOhttm.Kttm + 'b'.charCodeAt(0) );
    aS += aOhttm.ttmNoloi;
    if ( aOhttm.ttmI0sl !== 0  ) {
      aS += 'z' + aOhttm.ttmI0sl;
      }
    if ( aOhttm.subOhttms !== null ) {
      aS += aOhttm.subOhttms.encode();
      }
    else {
      aS += aOhttm.OHoj.encode();
      }
    aS += ')';
    }
  return aS;
  };
function TOhttms( iOparse ) {
  var aOhttms = this;
  var aOhttm, aS, aHojS;
  aOhttms.AOhttm = [];
  aS = iOparse.getChar();
  // alert( 'getOhttms:' + aS );
  while ( aS === '(' ) {   
    aOhttm = new TOhttm( );
    aS = iOparse.getAlpha();
    aOhttm.Kttm = aS.charCodeAt(0) - 'b'.charCodeAt(0);
    aOhttm.ttmNoloi = iOparse.extractN();
    aOhttm.ttmI0sl = 0;
    aS = iOparse.getAlpha();
    // alert( 'aS:' + aS + ' iOparse.S:' + iOparse.S );
    if ( aS === 'z' ) {
        gThisCaseB = true;
      aOhttm.ttmI0sl = iOparse.extractN(); 
        gThisCaseB = false;
      // aS = iOparse.getAlpha();
      }
    // alert( 'iOparse.S.substr( 0,1 ):' + iOparse.S.substr( 0,1 ) );
    if ( iOparse.S.substr( 0,1 ) === '(' ) {
      aOhttm.subOhttms = new TOhttms( iOparse );
      }
    else {
      aHojS = iOparse.getEndBit();
      aOhttm.OHoj = new THoj( aHojS );
      }
    aOhttms.AOhttm[ aOhttms.AOhttm.length ] = aOhttm;
    aS = iOparse.getChar(); // )
    // alert( 'Kttm:' +  aOhttm.Kttm + ' Noloi:' + aOhttm.ttmNoloi 
    // + ' I0sl:' + aOhttm.ttmI0sl + ' aOhttm.hojS:' + aOhttm.hojS
    // + ' aS:' + aS );
    aS = iOparse.getChar(); // (
    }   
  }
function THoj( iHojS ) {
  var aHoj = this;
  aHoj.ojI0sl = 0;
  var aOparse = new TOparse( iHojS );
  var aS = aOparse.S.substr( 0,1 );
  if (( aS >= '0' )&&( aS <= '9' )) {
    aHoj.KoiS = gFactKoi;
    }
  else {
    aHoj.KoiS = aOparse.getChar();
    }
  if ( aHoj.KoiS == gFactKoi ) {
    aHoj.ojNoloi = aOparse.extractN(); 
    aS = aOparse.S.substr( 0,1 );
    if ( aS === 'z' ) { 
      aS = aOparse.getChar();
      aHoj.ojI0sl = aOparse.extractN(); 
      // alert( 'aHoj.ojI0sl:' + aHoj.ojI0sl );
      }
    else { aHoj.ojI0sl = 0; }
    }
  else if ( aHoj.KoiS == gRealKoi ) {
    aHoj.ojReal = aOparse.extractReal(); 
    }
  else if ( aHoj.KoiS == gLitStrKoi ) { 
    aHoj.ojS = aOparse.S.nsFromOjText();
    }
  }
THoj.prototype.encode = function() {
  var aHoj = this;
  var aS = '';
  if ( aHoj.KoiS == gFactKoi ) {
    aS += aHoj.ojNoloi;
    }
  else {
    aS = aHoj.KoiS;
    if ( aHoj.KoiS == gRealKoi ) {
      aS += aHoj.ojReal;
      }
    else if ( aHoj.KoiS == gLitStrKoi ) {
      aS += aHoj.ojS.nsToOjText();
      }
    }
  return aS;
  };
/* ****************** */
function TOhttm( ) {
  var aOhttm = this;
  aOhttm.subOhttms = null;
  }
TOhttm.prototype.toStr = function toStr() {
  var aOhttm = this;
  var aS = String.fromCharCode( aOhttm.Kttm + - 'a'.charCodeAt(0) );
  aS += aOhttm.ttmNoloi;
  if ( aOhttm.ttmI0sl !== 0  ) {
    aS += 'z' + aOhttm.ttmI0sl;
    }
  aS += aOhttm.hojS;
  return aS;
  };
/* ****************** instance */
function TOein( iInstKtjS, iHojS ) {
  var aOein = this;
  aOein.instKtjS = iInstKtjS;
  aOein.HojS = iHojS;
  aOein.AOprf = []; // pot references
  }
/* ****************** potential group */
function TOpog( ) {
  var aOpog = this;
  aOpog.AOwif = [];
  }
/*
TOpog.prototype.getPogOwif = function getPogOwif( iHojS, iEinS ) {
  var iOpog = this;
  var i, aOwif;
  var rOwif = null;
  for ( i=0; (aOwif=iOpog.AOwif[i++]); ) {
    if (( aOwif.Opid.hojS == iHojS )&&( aOwif.Opid.einS == iEinS )) {
      rOwif = aOwif;
      }
    }
  return rOwif;
  };
*/
/* ******************************* */ 
// function html2entities(){
// var re=/[(<>"'&]/g
// for (i=0; i<arguments.length; i++)
// arguments[i].value=arguments[i].value.replace(re, function(m){return replacechar(m)})
// }
var gAesc =  [ 'e', 'o', 'c', 'q' ,'u' , 'w', 'x', 'y', 'z', 's' , 'm', 'p', 'b', 'a', 'k', 'r' , 'n', 'd' ];
var gAuesc = [ '!', '(', ')', '?', '\/', 'W', 'X', 'Y', 'Z', '\'', '&', '%', ' ', '+', ':', '\r', '\n', '\\' ];
var gEscS = gAesc.join('');
var gUescS = gAuesc.join('');
String.prototype.nsToOjText = function () {
  var iS = this;
  var re = new RegExp( '[' + gUescS + '\\]', "g" );
  var aS = iS.replace( re, function(m) { return '!' + gAesc[gUescS.indexOf(m)]; } );
  return aS;
  };
String.prototype.nsFromOjText = function nsFromOjText() {
  var iS = this;
  var re = new RegExp( /!./g );
  var aS = iS.replace( re, function(m) { return gAuesc[gEscS.indexOf(m.substring(1,2))]; } );
  return aS;
  };
String.prototype.edHtmlEsc = function edHtmlEsc() {
  var iS = this;
  var aS = iS;
  var re = /"/g;
  aS = aS.replace(re, "&quot;");
  re = /'/g;
  aS = aS.replace(re, "&#39;");
  re = /</g;
  aS = aS.replace(re, "&lt;");
  re = />/g;
  aS = aS.replace(re, "&gt;");
  return aS;
  };
String.prototype.EdBugEinDecodeS = function EdBugEinDecodeS( iIndent ) {
  function EdBoxVal( iChar, iS ) { 
    if ( iS.substr( 0, 1 ) != iChar ) {
      alert( 'EdBoxVal incorrect bracketing char:' + iChar + ' data:' + iS );
      }
    return iS.substr( 1, iS.length-2 );
    }
  var iS = this;
  var SS, bSS, cSS;
  var bS, cS, dS;
  var i;
  var oS = "";
  var inx = iS.indexOf( '(' );
  var preS = iS.substr( 0,inx );
  oS += EdBugSol( iIndent ) + 'preS(ident of question):' + preS;
  oS += EdBugSol( iIndent+1 ); 
  bSS = preS.split( 'X' );
  for ( i=0;i<bSS.length-1;i++ ) {
    oS += ' [' + i + ']'; 
    if ( i === 0 ) { oS += "ord:"; }
    if ( i === 1 ) { oS += "oj1:"; }
    if ( i === 2 ) { oS += "ref:"; }
    if ( i === 3 ) { oS += "b?:"; }
    if ( i === 4 ) { oS += "type:"; }
    if ( i === 5 ) { oS += "inst:";}
    oS += bSS[i];
    }
  dS = "";
  cSS = null;
  SS = iS.EdSplitBrack();
  for ( i=0;i<SS.length;i++ ) {
    oS += EdBugSol( iIndent ) + '[' + i + ']';
    if ( i === 0 ) { 
      oS += "name:" + SS[i]; 
      }
    else if ( i === 1 ) { 
      oS += "efs:" + EdBoxVal( 'f', SS[i]).EdBugEfsDecodeS( iIndent );
      }
    else { 
      oS += "subEins:" + SS[i]; 
      bS = EdBoxVal( 'i', SS[i] );
      // oS += "/n bS:" + bS;
      bSS = bS.EdSplitBrack();
      for ( var iB=0;iB<bSS.length;iB++ ) {
        cS = EdBoxVal( 'j', bSS[iB] );
        // oS += "/n cS:" + cS;
        cSS = cS.EdSplitBrack();
        for ( var iC=0;iC<cSS.length;iC++ ) {
          dS = EdBoxVal( 'n', cSS[iC] );
          // oS += "/n dS:" + dS;
          oS += dS.EdBugEinDecodeS( iIndent+2 );
          }
        }
      }
    }
  return oS;
  };
String.prototype.EdBugEfsDecodeS = function EdBugEfsDecodeS( iIndent ) {
  var iS = this;
  var cSS;
  var oS = "";
  var aS = "";
  var bS = "";
  var inx = 0;
  var bSS = iS.split( '+' );
  for ( var i=0;i<bSS.length-1;i++ ) {
    oS += EdBugSol( iIndent ) + '[' + i + ']:';
    aS = bSS[i];
    bS = aS.substr( 0, 1 );
    if ( bS === 's' ) { 
      oS += ' file, '; 
      aS += aS.substr( 1, aS.length-1 );
      oS += ' fileName:' + aS; 
      }
    else {
      if ( bS === 'f' ) { oS += ' not, '; }
      else if ( bS === 't' ) { oS += ' is, '; } 
      bS = aS.substr( 1, 1 );
      if ( bS === 'f' ) { oS += ' new, '; } 
      else if ( bS === 't' ) { oS += ' existing, '; } 
      aS = aS.substr( 2, aS.length-2 );
      cSS = aS.split( '!' );
      oS += 'Oj:' + cSS[0];
      aS = cSS[1];
      // oS += 'Rest:' + aS;
      inx = aS.indexOf( '(' );
      bS = aS.substr( 0,inx );
      oS += " type:" + bS;
      cSS = aS.EdSplitBrack();
      for ( var j=0;j<cSS.length;j++ ) {
        oS += EdBugSol( iIndent+1 ) + " httm:" + cSS[j].EdBugHttmToS( iIndent+1 );
        }
      }
    }
  return oS;
  };
String.prototype.EdBugHttmToS = function EdBugHttmToS( iIndent ) {
  var iS = this;
  var aS = iS;
  var bS = "";
  var InxX = aS.indexOf( 'x' );
  if ( InxX != -1 ) {
    bS += " x:" + aS.substr( 0, InxX );
    aS = aS.substr( InxX, aS.length-InxX );
    }
  var InxZ = aS.indexOf( 'z' );
  if ( InxZ != -1 ) {
    bS += " z:" +  aS.substr( 0, InxZ );
    aS = aS.substr( InxZ, aS.length-InxZ );
    }
  var InxBrac = aS.indexOf( '(' );
  if ( InxBrac != -1 ) {
    bS += " brac:" +  aS.substr( 0, InxBrac );
    aS = aS.substr( InxBrac, aS.length-InxBrac );
    }
  bS += " rest:" + aS;
  return bS;
  };
String.prototype.EdWikiString = function EdWikiString() {
  var iS = this;
  var aS = '';
  var bS = '';
  var inx = 0;
  var SS = iS.split( '\n' );
  for (inx=0; bS=SS[inx++]; ) {
    if( bS.substr( 0,1) === ' ' ){ bS = bS.substr( 1,bS.length-1); }
    aS += bS;
    if ( inx != ( SS.length ) ) { aS += "\r"; }
    }
  return aS;
  };
String.prototype.EdSplitBrack = function EdSplitBrack() {
  var iS = this;
  var ss = new Array();
  var aS = iS;
  var aCnt = 0;
  var startB = false;
  var cS = '';
  var bS = '';
  var inx=0;
  while ( aS !== '' ) {
    var inx1 = aS.indexOf( '(' );
    var inx2 = aS.indexOf( ')' );
    var oC = '';
    if ( ( inx1 != -1 ) && ( inx1 < inx2 ) ) {
      inx = inx1;
      oC = '(';
      aCnt++;
      }
    else {
      inx = inx2;
      if ( inx != -1 ) { 
        oC = ')';
        aCnt--;
        }
      }
    if ( oC === '' ) {
      bS = aS;
      aS = '';
      }
    else {
      bS = aS.substr( 0, inx );
      aS = aS.substr( inx+1, aS.length-inx );
//      alert( 'split ' + bS + '|' + aS );
      } 
    if ( startB ) {
      cS = cS + bS;
      if ( aCnt < 1 ) {
        ss[ ss.length ] = cS;
        cS = '';
        startB = false;
        }
      else { 
        cS = cS + oC;
        }
      }
    else { startB = ( aCnt == 1 ); }
    }
  return ss;
  };
function TOparse( iS ) {
  var iOparse = this;
  iOparse.S = iS;
  }
TOparse.prototype.extractN = function() {
  var iOparse = this;
  var doneB = false;
  var aS = "0";
  var cS;
  var inx = 0;
  while ( doneB === false ) {
    cS = iOparse.S.substr( inx, 1 );
    doneB = ( ( cS < "0" )||( cS > "9" ) ) && ( cS !== "-" );
    if ( doneB === false ) { 
      inx++;
      aS += cS;
      }
    }
  iOparse.S = iOparse.S.substr( inx );
  return parseInt( aS, 10 );
  };
TOparse.prototype.extractReal = function() {
  var iOparse = this;
  var doneB = false;
  var aS = "0";
  var cS;
  var inx = 0;
  while ( doneB === false ) {
    cS = iOparse.S.substr( inx, 1 );
    doneB = ( ( cS < "0" )||( cS > "9" ) ) && ( cS !== "-" ) && ( cS !== "." );
    if ( doneB === false ) { 
      inx++;
      aS += cS;
      }
    }
  iOparse.S = iOparse.S.substr( inx );
  return parseFloat( aS );
  };
TOparse.prototype.extractY = function extractY() {
  var iOparse = this;
  var doneB = false;
  var aS, cS, aN;
  cS = iOparse.getAlpha();
  if ( cS === "Y" ) {
    aN = iOparse.extractN();
    cS = iOparse.getAlpha();
    aS = iOparse.S.substr( 0, aN );
    iOparse.S = iOparse.S.substr( aN );
    }
  else { aS = ""; }
  return aS;
  };
TOparse.prototype.getAlpha = function() {
  var iOparse = this;
  var cS = iOparse.S.substr( 0, 1 ); 
  if ( cS > "9" ) { 
    iOparse.S = iOparse.S.substr( 1 );
    }
  else { cS = ""; }
  return cS;
  };
TOparse.prototype.getChar = function() {
  var iOparse = this;
  var cS = iOparse.S.substr( 0, 1 ); 
  iOparse.S = iOparse.S.substr( 1 );
  return cS;
  };
TOparse.prototype.getEndBit = function() {
  var iOparse = this;
  var inx = iOparse.S.indexOf( ')' ); 
  var aS = iOparse.S.substr( 0, inx ); 
  iOparse.S = iOparse.S.substr( inx );
  return aS;
  };
var gOjax = new TOjax();
var KUnoMove1 = 1;
gAOkel[ KUnoMove1 ] = new TOkel( 'input', "button", "<<", "zEdUnoMove1", false );
var KUnoMove2 = 2;
gAOkel[ KUnoMove2 ] = new TOkel( 'input', "button", " < ", "zEdUnoMove2", false );
var KUnoMove3 = 3;
gAOkel[ KUnoMove3 ] = new TOkel( 'input', "button", " > ", "zEdUnoMove3", false );
var KUnoMove4 = 4;
gAOkel[ KUnoMove4 ] = new TOkel( 'input', "button", ">>", "zEdUnoMove4", false );
var KCnoAll = 5;
gAOkel[ KCnoAll ] = new TOkel( 'input', "button", " All ", "zCnoAll", false );
var KCnoNone = 6;
gAOkel[ KCnoNone ] = new TOkel( 'input', "button", "None", "zCnoNone", false );
var KCnoDone = 7;
gAOkel[ KCnoDone ] = new TOkel( 'input', "button", "Done", "zCnoDone", false );
var KXnoPageReq = 8;
gAOkel[ KXnoPageReq ] = new TOkel( 'input', "button", "Show", "zXnoPageReq", false );
var KXnoDropClose = 9;
gAOkel[ KXnoDropClose ] = new TOkel( 'input', "button", "Close", "zXnoDropClose", false );
var KXnoActAll = 10;
gAOkel[ KXnoActAll ] = new TOkel( 'input', "button", "Select All", "zXnoActAll", false );
var KXnoPosAll = 11;
gAOkel[ KXnoPosAll ] = new TOkel( 'input', "button", "Select All", "zXnoPosAll", false );
var KXnoActNone = 12;
gAOkel[ KXnoActNone ] = new TOkel( 'input', "button", "Clear All", "zXnoActNone", false );
var KXnoPosNone = 13;
gAOkel[ KXnoPosNone ] = new TOkel( 'input', "button", "Clear All", "zXnoPosNone", false );
var KUnoShow = 14;
gAOkel[ KUnoShow ] = new TOkel( 'input', "button", "Show...", "zUnoShowBut", false );
var KUnoEdit = 15;
gAOkel[ KUnoEdit ] = new TOkel( 'input', "button", "Edit...", "zUnoEditBut", false );
var KUnoClone = 16;
gAOkel[ KUnoClone ] = new TOkel( 'input', "button", "Clone...", "zUnoCloneBut", false );
var KUnoRemove = 17;
gAOkel[ KUnoRemove ] = new TOkel( 'input', "button", "Remove...", "zUnoRemoveBut", false );
var KXnoNew = 18;
gAOkel[ KXnoNew ] = new TOkel( 'input', "button", "New...", "zXnoNewBut", false );
var KEnoRemove = 19;
gAOkel[ KEnoRemove ] = new TOkel( 'input', "button", "Remove...", "zEnoRemoveBut", false );
var KEnoClone = 20;
gAOkel[ KEnoClone ] = new TOkel( 'input', "button", "Clone...", "zEnoCloneBut", false );
var KEnoEdit = 21;
gAOkel[ KEnoEdit ] = new TOkel( 'input', "button", "Edit...", "zEnoEditBut", false );
var KEnoShow = 22;
gAOkel[ KEnoShow ] = new TOkel( 'input', "button", "Show...", "zEnoShowBut", false );
var KToAct = 23;
gAOkel[ KToAct ] = new TOkel( 'input', "button", "Add", "zToAct", false );
var KToPoss = 24;
gAOkel[ KToPoss ] = new TOkel( 'input', "button", "Del", "zToPoss", false );
var KEdNew = 25;
gAOkel[ KEdNew ] = new TOkel( 'input', "button", "New...", "zEdNew", false );
var KXnoDrop = 26;
gAOkel[ KXnoDrop ] = new TOkel( "div", "", "", "zDivXnoDrop", false );
var KUnspec = 27;
gAOkel[ KUnspec ] = new TOkel( "span", "", "", "zUnspec", false );
var KEdMessage = 28;
gAOkel[ KEdMessage ] = new TOkel( "span", "", "", "zEdMessage", false );
var KEmptyEntry = 29;
gAOkel[ KEmptyEntry ] = new TOkel( "input", "text", "", "zEdText", false );
var KEdUspan = 30;
gAOkel[ KEdUspan ] = new TOkel( "span", "", "", "zEdUSpan", false );
var KEnoControl = 31;
gAOkel[KEnoControl]  = new TOkel( "table", "", "", "zEdMultiTable", false );
var KTableHead = 32;
gAOkel[KTableHead]  = new TOkel( "thead", "", "", "", false );
var KTableBody = 33;
gAOkel[KTableBody]  = new TOkel( "tbody", "", "", "", false );
var KTableRow = 34; 
gAOkel[KTableRow]  = new TOkel( "tr", "", "", "", false );
var KTableData = 35; 
gAOkel[KTableData]  = new TOkel( "td", "", "", "", false );
var KUnoCnoControl = 36; 
gAOkel[KUnoCnoControl] = new TOkel( "div", "", "", "", false );
// gAOkel[KUnoCnoControl] = new TOkel( "span", "", "", "", false );
// var KUnoCnoFS = 35; 
// gAOkel[KUnoCnoFS] = new TOkel( "div", "", "", "zUnoFS", false );
var KUnoCnoIP = 37; 
gAOkel[KUnoCnoIP] = new TOkel( "div", "", "", "zXnoInputPar", false );
var KUnoCnoSpanIP = 38; 
gAOkel[KUnoCnoSpanIP] = new TOkel( "span", "", "", "zXnoInputPar", false );
var KUnoCnoPots = 39; 
gAOkel[KUnoCnoPots] = new TOkel( "div", "", "", "", false );
var KXnoListTable = 40;
gAOkel[KXnoListTable] = new TOkel( "table", "", "", "", false );
var KXnoUText = 41;
gAOkel[KXnoUText] = new TOkel( "input", "text", "", "zEdUText", false );
var KTdEnoMove = 42;
gAOkel[KTdEnoMove] = new TOkel( "td", "", "", "zTdEnoMove", false );
var KXnoTypeCount = 43;
gAOkel[ KXnoTypeCount ] = new TOkel( "span", "", "", "zXnoTypeCount", false );
// actions without element
var KCnoSet = -1;
function bomb() { aa = bb / cc; }
function openCallPage(){
  var w= 600;
  var h= 490;
  var LeftPosition=(screen.width)?(screen.width-w)/2:100;
  var TopPosition=(screen.height)?(screen.height-h)/2:100;
  var w = window.open('', 'mywindow','width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition
    +',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=yes,resizable=yes');
  document.WidgetForm.target = 'mywindow';
  document.WidgetForm.submit();
  w.focus();
}