function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function openwindow(pie,imagen){
	var centroy=((screen.availHeight - 510)/2);
	var centrox=((screen.availWidth - 510)/2);	
	window.open('/popup.php?pie='+pie+'&imagen='+imagen,'Imagen','resizable=yes,menubar=no,toolbar=no,scrollbars=yes,width=468,height=300,left='+centrox+',top='+centroy);
}

function iecompattest(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}		

function CambiarFotoPortada() {
	imagen= Math.floor(Math.random()*4);
	document.getElementById("FotoPortada").style.backgroundImage="url(http://www.zaragozadirecto.com/img/fotos_portada/"+imagen+".jpg)";
}

function ComprobarFormBaja(form){
	if(document.getElementById('EMailB').value==''){
		alert('El campo EMail es obligatorio .');
		return false;
	}
	if(!validarEmailModificar(document.getElementById('EMailB').value)){
		return false;
	}
	if(document.getElementById('PasswordB').value==''){
		alert('El campo Clave es obligatorio.');
		return false;
	}
	return true;
}

function ConfirmarSalir(Ruta) {
	if (confirm("&iquest;Est&aacute; seguro de que desea salir?")){
		window.location = Ruta + "salir.php";
	}
}

function ConfirmarBaja(Ruta) {
	if (confirm("&iquest;Est&aacute; seguro de que desea darse de baja?")){
		window.location = Ruta + "baja.php";
	}
}


//Funciones para capa flotante en Mosaico

	// CLICK
	function MostrarInformacionCompleta(IdCaja, IdPadre, numElementos) {
			if (document.getElementById('videoSeleccionado').value==IdCaja){
				//No hacer nada
			}else{
				document.getElementById('videoSeleccionado').value=IdCaja;
				if (Tipos[IdCaja]=="Video") {
					document.getElementById('FotoUltimaHora').style.display  = 'none';
					document.getElementById('VideoUltimaHora').style.display  = 'block';
				}else{
					if (Tipos[IdCaja]=="Foto") {
						document.getElementById('FotoUltimaHora').style.display  = 'block';
						document.getElementById('VideoUltimaHora').style.display  = 'none';	
					}
				}
				document.getElementById('Hora').innerHTML  = Horas[IdCaja];
				document.getElementById('Recurso').innerHTML  = HTMLVideo[IdCaja];
				document.getElementById('AutorVideo').innerHTML  = Autores[IdCaja];	
				document.getElementById('TituloVideo').innerHTML  = Titulos[IdCaja];
				document.getElementById('CaricaUsuario').innerHTML  = Avatar[IdCaja];
				
				for (i=0; i<numElementos; i++) {
					document.getElementById('Cajalistado'+i).className= "Cajita";
				}
				document.getElementById(IdPadre).className="Cajita Activo";
			}
	}
	
	function MostrarPrimero(IdCaja, IdPadre, numElementos) {
		if(numElementos>0){
				document.getElementById('videoSeleccionado').value=IdCaja;
				if (Tipos[IdCaja]=="Video") {
					document.getElementById('FotoUltimaHora').style.display  = 'none';
					document.getElementById('VideoUltimaHora').style.display  = 'block';
				}else{
					if (Tipos[IdCaja]=="Foto") {
						document.getElementById('FotoUltimaHora').style.display  = 'block';
						document.getElementById('VideoUltimaHora').style.display  = 'none';	
					}
				}
				document.getElementById('Hora').innerHTML  = Horas[IdCaja];
				document.getElementById('Recurso').innerHTML  = HTMLVideo[IdCaja];
				document.getElementById('AutorVideo').innerHTML  = Autores[IdCaja];	
				document.getElementById('TituloVideo').innerHTML  = Titulos[IdCaja];
				document.getElementById('CaricaUsuario').innerHTML  = Avatar[IdCaja];
				
				
				
				for (i=0; i<numElementos; i++) {
					document.getElementById('Cajalistado'+i).className= "Cajita";
				}
				document.getElementById(IdPadre).className="Cajita Activo";
		}
	}
