function chgBgClr(pObj, pColor) {
  pObj.style.backgroundColor = pColor;
}

function chgBrdClr(pObj, pColor) {
  pObj.style.borderColor = pColor;
}

function doHttpRequest(pUrl, pFunc, pParam, pRawPostData) {
  var HttpReq = false;

  if (window.XMLHttpRequest)
    HttpReq = new XMLHttpRequest();
  else if (window.ActiveXObject) {
    try {
      HttpReq = new ActiveXObject('Msxml2.XMLHTTP');
    } catch (Err) {
      try {
        HttpReq = new ActiveXObject('Microsoft.XMLHTTP');
      } catch (Err) {}
    }
  }

  if (HttpReq) {
    if (pFunc != '')
      HttpReq.onreadystatechange = function() {
        if (HttpReq.readyState == 4 && HttpReq.status == 200)
          eval(pFunc + '(HttpReq.responseText, pParam);');
      }
    if (pRawPostData == '') {
      HttpReq.open('GET', pUrl, true);
      HttpReq.send(null);
    } else {
      HttpReq.open('POST', pUrl, true);
      HttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      HttpReq.send(pRawPostData);
    }
  }
}

function displayElem(pObj, pDisplay) {
  if (pObj)
    with (pObj.style)
      try {
        display = pDisplay;
      } catch (Err) {
        display = 'block';
      }
}

function displayElemById(pId, pDisplay) {
  displayElem(elementById(pId), pDisplay);
}

function displayElemByIdOpener(pId, pDisplay) {
  displayElem(elementByIdOpener(pId), pDisplay);
}

function elementById(pId) {
  pId = 'id_' + pId;
  with (window.document)
    var Elem = getElementById ? getElementById(pId) : all[pId];
  return Elem == null ? false : Elem;
}

function elementByIdOpener(pId) {
  pId = 'id_' + pId;
  with (opener.document)
    var Elem = getElementById ? getElementById(pId) : all[pId];
  return Elem == null ? false : Elem;
}

function evalSelect(pObj) {
  var S = getSelectSelValue(pObj);
  pObj.selectedIndex = 0;
  if (S != '')
    eval(S);
}

function fadeElemById(pId, pDisplay) {
  var Elem = elementById(pId);
  if (Elem && Elem.style.display != pDisplay)
    if (pDisplay == 'none')
      displayElemById(pId, pDisplay);
    else {
      opacElemById(pId, 0);
      displayElemById(pId, pDisplay);
      for (var I = 0; I <= 100; I += 1)
        window.setTimeout('opacElemById("' + pId + '", ' + I + ');', I * 4);
    }
} 

function formByIndex(pIndex) {
  return window.document.forms[pIndex];
}

function formByIndexOpener(pIndex) {
  return opener.document.forms[pIndex];
}

function formByName(pName) {
  return window.document.forms['frm_' + pName];
}

function formByNameOpener(pName) {
  return opener.document.forms['frm_' + pName];
}

function getHTML(pId) {
  var Elem = elementById(pId);
  return Elem ? Elem.innerHTML : '';
}

function getHTMLOpener(pId) {
  var Elem = elementByIdOpener(pId);
  return Elem ? Elem.innerHTML : '';
}

function getOptSelValue(pObj) {
  if (typeof(pObj.length) == 'number') {
    for (var I = 0; I < pObj.length; I++)
      if (pObj[I].checked)
        return pObj[I].value;
  } else if (pObj.checked)
    return pObj.value;
  return '';
}

function getAllOptSelValues(pObj) {
  var List = new Array();
  if (typeof(pObj.length) == 'number') {
    for (var I = 0; I < pObj.length; I++)
      if (pObj[I].checked)
        List.push(pObj[I].value);
  } else if (pObj.checked)
    List.push(pObj[I].value);
  return List;
}

function getSelectSelValue(pObj) {
  with (pObj) {
    if (pObj.selectedIndex == -1)
      return '';
    return options[selectedIndex].value;
  }
}

function getDOMTable(pId) {
  var Children = elementById(pId).childNodes;
  var Rows = new Array();
  for (var I = 0; I < Children.length; I++)
    if (Children[I].nodeName == 'TBODY') {
      var ChildrenRows = Children[I].childNodes;
      for (var J = 0; J < ChildrenRows.length; J++)
        if (ChildrenRows[J].nodeName == 'TR') {
          var ChildrenCols = ChildrenRows[J].childNodes;
          var Cols = new Array();
          for (var H = 0; H < ChildrenCols.length; H++)
            if (ChildrenCols[H].nodeName == 'TD')
              Cols.push(ChildrenCols[H]);
          Rows.push(Cols);
        }
      break;
    }
  return Rows;
}

function getElemBody() {
  with (window.document)
    return getElementsByTagName ? getElementsByTagName('body')[0] : body;
}

function getPageHeight() {
  return Math.max(getWindowHeight(), getElemBody().scrollHeight);
}

function getPageWidth() {
  return getElemBody().scrollWidth;
}

function getWindowHeight() {
  return typeof(window.innerHeight) == 'number' ? window.innerHeight : getElemBody().clientHeight;
}

function getWindowWidth() {
  return typeof(window.innerWidth) == 'number' ? window.innerWidth : getElemBody().clientWidth;
}

function getWindowScrollLeft() {
  return typeof(window.pageXOffset) == 'number' ? window.pageXOffset : getElemBody().scrollLeft;
}

function getWindowScrollTop() {
  return typeof(window.pageYOffset) == 'number' ? window.pageYOffset : getElemBody().scrollTop;
}

function go(pUrl) {
  window.location.href = pUrl;
}

function goOpener(pUrl) {
  opener.location.href = pUrl;
}

function goSelect(pObj) {
  var S = getSelectSelValue(pObj);
  pObj.selectedIndex = 0;
  if (S != '')
    go(S);
}

function htmlcode(pValue) {
  return pValue.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}

function imageByName(pName) {
  return window.document.images['img_' + pName];
}

function imageByNameOpener(pName) {
  return opener.document.images['img_' + pName];
}

function insertCode(pObjCode, pObjData) {
  var S = getSelectSelValue(pObjCode);
  pObjCode.selectedIndex = 0;
  if (S != '') {
    var Code = S.split('|');
    insertText(pObjData, Code[0], Code[1]);
  }
}

function insertText(pObj, pTextLeft, pTextRight) {
  pObj.focus();
  if (typeof(document.selection) != 'undefined') {
    var Range = document.selection.createRange();
    var S = Range.text;
    Range.text = pTextLeft + S + pTextRight;
    Range = document.selection.createRange();
    if (S.length == 0)
      Range.move('character', - pTextRight.length);
    else
      Range.moveStart('character', pTextLeft.length + S.length + pTextRight.length);      
    Range.select();
  } else if (typeof(pObj.selectionStart) != 'undefined') {
    var Start = pObj.selectionStart;
    var End = pObj.selectionEnd;
    var S = pObj.value.substring(Start, End);
    pObj.value = pObj.value.substr(0, Start) + pTextLeft + S + pTextRight + pObj.value.substr(End);
    pObj.selectionStart = pObj.selectionEnd = S.length == 0 ? Start + pTextLeft.length : Start + pTextLeft.length + S.length + pTextRight.length;
  }
}

function opacElemById(pId, pOpacity) {
  var Elem = elementById(pId);
  if (Elem)
    with (Elem.style)
      try {
        opacity = pOpacity / 100;
        MozOpacity = pOpacity / 100; 
        KhtmlOpacity = pOpacity / 100; 
        filter = 'alpha(opacity=' + pOpacity + ')';
      } catch (Err) {}
}

function popupWindow(pUrl, pHeight, pWidth) {
  window.open(pUrl, 'popup', 'dependent=no,height=' + pHeight + ',left=' + Math.round((screen.availWidth - pWidth) / 2) + ',resizable=yes,width=' + pWidth + ',top=' + Math.round((screen.availHeight - pHeight) / 2)).focus();
}

function resetElemConfirm(pMsg, pObj) {
  if (!confirm(pMsg))
    with (pObj)
      if (type == 'text')
        value = defaultValue;
      else
        for (var I = 0; I < options.length; I++)
          options[I].selected = options[I].defaultSelected;
}

function selFloat(pObj, pCountDec, pNeg) {
  with (pObj) {
    var J = -1;
    try {
      var I = parseFloat(eval(value.replace(/,/, '.')));
      if (!isNaN(I) && (pNeg || I >= 0))
        J = I;
    } catch (Err) {}
    var B = J == -1;
    value = B ? defaultValue : J;
    if (pCountDec != -1) {
      var I = Math.pow(10, pCountDec);
      value = Math.round(value * I) / I;
    }
    return B;
  }
}

function selNum(pObj, pMaxLength, pNeg) {
  with (pObj) {
    var J = -1;
    try {
      var I = parseInt(eval(value.replace(/,/, '.')));
      if (!isNaN(I) && (pNeg || I >= 0))
        J = I;
    } catch (Err) {}
    var B = J == -1;
    value = B ? defaultValue : J;
    value = value.substr(0, pMaxLength);
    return B;
  }
}

function selUpperCase(pObj) {
  with (pObj)
    value = value.toUpperCase();
}

function setHTML(pValue, pId) {
  var Elem = elementById(pId);
  if (Elem)
    Elem.innerHTML = pValue;
}

function setHTMLOpener(pValue, pId) {
  var Elem = elementByIdOpener(pId);
  if (Elem)
    Elem.innerHTML = pValue;
}

function submitForm(pName) {
  formByName(pName).submit();
}

function submitFormOpener(pName) {
  formByNameOpener(pName).submit();
}