var maxQuestionLength = 500;
var preText = "";
setInterval("countBytes()", 500);
function countBytes() {
	var question;
	if (document.all)
		question = document.all('question');
	else if (document.getElementById)
		question = document.getElementById('question');

	var str = "";
	if (question) { 
		if (question.value) 
			str = question.value;
	}
	if (str == preText)
		return false;
	else
		preText = str;
	
	var bytes = 0;
	for (var i=0; i<str.length; i++) {
		if (str.charCodeAt(i) <= 255)
			bytes += 1;
		else
			bytes += 3;
	}
	var cc;
	if (document.all)
		cc = document.all('question_count');
	else if (document.getElementById)
		cc = document.getElementById('question_count');
	
	var textLength	 = Math.ceil(bytes/3);
	var text = textLength +"/"+ maxQuestionLength;
	
	if (textLength>maxQuestionLength)
		cc.style.color = "red";
	else
		cc.style.color = "";
	
	cc.innerHTML = text;
}