/* Dori's original form very functions. */

function validEmail(email) {
		invalidChars = " /:,;"
		
		if (email == "")  // cannot be empty
 return false
 
		for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
 badChar = invalidChars.charAt(i)
 if (email.indexOf(badChar,0) > -1)
 	return false
		}
		
		atPos = email.indexOf("@",1) // there must be one "@" symbol
		if (atPos == -1) 
 return false
 
		if (email.indexOf("@",atPos+1) != -1)	// and only one "@" symbol
 return false
 
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1)  		// and at least one "." after the "@"
 return false
 
		if (periodPos+3 > email.length) // and at least 2 characters after the "."
 return false

		return true
	}
	
 
	function submitIt(mailForm) {
		// check to see if the email's valid
		if (!validEmail(mailForm.email.value)) {
 alert("Invalid email address")
 mailForm.email.focus()
 mailForm.email.select()
 return false
		}
		
		// They had to enter a name
		if (mailForm.realname.value == "") {
 alert("You must enter a name")
 mailForm.realname.focus()
 mailForm.realname.select()
 return false
		}
		
		// No dreamscape users
		/* if (mailForm.email.value.indexOf("@dreamscape.com",1) > -1) {
 alert("Dreamscape does not allow their members to subscribe to this list--please contact them for more info (they don't respond to our mail). If you write to us, please use a non-Dreamscape account if you wish a reply.")
 return false
		}  */
		// Warn AOL and Yahoo mail users
		/*  if (mailForm.email.value.indexOf("@aol.com",1) > -1 || mailForm.email.value.indexOf("@yahoo.com",1) > -1) {
 alert("Please be aware that you are subscribing from a domain that does not properly support mailing lists. Your subscription will be accepted, but the chances are good you'll never see any mail.")
		} */ 
		
		// If we made it to here, everything's valid, so return true
		return true
	}

/* Other ones */

function fillin() {
if (document.forms[0].sender_name.value !="") {
for (i=1;i< document.forms.length;i++) {
   for (j=0; j< document.forms[i].elements.length;j++) {
    if (document.forms[i].elements[j].name == "sender_name") {
document.forms[i].sender_name.value = document.forms[0].sender_name.value;}
    if (document.forms[i].elements[j].name == "sender_email") {
document.forms[i].sender_email.value = document.forms[0].sender_email.value;}
}
}
}
}

function emailname(survey) {
		// check to see if the email's valid
		if (!validEmail(survey.email.value)) {
 alert("Invalid email address")
 survey.email.focus()
 survey.email.select()
 return false
		}
		
		// They had to enter a name
		if (survey.realname.value == "") {
 alert("You must enter a name")
 survey.realname.focus()
 survey.realname.select()
 return false
		}
		
		
		// If we made it to here, everything's valid, so return true
		return true
 }  














