//----------------------------------------------------------------------------------------------------//
//　初期化（ドキュメントのイベントを設定）
//　引数：なし
//　戻値：なし
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/gati1tip/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/keiba/index.htm\">　ニュース／ランキング／メインイベント</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=keiba&fnm=../keiba/ktr/keiba_tip_pkrank01tip.htm\">　ランキングトップ予想</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=keiba&fnm=../keiba/ktr/keiba_tip_qrtrank01tip.htm\">　回収率トップ予想</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_nowwoltop5tip.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/cgi-local/tip_info.cgi?tip=keiba&fnm=../keiba/ktr/keiba_tip_nowwolrtranking.htm\">　勝負レース回収率ランキング</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=keiba&fnm=../keiba/ktr/keiba_tip_nowreqrtranking.htm\">　条件別ランキング</a><br>";
    buff += "<a href=\"http://www.team-nave.com/cgi-local/tip_info.cgi?tip=keiba&fnm=../keiba/ktr/keiba_tip_refranking.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/keiba/keiba_tip_help.htm\">　ヘルプ</a><br>";
    buff += "<a href=\"http://www.team-nave.com/shop/keiba_item.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 == "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/kakegoto_tv/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/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/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 = "200px";
  }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/lottery_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 += "</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=\"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 = "140px";
  }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 = "SUN";
  }else if ( now.getDay() == 1 )
  {
    daynm = "MON";
  }else if ( now.getDay() == 2 )
  {
    daynm = "TUE";
  }else if ( now.getDay() == 3 )
  {
    daynm = "WED";
  }else if ( now.getDay() == 4 )
  {
    daynm = "THU";
  }else if ( now.getDay() == 5 )
  {
    daynm = "FRI";
  }else if ( now.getDay() == 6 )
  {
    daynm = "SAT";
  }
  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 );
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　クッキー設定値取得
//　引数：cnm		...クッキー名
//　戻値：クッキー値
function getCookie( cnm )
{
  if ( !document.getElementById ) return;
  var ret = "";
  var cookies = document.cookie.split( "; " );
  var j;
  var vals;
  for ( j = 0; j < cookies.length; j++ )
  {
    vals = cookies[ j ].split( "=" );
    if ( vals[ 0 ] == cnm )
    {
      ret = vals[ 1 ];
    }
  }
  return( ret );
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　ウィンドウ自動スクロール
//　引数：amount	...増分(Pixel)
//	  delay		...更新タイムアウト(ms)
//　戻値：なし
var s_pos = -1;
var gEOS = 0;
function scrollWin( amount, delay )
{
  if ( !document.getElementById ) return;
  if ( s_pos < document.body.scrollTop )
  {
    if ( s_pos == - 1 )
    {
      s_pos = 0;
    }else{
      s_pos = document.body.scrollTop;
    }
    window.scrollTo( 0, s_pos + amount );

    var callfunc = "scrollWin(" + amount + "," + delay + ")";
    if ( s_pos == 0 )
    {
      setTimeout( callfunc, 2000 );
    }else{
      setTimeout( callfunc, delay );
    }
  }else{
    clearTimeout();
    gEOS = 1;
  }
}
//----------------------------------------------------------------------------------------------------//

var gScrollOn = 1;

//----------------------------------------------------------------------------------------------------//
//　ウィンドウ自動スクロール停止
//　引数：なし
//　戻値：なし
function offScroll()
{
  gScrollOn = 0;
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　ウィンドウ自動スクロール開始
//　引数：なし
//　戻値：なし
function onScroll()
{
  gScrollOn = 1;
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　ウィンドウ自動スクロール（クッキー対応版）
//　引数：なし
//　戻値：なし
function autoScroll()
{
  if ( !document.getElementById ) return;
  var scroll = getCookie( 'scroll' );
  if ( scroll == "" )
  {
    scroll = 3;
  }
  if ( s_pos < document.body.scrollTop && scroll > 0 )
  {
    if ( gScrollOn == 1 )
    {
      if ( s_pos == - 1 )
      {
        s_pos = 0;
      }else{
        s_pos = document.body.scrollTop;
      }
      window.scrollTo( 0, s_pos + 1 );
    }

    var callfunc = "autoScroll()";
    if ( s_pos == 0 )
    {
      setTimeout( callfunc, 6000 / scroll );
    }else{
      setTimeout( callfunc, 300 / scroll );
    }
  }else{
    if ( gScrollOn == 1 )
    {
      clearTimeout();
      gEOS = 1;
    }
  }
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　ウィンドウ手動スクロール
//　引数：updown	...up or down
//　戻値：なし
function manualScroll( updown )
{
  if ( !document.getElementById ) return;
  var scrollvol = getCookie( 'scrollvol' );
  if ( scrollvol == "" )
  {
    scrollvol = 5;
  }
  scrollvol = 11 - scrollvol;
  if ( updown == "up" )
  {
    window.scrollTo( 0, document.body.scrollTop - ( winHeight() / scrollvol ) );
  }else{
    window.scrollTo( 0, document.body.scrollTop + ( winHeight() / scrollvol ) );
  }
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　自動スクロール終了後ジャンプ
//　引数：url		...ジャンプ先URL
//	  frnm		...フレーム名
//	  delay		...更新タイムアウト(ms)
//　戻値：なし
function eosJump( url, frnm, delay )
{
  if ( !document.getElementById ) return;
  var scroll = getCookie( 'scroll' );
  if ( delay > 0 && scroll > 0 )
  {
    if ( gEOS )
    {
      if ( frnm != "" )
      {
        setTimeout( "top." + frnm + ".location.href='" + url + "'", delay / scroll );
      }else{
        setTimeout( "location.href='" + url + "'", delay / scroll );
      }
    }else{
      setTimeout( "eosJump('" + url + "','" + frnm + "'," + delay + ")", 500 );
    }
  }
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　指定時間終了後ジャンプ
//　引数：url		...ジャンプ先URL
//	  frnm		...フレーム名
//	  delay		...更新タイムアウト(ms)
//　戻値：なし
function timeoutJump( url, frnm, delay )
{
  if ( !document.getElementById ) return;
  if ( delay > 0 )
  {
    if ( gEOS )
    {
      if ( frnm != "" )
      {
        setTimeout( "top." + frnm + ".location.href='" + url + "'", delay );
      }else{
        setTimeout( "location.href='" + url + "'", delay );
      }
    }else{
      setTimeout( "timeoutJump('" + url + "','" + frnm + "'," + delay + ")", 500 );
    }
  }
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　点滅表示
//　引数：id		...対象オブジェクト
//	  times		...点滅回数
//	  delay		...更新タイムアウト(ms)
//　戻値：なし
var blinkcnt = 0;
function blink( id, times, delay )
{
  if ( !document.getElementById ) return;
  if ( blinkcnt < times )
  {
    var obj = document.getElementById( id );
    if ( ( blinkcnt % 2 ) == 0 )
    {
      obj.style.color = "rgb(255,255,255)";
    }else{
      obj.style.color = "rgb(0,0,0)";
    }
    blinkcnt++;

    var callfunc = "blink('" + id + "'," + times + "," + delay + ")";
    setTimeout( callfunc, delay );
  }else{
    clearTimeout();
  }
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　フェードイン
//　引数：id		...対象オブジェクト
//	  amount	...増分(カラー16進数)
//	  delay		...更新タイムアウト(ms)
//　戻値：なし
var col = 0;
function fadeIn( id, amount, delay )
{
  if ( !document.getElementById ) return;
  if ( col < 255 )
  {
    var obj = document.getElementById( id );
    obj.style.color = "rgb(" + col + "," + col + "," + col + ")";
    col += amount;

    var callfunc = "fadeIn('" + id + "'," + amount + "," + delay + ")";
    setTimeout( callfunc, delay );
  }else{
    clearTimeout();
  }
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　タイトル表示
//　引数：id1		...対象オブジェクト1
//	  id2		...対象オブジェクト2
//　戻値：なし
function showTitle( id1, id2 )
{
  if ( !document.getElementById ) return;
  setTimeout( "blink( '" + id1 + "', 4, 200 )", 500 );
  setTimeout( "fadeIn( '" + id1 + "', 10, 200 )", 2000 );
  setTimeout( "fadeIn( '" + id2 + "', 10, 200 )", 3000 );
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　ロゴ表示
//　引数：id		...対象オブジェクト
//	  showleft
//	  showtop
//　戻値：なし
function showLogo( id, showleft, showtop )
{
  if ( !document.getElementById ) return;
  var obj = document.getElementById( id );
  var x = scrollLeft() + showleft;
  var y = scrollTop() + showtop;
  obj.style.left = x + "px";
  obj.style.top = y + "px";
  setTimeout( "showLogo( '" + id + "'," + showleft + "," + showtop + " )", 100 );
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　POWER OFF/ON
//　引数：なし
//　戻値：なし
function power()
{
  if ( !document.getElementById ) return;
  if ( window.top.contents.location.href.indexOf( 'kakegoto.tv/ending.htm' ) >= 0 )
  {
    //OFF->ON
    window.top.location.href = '/';
  }else{
    //ON->OFF
    window.top.contents.location.href = '/ending.htm';
  }
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　POWER OFF/ON(Remocon)
//　引数：なし
//　戻値：なし
function remocon_power()
{
  if ( !document.getElementById ) return;
  if ( opener.top.contents.location.href.indexOf( 'kakegoto.tv/ending.htm' ) >= 0 )
  {
    //OFF->ON
    opener.top.location.href = '/';
  }else{
    //ON->OFF
    opener.top.contents.location.href = '/ending.htm';
  }
}
//----------------------------------------------------------------------------------------------------//

//----------------------------------------------------------------------------------------------------//
//　フォーカス設定
//　引数：e	...オブジェクト
//　戻値：なし
function setFocus( e )
{
  if ( !document.getElementById ) return;
  var obj = document.getElementById( e );
  obj.focus();
}
//----------------------------------------------------------------------------------------------------//

