/**
 * Counts and limits the number of words in the given field to the
 * specified word limit.
 *
 * @author Madhavan Lakshminarayanan
 */
function countWords1(field, word_limit, display_field) {
	var str = field.value,
		len = str.length,
		words = 0;

	// Skip leading spaces
	i=0;
	while (str.charCodeAt(i) <= 0x20) i++;
	
	// Count the number of words
	for (;i<len;i++) {
		if (str.charCodeAt(i) <= 0x20 && str.charCodeAt(i+1) > 0x20) words++;
		if (words >= word_limit) break;
	}

	// Truncate the text at the word limit	
	if (words >= word_limit) field.value = str.substring(0, i);

	// Update the word count in the display
	words = word_limit - words;
	document.getElementById(display_field).innerHTML = "<strong>Word count:</strong> You have <strong>" + words  + "</strong> " + ((words == 1) ? "word" : "words") + " left";
}
function countWords(field, char_limit, display_field) {
	var str = field.value,
	len = str.length,
	chars = 0;
	
	if (len > char_limit) 
	{
		field.value = str.substring(0, char_limit);
		str = field.value,
		len = str.length;
	}
	
	// Update the word count in the display
	chars = char_limit - len;
	document.getElementById(display_field).innerHTML = "<strong>Characters count:</strong> You have <strong>" + chars  + "</strong> " + ((chars == 1) ? "Character" : "Characters") + " left.";
}

IEFlicker();

function IEFlicker(){
 try
 {
    document.execCommand("BackgroundImageCache", false, true);
 }
 catch(err) {
 }
}