// JavaScript Document
function ajaxFunction() {
var xmlHttp;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
return xmlHttp;
} catch (e) {
// Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
return xmlHttp;
} catch (e) {
try {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
return xmlHttp;
} catch (e) {
alert("Tu navegador no soporta AJAX!");
return false;
}}}
}



function MenuPage(pagina, capa) {

document.getElementById('loading').innerHTML = '<img src="images/loading.gif" /> Cargando...';
var httpb;
httpb = ajaxFunction();

httpb.open("get", "php/contenido.php?pagina="+pagina, true);
httpb.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

httpb.onreadystatechange=function() {

if (httpb.readyState != 4)
{
	document.getElementById('loading').innerHTML = '<img src="images/loading.gif" /> Cargando...';
}
else
{
	if(httpb.status==200){
		document.getElementById('contenidoajax').innerHTML = httpb.responseText;
		document.getElementById('loading').innerHTML = '';	
		
	}
	else
	{
		
		document.getElementById('loading').innerHTML = '<img src="loading.gif" /> Cargando...';	
	}
	
}

}
httpb.send(null);

}



function MenuPageb(pagina, capa) {

document.getElementById('loading').innerHTML = '';
document.getElementById('loadingb').innerHTML = '<img src="images/loading.gif" /> Cargando...';
var httpc;
httpc = ajaxFunction();

httpc.open("get", "php/contenido.php?pagina="+pagina, true);
httpc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

httpc.onreadystatechange=function() {

if (httpc.readyState != 4)
{
	document.getElementById('loading').innerHTML = '<img src="images/loading.gif" /> Cargando...';
	document.getElementById('loading').innerHTML = '';
}
else
{
	if(httpc.status==200){
		document.getElementById('contenidoajax').innerHTML = httpc.responseText;
		document.getElementById('loadingb').innerHTML = '';	
		document.getElementById('loading').innerHTML = '';
	}
	else
	{
		
		document.getElementById('loadingb').innerHTML = '<img src="loading.gif" /> Cargando...';
		document.getElementById('loading').innerHTML = '';
	}
	
}

}
httpc.send(null);

}


function Enviar(pagina) {
	
	
var name = document.consulta.name.value;
var email = document.consulta.email.value;
var message = document.consulta.message.value;

if (name != '' && email != '' && message != '')
{
	document.getElementById('error1').style.display = 'none'; 
	document.getElementById('error2').style.display = 'none'; 
	document.getElementById('error3').style.display = 'none';
	document.getElementById('loadform').innerHTML = 'AJAX1';
	document.consulta.reset();
	
}
else
{
	document.getElementById('loadform').innerHTML = '';
	
	if (name == '')
	{
	document.getElementById('error1').style.display = 'block'; 
	}
	else
	{
	
	document.getElementById('error1').style.display = 'none';
	}
	
	if (email == '')
	{
	document.getElementById('error2').style.display = 'block'; 
	}
	else
	{
	
	document.getElementById('error2').style.display = 'none';
	}
	
	if (message == '')
	{
	document.getElementById('error3').style.display = 'block'; 
	}
	else
	{
	
	document.getElementById('error3').style.display = 'none';
	}
}


}


function Enviarb(pagina) {
	
	
	var nameb = document.consultab.nameb.value;
	var emailb = document.consultab.emailb.value;
	var messageb = document.consultab.messageb.value;

	if (nameb != '' && emailb != '' && messageb != '')
	{
		
		document.getElementById('error1b').style.display = 'none'; 
		document.getElementById('error2b').style.display = 'none'; 
		document.getElementById('error3b').style.display = 'none '; 
		document.getElementById('loadformb').innerHTML = 'AJAX2';
		document.consultab.reset();
		

	}
	else
	{
		document.getElementById('loadformb').innerHTML = '';
		
		if (nameb == '')
		{
		document.getElementById('error1b').style.display = 'block'; 
		}
		else
		{
		
		document.getElementById('error1b').style.display = 'none';
		}
		
		if (emailb == '')
		{
		document.getElementById('error2b').style.display = 'block'; 
		}
		else
		{
		
		document.getElementById('error2b').style.display = 'none';
		}
		
		if (messageb == '')
		{
		document.getElementById('error3b').style.display = 'block'; 
		}
		else
		{
		
		document.getElementById('error3b').style.display = 'none';
		}
		
		
	}


}




