function preloader() 
{
	imageObj = new Image();
	var fotos_gal = new Array();
	for(i = 0; i <= 5; i++) {
	  fotos_gal[i]="fotos/tapa_" + i + ".jpg"
	  }
	for(i = 0; i <= 5; i++) {
	  imageObj.src= fotos_gal[i];
	  }
}
function blendimage(ID) {
    var speed = 6;
    var timer = 0;
   	ID_siguiente= ID + 1;
	if(ID_siguiente==6)
		ID_siguiente=0;
	document.getElementById("seccion_next").value=ID_siguiente;	
	//set the current image as background
    document.getElementById('imagen').style.backgroundImage = "url(" + document.getElementById('foto').src + ")";
    
    //make image transparent
    changeOpac(0, 'foto');
    
    //make new image
    document.getElementById('foto').src = "fotos/tapa_" + ID + ".jpg";

    //fade in image
    for(i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'foto')",(timer * speed));
        timer++;
    }
	ID_anterior=document.getElementById("seccion_ID").value;
	document.getElementById("seccion_" + ID).style.backgroundImage="url(fotos/tapa_" + ID + "_mini.jpg)";
	document.getElementById("seccion_" + ID_anterior).style.backgroundImage="url(fotos/tapa_" + ID_anterior + "_byw.jpg)";
	document.getElementById("p_" + ID).style.backgroundColor=colorP(ID);
	document.getElementById("p_" + ID_anterior).style.backgroundColor="#4D4D4D";
	document.getElementById("galeria_fecha").innerHTML=fechas[ID];
	document.getElementById("galeria_titulo").innerHTML=titulos[ID];
	document.getElementById("detalle_texto").innerHTML=copetes[ID];
	document.getElementById("seccion_ID").value=ID;
	setTimeout("manejanext(" + ID_siguiente + ")",(6500));
	
} 
function next(ID)
{
	document.getElementById("seccion_next").value=ID;
	setTimeout("manejanext(" + ID + ")",(10));
}
function manejanext(ID)
{
	proximo=document.getElementById("seccion_next").value;
	setTimeout("blendimage(" + proximo + ")",(20));
}
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}
function homeSeccion()
{
	window.location="seccion.php?ID=" + document.getElementById("seccion_ID").value;
}

function colorP(id)
{
	switch (id)
	{
		case 0: color="#8D9F66";
				break;
		case 1: color="#00B7AE";
				break;
		case 2: color="#554D9F";
				break;
		case 3: color="#8797C6";
				break;
		case 4: color="#0D76D6";
				break;
		case 5: color="#AF113C";
				break;
	}
	return color;
			
}