﻿// 使い方説明　//
// <htm>　// 
// <body onLoad="getCookie();">　// 
// <div id="LAYOUTBOX"> この中が有効 </div>　// 
// </body</htm>　// 
// 
// <a href="javascript:textSizeUp();">hogehoge</a>　// 
// <a href="javascript:textSizeDown();">hogehoge</a>　// 




//設定↓ここから//
var siteName = "imgh";
var focusArea = "LAYOUTBOX";
//設定↑ここまで//

window.onload = function(e) {
  getCookie();
}

function setCookie(s){
	exp = new Date();
	exp.setTime(exp.getTime() + 31536000000);
	document.cookie = siteName + s + "; path=/" + "; expires=" + exp.toGMTString();
}

function getCookie(){
	zoom = "";
	tmpCookie = document.cookie + ";";
	start = tmpCookie.indexOf(siteName);
	if (start != -1)
	{
		end = tmpCookie.indexOf(";", start);
		zoom = tmpCookie.substring(start + siteName.length, end);
		document.getElementById(focusArea).style.fontSize = zoom;
	} else {
		document.getElementById(focusArea).style.fontSize = "100%";
	}
}

function textSizeUp(){
	currentSize = document.getElementById(focusArea).style.fontSize;
	selectSize = "";
	if ( currentSize == "8px" ){
		selectSize = "10px";
	}
	else if ( currentSize == "10px" ){
		selectSize = "12px";
	}
	else if ( currentSize == "12px" ){
		selectSize = "14px";
	}
	else if ( currentSize == "14px" ){
		selectSize = "16px";
	}
	else if ( currentSize == "16px" ){
		selectSize = "18px";
	}
	else if ( currentSize == "18px" ){
		m = escape("これ以上文字のサイズを大きくできません。");
		alert(unescape(m));
		selectSize = "18px";
	}
	else {
		selectSize = "16px";
	}
	document.getElementById(focusArea).style.fontSize = selectSize;
	setCookie(selectSize);
}

function textSizeDown(){
	currentSize = document.getElementById(focusArea).style.fontSize;
	selectSize = "";
	if ( currentSize == "18px" ){
		selectSize = "16px";
	}
	else if ( currentSize == "16px" ){
		selectSize = "14px";
	}
	else if ( currentSize == "14px" ){
		selectSize = "12px";
	}
	else if ( currentSize == "12px" ){
		selectSize = "10px";
	}
	else if ( currentSize == "10px" ){
		selectSize = "8px";
	}
	else if ( currentSize == "8px" ){
		m = escape("これ以上文字のサイズを小さくできません。");
		alert(unescape(m));
		selectSize = "8px";
	}
	else {
		selectSize = "12px";
	}
	document.getElementById(focusArea).style.fontSize = selectSize;
	setCookie(selectSize);
}