function validate_reply(form) {
	var comment = form.comment.value;
	
	if(comment == "") {
		validation_error('comment', 'You can\'t reply without anything to say!');
		return false;
	}
	
	if(comment.length < 3) {
		validation_error('comment', 'That can\'t be all you have to say... can you add some more detail?');
		return false;
	}
	
	if(comment.length > 65535) {
		validation_error('comment', 'Unfortunately, your post is too long!');
		return false;
	}
	
	return true;
}

function validate_post(form) {
	var subject = form.subject.value;
	var comment = form.comment.value;
	var tag1 = form.tag1.value;
	var tag2 = form.tag2.value;
	var tag3 = form.tag3.value;
	var tag4 = form.tag4.value;
	
	if(subject == "") {
		validation_error('subject', 'Give your post a subject to help others find it.');
		return false;
	}
	
	if(subject.length < 15) {
		validation_error('subject', 'That subject is a little too short to be useful. Can you add some more detail?');
		return false;
	}
	
	if(subject.length > 63) {
		validation_error('subject', 'Unfortunately, your subject is too long!');
		return false;
	}
	
	if(comment == "") {
		validation_error('comment', 'You can\'t post without anything to say!');
		return false;
	}
	
	if(comment.length < 3) {
		validation_error('comment', 'That can\'t be all you have to say... can you add some more detail?');
		return false;
	}
	
	if(comment.length > 65535) {
		validation_error('comment', 'Unfortunately, your post is too long!');
		return false;
	}
	
	if(tag1.length == "" && tag2.length == "" && tag3.length == "" && tag4.length == "") {
		validation_error('tag1', 'At least one tagg is required. A tagg is a relevant keyword or term to help others find your post.');
		return false;
	}
	
	if(tag1.length != "" && tag1.length > 40) {
		validation_error('tag1', 'Taggs must be less than 40 characters in length.');
		return false;
	}
	
	if(tag2.length != "" && tag2.length > 40) {
		validation_error('tag2', 'Taggs must be less than 40 characters in length.');
		return false;
	}
	
	if(tag3.length != "" && tag3.length > 40) {
		validation_error('tag3', 'Taggs must be less than 40 characters in length.');
		return false;
	}
	
	if(tag4.length != "" && tag4.length > 40) {
		validation_error('tag3', 'Taggs must be less than 40 characters in length.');
		return false;
	}
	
	return true;
}

function validation_error(targetId, message) {
	var target = document.getElementById(targetId);
	var originalClass = target.className;
	
	//Highlight the target
	target.className += target.className ? ' invalid' : 'invalid';
	
	//Show alert message
	alert(message);
	
	//Remove highlighting on target
	target.className = originalClass;
	
	//Bring focus to the target
	target.focus();
}
