function init()
{
	var W3CDOM = (document.createElement && document.getElementsByTagName);

	if(W3CDOM)
	{
		// Watch the form.
		var theForm = document.getElementById('contact_form');
		if(theForm)
		{
			theForm.onsubmit = function() { checkReqFields(theForm); return false; }
		}
	}
}

function checkReqFields(formId)
{
	// Loop through required fields on form submission
	var arrReqFields = new Array('cb_number','cb_name');
	var arrMissingFields = new Array();
	for(var i=0;i<arrReqFields.length;i++)
	{
		var theField = document.getElementById(arrReqFields[i]);
		if(theField)
		{
			if(theField.value == '')
			{arrMissingFields.push(arrReqFields[i]);}
		}
	}
	if(arrMissingFields.length > 0)
	{
		for(var i=0;i<arrMissingFields.length;i++)
		{
			var highlightField = document.getElementById(arrMissingFields[i]);
			if(highlightField)
			{
				highlightField.style.borderColor = "red";
				highlightField.style.borderWidth = "2px";
			}
		}
		alert("Please go back and complete all of the required fields.");
		return false;
	}
	else
	{formId.submit();}
}

window.onload = init;