function redimentionneBlock()
{
    var posX = $('.aRider:eq('+index+')').position().left + 7 - 66;
    var posY = $('.aRider:eq('+index+')').position().top - 13;

    $('#ficheHover img ').animate( { width:"371px", height :"103px", opacity:'1'}, 300, null, null);
    $('#ficheHover').animate( { width:"416px", height :"192px", left : posX, top : posY }, 300, null, null);
}

function afficheBlock()
{
    var img = $('.aRider:eq('+index+') img').attr('src');
    var nom = $('.aRider:eq('+index+') .nomPrenom').html();
    var pays = $('.aRider:eq('+index+') .country').html();


    $('#ficheHover img').attr('src',img);
    $('#ficheHover #showPrenom').html(nom);
    $('#ficheHover #showPays').html(pays);



    var posX = $('.aRider:eq('+index+')').position().left + 7;
    var posY = $('.aRider:eq('+index+')').position().top;
    var width ="284px";
    var height ="165px";

    var css = {'left' : posX, 'top' : posY, 'width' : width, 'height': height}
    $('#ficheHover').css(css);

    $('#ficheHover').fadeIn(500,redimentionneBlock);
}

$(document).ready(function(){

    index=0;

    var skinName = readCookie("skinName");
    if (skinName) switch_style(skinName);
    else switch_style('surfTheme');
     
    $(".aSkin").click(function(){
           var id 	=	$('.aSkin').index(this); 
           var skin = 	$('.aSkin:eq('+id+')').attr('id')
           switch_style(skin);
    });

    $('#flags').addClass('hide');
    $('#skins').addClass('hide');

    $('#country').click(function(){
        $('#flags').toggleClass('hide');
    });

    $('#setup').click(function(){
        $('#skins').toggleClass('hide');
    });

    // =========================
    // --  Gestion du filtre ---
    // =========================
    
    // All riders :
    
    $("#viewAll").click(function(){
        $('#viewAll').removeClass('OFF');
        $('#viewAll').addClass('ON');
        //$("#filtres h3").html('All riders');

        $(".surf").fadeIn(500,function(){
            $('#switch2surf').removeClass('ON');
            $('#switch2surf').addClass('OFF');
        });
        
        $(".skate").fadeIn(500,function(){
            $('#switch2skate').removeClass('ON');
            $('#switch2skate').addClass('OFF');
        });
        
        $(".snow").fadeIn(500,function(){
            $('#switch2snow').removeClass('ON');
            $('#switch2snow').addClass('OFF');
        });
        
        $(".others").fadeIn(500,function(){
            $('#switch2others').removeClass('ON');
            $('#switch2others').addClass('OFF');
        });
        
    });

    // Riders surf :
    
    $("#switch2surf").click(function(){
        $('#viewAll').removeClass('ON');
        $('#viewAll').addClass('OFF');
        //$("#filtres h3").html('Surfers');

        $(".surf").fadeIn(500,function(){
            $('#switch2surf').removeClass('OFF');
            $('#switch2surf').addClass('ON');
        });
        
        $(".skate").fadeOut(500,function(){
            $('#switch2skate').removeClass('ON');
            $('#switch2skate').addClass('OFF');
        });

        $(".snow").fadeOut(500,function(){
            $('#switch2snow').removeClass('ON');
            $('#switch2snow').addClass('OFF');
        });
        
        $(".others").fadeOut(500,function(){
            $('#switch2others').removeClass('ON');
            $('#switch2others').addClass('OFF');
        });

    });
    
    // Riders skate :

    $("#switch2skate").click(function(){
        $('#viewAll').removeClass('ON');
        $('#viewAll').addClass('OFF');
        //$("#filtres h3").html('Skaters');

        $(".skate").fadeIn(500,function(){
            $('#switch2skate').removeClass('OFF');
            $('#switch2skate').addClass('ON');
        });
        
        $(".surf").fadeOut(500,function(){
            $('#switch2surf').removeClass('ON');
            $('#switch2surf').addClass('OFF');
        });

        $(".snow").fadeOut(500,function(){
            $('#switch2snow').removeClass('ON');
            $('#switch2snow').addClass('OFF');
        });
        
        $(".others").fadeOut(500,function(){
            $('#switch2others').removeClass('ON');
            $('#switch2others').addClass('OFF');
        });

    });
    
    // Riders snow :

    $("#switch2snow").click(function(){
        $('#viewAll').removeClass('ON');
        $('#viewAll').addClass('OFF');
        //$("#filtres h3").html('Snowboarders');

        $(".snow").fadeIn(500,function(){
            $('#switch2snow').removeClass('OFF');
            $('#switch2snow').addClass('ON');
        });
        
        $(".surf").fadeOut(500,function(){
            $('#switch2surf').removeClass('ON');
            $('#switch2surf').addClass('OFF');
        });

        $(".skate").fadeOut(500,function(){
            $('#switch2skate').removeClass('ON');
            $('#switch2skate').addClass('OFF');
        });
        
        $(".others").fadeOut(500,function(){
            $('#switch2others').removeClass('ON');
            $('#switch2others').addClass('OFF');
        });

    });
    
    // Riders others :
    
    $("#switch2others").click(function(){
        $('#viewAll').removeClass('ON');
        $('#viewAll').addClass('OFF');
        //$("#filtres h3").html('Others');

        $(".others").fadeIn(500,function(){
            $('#switch2others').removeClass('OFF');
            $('#switch2others').addClass('ON');
        });
        
        $(".surf").fadeOut(500,function(){
            $('#switch2surf').removeClass('ON');
            $('#switch2surf').addClass('OFF');
        });
        
        $(".skate").fadeOut(500,function(){
            $('#switch2skate').removeClass('ON');
            $('#switch2skate').addClass('OFF');
        });

        $(".snow").fadeOut(500,function(){
            $('#switch2snow').removeClass('ON');
            $('#switch2snow').addClass('OFF');
        });
        


    });
    
    // All :
    
    $("#viewAll").mouseenter(function(){
        if ($("#viewAll").hasClass('OFF'))
        $("#viewAll").animate( { opacity:"0.5" }, 0);
    });
    
    $("#viewAll").mouseleave(function(){
        $("#viewAll").animate( { opacity:"1.0" }, 0);
    });
    
    // Snow :

    $("#switch2snow").mouseenter(function(){
    if ($("#switch2snow").hasClass('OFF'))
        $("#switch2snow").animate( { opacity:"0.5" }, 0);
    });

    $("#switch2snow").mouseleave(function(){
        $("#switch2snow").animate( { opacity:"1.0" }, 0);
    });
    
    // Surf :
    
    $("#switch2surf").mouseenter(function(){
    if ($("#switch2surf").hasClass('OFF'))
        $("#switch2surf").animate( { opacity:"0.5" }, 0);
    });

    $("#switch2surf").mouseleave(function(){
        $("#switch2surf").animate( { opacity:"1.0" }, 0);
    });
    
    // Skate :
    
    $("#switch2skate").mouseenter(function(){
    if ($("#switch2skate").hasClass('OFF'))
        $("#switch2skate").animate( { opacity:"0.5" }, 0);
    });

    $("#switch2skate").mouseleave(function(){
        $("#switch2skate").animate( { opacity:"1.0" }, 0);
    });
    
    // Others :
    
    $("#switch2others").mouseenter(function(){
    if ($("#switch2others").hasClass('OFF'))
        $("#switch2others").animate( { opacity:"0.5" }, 0);
    });

    $("#switch2others").mouseleave(function(){
        $("#switch2others").animate( { opacity:"1.0" }, 0);
    });

});






