<!--

/*
-----------------------------------------------
title:　各画面共有スクリプト
original version:  2006.09.23
original modified by: defide

last version: 2007.1.17
last modified by: TLC

----------------
:: history ::
2007.1.9  satoh 各ボタンのソースのパスを変更（"../common/img/" -> "common/img/")
2007.1.17 satoh getCommonPath() ファンクションでimageSrc が見つからない場合の制御を追加
----------------------------------------------- */

// フォントサイズ設定用cookie設置

function setCookie(theName, theValue) {
	if(navigator.cookieEnabled){
		expDay = 30;
		setDay = new Date();
		setDay.setTime(setDay.getTime() + (expDay*1000*24*3600));
		prd = setDay.toGMTString();
		document.cookie = theName + "=" + theValue + ";expires=" + prd + ";path=/";
	}
}

function getCookie(theName) {
	theName += "=";
	theCookie = document.cookie+";";
	start = theCookie.indexOf(theName);
	if(start != -1) {
		end = theCookie.indexOf(";",start);
		return unescape(theCookie.substring(start + theName.length, end));
	}
	return false;
}

function checkFontSetCookie(){
	getValue = getCookie("FONTSIZE");
	//alert("getValue=" +getValue);
	//alert("pathCommon =" +pathCommon);
	if(getValue){
		switch(getValue){
			case "big" : fontBig(),chFontsizeImg(getValue);
						break;
			case "middle" : fontMiddle(),chFontsizeImg(getValue);
						break;
			case "small" : fontSmall(),chFontsizeImg(getValue);
						break;
			default:break;
		}
	}else{
		document.getElementById("bt_middle").src= pathCommon +"common/img/bt_middle_a.gif";
	}
}

// フォント（大）選択時の処理
function fontBig(){
	broserType = chkBrowserType();
	cssPath =  pathCommon +"common/css/fontsize_big.css";
	if (broserType == "macIE5"){
		document.createStyleSheet(cssPath);
		chFontsizeImg("big")
		setCookie("FONTSIZE", "big");
	} else if (document.getElementById){
		fontStyle = document.createElement("link");
		fontStyle.setAttribute("href", cssPath);
		fontStyle.setAttribute("rel", "stylesheet");
		fontStyle.setAttribute("type", "text/css");
		document.getElementsByTagName('head')[0].appendChild(fontStyle);
		chFontsizeImg("big");
		setCookie("FONTSIZE", "big");
	} 
}

// フォント（中）選択時の処理
function fontMiddle(){
	broserType = chkBrowserType();
	cssPath =  pathCommon +"common/css/fontsize_middle.css";
	if (broserType == "macIE5"){
		document.createStyleSheet(cssPath);
		chFontsizeImg("middle")
		setCookie("FONTSIZE", "middle");
	} else if (document.getElementById){
		fontStyle = document.createElement("link");
		fontStyle.setAttribute("href", cssPath);
		fontStyle.setAttribute("rel", "stylesheet");
		fontStyle.setAttribute("type", "text/css");
		document.getElementsByTagName('head')[0].appendChild(fontStyle);
		chFontsizeImg("middle")
		setCookie("FONTSIZE", "middle");
	}
}

// フォント（小）選択時の処理
function fontSmall(){
	broserType = chkBrowserType();
	cssPath =  pathCommon +"common/css/fontsize_small.css";
	if (broserType == "macIE5"){
		document.createStyleSheet(cssPath);
		chFontsizeImg("small")
		setCookie("FONTSIZE", "small");
	} else if (document.getElementById){
		fontStyle = document.createElement("link");
		fontStyle.setAttribute("href", cssPath);
		fontStyle.setAttribute("rel", "stylesheet");
		fontStyle.setAttribute("type", "text/css");
		document.getElementsByTagName('head')[0].appendChild(fontStyle);
		chFontsizeImg("small")
		setCookie("FONTSIZE", "small");
	}
}

// commonまでのパス取得 -------------------------------------------------------------------

pathCommon = "";
function getCommonPath(){

	// -- ## satoh mod 2007.01.16
	imageSrc = new Image().src;

	if (document.images["bt_pagetop"]) {
		imageSrc = document.images["bt_pagetop"].src;
	} else {
		imageSrc = top.footer.document.images["bt_pagetop"].src;
	}
	// -- ## satoh mod 2007.01.16

	strNum = imageSrc.indexOf("common",0);
	pathCommon = imageSrc.substring(0,strNum);
}

// 文字拡大縮小時の画像表示切替-------------------------------------------------------------
function chFontsizeImg(pos){
		switch(pos){
			case "big" : document.getElementById("bt_bigger").src= pathCommon + "common/img/bt_bigger_a.gif";
						 document.getElementById("bt_middle").src= pathCommon + "common/img/bt_middle.gif";
						 document.getElementById("bt_smaller").src= pathCommon + "common/img/bt_smaller.gif";
						 break;
			case "middle" :document.getElementById("bt_bigger").src= pathCommon + "common/img/bt_bigger.gif";
						 document.getElementById("bt_middle").src= pathCommon + "common/img/bt_middle_a.gif";
						 document.getElementById("bt_smaller").src= pathCommon + "common/img/bt_smaller.gif";
						 break;
			case "small" :document.getElementById("bt_bigger").src= pathCommon + "common/img/bt_bigger.gif";
						 document.getElementById("bt_middle").src= pathCommon + "common/img/bt_middle.gif";
						 document.getElementById("bt_smaller").src= pathCommon + "common/img/bt_smaller_a.gif";
						 break;
			default:break;
		}
}

// イメージオブジェクトストック用配列
imgObjOver = new Array();
imgObjOut = new Array();
imgObjID = new Array();

// 画像イメージの初期ロード
function imgStock(id,overImgSrc,outImgSrc){
	imgID = id.split(",");
	overImg = overImgSrc.split(",");
	outImg = outImgSrc.split(",");
	for(i=0; i<imgID.length; i++){
		imgObjID[i] = imgID[i];
		imgObjOver[i] = new Image();
		imgObjOver[i].src = overImg[i];
		imgObjOut[i] = new Image();
		imgObjOut[i].src = outImg[i];
	}
/*
	var str="";
	for(i=0; i<imgID.length; i++){
		str += imgID[i];
		str += "\n";
	}
	alert(str);
*/
}

// ロールオーバー処理
function rollOver(imgId){
	id = typeof(imgId);
	if(id == "string"){
		var findID = imgId;
	}else{
		var findID = this.id;
	}
	var overImageSrc;

	for(i=0; i<imgObjID.length; i++){
		if(imgObjID[i] == findID){
			overImageSrc = imgObjOver[i].src;
		}
	}
	document.getElementById(findID).src = overImageSrc;
}
	
// ロールアウト処理
function rollOut(imgId){
	id = typeof(imgId);
	if(id == "string"){
		var findID = imgId;
	}else{
		var findID = this.id;
	}
	var outImageSrc;
	for(i=0; i<imgObjID.length; i++){
		if(imgObjID[i] == findID){
			outImageSrc = imgObjOut[i].src;
		}
	}
	document.getElementById(findID).src = outImageSrc;
}

// 印刷時設定
function printsetting(printcss){
	
	broserType = chkBrowserType();
	cssPath = pathCommon + printcss;
	
//	cssPath = pathCommon + css;
	if (document.getElementById){
		printStyle = document.createElement("link");
		printStyle.setAttribute("href", cssPath);
		printStyle.setAttribute("rel", "stylesheet");
		printStyle.setAttribute("type", "text/css");
		document.getElementsByTagName('head')[0].appendChild(printStyle);
		print();
	}
}

//左ナビゲーションの高さ取得＆表示エリア調整
DefaultPageContentsHeight = 0;
function setHightIframe(){
	if(top.navi.document.body.clientHeight){
		frameContentsHeight = top.navi.document.body.clientHeight;
	}else{
		frameContentsHeight = top.navi.document.height;
	}
	//IFRAMEの高さ設定
	document.getElementById("navi").height = frameContentsHeight;
}

/**
 * 上場検索 処理。
 * 
 */
function stockSearch() {
	if(document.topsearch.topSearchStr.value.replace(/^[ 　]+/,"") == ""){
		document.topsearch.topSearchStr.value="";
		window.alert("Please input the company name or code.");
		return false;
	}
	document.topsearch.method.value="topsearch";
	//document.topsearch.action = "http://hp.ift.tse.or.jp/tseHpFront/StockSearch.do";
	document.topsearch.action = "/tseHpFront/StockSearch.do";
	document.topsearch.submit();
	return false;

}

/**
 * EnterKey 処理。
 * 
 */
function enterKey() {

	if(event.keyCode == 13) {
		//stockSearch();
		return stockSearch();
	}

}
function TDnetLink(){
        var myWin = window.open('http://www.tse.or.jp/cgi-bin/TDnet/TDnet.cgi','sub',
        'location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,fullscreen=no,top=0,left=0,width=930,height=670');
}
//-->
