///////////////////////////////////////////////
// version: rev3
// writer: miyu
// written-date: 2008/12/12
// history:

ncsj = function() {};
ncsj.layout = function() {};

ncsj.layout.Utils = {

	/////////////////////////////////////////////////
	// make a popup panel
	//
	// ncsj.layout.Utils.MakePopupPanel(idStr, thePanelStr, otherPanelStrsArr);
	//
	// idStr: the id of the img tag.
	// thePanelStr: the id of the div tag which represents current popup panel.
	// otherPanelStrsArr: an array of strings which are ids of the div tags for other popup panels.
	//
	// example:
	//		ncsj.layout.Utils.MakePopupPanel('mmorpg_button',
	//			'plaync_red-game-nav',
	//			['plaync_green-game-nav', 'plaync_shop-nav']);

  MakePopupPanel: function (buttonStr, panelStr, panelListBehind) {
	var button = $(buttonStr);
	var panel = $(panelStr);
	var timer = null;
	var timeout = 100;
	var highPos = 999;
	var lowPos = 0;

	var showPanel = function () {
		panel.setStyle({'display':'block'});
		panel.setStyle({'z-index': highPos});
		if (null != timer) {
			clearTimeout(timer);
			clearInterval(timer);
		}

		panelListBehind.each(function (otherPanelStr, i) {
			var otherPanel = $(otherPanelStr);
			otherPanel.setStyle({'z-index': lowPos});
			otherPanel.setStyle({display:'none'});
		});
	};
	var hidePanel = function () {
		var hideFunc = function () {
			panel.setStyle({display:'none'});
		};
		timer = window.setTimeout(hideFunc, timeout);
	};

	button.observe('mouseover', showPanel);
	panel.observe('mouseover', showPanel);
	button.observe('mouseout', hidePanel);
	panel.observe('mouseout', hidePanel);
},

	//////////////////////////////////////////////
	// make a hightlight button.
	//
	// ncsj.layout.Utils.MakeHightlightLinkButton(idStr, f1, f2);
	//
	// idStr: the id of the img tag.
	// f1: function which called when the mouse is over the img.
	// f2: function which called when the mouse is out of the img.
	//
	// example:
	//		ncsj.layout.Utils.MakeHightlightLinkButton('red-game_button',
	//		function (e) {
	//			e.src = img_prefix + "nav_red-game-on.gif";
	//		},
	//		function (e) {
	//			e.src = img_prefix + "nav_red-game-off.gif";
	//		});
  MakeHightlightLinkButton: function (imgStr, whenTurnOn, whenTurnOff) {
	var img = $(imgStr);
	img.observe('mouseover', function () {
		whenTurnOn(img);
	});
	img.observe('mouseout', function () {
		whenTurnOff(img);
	});
  }
};

ncsj.layout.GlobalNaviOut = {

  Show: function (imgRootPath) {
  	arr = [];
	arr.push("<div id='gnb_navi2'>");
	arr.push("	<table>");
	arr.push("	<tbody>");
	arr.push("	<tr>");
	arr.push("		<td>");
	arr.push("			<div class='top_area'>");
	arr.push("				<p><a href='http://www.plaync.jp/'><img src='img/logo.gif' alt='plaync'></a></p>");
	arr.push("				<ul class='top_menu'>");
	arr.push("					<li class='open_list' id='btnGameList'><a href='http://game.plaync.jp/'>ゲーム</a></li>");
	arr.push("					<li><a href='http://minigame.plaync.jp/'>ミニゲーム</a></li>");
	arr.push("					<li><a href='http://blog.plaync.jp/'>ブログ</a></li>");
	arr.push("					<li><a href='http://club.plaync.jp/'>クラブ</a></li>");
	arr.push("					<li><a href='http://shop.plaync.jp/'>ショップ</a></li>");
	arr.push("					<li><a href='http://lounge.plaync.jp/'>ラウンジ</a></li>");
	arr.push("				</ul>");
	arr.push("				<ul class='game_navi' id='game_navi_list' style='display:none;'>");
	arr.push("					<li><a href='http://aion.plaync.jp/'>タワー オブ アイオン</a></li>");
	arr.push("					<li><a href='http://lineage2.plaync.jp/'>リネージュＩＩ</a></li>");
	arr.push("					<li><a href='http://lineage.plaync.jp/'>リネージュ</a></li>");
	arr.push("					<li><a href='http://janryumon.plaync.jp/'>雀龍門</a></li>");
	arr.push("					<li><a href='http://guildwars.plaync.jp/'>ギルド ウォーズ</a></li>");
	arr.push("					<li><a href='http://suddenattack.plaync.jp/'>サドンアタック</a></li>");
	arr.push("					<li class='last'><a href='http://driftcity.plaync.jp/'>ドリフトシティ</a></li>");
	arr.push("				</ul>");
	arr.push("			</div>");
	arr.push("		</td>");
	arr.push("		<td class='quick_menu'>");
	arr.push("			<ul>");
	arr.push("				<li><a href='http://www.plaync.jp/guide/kantan_guide.html'>かんたんガイド</a></li>");
	arr.push("				<li><a href='http://support.plaync.jp/'>サポート</a></li>");
	arr.push("				<li><a href='http://shop.plaync.jp/kaimocharge/index.nc'>カイモチャージ</a></li>");
	arr.push("			</ul>");
	arr.push("		</td>");
	arr.push("	</tr>");
	arr.push("	</tbody>");
	arr.push("	</table>");
	arr.push("</div>");

	if (undefined == imgRootPath) {
		imgRootPath = 'http://static.plaync.jp/common/top/img/';
	}
	document.write(arr.join("").replace(/\'img\//g, '\'' + imgRootPath));

  	////////////////////////////
	// show/hide popup menus
  	////////////////////////////
	ncsj.layout.Utils.MakePopupPanel('btnGameList', 'game_navi_list', []);
  }
};