//Obtenemos el objecto http
function getHTTPObject() {
  var xmlhttp;
 
  if(window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject){
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    if (!xmlhttp){
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
}
  return xmlhttp;
}
//Instanciamos httpObject
var http00 = getHTTPObject();
var http01 = getHTTPObject();
var http02 = getHTTPObject();
var http03 = getHTTPObject();
var http04 = getHTTPObject();
var http05 = getHTTPObject();
var http06 = getHTTPObject();
var http07 = getHTTPObject();
var http08 = getHTTPObject();
var http09 = getHTTPObject();
/*Funciones ajax*/
/*LIsta boletines*/
function listaContenido(){
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "contenido/boletines.php?myrand="+myrand;
	http00.open("GET", modurl, true);
	http00.onreadystatechange = listaContenido; 
	http00.send(null);
}
function listaContenido(){
	if (http00.readyState == 4) 
	{
		if(http00.status == 200) 
		{
			var textoHTML= http00.responseText;
			document.getElementById('contenido').innerHTML=textoHTML;
		}	
	} 
	else{document.getElementById('contenido').innerHTML="cargando...";} 
} 
/*fin*/

function pagina_main(){
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "contenido/home.html?myrand="+myrand;
	http00.open("GET", modurl, true);
	http00.onreadystatechange = response_pagina_main; 
	http00.send(null);
}
function response_pagina_main(){
	if (http00.readyState == 4) 
	{
		if(http00.status == 200) 
		{
			var textoHTML= http00.responseText;
			document.getElementById('contenido').innerHTML=textoHTML;
		}	
	} 
	else{document.getElementById('contenido').innerHTML="cargando...";} 
} 
function pagina_somos(){
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "contenido/somos.html?myrand="+myrand; 
	http01.open("GET", modurl, true);
	http01.onreadystatechange = response_pagina_somos; 
	http01.send(null);
}
function response_pagina_somos(){
	if (http01.readyState == 4) 
	{
		if(http01.status == 200) 
		{
			var textoHTML= http01.responseText;
			document.getElementById('contenido').innerHTML=textoHTML;
		}	
	} 
	else{document.getElementById('contenido').innerHTML="cargando...";} 
} 
function pagina_localizacion(){
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "contenido/localizacion.html?myrand="+myrand; 
	http02.open("GET", modurl, true);
	http02.onreadystatechange = response_pagina_localizacion; 
	http02.send(null);
}	
function response_pagina_localizacion(){
	if (http02.readyState == 4) 
	{
		if(http02.status == 200) 
		{
			var textoHTML= http02.responseText;
			document.getElementById('contenido').innerHTML=textoHTML;
		}	
	} 
	else{document.getElementById('contenido').innerHTML="cargando...";} 
}
function pagina_condiciones_venta(){
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "contenido/condiciones_venta.html?myrand="+myrand; 
	http03.open("GET", modurl, true);
	http03.onreadystatechange = response_pagina_condiciones_venta; 
	http03.send(null);
}	
function response_pagina_condiciones_venta(){
	if (http03.readyState == 4) 
	{
		if(http03.status == 200) 
		{
			var textoHTML= http03.responseText;
			document.getElementById('contenido').innerHTML=textoHTML;
		}	
	} 
	else{document.getElementById('contenido').innerHTML="cargando...";} 
}
function pagina_condiciones_compra(){
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "contenido/condiciones_compra.html?myrand="+myrand; 
	http04.open("GET", modurl, true);
	http04.onreadystatechange = response_pagina_condiciones_compra; 
	http04.send(null);
}	
function response_pagina_condiciones_compra(){
	if (http04.readyState == 4) 
	{
		if(http04.status == 200) 
		{
			var textoHTML= http04.responseText;
			document.getElementById('contenido').innerHTML=textoHTML;
		}	
	} 
	else{document.getElementById('contenido').innerHTML="cargando...";} 
}
function pagina_contacto(){
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "contenido/contacto.php?myrand="+myrand; 
	http05.open("GET", modurl, true);
	http05.onreadystatechange = response_pagina_contacto; 
	http05.send(null);
}	
function response_pagina_contacto(){
	if (http05.readyState == 4) 
	{
		if(http05.status == 200) 
		{
			var textoHTML= http05.responseText;
			document.getElementById('contenido').innerHTML=textoHTML;
		}	
	} 
	else{document.getElementById('contenido').innerHTML="cargando...";} 
}
function pagina_noticias() 
{
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "noticias.php?myrand="+myrand; 
	http06.open("GET", modurl, true);
	http06.onreadystatechange = response_pagina_noticias; 
	http06.send(null);
}	
function response_pagina_noticias()
{
	if (http06.readyState == 4) 
	{
		if(http06.status == 200) 
		{
			var textoHTML= http06.responseText;
			document.getElementById('contenido').innerHTML=textoHTML;
		}	
	} 
	else{document.getElementById('contenido').innerHTML="cargando...";} 
}
function pagina_noticias1(iparm){
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "noticias1.php?iparm="+iparm+"&myrand="+myrand; 
	http07.open("GET", modurl, true);
	http07.onreadystatechange = response_pagina_noticias1; 
	http07.send(null);
}	
function response_pagina_noticias1(){
	if (http07.readyState == 4) 
	{
		if(http07.status == 200) 
		{
			var textoHTML= http07.responseText;
			document.getElementById('contenido').innerHTML=textoHTML;
		}	
	} 
	else{document.getElementById('contenido').innerHTML="cargando...";} 
}
function contacto(){
	
	nombre=document.getElementById("nombre").value;
	mail=document.getElementById("mail").value;
	telefono=document.getElementById("telefono").value;
	mensajes = document.getElementById("mensajes").value;
	
	if(nombre.length <= 3){
		alert("El campo nombre es un campo obligatorio, Debe introducir un nombre valido.");
	}else if(mail.length <= 1){
		alert("El campo E-mail es un campo obligatorio, Introducir una dirección de correo electrónico valida.");
	}else if(mensajes.length <= 10){
		alert("El campo mensaje es un campo obligatorio.");
	}else {
		url_mas = "&nombre="+nombre+"&mail="+mail+"&telefono="+telefono+"&mensajes="+mensajes;
		var myrand=parseInt(Math.random()*99999999);
		var modurl= "contenido/send_contacto.php?s=1&myrand="+myrand+url_mas; 
		http08.open("GET", modurl, true);
		http08.onreadystatechange = response_contacto; 
		http08.send(null);
	}
}	
function response_contacto(){
	if (http08.readyState == 4) 
	{
		if(http08.status == 200) 
		{
			var textoHTML= http08.responseText;
			document.getElementById('ID_RESULT').innerHTML=textoHTML;
			
			nombre=document.getElementById("nombre").value = "";
			mail=document.getElementById("mail").value = "";
			telefono=document.getElementById("telefono").value = "";
			mensajes = document.getElementById("mensajes").value = "";
			obs = document.getElementById("mensajes").value = "";
			/*
			document.form_.nombre.value="";
			document.form_.mail.value="";
			document.form_.telefono.value="";
			document.form_.mensajes.value="";
			*/
		}	
	} 
	else{document.getElementById('ID_RESULT').innerHTML="enviando...";} 
}
function RegistraBoletin(iparm){
	if(iparm!="")
	{
		var myrand=parseInt(Math.random()*99999999);
		var modurl= "add_boletin.php?iparm="+iparm+"&myrand="+myrand; 
		http09.open("GET", modurl, true);
		http09.onreadystatechange = response_RegistraBoletin; 
		http09.send(null);
	}
	else
	{
		alert("Introduzca su E-mail");	
	}
}
function response_RegistraBoletin(){
	if (http09.readyState == 4) 
	{
		if(http09.status == 200) 
		{
			var textoHTML= http09.responseText;
			document.getElementById('contenido').innerHTML=textoHTML;
			document.form_mail.text_mailBoletin.value="";
		}	
	} 
	else{document.getElementById('contenido').innerHTML="agregando información para el boletín...";} 
}
/*Funciones Normales*/
function buscarPagina(busca){
	page1 = document.getElementById("page1").value;
	url = "index.php?busca="+busca+"&opcion=2,0&page1="+page1;
	alert (url);
	window.location.href=url;
}