/*
	Easydynfont 
	Version 1.0
	written by Chris Heilmann
	please refer to the homepage at http://www.onlinetools.org/tools/easydynfont.php 
*/

// Standard setting, separate fonts with "," and make sure to set standardfont
// and size to avoid errors
var standardsize="75%";
var nosave=false;

/* 
	function renderMap()
	adds the standard form to the document.
	Text resize function 
	font size can be changed "addsize(-10)" 
*/
function renderMap(){
	document.write('<div class="siteFontSize">');
	document.write('<img src="/images/page/font_size.gif" alt="Font Size Selector" title="Font Size Selector" usemap="#Map" />');
	document.write('<map name="Map" id="Map">');
	document.write('<area shape="rect" coords="0,0,9,14" href="javascript:setFontSize(60)" alt="small &raquo;" title="small &raquo;" />');
	document.write('<area shape="rect" coords="10,0,23,14" href="javascript:setFontSize(75)" alt="default &raquo;" title="default &raquo;" />');
	document.write('<area shape="rect" coords="24,0,38,14" href="javascript:setFontSize(90)" alt="large &raquo;" title="large &raquo;"/>');
	document.write('</map>');
	document.write('</div>');
}

/* 
	function init()
	loads the cookiedata and changes the document accordingly, if there is no 
	cookie, sets the standard settings and stores it 
*/
function init(){
    if (!document.layers){
	size=getCookie("fontsize");
	if (size!=null){
		c=size.split(":");
		document.getElementsByTagName("body").item(0).style.fontSize=c[0];
	}
	if (size==null || c[0]=="" || c[1]==""){
		document.getElementsByTagName("body").item(0).style.fontSize=standardsize;
		saveFontSize();
		}
	}
}		
/* 
	function setFontSize(add)
	sets the font size of the document after page change.
*/
function setFontSize(size){
    if (!document.layers){
	document.getElementsByTagName("body").item(0).style.fontSize=size+"%";
	if (nosave==false) saveFontSize() 
	}
}

/* 
	function saveFontSize()
	saves the current settings of the document in a cookie
	please note: currently the path is set to root "/" but when the main msaustralia website is setup, please make it more specific like "nswvic/"
*/
function saveFontSize(){
	var end = new Date();
	end.setTime(end.getTime() + 24*60*60*90*1000);
	size=document.getElementsByTagName("body").item(0).style.fontSize;
	setCookie("fontsize", size+":"+end,"/");
}
/* 
	function setCookie()
	sets the cookie (note: expires has been taken out so cookie only lasts single session)
*/
function setCookie(name, value, expires, path, domain, secure) { 
	var curCookie = name + "=" + escape(value) + 
	((path) ? "; path=" + path : "") + 
	((domain) ? "; domain=" + domain : "") + 
	((secure) ? "; secure" : "") 
	document.cookie = curCookie 
} 
/* 
	function getCookie()
	reads the cookie
*/
function getCookie(name) { 
	var prefix = name + "=" 
	var cookieStartIndex = document.cookie.indexOf(prefix) 
	if (cookieStartIndex == -1) 
	return null 
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + 
	prefix.length) 
	if (cookieEndIndex == -1) 
	cookieEndIndex = document.cookie.length 
	return unescape(document.cookie.substring(cookieStartIndex + 
	prefix.length, 
	cookieEndIndex)) 
} 
