﻿

var sizeCount = 0;
var sizeArray = new Array("86%","100%","115%","129%","143%");
cName = "DIGISUP=";
zoom = "";

var expire = new Date();
expire.setTime(expire.getTime()+(1*1000*60*60*24));
expire = expire.toGMTString();

function getCookie(){
	tmpCookie = document.cookie + ";";
	start = tmpCookie.indexOf(cName);
	if (start != -1)
	{	end = tmpCookie.indexOf(";", start);
		zoom = tmpCookie.substring(start + cName.length, end);
		zoom = eval(zoom)
		sizeCount = zoom
		document.body.style.fontSize = sizeArray[sizeCount];
		sizeCount = zoom;
	} else {
		document.body.style.fontSize = "86%";
	}
}
function setCookie(){
		var sizeData = ""  + sizeCount;
		document.cookie = cName + sizeData + ";expire" + "=" + expire;
	}
function textSizeUp(){
	if (sizeCount < sizeArray.length-1){
		sizeCount += 1;	
		document.body.style.fontSize = sizeArray[sizeCount];
		setCookie();
	}
	else if(sizeCount == sizeArray.length-1){
		m = escape("これ以上文字サイズを大きくはできません。");
		alert(unescape(m));
		setCookie();
	}
	 
}

function textSizeDown(){
	if (sizeCount > 0 ){
		sizeCount -= 1	
		document.body.style.fontSize = sizeArray[sizeCount];
		setCookie();
		
	}
	else {
		m = escape("これ以上文字サイズを小さくできません。");
		alert(unescape(m));
	}
	
}

try{
	window.addEventListener("load",getCookie,false);
}catch(e){
	window.attachEvent("onload",getCookie);
}
