// Form Validation

function checkForm(){

	var myX = $('employmentForm').cmEmail.value;
	var filter  = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;

	if ($('employmentForm').cmName.value ===""){
		alert("Please provide your name.");
		$('employmentForm').cmName.focus();
		return false;
	}

	if ($('employmentForm').cmName.value !==""){
		var original = $('employmentForm').cmName.value;
		var o_split = original.split(" ");
		//this probably isn't a complete list of words that shouldn't be capitalized
		var special_words = new Array('and', 'the', 'to', 'for', 'is', 'in', 'a', 'at', 'an', 'from', 'by', 'if', 'of');
		for (i=0;i<o_split.length;i++) {
			if (i == 0) {
				//always capitalize the first word
				o_split[i] = (o_split[i].substring(0,1)).toUpperCase() + o_split[i].substring(1);
			}
			else if(special_words.indexOf(o_split[i]) < 0) { 
			  	o_split[i] = (o_split[i].substring(0,1)).toUpperCase() + o_split[i].substring(1);
			}
		}
		retval = o_split.join(' ');
		$('employmentForm').cmName.value = retval;
	}

	if ($('employmentForm').cmEmail.value === ""){
		alert("Please enter your email address.");
		$('employmentForm').cmEmail.focus();
		return false;
	}

	if ($('employmentForm').cmEmail.value !==""){
		if (!filter.test(myX)) {
		alert("Oops, looks like there's a problem with your email address.");
		$('employmentForm').cmEmail.focus();
		return false;
		}
	}

	if ($('employmentForm').cmPosition.value === ""){
		alert("Please make a career selection from the drop-down menu.");
		return false;
	}
	
	return (true);
	
}







