// JavaScript Document


function validateEmail(){
var email = document.getElementById('email');
	//make sure the user puts something in the email
	if(email.value == ""){
		alert('Please enter an email address');
		return false;	
	}
	
	//check for illegal characters
	var invalidChars = ' /:,;';
	for(var i=0; i<invalidChars.length; i++){
		var badChar = invalidChars.charAt(i);
		if(email.value.indexOf(badChar) > -1){
		alert('You have entered an invalid character: '+ badChar);
		email.parentNode.className = 'invalid';
		return false;
		}
	}	
	
	//make sure the email address contains @ after the first char
	var atPos = email.value.indexOf('@',1)
	if(atPos == -1){
		alert('Your email address must contain a single @')
		return false;
	}
	
	//make sure there is not an additional @ after the first one
	if(email.value.indexOf('@',atPos+1) != -1){
		alert('Your email address must contain a single @')
		return false;
	}

	//make sure there is a period after the @ symbol
	var periodPos = email.value.indexOf('.',atPos);
	if(periodPos == -1){
		alert('Your email address must contain a period after the @ symbol');
		return false;
	}
	
	//make sure that both fields contain the same address
/*	if(email.value != email2.value){
		alert('The Re-entered email address does not match the original.')
		email2.parentNode.className = 'invalid';
		return false;
	}*/
	return true;
}
