var W3CDOM = document.createElement && document.getElementsByTagName;

function init() { // this function is automatically called onload by quirksmode.js
	setMaxLength();
}

function setMaxLength() {
	if (document.formaddcomment) {
		document.formaddcomment.comment.onkeyup = document.formaddcomment.comment.onchange = checkMaxLength;
	}
	if (document.formaddcomment1) {
		document.formaddcomment1.comment.onkeyup = document.formaddcomment1.comment.onchange = checkMaxLength;
	}
	if (document.formaddcomment2) {
		document.formaddcomment2.comment.onkeyup = document.formaddcomment2.comment.onchange = checkMaxLength;
	}
}

function checkMaxLength() {
	var maxLength = 250;
	if (document.formaddcomment) {
		var currentLength = document.formaddcomment.comment.value.length;
		if (currentLength > maxLength && document.formaddcomment) {
			document.formaddcomment.comment.value = document.formaddcomment.comment.value.substr(0, maxLength);
			alert('Comments are restricted to '+maxLength+' characters.');
		}
	}
	if (document.formaddcomment1) {
		var currentLength = document.formaddcomment1.comment.value.length;
		if (currentLength > maxLength && document.formaddcomment1) {
			document.formaddcomment1.comment.value = document.formaddcomment1.comment.value.substr(0, maxLength);
			alert('Comments are restricted to '+maxLength+' characters.');
		}
	}
	if (document.formaddcomment2) {
		var currentLength = document.formaddcomment2.comment.value.length;
		if (currentLength > maxLength && document.formaddcomment2) {
			document.formaddcomment2.comment.value = document.formaddcomment2.comment.value.substr(0, maxLength);
			alert('Comments are restricted to '+maxLength+' characters.');
		}
	}
}
