// Copyright 2007 STARRYWORKS inc. All rights reserved.
//
// Technical Information :
//     STARRYWORKS INC.
//     Mail:info@starryworks.jp
//     Tel:06-6535-1747
//     Director:Koji Kimura
//

c = getCookie("FONT_SIZE");
if ( c != null ) {
	var fontSizeIndex = parseInt(c);
} else {
	var fontSizeIndex = 1;
}
if ( typeof(window.onload) != "function" ) {
	window.onload = function() {
		setFontSize(0);
	};
} else {
	var fontSizeOnload = window.onload;
	window.onload = function() {
		setFontSize(0);
		fontSizeOnload();
	};
}

var fontSizeArray = new Array("70%","85%","95%","105%","115%","130%","150%");
function setFontSize(val){
	try {
		fontSizeIndex += val;
		if ( fontSizeIndex < 0 ) {
			fontSizeIndex = 0;
		} else if ( fontSizeIndex >= fontSizeArray.length ) {
			fontSizeIndex = fontSizeArray.length-1;
		}
		if ( fontSizeIndex == 0 ) {
			document.getElementById('FontSmall').className = "fontsize-disabled-minus";
			document.getElementById('FontLarge').className = "fontsize-enabled-plus";
		} else if ( fontSizeIndex == (fontSizeArray.length-1) ) {
			document.getElementById('FontSmall').className = "fontsize-enabled-minus";
			document.getElementById('FontLarge').className = "fontsize-disabled-plus";
		} else {
			document.getElementById('FontSmall').className = "fontsize-enabled-minus";
			document.getElementById('FontLarge').className = "fontsize-enabled-plus";
		}
		document.body.style.fontSize = fontSizeArray[fontSizeIndex];
		//Element.setStyle("AwajiBody",{"font-size":fontSizeArray[fontSizeIndex]});
		//Set Cookie
		cD = new Date();
		cDate = cD.getDate();
		cD.setDate(cDate+90);
		setCookie("FONT_SIZE",""+fontSizeIndex,cD,"/");
	} catch(e) {
	}
}


// Function to Set Cookie
function setCookie(name,value,expire,path){
	document.cookie = name + '=' + escape(value) + ((expire==null)?'':('; expires='+expire.toGMTString())) + ((path==null)?'':('; path='+path));
}
// Function to Get Cookie
function getCookie(name){
	var search = name + '=';
	if (document.cookie.length>0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1){
			offset += search.length;
			end = document.cookie.indexOf(';',offset);
			if(end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset,end));
		}
	}
	return null;
}

