var url_pre = "http://" + document.domain + "/";

function submitContact() {
			val1 = document.getElementById("form_name");
			val2 = document.getElementById("form_email");
			val4 = document.getElementById("form_message");
			
			if ( IsEmpty( val1 ) || IsEmpty( val2 ) || IsEmpty( val4 ) ) {
				alert( "Please provide information in every field." );
				return false;
			}
			if ( !isValidEmail( val2.value ) ) {
				alert( "The email address is not valid. Please enter a valid email address." );
				val2.focus();
				return false;
			}
			
			var myRequest = new Request( { 
				method: 'get', 
				
				url: url_pre + 'send.php',
				
				onSuccess: function ( txt ) {
					$( 'sent_response' ).set( 'html', txt);
				}
			}).send( 'Name=' + val1.value + '&Email=' + val2.value + '&Message=' + val4.value );
}

function IsEmpty(aTextField) {
   if ((aTextField.value.length==0) ||
   (aTextField.value==null)) {
      return true;
   }
   else { return false; }
}

function IsEmpty_str(aTextField) {
   if ((aTextField.length==0) ||
   (aTextField==null)) {
      return true;
   }
   else { return false; }
}


function isValidEmail( emailValue ) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var address = emailValue;
	if(reg.test(address) == false) {
	  return false;
	}
	return true;
}