function CheckEmail(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	var valid = true;
	
	if (str.indexOf(at)==-1){
		valid = false;
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		valid = false;
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		valid = false;
	}
	
	if (str.indexOf(at,(lat+1))!=-1){
		valid = false;
	}
	
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		valid = false;
	}
	
	if (str.indexOf(dot,(lat+2))==-1){
		valid = false;
	}
	
	if (str.indexOf(" ")!=-1){
		valid = false;
	}
	
	return valid;					
}

function ValidateForm() {

	var email = document.contactForm.email;
	
	var errorMsg = "";	
	
	if ((email.value == null) || (email.value == "")) {
		errorMsg += "Please enter your email address.\n";
	} else if (CheckEmail(email.value) == false) {
		errorMsg += "The email address you entered is not valid.\n";
	}
	
	if (errorMsg.length > 0) {
		alert(errorMsg);
		return false;
	} else {
		return true;
	}
	
 }
 
 
function ValidateSubmitForm() {

	var name = document.submitForm.email;
	var email = document.submitForm.email;
	
	var errorMsg = "";
	
	if ((email.value == null) || (email.value == "")) {
		errorMsg += "Please enter your email address.\n";
	} else if (CheckEmail(email.value) == false) {
		errorMsg += "The email address you entered is not valid.\n";
	}
	
	if ((name.value == null) || (name.value == "")) {
		errorMsg += "Please enter your name.\n";
	}
	
	if (errorMsg.length > 0) {
		alert(errorMsg);
		return false;
	} else {
		return true;
	}
	
} 
 
 
function ValidateNewsletter() {

	var emailID = document.newsletterForm.email;
	
	if ((emailID.value == null) || (emailID.value == "")) {
		alert("Please enter your email address!");
		emailID.focus();
		return false;
	}
	if (CheckEmail(emailID.value) == false) {
		emailID.value="";
		emailID.focus();
		return false;
	}
	
	return true;
 }	 