﻿// user_set //
var siteName = "hyogo";
var focusArea = "sizechange_area";
// user_set //

window.onload = function(e) {
  getSize();
}

function setSize(s){
	exp = new Date();
	exp.setTime(exp.getTime() + 31536000000);
	document.cookie = siteName + "=" + s + "; path=/" + "; expires=" + exp.toGMTString();
}

function getSize(){
	zoom = "";
	tmpCookie = document.cookie + ";";
	startPoint1 = tmpCookie.indexOf(siteName);
	startPoint2 = tmpCookie.indexOf("=",startPoint1);
	endPoint = tmpCookie.indexOf(";",startPoint1);
	if(startPoint2 < endPoint && startPoint1 > -1){
		zoom = tmpCookie.substring(startPoint2+1,endPoint);
		document.getElementById(focusArea).style.fontSize = zoom;
	} else {
		document.getElementById(focusArea).style.fontSize = "100%";
	}
}

function textSizeUp(){
	currentSize = document.getElementById(focusArea).style.fontSize;
	selectSize = "";
	if ( currentSize == "80%" ){
		selectSize = "90%";
	}
	else if ( currentSize == "90%" ){
		selectSize = "100%";
	}
	else if ( currentSize == "100%" ){
		selectSize = "110%";
	}
	else if ( currentSize == "110%" ){
		selectSize = "120%";
	}
	else if ( currentSize == "120%" ){
		selectSize = "130%";
	}
	else if ( currentSize == "130%" ){
		selectSize = "140%";
	}
	else if ( currentSize == "140%" ){
		m = escape("Size of a character cannot be enlarged any more.");
		alert(unescape(m));
		selectSize = "140%";
	}
	else {
		selectSize = "140%";
	}
	document.getElementById(focusArea).style.fontSize = selectSize;
	setSize(selectSize);
}
function textSizeDefault(){
	currentSize = document.getElementById(focusArea).style.fontSize;
	selectSize = "100%";
	document.getElementById(focusArea).style.fontSize = selectSize;
	setSize(selectSize);
}
function textSizeDown(){
	currentSize = document.getElementById(focusArea).style.fontSize;
	selectSize = "";
	if ( currentSize == "140%" ){
		selectSize = "130%";
	}
	else if ( currentSize == "130%" ){
		selectSize = "120%";
	}
	else if ( currentSize == "120%" ){
		selectSize = "110%";
	}
	else if ( currentSize == "110%" ){
		selectSize = "100%";
	}
	else if ( currentSize == "100%" ){
		selectSize = "90%";
	}
	else if ( currentSize == "90%" ){
		selectSize = "80%";
	}
	else if ( currentSize == "80%" ){
		m = escape("Size of a character cannot be made small any more.");
		alert(unescape(m));
		selectSize = "80%";
	}
	else {
		selectSize = "80%";
	}
	document.getElementById(focusArea).style.fontSize = selectSize;
	setSize(selectSize);
}
