/* フォントサイズの変換 */
/* 元ソース　http://www.savechildren.or.jp/ */

// サイズ大中小で、読み込むべきCSSファイルを定義
cssTagS = '<link href="http://www.town.kotoura.tottori.jp/shared/font-s.css" rel="stylesheet" type="text/css" media="all">';
cssTagM = '<link href="http://www.town.kotoura.tottori.jp/shared/font-m.css" rel="stylesheet" type="text/css" media="all">';
cssTagL = '<link href="http://www.town.kotoura.tottori.jp/shared/font-l.css" rel="stylesheet" type="text/css" media="all">';

cookiename = "kotouraFontSize";

function  changeFontSize(s){
	exp=new Date();
	exp.setTime(exp.getTime()+1000*60*60*24*365);
	// 変数 s の値は、0, 1, 2 のどれか。Cookieにこの値を保存して再読み込み。
	document.cookie = cookiename + "=" + s + "; path=/; expires=" + exp.toGMTString();
	window.location.reload(true);
}

function LoadFontSize(){
	// Cookieを読み込み、変数を取り出す。
	allCookie = document.cookie+";";
	temp = allCookie.indexOf(cookiename);
	if (temp != -1) {
		temp2 = allCookie.indexOf("=",temp);
		temp3 = allCookie.indexOf(";",temp2);
		value = allCookie.substring(temp2+1, temp3);
	} else {
		value = null;
	}

	// 変数により、CSSのファイルを選択。（変数にURLは定義済み）
	if(value==0){
		document.write(cssTagS);
	}else if(value==1){
		document.write(cssTagM);
	}else if(value==2){
		document.write(cssTagL);
	}else{
		document.write(cssTagM);
	}
}

function ReadFontSize() {
	var allCookie = document.cookie+";";
	var temp = allCookie.indexOf(cookiename);
	if (temp != -1) {
		var temp2 = allCookie.indexOf("=",temp);
		var temp3 = allCookie.indexOf(";",temp2);
		var value = allCookie.substring(temp2+1, temp3);
	} else {
		var value = '';
	}
	return value;
}
