(function(A){A.fn.charCounter=function(B,C){B=B||100;
C=A.extend({container:"<p>",classname:"charcounter",format:"(%1 characters remaining)",pulse:true},C);
var F;
function E(H,G){H=A(H);
if(H.val().length>B){H.val(H.val().substring(0,B));
if(C.pulse&&!F){D(G,true)
}}G.html(C.format.replace(/%1/,(B-H.val().length)))
}function D(G,H){if(F){window.clearTimeout(F);
F=null
}G.animate({opacity:0.1},100,function(){A(this).animate({opacity:1},100)
});
if(H){F=window.setTimeout(function(){D(G)
},200)
}}return this.each(function(){var G=(!C.container.match(/^<.+>$/))?A(C.container):A(C.container).insertAfter(this).addClass(C.classname);
A(this).bind("keydown",function(){E(this,G)
}).bind("keypress",function(){E(this,G)
}).bind("keyup",function(){E(this,G)
}).bind("focus",function(){E(this,G)
}).bind("mouseover",function(){E(this,G)
}).bind("mouseout",function(){E(this,G)
}).bind("paste",function(){var H=this;
setTimeout(function(){E(H,G)
},10)
});
if(this.addEventListener){this.addEventListener("input",function(){E(this,G)
},false)
}E(this,G)
})
}
})(jQuery);