// *** This is used to validate the tell a friend form:

function validate () {
	if ( ! checkFromField() ) return false;
	if ( ! checkToField()   ) return false;
	return true;
}
	

function checkFromField() {
	
	if(-1 == document.tellfriend.from.value.indexOf("@")) { 
		document.tellfriend.from.focus(); 
		alert("Your email address must have a '@'."); 
		return false; 
	}

	if(-1 != document.tellfriend.from.value.indexOf(",")) { 
		document.tellfriend.from.focus(); 
		alert("Your email address must not have a ',' in it"); 
		return false; 
	}

	if(-1 != document.tellfriend.from.value.indexOf("#")) { 
		document.tellfriend.from.focus(); 
		alert("Your email address must not have an '#' in it." ); 
		return false; 
	}

	if(-1 != document.tellfriend.from.value.indexOf("!")) { 
		document.tellfriend.from.focus(); 
		alert("Your email address must not have a '!' in it." ); 
		return false; 
	}

	if(-1 != document.tellfriend.from.value.indexOf(" ")) { 
		document.tellfriend.from.focus(); 
		alert("Your email address must not have a space in it." ); 
		return false; 
	}

	if(document.tellfriend.from.value.length == (document.tellfriend.from.value.indexOf("@")+1) ) {
		document.tellfriend.from.focus();
		alert("Your email address must have a domain name after the '@'.");
		return false;
	}

	if(document.tellfriend.from.value.length == 0) { 
		document.tellfriend.from.focus(); 
		alert("Please enter your email address."); 
		return false; 
	}

	return true;
}










function checkToField() {

	if(-1 == document.tellfriend.to.value.indexOf("@")) { 
		document.tellfriend.to.focus(); 
		alert("Your friend's email address must have a '@'."); 
		return false; 
	}

	if(-1 != document.tellfriend.to.value.indexOf(",")) { 
		document.tellfriend.to.focus(); 
		alert("Your friend's email address must not have a ',' in it"); 
		return false; 
	}

	if(-1 != document.tellfriend.to.value.indexOf("#")) { 
		document.tellfriend.to.focus(); 
		alert("Your friend's email address must not have an '#' in it." ); 
		return false; 
	}

	if(-1 != document.tellfriend.to.value.indexOf("!")) { 
		document.tellfriend.to.focus(); 
		alert("Your friend's email address must not have a '!' in it." ); 
		return false; 
	}

	if(-1 != document.tellfriend.to.value.indexOf(" ")) { 
		document.tellfriend.to.focus(); 
		alert("Your friend's email address must not have a space in it." ); 
		return false; 
	}

	if(document.tellfriend.to.value.length == (document.tellfriend.to.value.indexOf("@")+1) ) {
		document.tellfriend.to.focus();
		alert("Your friend's email address must have a domain name after the '@'.");
		return false;
	}

	if(document.tellfriend.to.value.length == 0) { 
		document.tellfriend.to.focus(); 
		alert("Please enter your friend's email address."); 
		return false; 
	}

	return true;
}





