var scroller = function(id){
    var self=this;
    this.div = $(id);
    var contentToMove = this.div.find(".content-holder");
    var contentScroll = this.div.find('.content-scroll');
    this.nbElement=0;
    this.hauteur=0;
    this.div.find('div.content-item').each(function(){
        self.nbElement++;
        self.element=this;
        self.hauteur += $(self.element).height();
        self.hauteur+=parseInt($(self.element).css("margin-top"));
        self.hauteur+=parseInt($(self.element).css("margin-bottom"));
        self.hauteur+=parseInt($(self.element).css("padding-top"));
        self.hauteur+=parseInt($(self.element).css("padding-bottom"));
    });
    //alert(this.hauteur);

    $(".slider-vertical").slider({
        orientation: "vertical",
        min:-100,
        max:0,
        value: 0,
        animate: true,
        change: handleSliderAction
    });
    var maxScroll = this.hauteur-(contentScroll.height()-parseInt(contentScroll.css("margin-bottom")));
    this.div.find(".slider-vertical").bind("slide", handleSliderAction);

    function handleSliderAction(e, ui)
    {
        contentToMove.animate({
            top: ui.value * (maxScroll / 100)+ "px"
        }, 5);
        $("#amount").val(ui.value * (maxScroll / 100));
    }
}
/**************************/
/* Sliders A suivre */
$(document).ready(function(){
    // A suivre
    s1 = new scroller("#content-scroll-slider-1");
    s2 = new scroller("#content-scroll-slider-2");
    s3 = new scroller("#content-scroll-slider-3");
});

/************/
/* Onglets A suivre */
$(function() {
    $("#a_suivre").tabs({
        cookie: {
            // store cookie for a day, without, it would be a session cookie
            expires: 1
        }
    });
});
/**************************/
/* Slider Annonces */
$(document).ready(function(){
    s7 = new scroller("#content-scroll-slider-annonces");
})
