function objById(id) {
  if (document.getElementById) {
    var returnVar = document.getElementById(id);
  } else if (document.all) {
    var returnVar = document.all[id];
  } else if (document.layers) {
    var returnVar = document.layers[id];
  }
  return returnVar;
}

function moveFooter() {
  // move the footer to the bottom the screen if it is above it
  var footer = objById('footer');
  var oElement = footer;
  var footerSize = 75; // margin 40 + height 35
  var top = 0; // footer height in pixels.
  while( oElement != null ) {
    top += oElement.offsetTop;
    oElement = oElement.offsetParent;
  }
  var height;
  if (typeof(window.innerWidth) == 'number') {
    //Non-IE
    height = window.innerHeight;
  } else if (document.documentElement &&
             (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
    //IE 6+ in 'standards compliant mode'
    height = document.documentElement.clientHeight;
  } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
    //IE 4 compatible
    height = document.body.clientHeight;
  }
  if (height && (top + footerSize) < height) {
    // We need to move the footer down
    footer.style.position = "absolute";
    footer.style.top = (height - footerSize) + "px";
    footer.style.left = "0px";
  }
}

function selectSearchBox(box) {
  searchbox = objById(box);
  if (searchbox) {
    searchbox.focus();
  }
}

function expandList(view, showHide) {
  view = objById(view);
  showHide = objById(showHide);
  if (view.style.display == 'none') {
    view.style.display = 'block';
    showHide.innerHTML = 'Hide <img src="/images/hide.png" />';
    showHide.title = 'Hide';
  } else {
    view.style.display = 'none';
    showHide.innerHTML = 'View all <img src="/images/view_all.png" />';
    showHide.title = 'View all';
  }
  return false;
}

function expandChildren(o, expand) {
  o = objById(o);
  expand = objById(expand);
  if (o.style.display == 'none') {
    o.style.display = 'block';
    expand.innerHTML = '<img src="/images/minus.png" alt="Shrink">';
    expand.title = 'Shrink';
  } else {
    o.style.display = 'none';
    expand.innerHTML = '<img src="/images/plus.png" alt="Expand">';
    expand.title = 'Expand';
  }
  expand.blur();
  return false;
}

