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

var alertTimerId;
var publiConten;
var video;

function selPagina(urlBarra, tipo, nombreClase){
		var publi = document.getElementById('publi');
		contenido = document.getElementById('especial-desplegable');
		//if(document.getElementById('primaryContentVideo'))video = document.getElementById('primaryContentVideo').getElementsByTagName("object")[0];
		if(document.getElementById('primaryContentVideo'))video = document.getElementById('primaryContentVideo');
		
		//if (publi.getElementsByTagName("object").length>0)publiConten = publi.getElementsByTagName("object")[0];
		
		if(tipo=="over" ){
			clearTimeout ( alertTimerId );
			if(urlBarra){
				contenido.style.display = "none";
				alea = Math.floor(Math.random() * 999999999);
				Cargar(urlBarra+"?al="+alea, nombreClase);
			}
		}else{
			if(publiConten && video)alertTimerId = setTimeout ( "contenido.style.display = \"none\"; publiConten.style.visibility = \"visible\";  video.style.visibility = \"visible\"", 500 );
			else if(publiConten)alertTimerId = setTimeout ( "contenido.style.display = \"none\"; publiConten.style.visibility = \"visible\"", 500 );
			else if(video)alertTimerId = setTimeout ( "contenido.style.display = \"none\"; video.style.visibility = \"visible\"", 500 );
			else alertTimerId = setTimeout ( "contenido.style.display = \"none\"", 500 );
		}
		
}

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, nombreClase){
	var contenido, publi;
	contenido = document.getElementById('especial-desplegable');
	publi = document.getElementById('publi');
	
	//if (publi.getElementsByTagName("object").length>0)publiConten = publi.getElementsByTagName("object")[0];
	
	//if(document.getElementById('primaryContentVideo'))var video = document.getElementById('primaryContentVideo').getElementsByTagName("object")[0];
	if(document.getElementById('primaryContentVideo'))var video = document.getElementById('primaryContentVideo');
		
	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;
					contenido.style.display = "block";
					if(publiConten)publiConten.style.visibility = "hidden";
					if(video)video.style.visibility = "hidden";
					
					if(nombreClase){
						entreDiv = contenido.getElementsByTagName("div")[0];
						if (entreDiv.setAttribute("class", nombreClase)) entreDiv.setAttribute("class", nombreClase);
			    	if (entreDiv.setAttribute("className", nombreClase))entreDiv.setAttribute("className", nombreClase);
			  	}
					
				}else if(ajax.status==404){
					alert("La página no existe");
				}else{
					alert("Error:".ajax.status);
				}
			}
		}
		ajax.send(null);
	}
}