/*
 * 
 * Textarea Word Count Jquery Plugin 
 * Version 1.0
 * 
 * Copyright (c) 2008 Roshan Bhattarai
 * website : http://roshanbh.com.np
 * 
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * 
*/

jQuery.fn.wordCount = function(params){
	var p = {
		counterElement:"display_count",
		counterMinimum:"display_minimum",
		counterTotal:5
	};
	var total_words;
	
	if(params) {
		jQuery.extend(p, params);
	}
	
	//for each keypress function on text areas
	this.keypress(function()
	{ 
		total_words=this.value.split(/[\s\.\?]+/).length;
		if(total_words >= p.counterTotal) {
			jQuery('#'+p.counterMinimum).css('color','green');
			//return false;
		}
		jQuery('#'+p.counterElement).html(total_words);
	});

};