// JavaScript Document
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!="ndefined") {
			xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}
function suxestions(){
	var nomeQuen=document.FormSuxest.nome.value;
	var telefono=document.FormSuxest.telefono.value;
	var correoQuen=document.FormSuxest.correo.value;
	var que=document.FormSuxest.content.value;
	var aQuen=document.FormSuxest.destinatario.value;
	var aviso=document.FormSuxest.aviso.checked;
	if(nomeQuen=="" || telefono=="" || que=="" || aQuen=="")
	{
		alert("Os campos marcados con asterisco son obrigatorios");
	}
	else
	{
		if(aviso==false)
		{
			alert("Debe seleccionar o aviso legal");
		}
		else
		{
			var parametros="nomeQuen="+nomeQuen+"&correoQuen="+correoQuen+"&que="+que+"&aQuen="+aQuen+"&telefono="+telefono;
			  ajax=objetoAjax();
			  ajax.open("POST","ajax/suxestions.php?"+parametros,true);
			  ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					if(ajax.responseText==1)
					{
						alert("correo enviado satisfactoriamente");
						document.location.reload();
					}
					else alert("non se pudo enviar, intenteo máis tarde");
				}
			  }
			  ajax.send(false);
		}
	}
}