//----------------------------------------------------------------------------------------------------//
//　初期化（ドキュメントのイベントを設定）
//　引数：なし
//　戻値：なし
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 == "keiba" )
  {
    buff += "<a href=\"http://www.team-nave.com/keiba/index.htm\">　全場全レース予想</a><br>";
    buff += "<a href=\"http://www.team-nave.com/keiba/game/index.htm\">　競馬予想大会「Keiba Tip Rally」</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=keiba&fnm=../keiba/ktr/keiba_tip_cmttip.htm\">　コメント予想</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=keiba&fnm=../keiba/ktr/keiba_tip_prgtip.htm\">　プログラミング予想</a><br>";
    buff += "<a href=\"http://www.team-nave.com/keiba/keiba_tip_ranking.htm\">　ランキング</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=keiba&fnm=../keiba/keiba_tip_result.htm\">　予想結果</a><br>";
    buff += "<a href=\"http://www.team-nave.com/keiba/game/keiba_tip_rally_mailmagazine.htm\">　メールマガジン</a><br>";
    buff += "<a href=\"http://www.team-nave.com/keiba/weather.htm\">　競馬場のお天気</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/keiba_item.htm\">　競馬アイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/keiba/keiba_tip_help.htm\">　ヘルプ</a><br>";
    buff += "</td></tr><tr bgcolor=\"#666666\"><td>";
    buff += "<a href=\"http://www.jra.go.jp/\" target=\"_blank\">　JRA ホームページ</a><br>";
    buff += "<a href=\"http://www.keiba.go.jp/\" target=\"_blank\">　地方競馬全国協会公式サイト</a><br>";
    buff += "<a href=\"http://www.ipat.jra.go.jp/\" target=\"_blank\">　JRA IPAT</a>";
    obj.style.width = "220px";
  }else if ( menu == "kyotei" )
  {
    buff += "<a href=\"http://www.team-nave.com/kyotei/index.htm\">　全場全レース番組表・進入スタート予想</a><br>";
    buff += "<a href=\"http://www.team-nave.com/kyotei/kyotei_tip_result_main.htm\">　場別最新節成績</a><br>";
    buff += "<a href=\"http://www.team-nave.com/kyotei/mail/index.htm\">　選手出場情報配信「ライダーメール」</a><br>";
    buff += "<a href=\"http://www.team-nave.com/kyotei/pool/index.htm\">　競艇場データ</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/kyotei_item.htm\">　競艇アイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/kyotei/kyotei_tip_race_manual.htm\">　番組表の見方／プリントの仕方</a><br>";
    buff += "</td></tr><tr bgcolor=\"#666666\"><td>";
    buff += "<a href=\"http://www.kyotei.or.jp/\" target=\"_blank\">　競艇オフィシャルWEB</a><br>";
    buff += "<a href=\"https://wwwi.mbrace.or.jp/\" target=\"_blank\">　競艇インターネット投票システム</a>";
    obj.style.width = "240px";
  }else if ( menu == "keirin" )
  {
    buff += "<a href=\"http://www.team-nave.com/keirin/index.htm\">　競輪場のお天気</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/keirin_item.htm\">　競輪アイテム</a><br>";
    buff += "</td></tr><tr bgcolor=\"#666666\"><td>";
    buff += "<a href=\"http://www.keirin.go.jp/\" target=\"_blank\">　競輪オフィシャルWEB</a>";
    obj.style.width = "200px";
  }else if ( menu == "autorace" )
  {
    buff += "<a href=\"http://www.team-nave.com/autorace/index.htm\">　オートレース場のお天気</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/autorace_item.htm\">　オートレースアイテム</a><br>";
    buff += "</td></tr><tr bgcolor=\"#666666\"><td>";
    buff += "<a href=\"http://www.autorace.or.jp/\" target=\"_blank\">　オートレースオフィシャルWEB</a><br>";
    obj.style.width = "200px";
  }else if ( menu == "kabu" )
  {
    buff += "<a href=\"http://www.team-nave.com/kabu/index.htm\">　株式情報交換</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/kabu_item.htm\">　株式アイテム</a><br>";
    obj.style.width = "200px";
  }else if ( menu == "lottery" )
  {
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=loto&fnm=../loto/loto6_bestb.htm\">　ロト６[ベスト／ワーストナンバー(B)]</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=loto&fnm=../loto/loto6_best.htm\">　ロト６[ベスト／ワーストナンバー]</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=loto&fnm=../loto/loto6_kakob.htm\">　ロト６[出現度数(B)]</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=loto&fnm=../loto/loto6_kako.htm\">　ロト６[出現度数]</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=loto&fnm=../loto/miniloto_bestb.htm\">　ミニロト[ベスト／ワーストナンバー(B)]</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=loto&fnm=../loto/miniloto_best.htm\">　ミニロト[ベスト／ワーストナンバー]</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=loto&fnm=../loto/miniloto_kakob.htm\">　ミニロト[出現度数(B)]</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=loto&fnm=../loto/miniloto_kako.htm\">　ミニロト[出現度数]</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/lottery_item.htm\">　宝くじアイテム</a><br>";
    obj.style.width = "230px";
  }else if ( menu == "toto" )
  {
    buff += "<a href=\"http://www.team-nave.com/toto/index.htm\">　totoGOAL 番組表</a><br>";
    buff += "<a href=\"http://www.team-nave.com/toto/toto_tip_toto.htm\">　toto 番組表</a><br>";
    buff += "<a href=\"http://www.team-nave.com/toto/toto_tip_game_manual.htm\">　番組表の見方／プリントの仕方</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/toto_item.htm\">　totoアイテム</a><br>";
    obj.style.width = "200px";
  }else if ( menu == "products" )
  {
    buff += "<a href=\"http://www.team-nave.com/products/index.htm\">　ソフトウェア</a><br>";
    buff += "<a href=\"http://www.team-nave.com/products/gtcforblackjack/index.htm\">　ブラックジャック科</a><br>";
    buff += "<a href=\"http://www.team-nave.com/products/kstms/index.htm\">　KabuShiki Trade Management System</a><br>";
    buff += "<a href=\"http://www.team-nave.com/products/kdbforkeiba/index.htm\">　KDB for Keiba</a><br>";
    buff += "<a href=\"http://www.team-nave.com/products/kdbforkyotei/index.htm\">　KDB for Kyotei</a><br>";
    buff += "<a href=\"http://www.team-nave.com/products/kbdbs/index.htm\">　KeiBa DataBase Server</a><br>";
    buff += "<a href=\"http://www.team-nave.com/products/kbp/index.htm\">　KeiBa Paper</a><br>";
    buff += "<a href=\"http://www.team-nave.com/products/kbr/index.htm\">　KeiBa Reporter</a><br>";
    buff += "<a href=\"http://www.team-nave.com/products/kbtv/index.htm\">　KeiBa TeleVision</a><br>";
    buff += "<a href=\"http://www.team-nave.com/products/ksaforkeiba/index.htm\">　KSA for Keiba</a><br>";
    buff += "<a href=\"http://www.team-nave.com/products/ksaforkyotei/index.htm\">　KSA for Kyotei</a><br>";
    buff += "<a href=\"http://www.team-nave.com/products/umawser/index.htm\">　Umawser</a>";
    buff += "</td></tr><tr bgcolor=\"#666666\"><td>";
    buff += "<a href=\"http://www.vector.co.jp/\" target=\"_blank\">　Vector</a><br>";
    buff += "<a href=\"http://www.jra-van.ne.jp/\" target=\"_blank\">　JRA-VAN</a>";
    obj.style.width = "235px";
  }else if ( menu == "shop" )
  {
    buff += "<a href=\"http://www.team-nave.com/shop/gamble_item.htm\">　ギャンブルアイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/keiba_item.htm\">　競馬アイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/kyotei_item.htm\">　競艇アイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/keirin_item.htm\">　競輪アイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/autorace_item.htm\">　オートレースアイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/kabu_item.htm\">　株式アイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/casino_item.htm\">　カジノアイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/toto_item.htm\">　totoアイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/lottery_item.htm\">　宝くじアイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/pachinko_item.htm\">　パチンコアイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/pachislot_item.htm\">　パチスロアイテム</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/mahjong_item.htm\">　麻雀アイテム</a><br>";
    buff += "</td></tr><tr bgcolor=\"#666666\"><td>";
    buff += "<a href=\"http://www.amazon.co.jp/exec/obidos/redirect?tag=gambletips-22&amp;path=tg/browse/-/489986\" target=\"_blank\">　Amazon.co.jp</a>";
    obj.style.width = "200px";
  }else if ( menu == "link" )
  {
    buff += "<a href=\"http://www.team-nave.com/link/index.htm\">　ギャンブル</a><br>";
    buff += "<a href=\"http://www.team-nave.com/link/link_site_other.htm\">　ギャンブル以外</a><br>";
    buff += "</td></tr><tr bgcolor=\"#666666\"><td>";
    buff += "<a href=\"http://www.jra.go.jp/\" target=\"_blank\">　JRA ホームページ</a><br>";
    buff += "<a href=\"http://www.keiba.go.jp/\" target=\"_blank\">　地方競馬全国協会公式サイト</a><br>";
    buff += "<a href=\"http://www.kyotei.or.jp/\" target=\"_blank\">　競艇オフィシャルWEB</a><br>";
    buff += "<a href=\"http://www.keirin.go.jp/\" target=\"_blank\">　競輪オフィシャルWEB</a><br>";
    buff += "<a href=\"http://www.autorace.or.jp/\" target=\"_blank\">　オートレースオフィシャルWEB</a>";
    buff += "</td></tr><tr bgcolor=\"#666666\"><td>";
    buff += "<a href=\"http://www.ipat.jra.go.jp/\" target=\"_blank\">　JRA IPAT</a><br>";
    buff += "<a href=\"https://wwwi.mbrace.or.jp/\" target=\"_blank\">　競艇インターネット投票システム</a>";
    obj.style.width = "200px";
  }else if ( menu == "mobile" )
  {
    buff += "<a href=\"http://www.team-nave.com/handy_index.htm\">　DoCoMo</a><br>";
    buff += "<a href=\"http://www.team-nave.com/handy_index.htm\">　Vodafone</a>";
    obj.style.width = "80px";
  }else if ( menu == "help" )
  {
    buff += "<a href=\"http://www.team-nave.com/help/articles.htm\">　利用規約</a><br>";
    buff += "<a href=\"http://www.team-nave.com/help/pp.htm\">　プライバシーポリシー</a><br>";
    buff += "<a href=\"mailto:team-nave@nifty.com?subject=Gamble%20Tips%20FAQ\">　メール</a><br>";
    buff += "<a href=\"http://www.team-nave.com/help/request.htm\">　リクエスト</a><br>";
    buff += "<a href=\"http://www.team-nave.com/help/history.htm\">　更新履歴／記事掲載</a><br>";
    buff += "<a href=\"http://homepage1.nifty.com/team-nave/\">　ミラーサイト１</a><br>";
    buff += "<a href=\"http://hp.vector.co.jp/authors/VA019944/\">　ミラーサイト２</a><br>";
    buff += "<a href=\"http://www.team-nave.com/help/version.htm\">　バージョン情報</a>";
    obj.style.width = "160px";
  }else{
    buff += menu;
    obj.style.width = "200px";
  }
  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;
  }
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　日時表示
//　引数：なし
//　戻値：なし
function clock()
{
  if ( !document.getElementById ) return;
  var obj = document.getElementById( "clock" );
  var now = new Date();
  var yyyy = now.getFullYear();
  var mm = now.getMonth() + 1; 
  if ( mm < 10 ) mm = "0" + mm;
  var dd = now.getDate();
  if ( dd < 10 ) dd = "0" + dd;
  var daynm;
  if ( now.getDay() == 0 )
  {
    daynm = "日";
  }else if ( now.getDay() == 1 )
  {
    daynm = "月";
  }else if ( now.getDay() == 2 )
  {
    daynm = "火";
  }else if ( now.getDay() == 3 )
  {
    daynm = "水";
  }else if ( now.getDay() == 4 )
  {
    daynm = "木";
  }else if ( now.getDay() == 5 )
  {
    daynm = "金";
  }else if ( now.getDay() == 6 )
  {
    daynm = "土";
  }
  var hh = now.getHours(); 
  if ( hh < 10 ) hh = "0" + hh;
  var nn = now.getMinutes(); 
  if ( nn < 10 ) nn = "0" + nn;
  var ss = now.getSeconds(); 
  if ( ss < 10 ) ss = "0" + ss;
  var dttmstr = yyyy + "/" + mm + "/" + dd + " (" + daynm + ") " + hh + ":" + nn + ":" + ss;
  obj.innerHTML = dttmstr;
  setTimeout( "clock();", 1000 );
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　フォーカス設定
//　引数：e	...オブジェクト
//　戻値：なし
function setFocus( e )
{
  if ( !document.getElementById ) return;
  var obj = document.getElementById( e );
  obj.focus();
}
//----------------------------------------------------------------------------------------------------//
