function Browser() {
  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.
  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}
var browser = new Browser();

/* Global window height/width info (from: http://www.jalix.org/ressources/internet/dhtml/_dynduo/dynduo/en/widthheight.html) */
var winW = (browser.isNS)? window.innerWidth-16 : document.documentElement.offsetWidth-20;
var winH = (browser.isNS)? window.innerHeight : document.documentElement.offsetHeight;

var POS_BELOW_EL	= "pbe";
var POS_LEFT_EL		= "ple";
var POS_RIGHT_EL	= "pre";
var POS_ABOVE_EL	= "pae";
var POS_OVER_EL		= "poe";
var POS_CENTER_SCR	= "pcs";
var cm=null;
var mTimer;

document.onclick = new Function("showMenu(null)");

function getPos(el,sProp) {
	var iPos = 0;
	while (el!=null) {
		iPos+=el["offset" + sProp];
		el = el.offsetParent;
	}
	return iPos;
}

function showMenu(el, m, posId) {
	var IfrRef = document.getElementById('DivShim');
	IfrRef.style.display='none';
	if (m) {
		m.style.display = '';
		m.style.position='absolute';
		if (posId==POS_CENTER_SCR) {
			m.style.left = (winW/2) - (m.offsetWidth/2);
			m.style.top = (winH/2) - (m.offsetHeight/2);
		} else if (posId==POS_BELOW_EL) {
			m.style.left = getPos(el, "Left");
			m.style.top = getPos(el, "Top") + el.offsetHeight;
		} else if (posId==POS_OVER_EL) {
			m.style.left = getPos(el, "Left");
			m.style.top = getPos(el, "Top");
		} else {
			m.style.left = getPos(el,"Left") + el.offsetWidth;
			m.style.top = getPos(el,"Top");
		}
		m.style.zIndex = 5;
		IfrRef.style.width = m.offsetWidth;
		IfrRef.style.height = m.offsetHeight;
		IfrRef.style.top = m.style.top;
		IfrRef.style.left = m.style.left;
		IfrRef.style.zIndex = m.style.zIndex - 1;
		IfrRef.style.display = "block";
	}
	if ((m!=cm) && (cm)) {
		cm.style.display='none';
	}
	cm=m;
}

function closeMenu() {
	showMenu(null);
}
