cookiename = "strval";
path="/";

function fontsizeChange(val)
{
	if (document.getElementById && document.createElement) {
		document.getElementById('all').className = val;
		weektime = 60 * 1000 * 60 * 24 * 7;
		expiresdate = addTime(new Date(), weektime);
		document.cookie = cookiename + "=" + val + ";expires=" + expiresdate + ";path=" + path;
		switch (val) {
			case 'font-superlarge':
				document.getElementById('fs1').style.backgroundPosition = 'bottom';
				document.getElementById('fs2').style.backgroundPosition = 'top';
				document.getElementById('fs3').style.backgroundPosition = 'top';
				break;
			case 'font-large':
				document.getElementById('fs1').style.backgroundPosition = 'top';
				document.getElementById('fs2').style.backgroundPosition = 'bottom';
				document.getElementById('fs3').style.backgroundPosition = 'top';
				break;
			case 'font-normal':
				document.getElementById('fs1').style.backgroundPosition = 'top';
				document.getElementById('fs2').style.backgroundPosition = 'top';
				document.getElementById('fs3').style.backgroundPosition = 'bottom';
				break;
		}
    } else {
        alert('あなたのブラウザは文字サイズ変更未対応です。');
    }
}

function addTime(date, time) {
    date.setTime(date.getTime() + time);
    return date.toGMTString();
}

function getCookieValue(key) {
	var cookies = document.cookie.split("; ");
	for (var i = 0; i < cookies.length; i++) {
		var str = cookies[i].split("=");
		if (str[0] == key) {
			var cookie_value = unescape(str[1]);
			break;
		}
	}
    return cookie_value;
}

function getCookie(){
	document.getElementById('fs3').style.backgroundPosition = 'bottom';
	if (document.cookie) {
        strval = getCookieValue(cookiename);
        if (strval != null) {
            fontsizeChange(strval);
        }
    }
}
