/* submitForm.js */
/* Validates abstracts form before submitting */
/* Creation date: 7/14/09 */

/* Implementation  */


function submitForm(abstracts){

	if (abstracts.abstract.value == ""){
		alert("Please enter your abstract")
		abstracts.abstract.focus()
		abstracts.abstract.select()
		return false
	}
	
	if (!abstracts.presentationtype[0].checked && !abstracts.presentationtype[1].checked){ 	
		alert("Please indicate the type of presentation you are submitting")
		return false
	}
		
	if (abstracts.first.value == ""){
		alert("Please enter your first name")
		abstracts.first.focus()
		abstracts.first.select()
		return false
	}
	
	if (abstracts.last.value == ""){
		alert("Please enter your last name")
		abstracts.last.focus()
		abstracts.last.select()
		return false
	}
	
	if (abstracts.organization.value == ""){
		alert("Please enter your Organization name")
		abstracts.organization.focus()
		abstracts.organization.select()
		return false
	}
	
	emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
	if (!emailRe.test(abstracts.email.value)){
		alert("Please enter a valid e-mail address")
		abstracts.email.focus()
		abstracts.email.select()
		return false
	}	
		
	phoneRe = /^\(?(\d{3})\)?[\.\-\/ ]?(\d{3})[\.\-\/ ]?(\d{4})$/
	
	if (!phoneRe.test(abstracts.phone.value)){
		alert("Please enter a valid phone number with the area code")
		abstracts.phone.focus()
		abstracts.phone.select()
		return false
	}
	else{
		validPhone = phoneRe.exec(abstracts.phone.value)
		abstracts.phone.value = "(" + validPhone[1] + ") " + validPhone[2] + "-" + validPhone[3]
	}
	
	if (!abstracts.digitalsig.checked){
		alert("Your abstract cannot be submitted without the consent of the author. Please obtain the author's consent and resubmit the abstract at that time.")
		return false
	}
	
	if (abstracts.recaptcha_challenge_field.value == ""){
		alert("Please type the two words into the captcha. Doing so helps us prevent automated spam from abusing the form. Thanks! ")
		abstracts.recaptcha_challenge_field.focus()
		abstracts.recaptcha_challenge_field.select()
		return false
	}
	
	
			
	return true
}


function submitForm2(nominations){

	if (nominations.nominee_name.value == ""){
		alert("Please enter the name of the nominee")
		nominations.nominee_name.focus()
		nominations.nominee_name.select()
		return false
	}
			
	if (nominations.nomination_reason.value == ""){
		alert("Please enter the reason for the nomination")
		nominations.nomination_reason.focus()
		nominations.nomination_reason.select()
		return false
	}
	
	if (nominations.realname.value == ""){
		alert("Please enter your full name")
		nominations.realname.focus()
		nominations.realname.select()
		return false
	}
	
	emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
	if (!emailRe.test(nominations.email.value)){
		alert("Please enter a valid e-mail address")
		nominations.email.focus()
		nominations.email.select()
		return false
	}
	
	if (nominations.address.value == ""){
		alert("Please enter your street address")
		nominations.address.focus()
		nominations.address.select()
		return false
	}
	
	if (nominations.city.value == ""){
		alert("Please enter your city")
		nominations.city.focus()
		nominations.city.select()
		return false
	}
		
	zipRe = /^\d{5}/
	
	if (!zipRe.test(nominations.zip.value)){
		alert("Please enter a valid zip code")
		nominations.zip.focus()
		nominations.zip.select()
		return false
	}
				
	return true
}
