/*** textsize.js ***/

/* ----------------- 変数宣言 -------------------*/
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 */
Obj = 'docs';

/* size 0:% 1:px */
Unit = 0;

/* size % */
SizeList["S"] = 85;
SizeList["M"] = 100;
SizeList["L"] = 120;

/* button text:0 image:1 */
ButtonType = 1;

/* image (not select) */
Img["S"] = '../share/images/t_sizeAS.gif';
Img["M"] = '../share/images/t_sizeAM.gif';
Img["L"] = '../share/images/t_sizeAL.gif';

/* image (select) */
ImgOn["S"] = '../share/images/t_sizeAS_on.gif';
ImgOn["M"] = '../share/images/t_sizeAM_on.gif';
ImgOn["L"] = '../share/images/t_sizeAL_on.gif';

/* 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> ');
		}
} else {
if (SizeList[Size] == FontSize) {
var Style;
if (SelectedBold) {
Style = 'color:' + SelectedColor + ';font-weight:bold';
} else {
Style = 'color:' + SelectedColor;
	}

document.write ('<span style="' + Style + '">' + Text[Size] + '</span> ');
} else {
document.write ('<a href="javascript:Write(' + SizeList[Size] + ');" style="color:' + TextColor + '">' + Text[Size] + '</a> ');
		}
	}
}

function ReadCookie() {
if (document.cookie) {
Cookie = document.cookie;
if (Cookie.match(/FontSize=(\d*)/)) {
FontSize = RegExp.$1;
		}
	}
}

function SizeChange() {
if (FontSize != null) {
document.getElementById(Obj).style.fontSize = FontSize + Units[Unit];
	}
}

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();
}






