// Check if a field has text in it.
function cu_isFilledIn(value) {
	i = document.getElementById(value);
	if (i.value == null || i.value == "") {
		return false;
	}
	return true;
}


// Highlight the field
function cu_highlightField(value) {
	document.getElementById(value).style.border = "solid #ff0000";
}


// Unhighlight fields
function cu_unhighlightField(value) {
	document.getElementById(value).style.border = "";
}


// Check if the required fields are filled out.  If yes, then submit the form.
function cu_submitForm() {
	success = true;
	
	// Unhighlight the fields
	cu_unhighlightField('name');
	cu_unhighlightField('company');
	cu_unhighlightField('phone');
	cu_unhighlightField('email');
	cu_unhighlightField('companytype');
	
	if (!cu_isFilledIn('name')) {
		cu_highlightField('name');
		success = false;
	}
	
	if (!cu_isFilledIn('company')) {
		cu_highlightField('company');
		success = false;
	}
	
	if (!cu_isFilledIn('phone')) {
		cu_highlightField('phone');
		success = false;
	}
	
	if (!cu_isFilledIn('email')) {
		cu_highlightField('email');
		success = false;
	}
	
	if (!cu_isFilledIn('companytype')) {
		cu_highlightField('companytype');
		success = false;
	}
	
	if (!success) {
		document.getElementById('message').innerHTML = "<p style=\"color: #ff0000\">Please fill out all required fields.</p>";
		return false;
	}
	
	document.getElementById('message').innerHTML = "";
	document.forms[0].submit();
	return true;
}