/* ------------------------------------------------------------------------ *
    SlideBox
    
    (c) 2008 Daniel Haus
        http://ematia.de
 * ------------------------------------------------------------------------ */

$(window).load(function () {
    if (!window.console) {
        window.console = {
            log: function (msg) {
                window.status = msg;
            }
        };
    }
    
    SlideBox = function (element, options) {
        if (this == window) return new SlideBox(element, options);
        this.init(element, options);
    };

    SlideBox.prototype = {
        init: function (element, options) {
            var self = this;
            options = options || {};
            
            this.factor = options.factor || 1.5;
            this.element = $(element);
            this.boxes = this.element.children("li");
            this.width = this.element.width();
            this.boxWidth = this.boxes.width();
            this.boxes
                .css("width", this.boxWidth)
                .bind("mouseenter", function () { self.expandBox(this); });
            this.element.bind("mouseleave", function () { self.relax(); });
            
            this.widthExp = parseInt(this.factor * this.boxWidth);
            this.widthShrinked = parseInt(((this.width - this.widthExp) /
                                        (this.boxes.size() - 1.0)));
        },
        
        
    
        expandBox: function (box) {
            // var box = $(box);
            $(box)
            .animate({"width": this.widthExp}, { duration: 500, easing: "swing" })
            .siblings("li")
                .animate({"width": this.widthShrinked}, { duration: 500, easing: "swing" });
        },
    
        relax: function (box) {
            this.boxes.animate({"width": this.boxWidth}, { duration: 500, easing: "swing" });
        }
    };

    SlideBox("#slidebox");
});

