// Email Validation. Written by PerlScriptsJavaScripts.com

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		}	
	} 

	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}

function check_form(f) { // f is the form (passed using the this keyword)
	if(f.qText.value.length < 1){
		alert("You didn't enter any message!");
		f.qText.focus(); // put the prompt in the name field 
		// make sure the form is not submitted
		return false;
	}
	if(f.qEmail.value.length < 1){
		alert("Please provide your email address.");
		f.qEmail.focus(); // put the prompt in the name field 
		// make sure the form is not submitted
		return false;
	}
	// check the first email address ( the exclamation means "not" )
	if(!check_email(f.qEmail.value)){
		alert("That is an invalid email address.");
		f.qEmail.focus(); 
		// make sure the form is not submitted
		return false;
	}
}

