function cookieVal(CookieName) {
	thisCookie = document.cookie.split ("; ")
	for (i=0; i<thisCookie.length; i++) {
		if(CookieName == thisCookie[i].split("=")[0]) {
			return thisCookie[i].split ("=")[1]
		}
	}
	return 0
}

expireDate = new Date
expireDate.setMonth(expireDate.getMonth()+6)

var fontsize

fontsize = eval(cookieVal("fontsize"))

if (fontsize == 0) {
	fontsize = '14';
}
document.cookie = "fontsize="+fontsize+";expires=" + expireDate.toGMTString()

function setCookie(size) {
	fontsize = size;
	document.cookie = "fontsize="+fontsize+";expires=" + expireDate.toGMTString()
}

function increaseFontSize() {
   var min=10;
   var max=20;
   var s = eval(cookieVal("fontsize")) - 0;
	
   var body = document.getElementsByTagName('body');
   for(i=0;i<body.length;i++) {
      if (s == 0) {
         if(body[i].style.fontSize) {
            s = parseInt(body[i].style.fontSize.replace("px",""));
         } else {
            s = 14;
         }
      }

      if(s!=max) {
         s += 1;
      }

      body[i].style.fontSize = s+"px"
   }

   fontsize = s + ""

   setCookie(fontsize)
}

function decreaseFontSize() {
   var min=10;
   var max=20;
   var s = eval(cookieVal("fontsize")) - 0;
	
   var body = document.getElementsByTagName('body');
   for(i=0;i<body.length;i++) {
      if (s == 0) {
         if(body[i].style.fontSize) {
            s = parseInt(body[i].style.fontSize.replace("px",""));
         } else {
            s = 14;
         }
      }

      if(s!=min) {
         s -= 1;
      }

      body[i].style.fontSize = s+"px"
   }

   fontsize = s + ""

   setCookie(fontsize)
}

function loadFontSize() {
   var s = eval(cookieVal("fontsize")) - 0;
	
   var body = document.getElementsByTagName('body');
   for(i=0;i<body.length;i++) {
      if (s == 0) {
         if(body[i].style.fontSize) {
            s = parseInt(body[i].style.fontSize.replace("px",""));
         } else {
            s = 14;
         }
      }

      body[i].style.fontSize = s+"px"
   }

   fontsize = s + ""

   setCookie(fontsize)
}


function defaultFontSize() {
   var body = document.getElementsByTagName('body');
   for(i=0;i<body.length;i++) {
      var s = 14

      body[i].style.fontSize = s+"px"
   }

   fontsize = s + ""
   setCookie(fontsize)
}
