var cookie;

// # Si Javascript está activado, creo una Cookie #
function checkjs() {
			cookie = getCookie("javascript");
			if(cookie != 1) {
				document.cookie = "javascript = 1";
				location.reload(true);
				}
		}
checkjs();
// # Función aunxiliadora para checkjs() #
function getCookie(name){
  var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}
			

// # Función de navegación primera. #
var ajaxreturn;
var value = 0;  
var primera = 0;;
var whereto;
var beenh = 0;
var quiensoy;
function transform(div)
	{
		if(beenh == 0 && quiensoy != div) {
			loading();
			beenh++;
			quiensoy = div;
			ajaxFunction(div);

		}
	}
// # Función auxiliar para la navegación #	
function loading() {
		document.getElementById('content').innerHTML = "<br><br><center><img src='imagenes/loading.gif'></center>";
		}
// # Función de navegación segunda #
function ajaxFunction(div){
			var ajaxRequest;  // The variable that makes Ajax possible!
			
			try{
				// Opera 8.0+, Firefox, Safari
				ajaxRequest = new XMLHttpRequest();
			} catch (e){
				// Internet Explorer Browsers
				try{
					ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try{
						ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e){
						// Something went wrong
						alert("Tu navegador no soporta Javascript o lo hace mal. Por favor, utilize el men&uacute; de abajo.");
						return false;
					}
				}
		}
			// Create a function that will receive data sent from the server
			a = 0;
			ajaxRequest.onreadystatechange = function(){
				
				if(ajaxRequest.readyState == 4){
					transform2(ajaxRequest.responseText);
				}
				else {
					
					a++;
					if (a == 3) {	
						a = 0;
						document.getElementById('content').style.opacity = 0;
						document.getElementById('content').style.filter = 'alpha(opacity=' + 0 + ')';
						
				}
				}
				}
			ajaxRequest.open("GET", div, true);
			ajaxRequest.send(null); 
		}
// # Función de navegación tercera #
function transform2(div) {
		if (value == 0) {
			document.getElementById('content').style.opacity = 0;
			document.getElementById('content').style.filter = 'alpha(opacity=' + 0 + ')';
			document.getElementById("content").innerHTML = div;
			value = 0;
			primera++;
		}
		if(value <= 10) {
			document.getElementById('content').style.opacity = value/10;
			document.getElementById('content').style.filter = 'alpha(opacity=' + value*10 + ')';
			value += 1;
			a = setTimeout("transform2()",45);
		}
		else {
			beenh = 0;
			primera = 0;
			value = 0;
			a = 0;
			}	
}
		
var estuve = 0;
var valor = 0;
// # Función para mostrar sitios primera #
function sitiosreal(url)
{ 
	if(estuve == 0) {
	document.getElementById("sitiosdentro").innerHTML = ""; 
		document.getElementById('sitiosrealizados').style.opacity = 0;
		document.getElementById('sitiosrealizados').style.filter = 'alpha(opacity=' + 0 + ')';
		document.getElementById('sitiosrealizados').style.zIndex = 5;
		document.getElementById('sitiosrealizados').style.display = "block";
		estuve++;
		}
		if( valor < 10) {
	valor += 2;
	document.getElementById('sitiosrealizados').style.opacity = valor/10;
	document.getElementById('sitiosrealizados').style.filter = 'alpha(opacity=' + valor*10 + ')';
	a = setTimeout("sitiosreal('sitios.php')",5);
	}
else {
	ajaxsitios(url);
	estuve = 0;
	valor = 0;
	 }

 }
 // # Función para mostrar sitios segunda #
 function ajaxsitios(paraurl){
	 var ajaxRequest;  // The variable that makes Ajax possible!
			try{
				// Opera 8.0+, Firefox, Safari
				ajaxRequest = new XMLHttpRequest();
			} catch (e){
				// Internet Explorer Browsers
				try{
					ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try{
						ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e){
						// Something went wrong
						alert("Tu navegador no soporta Javascript o lo hace mal. Por favor, utilize el men&uacute; de abajo.");
						return false;
					}
				}
			}
			// Create a function that will receive data sent from the server
			ajaxRequest.onreadystatechange = function(){
				if(ajaxRequest.readyState == 4){
					document.getElementById("sitiosdentro").innerHTML = ajaxRequest.responseText;
				}
				else{
					document.getElementById("sitiosdentro").innerHTML = "<br><br><center><div style='position: absolute; width: 100%; margin-top: -300px'><img src='imagenes/loading.gif'></div></center>"; 
				}	
		}
		
			ajaxRequest.open("GET", paraurl, true);
			ajaxRequest.send(null); 
		}

// # Función para mas información #
function masinformacion() {
		document.getElementById("mas").style.display = "block";
 		document.getElementById("mas").innerHTML = document.getElementById("escondido").innerHTML;
	}
// # Función para cerrar mas información #
function cerrarmasinformacion() {
		document.getElementById("mas").innerHTML = "&#32;";
		document.getElementById("mas").style.display = "none";
	}
// # Función para Cerrar los sitios #
function cerrarsitios() {
			document.getElementById('sitiosrealizados').style.opacity = 0;
			document.getElementById('sitiosrealizados').style.filter = 'alpha(opacity=' + 0 + ')';
			document.getElementById('sitiosrealizados').style.zIndex = -5;
	}
