var min=8;
var max=18;

function initializeFonts() {

    var ccs = getCookie('fontsize');

    if(ccs == "")
       setCookie('fontsize',0,1);
    else
       setInitialFontSize(ccs);


}

function setInitialFontSize(cookiefont) {

   if(cookiefont == 0) return;

   var p = document.getElementsByTagName('p');
   var d = document.getElementsByTagName('div');
   var t = document.getElementsByTagName('td');
   var a = document.getElementsByTagName('a');
   var b = document.getElementsByTagName('b');

   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += parseInt(cookiefont);
      }
      p[i].style.fontSize = s+"px"
   }

for(i=0;i<d.length;i++) {
      if(d[i].style.fontSize) {
         var s = parseInt(d[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += parseInt(cookiefont);
      }
      d[i].style.fontSize = s+"px"
   }

for(i=0;i<t.length;i++) {
      if(t[i].style.fontSize) {
         var s = parseInt(t[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += parseInt(cookiefont);
      }
      t[i].style.fontSize = s+"px"
   }

for(i=0;i<a.length;i++) {
      if(a[i].style.fontSize) {
         var s = parseInt(a[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += parseInt(cookiefont);
      }
      a[i].style.fontSize = s+"px"
   }

for(i=0;i<b.length;i++) {
      if(b[i].style.fontSize) {
         var s = parseInt(b[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += parseInt(cookiefont);
      }
      b[i].style.fontSize = s+"px"
   }

}

function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   var d = document.getElementsByTagName('div');
   var t = document.getElementsByTagName('td');
   var a = document.getElementsByTagName('a');
   var b = document.getElementsByTagName('b');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }

for(i=0;i<d.length;i++) {
      if(d[i].style.fontSize) {
         var s = parseInt(d[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      d[i].style.fontSize = s+"px"
   }

for(i=0;i<t.length;i++) {
      if(t[i].style.fontSize) {
         var s = parseInt(t[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      t[i].style.fontSize = s+"px"
   }

for(i=0;i<a.length;i++) {
      if(a[i].style.fontSize) {
         var s = parseInt(a[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      a[i].style.fontSize = s+"px"
   }

for(i=0;i<b.length;i++) {
      if(b[i].style.fontSize) {
         var s = parseInt(b[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      b[i].style.fontSize = s+"px"
   }

var ccs = getCookie('fontsize');

if(ccs == "")
   setCookie('fontsize',1,1);
else
   setCookie('fontsize',parseInt(ccs)+1,1);


}

function decreaseFontSize() {
   var p = document.getElementsByTagName('div');
   var d = document.getElementsByTagName('div');
   var t = document.getElementsByTagName('td');
   var a = document.getElementsByTagName('a');

   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   } 

for(i=0;i<d.length;i++) {
      if(d[i].style.fontSize) {
         var s = parseInt(d[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      d[i].style.fontSize = s+"px"
   } 

for(i=0;i<t.length;i++) {
      if(t[i].style.fontSize) {
         var s = parseInt(t[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      t[i].style.fontSize = s+"px"
   } 

for(i=0;i<a.length;i++) {
      if(a[i].style.fontSize) {
         var s = parseInt(a[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      a[i].style.fontSize = s+"px"
   } 

var ccs = getCookie('fontsize');

if(ccs == "")
   setCookie('fontsize',-1,1);
else
   setCookie('fontsize',parseInt(ccs)-1,1);

  
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function checkCookie()
{
fontsize=getCookie('fontsize');
if (fontsize!=null && fontsize!="")
  {
  alert('current font size is '+fontsize+'!');
  }
else
  {
  fontsize=14;
  if (fontsize!=null && fontsize!="")
    {
    setCookie('fontsize',fontsize,1);
    }
  }
}
