<!--

/*
-----------------------------------------------
title:　各画面共有スクリプト
original version:  2006.09.23
original modified by: defide

last version: 2007.1.17
last modified by: TLC

----------------
:: history ::
2010.2.11 LW NEWアイコン制御スクリプト・汎用ロールオーバースクリプトを追加
2010.2.3 LW 各ボタンのソースのパスをコメントアウト
2010.2.3 LW 画像パスを変更
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/wr-img/bt_middle_a.gif";
	}
}

// フォント（大）選択時の処理
function fontBig(){
	broserType = chkBrowserType();
	cssPath =  pathCommon +"/common/wr-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/wr-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/wr-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(){


	// -- ## LW mod 2010/02/03
	// -- ## 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/wr-img/bt_bigger_a.gif";
						 document.getElementById("bt_middle").src= pathCommon + "/common/wr-img/bt_middle.gif";
						 document.getElementById("bt_smaller").src= pathCommon + "/common/wr-img/bt_smaller.gif";
						 break;
			case "middle" :document.getElementById("bt_bigger").src= pathCommon + "/common/wr-img/bt_bigger.gif";
						 document.getElementById("bt_middle").src= pathCommon + "/common/wr-img/bt_middle_a.gif";
						 document.getElementById("bt_smaller").src= pathCommon + "/common/wr-img/bt_smaller.gif";
						 break;
			case "small" :document.getElementById("bt_bigger").src= pathCommon + "/common/wr-img/bt_bigger.gif";
						 document.getElementById("bt_middle").src= pathCommon + "/common/wr-img/bt_middle.gif";
						 document.getElementById("bt_smaller").src= pathCommon + "/common/wr-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("銘柄名または銘柄コードを入力して下さい。");
		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');
}


// NEWアイコン制御スクリプト
var nowIconDate = new Date();
function iconDateCH(year,month,day,period){
	publishDate = new Date(year,month-1,day);
	countDay = Math.floor((nowIconDate.getTime()-publishDate.getTime())/(1000*60*60*24));
	if(countDay >= 0 && countDay<period) document.write('<img src="/common/wr-img/icon_new.gif" alt="NEW!" width="34" height="13" />');
}

// 汎用ロールオーバースクリプト
function ROfunction(){
	var imgNum=document.getElementsByTagName("img");
	var inputNum=document.getElementsByTagName("input");
	overNum=new Array;
	for(i=0;i<imgNum.length;i++){overNum.push(imgNum[i]);}
	for(i=0;i<inputNum.length;i++){overNum.push(inputNum[i]);}
	for(i=0;i<overNum.length;i++){
		if(overNum[i].className.indexOf("Rover")!=-1){
			overNum[i].overimg=new Image();
			if(overNum[i].className.indexOf(":")!=-1){
				Replace=overNum[i].className.split(":");
				Replace=Replace[1].split(" ");
				overNum[i].overimg.src=Replace[0];
			}else{
				Replace = overNum[i].src.length;
				overNum[i].overimg.src=overNum[i].src.substring(0,Replace-4)+"_a"+overNum[i].src.substring(Replace-4,Replace);
			}
			overNum[i].setAttribute("out",overNum[i].src);
			overNum[i].onmouseover=new Function('this.src=this.overimg.src;');
			overNum[i].onmouseout=new Function('this.src=this.getAttribute("out");');
		}
	}
}


//-->
