var Default_settei = 2;
var Default = 0;
var tags    = new Array('div','td','tr','a','input','textarea','span','pre','p','strong','b','li');
var sizing  = new Array('xx-small','x-small','small','medium','large','x-large');

function FontChange(tarF) 
{
	v = parseInt(tarF);
	v = v + parseInt(Default);
  	if (v < 0) v = 0;
  	if (v > 6) v = 6;
	Default = v;
	FontChangeKotei('body');
}

function FontChangeDefault() 
{
	Default = Default_settei;
	FontChangeKotei('body');
}

function FontChangeKotei(target) 
{
  	if (!document.getElementById) return

  	var dore = document,tarS = null,fontSize = Default,value,su,cTags;
  	if (fontSize < 0) fontSize = 0;
  	if (fontSize > 6) fontSize = 6;
  	Default = fontSize;

  	if (!(tarS = dore.getElementById(target))) 
  	{
		tarS = dore.getElementsByTagName(target)[0];
  		tarS.style.fontSize = sizing[fontSize];
	}
  	for (value = 0 ; value < tags.length ; value++) 
	{
    		cTags = tarS.getElementsByTagName(tags[value]);
    		for (su = 0 ; su < cTags.length ; su++) 
		{
			cTags[su].style.fontSize = sizing[fontSize];
		}
  	}
	// クッキーに保存
  	document.cookie="fontSize=" + fontSize + ";path=/;";
}

function FontChangeStart()
{
	var name="fontSize";
	var cookie=document.cookie; //クッキーを取得
	if(-1==cookie.indexOf(name))
	{ 	
		//クッキーがなければsmallを指定（デフォルト）
		Default = Default_settei;
	}
	else
	{
		var pos_s=cookie.indexOf(name)+name.length+1; //クッキーの値の開始位置
		var pos_e=cookie.indexOf(";",pos_s); //クッキーの値の終了位置
		if(-1==pos_e)
		{ 
			//末尾にセミコロンがあるか？
			var size=cookie.slice(pos_s); //無い
		}
		else
		{
			var size=cookie.slice(pos_s,pos_e); //有る
		}
		Default = size;
		FontChangeKotei('body');
	}
}

