// -------------------------------------------------------------------------------------------------
// stockweather menu script   Masa "honchun" Nakamura  -  masa@dunksoft.com
//   Copyright (C) 2001 DunkSoft Co., Ltd. All Rights Reserved.
// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------
// ベース
var LAY = (document.layers) ? 1 : 0;
var ALL = (document.all) ? 1 : 0;
var DOM = (!(document.all) && document.getElementById) ? 1 : 0;
var VER3 = (!LAY && !ALL && !DOM) ? 1 : 0;
var VER4 = !VER3;
var WIN = (navigator.platform == "Win32") ? 1 : 0;
var MAC = (navigator.platform == "MacPPC") ? 1 : 0;
var IE5 = (navigator.appVersion.indexOf( "MSIE 5", 0 ) >= 0) ? 1 : 0;
var IE4 = (navigator.appVersion.indexOf( "MSIE 4", 0 ) >= 0) ? 1 : 0;

// -------------------------------------------------------------------------------------------------
// マップコントロール
GYOUSYU = new Array('水産・農林業','鉱業','建設業','食料品','繊維製品','パルプ・紙','化学','医薬品','石油・石炭製品','ゴム製品','ガラス・土石製品',
'鉄鋼','非鉄金属','金属製品','機械','電気機器','輸送用機器','精密機器','その他製品','電気・ガス業','陸運業','海運業','空運業','倉庫・運輸関連業',
'通信業','卸売業','小売業','銀行業','証券、商先','保険','その他金融業','不動産業','サービス業','監理銘柄','整理銘柄','管理銘柄');
MLF = null;
function LS(val,ev) {
	var x,y;
	if (DOM||LAY) {
		x = ev.pageX + 5;
		y = ev.pageY + 20;
	} else {
		x = ev.x + 5;
		y = ev.y + 20;
	}
	if (MLF) clearTimeout(MLF);
	MLF = null;
	wrt_mpop(val);
	set_pos('MMP',x,y)
	show_layer('MMP');
}
function LH() {
	MLF = setTimeout("hide_layer('MMP')", 100);
}
function mpop() {
	var MSG = "";
	if (LAY) {
		MSG += '<layer id="MMP" left="10" top="10" width="115" height="20" z-index="1" visibility="hide"></layer>';
	} else {
		 MSG += '<div id="MMP" style="position:absolute; left:10px; top:10px; width:115px; height:20px; z-index:1; border: 1px none #000000; visibility: hidden"></div>';
	}
	document.write(MSG);
}
function wrt_mpop(val) {
	val = parseInt(val);
	val = GYOUSYU[val-1];
	var MSG = '<table border="0" cellspacing="0" cellpadding="3" border="0" bgcolor="#FFFFCC"><tr><td nowrap>';
	MSG += val;
	MSG += '</td></tr></table>'
	wrt_val('MMP',MSG);
}


// -------------------------------------------------------------------------------------------------
// レイヤーコントロール
function show_layer(obj) {
	if (LAY)      document.layers[obj].visibility = 'show';
	else if (ALL) document.all[obj].style.visibility = 'visible';
	else if (DOM) document.getElementById(obj).style.visibility = 'visible';
}
function hide_layer(obj) {
	if (LAY)      document.layers[obj].visibility = 'hide';
	else if (ALL) document.all[obj].style.visibility = 'hidden';
	else if (DOM) document.getElementById(obj).style.visibility = 'hidden';
}
function get_pos(id,x,y,id2) {
	if (get_pos.arguments.length==4) NN_FW_showMenu(null,id,x,y,id2);
	else NN_FW_showMenu(null,id,x,y);
}
function set_pos(obj,x,y) {
	if (LAY) {
		document.layers[obj].left = x;
		document.layers[obj].top = y;
	} else if(ALL) {
		document.all.item(obj).style.left = x;
		document.all.item(obj).style.top = y;
	} else if(DOM) {
		document.getElementById(obj).style.left = x;
		document.getElementById(obj).style.top = y;
	}
}
function wrt_val(obj,val) {
	if(LAY) {
		with(document.layers[obj].document) {
			open();
			write(val);
			close();
		}
	} else if (ALL) {
		document.all[obj].innerHTML=val;
	} else if (DOM) {
		document.getElementById(obj).innerHTML=val;
	}
}
function check_show(obj) {
	if (LAY) {
		if ( document.layers[obj].visibility == 'hide' ) return false;
		else return true;
	} else if(ALL) {
		if ( document.all[obj].style.visibility == 'hidden' ) return false;
		else return true;
	} else if(DOM) {
		if ( document.getElementById(obj).style.visibility == 'hidden' ) return false;
		else return true;
	}
}

// -------------------------------------------------------------------------------------------------
// メニューイベント
function OMNS() {
	if (LAY) {
		NN_FW_showMenu('SWTOP','SWTOPLOGO',1,-8);
		show_layer('SWTOP');
	} else if(ALL) {
		NN_FW_showMenu('SWTOP','SWTOPLOGO',0,-9);
		show_layer('SWTOP');
	} else if(DOM) {
		NN_FW_showMenu('SWTOP','SWTOPLOGO',0,-9);
		show_layer('SWTOP');
	}
}
function OMNH() {
	hide_layer('SWTOP');
}

// -------------------------------------------------------------------------------------------------
// メニュー作成
function write_menu() {
	var MSG = '';

		if(LAY) {
			MSG += '<layer id="SWTOP"';
			MSG += ' left="0" top="0" width="760" height="70" z-index="1" visibility="hide">'
		} else {
			MSG += '<div id="SWTOP"';
			MSG += ' style="position:absolute; left:0px; top:0px;';
			MSG += ' width:760px; height:70px; z-index:1;';
			MSG += ' visibility:hidden;" >';
		}

		MSG += '<table width="760" border="0" cellspacing="0" cellpadding="0" bgcolor="#FF9408">';
		MSG += '<tr>';
		MSG += '<td width="28"><img src="/sw/images/sw_logoss.gif" width="20" height="20"></td>';
		MSG += '<td width="590">';
		MSG += '<table width="502" border="0" cellspacing="0" cellpadding="0" height="20">';
		MSG += '<tr>';
		MSG += '<td nowrap align="right" width="108">SW300にログイン</td>';
		MSG += '<td align="center" width="20"><img src="/sw/images2/m_arrow.gif" width="9" height="11"></td>';
		MSG += '<td nowrap align="center" width="59" bgcolor="#FFEA86"><a href="https://www.sw300.com/sw/secure/login.asp"><font color="#000000">ログイン</font></a></td>';
		MSG += '<td nowrap align="right" width="200">投資情報サイト”ファンドウェザー”</td>';
		MSG += '<td align="center" width="20"><img src="/sw/images2/m_arrow.gif" width="9" height="11"></td>';
		MSG += '<td nowrap align="center" width="95" bgcolor="#FFEA86"><a href="/fw/"><font color="#000000">ファンドウェザー</font></a></td>';
		MSG += '</tr>';
		MSG += '</table>';
		MSG += '</td>';
		MSG += '<td align="right" width="142"><a href="javascript:OMNH();void(0);"><img src="/sw/images/mclose.gif" width="134" height="20" border="0"></a></td>';
		MSG += '</tr>';
		MSG += '<tr valign="top" align="center">';
		MSG += '<td colspan="3" height="50">';
		MSG += '<table width="760" border="0" cellspacing="0" cellpadding="0">';
		MSG += '<tr bgcolor="#FFFFFF">';
		MSG += '<td height="21" align="center" colspan="3">｜';
		MSG += '<a href="/sw/market/index.html">マーケット</a>｜';
		MSG += '<a href="/sw/news/index.html">ニュース</a>｜';
		MSG += '<a href="/sw/valuesearch/index.html">スクリーニング検索</a>｜';
		MSG += '<a href="/sw/gyro/index.html">銘柄ジャイロ</a>｜';
		MSG += '<a href="/sw/ranking/index.html">ランキング</a>｜';
		MSG += '<a href="/sw/ipo/index.html">IPO(新規公開)情報</a>｜';
		MSG += '<a href="/sw/sec-info/index.html">証券各社レポート</a>｜';
		MSG += '<a href="/sw/ts/index.html">Trader\'s Square</a>｜</td>';
		MSG += '</tr>';
		MSG += '<tr bgcolor="#FFFFFF">';
		MSG += '<td height="27" width="60" align="center">｜<a href="/sw/index.html">ホーム</a></td>';
		MSG += '<td height="27" width="478">';
		MSG += '<table width="478" border="0" cellspacing="0" cellpadding="0">';
		MSG += '<form name="KSEARCHm" action="/scripts/sw/search_k/search_k.asp">';
		MSG += '<tr>';
		MSG += '<td><a href="/scripts/sw/portfolio/p_listview.asp"><img src="/sw/images2/menu.gif" width="211" height="23" vspace="2" hspace="8" border="0"></a></td>';
		MSG += '<td><img src="/sw/images2/k_kenst.gif" width="50" height="11"></td>';
		if (LAY) {
			MSG += '<td width="116">&nbsp;</td>';
			MSG += '<td><a href="javascript:document.KSEARCH.submit();"><img src="/sw/images2/k_kens.gif" width="64" height="19" border="0" alt="株価検索"></a></td>';
		} else {
			MSG += '<td><input type="text" name="T1TXT1" size="15" maxlength="24" style="width:116px"></td>';
			MSG += '<td><input type="image" border="0" src="/sw/images2/k_kens.gif" name="image" width="64" height="19" alt="株価検索"></td>';
		}
		MSG += '</tr>';
		MSG += '</form>';
		MSG += '</table>';
		MSG += '</td>';
		MSG += '<td height="27" align="center" width="222">｜<a href="/scripts/sw/portfolio/p_listview.asp"><img src="/sw/images/m/my.gif" width="18" height="10" border="0">登録銘柄一覧</a>｜<a href="http://www.sw300.com/sw/"><font color="#CC0000">SW300について</font></a>｜</td>';
		MSG += '</tr>';
		MSG += '<tr>';
		MSG += '<td height="2"></td>';
		MSG += '<td height="2"></td>';
		MSG += '<td height="2"></td>';
		MSG += '</tr>';
		MSG += '</table>';
		MSG += '</td>';
		MSG += '</tr>';
		MSG += '</table>';

		if(LAY) {
			MSG += '</layer>';
		} else {
			MSG += '</div>';
		}

	document.write(MSG);
}

// -------------------------------------------------------------------------------------------------
// 新規ウィンドウ
function open_win(ln,nm,w,h,pa) {
	pa = pa + ",width=" + w + ",height=" + h;
	window.open(ln,nm,pa);
}

// -------------------------------------------------------------------------------------------------
// トップニュース
function topnews_win(url) {
	var nm = 'meiwin';
	var w = 550;
	var h = 450;
	var pa = 'resizable=yes,scrollbars=yes';

	open_win(url,nm,w,h,pa);
}

// ポップアップ
function popup_win(url) {
	var nm2 = 'popwin';
	var w2 = 625;
	var h2 = 500;
	var pa = 'resizable=yes,scrollbars=yes';

	open_win(url,nm2,w2,h2,pa);
}

// NN_FW_showMenu()
//
//   2001.05.16
//   http://homepage2.nifty.com/nansya/JavaScript/FW_MENU/ nansya@big.or.jp
//   http://www.get-extension.com/fw_depository/           sakai

//
//   This function shows  fireworks4 pop-up menu with relative positon
//   from image object ,  not with absolute position.
//
//   argv[0]  : fireworks pop-up menu object
//   argv[1]  : image name or 'this'  ('this' is anchor object )
//   argv[2]  : relative X position
//   argv[3]  : relative Y position
//
// HOW TO
// step 1. add next source  in your  HTML.
//
//  <script language="JavaScript1.2" src="NN_fw_menu.js"></script>
//
// step 2. change your onMouseOver evnt handler.
//
//   before : onMouseOver="window.FW_showMenu( fw_menu0,  absoluteX, absoluteY );"
//   after  : onMouseOver="NN_FW_showMenu( fw_menu0,  'imageName', relativeX, relativeY );" or
//            onMouseOver="NN_FW_showMenu( fw_menu0,  this , relativeX, relativeY );"

function NN_FW_showMenu( FWmenuID, targetObj, offsetX, offsetY ) {
	var x, y;
	if(document.layers) {
		// Navigator 4
		if ( targetObj.href ){
			// text link
			x = targetObj.x ;
			y = targetObj.y ;
			for(i=0; i<document.layers.length; i++){
				for(j=0; j<document.layers[i].document.links.length; j++){
					if(document.layers[i].document.links[j] == targetObj ){
						x += document.layers[i].left;
						y += document.layers[i].top;
					}
				}
			}
		} else {
			// image link
			var imageObject = document.images[targetObj];
			if (!imageObject){
				for(i=0; i<document.layers.length; i++){
					if(document.layers[i].document.images[targetObj]){
						imageObject = document.layers[i].document.images[targetObj];
						x = imageObject.x ;
						y = imageObject.y ;
						x += document.layers[i].left;
						y += document.layers[i].top;
					}
				}
			}else{
				x = imageObject.x ;
				y = imageObject.y ;
			}
		}
		x -= 1; y-= 1;	 // adjust
		x += offsetX;
		y += offsetY;
	} else {
		// IE , NN6
		var version = navigator.appVersion;

		if ( (document.all && version.indexOf( "MSIE 4", 0 ) >= 0 )){
			 //  IE4.x
			 x = event.x + document.body.scrollLeft ;
			 y = event.y  + document.body.scrollTop ;
		} else {
			if( targetObj.href ){
				// text link
				x = targetObj.offsetLeft;
				y = targetObj.offsetTop;
				tempEl = targetObj.offsetParent;
			} else {
				// image link
				var targetObj = document.images[targetObj] ;
				x = eval(targetObj).offsetLeft;
				y = eval(targetObj).offsetTop;
				tempEl = eval(targetObj).offsetParent;
			}
			while (tempEl != null) {
				x += tempEl.offsetLeft;
				y += tempEl.offsetTop;
				tempEl = tempEl.offsetParent;
			}
			if ( document.all && navigator.appVersion.indexOf("Mac") >= 0) {
				// Mac IE
				y += parseInt(document.body.topMargin );
				x += parseInt(document.body.leftMargin) ;
			}
			x += offsetX;
			y += offsetY;
		}
	 }
//	window.FW_showMenu( FWmenuID, x, y );  // change by masa
	set_pos(FWmenuID,x,y);  // change by masa
}
