var is_loaded=false;
var popups = Array()
var hideInterval = 0

function movePopups()
{
  offset = document.getElementById('menurosportblue').height - (-24)
  
  x = getXOffset('menurosport')
  y = getYOffset('menurosport')
  movePopup('poprosport', x, y + offset)
  popups[popups.length] = 'poprosport'

  x = getXOffset('menurosportblue')
  y = getYOffset('menurosportblue')
  movePopup('poprosportblue', x, y + offset)
  popups[popups.length] = 'poprosportblue'

  x = getXOffset('menurosportviva')
  y = getYOffset('menurosportviva')
  movePopup('poprosportviva', x, y + offset)
  popups[popups.length] = 'poprosportviva'
  
  is_loaded=true;
}

window.onresize = movePopups

function movePopup(id, x, y)
{
  layer = document.getElementById(id)
  layer.style.left = x + 'px'
  layer.style.top  = y + 'px'
}

function getXOffset(elID)
{
  xPos = document.getElementById(elID).offsetLeft
  tmpEl = document.getElementById(elID).offsetParent
  while (tmpEl != null)
  { xPos += eval(tmpEl).offsetLeft
   tmpEl = eval(tmpEl).offsetParent
  }

  return xPos
}

function getYOffset(elID)
{
  yPos = document.getElementById(elID).offsetTop

  tmpEl = document.getElementById(elID).offsetParent
  while (tmpEl != null)
  { yPos += eval(tmpEl).offsetTop
    tmpEl = eval(tmpEl).offsetParent
  }

  return yPos
}

function showPopup(id)
{
  if ( hideInterval != 0 )
  { clearTimeout(hideInterval)
    hideInterval = 0
  }

  for ( i = 0; i < popups.length; i++ )
  { if ( popups[i] != id
         && document.getElementById(popups[i]).style.visibility == 'visible' )
      hidePopupNow(popups[i])
  }

  if (is_loaded)
    document.getElementById(id).style.visibility = 'visible';
}

function hidePopupNow(id)
{
  document.getElementById(id).style.visibility = 'hidden'
}

function hidePopup(id)
{
  hideInterval = setTimeout('hidePopupNow(\''+ id +'\')', 200)
}

function enterPopup(id)
{
  clearTimeout(hideInterval)
  hideInterval = 0
}

function setClass(tag, className) { tag.className = className }

function pop(name, path, width, height)
{
	var win = window.open(path, name, "width=" + width + ",height=" + height + ",directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no") ;
	win.moveTo(
		(screen.width - width) / 2
		, (screen.height - height) / 2)
	return win 
}