/*!
 * Autogrow Textarea Plugin Version v2.0
 * http://www.technoreply.com/autogrow-textarea-plugin-version-2-0
 *
 * Copyright 2011, Jevin O. Sewaruth
 *
 * Date: March 13, 2011
 */
jQuery.fn.autoGrow = function(){
	return this.each(function(){
		// Variables

		//Functions
		var grow = function() {
			updateHeight(this);
		}

        var updateHeight = function(obj) {
            if( obj.scrollHeight > obj.offsetHeight)
                obj.style.height = obj.scrollHeight + "px";
        }

        this.style.overflow = "hidden";
        
		$(this).unbind('.autoGrow')
			.bind('keyup.autoGrow', grow)
			.bind('change.autoGrow', grow);
		updateHeight(this);
	});
};
