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
	nomb=document.forma.nombre.value;
	mail=document.forma.email.value;
	tel=document.forma.telefono.value;
	asu=document.forma.asunto.value;
	men=document.forma.mensaje.value;
	dest=document.forma.destinatario.value;
	
	ajax=nuevoAjax();
	c.innerHTML = '<p style="text-align:center;"><img src="esperando.gif"/></p>'; 
	ajax.open("POST", "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("destinatario="+dest+"&nombre="+nomb+"&email="+mail+"&telefono="+tel+"&asunto="+asu+"&mensaje="+men)
	hola()
}

function borrarCampos(){
	document.forma.nombre.value="ANONIMO";
	document.forma.email.value="";
	document.forma.telefono.value="";
	document.forma.asunto.value="Elija una opción";
	document.forma.mensaje.value="";
	//document.forma.nombre.focus();
}

function hola()
{
	document.forma.asunto.value="Elija una opción";
}