




function showToolTip(_text, width){
  _showToolTip(_text, event.clientX, event.clientY, width);
}
function _showToolTip(_text, x, y, width){
  if (isNaN(width) || width <= 0) {
    width=2000;
  }
  var ttDiv = getDocElm('ToolTipDiv');
  ttDiv.innerHTML = "<table " + (width>=2000?"":"width=" + width) + "><tr><td " + (width>=2000?"nowrap":width) + ">" + _text + "</td></tr></table>"; //.replace(/ /gi, "&nbsp;")
  ttDiv.style.display='block';
  ttDiv.style.width=width;
  ttDiv.style.width=ttDiv.firstChild.clientWidth;
  ttDiv.style.zIndex = 800;

  if (isNull(x) || isNull(y)) {
    reshowToolTip();
  } else {
    _reshowToolTip(x,y);
  }
}

function unhideHeavyComponents(_t){
  if (!isIE()) {
    return;   
  }
  var wVar = "HIDDEN_HEAVY_COMP_"+_t;
  for (var i = 0; !isNull(window[wVar]) && i < window[wVar].length; i++) {
    window[wVar][i].style.visibility = 'visible';
  }
}
function hideHeavyComponents(_t,_obj){
  if (!isIE()) {
    return;
  }
  var compToHide = MenuBar_GetCompToHide();
  if (isNull(compToHide) || compToHide.length == 0) {
    return;
  }
  unhideHeavyComponents(_t);
  var wVar = "HIDDEN_HEAVY_COMP_"+_t;
  var hiddenComp = new Array();
  var objPos = getObjPos(_obj);
  for(var i = 0; i < compToHide.length; i++) {
    var compToCheck = compToHide[i];
    var compPos = getObjPos(compToCheck);
    var res = intersects(compPos.x, compPos.y,
                         compToCheck.clientWidth, compToCheck.clientHeight,
                         objPos.x, objPos.y,
                         _obj.clientWidth, _obj.clientHeight);
    if (res && compToCheck.style.visibility != 'hidden') {
      compToCheck.style.visibility = 'hidden';
      hiddenComp[hiddenComp.length] = compToCheck;
    }
  }
  window[wVar] = hiddenComp;
}

function reshowToolTip() {
  if(event){
    _reshowToolTip(event.clientX, event.clientY);
  }
}

var SCREEN_SHORTCUTS = new Object();
var SCREEN_SHORTCUTS_ENABLED = false;

function adminProcessKeyPress(e) { 
  var evnt = event;
  if (!isNull(e)) { evnt = e; }
  if (isNull(evnt)) {return;}
  var keyName = getKeyName(evnt.keyCode);
  if (evnt.shiftKey==1) {
    keyName = "Shift+" + keyName;
  }
  if (evnt.altKey==1) {
    keyName = "Alt+" + keyName;
  }
  if (evnt.ctrlKey==1) {
    keyName = "Ctrl+" + keyName;
  }
  
  if (!isNull(SCREEN_SHORTCUTS[keyName]) && !isNull(SCREEN_SHORTCUTS[keyName].js)) {
    eval(SCREEN_SHORTCUTS[keyName].js);
    evnt.cancelBubble=true;
    if (!isNull(evnt.preventDefault)) {
      evnt.preventDefault();
    }
    return false;
  }
}
function addShortcut(key, label, js) {
  SCREEN_SHORTCUTS[key] = new Object();
  SCREEN_SHORTCUTS[key].label = label;
  SCREEN_SHORTCUTS[key].js = js;
  if (!SCREEN_SHORTCUTS_ENABLED) {
    SCREEN_SHORTCUTS_ENABLED = true;
    addOnKeyDown(adminProcessKeyPress);
  }
}

function _reshowToolTip(x, y, overX, overY) {
  if (!overX) overX = 0;
  if (!overY) overY = 0;
  
  var ttDiv = getDocElm('ToolTipDiv');
  ttDiv.style.top=y+10+document.body.scrollTop;
  ttDiv.style.left=x+11+document.body.scrollLeft;
  if (ttDiv.clientWidth + parseInt(ttDiv.style.left) - document.body.scrollLeft + 5 > document.body.clientWidth) {
    ttDiv.style.left = x - ttDiv.clientWidth - 2 + document.body.scrollLeft + overX;
  }
  if (ttDiv.clientHeight + parseInt(ttDiv.style.top) - document.body.scrollTop + 5 > document.body.clientHeight) {
    ttDiv.style.top = y - ttDiv.clientHeight - 2 + document.body.scrollTop + overY;
  }
  if (parseInt(ttDiv.style.left) < 0) {
    ttDiv.style.left = 0;
  }
  hideHeavyComponents('ToolTip',ttDiv);
}

function hideToolTip(){
  var ttDiv = getDocElm('ToolTipDiv');
  ttDiv.innerHTML = '';
  ttDiv.style.display='none';
  unhideHeavyComponents('ToolTip');
}
function adminRemovePageHelp(helpUrl,helpTitle,helpW,helpH) {
  getDocElm('PAGE_HELP').style.display='none';
}
function adminSetPageHelp(helpUrl,helpTitle,helpW,helpH) {
  getDocElm('PAGE_HELP_LINK').onclick = function() { showDialog(helpW, helpH, helpUrl, 'parent.hidePopIFrame()', helpTitle, false); return false; };
  document.body.onhelp = getDocElm('PAGE_HELP_LINK').onclick;
  getDocElm('PAGE_HELP').style.display='block';
}
function adminSetPageFlashHelp(helpUrl,helpTitle,helpW,helpH) {
  getDocElm('PAGE_FLASH_HELP_LINK').onclick = function() {
   var d = new Object; d.url=helpUrl;d.width=helpW;d.height=helpH;d.scrollbars=false;d.resizable=false;d.target='FLASH_HELP';d.center=true;
   _showWindow(d).focus();
   return false;
  };
  document.body.onhelp = getDocElm('PAGE_FLASH_HELP_LINK').onclick;
  getDocElm('PAGE_FLASH_HELP').style.display='block';
}
function adminSetEditPageHelp(helpUrl,helpTitle,helpW,helpH) {
  if (!isNull(getDocElm('EDIT_PAGE_HELP_LINK'))) {
    getDocElm('EDIT_PAGE_HELP_LINK').onclick = function() { showDialog(helpW, helpH, helpUrl, 'parent.hidePopIFrame()', helpTitle, false); return false; };
    getDocElm('EDIT_PAGE_HELP').style.display='block';
  }
}
function adminSetTitle(pageTitle) {
  getDocElm('PAGE_TITLE_TEXT').innerHTML = pageTitle;
}
function adminAddTitle(pageTitle) {
  getDocElm('PAGE_TITLE_TEXT').innerHTML += pageTitle;
}

function adminSetTitleImg(imgSrc) {
  if (imgSrc=='') {
    getDocElm('PAGE_TITLE_IMG').innerHTML = '';
  } else {
    getDocElm('PAGE_TITLE_IMG').innerHTML = "<div class='adminTitleImg'><img src='" + imgSrc + "'></div>";
  }
}

function adminGetMessageHeight() { if (getDocElm('PAGE_MESSAGES').style.display=='block') { return getDocElm('PAGE_MESSAGES').offsetHeight + 10;} else { return 0; } }

function adminHideTitle() {getDocElm('PAGE_TITLE').style.display='none';}
function adminShowTitle() {getDocElm('PAGE_TITLE').style.display='block';}

function adminHideAllMessages() {getDocElm('PAGE_MESSAGES').style.display='none';}
function adminShowAllMessages() {getDocElm('PAGE_MESSAGES').style.display='block';}

function adminHideInfo() { getDocElm('PAGE_INFO').style.display='none';}
function adminShowInfo() { getDocElm('PAGE_INFO').style.display='block';}

function adminHideMessage() { getDocElm('PAGE_MESSAGE').style.display='none';}
function adminShowMessage() { getDocElm('PAGE_MESSAGE').style.display='block';}

function adminHideWarnings() { getDocElm('PAGE_WARNINGS').style.display='none';}
function adminShowWarnings() { getDocElm('PAGE_WARNINGS').style.display='block';}

function adminHideErrors() { getDocElm('PAGE_ERRORS').style.display='none';}
function adminShowErrors() { getDocElm('PAGE_ERRORS').style.display='block';}

function adminCheckMessageHR() {
  getDocElm('PAGE_INFO_HR').style.display='none';
  getDocElm('PAGE_MESSAGE_HR').style.display='none';
  getDocElm('PAGE_WARNINGS_HR').style.display='none';
  //err,warning,message,info
  var bSep = false;
  if(getDocElm('PAGE_ERRORS_LIST').innerHTML != ''){
    bSep = true;
  }
  if(getDocElm('PAGE_WARNINGS_LIST').innerHTML != ''){
    if(bSep){
      getDocElm('PAGE_WARNINGS_HR').style.display='block';
    }
    bSep = true;
  }
  if(getDocElm('PAGE_MESSAGE_LIST').innerHTML != ''){
    if(bSep){
      getDocElm('PAGE_MESSAGE_HR').style.display='block';
    }
    bSep = true;
  }
  if(getDocElm('PAGE_INFO_LIST').innerHTML != ''){
    if(bSep){
      getDocElm('PAGE_INFO_HR').style.display='block';
    }
    bSep = true;
  }
}

function adminAddListItem(obj, item) {
  if(obj.childNodes.length==5) {
    obj.style.height=obj.scrollHeight;
    obj.style.overflowY='scroll';
  }
  obj.innerHTML = obj.innerHTML + "<li>" + item + '</li>';
  if(obj.childNodes.length>5){
    obj.scrollTop=1000;
  }
}
function adminAddError(errorToAdd) {
  adminShowAllMessages();
  adminShowErrors();
  adminAddListItem(getDocElm('PAGE_ERRORS_LIST'), errorToAdd);
  adminCheckMessageHR();
}
function adminAddInfo(intoToAdd) {
  adminShowAllMessages();
  adminShowInfo();
  adminAddListItem(getDocElm('PAGE_INFO_LIST'), intoToAdd);
  adminCheckMessageHR();
}
function adminAddMessage(intoToAdd) {
  adminShowAllMessages();
  adminShowMessage();
  adminAddListItem(getDocElm('PAGE_MESSAGE_LIST'), intoToAdd);
  adminCheckMessageHR();
}
function adminAddWarning(warnToAdd) {
  adminShowAllMessages();
  adminShowWarnings();
  adminAddListItem(getDocElm('PAGE_WARNINGS_LIST'), warnToAdd);
  adminCheckMessageHR();
}
function adminHideMessagesIfClear() {
  if (getDocElm('PAGE_ERRORS_LIST').innerHTML == ''
   && getDocElm('PAGE_WARNINGS_LIST').innerHTML == ''
   && getDocElm('PAGE_MESSAGE_LIST').innerHTML == ''
   && getDocElm('PAGE_INFO_LIST').innerHTML == '') {
    adminHideAllMessages();
  }
}
function adminClearMessages() {
  adminClearErrors();
  adminClearWarnings();
  adminClearMessage();
  adminClearInfo();
  adminHideMessagesIfClear();
}

function adminClearErrors() {PAGE_ERRORS_LIST.innerHTML = '';adminHideErrors();adminHideMessagesIfClear();}
function adminClearWarnings() {PAGE_WARNINGS_LIST.innerHTML = '';adminHideWarnings();adminHideMessagesIfClear();}
function adminClearMessage() {PAGE_MESSAGE_LIST.innerHTML = '';adminHideMessage();adminHideMessagesIfClear();}
function adminClearInfo() {PAGE_INFO_LIST.innerHTML = '';adminHideInfo();adminHideMessagesIfClear();}

function adminUpdateElement(divId, inHTML) {
  var elm = getDocElm(divId);
  if (!isNull(elm)) {
    elm.innerHTML = inHTML;
  }
}

function doAction() {}
function doSave(p, p2){return doAction("SAVE",p,p2,false);}
function doDelete(actionParam, actionParam2, checkChanges) {return doAction("DELETE", actionParam, actionParam2, checkChanges);}
function doAjaxDelete(actionParam, actionParam2, checkChanges) {return doAjaxAction("DELETE", actionParam, actionParam2, checkChanges);}
function doAddNote(actionParam, actionParam2, checkChanges) {return doAction("ADD_NOTE", actionParam, actionParam2, checkChanges);}
function doAjaxAddNote(actionParam, actionParam2, checkChanges) {return doAjaxAction("ADD_NOTE", actionParam, actionParam2, checkChanges);}
function doObjDelete(actionParam, actionParam2, checkChanges) {return doAction("OBJDELETE", actionParam, actionParam2, checkChanges);}
function doAjaxObjDelete(actionParam, actionParam2, checkChanges) {return doAjaxAction("OBJDELETE", actionParam, actionParam2, checkChanges);}

function doAjaxObjDelete2(actionParam, actionParam2, checkChanges) {return doAjaxAction("OBJDELETE2", actionParam, actionParam2, checkChanges);}

function doActionOnEnter(event, prm1, prm2, prm3, prm4) {
  var iKeycode = getEventKeyCode(event);
  if (iKeycode != 13) {
    return true;
  }
  event.cancelBubble=true;
  return doAction(prm1, prm2, prm3, prm4);
}

function doActionSaveScroll(prm1, prm2, prm3, prm4, prm5, prm6) {
  TheForm['z6N'].value = document.body.scrollTop;TheForm['z6M'].value = document.body.scrollLeft;
  return doAction(prm1, prm2, prm3, prm4, prm5, prm6);
}

function doRefresh(p, p2){return doAction("LAST",p,p2,false);}

function adminClearBody() {
  getDocElm('PAGE_BODY').innerHTML='';
}

function adminClearScreen() {
  adminClearBody();
  adminHideTitle();
  adminHideAllMessages();
}

function adminSetBodyStyle(st) {
  getDocElm('PAGE_BODY').className = st;
}

var ADMIN_CHECK_PAGE_CHANGES=null;
function adminCheckPageChanges(bCheck) {
  if (bCheck) {
    ADMIN_CHECK_PAGE_CHANGES = checkOnUnload;
  } else {
    ADMIN_CHECK_PAGE_CHANGES = null;
  }
}

function adminIsCheckPageChanges() {
  return ADMIN_CHECK_PAGE_CHANGES != null;
}

var adminNeedsSaving = false;
function adminSetNeedSaving(b) { adminNeedsSaving = b; }

function checkOnUnload(){
  if (isUserLoggedOut()) return;
  var vChanged = adminNeedsSaving || didFormValuesChange(TheForm);
  if (vChanged) {
    event.returnValue = getAlertChangesText();
    return event.returnValue;
  }
}

function adminOnBeforeUnload() {
  var ret = null;
  if (ADMIN_CHECK_PAGE_CHANGES != null) {
    ret = ADMIN_CHECK_PAGE_CHANGES();
  }
  if (!isBlank(ret)) {
    return ret;
  }
}

var ON_BEFORE_SUBMIT = new Array();
function addOnBeforeSubmit(func){
  ON_BEFORE_SUBMIT[ON_BEFORE_SUBMIT.length] = func;
  return ON_BEFORE_SUBMIT.length-1;
}

function adminTheFormOnBeforeSubmit() {
  for (var i = 0; i < ON_BEFORE_SUBMIT.length; i++) {
    ON_BEFORE_SUBMIT[i]();
  }
}

function adminTheFormSubmit() {
  adminTheFormOnBeforeSubmit();
  TheForm.submit();
}

function adminAddOnUnloadHandler() {

  window.onbeforeunload=adminOnBeforeUnload;

}
addOnLoad(adminAddOnUnloadHandler);

var defFormAction = function() {TheForm.submit();}

function runDefAction() {
  return defFormAction();
}

var ActionsToConfirm = new Object();
function beforeDoAction(actionType, extraPrms, extraPrms2, checkChange) {
  if (ActionsToConfirm[actionType]) {
    alert(ActionsToConfirm[actionType]);
  }
}


// ProgressBar

function adminUpdateProgressStatus(total, row, _msg, bShowCount){
  var pageProg = getDocElm('PAGE_PROGRESS');
  var perDone = row*300/total;
  var html = "";

  if (!isNull(pageProg.cancelLabel) && pageProg.cancelLabel != '') {
    html = html + "<table border=0 cellpadding=0 cellspacing=0 height=20><tr><td>";
  }

  html = html + "<table style='border:1px solid gray' width=300 height=20 border=0 cellpadding=0 cellspacing=0><tr>";
  html = html + "<td bgcolor='#6699CC' width=" + perDone + "></td>";
  if (row < total) {
    html = html + "<td bgcolor='#CCCCCC' width=" + (300-perDone) + "></td>";
  }
  html = html + "</tr></table>";

  if (!isNull(pageProg.cancelLabel) && pageProg.cancelLabel != '') {
    html = html + "</td><td><input type='button' value='" + pageProg.cancelLabel + "' onclick='" + pageProg.cancelJs + "'>";
    html = html + "</td></tr></table>";
  }

  var msgToAdd = "";
  if (!isNull(_msg)) {
    msgToAdd = _msg;
  }

  if (bShowCount) {
    msgToAdd = msgToAdd + ' ' + row + '/' + total;
  }
  html = msgToAdd + html;

  getDocElm('PROG_BAR_BODY').innerHTML = html;
}

function adminGenerateProgressDiv(msg) {
  var html  = "<div id='PROG_BAR_TABLE'><table width='100%' height='70%'><tr><td align='center's valign='middle'>";
      if (!isNull(msg) && msg != '') {
        html += "<b>";
        html += msg;
        html += "</b><br>&nbsp;<br>";
      }
      html += "<div id='PROG_BAR_BODY'></div></td></tr></table>";
  return html;
}

function adminShowProgress(msg, cancelLabel, cancelJs) {
  var pageProg = getDocElm('PAGE_PROGRESS');
  pageProg.cancelLabel = cancelLabel;
  pageProg.cancelJs = cancelJs;
  pageProg.innerHTML = adminGenerateProgressDiv(msg);
  pageProg.style.display='block';
  getDocElm('PAGE_BODY').style.display = 'none';
}

function adminHideProgress() {
  if ( !isNull(getDocElm('PAGE_PROGRESS'))) {
    getDocElm('PAGE_PROGRESS').innerHTML = '';
    getDocElm('PAGE_PROGRESS').style.display='none';
    getDocElm('PAGE_BODY').style.display = 'block';
  }
}

// end progress bar

function adminRedirect(_url){
  window.location=_url;
}

function adminTogleBoxState(boxId) {
  boxSt = TheForm['BxSt' + boxId].value;
  helpId = TheForm['BxHlp' + boxId].value;
  if (boxSt == 1) {
    TheForm['BxSt' + boxId].value=0;
    getDocElm('BxBody' + boxId).style.display='none';
    getDocElm('BxImg' + boxId).src='/images/InfoBox_Maximize.gif';
    saveScreenLayoutInfo('BOX_STATE_' + helpId, 'MIN');
  } else {
    TheForm['BxSt' + boxId].value=1;
    getDocElm('BxBody' + boxId).style.display='block';
    getDocElm('BxImg' + boxId).src='/images/InfoBox_Minimize.gif';
    saveScreenLayoutInfo('BOX_STATE_' + helpId, 'MAX');
  }
  _MenuBar_AdjustToBottom();
  return false;
}

function adminMinimizeAllBoxes() {
  for (var i = 0; i < TheForm.elements.length; i++) {
    var nm = TheForm.elements[i].name;
    if (!isNull(nm) && nm.indexOf('BxHlp') == 0) {
      boxId = nm.substring(5);
      helpId = TheForm['BxHlp' + boxId].value;
      TheForm['BxSt' + boxId].value=0;
      getDocElm('BxBody' + boxId).style.display='none';
      getDocElm('BxImg' + boxId).src='/images/InfoBox_Maximize.gif';
      saveScreenLayoutInfo('BOX_STATE_' + helpId, 'MIN');
    }
  }
  return false;
}

function saveUserPref(pref,value){
 var xmlHttp = getXmlHttp();
 window.rnd = r = window.rnd ? window.rnd+1 : 1;
 xmlHttp.open('POST','/ta/Default.admin?@NoBody=1&@SetUserPref=1&rnd='+r,true);
 var postData = 'PrefName='+escapeStr(pref)+'&PrefValue='+escapeStr(value);
 xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
 xmlHttp.send(postData);
}

function saveScreenLayoutInfo(pref,value){
 var xmlHttp = getXmlHttp();
 window.rnd = r = window.rnd ? window.rnd+1 : 1;
 xmlHttp.open('POST','/ta/Default.ajax?rnd=HDCONKRM&@impl=zeyt.ui.screen.AjaxControl_SaveTabbedLayoutInfo&@windowId=FWPMQ&@showStackMB=0&@pushOnStack=0&@noBG=1&@showMB=1'+r,true);
 var postData = 'PrefName='+escapeStr(pref)+'&PrefValue='+escapeStr(value);
 var tabFormName = 'z8G';
 if (!isNull(TheForm[tabFormName])) {
  postData +='&' + tabFormName + '=' + TheForm[tabFormName].value;
 }
 xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
 xmlHttp.send(postData);
}

function changeTab(controlId, tabNum,chkChanges) {
 if (chkChanges) {
   var vChanged = adminNeedsSaving || didFormValuesChange(TheForm);
   if (vChanged) {
     doAjaxAction('CHANGE_TAB_PRESAVE:' + controlId, tabNum);
     return;
   }
 } 
 return doAction('CHANGE_TAB:' + controlId, tabNum);
}
 
function Title_AdjustToTop(obj) {
  if (titleFloating) {
    setTimeout("_Title_AdjustToTop()", 10);
    _Title_AdjustToTop();
  }
}

function _Title_AdjustToTop() {
  obj = getDocElm('PAGE_TITLE');
  obj.style.position = 'absolute';
  befObj = getDocElm('BEFORE_TITLE');
  befObj.style.display='block';
  befObj.style.height=parseInt(obj.clientHeight)+3;
  var border = 1;
  
   obj.style.top = 0;
   obj.style.position='fixed';
   obj.style.width=document.body.clientWidth-23;
   obj.style.bottom='auto';
   return;
  
  obj.style.left = border+document.body.scrollLeft+1;
  obj.style.width = Math.max(document.body.clientWidth-4*border,5);
  obj.style.top = document.body.scrollTop;
  _Title_CheckCompToHide();
}

function _Title_CheckCompToHide() {
  obj = getDocElm('PAGE_TITLE');
  compToHide = MenuBar_GetCompToHide();
  if (isNull(compToHide) || compToHide.length == 0) {
    return;
  }
  if (isNull(obj)) {
    return;
  }
  for (var i = 0; !isNull(window["TITLE_HIDDEN"]) && i < window["TITLE_HIDDEN"].length; i++) {
    window["TITLE_HIDDEN"][i].style.visibility = 'visible';
  }

  var hiddenComp = new Array();
  var objPos = getObjPos(obj);
  for(var i = 0; i < compToHide.length; i++) {
    var compToCheck = compToHide[i];
    var compPos = getObjPos(compToCheck);
    var res = intersects(compPos.x, compPos.y,
                         compToCheck.clientWidth, compToCheck.clientHeight,
                         objPos.x, objPos.y,
                         obj.clientWidth, obj.clientHeight);
    if (res) {
      compToCheck.style.visibility = 'hidden';
      hiddenComp[hiddenComp.length] = compToCheck;
    }
  }
  window["TITLE_HIDDEN"] = hiddenComp;
}

var titleFloating = false;
var floatingFuncsAttached = false;
function floatPageTitle(bSave) {
 var title = getDocElm('PAGE_TITLE');
 if (isNull(title)) {
    return;
 }
 if (titleFloating) {
   if (bSave) {
     saveUserPref('SCROLL_TITLE', 0);
   }
   titleFloating=false;
   title.style.position = 'relative';
   title.style.left = title.oldleft;
   title.style.top = title.oldtop;
   title.style.width = '100%';
   title.style.margin = title.oldmargin;
   befObj = getDocElm('BEFORE_TITLE');
   befObj.style.display='none';
 } else {
   if (bSave) {
     saveUserPref('SCROLL_TITLE', 1);
   }
   titleFloating=true;
   title.oldmargin = title.style.margin;
   title.oldtop = title.style.top;
   title.oldleft = title.style.left;
   title.style.margin = '0px';
   if (!floatingFuncsAttached) {
     addOnScroll(Title_AdjustToTop);
     addOnResize(Title_AdjustToTop);
     floatingFuncsAttached=true;
   }
   Title_AdjustToTop();
 }
}


var bSaf = (navigator.userAgent.indexOf('Safari') != -1);
var bOpera = (navigator.userAgent.indexOf('Opera') != -1);
var bMoz = (navigator.appName == 'Netscape');
function execJS(node) {
  var st = node.getElementsByTagName('SCRIPT');
  var strExec;
  for(var i=0;i<st.length; i++) {

    if (bSaf) {
      strExec = st[i].innerHTML;
    } else if (bOpera) {
      strExec = st[i].text;
    } else if (bMoz) {
      strExec = st[i].textContent;
    } else {
      strExec = st[i].text;
    }
    try {
      eval(strExec.split("<!--").join("").split("-->").join(""));
    } catch(e)  {}
  }
}

function execJS2(html) {
 var re = /<script\b[\s\S]*?>([\s\S]*?)<\//ig;
 var match;
 while (match = re.exec(html)) {
  eval(match[1]);
 }
};

var ObjToHighlight = new Array();
var ObjToRemoveHigh = new Array();
function addObjToHighligh(objToH) {
  ObjToHighlight[ObjToHighlight.length] = objToH;
}
function highlightObjs() {
  for (var i = 0; i < ObjToHighlight.length; i++) {
    if (!isNull(ObjToHighlight[i])) {
      highlightObj(null, ObjToHighlight[i]);
    }
    ObjToHighlight[i] = null;
  }
  setTimeout("removeHighlighObjs()", 500);
}

function removeHighlighObjs() {
  for (var i = 0; i < ObjToRemoveHigh.length; i++) {
    if (!isNull(ObjToRemoveHigh[i])) {
      ObjToRemoveHigh[i].style.display='none';
    }
    ObjToRemoveHigh[i] = null;
  }
}

var highlightId = 0;
function highlightObj(options, objToH) {
 var options = options || {};
 var zindex = options.zindex || 50;
 var opacity = options.opacity || 30;
 var opaque = (opacity / 100);
 var bgcolor = options.bgcolor || '#cccccc'; //#ffff66
  var tbody = document.getElementsByTagName("body")[0];
  var tnode = document.createElement('div');

  var tNodeId = 'highlightObj' + (highlightId++);
  tnode.style.position='absolute';
  tnode.style.top=getObjPos(objToH).y + getPageY();
  tnode.style.left=getObjPos(objToH).x + getPageX();
  tnode.style.width=objToH.offsetWidth;
  tnode.style.height=objToH.offsetHeight;
  tnode.style.overflow='hidden';
  tnode.id=tNodeId;
  tbody.appendChild(tnode);
  dark=document.getElementById(tNodeId);
  ObjToRemoveHigh[ObjToRemoveHigh.length] = dark;

  dark.style.opacity=opaque;
  dark.style.MozOpacity=opaque;
  dark.style.filter='alpha(opacity='+opacity+')';
  dark.style.zIndex=zindex;
  dark.style.backgroundColor=bgcolor;
}

function grayOutDef() {
  grayOut(true, {'zindex':'1500', 'bgcolor':'#333333', 'opacity':'55'});
}

function grayOut(vis, options) {
hidePopIFrame();

 var options = options || {};
 var zindex = options.zindex || 50;
 var opacity = options.opacity || 70;
 var opaque = (opacity / 100);
 var bgcolor = options.bgcolor || '#000000';
 var dark=document.getElementById('darkenScreenObject');
 if (!dark) {

  var tbody = document.getElementsByTagName("body")[0];
  var tnode = document.createElement('div');
      tnode.style.position='absolute';
      tnode.style.top='0px';
      tnode.style.left='0px';
      tnode.style.overflow='hidden';
      tnode.style.display='none';
      tnode.id='darkenScreenObject';
      tnode.onclick=function() {};
      
        tnode.addEventListener("click", new Function("event", "event.cancelBubble=true; return false;"), true);
      
  tbody.appendChild(tnode);
  dark=document.getElementById('darkenScreenObject');
 }
 if (vis) {

  if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
   var pageWidth = document.body.scrollWidth+'px';
   var pageHeight = document.body.scrollHeight+'px';
  } else if ( document.body.offsetWidth ) {
    var pageWidth = document.body.offsetWidth+'px';
    var pageHeight = document.body.offsetHeight+'px';
  } else {
    var pageWidth='100%';
    var pageHeight='100%';
  }

  dark.style.opacity=opaque;
  dark.style.MozOpacity=opaque;
  dark.style.filter='alpha(opacity='+opacity+')';
  dark.style.zIndex=zindex;
  dark.style.backgroundColor=bgcolor;
  dark.style.width= pageWidth;
  dark.style.height= pageHeight;
  dark.style.display='block';
 } else {
  dark.style.display='none';
 }

 if (!window.grayOutOnResizeAdded) {
   window.grayOutOnResizeAdded=1;
   addOnResize(resizeGrayConfirm);
 }
 compToHide = MenuBar_GetCompToHide();
 if (isNull(compToHide) || compToHide.length == 0) {
   return;
 }
 for(var i = 0; i < compToHide.length; i++) {
  var compToCheck = compToHide[i];
  if (vis) {
    if (compToCheck.style.visibility=='hidden') {
     continue;
    }
    compToCheck.style.visibility='hidden';
    compToCheck.grayedOut=1;
  } else {
    if (compToCheck.grayedOut!=1) {
     continue;
    }
    compToCheck.style.visibility='visible';
    compToCheck.grayedOut=0;
  }
 }
}

function confirm_done(clrMsgs, clrGray) {
 TheForm['z6I'].value='';
 TheForm['z6J'].value='';
 TheForm['z6K'].value='';
 TheForm['z6G'].value=0;
 if (isNull(clrMsgs)) {
   clrMsgs = true;
 }
 if (isNull(clrGray)) {
   clrGray = true;
 }
 if (clrMsgs) {
   adminClearMessages();
 }
 if (clrGray) {
   grayOut(false);
   var dark=document.getElementById('confirmScreenObject');
   if (dark) {
     dark.innerHTML = '';
     dark.style.display='none';
   }
 }
}

var adminPageAddHTML_NextId=0;
function adminPageAddHtml(html) {
  adminPageAddHTML_NextId++;
  var tbody = TheForm;
  var tnode = document.createElement('div');
      tnode.style.position='absolute';
      tnode.style.top='0px';
      tnode.style.left='0px';
      tnode.style.overflow='hidden';
      tnode.style.display='none';
      tnode.id='adminPageAddHtml_' + adminPageAddHTML_NextId;
  tbody.appendChild(tnode);
  tnode.innerHTML = html;  
  execJS2(html);
}

function adminPageConfirm(html) {
 var cnf=document.getElementById('confirmScreenObject');
 if (!cnf) {
  var tbody = TheForm;
  var tnode = document.createElement('div');
      tnode.style.position='absolute';
      tnode.style.top='0px';
      tnode.style.left='0px';
      tnode.style.overflow='hidden';
      tnode.style.display='none';
      tnode.id='confirmScreenObject';
  tbody.appendChild(tnode);
  cnf=document.getElementById('confirmScreenObject');
 }
 var dark=document.getElementById('darkenScreenObject');
  cnf.innerHTML = html;
  cnf.style.zIndex='1600';
  cnf.style.width=dark.style.width;
  cnf.style.height=parseInt(dark.style.height)-document.body.scrollTop;
  cnf.style.display='block';
  cnf.style.top=document.body.scrollTop;
  cnf.style.left=dark.style.left;

  execJS2(html);
}

function resizeGrayConfirm() {
  var dark=document.getElementById('darkenScreenObject');

  if (dark != null && dark.style.display=='block') {
   if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
     var pageWidth = document.body.scrollWidth+'px';
     var pageHeight = (document.body.scrollHeight-getPageY()-60)+'px';
    } else if ( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = (document.body.offsetHeight-getPageY()-60)+'px';
    } else {
      var pageWidth='100%';
      var pageHeight='100%';
    }
    dark.style.width=pageWidth;
    dark.style.height=pageHeight;
  }
}

function showTopLoading(b) {
  var obj = getDocElm('LoadingDiv');
  if (obj != null) {
    obj.style.display=b?'block':'none';
  }
}

function mnuItemShow(id, vis) {
  obj = getDocElm('MnuItm' + id);
  if (obj != null) {
    obj.style.display=vis?"block":"none";
  }
}

var ON_BEFORE_AJAX = new Array();
function addOnBeforeAjax(func){
  ON_BEFORE_AJAX[ON_BEFORE_AJAX.length] = func;
  return ON_BEFORE_AJAX.length-1;
}

function adminTheFormOnAjax() {
  for (var i = 0; i < ON_BEFORE_AJAX.length; i++) {
    ON_BEFORE_AJAX[i]();
  }
}

var responseId = 1;
function processResponseDelayed() {
 if (numJsToLoad>0) {
   setTimeout("processResponseDelayed()", 5);
   return;
 }
 for (var i = 0; i < responseId; i++) {
   var respObj = window["Resp" + i];
   if (respObj != null) {
     processResponse(respObj);
     window["Resp" + i] = null;
   }
 }
 highlightObjs();
}

function processResponse(respObj) {
  for (var i = 0; respObj != null && i < respObj.length; i++) {
   if (respObj[i] && respObj[i].Type) {
     var type = respObj[i].Type;
     if (type == 'JS') {
       eval(respObj[i].Params.JS);
     } else if (type == 'CONFIRM') {
       grayOutDef();
       adminPageConfirm(respObj[i].Params.HTML);
     } else if (type == 'HTML') {
       adminPageAddHtml(respObj[i].Params.HTML);
     } else if (type == 'UIFORM') {
       var obj = getDocElm('BxBody' + respObj[i].BoxId);
       if (!isNull(obj)) {
         obj.innerHTML = respObj[i].HTML;
         execJS2(respObj[i].HTML);
       }
       resizeWindow();
       if (obj && respObj[i].Highligh) {
         addObjToHighligh(obj);
       }
     } else if (type == 'REPORT') {
       var obj = getDocElm('Rep_' + respObj[i].RepId);
       if (!isNull(obj)) {
         obj.innerHTML = respObj[i].HTML;
         execJS2(respObj[i].HTML);
       }
       resizeWindow();
     }
   }
 }
}

function doAjaxActionProcessResponse(xmlHttp, actionType, extraPrms, extraPrms2, clrMsgs, clrGray) {
 if (xmlHttp.readyState == 4) {
   if (xmlHttp.status != 200) {
     return doAction(actionType, extraPrms, extraPrms2);
   } else {
    try {
     var respObj = eval(xmlHttp.responseText);
    } catch(e)  {}
     if (clrMsgs) {
       adminClearMessages();
     }
     for (var i = 0; respObj != null && i < respObj.length; i++) {
       if (respObj[i] && respObj[i].Type) {
         var type = respObj[i].Type;
         if (type == 'RESUBMIT_AS_DO_ACTION') {
           return doAction(actionType, extraPrms, extraPrms2);
         }
       }
     }
     confirm_done(clrMsgs, clrGray);
     window["WIN_COMP_TO_HIDE"] = null;
     var bDoDelayed = false;
     for (var i = 0; respObj != null && i < respObj.length; i++) {
       if (respObj[i] && respObj[i].Type) {
         var type = respObj[i].Type;
         if (type == 'LOGOUT') {
           window.location = respObj[i].Params.URL;
           return;
         } else if (type == 'FILE-JS') {
           bDoDelayed=true;
           includeJavaScript(respObj[i].Params.Name);
         } else if (type == 'FILE-CSS') {
           includeCSS(respObj[i].Params.Name);
         }
       }
     }
     
     if (bDoDelayed) {
       var rId = responseId;
       responseId++;
       window["Resp" + rId] = respObj;
       setTimeout("processResponseDelayed()", 5);
     } else {
       processResponse(respObj);
       setTimeout("highlightObjs()", 10);
     }
   }
 }
}

function doAjaxAction(actionType, extraPrms, extraPrms2, chkChanges, clrMsgs, clrGray) {
 return doAjaxActionToURL(TheForm.action, actionType, extraPrms, extraPrms2, chkChanges, clrMsgs, clrGray);
}

function doAjaxActionToURL(actionURL, actionType, extraPrms, extraPrms2, chkChanges, clrMsgs, clrGray) {
 adminTheFormOnAjax();
 
 if (chkChanges) {
   var vChanged = adminNeedsSaving || didFormValuesChange(TheForm);
   if (vChanged) {
     returnValue = getAlertChangesText();
     if(!confirm(getAlertChangesText(true))){ return; }
   }
 }
 var xmlHttp;
 try {
   xmlHttp = getXmlHttp();
 } catch(e)  {
   return doAction(actionType, extraPrms, extraPrms2);
 }
 window.rnd = r = window.rnd ? window.rnd+1 : 1;
 xmlHttp.open('POST',actionURL + '&@AJAX=1&rnd='+r,true);
 TheForm['z6I'].value=actionType;
 if (!isNull(extraPrms)) {
   TheForm['z6J'].value=extraPrms;
 }
 if (!isNull(extraPrms2)) {
   TheForm['z6K'].value=extraPrms2;
 }
 TheForm['z6H'].value='TheForm';
 TheForm['z6G'].value=1;
 var postData = buildPOST();

 TheForm['z6I'].value='';
 TheForm['z6J'].value='';
 TheForm['z6K'].value='';
 TheForm['z6H'].value='';
 TheForm['z6G'].value=0;

 if (isNull(clrMsgs)) {
   clrMsgs = true;
 } 
 if (isNull(clrGray)) {
   clrGray = true;
 }
  
 xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
 xmlHttp.onreadystatechange =  xmlHttp.onreadystatechange = function() {
   doAjaxActionProcessResponse(xmlHttp, actionType, extraPrms, extraPrms2, clrMsgs, clrGray);
 }
 xmlHttp.send(postData);
 return false;
}

function doAction(at, ep, ep2, cc) {adminTheFormOnBeforeSubmit();ep=isNull(ep)?"":ep;ep2=isNull(ep2)?"":ep2;var vChanged = cc && (adminNeedsSaving || didFormValuesChange(TheForm));if(vChanged){ if(!confirm(getAlertChangesText(true))){ return false; } }adminCheckPageChanges(false);TheForm['z6M'].value=getPageX();TheForm['z6N'].value=getPageY();TheForm['z6G'].value=1;TheForm['z6I'].value=at;TheForm['z6J'].value=ep;TheForm['z6K'].value = ep2;TheForm['z6H'].value='TheForm';beforeDoAction(at,ep,ep2,cc);TheForm.submit();return false;}function doRefresh() { TheForm['z6N'].value = document.body.scrollTop;TheForm['z6M'].value = document.body.scrollLeft; return doAction('LAST'); }function isActionType(actionType) { return TheForm['z6G'].value == '1' && TheForm['z6I'].value == actionType; }

function showPrevScreen() {
  window.location='/ta/Default.admin?rnd=KZIFQZZM&@page=doAction&@subPage=DoPrev&@windowId=DTZTW';
  return false;
}
