// JavaScript Document
function WriteCookie(key, value, days) {
   var str = key + "=" + escape(value) + ";";
   if (days != 0) {
      var dt = new Date();
      dt.setDate(dt.getDate() + days);
      str += "expires=" + dt.toGMTString() + ";";
   }
   document.cookie = str;
}
function ReadCookie(key) {
   var sCookie = document.cookie;
   var aData = sCookie.split(";");
   var oExp = new RegExp(" ", "g");
   key = key.replace(oExp, "");

   var i = 0;
   while (aData[i]) {
      var aWord = aData[i].split("=");
      aWord[0] = aWord[0].replace(oExp, "");
      if (key == aWord[0]) return unescape(aWord[1]);
      if (++i >= aData.length) break;
   }
   return "";
}
function DeleteCookie(key) {
   var dt = new Date();
   var str = key + "=;expires=" + dt.toGMTString();
   document.cookie = str;
}

//設定項目
var defSize = 12; //規定サイズ
var Unit = 'px'   //単位
var chWidth = 2;  //増減幅
var days = 30;     //クッキー保存日数
//設定項目終わり

var x = defSize;
function SetFontSize(v,page)  {
   if (v > 8 && v < 18) { 
      // index.htmlのとき
			if (page == 1) {
				document.getElementById("index_main").style.fontSize = v + Unit;
				var el=document.getElementsByTagName('dt');
				for (var i=0;i<el.length;i++){
						el[i].style.fontSize = (v + chWidth) + Unit;
					}

			} else {
				document.getElementById("index_main").style.fontSize = v + Unit;
			}
      if (defSize == v) {
         DeleteCookie('FontSize');
			} else {
         WriteCookie('FontSize', v, days);
			}
      x = v;
		 //alert(v);
   }
}
function FontSizeChange(cv,page) {
   if (cv == 0) {
      SetFontSize(defSize,page);
	 } else if(cv > 0) {
      SetFontSize(x + cv, page);
	 } else {
		 	SetFontSize(x + cv, page);
	 }
}
function ReadFontSize() {
   fs = ReadCookie('FontSize')
   if (fs != '') SetFontSize(fs);
}

