var cdDisablePostForm = 0;
function cdOpenPostBox() {
	document.getElementById('cdPostBoxExpander').style.display = 'block';

	return false;
}

function cdOpenPostBoxStatic() {
	document.getElementById('cdPostBoxExpander').style.display = 'block';
	return false;
}

function cdFocusPostTitle() {
	document.getElementById('cdPostBoxTitleInput').focus();
	return false;
}
function cdClosePostBox() {
	document.getElementById('cdPostBoxExpander').style.display = 'none';
	document.getElementById('cdPostBoxForm').reset();
	cdDisablePostForm = 0;
	return false;
}

function cdPostCancelKey(e) {
	var code;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	if (code == 32) {
		cdClosePostBox();
		return false;
	}
}
function cdCheckPost(form) {
	var sub = '' + form.subject.value;
	if ( (sub == '') || (sub.match(/^\s*$/)) ) {
		alert("The discussion topic is empty. Please add text to it.");
		return false;
	}
	if ( sub.length > 255 ) {
		alert("The discussion topic is "+ (sub.length - 255) +" characters longer than the maximum topic length. Please edit it.");
		return false;
	}

	var body = '' + form.content.value;
	if ( (body == '') || (body.match(/^\s*$/)) ) {
		alert("The post is empty. Please add text to it.");
		return false;
	}
	if ( body.length > 16384 ) {
		alert("The post is "+ (body.length - 16384) +" characters longer than the maximum post length. Please edit it.");
		return false;
	}
	if ( cdDisablePostForm++ ) {
		return false;
	}

	return true;
}