
listado = new Array(new Array (),new Array (),new Array (),new Array ());


var ruta = './contenido/biombo/';
var z0=0;
var z1=0;
var z2=0;
var z3=0;

var loss = new Array(4000, 4700, 5400, 4200);


var cont=0;


var nBiombos;

function biombos()
{
	z0=0;
	z1=0;
	z2=0;
	z3=0;
	cont=0;
	
	addLista("biombo_0",0);
	addLista("biombo_1",1);
	addLista("biombo_2",2);
	//addLista("biombo_3",3);
	
	nBiombos=3;
	
	
	ini();
	
	
	
	
}
	





function addLista(donde,ref)
{
	
	
	x=cos;
	
	var fo = document.getElementById(donde); // 1
	
		fo.style.width = parte + "px";
		fo.style.height = x + "px";
		
	var contenedor = document.createElement('div'); // 2
		contenedor.id = 'cara'+ ref + 'B' ; // 3
		contenedor.className="caraA";
		contenedor.style.width=parte + "px";
		contenedor.style.height= x + "px";
		
	fo.appendChild(contenedor); // 4
	
	
	var contenedor = document.createElement('div'); // 2
		contenedor.id = 'cara'+ ref + 'A' ; // 3
		contenedor.className="caraB";
		contenedor.style.width=parte + "px";
		contenedor.style.height= x + "px";
		
	fo.appendChild(contenedor); // 4
	
	//----------------------------
	
	var lista = document.getElementById("lista" + ref).getElementsByTagName("li");
	var num = lista.length;
	
	
	var fo = document.getElementById("container"); // 1

	for	(b=0;b<num;b++)
	{
		var img = lista[b].innerHTML;
		
		var contenedor = document.createElement('div'); // 2
		contenedor.id = 'capa'+ cont ; // 3
		
		fo.appendChild(contenedor); // 4
		
		
		var fo = document.getElementById('capa'+ cont); // 1
		var imgM = document.createElement('img');
			
			imgM.src = ruta + reso + "_" + img;
			fo.appendChild(imgM); // 4
		
		
		listado[ref][b] =  ruta + reso + "_" + img; 
		
		cont++;
		
	}
	
	
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2




function ini()
{
	var lim=nBiombos;
	
	
	for(id=0;id<lim;id++)
	{
		
			var n= window["z"+ id];
			
			var img = document.createElement('img');
				img.src =  listado[id][n];
				img.width = newW ;
				img.height = newH ;
				document.getElementById("cara"+ id + "A").appendChild(img); // 4
				
			n++;
			
			var img = document.createElement('img');
				img.src =  listado[id][n];
				img.width = newW ;
				img.height =newH ;
				document.getElementById("cara"+ id + "B").appendChild(img); // 4
				
			window["z"+ id]= n;
			
			
			if(listado[id].length > 1)
			{
				window.setTimeout('run('+ id +')',loss[id]);
			}
		
		if(id > 0 )
		{
			$("#biombo_"+ id).css("left","-1px"); //correccion
		}
		
	}
	
	
	
}



function run(id)
{
	$('#cara' + id + 'A').fadeOut(1000, function() {
		
		window.setTimeout('ran(\''+ id +'\')',8000);
	});
}


function ran(id)
{
	var n= window["z"+ id];
	
	n+=1;
	
	if(n == listado[id].length)
	{
		n=0;
	}
	
	window["z"+ id]= n; 
	document.getElementById("cara"+ id + "A").innerHTML="";
	
	var img = document.createElement('img');
		img.src = listado[id][n];
		img.width = newW ;
		img.height = newH ;
		document.getElementById("cara"+ id + "A").appendChild(img); // 4
	
	
	
	
	$('#cara' + id + 'A').fadeIn(1000, function() {
		
		n+=1;
	
		if(n == listado[id].length)
		{
			n=0;
		}
		window["z"+ id]= n; 
		document.getElementById("cara"+ id + "B").innerHTML="";

		var img = document.createElement('img');
				img.src =  listado[id][n];
				img.width = newW ;
				img.height = newH ;
				document.getElementById("cara"+ id + "B").appendChild(img); // 4
		
		window.setTimeout('run(\''+id+'\')',8000);
		
		
	});
	
	
	
	
}
