
function checkInfoForm() {
	fm = document.forms['clearlyLasikInfoForm'];
	var missing = "";
	if (fm.firstname.value == "")
		missing += "First name is required.\n";
	if (fm.lastname.value == "")
		missing += "Last name is required.\n";
	if (fm.phone.value == "")
		missing += "Phone number, including area code is required.\n";
	else {
		temp = fm.phone.value + " ";
		if (temp.search(/\d{10}\s{1}/) == 0)
			fm.phone.value = fm.phone.value.substring(0, 3) + "-" + fm.phone.value.substring(3, 6) + "-" + fm.phone.value.substring(6);
		temp = fm.phone.value + " ";							
		if (temp.search(/\d\d\d-\d\d\d-\d\d\d\d+\s{1}/) != 0)
			missing += "Phone must be digits and dashes only in the form 123-456-7890\n";
		
	}
	
	if (fm.email.value == "")
		missing += "E-mail is required.\n";
	else {
		temp = fm.email.value + " ";
		found = temp.search(/[\w\.-]+@([\w-]+\.){1,3}[a-zA-Z]{2,}\s{1}/);
		if (found != 0)
			missing += "E-mail must be in the form username@domain.com\n"
	}
	if (missing != "") {
		alert(missing);
		return false;
	}
	return true;
}


function getURLVar(urlVarName) {
//divide the URL in half at the '?'
var urlHalves = String(document.location).split('?');
var urlVarValue = '';
	if(urlHalves[1]){
		//load all the name/value pairs into an array
		var urlVars = urlHalves[1].split('&');
		//loop over the list, and find the specified url variable
		for(i=0; i<=(urlVars.length); i++){
			if(urlVars[i]){
				//load the name/value pair into an array
				var urlVarPair = urlVars[i].split('=');
				if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
					//I found a variable that matches, load it's value into the return variable
					urlVarValue = urlVarPair[1];
				}
			}
		}
	}
	return urlVarValue;   
}
