var scroller = {

                    outer_box:      Object,
                    pic_box:        Object,
                    pic_group:      Object,
                    pics:           Object,
                    pic_info:       {},
                    box_info:       {},
                    box_width:      Number,
                    group_width:    Number,
                    end_position:   Number,
                    pic_time:       Number,
                    duration:       {},

                    init:           function(settings) {
                    
                                        this.outer_box = settings.outer_box;
                                        this.pic_box = settings.pic_box;
                                        this.pic_group = settings.pic_group;
                                        this.pics = $(this.pic_group).find("img");
                                        this.pic_time = settings.pic_time;
                                        
/*
                                        this.duration.first = settings.duration;
                                        this.duration.last = this.duration.first / 2;
*/
                                        
                                        this.run();
                                        
                                    },
                                    
                    get_info:       function() {
                                        
                                        this.pic_info.count = this.pics.length;
                                        this.pic_info.width = this.pics.outerWidth(true);
                                        this.pic_info.height = this.pics.height();
                                        
                                        this.box_info.width = this.outer_box.width();
                                        this.duration.spread = this.box_info.width / this.pic_info.width;
                                        
                                    },
                                    
                    resize:         function() {
                                        
                                        this.group_width = this.pic_info.count * this.pic_info.width;
                                        this.box_width = this.group_width * 2;
                                        this.end_position = this.group_width * -1;
                                        
                                        $(this.pic_box).width(this.box_width);
                                        $(this.pic_group).width(this.group_width);

                                    },
                                    
                    clone_pics:     function() {$(this.pic_group).clone().appendTo(this.pic_box);},
                                    
                    animate:        function(duration) {
                                        
                                        base = this;
                                        $(this.pic_box).animate({ left: this.end_position }, duration, 'linear', function() {
                                            $(this).animate({ left: 0 }, 1, function() {base.animate(base.duration.last);});
                                        });
                    
                                    },
                                                                        
                    first_pos:      function() {
                    
                                        $(this.pic_box).css({ left: this.box_info.width });
                    
                                    },
                                    
                    run:            function() {
                    
                                        this.get_info();
                                        this.resize();
                                        this.clone_pics();
                                        this.first_pos();

                                        this.duration.first = this.pic_info.count * this.pic_time;
                                        this.duration.last = this.duration.first - (this.pic_time * this.duration.spread);

                                        this.animate(this.duration.first);
                        
                                    }

}



$(window).load(function() {
    
    var settings = {
        outer_box: $("#scroller_box"),
        pic_box: $("#scroller_pics"),
        pic_group: $(".pic_group"),
        duration: 18000,
        pic_time: 1500
    }

    scroller.init(settings);
    
});