// 
// EVENTOS Y ANIMACIONES DE LOS BOTONES DE PRODUCTOS
// 


//Iconos Spor Choice//
$('.IcoTopChoice').click(function() {
    $('.BackDesarrolloProductos').fadeIn(800);
    $('.ContProductosChoice').fadeIn(3000);
    
    $('.ContProductosMorp').fadeOut(500);
    $('.ContProductosFace').fadeOut(500);
    $('.ContProductosPede').fadeOut(500);
});


//Iconos Spor Morpad//
$('.IcoTopMorp').click(function() {
    $('.BackDesarrolloProductos').fadeIn(800);
    $('.ContProductosMorp').fadeIn(3000);
    
    $('.ContProductosChoice').fadeOut(500);
    $('.ContProductosFace').fadeOut(500);
    $('.ContProductosPede').fadeOut(500);
});


//Iconos Spor FaceFan//
$('.IcoTopFace').click(function() {
    $('.BackDesarrolloProductos').fadeIn(800);
    $('.ContProductosFace').fadeIn(3000);
    
    $('.ContProductosMorp').fadeOut(500);
    $('.ContProductosChoice').fadeOut(500);
    $('.ContProductosPede').fadeOut(500);
});


//Iconos Spor Pedeolmos mkt digital//
$('.IcoTopPede').click(function() {
    $('.BackDesarrolloProductos').fadeIn(800);
    $('.ContProductosPede').fadeIn(3000);
    
    $('.ContProductosMorp').fadeOut(500);
    $('.ContProductosFace').fadeOut(500);
    $('.ContProductosChoice').fadeOut(500);
});





// SLIDER PRODUCTOS //
function multislide(elemento){
    var elem=$(elemento);
    var mov = false;
    var li = 280;
    var cant = elem.find('ul li').length;
    var next = li*cant-li;
    var back = li*cant;
    var contar = 1;
    //var r = Math.floor(Math.random()*1000);
    
    var nextfl=elem.parent().parent().find('.NextFlash');
    var backfl=elem.parent().parent().find('.BackFlash');
    
    nextfl.click(function() {
        var curr = parseInt(elem.css('top'));
        if (contar!=cant){
            if(curr <= 0 && curr>-next && !mov){
                mov = true;
                elem.animate({
                    "top":(curr-li)+'px'
                    },"slow",function(){
                    mov = false;
                    contar++;
                });
            }
        }
        else{
            mov = true;
            elem.animate({
                "top":"0px"
            },"slow",function(){
                mov = false;
                contar = 1;
            });
        }                    
    });
            
            
            
    backfl.click(function() {
        var curr = parseInt(elem.css('top'));
        if (contar!=1){
            if(curr>=-back && curr!=0 && !mov){
                mov = true;
                elem.animate({
                    "top":(curr+li)+'px'
                    },"slow",function(){
                    mov = false;
                    contar--;
                });
            }
        }
        else{
            mov = true;
            elem.animate({
                "top":(-1*next)+'px'
                },"slow",function(){
                mov = false;
                contar = cant;
            });
        }                      
    });
}
                                
var elems=$('.ContentFlash');
$.each(elems, function(i,e){    
    multislide($(e));
});
