//文字(サイズ) 用Script
//ひだか青年自然の家 2009.01

/*==============================
クッキーの有効期限（7日）
==============================*/
function save(n, v) {
	var key = new Date();
	key.setTime(key.getTime() + 24 * 60 * 60 * 7 * 1000);
	var exp = key.toGMTString();
	document.cookie = n + '=' + v + ';expires=' + exp + ';path=/';
	return null;
}

/*===============クッキーの読み出し===============*/
function read(n) {
	n = n + '=';
	var s = null;
	var x = document.cookie.length;
	var l = n.length;
	for (i = 0; i < x; i++) {
		if (document.cookie.substring(i, i + l) == n) {
			if (document.cookie.indexOf (";", i + l) == -1) {
				s = document.cookie.substring(i + l, document.cookie.length);
			} else {
				s = document.cookie.substring(i + l, document.cookie.indexOf (";", i + l));
			}
		}
	}
	return s;
}


/*===============フォントサイズ変更の設定===============*/
function view(r) {
	var f_size = document.body.style.fontSize;//現在値
	var num = 10;//増減幅
	var s = (f_size.substr(0,f_size.length-1)-0) ;//数値化(％除去)
	if(r == '-'){
		s = s - num;
		if (s < 70) { s = 70; }           //フォントの限界縮小値70%指定
	}else{
		s = s + num;
		if (s > 300) { s = 300; }           //フォントの限界縮大値300%指定
	}
	document.body.style.fontSize = s + '%';
	save('fontsize', s);
	//alert(document.body.style.fontSize);
	return null;
}


/*========初回ページ読み込み時の設定(初期化)========*/

function init(f) {
	var set1;
	
	set1 = read('fontsize') ;
	
	if (f == true || set1 == null) {
		set1 = 100; //初期値 100%
		save('fontsize', set1);               
	}
	document.body.style.fontSize = set1 + '%';//フォントサイズを%で指定

	return null;
}

/*===============リセットの設定===============*/
function re_set() {

	init(true); //初期化

	return null;
}

/*===============ページロード時===============*/
window.onload = function(e) {
	
	init(false); //設定値読み込み/初期化
	
}

function plus(){
	view('+');
}
function minus(){
	view('-');
}	
function white(){
	colors(1);
}
function black(){
	colors(2);
}
//ツールボタン書き出し
function f_tools(){
	var tool_code = "<p id='t_fsize'>文字サイズの変更｜"+
	"<a href='#' onclick='plus()' id='rink1'>大</a>・<a href='#' onclick='minus()'>小</a>｜"+
	"<a href='#' onclick='re_set()'>リセット</a>｜</p>";

	document.write(tool_code);
}