/***********************************************
* Email Validation script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i



function validateMailForm(theForm) {
	var valid;
	valid = true;
	var themessage =  "The following are Mandatory fields\n"

	//TEXT
	if( theForm.email_contact != undefined ){
		if( theForm.email_contact.value.length < 1){
			themessage = themessage + " - Name\n";
			valid = false;
		}
	}else{
		themessage = themessage = themessage + " - Name\n";
		valid = false;
	}

	if( theForm.email_sender != undefined ){
		if( theForm.email_sender.value.length < 1){
			themessage = themessage + " - Email\n";
			valid = false;
		}else{
			if ( !checkmail(theForm.email_sender.value ) ){
				themessage = themessage + " - Please provide a valid email address\n";
				valid = false;
			}
		}
	}else{
		themessage = themessage = themessage + " - Email\n";
		valid = false;
	}


	if( theForm.email_content != undefined ){
		if( theForm.email_content.value.length < 1){
			themessage = themessage + " - Message\n";
			valid = false;
		}
	}else{
		themessage = themessage + " - Message\n";
		valid = false;
	}




	if ( valid ) {
		theForm.submit();

	} else {
		alert(themessage);
	}
}



function checkmail(e){
	var returnval=emailfilter.test(e)
	return returnval
}

