cookiePath = "/";                   // 
cookieThru = 3;                     // クッキーの有効期限(日)

fontSizeCookie = "fontsize";        // 
fontSizeClassMax = 4;               // フォントの大きさは 4 段階.
fontSizeClassDefault = 2;           // 2 が標準.
fontSizeClass = fontSizeClassDefault;

var parentFlag = true;

function setCookie(name, value) {
   dateObj = new Date();
   dateObj.setTime(dateObj.getTime() + 24 * 60 * 60 * cookieThru * 1000);
   expires = dateObj.toGMTString();
   document.cookie = name + "=" + escape(value) + ";expires=" + expires + ";path=" + cookiePath;
}

function getCookie(name) {
   key = name + "=";
   keyLen = key.length;
   cookieLen = document.cookie.length;
   for (i = 0; i < cookieLen; ) {
      j = i + keyLen;
      if (document.cookie.substring(i, j) == key) {
         return getCookieValue(j);
      }
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) {
         break;
      }
   }
   return null;
}

function getCookieValue(offset) {
   terminator = document.cookie.indexOf(";", offset);
   if (terminator < 0) {
      terminator = document.cookie.length;
   }
   return unescape(document.cookie.substring(offset, terminator));
}

function deleteCookie(name) {
   if (getCookie(name)) {
      document.cookie = name + "=" + ";expires=Thu, 01-Jan-70 00:00:01 GMT;path=" + cookiePath;
   }
}

function fontSize(how) {
   if (how == "larger") {
      fontSizeClass ++;
      if (fontSizeClassMax < fontSizeClass) {
         fontSizeClass = fontSizeClassMax;
      }
   }
   else if (how == "smaller") {
      fontSizeClass --;
      if (fontSizeClass <= 0) {
         fontSizeClass = 1;
      }
   }
   else if (how == "default") {
      fontSizeClass = fontSizeClassDefault;
   }

   setCookie(fontSizeCookie, fontSizeClass);
   location.reload(true);
   if (parentFlag) {
      try {
         parent.main.location.reload(true);
      } catch (e) { }
   }
}

// Cookie から現在の fontsize の値を取得し, 対応する CSS を読み込む.
fontSizeCookieValue = getCookie(fontSizeCookie);
if (fontSizeCookieValue != null) {
   fontSizeClass = parseInt(fontSizeCookieValue);
}

fontSize1 =  9;
fontSize2 = 10;
fontSize3 = 11;
fontSize4 = 12;
fontSize5 = 13;

if (fontSizeClass <= 1) {
   fontSize1 =  8;
   fontSize2 =  9;
   fontSize3 = 10;
   fontSize4 = 11;
   fontSize5 = 12;
}
else if (fontSizeClass == 2) {
   fontSize1 =  9;
   fontSize2 = 10;
   fontSize3 = 11;
   fontSize4 = 12;
   fontSize5 = 13;
}
else if (fontSizeClass == 3) {
   fontSize1 = 10;
   fontSize2 = 11;
   fontSize3 = 12;
   fontSize4 = 13;
   fontSize5 = 14;
}
else if (fontSizeClass == 4) {
   fontSize1 = 11;
   fontSize2 = 12;
   fontSize3 = 13;
   fontSize4 = 14;
   fontSize5 = 15;
}
else if (5 <= fontSizeClass) {      // 大き過ぎてレイアウトが乱れる!
   fontSize1 = 12;
   fontSize2 = 13;
   fontSize3 = 14;
   fontSize4 = 15;
   fontSize5 = 16;
}

document.writeln("<style type=\"text/css\">");
document.writeln("body { font-size:" + fontSize3 + "pt; }");
document.writeln(".SS  { font-size:" + fontSize1 + "pt; }");
document.writeln(".S   { font-size:" + fontSize2 + "pt; }");
document.writeln(".M   { font-size:" + fontSize3 + "pt; }");
document.writeln(".L   { font-size:" + fontSize4 + "pt; }");
document.writeln(".LL  { font-size:" + fontSize5 + "pt; }");
document.writeln(".R   { font-size:" + fontSize3 + "pt; color: red; }");
document.writeln(".RSS { font-size:" + fontSize1 + "pt; color: red; }");
document.writeln(".RS  { font-size:" + fontSize2 + "pt; color: red; }");
document.writeln(".RM  { font-size:" + fontSize3 + "pt; color: red; }");
document.writeln(".RL  { font-size:" + fontSize4 + "pt; color: red; }");
document.writeln(".RLL { font-size:" + fontSize5 + "pt; color: red; }");
//document.writeln("th   { font-size:" + fontSize3 + "pt;text-align:left;vertical-align:top;font-weight:normal; }");
//document.writeln("td   { font-size:" + fontSize3 + "pt;text-align:left;vertical-align:top; }");
document.writeln("th   { font-size:" + fontSize3 + "pt;font-weight:normal; }");
document.writeln("td   { font-size:" + fontSize3 + "pt; }");
document.writeln("</style>");

