(function($) {
  $.fn.wordcount = function() {
    return this.each(function() {
    	var elClass = $(this).attr('class');
        
        $(this).after('<div id="nda" class="clear"><input type="checkbox" name="nda" /><span>This document requires <abbr title="Non-Disclosure Agreement">NDA</abbr></span></div><div class="wordcount clear"><strong>0</strong> Words &mdash; <span id="estimate">Estimate Cost</span></div>');
        
        $(this).bind('keyup click blur focus change paste', function() {
            var numWords = jQuery.trim($(this).val()).replace(/\s+/g," ").split(' ').length;
            if($(this).val() === '') {
                numWords = 0;
            }   
            $(this).siblings('.wordcount').children('strong').text(numWords);
            
        });
    });
  }
})(jQuery);