var agt = navigator.userAgent.toLowerCase();
var IE = agt.indexOf("msie") != -1;

var inActivoClases = ["calendario","cronicas","backstage","videos","visor","ego"];
var activoClases = ["active cal","active cro","active back","active vid","active vis","active ego"];

var indice;

function selPagina(urlBarra, idBot){
	
		indice = 	idBot;
		alea = Math.floor(Math.random() * 999999999);
		if(urlBarra!="portada")Cargar(urlBarra+"?al="+alea);
  	else Cargar(urlBarra);
  	
  	for (i=0;i<4;i++){
    	var actBot = document.getElementById("bt"+i);
    	if(actBot){
	    	if(i!=idBot){
	    		if(IE){
	    			actBot.setAttribute("className", inActivoClases[i]);
	    		}else{
		    		actBot.setAttribute("class", inActivoClases[i]);
		    	}
	    	}else{
	    		if(IE){
	    			actBot.setAttribute("className", activoClases[i]);
	    		}else{
		    		actBot.setAttribute("class", activoClases[i]);
		    	}
	    	}
	    }
    }
}

function NuevoAjax(){
	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;
}

var timePubli;

function Cargar(url){
	var contenido, preloader;
	contenido = document.getElementById('selects');
	//preloader = document.getElementById('preloader');
	if(url!="portada"){
		ajax=NuevoAjax();
		ajax.open("GET", url,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==1){
				//preloader.innerHTML = "Cargando...";
				//preloader.style.display = "block";
			}else if(ajax.readyState==4){
				if(ajax.status==200){
					contenido.innerHTML = ajax.responseText;
					
					if(IE){
		    			contenido.setAttribute("className", inActivoClases[indice]);
		    		}else{
			    		contenido.setAttribute("class", inActivoClases[indice]);
			    }
					
					//preloader.style.display = "none";
				}else if(ajax.status==404){
					alert("La página no existe");
				}else{
					alert("Error:".ajax.status);
				}
			}
		}
		ajax.send(null);
	}else{
		if(IE){
		    contenido.setAttribute("className", inActivoClases[indice]);
		}else{
			  contenido.setAttribute("class", inActivoClases[indice]);
		}
	}
}