﻿window.onload = function() {

  li=document.getElementById('text-size');
  
  li.innerHTML = 
  
     '<a id="reduceFont" href="javascript:void(0);" onclick="resizeDown();return false;" title="Reduce font size"><img src="/images/template/text-small.png" alt="Smaller" /> </a>' +
        
     '<a id="increaseFont" href="javascript:void(0);" onclick="resizeUp();return false;" title="Increase font size"><img src="/images/template/text-large.png" alt="Larger" /> </a>' +
       
     '<a id="normalFont" href="javascript:void(0);" onclick="resizeZero();return false;" title="Reload font size"><img src="/images/template/text-reload.png" alt="Reset text" /> </a>';
          
}

function getAllChildren(e) {

// Returns all children of element. Workaround required for IE5/Windows. Ugh. 

return e.all ? e.all : e.getElementsByTagName('*'); 

}



function resizeUp() {

	if (document.getElementById ('reduceFont').style.display=='none'){

		document.getElementById ('reduceFont').style.display='inline';	

	}

	var bds =document.getElementsByTagName('BODY');

	var bodyObj = bds[0];

	if(!bodyObj.style.fontSize){

		bodyObj.style.fontSize = '88.5%';

	} else {

		var str_fontsize = bodyObj.style.fontSize;

		var num_fontsize = str_fontsize.substring(0,str_fontsize.length-1);

		

		var num_newsize = num_fontsize * 1 + 8.5;

		if (num_newsize>114) num_newsize=114;

		bodyObj.style.fontSize = num_newsize + '%';

	}

	

	if (bodyObj.style.fontSize == '114%'){

		document.getElementById ('increaseFont').style.display='none';

	}

	fontSize=bodyObj.style.fontSize.substring(0,bodyObj.style.fontSize.length-1);

	setCookie('fontSize',fontSize,30);

}



function resizeZero() {

	document.getElementById ('increaseFont').style.display='inline';

	document.getElementById ('reduceFont').style.display='inline';	

	var bds =document.getElementsByTagName('BODY');

	var bodyObj = bds[0];

	bodyObj.style.fontSize = '80%';

	fontSize=80;

	setCookie('fontSize',fontSize,30);

}



function resizeDown() {

	if (document.getElementById ('increaseFont').style.display=='none'){

		document.getElementById ('increaseFont').style.display='inline';	

	}

	var bds =document.getElementsByTagName('BODY');

	var bodyObj = bds[0];

	if(!bodyObj.style.fontSize){

		bodyObj.style.fontSize = '71.5%';

	} else {

		var str_fontsize = bodyObj.style.fontSize;

		var num_fontsize = str_fontsize.substring(0,str_fontsize.length-1);



		var num_newsize = num_fontsize * 1 - 8.5;

		if (num_newsize<64) num_newsize=63;

		bodyObj.style.fontSize = num_newsize + '%';



	}

	

	if (bodyObj.style.fontSize =='63%'){

		document.getElementById ('reduceFont').style.display='none';

	}

	fontSize=bodyObj.style.fontSize.substring(0,bodyObj.style.fontSize.length-1);

	setCookie('fontSize',fontSize,30);

}

function resizeFontTo (num_fontsize) {

	var bds =document.getElementsByTagName('BODY');

	var bodyObj = bds[0];

	bodyObj.style.fontSize = num_fontsize + '%';

	if (bodyObj.style.fontSize == '114%'){

		document.getElementById ('increaseFont').style.display='none';

	}

	if (bodyObj.style.fontSize =='63%'){

		document.getElementById ('reduceFont').style.display='none';	

	}

	fontSize=bodyObj.style.fontSize.substring(0,bodyObj.style.fontSize.length-1);

	setCookie('fontSize',fontSize,30);

}



function setCookie(c_name,value,expiredays)

{

var exdate=new Date();

exdate.setDate(exdate.getDate()+expiredays);

document.cookie=c_name+ "=" +escape(value)+

((expiredays==null) ? "" : ";expires="+exdate.toGMTString());

}



function getCookie(c_name)

{

if (document.cookie.length>0)

  {

  c_start=document.cookie.indexOf(c_name + "=");

  if (c_start!=-1)

    { 

    c_start=c_start + c_name.length+1; 

    c_end=document.cookie.indexOf(";",c_start);

    if (c_end==-1) c_end=document.cookie.length;

    return unescape(document.cookie.substring(c_start,c_end));

    } 

  }

return "";

}



var fontSize;



function checkCookie()

{

cCookie=getCookie('fontSize');

if (cCookie!=null && cCookie!="")

	{

		fontSize = cCookie;

	

	}

else 

	{

		setCookie('fontSize',fontSize,30);

	}

}


