function getInternetExplorerVersion()
// Returns the version of Windows Internet Explorer or a -1
// (indicating the use of another browser).
{
   var rv = -1; // Return value assumes failure.
   if (navigator.appName == 'Microsoft Internet Explorer')
   {
      var ua = navigator.userAgent;
      var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
      if (re.exec(ua) != null)
         rv = parseFloat( RegExp.$1 );
   }
   return rv;
}

var menutimeout;

function initmenu()
{
	
var menuxposnav=0;
var menuyposnav=42;
var vermenuie = getInternetExplorerVersion();
if ((navigator.appName == 'Microsoft Internet Explorer') && ( vermenuie >= 8.0 )) {
	menuxposnav=12;
	menuyposnav=30;
}

	
	var xpos, ypos, link, submenu;
	/* grab any flyout divs */
	var flyOutNav = document.getElementsByTagName("span");

	for (var i=0;i<flyOutNav.length;i++) {
		if (flyOutNav[i].className && flyOutNav[i].className.indexOf("FLYOUTNAV") != -1) {
			/* should be the first ul in flyOutNav div */
			var navLinks = flyOutNav[i].getElementsByTagName("ul").item(0);
			/* now get the list of links */
			var linkList = navLinks.getElementsByTagName("li");
			/* find out where the main menu is */
			var menuypos = findPosY(flyOutNav[i]);
			/* now loop through all flyoutnav links and add onmouseovers */
			for (var k=0;k<linkList.length;k++) {
				link = linkList[k];
				/* make sure we only add mouseovers to the main list items 
				not the submenu items */
				if (link.parentNode == navLinks) {
					xpos = findPosX(link);
					//ypos = findPosY(link);
					submenu = link.getElementsByTagName("ul").item(0);
					link.onmouseover=showsubmenu;
					link.onmouseout=hidesubmenu;
					if (submenu) {
						submenu.style.top = menuypos + menuyposnav;
						submenu.style.left = xpos - menuxposnav;
						submenu.style.display="none";
					}
				}
			}
		} // end if FLYOUTNAV
	} // end for div
}

/* make the selected submenu visible */
function showsubmenu(e)
{
  if (menutimeout) {
    window.clearTimeout(menutimeout);
  }
  submenu = this.getElementsByTagName("ul").item(0);
  opensubmenu(submenu);
}

/* make the selected submenu invisible */
function hidesubmenu(e)
{
  if (menutimeout) {
    window.clearTimeout(menutimeout);
  }
  menutimeout = window.setTimeout('closeall()',1000);
}

function findPosX(obj)
{
  var curleft = 0;
  var hack=0;
  if (obj.offsetParent) {
//Disabling proper lookup of actual position because the (Select another player)
//link is inside a relative div so you want the position relative to that div
//not relative to the main body.
//now it only gets the first offset
    while ((document.all || curleft == 0) && obj.offsetParent) {
if (document.all && curleft != 0 && !obj.offsetParent.id) {
  //okay this hack is to get around IE, it should set the value twice
// and thats it, man is this ever ugly
  if (hack) {
    break;
  } else {
    hack++;
  }
}
      curleft += obj.offsetLeft
      obj = obj.offsetParent;
   }
  } else if (obj.x) {
    curleft += obj.x;
  }
  return curleft;
}

function findPosY(obj)
{
  var curtop = 0;
  var hack=0;

  if (obj.offsetParent) {
//Disabling proper lookup of actual position because the (Select another player)
//link is inside a relative div so you want the position relative to that div
//not relative to the main body.
//now it only gets the first offset
    while ((document.all || curtop == 0) && obj.offsetParent) {
if (document.all && curtop != 0 && !obj.offsetParent.id) {
  //okay this hack is to get around IE, it should set the value twice
// and thats it, man is this ever ugly
  if (hack) {
    break;
  } else {
    hack++;
  }
}
      curtop += obj.offsetTop;
      obj = obj.offsetParent;
    }
  } else if (obj.y) {
    curtop += obj.y;
  }
  return curtop;
}

function closeall()
{
  /* grab any flyout divs */
  var flyOutNav = document.getElementsByTagName("span");

  for (var i=0;i<flyOutNav.length;i++) {
    if (flyOutNav[i].className &&
        flyOutNav[i].className.indexOf("FLYOUTNAV") != -1) {
      /* we want the first ul in flyout div */
      var navLinks = flyOutNav[i].getElementsByTagName("ul").item(0);
      /* now get the list of links */
      var linkList = navLinks.getElementsByTagName("li");

      for (var k=0;k<linkList.length;k++) {
        link = linkList[k];
        submenu = link.getElementsByTagName("ul").item(0);
        if (submenu) {
          submenu.style.display="none";
        }
      }
    }
  }
}

function opensubmenu(submenu)
{
  if (submenu && submenu.style.display == "none") {
    closeall();
    if (submenu) {
      submenu.style.display="block";
    }
  }
}

function addOnloadEvent(fnc){
  if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fnc, false );
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", fnc );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[fnc]();
      };
    }
    else
      window.onload = fnc;
  }
}

addOnloadEvent(initmenu);
