var dockTimer;
function inicializarDock()
{
    
    /*Establecemos el tamaño máximo de la lista con las imágenes del dock*/
    var ofertas = $("#dock_ofertas li div");
    var ancho = 3 +  parseInt(ofertas.css('width').replace('px','')) * (ofertas.length);



    $("#dock_ofertas").css('width',ancho);


    //asignamos los eventos a las flechas del dock
    $("#dock_flecha_der2 div").mouseover(dock_movimiento);
    $("#dock_flecha_der2 div").mouseout(dock_movimiento_stop);
    
    $("#dock_flecha_izq2 div").mouseover(dock_movimiento);
    $("#dock_flecha_izq2 div").mouseout(dock_movimiento_stop);
    
    ofertas.mouseover(dock_mostrar_titulo);
    ofertas.mouseout(dock_ocultar_titulo);

    $('#dock').show();
}

function dock_movimiento()
{    
    var tipo = ($(this).attr('tipo'));
    var desplazamiento = 20;
    
    

    var auxLeft = parseInt($("#dock_ofertas").css('left').replace('px',''));
    var auxMax = parseInt($("#dock_contenido").css('width').replace('px','')) -
                        parseInt($("#dock_ofertas").css('width').replace('px',''));

    if ( (tipo == 1 && auxLeft >=0) || (tipo == -1 && auxLeft <= auxMax))
    {
    
            return false;
    }
            

    $("#dock_ofertas").css('left',(Math.round(auxLeft + (desplazamiento * tipo))));
    
    if (tipo == 1)      
      dockTimer = setTimeout('$("#dock_flecha_izq div").mouseover()', 125);
      
    else if (tipo == -1)      
        dockTimer = setTimeout('$("#dock_flecha_der div").mouseover()', 125);
      
}

function dock_movimiento_stop()
{
    clearTimeout(dockTimer);
}

function dock_mostrar_titulo ()
{
    $("#dock_oferta_titulo").text($(this).attr('titulo'));    
}

function dock_ocultar_titulo()
{
    $("#dock_oferta_titulo").text('');
}