function initResizer()
{
	document.getElementById('dBody') && (window.fontSize = new FontSize("dBody"));
}

//START Cookie Handler //
function CookieHandler() 
{
	this.setCookie = function (name, value, seconds) 
	{
		if (typeof(seconds) != 'undefined')
		{
			var date = new Date();
			date.setTime(date.getTime() + (seconds*1000));
			var expires = "; expires=" + date.toGMTString();
		}
		else
		{
			var expires = "";
		}
		document.cookie = name+"="+value+expires+"; path=/";
	}
    this.getCookie = function (name) 
	{
		name = name + "=";
		var carray = document.cookie.split(';');
		for(var i=0;i < carray.length;i++)
		{
			var c = carray[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
		}
		return null;
	}
	this.deleteCookie = function (name) 
	{
		this.setCookie(name, "", -1);
	}
}

//END Cookie Handler //

//START Font Size //
function FontSize(elementId)
{
	this.Sizes = new Array(70,80,90,100,110,120,130);
	this.Cookie = new CookieHandler;
	this.Default = parseInt(this.Sizes.length / 2);
	this.Size = parseInt(this.Cookie.getCookie(this.ElementId + "_fontSize"));

	if (elementId == "body") 
	{
		this.Element = document.body;
	}
	else
	{
		this.Element = document.getElementById(elementId);
	}

	this.Set = function(size) 	
	{
		try 
		{
			if (size != parseInt(size)) 
			{
				size = this.Default;
			}
		}
		catch(exc) 
		{
			size = this.Default;
		}
		if (size < 0) size = 0;
		if (size >= this.Sizes.length) size = this.Sizes.length - 1;
		this.Size = size;
		this.Cookie.setCookie(this.ElementId + "_fontSize", this.Size)
		this.Element.style.fontSize = this.Sizes[this.Size] + "%";
		
		var tags = new Array(this.Element);
		var tag;
		while (tag = tags.pop())
		{
			var i;
			for (i = 0; i < tag.childNodes.length; i++)
			{
				var child = tag.childNodes[i];
				if (child.nodeType != 1) continue;
				tags.push(child);
				if (!(child.style && child.style.fontSize)) continue;
				child.initialFontSize || (child.initialFontSize = child.style.fontSize);
				var sizeNumber = parseInt(child.initialFontSize);
				var numberLength = sizeNumber.toString().length;
				child.style.fontSize = sizeNumber * this.Sizes[this.Size] / 100 + child.initialFontSize.substr(numberLength, child.initialFontSize.length - numberLength);				
			}
		}		
		
		this.Large = this.Size + 1;
		this.Small = this.Size - 1;
	}
	this.Set(this.Size);
}

addLoadEvent(initResizer);
