// =============================================================================
// ヘッダ管理クラス
// =============================================================================
/*
   Header クラス

   最終更新日:2004年2月19日(木)
   -----------------------------------------------------------------------------

   依存
	sniffer.js
	broadcaster.js
	multipleimage.js
	document.js
	navigation.js
	window_onload.js

   -----------------------------------------------------------------------------

   コンストラクタの引数
	無し

   -----------------------------------------------------------------------------

   メソッド
	- init()
		初期化

	- onReady()
		イベント（windowからとんでくるイベント）

	- setSimpleMultipleImage();
		submenuのULに連なる画像を単純なロールオーバーにする。
		（今回オリジナル）
*/
// =============================================================================
if(sniffer.DOMable()) {



// -----------------------------------------------------------------------------
/*
   オブジェクト準備
*/
function Header() {
	this.navis = null;

	this.init();
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
/*
   initメソッド
	Null header.init()
*/
Header.prototype.init = function() {
	//タイミングがただのロールオーバーではないので手動でMultipleImage作ります。

	//TOP
	this.topImg = new MultipleImage();
	this.topImg.addState( "on", document.getRootPath() + "images_public/navigation/top_on.gif" );
	this.topImg.addState( "off", document.getRootPath() + "images_public/navigation/top.gif" );

	//TBSサービスとは
	this.profileImg = new MultipleImage();
	this.profileImg.addState( "on", document.getRootPath() + "images_public/navigation/profile_on.gif" );
	this.profileImg.addState( "off", document.getRootPath() + "images_public/navigation/profile.gif" );

	//サービス内容
	this.serviceImg = new MultipleImage();
	this.serviceImg.addState( "on", document.getRootPath() + "images_public/navigation/service_on.gif" );
	this.serviceImg.addState( "off", document.getRootPath() + "images_public/navigation/service.gif" );

	//会社案内
	this.companyImg = new MultipleImage();
	this.companyImg.addState( "on", document.getRootPath() + "images_public/navigation/company_on.gif" );
	this.companyImg.addState( "off", document.getRootPath() + "images_public/navigation/company.gif" );

	//社員採用
	this.recruitImg = new MultipleImage();
	this.recruitImg.addState( "on", document.getRootPath() + "images_public/navigation/recruit_on.gif" );
	this.recruitImg.addState( "off", document.getRootPath() + "images_public/navigation/recruit.gif" );

	//プルダウン子メニューのスタイルをJavaScriptから変更(JavaScriptオフブラウザへの対応)
	document.open();
	document.write('<link href="'+document.getRootPath()+'css/headerjs.css" rel="stylesheet" type="text/css" media="all" />\n');
	document.close();
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
/*
   readyイベント（windowから教えてもらえるイベント）
	Null header.onReady()
*/
Header.prototype.onReady = function() {
	//TOP
	this.topImg.setImageObject(document.getElementById("menu_top").firstChild);
	rootnaviBase.addChild(new Navigation(null, this.topImg.imageObject.parentNode, this.topImg));

	//TBSサービスとは
	this.profileImg.setImageObject(document.getElementById("menu_profile").firstChild);
	rootnaviBase.addChild(new Navigation(document.getElementById("submenu_profile"), this.profileImg.imageObject.parentNode, this.profileImg));
	//TBSサービスとはサブメニュー
	this.setSimpleMultipleImage(document.getElementById("submenu_profile"));

	//サービス内容メニュー
	this.serviceImg.setImageObject(document.getElementById("menu_service").firstChild);
	rootnaviBase.addChild(new Navigation(document.getElementById("submenu_service"), this.serviceImg.imageObject.parentNode, this.serviceImg));
	//サービス内容サブメニュー
	this.setSimpleMultipleImage(document.getElementById("submenu_service"));

	//会社案内
	this.companyImg.setImageObject(document.getElementById("menu_company").firstChild);
	rootnaviBase.addChild(new Navigation(document.getElementById("submenu_company"), this.companyImg.imageObject.parentNode, this.companyImg));
	//会社案内サブメニュー
	this.setSimpleMultipleImage(document.getElementById("submenu_company"));

	//社員採用
	this.recruitImg.setImageObject(document.getElementById("menu_recruit").firstChild);
	rootnaviBase.addChild(new Navigation(document.getElementById("submenu_recruit"), this.recruitImg.imageObject.parentNode, this.recruitImg));
	//社員採用サブメニュー
	this.setSimpleMultipleImage(document.getElementById("submenu_recruit"));

	rootnaviBase.setEventToChildren();
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
/*
   setSimpleMultipleImageメソッド
	Null header.setSimpleMultipleImage()
*/
Header.prototype.setSimpleMultipleImage = function(ul_element) {
	maybe_lis = ul_element.childNodes;
	for(var i=0; i<maybe_lis.length; i++) {
		if(maybe_lis[i].tagName == "LI") {
			var imgsrc = maybe_lis[i].firstChild.firstChild.src;
			var imgobj = new MultipleImage(imgsrc);
			imgobj.setImageObject(maybe_lis[i].firstChild.firstChild);
		}
	}
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
/*
   インスタンス化
*/
var header = new Header();
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
/*
   windowさんにイベントを教えてもらえるようにする。
*/
window.addListener(header);
// -----------------------------------------------------------------------------
}