(function(jQuery) {

jQuery.fn.simpleautogrow = function(o) {
return this.each(function() { new jQuery.simpleautogrow(this, o); }); };

jQuery.simpleautogrow = function (e, o) {
var self = this;
var $e = this.textarea = jQuery(e)
.css({overflow: 'hidden', display: 'block', height: '35px'})
.bind('focus', function() {
this.timer = window.setInterval(function() {self.checkExpand(); }, 200); })
.bind('blur', function() { clearInterval(this.timer); });
this.border = $e.outerHeight() - $e.innerHeight();
this.o = o||{};
this.clone = $e.clone().css({position: 'absolute', visibility: 'hidden'}).attr('name', '')
$e.height(e.scrollHeight + this.border)
.after(this.clone);
this.checkExpand(); 
};

jQuery.simpleautogrow.prototype.checkExpand = function() {
var target_height = this.clone[0].scrollHeight + this.border;
this.o.min_height =34;
if (this.o.min_height)
target_height = target_height > this.o.min_height?target_height:this.o.min_height;
if (this.textarea.outerHeight() != target_height)
this.textarea.height(target_height + 'px');
this.clone.attr('value', this.textarea.attr('value')).height(0); };

})(jQuery);