window.onload = function() { 
setFooter();
setBlackContenido();
} 
window.onresize = function() {
setFooter();
setBlackContenido(); 
} 
function setBlackContenido() {
var alturaDisponible = $("body").height();
$("#contenido").css("height",alturaDisponible - 200 + "px");
$("#content_giros,#content_explorar,#content_busqueda").css("height",alturaDisponible - 330 + "px");
} 
function cerrar() {
	$("#div_giros a").removeClass("selected"); 
	$("#pestanas").children().addClass("amarillo"); 
	$("#pestanas").children(":first").removeClass("amarillo"); 
    $("#pestanas").children(":first").addClass("blanco"); 
	$("#div_explorar,#div_busqueda").css("display","none"); 
	$("#div_giros").css("display","block"); 
    	$('#black').fadeOut('def');
		mostrarPublicidad();
		return false;
}
function iefix() { 
altura = $("#content_giros").height();
$("#content_giros").css("height",(altura + 1)+"px");
setBlackContenido();
clearInterval(intervalo); 
}
function filtrarGiros(e) {
	var str = escape(document.getElementById('filtrar').value); 
    if(str != "") {
    $.ajax({
		   type: "GET",
		   url: path + "ajax/ajax_filtrar.php?filtrar=" + str + "&path=" + path,
		   beforeSend: function() {
			   	$("#content_giros").removeClass();
	            $("#content_giros").addClass("loading");
		   }, 
		   success: function(data,statusText) {
			   $("#content_giros").removeClass("loading");
			   $("#content_giros").html(data); 
		   } 
		   }); 
	} 
} 
function busquedaRapida() {
	var b =  escape($("#busqueda_rapida").attr("value"));
    if(b != "") {
    $.ajax({
		   type: "GET",
		   url: path + "ajax/busqueda-rapida.php?b=" + b + "&path=" + path,
		   beforeSend: function() {
	            $("#busqueda_rapida").addClass("loading");
		   }, 
		   success: function(data,statusText) {
			   $("#busqueda_rapida").removeClass("loading");
			   $("#busqueda_resultados").html(data); 
		   } }); 
} 
} 
$('document').ready(function() {
 $('#giros a').click(function(event) {
	$('#black').fadeIn('def', function() { 
		if($.browser.msie) { 
		 this.style.removeAttribute('filter'); 
		} 
	}); 
    solicitar_subCategorias($(this).html()); 
	setBlackContenido(); 
	$(".nav a:contains(" + $(this).html() + ")").addClass("selected"); 
	event.preventDefault();
 }); 
 $('#botones  a.btn_giros_i').click(function(event) {
	$('#black').fadeIn('def', function() { 
		if($.browser.msie) { 
		 this.style.removeAttribute('filter'); 
		} 
	}); 
    solicitar_subCategorias("A"); 
	$(".nav a:contains(" + "A" + ")").addClass("selected"); 
	setBlackContenido(); 
	event.preventDefault();
 }); 
 $('#botones  a.btn_explorar_i').click(function(event) {
	$('#black').fadeIn('def', function() { 
		if($.browser.msie) { 
		 this.style.removeAttribute('filter'); 
		} 
	}); 
    solicitar_subCategorias("A"); 
	$(".nav a:contains(" + "A" + ")").addClass("selected"); 
	$("#div_explorar").css("display","block");
	$("#div_giros").css("display","none");
	$("#div_busqueda").css("display","none");
	$("#btn_explorar").removeClass(); $("#btn_explorar").addClass("blanco");
	$("#btn_giros").removeClass(); $("#btn_giros").addClass("amarillo");
	$("#btn_busqueda").removeClass(); $("#btn_busqueda").addClass("amarillo");
	setBlackContenido(); 
	event.preventDefault();
 }); 
 $('#botones a.btn_busqueda_i').click(function(event) {
	$('#black').fadeIn('def', function() { 
		if($.browser.msie) { 
		 this.style.removeAttribute('filter'); 
		} 
	}); 
    solicitar_subCategorias("A"); 
	$(".nav a:contains(" + "A" + ")").addClass("selected"); 
	
	$("#div_busqueda").css("display","block");
	$("#div_giros").css("display","none");
	$("#div_explorar").css("display","none");
	
	$("#btn_busqueda").removeClass(); $("#btn_busqueda").addClass("blanco");
	$("#btn_explorar").removeClass(); $("#btn_explorar").addClass("amarillo");
	$("#btn_giros").removeClass(); $("#btn_giros").addClass("amarillo");
	
	setBlackContenido(); 
	event.preventDefault();
 }); 
$("#pestanas a").click(function(event) {
   
   if($(this).parent().attr("class") != "blanco") {
	   $("#pestanas div").addClass("amarillo"); 
	   $(this).parent().addClass("blanco"); 
	   $(this).parent().removeClass("amarillo"); 
	   $(this).blur();
	   btn = $(this).parent().attr("id");
	   if(btn == "btn_giros") {
		   $("#contenido").children().css("display","none");
		   $("#div_giros").css("display","block");
	   } 
	   if(btn == "btn_explorar") {
		   $("#contenido").children().css("display","none");
		   $("#div_explorar").css("display","block");
	   } 
	   if(btn == "btn_busqueda") {
		   $("#contenido").children().css("display","none");
		   $("#div_busqueda").css("display","block");
	   }  
   } 
    event.preventDefault();
}); 
$(".nav a").click(function(event) {
	solicitar_subCategorias($(this).html()); 
	$(this).siblings().removeClass("selected"); 
	$(this).addClass("selected"); 
	$(this).blur();
	event.preventDefault();
}); 
$(".categoria a").click(function(event) {
   if($(this).siblings().length == 0)  { 
   id = $(this).attr("class"); 
   var a = $(this); 
   a.parent().addClass("loading"); 
	 $.ajax({  
			  type:"GET", 
			  url: path + "ajax/explorar-directorio.php?idcat=" + id,
			  success:function(data) {
				 a.after(data); 
	             a.parent().addClass("clic"); 
				 a.parent().removeClass("loading");
				 a.siblings().slideDown("fast"); 
			  } 
			  }); 
	$(this).parent().addClass("abierto"); 
   } 
   
   else if($(this).parent().attr("class") == "categoria abierto")  {
	 $(this).parent().addClass("clic"); 
	 $(this).siblings().slideDown("fast"); 
	
	} else {
	 $(this).siblings().slideUp("fast");
	 $(this).parent().removeClass("clic"); 
   } 

   $(this).blur();
   event.preventDefault();  
 
}); 
$(".subcategoria > a").live("click",function(event) {
   if($(this).siblings().length == 0)  { 
   id = $(this).attr("class"); 
   var a = $(this); 
   a.parent().addClass("loading"); 
	 $.ajax({  
			  type:"GET", 
			  url: path + "ajax/explorar-directorio.php?idsubcat=" + id + "&path=" + path,
			  success:function(data) {
				 a.after(data); 
	             a.parent().addClass("clic"); 
				 a.parent().removeClass("loading");
				 a.siblings().slideDown("fast"); 
			  } 
			  }); 
	$(this).parent().addClass("abierto"); 
   } 
   else if($(this).parent().attr("class") == "subcategoria abierto")  {
	 $(this).parent().addClass("clic"); 
	 $(this).siblings().slideDown("fast"); 
	} else {
	 $(this).siblings().slideUp("fast");
	 $(this).parent().removeClass("clic"); 
   } 
   $(this).blur();
   event.preventDefault();  

});
}); 
	function ocultarPublicidad() {
	if(document.getElementById("publicidad_bordes")) {
	var publicidad_bordes = document.getElementById("publicidad_bordes");
	 for(i=0;i<publicidad_bordes.childNodes.length;i++) {
	   if(publicidad_bordes.childNodes[i].nodeName == "DIV") {
		   publicidad_bordes.childNodes[i].style.display = "none";
	   } 
	 } 
	} 
	if(document.getElementById("superior1")) { 
	  document.getElementById("superior1").style.display = "none";
	  document.getElementById("superior2").style.display = "none";
	  document.getElementById("superior3").style.display = "none";
	  document.getElementById("inferior1").style.display = "none";
	  document.getElementById("inferior2").style.display = "none";
	  document.getElementById("inferior3").style.display = "none";
	}
$("#publicidad_xcosas").css("display","none");
	} 
	function mostrarPublicidad() {
	if(document.getElementById("publicidad_bordes")) {
	var publicidad_bordes = document.getElementById("publicidad_bordes");
	 for(i=0;i<publicidad_bordes.childNodes.length;i++) {
	   if(publicidad_bordes.childNodes[i].nodeName == "DIV") {
		   publicidad_bordes.childNodes[i].style.display = "block";
	   } 
	 } 
	} 
	if(document.getElementById("superior1")) { 
	  document.getElementById("superior1").style.display = "block";
	  document.getElementById("superior2").style.display = "block";
	  document.getElementById("superior3").style.display = "block";
	  document.getElementById("inferior1").style.display = "block";
	  document.getElementById("inferior2").style.display = "block";
	  document.getElementById("inferior3").style.display = "block";
	}
$("#publicidad_xcosas").css("display","block");
	} 
function solicitar_subCategorias(sc) {
	ocultarPublicidad();
    var XMLHttp = new newXMLHttpRequest();
   rand = Math.random(); 
   url = path + "ajax_subcategorias.php?sc=" + sc + "&path=" + path + "&rand=" + rand;
   XMLHttp.open("GET",url,true);
   XMLHttp.onreadystatechange = procesarRespuesta;
   XMLHttp.send(null);
function procesarRespuesta() {
	if(XMLHttp.readyState == 4 && XMLHttp.status == 200) {
		var respuesta = XMLHttp.responseText;
	    var contenido = document.getElementById('content_giros');
        var contenido_inner = document.getElementById('content_giros_inner');
		contenido_inner.innerHTML = respuesta;
		contenido.className = sc;
	} else {
        var contenido = document.getElementById('content_giros');
		var contenido_inner = document.getElementById('content_giros_inner');
        contenido_inner.innerHTML = "";
		contenido.className = "loading";} } } 