function validar_formulario(type)
{
	switch(type)
	{
		case "contact":
			var NOMBRE=document.getElementById("NOMBRE").value; 
			if(!NOMBRE) { alert("Escribe tu nombre completo!"); document.getElementById('NOMBRE').focus(); return false; }
			var EMAIL=document.getElementById("EMAIL").value; 
			if(!EMAIL) { alert("Escribe un correo electrónico!"); document.getElementById('EMAIL').focus(); return false; }
			else if(!validarEmail(EMAIL)) { alert("El correo electrónico escrito es incorrecto!"); document.getElementById('EMAIL').focus(); return false; }
			var MENSAJE=document.getElementById("MENSAJE").value; 
			if(!MENSAJE) { alert("Escribe un mensaje!"); document.getElementById('MENSAJE').focus(); return false; }
			document.getElementById("BUTTON_CONTACT").value="Espere...enviando";
			document.getElementById("BUTTON_CONTACT").disabled=true;
			load_options('contact_send');
			return false;
		break;
	}
}

function load_options(type)
{
	var archivo_ajax="ajax.php?type="+type;
	switch (type)
	{
		case "contact_send": 
			var valor='1'; 
			var NOMBRE	=document.getElementById("NOMBRE").value;
			var EMAIL	=document.getElementById("EMAIL").value;
			var ASUNTO	=document.getElementById("ASUNTO").value;
			var MENSAJE	=document.getElementById("MENSAJE").value;
		break;
	}
	if(valor) 
	{
		var ajax=funcionnuevoAjax();
		ajax.open("POST", archivo_ajax, true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		switch (type)
		{
			case "contact_send": ajax.send("NOMBRE="+NOMBRE+"&EMAIL="+EMAIL+"&ASUNTO="+ASUNTO+"&MENSAJE="+MENSAJE); break;
		}
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState==1)
			{
				switch (type)
				{
					case "contact_send":
						document.getElementById("BUTTON_CONTACT").value="Espere...enviando";
						document.getElementById("BUTTON_CONTACT").disabled=true;
					break;
				}
			}
			if (ajax.readyState==4)
			{
				//alert(ajax.responseText);
				if(!ajax.responseText) { }
				else 
				{
					switch (type)
					{
						case "contact_send": 		
							var respuesta=new Array(2); respuesta=ajax.responseText.split("*&*"); 
							document.getElementById("FILA_ERROR_EMAIL").innerHTML=respuesta[1]; 		
							document.getElementById("FILA_SEND").innerHTML=respuesta[2]; 		
						break; 
					}
				}
			}
		}
	}
}

