
// Various onloiad attachments as required

window.onload = function() { 
	attachFormValidation();
}

function attachFormValidation() {
	if (document.getElementById('main-inquiry')) {
		document.getElementById('main-inquiry').onsubmit=function () { return validate_form(this); }
	}
}

// Validate the form

function validate_form(form) {
	var requireds  = new Array('your-name','email','phone');
	var plainNames = new Array('name','email address','contact phone');
	var checkThis=itemName=msg="";

	for (i=0; i<requireds.length; i++) {
		var obj = document.getElementById(requireds[i]);
		itemName =  plainNames[i];
		if (obj.value == '') {
			msg += '\n  Please provide your ' + itemName + ' before submitting this form.';
		}
	}
	if (msg != '') {
		msg = 'Your form contains the following errors:\n'+msg+'\n Please make the necessary corrections and try again.';
		alert(msg);
	}
	else  { 
		//form.submitButton.disabled = true; 
		form.submit();
	}
	return false;
}
