
function fontStyleInit() {
	var mode = 2;

	if(checkCookie()) {
		mode = getCookie("fontStyle");
	}

	fontStyleSet(mode);
}

function fontStyleSet(mode) {

if( navigator.appVersion.indexOf("Mac") > 1 && navigator.userAgent.indexOf("7.0") > 1){
	} else if (navigator.appVersion.indexOf("Mac") > 1 && navigator.appName.charAt(0)=="M" && navigator.userAgent.indexOf("5.0") > 1){
	} else if (navigator.appVersion.indexOf("Mac") > 1 && navigator.appName.charAt(0)=="M" && navigator.userAgent.indexOf("5.1") > 1){
	var nav = document.getElementById('fontStyle');
	var writeHtml = '';

	if(mode == 1) {
		writeHtml = '<link rel="stylesheet" href="/common/css/small.css" id="fontStyle" type="text/css" media="screen">';
	} else if(mode == 3) {
		writeHtml = '<link rel="stylesheet" href="/common/css/large.css" id="fontStyle" type="text/css" media="screen">';
	} else {
		writeHtml = '<link rel="stylesheet" href="/common/css/medium.css" id="fontStyle" type="text/css" media="screen">';
	}

	nav.innerHTML = writeHtml;
	location.reload();


	} else if( navigator.appVersion.indexOf("Mac") > 1 && navigator.appName.charAt(0)=="M" && navigator.userAgent.indexOf("5.2") > 1){


	var nav = document.getElementById('fontStyle');
	var writeHtml = '';

	if(mode == 1) {
		writeHtml = '<link rel="stylesheet" href="/common/css/small.css" id="fontStyle" type="text/css" media="screen">';
	} else if(mode == 3) {
		writeHtml = '<link rel="stylesheet" href="/common/css/large.css" id="fontStyle" type="text/css" media="screen">';
	} else {
		writeHtml = '<link rel="stylesheet" href="/common/css/medium.css" id="fontStyle" type="text/css" media="screen">';
	}

	nav.innerHTML = writeHtml;
	location.reload();
	} else {


	var style = document.getElementById('fontStyle');

	if(mode == 1) {
		style.href="/common/css/small.css";
	} else if(mode == 3) {
		style.href="/common/css/large.css";
	} else {
		style.href="/common/css/medium.css";
	}

	}

	if(checkCookie()) {
		setCookie("fontStyle", mode, "", "", 7, 0);

	}

}


function checkCookie() {
	if (window.navigator.cookieEnabled) {
		return true;
	}
	else {
		return false;
	}
}


function getCookie(name) {
	if (!name || !document.cookie) {
		return;
	}

	var cookies = document.cookie.split("; ");
	for(var i=0; i<cookies.length; i++) {
		var str = cookies[i].split("=");
		if(str[0] != name) {
			continue;
		}
		return unescape(str[1]);
	}
	return;
}


function setCookie(name, value, domain, path, expires, secure) {
	if (!name) {
		return;
	}

	var str = name + "=" + escape(value);
	if(domain) {
		if(domain == 1) {
			domain = location.hostname.replace(/^[^\.]*/, "");
			str += "; domain=" + domain;
		}
	}

	path = "/";
	str += "; path=" + path;

	if(expires) {
		var nowtime = new Date().getTime();
		expires = new Date(nowtime + (60 * 60 * 24 * 1000 * expires));
		expires = expires.toGMTString();
		str += "; expires=" + expires;
	}
	if(secure && location.protocol == "https:") {
		str += "; secure";
	}

	document.cookie = str;
}


function fontPicSet(mode) {

if( navigator.appVersion.indexOf("Mac") > 1 && navigator.userAgent.indexOf("7.0") > 1){

	} else if (navigator.appVersion.indexOf("Mac") > 1 && navigator.appName.charAt(0)=="M" && navigator.userAgent.indexOf("5.0") > 1){

	} else {


	var nav = document.getElementById('controlInner');
	var writeHtml = '';

	if(mode == 1) {
		writeHtml = '<img src="/common/images/fc_txt.gif" alt="文字サイズ" width="77" height="25">';
		writeHtml += '<a href="javascript:void(0)"><img src="/common/images/font_s_on.gif" width="27" height="25" alt="小" onclick="fontStyleSet(1);fontPicSet(1)"></a>';
		writeHtml += '<a href="javascript:void(0)"><img src="/common/images/font_m.gif" width="27" height="25" alt="中" onclick="fontStyleSet(2);fontPicSet(2)"></a>';
		writeHtml += '<a href="javascript:void(0)"><img src="/common/images/font_l.gif" width="27" height="25" alt="大" onclick="fontStyleSet(3);fontPicSet(3)"></a>';

	} else if(mode == 3) {
		writeHtml = '<img src="/common/images/fc_txt.gif" alt="文字サイズ" width="77" height="25">';
		writeHtml += '<a href="javascript:void(0)"><img src="/common/images/font_s.gif" width="27" height="25" alt="小" onclick="fontStyleSet(1);fontPicSet(1)"></a>';
		writeHtml += '<a href="javascript:void(0)"><img src="/common/images/font_m.gif" width="27" height="25" alt="中" onclick="fontStyleSet(2);fontPicSet(2)"></a>';
		writeHtml += '<a href="javascript:void(0)"><img src="/common/images/font_l_on.gif" width="27" height="25" alt="大" onclick="fontStyleSet(3);fontPicSet(3)"></a>';

	} else {
		writeHtml = '<img src="/common/images/fc_txt.gif" alt="文字サイズ" width="77" height="25">';
		writeHtml += '<a href="javascript:void(0)"><img src="/common/images/font_s.gif" width="27" height="25" alt="小" onclick="fontStyleSet(1);fontPicSet(1)"></a>';
		writeHtml += '<a href="javascript:void(0)"><img src="/common/images/font_m_on.gif" width="27" height="25" alt="中" onclick="fontStyleSet(2);fontPicSet(2)"></a>';
		writeHtml += '<a href="javascript:void(0)"><img src="/common/images/font_l.gif" width="27" height="25" alt="大" onclick="fontStyleSet(3);fontPicSet(3)"></a>';
	}

	nav.innerHTML = writeHtml;

	}
}


fontStyleInit();

