

uaName = navigator.userAgent;
appName = navigator.appVersion;

SetMarkup();

var sizeUnit = '%';
var recommendSize = 75;
var variation = 12.5;

var cookieName = 'JAACCTextSize';
var cookieExpire = 30 * 24 * 60 * 60 * 1000;
var cookiePath = '/';


var fSize = GetCookie(cookieName);

if ( fSize == null ) {
	currentSize = recommendSize;
} else {
	currentSize = Number(fSize);
}

reFashion();

function SetMarkup(){
	if (( document.layers )||(( appName.indexOf("Mac",0) != -1 ) && ( uaName.indexOf("MSIE 4.0",0) != -1 ))){
		return false;
	} else if( document.body ){
		document.write("<dl>");
		document.write("<dt><img src=\"/common/img/base_text-size_title.gif\" width=\"56\" height=\"17\" alt=\"文字サイズ\"></dt>");
		document.write("<dd><ul>");
		document.write("<li><a href=\"#\" onclick=\"fCommand('magnify');return false;\" onkeypress=\"fCommand('magnify');return false;\" class=\"rollover\"><img src=\"/common/img/base_text-size_enlarge.gif\" width=\"63\" height=\"17\" alt=\"大きくする\"></a></li>");
		document.write("<li><a href=\"#\" onclick=\"fCommand('recommend');return false;\" onkeypress=\"fCommand('recommend');return false;\" class=\"rollover\"><img src=\"/common/img/base_text-size_reset.gif\" width=\"90\" height=\"17\" alt=\"標準サイズ\"></a></li>");
		document.write("</ul></dd>");
		document.write("</dl>");
	}
}

function reFashion(){
	if (( document.layers )||(( appName.indexOf("Mac",0) != -1 ) && ( uaName.indexOf("MSIE 4.0",0) != -1 ))){
		return false;
	} else if( document.body ){
		document.body.style.fontSize = currentSize + sizeUnit;
	}
}

function fCommand( INDICATION ){
	if( INDICATION == "magnify" ){
		var newSize = Number( currentSize + variation );
		SetCookie( cookieName , newSize );
	}
	if( INDICATION == "recommend" ){
		var newSize = recommendSize;
		DeleteCookie( cookieName );
	}

	if (( document.layers )||(( appName.indexOf("Mac",0) != -1 ) && ( uaName.indexOf("MSIE 4.0",0) != -1 ))){
		return false;
	} else {
		currentSize = newSize;
		reFashion();
	}
}

function SetCookie(name,value){
	var dobj = new Date();
	dobj.setTime( dobj.getTime() + cookieExpire);
	var expiryDate = dobj.toGMTString();
	document.cookie = name + '=' + escape(value)+ ';expires=' + expiryDate + ';path=' + cookiePath;
}

function GetCookie (name){
	var arg  = name + "=";
	var i = 0;
	while (i < document.cookie.length){
		var j = i + arg.length;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function getCookieVal (offset){
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset,endstr));
}

function DeleteCookie(name){
	if (GetCookie(name)) {
		document.cookie = name + '=' + '; expires=Thu, 01-Jan-70 00:00:01 GMT;path=' + cookiePath;
	}
}
