/**
 * Constructs a TextChange Object for changing dynamically the style of a section of text
 *
 * @param id name of controling div element
 *
 * @return TextChange
 */
function TextChange(id) {

	this.id = id;
	this.element = document.getElementById ? document.getElementById(this.id) : document.all ? document.all(this.id) : null;
	this.size = (this.element && this.element.className) ? Number(this.element.className.charAt(this.element.className.length-1)) : Math.round(TextChange.MAXSIZE/2);
	return this;

}
TextChange.MAXSIZE = 5; // Highest level of text size allowed

/**
 * Resize the current font-style by a level of i
 *
 * @param iDelta (Number) increment/decrement level
 *
 * @return true IFF size was changed
 */
TextChange.prototype.resizeBy = function (iDelta) {

	return this.resizeTo(this.size + iDelta);
}

/**
 * Resize the current font-style to the specified level
 *
 * @param iSize (Number) new font size level
 *
 * @return true IFF size was changed
 */
TextChange.prototype.resizeTo = function (iSize) {

	if (null == this.size || null == this.element) return false // alert ("This feature is not available on your browser.")

	if (iSize >= 1 && iSize <= TextChange.MAXSIZE) {
		this.size = iSize;
		this.element.className = this.id + '-' + iSize;	
		return this.onSizeChanged (this);
	}	
	return false;
}

/**
 * The following function is fired whenever the font size changes
 *
 * @param o TextChange instance
 *
 * @return (Boolean) returns true if program flow shall continue normally
 */
TextChange.prototype.onSizeChanged = function (o) {
	return true;
}

