/*--------------------------------------------------------------------------*/

Element.addMethods();var v_IE = (document.documentElement.getAttribute("style") == document.documentElement.style);
var v_cNamefontSize = "fontSize";
var v_size = f_getCookie(v_cNamefontSize);
var v_img = new Array();

// listener(IE) ----------------------------------------
function f_addListener(e, f) {
	if(this.attachEvent) this.attachEvent("on" + e, f);
}

if(!window.addEventListener) window.addEventListener = f_addListener;

// class ----------------------------------------
if(v_IE) v_class = "className";
if(!v_IE) v_class = "class";

// change font size ----------------------------------------
var v_font = {
	a_offList : new Array(),
	a_onList : new Array(),
	v_title : "",


	f_fontSizeArea : function() {
		var v_html;
				v_font.v_title = "文字サイズの変更";
				// a_offList text
				v_btnMinus = "フォントサイズを小さく";
				v_btnS = "フォントサイズを「小」に変更";
				v_btnM = "フォントサイズを「中」に変更";
				v_btnL = "フォントサイズを「大」に変更";
				v_btnPlus = "フォントサイズを大きく";
				// a_onList text
				v_txtMinus = "最小サイズに設定されています";
				v_txtS = "フォントサイズは「小」に設定されています";
				v_txtM = "フォントサイズは「中」に設定されています";
				v_txtL = "フォントサイズは「大」に設定されています";
				v_txtPlus = "最大サイズに設定されています";

		// a_offList
		v_font.a_offList[0] = '<li id="minusOff"><a href="#" onclick="v_font.f_changeSize(\'-\'); return false;" title="' + v_txtMinus + '">' + v_txtMinus + '</a></li>';
		v_font.a_offList[1] = '<li id="sSizeOff"><a href="#" onclick="v_font.f_changeSize(\'1\'); return false;" title="' + v_btnS + '">' + v_btnS + '</a></li>';
		v_font.a_offList[2] = '<li id="mSizeOff"><a href="#" onclick="v_font.f_changeSize(\'2\'); return false;" title="' + v_btnM + '">' + v_btnM + '</a></li>';
		v_font.a_offList[3] = '<li id="lSizeOff"><a href="#" onclick="v_font.f_changeSize(\'3\'); return false;" title="' + v_btnL + '">' + v_btnL + '</a></li>';
		v_font.a_offList[4] = '<li id="plusOff"><a href="#" onclick="v_font.f_changeSize(\'+\'); return false;" title="' + v_btnPlus + '">' + v_btnPlus + '</a></li>';

		// a_onList
		v_font.a_onList[0] = '<li id="minusOn"><strong>' + v_txtMinus + '</strong></li>';
		v_font.a_onList[1] = '<li id="sSizeOn"><strong>' + v_txtS + '</strong></li>';
		v_font.a_onList[2] = '<li id="mSizeOn"><strong>' + v_txtM + '</strong></li>';
		v_font.a_onList[3] = '<li id="lSizeOn"><strong>' + v_txtL + '</strong></li>';
		v_font.a_onList[4] = '<li id="plusOn"><strong>' + v_txtPlus + '</strong></li>';

		switch(v_size) {
			case "1" :
				v_html =
							'<p>' + v_font.v_title + '</p>' +
							'<ul>' +
							v_font.a_onList[0] +
							v_font.a_onList[1] +
							v_font.a_offList[2] +
							v_font.a_offList[3] +
							v_font.a_offList[4] +
							'</ul>';
				break;
			case "2" :
				v_html =
							'<p>' + v_font.v_title + '</p>' +
							'<ul>' +
							v_font.a_offList[0] +
							v_font.a_offList[1] +
							v_font.a_onList[2] +
							v_font.a_offList[3] +
							v_font.a_offList[4] +
							'</ul>';
				break;
			case "3" :
				v_html =
							'<p>' + v_font.v_title + '</p>' +
							'<ul>' +
							v_font.a_offList[0] +
							v_font.a_offList[1] +
							v_font.a_offList[2] +
							v_font.a_onList[3] +
							v_font.a_onList[4] +
							'</ul>';
				break;
			default :
				break;
		}
		$("fontSizeChange").innerHTML = v_html;
	},

	f_changeSize : function(param) {
		v_size = v_size - 0; // change type [ string to number ] !Don't change this line.
		
		if(param == "-") param = v_size - 1;
		if(param == "+") param = v_size + 1;
		
		param = param + ""; // change type [ number to string ] !Don't change this line.

		v_size = param;
		f_setCookie(v_cNamefontSize, param);
		$("fontSize").setAttribute("href", "/css" + "/fontSize_0" + param + ".css");
		v_font.f_fontSizeArea();
	}
};

// cookie ----------------------------------------
function f_getCookie(key) {
	ck = document.cookie + ";";
	ck1 = ck.indexOf(key + "=", 0);
	
	if(ck1 != -1) {
		ck = ck.substring(ck1, ck.length);
		start = ck.indexOf("=", 0) + 1;
		end = ck.indexOf(";", start);
		return(unescape(ck.substring(start, end)));
	} else {
		return("");
	}
}

function f_setCookie(key, val, param) {
	cookieName = key + "=" + escape(val) + ";";
	cookieName += "name=gtm;";
	effectPath = "path=/;";

	switch(param) {
		case "temporary":
			if(!v_IE) expiresTime = "expires=0";
			if(v_IE) expiresTime = "expires=";
			break;
		default:
			nowTime = new Date();
			nowTime.setTime(nowTime.getTime() + (3000 * 1000 * 60 * 60 * 24));
			expiresTime = "expires=" + nowTime.toGMTString();
			break;
	}
	document.cookie = cookieName + effectPath + expiresTime;
}

function f_entity(val) {
	var a_tEntity = new Array('&', '<', '>', '"', '\'');
	var a_nEntity = new Array('&amp;', '&lt;', '&gt;', '&quot;', '&#39;');
	for(var i = 0; i < a_tEntity.length; i ++) {
		val = val.replace(new RegExp('(' + a_tEntity[i] + ')', 'g'), a_nEntity[i]);
	}
	return val;
}

// document write font size css ----------------------------------------
switch(v_size) {
	case "" :
		v_size = "1";
		break;
	case "4" : // old site cookie
		v_size = "3";
		break;
	default :
		break;
}

document.write('<link rel="stylesheet" type="text/css" href="/css' + '/fontSize_0' + f_entity(v_size) + '.css" media="all" id="fontSize" charset="utf-8" />');

