/* ----------------- 変数宣言 -------------------*/
var ButtonType;
var FontSize;
var Unit;
var Obj;
var LinkColor;
var SelectedColor;
var SelectedBold;
Img = new Array();
ImgOn = new Array();
SizeList = new Array();
Units = new Array('%','px','pt','em');
Text = new Array();

/* ----------------- 初期設定 -------------------*/
/* IDの指定 */
//文字サイズを変更したい要素のID
Obj = 'docs';

/* サイズの単位（0 = %、1 = px、2 = pt, 3= em） */
Unit = 0;

/* サイズの選択肢（上から順に小、中、大。指定できるのは数字のみ）*/
SizeList["S"] = 90;
SizeList["M"] = 100;
SizeList["L"] = 110;

/* ボタンのタイプ （0 = テキスト  1 = 画像）*/
ButtonType = 1;

/* 画像ボタン（未選択）のURL（上から順に小、中、大）*/
Img["S"] = 'img/common/header/font_S_off.png';
Img["M"] = 'img/common/header/font_M_off.png';
Img["L"] = 'img/common/header/font_L_off.png';

/* 画像ボタン（選択中）のURL（上から順に小、中、大）*/
ImgOn["S"] = 'img/common/header/font_S_on.png';
ImgOn["M"] = 'img/common/header/font_M_on.png';
ImgOn["L"] = 'img/common/header/font_L_on.png';

/* Cookieの有効期限（日数） */
ExpireDays = 30;


/* -------------------- 実　行 ---------------------*/
ReadCookie();
Buttons();


/* -------------------- 関　数 ---------------------*/
/* ボタン書き出し */
function Buttons() {
	Button("S");
	Button("M");
	Button("L");
}

/* 各ボタンの書き出し */
function Button(Size) {
	// 画像
	if (ButtonType) {
		if (SizeList[Size] == FontSize) {
			document.write('<img src="' + ImgOn[Size] + '"> ');
		} else {
			document.write('<a href="javascript:Write(' + SizeList[Size] + ');"><img src="' + Img[Size] + '" border=0"></a> ');
		}
	}
}

/* Cookie呼出 */
function ReadCookie() {
	if (document.cookie) {
		Cookie = document.cookie;
		if (Cookie.match(/FontSize=([\d.]*)/)) {
			FontSize = RegExp.$1;
		}
	}
}

/* フォントサイズ変更 */
function SizeChange() {
	var oElements;
	var oElement;

	//文字サイズを変更したい要素のID
	Obj = 'docs';

	if (FontSize != null) {
		oElements = document.getElementsByName(Obj);
		for (i = 0; i < oElements.length; i++) {
		    oElement = oElements[i];
			oElement.style.fontSize = FontSize + Units[Unit];
		}
	}
}

/* Cookie書込 */
function Write(Size) {
	// 日付の計算
	var toDay = new Date;
	var xDay = new Date;
	parseInt(ExpireDays);
	xDay.setDate(toDay.getDate()+ExpireDays);
	ExpireText = xDay.toGMTString();
	// 書込
	document.cookie = "FontSize = " + Size + ";expires=" + ExpireText;
	// 再読込
	location.reload();
}

