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 validar_formulario_contacto (form) {
	var texto;
	texto = '';
	if (form.nombre.value.length < 1) {
		texto += "<br />- The name can't be empty";
	}
	if (form.email.value.indexOf('@', 0)==-1 || form.email.value.indexOf('.', 0)==-1) {
		texto += '<br />- The email is incorrect';
	}
	if (texto.length > 0) {
		document.getElementById('errores').style.visibility = 'visible';
		document.getElementById('errores').innerHTML = '<img src="../images/error-trans.png" alt="Error" /> &nbsp; There are some errors:'+texto;
	}
	else {
		document.getElementById('errores').style.visibility = 'hidden';
		var valorpost = "nombre=" + form.nombre.value + "&email=" + form.email.value + "&texto=" + form.texto.value;
		//instanciamos el objetoAjax
		ajax=objetoAjax();
		//uso del medotod GET
		//indicamos el archivo que se cargará
		ajax.open("POST", "contacto.php");
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				//mostrar resultados en esta capa
				document.getElementById('form_contacto').innerHTML = ajax.responseText;
			}
		}
		//como hacemos uso del metodo POST mandamos la variable
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send(valorpost)
	}
}