function nuevoAjax()
{ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}
function Limpiar(id)
{
	document.getElementById(id).value="";	
}

function Llenar(id)
{
	variable = "ingrese su email";
	var d = document.getElementById(id).value;	
	if (d=="")
	{
		document.getElementById(id).value=variable+" aquí";
	}
}

function RegistrarBoletin()
{

	var txtEmail = document.getElementById("textfield").value;
	
	var ajax = nuevoAjax();
	ajax.open("post", "ajax/boletin/comprobar_suscripcion.php", true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	var URLparaEnviar = ("txtEmail="+txtEmail);
	ajax.send(URLparaEnviar);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState==4)
		{
			if (ajax.responseText=="duplicado")
				{
					alert("Ya esta Registrado");
				}
			if (ajax.responseText=="registrado")
				{
					alert("Registro Exitoso");
					document.getElementById("txtEmail").value="";							
				}			
		}
	}
	
}