function CountWords (content, show_word_count, show_char_count, totalCount) {

	if (show_word_count == null) {
		show_word_count = true;
	}
	if (show_char_count == null) {
		show_char_count = false;
	}

	var temp = content.replace(/(<([^>]+)>)/ig," ");
	var input_str = temp.replace(/&nbsp;/g , " ");
	var char_count = input_str.length;
	var fullStr = input_str + " ";
 	var w = input_str.split(/\s+/); 
	
	var word_count = 0 ;
	for ( z=0 ; z<w.length ; z++ ) {
		if ( w[z] != "" ) {
			word_count ++ ;
		} 
	}

//	var word_count = (w != "") ? w.length - 1 : 0;	
	
	if (fullStr.length <2) {
		word_count = 0;
	}
	if (word_count == 1) {
		wordOrWords = " word";
	} else {
		wordOrWords = " words";
	}
	if (char_count == 1) {
		charOrChars = " character";
	} else {
		charOrChars = " characters";
	}
	
	if (show_word_count & show_char_count) {
		var countLeft = totalCount - word_count ;
		if ( countLeft > 0 ) {
			alert ("Word Count:\n" + "    " + 
					word_count + wordOrWords + "\n" + "    " + 
					char_count + charOrChars + "\n" + "    " +
					"You can add up to another " +(countLeft)+ " words." ) ;
		} else {
			alert ("Word Count:\n" + "    " + 
					word_count + wordOrWords + "\n" + "    " + 
					char_count + charOrChars + "\n" + "    " ) ;
		}
	} else {
		if (show_word_count) {
			alert ("Word Count:  " + word_count + wordOrWords);
		} else {
			if (show_char_count) {
				alert ("Character Count:  " + char_count + charOrChars);
      		}
   		}
	}
	return word_count;
}
