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 MostrarConsulta(datos,ContenidoId){
	if(document.getElementById('SeccionPrincipal').style.display=='')	
	{
		document.getElementById('SeccionPrincipal').style.display='none'	
		document.getElementById('SeccionInterior').style.display='';
		setTimeout("MostrarNoticia('noticias.php',0,0,'paginacion');",1000);	
		setTimeout("MostrarBannersPrincipal('banners.php','')",2500)		
	}
	
	
	if(ContenidoId==32)
	{
		document.getElementById('SeccionInicio').style.display=''
		document.getElementById('AjaxSecciones').style.display='none'
		divResultado = document.getElementById('AjaxSalida');
	}
	else
	{
		document.getElementById('SeccionInicio').style.display='none'
		document.getElementById('AjaxSecciones').style.display=''	
		divResultado = document.getElementById('AjaxSecciones');	
	}
	ajax=objetoAjax();
	ajax.open("GET", datos+"?contenido="+ContenidoId+"&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divResultado.innerHTML = 'Cargando...'
		}
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText			
		}
	}
	ajax.send(null)
}


function MostrarConsulta2(datos,ContenidoId){
	divResultado = document.getElementById('AjaxSalidaAlterno2');
	ajax=objetoAjax();
	ajax.open("GET", datos+"?contenido="+ContenidoId+"&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divResultado.innerHTML = 'Cargando...'
		}
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText	
		}
	}
	ajax.send(null)
}


function MostrarNoticia(datos,NoticiaId,numpag,accion){
	
	if(accion=='paginacion')
	{	
		divResultado = document.getElementById('AjaxNoticias');	
	}
	else
	{
		document.getElementById('AjaxSecciones').style.display=''
		document.getElementById('SeccionPrincipal').style.display='none'
		divResultado = document.getElementById('AjaxSecciones');			
	}
	ajax=objetoAjax();
	ajax.open("GET", datos+"?idNoticia="+NoticiaId+"&numpag="+numpag+"&accion="+accion+"&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}


function MostrarVideoGaleria(datos,tipo){
	document.getElementById('PagContenidos').style.display=''
	document.getElementById('PagInicio').style.display='none'
	document.getElementById('Galeria1').style.display='none'
	document.getElementById('Galeria2').style.display='none'

	divResultado = document.getElementById('AjaxSalidaAlterno');	

	ajax=objetoAjax();
	ajax.open("GET", datos+"?tipo="+tipo+"&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

function VerVideo(datos,iDVideo,tipo){
	divResultado = document.getElementById('ReproducirVideo');		
	ajax=objetoAjax();
	ajax.open("GET", datos+"?iDVideo="+iDVideo+"&tipo="+tipo+"&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divResultado.innerHTML = 'Cargando...'
		}
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)	

}

function MostrarProductos(datos){
	divResultado = document.getElementById('AjaxSalida');	
	ajax=objetoAjax();
	ajax.open("GET", datos+"?tipo=Productos&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divResultado.innerHTML = 'Cargando...'
		}
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}


function Busqueda(datos,accion){
	divResultado = document.getElementById('AjaxSalida');	
	ajax=objetoAjax();
	ajax.open("GET", datos+"?tipo="+accion+"&Indbusq="+document.getElementById('buscar').value+"&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divResultado.innerHTML = 'Cargando...'
		}
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
			document.getElementById('buscar').value='';
		}
	}
	ajax.send(null)
}

function MostrarPdfs(datos){
	divResultado = document.getElementById('AjaxSalida');	
	ajax=objetoAjax();
	ajax.open("GET", datos+"?tipo=pdfs&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divResultado.innerHTML = 'Cargando...'
		}
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)

}

function MostrarProductosDetalle(datos,Id){
	divResultado = document.getElementById('AjaxSalida');	
	ajax=objetoAjax();
	ajax.open("GET", datos+"?tipo=ProductoDetalle&Producto="+Id+"&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divResultado.innerHTML = 'Cargando...'
		}
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
			setTimeout("MostrarGaleria('Contenido.php',"+Id+",0)",500);			
		}
	}
	ajax.send(null)
}

function MostrarContacto(datos,tipo){
	if(document.getElementById('SeccionPrincipal').style.display=='')	
	{
		document.getElementById('SeccionPrincipal').style.display='none'	
		document.getElementById('SeccionInterior').style.display='';	
		setTimeout("MostrarNoticia('noticias.php',0,0,'paginacion');",1000);	
		setTimeout("MostrarBannersPrincipal('banners.php','')",2500)		
		
	}	
	document.getElementById('AjaxSecciones').style.display=''
	document.getElementById('SeccionInicio').style.display='none'
	divResultado = document.getElementById('AjaxSecciones');	

	ajax=objetoAjax();
	ajax.open("GET", datos+"?tipo="+tipo+"&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divResultado.innerHTML = 'Cargando...'
		}
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

function EnviaMail(datos){
	
	if(document.getElementById('name').value=='' && document.getElementById('email').value=='' && document.getElementById('comentario').value=='')
	{
			alert('Faltan algunos campos por llenar')
	}
	else
	{
		document.getElementById('AjaxSecciones').style.display=''
		document.getElementById('SeccionInicio').style.display='none'
		divResultado = document.getElementById('AjaxSecciones');	
	
		ajax=objetoAjax();
		ajax.open("GET", datos+"?tipo=MailEnviado&elNombre="+document.getElementById('name').value+"&email="+document.getElementById('email').value+"&comentario="+document.getElementById('comentario').value+"&ciudad="+document.getElementById('ciudad').value+"&telefono="+document.getElementById('telefono').value+"&PC="+Math.random());
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				//alert(ajax.responseText)
				divResultado.innerHTML = ajax.responseText
			}
		}
		ajax.send(null)
	}
}

function EnviaRecomienda(datos)
{	
	if(document.getElementById('SeccionPrincipal').style.display=='')	
	{
		document.getElementById('SeccionPrincipal').style.display='none'	
		document.getElementById('SeccionInterior').style.display='';	
		setTimeout("MostrarNoticia('noticias.php',0,0,'paginacion');",1000);	
		setTimeout("MostrarBannersPrincipal('banners.php','')",2500)		
		
	}
	
	if(document.getElementById('EmailRec').value=='')
	{
			alert('Faltan algunos campos por llenar')
	}
	else
	{
		divResultado = document.getElementById('AjaxRecomienda');
		ajax=objetoAjax();
		ajax.open("GET", datos+"?tipo=recomienda&email="+document.getElementById('EmailRec').value+"&PC="+Math.random());
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				alert(ajax.responseText)
				//divResultado.innerHTML = ajax.responseText
				document.getElementById('EmailRec').value=''
			}
		}
		ajax.send(null)
	}
}
function limpiar()
{
	document.getElementById('name').value='';
	document.getElementById('email').value='';
	document.getElementById('comentario').value='';
}

function MostrarConsultaPdf(datos,ContenidoId,tipo){
	divResultado = document.getElementById('AjaxPdfs');
	ajax=objetoAjax();
	ajax.open("GET", datos+"?contenido="+ContenidoId+"&tipo="+tipo+"&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}


function MostrarBannersPrincipal(datos,seccion)
{
	divResultado = document.getElementById('AjaxBanners');
	ajax=objetoAjax();
	ajax.open("GET", datos+"?seccion="+seccion+"&PC="+Math.random());
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			divResultado.innerHTML = 'Cargando...'
		}
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)		
}
