function nuevoAjax()
{
	var xmlhttp=false;
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	  xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function enviarMail()
{
	c = document.getElementById('resultado_mensaje');
	
	//variable=documenet.nombre_del_form.nombre_del_control.value
	url=document.enviar_email.url.value;
	emailorigen=document.enviar_email.emailorigen.value;
	emailamigo=document.enviar_email.emailamigo.value;
	nombreamigo=document.enviar_email.nombreamigo.value;
	nombreorigen=document.enviar_email.nombreorigen.value;
	
	ajax=nuevoAjax();
	c.innerHTML = '<p style="text-align:center;"><img src="recommend/loading.gif"/></p>'; 
	ajax.open("POST", "recommend/envia_mail.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			c.innerHTML = ajax.responseText
		}
		borrarCampos()
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("emailamigo="+emailamigo+"&nombreamigo="+nombreamigo+"&emailorigen="+emailorigen+"&nombreorigen="+nombreorigen+"&url="+url)
}

function borrarCampos(){
	document.enviar_email.emailamigo.focus();
}