var yomotsuSwitchFontSize = {
	
	conf : {
		fontSize    : ["140%","120%","100%"],
		switchId    : ["switchFontSizeBig", "switchFontSizeMedium", "switchFontSizeSmall"],
		defoSizeId  : "switchFontSizeSmall",
		targetAreaId: "container",              //フォントサイズを適用すE┘E△ID
		footer: "footer",              //フォントサイズを適用すE┘E△ID
		cookieName  : "yomotsuFontSize",      //クッキーの名前
		cookieLimit : 30,                     //有効E(E砲)
		switchWriteArea : "utility",          //指定したIDのエE△琉E嶌埜紊縫好ぅ奪舛HTMLが書き込まEE
		switchHTML      : '<ul id="gnavi"><li><a href="/access/"><img alt="アクセスマップ" src="/include/images/gnavi_06.jpg" width="108" height="19" /></a></li><li><a href="mailto:dougashima@cap.ocn.ne.jp"><img alt="" src="/include/images/gnavi_05.jpg" width="112" height="19" /></a></li><li><img alt="文字サイズ" src="/include/images/gnavi_04.jpg" width="93" height="19" /></li><li id="switchFontSizeSmall"><img alt="小サイズ" src="/include/images/gnavi_03.jpg" width="24" height="19" /></li><li id="switchFontSizeMedium"><img alt="中サイズ" src="/include/images/gnavi_02.jpg" width="24" height="19" /></li><li id="switchFontSizeBig"><img alt="大サイズ" src="/include/images/gnavi_01.jpg" width="22" height="19" /></li></ul>'

// switchHTMLの参考用デフォE斑
//
//  <ul>
//  <li id="switchFontSizeBig">E/li>
//  <li id="switchFontSizeMedium">E/li>
//  <li id="switchFontSizeSmall">小</li>
//  </ul>

	},
	
	main : function(){
		yomotsuSwitchFontSize.setHTML();
		yomotsuSwitchFontSize.defo();
		var i, j, switchItem = yomotsuSwitchFontSize.conf.switchId;
		
		for(i=0;i<switchItem.length;i++){
			document.getElementById(switchItem[i]).onclick = yomotsuSwitchFontSize.action;
		}
	},
	
	setHTML : function(){
		var fontsizeSwitch = document.createElement('div'); 
		fontsizeSwitch.id  = "fontsizeControl";
		fontsizeSwitch.innerHTML = yomotsuSwitchFontSize.conf.switchHTML; 
		
		document.getElementById(yomotsuSwitchFontSize.conf.switchWriteArea).appendChild(fontsizeSwitch);
	},
	
	defo : function(){
		var i;
		var switchId = yomotsuSwitchFontSize.conf.switchId;
		var targetAreaId = yomotsuSwitchFontSize.conf.targetAreaId;
		var footer = yomotsuSwitchFontSize.conf.footer;
		var fontSize = yomotsuSwitchFontSize.conf.fontSize;
		
		cookieValue = this.getCookie() || yomotsuSwitchFontSize.conf.defoSizeId;
		for(i = 0; i < switchId.length; i++){
			if(cookieValue == switchId[i]){
				document.getElementById(targetAreaId).style.fontSize = fontSize[i];
				document.getElementById(targetAreaId).style.lineHeight = "160%";
				document.getElementById(footer).style.fontSize = fontSize[i];
				document.getElementById(footer).style.lineHeight = "160%";
			}
		}
		document.getElementById(cookieValue).className ="active";
	},
	
	action : function(){
		var i;
		var switchId = yomotsuSwitchFontSize.conf.switchId;
		var targetAreaId = yomotsuSwitchFontSize.conf.targetAreaId
		var footer = yomotsuSwitchFontSize.conf.footer;
		var fontSize = yomotsuSwitchFontSize.conf.fontSize
		
		for(i=0;i<switchId.length;i++){
			var switchItem = document.getElementById(switchId[i]);
			switchItem.className="";
			if(this.id == switchId[i]){
				document.getElementById(targetAreaId).style.fontSize = fontSize[i];
				document.getElementById(targetAreaId).style.lineHeight = "160%";
				document.getElementById(footer).style.fontSize = fontSize[i];
				document.getElementById(footer).style.lineHeight = "160%";
			}
		}
		this.className ="active";
		
		yomotsuSwitchFontSize.setCookie(this.id);
	},
	
	setCookie: function(data) {
		var today = new Date();
		today.setTime(today.getTime() + (1000 * 60 * 60 * 24 * Number(this.conf.cookieLimit)));
		document.cookie = this.conf.cookieName + '=' + encodeURIComponent(data) + '; path=/; expires=' + today.toGMTString();
	},
	
	getCookie: function(m) {
		return (m = ('; ' + document.cookie + ';').match('; ' + this.conf.cookieName + '=(.*?);')) ? decodeURIComponent(m[1]) : null;
	},
	
	addEvent : function(){
		if(window.addEventListener) {
			window.addEventListener("load", this.main, false);
		}
		else if(window.attachEvent) {
			window.attachEvent("onload", this.main);
		}
	}
	
}

yomotsuSwitchFontSize.addEvent();

