﻿function setCookie (name,value,days) {
    if (days)
    {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie (name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++)
    {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

var min=14;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   var font = document.getElementsByTagName('font');
   var li = document.getElementsByTagName('li');
   var strong = document.getElementsByTagName('strong');
   var div = document.getElementsByTagName('div');


   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=max) {
         s += 2;
      }
      p[i].style.fontSize = s+"px"
   }
   for(i=0;i<font.length;i++) {
      if(font[i].style.fontSize) {
         var s = parseInt(font[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=max) {
         s += 2;
      }
      font[i].style.fontSize = s+"px"
   }
   for(i=0;i<li.length;i++) {
      if(li[i].style.fontSize) {
         var s = parseInt(li[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=max) {
         s += 2;
      }
      li[i].style.fontSize = s+"px"
   }
   for(i=0;i<strong.length;i++) {
      if(strong[i].style.fontSize) {
         var s = parseInt(strong[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=max) {
         s += 2;
      }
      strong[i].style.fontSize = s+"px"
   }
   
     for(i=0;i<div.length;i++) {
      if(div[i].style.fontSize) {
         var s = parseInt(div[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=max) {
         s += 2;
      }
      div[i].style.fontSize = s+"px"
   }
   
      // save the font size in a cookie for 25 years
   setCookie('fontsize', s, 365 * 25);
}

function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   var font = document.getElementsByTagName('font');
   var li = document.getElementsByTagName('li');
   var strong = document.getElementsByTagName('strong');
	var div = document.getElementsByTagName('div');


   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=min) {
         s -= 2;
      }
      p[i].style.fontSize = s+"px"
   }  
   for(i=0;i<font.length;i++) {
      if(font[i].style.fontSize) {
         var s = parseInt(font[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=min) {
         s -= 2;
      }
      font[i].style.fontSize = s+"px"
   }
   for(i=0;i<li.length;i++) {
      if(li[i].style.fontSize) {
         var s = parseInt(li[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=min) {
         s -= 2;
      }
      li[i].style.fontSize = s+"px"
   }
   for(i=0;i<strong.length;i++) {
      if(strong[i].style.fontSize) {
         var s = parseInt(strong[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=min) {
         s -= 2;
      }
      strong[i].style.fontSize = s+"px"
   }

   for(i=0;i<div.length;i++) {
      if(div[i].style.fontSize) {
         var s = parseInt(div[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=min) {
         s -= 2;
      }
      div[i].style.fontSize = s+"px"
   }

      
      // save the font size in a cookie for 25 years
   setCookie('fontsize', s, 365 * 25);
}

function fontSize() {
    // if the cookie exists, restore the variable
    var fontsize = getCookie('fontsize');
    if (fontsize) {
        var p = document.getElementsByTagName('p');
  		for(i=0;i<p.length;i++) {
      		p[i].style.fontSize = fontsize + 'px'
   		}
   	}
}