var yomotsuSwitchFontSize = {
	
	conf : {
		fontSize    : ["12pt","10pt","8pt"],
		lineHight    : ["14pt","12pt","10pt"],
		switchId    : ["switchFontSizeBig", "switchFontSizeMedium", "switchFontSizeSmall"],
		defoSizeId  : "switchFontSizeMedium",
		targetAreaId: "article",              //フォントサイズを適用するエリアのID
		cookieName  : "yomotsuFontSize",      //クッキーの名前
		cookieLimit : 30,                     //有効期限(日にち)
		switchWriteArea : "utility",          //指定したIDのエリアの一番最後にスイッチのHTMLが書き込まれる
//		switchHTML      : '<ul><li id="switchFontSizeBig">大</li><li id="switchFontSizeMedium">中</li><li id="switchFontSizeSmall">小</li></ul>'
		switchHTML      : '<img src="images/index_04.gif" width="20" height="26" id="switchFontSizeBig" alt="tHgTCYF"><IMG src="images/index_05.gif" width="20" height="26" id="switchFontSizeMedium" alt="tHgTCYF"><IMG src="images/index_06.gif" width="22" height="26" id="switchFontSizeSmall" alt="tHgTCYF">'


// switchHTMLの参考用デフォルト値
//
//  <ul>
//  <li id="switchFontSizeBig">大</li>
//  <li id="switchFontSizeMedium">中</li>
//  <li id="switchFontSizeSmall">小</li>
//  </ul>

	},
	
	setHTML : function(){
		var fontsizeSwitch = document.createElement('div'); 
		fontsizeSwitch.id  = "fontsizeSwitch";
		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 fontSize = yomotsuSwitchFontSize.conf.fontSize;
		var lineHight = yomotsuSwitchFontSize.conf.lineHight;
		
		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 = lineHight[i];
			}
		}
		
		document.getElementById(cookieValue).className ="active";
		
	},
	
	main : function(){		yomotsuSwitchFontSize.defo()
		var i, j, switchItem = yomotsuSwitchFontSize.conf.switchId;
		
		for(i=0;i<switchItem.length;i++){
			document.getElementById(switchItem[i]).onclick = yomotsuSwitchFontSize.action;
		}
	},
	
	action : function(){
		var i;
		var switchId = yomotsuSwitchFontSize.conf.switchId;
		var targetAreaId = yomotsuSwitchFontSize.conf.targetAreaId
		var fontSize = yomotsuSwitchFontSize.conf.fontSize
		var lineHight = yomotsuSwitchFontSize.conf.lineHight
		
		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 = lineHight[i];
			}
		}
		this.className ="active";
		
		yomotsuSwitchFontSize.setCookie(this.id);
	},
	
	changeSize : function(){
		
	},
	
	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.setHTML, false);
			window.addEventListener("load", this.main, false);
		}
		else if(window.attachEvent) {
			window.attachEvent("onload", this.main);
			window.attachEvent("onload", this.setHTML);
		}
	}
	
}

yomotsuSwitchFontSize.addEvent();





