function contact_form_check() {
	var error = false;
	var errorlist = "";

	// validate text - name
	// remove any leading spaces.
	var strText = document.getElementById('name').value;
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);
	document.getElementById('name').value = strText;
	if (document.getElementById('name').value.length == 0) {
		if (errorlist == "") {
			errorlist = "Name is missing";
		}
		else {
			errorlist = errorlist + ",\nName is missing";
		}
		error = true;
	}
	
	// validate text - email
	// remove any leading spaces.
	var strText = document.getElementById('email').value;
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);
	document.getElementById('email').value = strText;
	if (document.getElementById('email').value.length == 0) {
		if (errorlist == "") {
			errorlist = "E-mail is missing";
		}
		else {
			errorlist = errorlist + ",\nE-mail is missing";
		}
		error = true;
	}
	
	// validate text - phone
	// remove any leading spaces.
	var strText = document.getElementById('phone').value;
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);
	document.getElementById('phone').value = strText;
	if (document.getElementById('phone').value.length == 0) {
		if (errorlist == "") {
			errorlist = "Phone Number is missing";
		}
		else {
			errorlist = errorlist + ",\nPhone Number is missing";
		}
		error = true;
	}
	
	// validate select list - contact_selection
	var sChecked = false;
	var sLen = document.getElementById('contact_selection').length;
	for(i = 0; i < sLen; i++) {
		if(document.getElementById('contact_selection').options[i].selected && i>0) {
			sChecked = true;
		}
	}
	if (!sChecked) {
		if (errorlist == "") {
			errorlist = "You haven't selected how we can help";
		}
		else {
			errorlist = errorlist + ",\nYou haven't selected how we can help";
		}
		error = true;
	}

	// validate text - msg
	// remove any leading spaces.
	var strText = document.getElementById('msg').value;
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);
	document.getElementById('msg').value = strText;
	if (document.getElementById('msg').value.length == 0) {
		if (errorlist == "") {
			errorlist = "Message is missing";
		}
		else {
			errorlist = errorlist + ",\nMessage is missing";
		}
		error = true;
	}

	if (error) {
		alert("ERROR:\n"+errorlist);
		return false;
	}
	else {
		return true;
	}
}

function validateEmail(theItem) {
	var string = document.getElementById(theItem).value;
	if (string.length > 0) {
	    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	        return true;
	    else {
			alert("Email address is not valid.");
			setTimeout("document.getElementById('"+theItem+"').focus()",0);
			document.getElementById(theItem).select();
	        return false;
		}
	}
}
