// JavaScript Document
var precarga=false;
	
	function precargar2(){
		for(i=1;i<medias.length;i++){
			if(medias[i][0]==1){
				imagenes.push(new Image());
				imagenes[i].src = medias[i][1]; 
			}
		}
	}
	
	
	function precargar(codigo){
		for(i=0;i<medias.length;i++){
			if(medias[i][0]==1){
				imagenes.push(new Image());
				imagenes[i].src = medias[i][1]; 
			}
		}
		precarga=true;
		
		if(codigo==1){
			ir_posterior();
		}else if(codigo==-1){
			ir_anterior();
		}else{
			alert("Error en la galeria");
		}
	}
	
	function cargaVideo(){
		FlashReplace.replace("repvideo", medias[actual][1], "flash-element-id", 370, 300);
		document.getElementById("repimagen").style.display='none';
		document.getElementById("repvideo").style.display='block';
	}
	
	function cargaImagen(){
		if(document.getElementById("flash-element-id")){
			document.getElementById("flash-element-id").parentNode.removeChild(document.getElementById("flash-element-id"));
		}
		document.getElementById("repimagen").src = medias[actual][1];
		document.getElementById("repvideo").style.display='none';
		document.getElementById("repimagen").style.display='block';
	}

	function carga_inicial(){
		if(medias[actual][0]==1){//Imagen
			cargaImagen();
		}else{ //Flash
			cargaVideo();
		}
		document.getElementById("titulo").appendChild(document.createTextNode(datos[actual][0])); //Titulo
		document.getElementById("autor").appendChild(document.createTextNode(datos[actual][1])); //Autor
		document.getElementById("fecha").appendChild(document.createTextNode(datos[actual][2])); //fecha
		precargar2();
	}
	
	function carga_inicial2(){
		if(medias[actual][0]==1){//Imagen
			cargaImagen();
		}else{ //Flash
			cargaVideo();
		}
		document.getElementById("titulo").appendChild(document.createTextNode(datos[actual][0])); //Titulo
		document.getElementById("autor").appendChild(document.createTextNode(datos[actual][1])); //Autor
		document.getElementById("fecha").appendChild(document.createTextNode(datos[actual][2])); //fecha
	}
	
	function ir_anterior()
	{
		/*if(!precarga){
			precarga ??????????¨?r(-1);
			return false;
		}*/
		
		actual--;
		if(actual<0){
			actual=medias.length-1;
		}
		if(medias[actual][0]==1){//Imagen
			cargaImagen();
			//document.getElementById("repimagen").src = medias[actual][1];
		}else{ //Flash
			cargaVideo();
			//FlashReplace.replace("repvideo", medias[actual][1], "flash-element-id", 370, 300);
		}
		document.getElementById("titulo").removeChild(document.getElementById("titulo").firstChild);	
		document.getElementById("titulo").appendChild(document.createTextNode(datos[actual][0])); //Titulo
		document.getElementById("autor").removeChild(document.getElementById("autor").firstChild);
		document.getElementById("autor").appendChild(document.createTextNode(datos[actual][1])); //Autor
		document.getElementById("fecha").removeChild(document.getElementById("fecha").firstChild);
		document.getElementById("fecha").appendChild(document.createTextNode(datos[actual][2])); //fecha
	}
	
	function ir_posterior()
	{
		/*if(!precarga){
			precargar(1);
			return false;
		}*/
		
		actual++;
		if(actual>=medias.length){
			actual=0;
		}
		if(medias[actual][0]==1){//Imagen
			cargaImagen();
			//document.getElementById("repimagen").src = medias[actual][1];
		}else{ //Flash
			cargaVideo();
			//FlashReplace.replace("repvideo", medias[actual][1], "flash-element-id", 370, 300);
		}
		document.getElementById("titulo").removeChild(document.getElementById("titulo").firstChild);
		document.getElementById("titulo").appendChild(document.createTextNode(datos[actual][0])); //Titulo
		document.getElementById("autor").removeChild(document.getElementById("autor").firstChild);
		document.getElementById("autor").appendChild(document.createTextNode(datos[actual][1])); //Autor
		document.getElementById("fecha").removeChild(document.getElementById("fecha").firstChild);
		document.getElementById("fecha").appendChild(document.createTextNode(datos[actual][2])); //fecha
	}
	
	//publicidad
var img = new Array()
var url = new Array()
var ind = 0
var retardo = 4000

img[0] = new Image()
img[0].src = "logos/logo_mo_color.jpg"
url[0] = "http://www.mundoobrero.es"

img[1] = new Image()
img[1].src = "logos/banner_crisis.jpg"
url[1] = "http://www.nopagueslacrisis.org"

img[2] = new Image()
img[2].src = "logos/logo_r.jpg"
url[2] = "http://www.pce.es/secretarias/secmovrepublicano/pl.php?id=4521"





function sucesion()
{
if (ind ==  img.length) ind = 0

if (document.images)
{
document.images.banner.src = img[ind].src  
}
else
{
document.getElementById('banner').src=img[ind].src
}
ind++
setTimeout('sucesion()',retardo)
}
function ir()
{
window.open(url[ind-1])
}


