function checkContactUsForm(frm){
	var errorMessage = '';
	var allisgood = true;
	if( !isSet(frm.elements['fname'].value) ){
		errorMessage += 'You must fill out your first name.<br/>';
		allisgood = false;
	}
	
	if( !isSet(frm.elements['lname'].value) ){
		errorMessage += 'You must fill out your last name.<br/>';
		allisgood = false;
	}
	
	if( !isPhoneNumber( frm.elements['phone'].value ) ){
		errorMessage += 'You must fill out your phone number.<br/>';
		allisgood = false;
	}

	if( !isSet(frm.elements['message'].value) || frm.elements['message'].value.length < 10){
		errorMessage += 'You must fill out a message describing your situation<br/>';
		allisgood = false;
	}
	
	var element = null;
	
	if(!frm.elements['hash']){
		element = document.createElement('INPUT');
		element.name = 'hash';
		element.setAttribute('type','hidden');
		frm.appendChild(element);
	}else{
		element = frm.elements['hash'];
	}
	
	var hashed = buildHash();
	element.value = hashed;
	
	
	if(!allisgood){
		document.getElementById('mailFormFeedback').innerHTML = errorMessage;
		document.getElementById('mailFormFeedback').style.display = 'block';
		return false;
	}
	return true;
}

function isSet(variable){
	if(variable == '' || variable == null){
		return false;
	}
	return true;
}


/******************************************
isPhoneNumber(num);
	send a phone number string and it will check if it is a real phone number.
	
	it iwll take 801 804 8654 or 801-845-5614 (it actually strips the spaces so if they put spaces in it doesn't matter.)
	
	returns true if it appears to be a valid number and false if not.

******************************************/
function isPhoneNumber(num){
	num = stripSpaces(num);
	var reg = /\(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}/;
	is = reg.test(num);
	return is;
}


/******************************************
stripSpaces(str);
	send a string takes out all of the spaces.   
	
	returns new string with no spaces in it.

******************************************/
function stripSpaces(str){
		regex = /\s/g;
		newstr = str.replace(regex,'');
		return newstr;
}

function buildHash(){
	var str = 'blah';
	mydate = new Date();
	var dateString = mydate.toString();
	return str + stripSpaces(dateString);
}