﻿//フォントサイズ可変スクリプト　Ver.1.10 ---------------------

//設定ここから --------------------------------

//サイズリスト
SizeList = new Array (110,125,140);

//デフォルトサイズのインデックス数
DefaultKey = 1;

//Bodyタグに挿入するID名
BodyID = "default";

//フォントサイズ変更ボタンを押したときのパラメータ
ChangeFontSizeList = new Array ('small','default','large');
//フォントサイズ変更ボタンのID
ChangeFontSizeImageIdList = new Array ('cgfont_small','cgfont_default','cgfont_large');
//フォントサイズ変更ボタン未選択時のイメージ
ChangeFontSizeImageDisableList = new Array ('/hikari/Portals/0/image/syo_off.png','/hikari/Portals/0/image/hyojyun_off.png','/hikari/Portals/0/image/dai_off.png');
//フォントサイズ変更ボタン選択時のイメージ
ChangeFontSizeImageEnableList = new Array ('/hikari/Portals/0/image/syo_on.png','/hikari/Portals/0/image/hyojyun_on.png','/hikari/Portals/0/image/dai_on.png');

//設定ここまで、以下編集禁止 --------------------------------
if(GetCookie("StudioRikiyFSS") == "none"){
	key = DefaultKey;
}else if (!isNaN(GetCookie("StudioRikiyFSS"))){
	key = Number(GetCookie("StudioRikiyFSS"));
}else{
	key = DefaultKey;
}
window.onload = function (){
	cgfontimage(ChangeFontSizeList[key]);
}

document.writeln('<style type="text/css"><!--');
document.writeln('#'+BodyID+'{font-size: '+SizeList[key]+'%;}');
document.writeln('//--></style>');

function cgfont(value){

/*
	if(value=="large" && key < SizeList.length-1){
		key += 1;
	}else if(value=="small" && key > 0){
		key -= 1;
	}else if(value=="default"){
		key = DefaultKey;
	}
*/
	key = DefaultKey;
	for(i=0; i < ChangeFontSizeList.length; i++)
	{
		if (ChangeFontSizeList[i] == value) key = i;
	}
	
	size = SizeList[key] + "%";
	if(document.all){
		document.all(BodyID).style.fontSize = size;
	}
	if(document.getElementById){
		document.getElementById(BodyID).style.fontSize = size;
	}
	cgfontimage(value);
	WriteCookie("StudioRikiyFSS",key)
}

function cgfontimage(value)
{
	for (var i = 0; i < ChangeFontSizeList.length; i++)
	{
		var cgfontimage = document.getElementById(ChangeFontSizeImageIdList[i]);
		cgfontimage.src = (value == ChangeFontSizeList[i]) ? ChangeFontSizeImageEnableList[i] : ChangeFontSizeImageDisableList[i];
	}
}


function WriteCookie(name,value){
	tmp = name+"="+value+";";
	tmp += "expires=Fri, 31-Dec-2030 23:59:59;";
	tmp += "path=/;";
	document.cookie = tmp;
}

function GetCookie(value){

	data = document.cookie+";";
	tmp = data.indexOf(value,0);
	if(tmp != -1){
		size = data.substring(tmp,data.length);
		start = size.indexOf("=",0);
		end = size.indexOf(";",start);
		return(unescape(size.substring(start + 1,end)));
	}else{
		return "none";
	}
}
