/* Text Resize */

YAHOO.namespace("StoryTools");

YAHOO.StoryTools.textResize = function(el, direction) {

	function resizeFont(el, enlarge) {
		var elements = YAHOO.util.Dom.get(el); // Get DOM references
		for(var i=0; i<elements.length; i++) {
			resizeElement(elements[i], enlarge);
		}
	}

	function resizeElement(el, enlarge) {
		var fontStyle, fontSize, fontUnit;
		fontStyle  = YAHOO.util.Dom.getStyle(el, 'font-size');
		fontSize   = Number(fontStyle.replace(/[a-zA-Z]*$/, ''));
		fontUnit   = fontStyle.replace(/^[0-9\.]*/, '');


		if (fontUnit != 'px' && fontUnit != 'em') {
			return;
		}

		var factor = (fontUnit == 'px') ? 1 : .1;
		fontSize   = (enlarge) ? fontSize+factor : fontSize-factor;
		fontStyle  = fontSize + fontUnit;
		YAHOO.util.Dom.setStyle(el, 'font-size', fontStyle);
	}

	return {
		enlarge: function(el) {
			resizeFont(el, true);
		},
		reduce: function(el) {
			resizeFont(el, false);
		}
	}
}();