<!--

/* menu_scroll.js Copyright 2005- COSMOS Co.Ltd. All rights reserved. */

var n5, e4;
var oTop, HGT, TGH, limit;
var BarID, moveID, scrolltop;
var delay = 500;
var move = 100;

/* ブラウザ別オブジェクトを返す */
function which( name ) {
  if( e4 ) return document.all( name );
  else if( n5 ) return document.getElementById( name );
  else return;
}

function init() {
  // ブラウザ判定
  if ( document.layers ) return;
  else if ( document.all ) e4 = true;
  else if ( document.getElementById ) n5 = true;
  if( !which('Layer1') ) return;
  if ( n5 ) {
    HGT = innerHeight;
    TG1 = parseInt( which('Layer1').offsetHeight );
    TG2 = parseInt( which('Layer2').offsetHeight );
    oTop = parseInt( which('Layer1').style.top );
  } else if ( e4 ) {
    HGT = document.body.clientHeight;
    TG1 = parseInt( which('Layer1').offsetHeight );
    TG2 = parseInt( which('Layer2').offsetHeight );
    oTop = parseInt( which('Layer1').style.top );
  }
  if( TG1 > TG2 ) TGH = TG1; else TGH = TG2;
  kotei();                                   // 一度位置をセットしておく
  if( n5 ) setInterval( "kotei()", delay );  // NN の場合は再帰呼び出し
}

/* レイヤ位置の固定 */
function kotei() {
  var i = 0;
  if( n5 ) scrolltop = parseInt( window.pageYOffset );
  else if ( e4 ) scrolltop = document.body.scrollTop;
  clearInterval( moveID );
  if( which('Layer1') ) {
    var pos = parseInt( which('Layer1').style.top );
  }
  limit = scrolltop + HGT - TGH;
  if( pos < scrolltop + HGT - TGH ) {
    if( pos < scrolltop - TGH && scrolltop > HGT ) {
      which('Layer1').style.top = scrolltop - TGH - move;
    }
    moveID = setInterval( "BottomMove( scrolltop )", 10 );
  } else if( pos > scrolltop ) {
    if( pos > scrolltop + HGT ) {
      which('Layer1').style.top = scrolltop + HGT - move;
    }
    moveID = setInterval( "UpperMove( scrolltop )", 10 );
  }
  if( e4 ) clearInterval( BarID );
}

/* レイヤ上移動 */
function UpperMove( scrolltop ) {
  var pos1 = parseInt( which('Layer1').style.top );
  var pos2 = parseInt( which('Layer2').style.top );
  move = ( pos1 - scrolltop ) * 0.1;
  if( pos1 <= scrolltop || oTop >= pos1 ) {
    clearInterval( moveID );
  } else {
    which('Layer1').style.top = pos1 + ( -1 * move );
    which('Layer2').style.top = which('Layer1').style.top;
  }
}

/* レイヤ下移動 */
function BottomMove( scrolltop ) {
  var pos1 = parseInt( which('Layer1').style.top );
  var pos2 = parseInt( which('Layer2').style.top );
  move = ( limit - pos1 ) * 0.1;
  if( pos1 >= limit ) {
    clearInterval( moveID );
  } else {
    which('Layer1').style.top = pos1 + ( 1 * move );
    which('Layer2').style.top = which('Layer1').style.top;
  }
}

/* 移動開始ディレイ */
function Bar_startTimeout() {
  if( !which('Layer1') ) return;
  clearInterval( BarID );
  BarID = null;
  BarID = setInterval( "kotei()", delay );
}


 -->
