/**
 * Comment Form
 * Adam Shannon
 * 07/30/2009
 */

// Grab the form
var search_form = document.getElementsByTagName("form")[1];
	search_form.onsubmit = function () {
		// Set some vars
		this.action = "javascript:void(0);";
		var error_element = document.getElementById("errors");
		var all_good = true;
		
		// Validate...
		var fields = [];
			fields[0] = document.getElementById("author");
			fields[1] = document.getElementById("captcha");
			fields[2] = document.getElementById("message");
			
		// Check each field
		var count = fields.length;
			
		for (var n = 0; n < count; n++) {
			if (fields[n].value === '') {
				error_element.innerHTML = "You need to fill in all fields.";
				all_good = false;
			}
		}
		
		// Redirect
		if (all_good === true) {
			this.action = "post.php";
		}
	}