var dw_fontSizerDX = {
	sizeUnit : "px", defaultSize : 14, maxSize : 24, minSize : 10, adjustList : [], setDefaults :

	function(unit, dflt, mn, mx, sels)
	{
		this.sizeUnit = unit;
		this.defaultSize = dflt;
		this.maxSize = mx;
		this.minSize = mn;
		if(sels)
			this.set(dflt, mn, mx, sels);
	}

	, set :

	function(dflt, mn, mx, sels)
	{
		var ln = this.adjustList.length;
		for(var i = 0; sels[i]; i++)
		{
			this.adjustList[ln + i] = [];
			this.adjustList[ln + i]["sel"] = sels[i];
			this.adjustList[ln + i]["dflt"] = dflt;
			this.adjustList[ln + i]["min"] = mn || this.minSize;
			this.adjustList[ln + i]["max"] = mx || this.maxSize;
			this.adjustList[ln + i]["ratio"] = this.adjustList[ln + i]["dflt"] / this.defaultSize;
		}
	}

	, init : function()
	{
		if(!document.getElementById || !document.getElementsByTagName || !dw_fontSizerDX.ready)
			return;

		var size, sizerEl, i;
		size = window.location.search ? window.location.search.slice(1) : getCookie("fontSize");
		size = !isNaN(parseFloat(size)) ? parseFloat(size) : this.defaultSize;
		if(size > this.maxSize || size < this.minSize)
			size = this.defaultSize;

		this.curSize = this.defaultSize;
		sizerEl = document.getElementById('sizer');
		if(sizerEl)
			sizerEl.style.display = "block";

		if(this.adjustList.length == 0)
		{
			this.setDefaults(this.sizeUnit, this.defaultSize, this.minSize, this.maxSize, ['body', 'td']);
		}

		if(size != this.defaultSize)
			this.adjust(size - this.defaultSize);
	}

	, adjust : function(n)
	{
		if(!this.curSize || !dw_fontSizerDX.ready)
			return;

		var alist, size, list, i, j;
		if(n > 0)
		{
			if(this.curSize + n > this.maxSize)
				n = this.maxSize - this.curSize;
		}
		else
			if(n < 0)
			{
				if(this.curSize + n < this.minSize)
					n = this.minSize - this.curSize;
			}

		if(n == 0)
			return;

		this.curSize += n;
		alist = this.adjustList;
		for(i = 0; alist[i]; i++)
		{
			size = this.curSize * alist[i]['ratio'];
			size = Math.max(alist[i]['min'], size);
			size = Math.min(alist[i]['max'], size);
			list = dw_getElementsBySelector(alist[i]['sel']);
			for(j = 0; list[j]; j++)
			{
				list[j].style.fontSize = size + this.sizeUnit;
			}
		}

		setCookie("fontSize", this.curSize, 180, "/");
	}

	, reset : function()
	{
		if(!this.curSize || !dw_fontSizerDX.ready)
			return;

		var alist = this.adjustList, list, i, j;
		for(i = 0; alist[i]; i++)
		{
			list = dw_getElementsBySelector(alist[i]['sel']);
			for(j = 0; list[j]; j++)
			{
				list[j].style.fontSize = '';
			}
		}

		this.curSize = this.defaultSize;
		deleteCookie("", "/");
	}
};

var dw_Inf = {
};

dw_Inf.fn = function(v)
{
	return eval(v)
};

dw_Inf.gw = dw_Inf.fn("window.location");

function dw_getElementsBySelector(selector)
{
	if(!document.getElementsByTagName)
		return[];

	var nodeList = [document], tokens, bits, list, col, els, i, j, k;
	selector = selector.normalize();
	tokens = selector.split(' ');
	for(i = 0; tokens[i]; i++)
	{
		if(tokens[i].indexOf('#') != -1)
		{
			bits = tokens[i].split('#');
			var el = document.getElementById(bits[1]);
			if(!el)
				return[];

			if(bits[0])
			{
				if(el.tagName.toLowerCase() != bits[0].toLowerCase())
					return[];
			}

			for(j = 0; nodeList[j]; j++)
			{
				if(nodeList[j] == document || dw_contained(el, nodeList[j]))
					nodeList = [el];
				else
					return[];
			}

			continue;
		}
		else
			if(tokens[i].indexOf('.') != -1)
			{
				bits = tokens[i].split('.');
				col = [];
				for(j = 0; nodeList[j]; j++)
				{
					els = dw_getElementsByClassName(bits[1], bits[0], nodeList[j]);
					for(k = 0; els[k]; k++)
					{
						col[col.length] = els[k];
					}
				}

				nodeList = [];
				for(j = 0; col[j]; j++)
				{
					nodeList.push(col[j]);
				}

				continue;
			}
			else
			{
				els = [];
				for(j = 0; nodeList[j]; j++)
				{
					list = nodeList[j].getElementsByTagName(tokens[i]);
					for(k = 0; list[k]; k++)
					{
						els.push(list[k]);
					}
				}

				nodeList = els;
			}
	}

	return nodeList;
};

dw_Inf.ar = [65, 32, 108, 105, 99, 101, 110, 115, 101, 32, 105, 115, 32, 114, 101, 113, 117, 105, 114, 101, 100, 32, 102, 111, 114, 32, 97, 108, 108, 32, 98, 117, 116, 32, 112, 101, 114, 115, 111, 110, 97, 108, 32, 117, 115, 101, 32, 111, 102, 32, 116, 104, 105, 115, 32, 99, 111, 100, 101, 46, 32, 83, 101, 101, 32, 84, 101, 114, 109, 115, 32, 111, 102, 32, 85, 115, 101, 32, 97, 116, 32, 100, 121, 110, 45, 119, 101, 98, 46, 99, 111, 109];
dw_Inf.get = function(ar)
{
	var s = "";
	var ln = ar.length;
	for(var i = 0; i < ln; i++)
	{
		s += String.fromCharCode(ar[i]);
	}

	return s;
};

function dw_getElementsByClassName(sClass, sTag, oCont)
{
	var result = [], list, i;
	var re = new RegExp("\\b" + sClass + "\\b", "i");
	oCont = oCont ? oCont : document;
	if(document.getElementsByTagName)
	{
		if(!sTag || sTag == "*")
		{
			list = oCont.all ? oCont.all : oCont.getElementsByTagName("*");
		}
		else
		{
			list = oCont.getElementsByTagName(sTag);
		}

		for(i = 0; list[i]; i++)
			if(re.test(list[i].className))
				result.push(list[i]);
	}

	return result;
};

dw_Inf.mg = dw_Inf.fn('dw_Inf.get(dw_Inf.ar)');
dw_Inf.fn('dw_Inf.gw=\"localhost\"');

function dw_contained(oNode, oCont)
{
	if(!oNode)
		return;

	while(oNode = oNode.parentNode)
		if(oNode == oCont)
			return true;

	return false;
};

dw_Inf.x0 = function()
{
	dw_Inf.fn('if(!(dw_Inf.gw==\"\"||dw_Inf.gw==\"127.0.0.1\"||dw_Inf.gw==\"localhost\"||dw_Inf.gw.indexOf(\"dyn-web.com\")!=-1))alert(dw_Inf.mg);');
	dw_Inf.fn('dw_Inf.ready=true;');
	dw_Inf.fn('dw_fontSizerDX.ready=true;');
};

dw_Inf.fn('dw_Inf.x0();');
if(!Array.prototype.push)
{
	Array.prototype.push = function()
	{
		for(var i = 0; arguments[i]; i++)
			this[this.length] = arguments[i];

		return this[this.length - 1];
	};
};

String.prototype.normalize = function()
{
	var re = /fontSize\s\s +/g;
	return this.trim().replace(re, " ");
};

String.prototype.trim = function()
{
	var re = /^\s +| \s + $/;
	return this.replace(re, "");
};

dw_fontSizerDX.setDefaults("px", 13, 10, 20, ['td#content'] );
dw_fontSizerDX.set(16, 11, 24, ['h1'] );
dw_fontSizerDX.set(14, 10, 22, ['h2'] );
dw_fontSizerDX.set(11, 9, 16, ['.press td'] );
dw_fontSizerDX.set(11, 9, 16, ['.press th'] );
dw_fontSizerDX.init();