
function sendFriendForm() {
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var errMsg = "";
	
	if (!emailRE.test(document.getElementById('to').value)){
		errMsg = "Please, you must enter a valid e-mail";
		setfocus = "to";
	}	

	if (errMsg != ""){
		alert(errMsg);
		document.getElementById(setfocus).focus();
		return false;
	}
	else {
		new Ajax.Request("sendafriend.php", {
		method: "post",
		postBody: Form.serialize("formsendfriend"),
		onSuccess : function(resp) {
			Effect.Fade('sendafriend_container', { duration: 0.5 });
			Form.reset("formsendfriend");
		},
		onFailure : function(resp) {
			Effect.Fade('sendafriend_container', { duration: 0.5 });
			Form.reset("formsendfriend");
		}
		});
		return false;
	}
}

