//<script>
function centerElement (id,valign,voffset) {
  //valign: 0=center, 1=top, 2=bottom
  var el, windowWidth, windowHeight, elWidth, elHeight, cx, cy;
  if (document.layers) {
    el = document[id];
    windowWidth = window.innerWidth;
    windowHeight = window.innerHeight;
    elWidth = el.document.width;
    elHeight = el.document.height;
  }
  else if (document.all) {
    el = document.all[id];
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
    elWidth = el.offsetWidth;
    elHeight = el.offsetHeight;
  }
  else if (document.getElementById) {
    el = document.getElementById(id);
    windowWidth = window.innerWidth;
    windowHeight = window.innerHeight;
    elWidth = el.offsetWidth;
    elHeight = el.offsetHeight;
  }
  cx = Math.floor((windowWidth - elWidth) / 2);
  switch (valign){
    case 0:
      cy = Math.floor((windowHeight - elHeight) / 2);
      break;
    case 1:
      cy = 0
      break;
    case 2:
      cy = windowHeight-elHeight;
      break;
  }
  cy=cy+voffset;
  if (document.layers) {
    el.left = cx;
    el.top = cy;
    el.visibility = 'show';
  }
  else if (document.all || document.getElementById) {
    el.style.left = cx + 'px';
    el.style.top = cy + 'px';
    el.style.visibility = 'visible';
  }
}

function xGetElementById(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else if(document.layers) e=xLayer(e);
  else e=null;
  return e;
}
function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}


function xPageY(e) {
  if (!(e=xGetElementById(e))) return 0;
  if (xDef(e.pageY)) return e.pageY;
  var y = 0;
  while (e) {
    if (xDef(e.offsetTop)) y += e.offsetTop;
    e = xDef(e.offsetParent) ? e.offsetParent : null;
  }
  return y;
}


//]]></script>

