function IsEmpty(s) {
   if ((s.length==0) || (s==null)) {
      return true;
   }
   else { return false; }
}	

function IsEmail(s){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(s))
		testresults=true
	else{
		testresults=false
	}
	return (testresults)
}

function submitEmail(email, name, message) {
	if (!IsEmpty(email) && !IsEmpty(name) && !IsEmpty(message)) {
		if (IsEmail(email)) {
			$('btn_email').innerHTML = 'Sending...';
			var myAjax = new Ajax.Request('/send.php', {method: 'post', parameters: $('frm_email').serialize(), onComplete: function(transport) {
			  	$('frm_email').insert({ 'after' : '<h4>Thanks!</h4><p>We\'ll get back to you as soon as possible. Thanks for your interest in MetroGuild.</p><p>Metroguild will never share your personal information, send you unsolicited mail or make unsolicited phone calls.</p>' });
				$('frm_email').remove();
			}});
			_mw._trackAction('3', email +'|'+ message + '|' + name);
		} else {
			alert("That doesn't seem to be a valid email address, please check it and click on Send again.");
		}
	} else {
		alert("Please fill out all the fields and click on Send again.");
	}
}