//Specify affected tags. Add or remove from list:
var tgs = new Array('div','td','tr', 'p', 'a', 'span');

var curFontStep = 5;
var minFontStep = curFontStep - 4;
var maxFontStep = curFontStep + 4;

// -----------------------------------------------------------------
function ts(rootTagName, inc) {
	var rootTag = null, i;

	if (!document.getElementById) return false;

	if (inc !=  1 && inc != -1) return false;
	if (inc ==  1 && curFontStep >= maxFontStep) return false;
	if (inc == -1 && curFontStep <= minFontStep) return false;
	
	if (!( rootTag = document.getElementById(rootTagName))) rootTag = document.getElementsByTagName(rootTagName)[0];

	if (rootTag) {
		for (i = 0; i < tgs.length; i++) {
			if (inc ==  1) { increaseFontSize(rootTag, tgs[i]); }
			if (inc == -1) { decreaseFontSize(rootTag, tgs[i]); }
		}
		// Se ajusta el valor del curStepFont
		if (inc ==  1 && curFontStep < maxFontStep) { curFontStep = curFontStep + 1; }
		if (inc == -1 && curFontStep > minFontStep) { curFontStep = curFontStep - 1; }
	}
}
// -----------------------------------------------------------------
function increaseFontSize(rootTag, tagName) {
var tagObjs = rootTag.getElementsByTagName(tagName);
var s, i;

	for (i = 0; i < tagObjs.length; i++) {
		if (tagObjs[i].style.fontSize) {
			s = parseInt(tagObjs[i].style.fontSize.replace("px",""));
		} else {
			s = getStyle(tagObjs[i], 'fontSize', 'font-size');
			s = s.replace("px","");
			s = parseInt(s.replace("pt",""));
			if (! s) { s = 12; }
		}

		if (curFontStep < maxFontStep) { s += 1; }
		tagObjs[i].style.fontSize = s + "px"
	}
}
// -----------------------------------------------------------------
function decreaseFontSize(rootTag, tagName) {
var tagObjs = rootTag.getElementsByTagName(tagName);
var s, i;

	for (i = 0; i < tagObjs.length; i++) {
		if (tagObjs[i].style.fontSize) {
			s = parseInt(tagObjs[i].style.fontSize.replace("px",""));
		} else {
			s = getStyle(tagObjs[i], 'fontSize', 'font-size');
			s = s.replace("px","");
			s = parseInt(s.replace("pt",""));
			if (! s) { s = 12; }
		}

		if (curFontStep > minFontStep) { s -= 1; }
		tagObjs[i].style.fontSize = s+"px"
	}   
}
// -----------------------------------------------------------------
function getStyle(thisObj, styleProp, stylePropGecko) {
	var y;

	if (thisObj.currentStyle) {
		y = thisObj.currentStyle[styleProp];
	} else if (document.defaultView.getComputedStyle) {
		var styleName = (stylePropGecko != '' ? stylePropGecko : styleProp);
		y = document.defaultView.getComputedStyle(thisObj, "").getPropertyValue(styleName);
	} else {
		y = '';
	}
	return y;
}
// -----------------------------------------------------------------