function checkMailForm(theForm){
/* Check that name and telephone fields are completed */
	var err = new Array();
	
	if(theForm['name'].value == '')
		err[err.length] = "Contact Name";
	
	if(theForm['telephone'].value == '')
		err[err.length] = "Telephone Number";	

	if(!servicesSelected(theForm))
		err[err.length] = "Please select at least one service";

	if(!statusSelected(theForm))
		err[err.length] = "Please select a status";
	
	if(err.length > 0) {
		var Msg = "Please complete the following fields:\n\n";
		for(i=0; i<err.length; i++) {
			Msg = Msg + "\t" + err[i] + "\n";
		}
		
		alert(Msg);
	}
	
	return (err.length == 0);
}

function servicesSelected(theForm){
	var ticked = false;
	var max = theForm['services[]'].length;
	var i;

	//Check for max being null: if only one subject then control
	//will be returned as plain rather than an array
	if (max != null) {
		for (i=0; i<max && !ticked; i++){
			ticked = theForm['services[]'][i].checked;
		}
	}
	else {
		ticked = theForm['services[]'].checked;
	}
	
	return ticked;
	
}

function statusSelected(theForm){
	var ticked = false;
	var max = theForm['status[]'].length;
	var i;

	//Check for max being null: if only one subject then control
	//will be returned as plain rather than an array
	if (max != null) {
		for (i=0; i<max && !ticked; i++){
			ticked = theForm['status[]'][i].checked;
		}
	}
	else {
		ticked = theForm['status[]'].checked;
	}
	
	return ticked;
	
}