/*

*/

// Creamos un array asociativo. Wee!
IMGIDX = 0;
C = new Array();
IMG = Array();
Cp = 0;

// ShowHide
SHOW = false;
OPACITY = 0;
OPDIR = 0;


function poner_imagen ( idx ) {
    img = new Image();
    
    function poner() {
        // Ponemos la foto
        e('contenedor_portada').style.backgroundImage = "url('html/imgs/bg_" + C[idx] + ".jpg')";
        
        // Y la descripción
        e('descripcion').innerHTML = IMG [ C [idx ] ];
    }

    // Borramos la descripción
    e('descripcion').innerHTML = '';
    
    // Ponemos el wsait
    e('contenedor_portada').style.backgroundImage = "url('html/imgs/ajax-loader.gif')";    
    
    img.onLoad = poner()
    img.src = 'html/imgs/bg_' + C[idx] + '.jpg';
}

function siguiente() {
    IMGIDX++;
    
    // overflow?
    if ( IMGIDX >= Cp ) 
        IMGIDX = 0;


    // Colocamos la imagen
    poner_imagen ( IMGIDX )    
}

function anterior() {
    IMGIDX--;
    
    // overflow?
    if ( IMGIDX < 0) 
        IMGIDX = Cp - 1;


    // Colocamos la imagen
    poner_imagen ( IMGIDX )    
}

function cambiar_opacidad() {

    // Colocamos la opacidad
    OPACITY += OPDIR;
    
    // Firefox - Chrome
    e('contenido').style.opacity = OPACITY / 100;
    
    // Exploder
    e('contenido').style.filter = "alpha(opacity=" + OPACITY + ")";
    
    
    if ( OPACITY <= 0 ) {
        // Escondido
        SHOW = false;
        e('showhide').innerHTML = 'Mostrar panel';
    }
    else if ( OPACITY >= 100  ) {
        SHOW = true;
        e('showhide').innerHTML = 'Ocultar panel';
    }
    else {
        // Nos rellamamos
        setTimeout ( 'cambiar_opacidad()', 10 );
    }
}

function showhide () {
    // Mostramos u ocultamos la ventana de contenido
    
    if  ( SHOW ) {
        // Ocultamos
        OPDIR = -2
//        $('#contenido').fadeIn ();
    }
    else {
        // Mostramos
        OPDIR = 2
//        $('#contenido').fadeOut ();
    }   

    // Activamos
    setTimeout ( 'cambiar_opacidad()', 10 );
        
} 



IMG['01'] = "Polideportivo 'Rosa Vargas de Panizo' - Ica";
IMG['02'] = "Plazuela 'Sebastián Barranca' - Ica";

// Sacamos la lista de codigos
Cp = 0;
for ( var i in IMG ) {
    C[Cp++] = i;
}


