/*
 * Author : Michael Bosworth 2007
 *
 * Note : This class is dependant on : mootools
 *
 * These files must be included prior to this script to function.
*/

/* Get container Element */

mdp.textresize.container = $("#"+mdp.textresize.containerId);

/* Get all controllers */
mdp.textresize.upcontrollers = $(".sizeUpController");
mdp.textresize.downcontrollers = $(".sizeDownController");

/* Sets the the onclick event handler of each controlelr to the handler */
mdp.textresize.linkControllers = function(controllers, handler){
	$(controllers).each(function(index,item){
		item.onclick = handler;
	});
};

/* Increments size and sets the classname of the container to "size" + size css class */
mdp.textresize.sizeUp = function(){
    if(mdp.textresize.container != null){
        if(mdp.textresize.size + 1 <= mdp.textresize.upperLimit){
            mdp.textresize.size++;
            mdp.textresize.container.removeClass();
            mdp.textresize.container.addClass("size" + mdp.textresize.size);
        }
    }
};

/* Decrements size and sets the classname of the container to "size" + size css class */
mdp.textresize.sizeDown = function(){
    if(mdp.textresize.container != null){
        if(mdp.textresize.size - 1 >= mdp.textresize.lowerLimit){
            mdp.textresize.size--;
            mdp.textresize.container.removeClass();
            mdp.textresize.container.addClass("size" + mdp.textresize.size);
        }
    }
};

/* Attach events to controllers */
mdp.textresize.linkControllers(mdp.textresize.upcontrollers,mdp.textresize.sizeUp);
mdp.textresize.linkControllers(mdp.textresize.downcontrollers,mdp.textresize.sizeDown);
