Traverse = function (element, options) {
    var cls = arguments.callee;
    if (!(this instanceof cls)) {
        return new cls(element, options);
    }
    this.__init__(element, options);
};
Traverse.prototype = new MochiKit.Visual.Base();
MochiKit.Base.update(Traverse.prototype, {
    __class__ : Traverse,
    __init__: function (element, /* optional */options) {
        this.element = MochiKit.DOM.getElement(element);
        this.start(options);
    },
    /** @id Traverse.prototype.setup */
    setup: function () {
        var b = MochiKit.Base;
        var attrs = this.options.attrs;
        this.attrsStart = {};
        this.attrsEnd = {};
        this.units = {};
        var value, unit;
        for (var s in attrs) {
            value = "" + attrs[s];
            var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/);
            value = parseFloat(components[1]);
            unit = (components.length == 3) ? components[2] : null;
            this.attrsEnd[s] = value;
            this.units[s] = unit;
            current_value = "" + this.element[s];
            components = current_value.match(/^([\+\-]?[0-9\.]+)(.*)$/);
            current_value = parseFloat(components[1]);
            this.attrsStart[s] = current_value;
        }
    },

    /** @id Traverse.prototype.update */
    update: function (position) {
        var value;
        for (var s in this.attrsStart) {
            value = this.attrsStart[s] + Math.round((this.attrsEnd[s] - this.attrsStart[s]) * position * 1000) / 1000 + this.units[s];
            this.element[s] = value;
        }
    }
})


tabs_click_before = function(overflow, current_tab, new_tab, ev) {
	/* save current top */
	current_tab.current_top = $(overflow).scrollTop
	Traverse($(overflow), {
		'attrs': {
			'scrollTop': new_tab.current_top ? new_tab.current_top : 0
		}
	})
}
tabs_click_after = function(overflow, current_tab, old_tab, ev) {
	/* restore top */
	//$(overflow).scrollTop = tab.current_top;
}
