//Desarrollado por Jesus Lin
//webmaster@ribosomatic.com
//ribosomatic.com
//Puedes hacer lo que quieras con el cdigo
//pero visita la web cuando te acuerdes

function objetoAjax(){
	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 enviarDatosMensaje(){
	//donde se mostrar lo resultados
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	rec=document.nuevo_msg.rec.value;
	env=document.nuevo_msg.env.value;
	msj=document.nuevo_msg.mensaje.value;
	asu=document.nuevo_msg.asunto.value;
	
	//instanciamos el objetoAjax
	ajax=objetoAjax();
	//uso del medotod POST
	//archivo que realizar la operacion
	//registro.php
	ajax.open("POST", "http://www.myeart.com/ajax/enviarmensaje.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			divResultado.innerHTML = ajax.responseText
			//llamar a funcion para limpiar los inputs
			LimpiarCampos();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	//enviando los valores
	ajax.send("rec="+rec+"&env="+env+"&asunto="+asu+"&mensaje="+msj)
}

function LimpiarCampos(){
	document.nuevo_msg.rec.value="";
	document.nuevo_msg.env.value="";
	document.nuevo_msg.asu.value="";
	document.nuevo_msg.msj.value="";
	document.nuevo_msg.msj.focus();
}