//-------------------------------------------------------------------
// ブラウザ情報設定
// Dom_mac 	macの場合					true
// Dom_win 	winの場合					true
// Dom_IE 	IEの場合					true
// Dom_IE4 	IE4の場合					true
// Dom_IE45 IE4.5の場合					true
// Dom_IE5	IE5の場合					true
// Dom_IE55	IE5.5の場合					true
// Dom_IE6	IE6以上の場合				true
// Dom_NN4	Netscape4の場合				true
// Dom_NN47	Netscape4.7の場合(Default)	true
// Dom_NN6	Netscape6以上の場合			true
// Dom_NN60	Netscape6.0の場合			true
// Dom_NN61	Netscape6.1の場合			true
//-------------------------------------------------------------------
var Dom_IE4		= false ;
var Dom_IE5		= false ;
var Dom_IE55	= false ;
var Dom_IE6		= false ;
var Dom_NN4		= false ;
var Dom_NN47	= false ;
var Dom_NN6		= false ;
var Dom_NN60	= false ;
var Dom_NN61	= false ;
var Dom_FLET	= false ;

// Mac or Win判定
var Dom_mac = false ;
var Dom_win = false ;

Dom_mac = navigator.userAgent.indexOf( 'Mac' ) != -1 ;
if( ! Dom_mac ){
	Dom_win = true ;
}

// NN or IE判定
var Dom_IE = false ;
var Dom_NN = false ;

Dom_IE = navigator.userAgent.indexOf( 'MSIE' ) != -1 ;
if( ! Dom_IE ){
	Dom_NN = navigator.userAgent.indexOf( 'Mozilla' ) != -1 ;
}

if( Dom_IE ){
	// IE Version判定
	Dom_IE4 = navigator.userAgent.indexOf( 'MSIE 4' ) != -1 ;
	Dom_IE5 = navigator.userAgent.indexOf( 'MSIE 5' ) != -1 ;
	if( Dom_IE5 ){
		Dom_IE55 = navigator.userAgent.indexOf( 'MSIE 5.5' ) != -1 ;
		if( Dom_IE55 ){
			Dom_IE5 = false ;
		}
	}
	Dom_IE6 = navigator.userAgent.indexOf( 'MSIE 6' ) != -1 ;
	// IE4.x,5.x,6.x以外のIEはIE4として処理
	if( Dom_IE4 != true && Dom_IE5 != true && Dom_IE55 != true && Dom_IE6 != true ){
		Dom_IE4 = true ;
	}
	// 特定の UserAgent は、IE 4 として扱う
	if( navigator.userAgent.indexOf( 'Fletsphone' ) != -1 ){
		Dom_IE4	 = false ;
		Dom_IE5	 = false ;
		Dom_IE55 = false ;
		Dom_IE6	 = false ;
		Dom_FLET = true ;
	}
}else if( Dom_NN ){
	// NN Version判定
	Dom_NN4 = navigator.userAgent.indexOf( 'Mozilla/4' ) != -1 ;
	if( Dom_NN4 ){
		Dom_NN47 = navigator.userAgent.indexOf( 'Mozilla/4.7' ) != -1 ;
		if( Dom_NN47 ){
			Dom_NN4 = false ;
		}
	}
	// Netscape6.2以上の場合Dom_NN6はtrue
	Dom_NN6 = navigator.userAgent.indexOf( 'Netscape6' ) != -1 ;
	if( Dom_NN6 ){
		Dom_NN60 = navigator.userAgent.indexOf( 'Netscape6/6.0' ) != -1 ;
		Dom_NN61 = navigator.userAgent.indexOf( 'Netscape6/6.1' ) != -1 ;
	}
	// NN4.x,6.x以外のNNはNN6として処理
	if( Dom_NN4 != true && Dom_NN47 != true && Dom_NN6 != true ){
		Dom_NN6 = true ;
	}
}else{
	// IE,NN以外のブラウザはNetscape4.7と認識
	Dom_NN47 = true ;
}

//-------------------------------------------------------------------
// DHTML使用グローバル定義
//-------------------------------------------------------------------
var N_loaded = true ;
var N_tid ;
var N_selectedNo = 1 ;
var N_hideSwich = 'false' ;

//-------------------------------------------------------------------
// 各メニューの表示X座標
//-------------------------------------------------------------------
var posStatic_menu1 = 0 ;
var posStatic_menu2 = 126 ;
var posStatic_menu3 = 252 ;
var posStatic_menu4 = 378 ;
var posStatic_menu5 = 504 ;
var posStatic_menu6 = 629 ;

//-------------------------------------------------------------------
// メニューテーブルの幅
//-------------------------------------------------------------------
var width_table = 875 ;

//-------------------------------------------------------------------
// ウィンドウサイズ取得
//-------------------------------------------------------------------
function getWindowWidth(){
	return document.body.clientWidth ;
}

//-------------------------------------------------------------------
// メニューレイヤの表示位置を設定
//-------------------------------------------------------------------
function moveDivTo( div, left, top ){
	div.style.pixelLeft = left ;
	div.style.pixelTop = top ;
	return ;
}

//-------------------------------------------------------------------
// レイヤ名を取得
//-------------------------------------------------------------------
function getDivName( div ){
	return div.id ;
}

//-------------------------------------------------------------------
// メニューレイヤを中央に移動する
//-------------------------------------------------------------------
function moveCenterX( No ){
	var pos ;
	var w_width ;
	var layerName = 'menu' + No ;
	var div = getDivObjName( layerName ) ;

	// 座標計算
	// ※計算式
	// （現在のウィンドウサイズ − メニューテーブルのサイズ）÷ ２
	//									＋ 各メニューのＸ座標のオフセット
	w_width = Math.floor( getWindowWidth() ) ;
	if( w_width > width_table ){
		pos = Math.floor( ( w_width - width_table ) / 2 ) + eval( 'posStatic_menu' + No ) ;
	}else{
		pos = eval( 'posStatic_menu' + No ) ;
	}

	// レイアの移動
	moveDivTo( div, pos, 118 ) ;
}

//-------------------------------------------------------------------
// レイヤ名からレイヤオブジェクトを取得する
//-------------------------------------------------------------------
function getDivObjName( nm ){
	return document.getElementById( nm ) ;
}

//-------------------------------------------------------------------
// URLの切り替え
//-------------------------------------------------------------------
function N_changeUrl( url ){
	location.href = url ;
}

//-------------------------------------------------------------------
// URLの切り替え(トップ対応)
//-------------------------------------------------------------------
function N_changeUrl2( url ){
	var top_w = window.top ;
	top_w.location.href = url ;
}

//-------------------------------------------------------------------
// ロード時のブラウザ判別
//-------------------------------------------------------------------
function N_changeLdFast(){
	cookie_check() ;
	var top_type = blgetCookie( 'TopType' ) ;

	if( Dom_IE55 || Dom_IE6 ){
		if( top_type == 2 ){
			N_changeUrl( './index2.html' ) ;
		}
	}else if( Dom_FLET ){
		N_changeUrl( './tvphone/index.html' ) ;
	}else{
		N_changeUrl( './index2.html' ) ;
	}
	blsetCookie( 'TopType', 1 ) ;
}

//-------------------------------------------------------------------
// ロード時の初期処理
//-------------------------------------------------------------------
function N_changeLdMode(){
	N_loaded = true ;
	// タイマが起動中の場合
	if( N_tid ){
		// タイマクリア
		clearTimeout( N_tid ) ;
	}
}

//-------------------------------------------------------------------
// 該当するレイヤを表示し、現在表示されているレイヤを隠す
//-------------------------------------------------------------------
function N_showMenu( No ){
	if( N_loaded ){
		// 表示中のレイヤを隠す
		N_hideMenu() ;

		// 表示中のメニュー番号を保持
		N_selectedNo = No ;

		if( N_tid ){
			// タイマクリア
			clearTimeout( N_tid ) ;
		}

		// タイマセット
		N_tid = setTimeout( 'N_showMenu2();', 100 ) ;
	}
}

function N_showMenu2(){
	var N_obj ;

	N_hideSwich = 'true' ;
	N_layerName ='menu' + N_selectedNo ;

	// メニューをセンターへ表示
	moveCenterX( N_selectedNo ) ;

	N_obj = getDivObjName( N_layerName ) ;

	// 表示属性の設定
	N_obj.style.visibility = 'visible' ;
}

//-------------------------------------------------------------------
// 表示中のレイヤを隠す
//-------------------------------------------------------------------
function N_hideMenu(){
	var N_obj ;

	// 表示中のメニュー番号より該当するレイヤ名を生成
	N_layerName = 'menu' + N_selectedNo ;
	N_obj = getDivObjName( N_layerName ) ;

	if( N_tid ){
		// タイマクリア
		clearTimeout( N_tid ) ;
	}

	if( N_hideSwich == 'true' ){
		// 表示属性の設定
		N_obj.style.visibility = 'hidden' ;
	}
}

//-------------------------------------------------------------------
// マウスアウト時、レイヤを消すまでの時間(タイマ)をセット
//-------------------------------------------------------------------
function N_menuCloseTimer( No ){
	if( N_loaded ){
		N_selectedNo = No ;
		N_hideSwich = 'true' ;

		if( N_tid ){
			// タイマクリア
			clearTimeout( N_tid ) ;
		}

		// タイマセット
		N_tid = setTimeout( 'N_hideMenu();', 400 ) ;
	}
}

//-------------------------------------------------------------------
// レイヤ部分にマウスオンした時のフラグ設定
//	※N_hideMenu()で参照
//-------------------------------------------------------------------
function N_swichOFF(){
	N_hideSwich = 'false' ;
}
