// JavaScript Document
function getXMLHTTPRequest()
	{
	try { req = new XMLHttpRequest(); }
	catch(err1)
		{
		try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (err2)
			{
			try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (err3) { req = false; }
			}
		}
	return req;
	}

var http = getXMLHTTPRequest();



function enviar_correo()
	{
	var nombre = document.forma.name.value;
	if(nombre==""){alert("Para poder enviar sus comentarios deber\u00e1 escribir su nombre"); document.forma.name.focus();return false;}
	var correo = document.forma.email.value;
	if(correo==""){alert("Para poder enviar sus comentarios deber\u00e1 escribir su email"); document.forma.email.focus();return false;}
	var url = document.forma.url.value;
	var comments = document.forma.comments.value;
	var miran=parseInt(Math.random()*99999999);	
	var candado = 1; //enviar correo
	var url = "contacto_ajax.php?candado=" + candado+ "&nombre=" + nombre+ "&correo=" + correo+ "&url=" + url+ "&comments=" + comments;
	http.open("GET", url+ "&rand=" + miran, true);
	http.onreadystatechange = res_enviarcorreo;
	http.send(null);
	}
	
function res_enviarcorreo() 
	{
	if(http.readyState == 4) 
		{
		if(http.status == 200) 
			{
			var respuesta = http.responseText;
			if(respuesta == 1)
				{
				alert('Sus comentarios fueron enviados correctamente');
				document.forma.reset();
				}
			else
				{
				alert("Ocurrio un problema, intentelo de nuevo");	
				}
			}
		else { alert("Ha ocurrido un error: " + http.statusText); }
    	}
	}