/*--------------------------------------------------
Font Sizer - Copyright 2007 - Indiana Loans Limited.
Owner Site: http://www.indiana-loans.co.uk/
All rights reserved.
Coded by: Stewart Farquhar, Dicontas Limited
Developer Site: http://www.dicontas.co.uk/

Please retain this copyright notice in the script.
License is granted to user to reuse this code on
their own website if, and only if,
this entire copyright notice is included.
---------------------------------------------------*/

var aCSStags = new Array('div', 'tr', 'td', 'span', 'p');
var aFontSizes = new Array('10px', '12px', '13px', '14px', '15px', '16px');

var iDefaultFontSize = 1;
var iStartingFontSize = 1;
var iCookieFont;

jQuery(document).ready(function() {
	if (jQuery.cookie('STL_font_size')) {
		iCookieFont = jQuery.cookie('STL_font_size');
		
		if (iCookieFont >= 0) {
			iStartingFontSize = iCookieFont-1;
			fnChangeFontSize('content', 1);
		}
	}
});

function fnChangeFontSize(cTargetTag, iFontSizeChange) {
	var refDoc = document;
	var myElement = null;
	var iFontSize = iStartingFontSize;
	var iLoop;
	var jLoop;
	var cTags;
	var i;
	
	if (!document.getElementById) return;
	
	if (!(typeof(iFontSizeChange) == 'number') && !(iFontSizeChange.toString().indexOf('.') == -1)) return;
	
	if (iFontSizeChange == 0) {
		iFontSize = iDefaultFontSize;
	} else {
		iFontSize += iFontSizeChange;
	}
	
	if (iFontSize < 0) iFontSize = 0;
	if (iFontSize > 5) iFontSize = 5;
	
	iStartingFontSize = iFontSize;
		
	if (!(myElement = refDoc.getElementById(cTargetTag))) {
		myElement = refDoc.getElementsByTagName(cTargetTag)[0];
	}
	
	myElement.style.fontSize = aFontSizes[iFontSize];
	
	for (iLoop = 0; iLoop < aCSStags.length; iLoop++) {
		cTags = myElement.getElementsByTagName(aCSStags[i]);
		
		for (jLoop = 0; jLoop < cTags.length; jLoop++) {
			cTags[jLoop].style.fontSize = aFontSizes[iFontSize];
		}
	}
	
	jQuery.cookie('STL_font_size', iFontSize);
}

