/*!
 * jQuery Animated Auto-Resizable Textarea Plugin v1.0
 *
 * Copyright (c) 2009 - 2010 Wayne Haffenden
 * http://www.waynehaffenden.com/Blog/jQuery-AutoResizable-Plugin
 *
 * $Id: jquery.autoResizable.js, v 1.0 2009-12-30 01:53:14Z whaffenden $
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
;(function(e){e.fn.autoResizable=function(o){var c=e.extend({animate:true,animateDuration:200,maxHeight:500,onBeforeResize:null,onAfterResize:null,padding:20,paste:true,pasteInterval:100},o);return this.filter("textarea").each(function(){var a=e(this),j=a.height(),f=0,g=null,p=c.animate,q=c.animateDuration,h=c.maxHeight,l=c.onBeforeResize,i=c.onAfterResize,r=c.padding,s=c.paste,t=c.pasteInterval,n=function(){var b={};e.each(["height","letterSpacing","lineHeight","textDecoration","width"],function(k,m){b[m]=a.css(m)});return a.clone().removeAttr("id").removeAttr("name").css({left:-99999,position:"absolute",top:-99999}).css(b).attr("tabIndex",-1).insertBefore(a)}(),d=function(){if(j<=0)j=a.height();n.height(0).val(a.val()).scrollTop(1E4);var b=Math.max(n.scrollTop()+r,j);if(!(b===f||b>=h&&f===h)){if(b>=h){b=h;a.css("overflow-y","auto")}else a.css({overflow:"hidden",overflowY:"hidden"});var k=true;if(l!==null)k=l.call(a,f,b);f=b;if(k!==false)if(p&&a.css("display")==="block")a.stop().animate({height:b},q,function(){i!==null&&i.call(a)});else{a.height(b);i!==null&&i.call(a)}}};a.css({overflow:"hidden",resize:"none"});a.unbind(".autoResizable").bind("keydown.autoResizable",d).bind("keyup.autoResizable",d).bind("change.autoResizable",d).bind("focus.autoResizable",function(){if(s)g=setInterval(d,t);d()}).bind("blur.autoResizable",function(){if(g!==null){clearInterval(g);g=null}})})}})(jQuery);
