/*
Javascript to dynamically change font sizes on a web page.
Coded by Phil Nash of www.unintentionallyblank.co.uk
Cookies script courtesy of http://www.quirksmode.org/js/cookies.html

** Please don't remove this notice **

See http://www.unintentionallyblank.co.uk/2006/08/02/fontsizer/ for full details

To use the code, upload this file to your site's main directory and add the following lines to the <head> element of your site:

  <script type="text/javascript" src="fontsizer.js"></script>
  
If you want to use the php method to control the sizing on different pages then add the following to the <head> element too:

  <?php if(isset($_COOKIE['fs'])) { ?>
  <style type="text/css">
  <!--
  div { font-size:<?php $arr = array('0.9', '1', '1.1', '1.2', '1.3'); echo $arr[$_COOKIE['fs']]; ?>em; }
  // -->
  </style>
  <?php } ?>

If you would prefer to use the onLoad function of the body element, use this bit of code:

  <body onLoad="init()">

*/

function setFontByTag(e, v) {
	/*
	var elements = document.getElementsByTagName(e);
	for(var i = 0; i < elements.length; i++) {
		elements.item(i).style['fontSize'] = v;
		}
	}
	*/
	var shell = document.getElementById('shell');
	shell.style.fontSize = v;
}
	
function createCookie(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 readCookie(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;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}
/*
var sizes = new Array('0.9', '1', '1.1', '1.2', '1.3');
var si = 1;
*/
function changeSize(inc) {
	var sizes = new Array('0.9', '1', '1.1', '1.2', '1.3', '1.4');
	var si = 1;
	if(readCookie('fs')) { si = parseInt(readCookie('fs')); }
	if (!document.getElementsByTagName) {return false;}
	if (inc == '1') { 
		si+=1;
		if (si>5) si=5;
		}
	else if (inc == '-1') { 
		si-=1;
		if (si<0) si=0;
		}
	setFontByTag('div', sizes[si]+'em');
	createCookie('fs',si,30);
	}
	
function initFontSizer() {
	if(readCookie('fs')) { var si = parseInt(readCookie('fs')); }
	if (!document.getElementsByTagName) {return false;}
	var sizes = new Array('0.9', '1', '1.1', '1.2', '1.3');
	setFontByTag('div', sizes[si]+'em');
	}
	
function resetSize() {
	setFontByTag('div', '1em');
	eraseCookie('fs');
	}
	
