

function checkSnapshotForm(snapshot_form) {
	var why = "";
	why += checkField(document.forms.snapshot_form.fname.value, 'first name');
	why += checkField(document.forms.snapshot_form.lname.value, 'last name');
	why += checkField(document.forms.snapshot_form.address.value, 'address');
	why += checkField(document.forms.snapshot_form.city.value, 'city');
	why += checkField(document.forms.snapshot_form.state.value, 'state');
	why += checkField(document.forms.snapshot_form.zip.value, 'zip');
	why += checkField(document.forms.snapshot_form.b_country.value, 'country');
	why += checkField(document.forms.snapshot_form.phone.value, 'phone');
	why += checkEmail(document.forms.snapshot_form.email.value);
	why += checkPhoto(document.forms.snapshot_form.photo_file.value, 'photo');
	why += checkField(document.forms.snapshot_form.persons_in_photo.value, 'person in photo.');
	
	
	if (why != "") {
	   alert(why);
	   return false;
	}else{
		return true;
	}
}

function checkField (strng, field_name) {
	var error = "";
	if (strng == "") {
		error = "Please enter your "+field_name+'.\n';
	}
	if (strng == " ") {
		error = "Please enter your "+field_name+'.\n';
	}
	return error; 
}

function checkPhoto (strng, field_name) {
	var error = "";
	if (strng == "") {
		error = "Please choose a photo to upload.\n";
	}
	if (strng == " ") {
		error = "Please choose a photo to upload.\n";
	}
	return error; 
}

function checkEmail (strng) {
	var error="";
	if (strng == "") {
	   error = "You didn't enter an email address.\n";
	}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}

function checkComments(strng) {
	//alert(strng);
	var error = "";
	if (strng == "") {
		error = "Please enter your comment or question.\n";
	}
	if (strng == " ") {
		error = "Please enter your comment or question.\n";
	}
	return error;
	
}

function checkName(strng) {
	//alert(strng);
	var error = "";
	if (strng == "") {
		error = "Please enter your name.\n";
	}
	if (strng == " ") {
		error = "Please enter your name.\n";
	}
	return error;
	
}