// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Alternate Form Validation
// Use it like this: <form action="/web/contact/" method="post" onsubmit="return formCheck(this);">

function formCheck(formobj)
	{
	// 1) enter names of mandatory fields
	var fieldRequired = Array('fullname', 'email', 'telephone', 'subject', 'comments');

	// 2) enter descripts to appear in the alert box
	var fieldDescription = Array('Your name', 'Your email address', 'Your telephone number', 'The subject of the message', 'Your comments');

	// 3) enter alert box message
	var alertMsg = "Sorry about this, but you can't submit the form until ALL the compulsory fields have been filled out.\n";
	alertMsg += '____________________________________________________\n\n'
	alertMsg += "Please complete the following fields, then press 'Submit' again:\n\n";

	// set this count var to see if any blank fields were found
	var c = 0;

	for (var i = 0; i < fieldRequired.length; i++)
		{
		var obj = formobj.elements[fieldRequired[i]];
		document.getElementById(fieldRequired[i]).style.backgroundColor = '#' + 'ffffff';
		if (obj)
			{
			switch(obj.type)
				{
				case 'text':
				case 'textarea':
				if (obj.value == '' || obj.value == null)
					{
					alertMsg += ' - ' + fieldDescription[i] + '\n';
					document.getElementById(fieldRequired[i]).style.backgroundColor = '#' + 'fc0000';
					c++;
					}
				break;
				}
			}
		}
	
	alertMsg += '\nThese fields have been highlighted for your attention.';

	// if no blank fields were found, alter the submit button text and submit
	if (c == 0)
		{
		document.getElementById('submit').value = 'submitting...';
		return true;
		}
	
	// if blank fields were still found show alert box and deny submission
	else
		{
		alert(alertMsg);
		c = 0;
		return false;
		}
	}