//----------------------------------------------------------------------------------------------------//
//　初期化（ドキュメントのイベントを設定）
//　引数：なし
//　戻値：なし
function scrollLeft()
{
  if ( !document.getElementById ) return;
  if ( window.pageXOffset )
    return window.pageXOffset;
  if ( document.compatMode == "CSS1Compat" )
    return document.body.parentNode.scrollLeft;
  if ( document.body.scrollLeft )
    return document.body.scrollLeft;
  return 0;
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　初期化（ドキュメントのイベントを設定）
//　引数：なし
//　戻値：なし
function scrollTop()
{
  if ( !document.getElementById ) return;
  if ( window.pageYOffset )
    return window.pageYOffset;
  if ( document.compatMode == "CSS1Compat" )
    return document.body.parentNode.scrollTop;
  if ( document.body.scrollTop )
    return document.body.scrollTop;
  return 0;
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　Windowの幅を取得
//　引数：なし
//　戻値：なし
function winWidth () {
    if(window.innerWidth)
        return window.innerWidth;
    if(document.compatMode == "CSS1Compat")
        return document.body.parentNode.clientWidth;
    if(document.body.clientWidth)
        return document.body.clientWidth;
    return 600;
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　Windowの高さを取得
//　引数：なし
//　戻値：なし
function winHeight () {
    if(window.innerHeight)
        return window.innerHeight;
    if(document.compatMode == "CSS1Compat")
        return document.body.parentNode.clientHeight;
    if(document.body.clientHeight)
        return document.body.clientHeight;
    return 400;
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　初期化（ドキュメントのイベントを設定）
//　引数：なし
//　戻値：なし
function getElemLeft( elem )
{
  var x = elem.offsetLeft;
  var pa = elem.offsetParent;
  while ( pa )
  {
    if ( pa.offsetLeft )
    {
      x += pa.offsetLeft;
    }
    pa = pa.offsetParent;
  }
  return x;
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　初期化（ドキュメントのイベントを設定）
//　引数：なし
//　戻値：なし
function getElemTop( elem )
{
  var y = elem.offsetTop;
  var pa = elem.offsetParent;
  while ( pa )
  {
    if ( pa.offsetTop )
    {
      y += pa.offsetTop;
    }
    pa = pa.offsetParent;
  }
  return y;
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　初期化（ドキュメントのイベントを設定）
//　引数：なし
//　戻値：なし
function showPopup( e, menu )
{
  if ( !document.getElementById ) return;
  var obj = document.getElementById( "popup" );
  var x;
  var y;
  var elem;
  var buff;
  if ( e.srcElement )
  {
    elem = e.srcElement;
  }else{
    elem = e.currentTarget;
  }
  if ( elem.offsetParent && elem.offsetLeft )
  {
    x = getElemLeft( elem );
    y = getElemTop( elem ) + elem.offsetHeight + 1;
  }else{
    x = e.clientX + scrollLeft();
    y = e.clientY + scrollTop();
  }
  buff = "<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bordercolorlight=\"#ffffff\" bordercolordark=\"#000000\">";
  buff += "<tr bgcolor=\"#666666\"><td>";
  if ( menu == "products" )
  {
    buff += "<a href=\"http://www.team-nave.com/e/products/aog_blackjack/index.htm\">AOG-BLACKJACK</a><br>";
    obj.style.width = "120px";
  }else if ( menu == "help" )
  {
    buff += "<a href=\"mailto:team-nave@nifty.com?subject=About team-nave Products:\">E-Mail</a><br>";
    buff += "<a href=\"http://www.team-nave.com/e/help/history.htm\">News</a><br>";
    obj.style.width = "120px";
  }else{
    buff += menu;
    obj.style.width = "120px";
  }
  buff += "</td></tr>";
  buff += "</table>";
  obj.innerHTML = buff;
  obj.style.left = x + "px";
  obj.style.top = y + "px";
  obj.style.visibility = "visible";
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　初期化（ドキュメントのイベントを設定）
//　引数：なし
//　戻値：なし
function hidePopup()
{
  if ( !document.getElementById ) return;
  var obj = document.getElementById( "popup" );
  obj.style.visibility = "hidden";
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　初期化（ドキュメントのイベントを設定）
//　引数：なし
//　戻値：なし
function docClick( e )
{
  if ( !document.getElementById ) return;
  hidePopup();
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　初期化（ドキュメントのイベントを設定）
//　引数：なし
//　戻値：なし
function docMouseMove( e )
{
  if ( !document.getElementById ) return;
  var obj = document.getElementById( "popup" );
  var x;
  var y;
  if ( document.all )
  {
    //IE用
    x = event.x; 
    y = event.y;
  }else{
    //NN用
    x = evt.pageX;
    y = evt.pageY;
  }
  if ( x < obj.offsetLeft || x > ( obj.offsetLeft + obj.offsetWidth ) || y < obj.offsetTop - 20 || y > ( obj.offsetTop + obj.offsetHeight ) )
  {
    hidePopup();
  }
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　初期化（ドキュメントのイベントを設定）
//　引数：なし
//　戻値：なし
function init()
{
  if ( !document.getElementById ) return;
  document.onclick = docClick;
  document.onmousemove = docMouseMove;
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　メニュージャンプ
//　引数：select
//　戻値：なし
function menuJump( select )
{
  if ( !document.getElementById ) return;
  var url = select.options[ select.selectedIndex ].value;
  if ( url )
  {
    location.href = url;
  }
}
//----------------------------------------------------------------------------------------------------//
