// SwitchFontsize 文字サイズ変更----------------------------------------

var contentSwitchFontSize = {


conf : {

fontSize     : ["125%","100%","82%"],
switchId     : ["switchFontSizeBig", "switchFontSizeMedium", "switchFontSizeSmall"],

defoSizeId   : "switchFontSizeSmall",
targetAreaId : "contents",
cookieName   : "FontSizeChange",
cookieLimit  : 30,
switchWriteArea : "font-change",
switchHTML      : ''

},



main : function(){

contentSwitchFontSize.setHTML();
contentSwitchFontSize.defo();

var i, j, switchItem = contentSwitchFontSize.conf.switchId;

for(i=0;i<switchItem.length;i++){
document.getElementById(switchItem[i]).onclick = contentSwitchFontSize.action;
}

},



setHTML : function(){

var fontsizeSwitch = document.createElement('div');

fontsizeSwitch.id  = "fontsizeControl";
fontsizeSwitch.innerHTML = contentSwitchFontSize.conf.switchHTML;

document.getElementById(contentSwitchFontSize.conf.switchWriteArea).appendChild(fontsizeSwitch);

},



defo : function(){

var i;

var switchId = contentSwitchFontSize.conf.switchId;

var targetAreaId = contentSwitchFontSize.conf.targetAreaId;

var fontSize = contentSwitchFontSize.conf.fontSize;

cookieValue = this.getCookie() || contentSwitchFontSize.conf.defoSizeId;


for(i = 0; i < switchId.length; i++){

if(cookieValue == switchId[i]){
document.getElementById(targetAreaId).style.fontSize = fontSize[i];
}

}


document.getElementById(cookieValue).className ="active";

},



action : function(){

var i;

var switchId = contentSwitchFontSize.conf.switchId;

var targetAreaId = contentSwitchFontSize.conf.targetAreaId

var fontSize = contentSwitchFontSize.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];
}


}


this.className ="active";

contentSwitchFontSize.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;

}

}



$(function() {

contentSwitchFontSize.main();

});

