﻿var min=11;
var max=15;
var startSize = 13;

function setFontSize(){
    var cookieSize = readCookie('credibleCookie');
    // load the script if there is a cookie
    if (cookieSize){
        var div = document.getElementsByTagName('div');
        for(i=0;i<div.length;i++) {
          div[i].style.fontSize = cookieSize+"px"
        }
    }
}
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = startSize;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
   var div = document.getElementsByTagName('div');
   for(i=0;i<div.length;i++) {
      if(div[i].style.fontSize) {
         var s = parseInt(div[i].style.fontSize.replace("px",""));
      } else {
         var s = startSize;
      }
      if(s!=max) {
         s += 1;
      }
      div[i].style.fontSize = s+"px"
   }
   // drop the text size into a cookie
   cookieVal = s;
   createCookie('credibleCookie',cookieVal,7);

}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = startSize;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   } 
   var div = document.getElementsByTagName('div');
   for(i=0;i<div.length;i++) {
      if(div[i].style.fontSize) {
         var s = parseInt(div[i].style.fontSize.replace("px",""));
      } else {
         var s = startSize;
      }
      if(s!=min) {
         s -= 1;
      }
      div[i].style.fontSize = s+"px"
   } 
   // drop the text size into a cookie
   cookieVal = s;
   createCookie('credibleCookie',cookieVal,7);

}