var words;
function count()
{
	words = document.getElementById('content').value.length;	
	var line = 0;
	if (navigator.appName == "Netscape")
		line = document.getElementById('content').value.match(/\n/g);
	else
		line = document.getElementById('content').value.match(/\r\n/g);
	if (line)
		words -= line.length * line[0].length;
	
	document.getElementById('counter').innerHTML = words;	
	if (words > 1000)
		document.getElementById('counter').style.color = "red";
	else
		document.getElementById('counter').style.color = "";
}
setInterval("count()", 500);

function send()
{
    re = /\S/;
	if (!re.test($("#name").val()))
	{
		alert("請填姓名");
		$("#name").focus();
	}
	else if (!re.test($("#content").val()))
	{
		alert("請填內容");
		$("#content").focus();
	}
	else if (words > 1000)
	{
		alert("請將字數限制在1000字內");
		$("#content").focus();
	}
	else if (!re.test($("#code").val()))
	{
		alert("請填驗證碼");
		$("#code").focus();
	}
	else if (confirm("確定送出?"))
	    $("#form1").submit();
}
