
var defSize = 0.8;
var MinSize = 0.6;
var MaxSize = 2.0;
var Unit = 'em';
var chWidth = 0.2;
var days = 30;
 
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() + "; path=/";
   }
   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() + "; path=/";
   document.cookie = str;
}
 
var x = defSize;
function SetFontSize(v)  {
   if (v > MinSize && v < MaxSize) {
      document.body.style.fontSize = v + Unit;
      if (defSize == v)
         DeleteCookie('FontSize');
      else
         WriteCookie('FontSize', v, days);
      x = v;
   }
}
function FontSizeChange(cv) {
   if (cv == 0)
      SetFontSize(defSize);
   else
      SetFontSize(x + cv);
}
function ReadFontSize() {
   fs = ReadCookie('FontSize')
   if (fs != '') SetFontSize(fs);
}
 