function getInnerWidth() {
  var result;
  if (document.documentElement) result = document.documentElement.clientWidth;
  else if (document.body) result = document.clientWidth;
  else result = innerWidth;
  return result;
}

function getInnerHeight() {
  var result;
  if (document.documentElement) result = document.documentElement.clientHeight;
  else if (document.body) result = document.clientHeight;
  else result = innerHeight;
  return result;
}

function popup(url, w, h, tgt, scr) {
  if (url != "") {
    var l = Math.round((window.screen.width-w)/2);
    var t = Math.round((window.screen.height-h)/2);
    var win = window.open(url, (tgt == "" ? "_blank" : tgt),
      "height=" + h + ",width=" + w +
      ",left=" + l + ",top=" + t + ",screenX=" + l + ",screenY=" + t +
      ",status=no,resizable=no,scrollbars=" + (scr ? "yes" : "no"));
    win.focus();
    return win;
  }
}

function getHTTPObject() {
  if (typeof XMLHttpRequest != "undefined")
    return new XMLHttpRequest();
  try {
    return new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      return new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {}
  }
  return null;
}

function buttonEvent(e, m) {
  var s = e.style;
  if (m == "over") {
    s.color = "#F9BF21";
    s.borderWidth = "2px 0px 0px 2px";
  } else {
    s.color = "white";
    s.borderWidth = "1px";
  }
  e.firstChild.firstChild.style.color = s.color;
}

function findChildsByTagName(parentElement, lookingTagName) {
  var result = new Array();
  lookingTagName = lookingTagName.toLowerCase();
  for (var i = 0; i < parentElement.childNodes.length; i++) {
    var n = parentElement.childNodes[i];
    var tagName = n.tagName != null && n.tagName.length > 0 ? n.tagName.toLowerCase() : "";
    if (tagName.length > 0) {
      if (tagName == lookingTagName) result[result.length] = n;
      var r = findChildsByTagName(n, lookingTagName);
      for (var j = 0; j < r.length; j++) result[result.length] = r[j];
    }
  }
  return result;
}

function findChildsByClassName(parentElement, lookingClassName) {
  var result = new Array();
  var regexp = new RegExp('(^|\s)'+lookingClassName+'(\s|$)', "i");
  for (var i = 0; i < parentElement.childNodes.length; i++) {
    var n = parentElement.childNodes[i];
    if (n.tagName != null && n.tagName.length > 0) {
      if (n.className != null && n.className.length > 0 && n.className.search(regexp) != -1) result[result.length] = n;
      var r = findChildsByClassName(n, lookingClassName);
      for (var j = 0; j < r.length; j++) result[result.length] = r[j];
    }
  }
  return result;
}

function getChildsText(parentElement) {
  var result = "";
  for (var i = 0; i < parentElement.childNodes.length; i++) {
    var n = parentElement.childNodes[i];
    if (n.tagName != null && n.tagName.length > 0) result += getChildsText(n);
    else if (n.nodeName == "#text") result += n.nodeValue;
  }
  return result;
}

