// JavaScript Document

function SistemaOperativo() 
{ 
	if (navigator.userAgent.indexOf('IRIX') != -1) {var SO = "Irix" } 
		else if ((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('98') != -1)) {var SO= "Windows"} 
		else if ((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('95') != -1)) {var SO= "Windows"} 
		else if (navigator.appVersion.indexOf("16") !=-1) {var SO= "Windows"} 
		else if (navigator.userAgent.indexOf("NT 5.1") !=-1) {var SO= "Windows"} 
		else if (navigator.appVersion.indexOf("NT") !=-1) {var SO= "Windows"} 
		else if (navigator.userAgent.indexOf('Mac') != -1) {var SO= "Macintosh"} 
		else {var SO= "No identificado"} 
	
	return SO;
} 


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();

function getPageOffsetLeft(el) {
  var x;
  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {
  var y;
  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}

function PosicionarCapas(event, Absoluta)
{

	var button;

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;
	
	SO=SistemaOperativo();

	//IE - Win//
	if (browser.isIE) 
	{
		if(SO == "Windows")
		{
			x = getPageOffsetLeft(button) - 10;
			y = getPageOffsetTop(button) +10;
		}
		else
		{
			if(SO == "Macintosh")
			{
				x = getPageOffsetLeft(button) - 2;
				y = getPageOffsetTop(button) +22;
			}
		}
  	}
	else
	{
		//Mozilla - NetScape//
		x = getPageOffsetLeft(button) - 9;
	  	y = getPageOffsetTop(button) + 26;
	}
	
	switch (Absoluta)
	{
				case 'menu1': 
						 document.getElementById(Absoluta).style.left = (x+10) + "px";
	  					 document.getElementById(Absoluta).style.top  = (y+14) + "px";
				break;
	}
	 

}
