/* deps prototype.js, scriptaculous */

/**
 * if id for element is "river-div"
 * id for i-th item would be "river-div-i"
 * with class "river-div-item"
 */
var River = function(items, id, options) {
    this.items = items;
    this.element = jQuery("#" + AXIS.escapeCSS(id));
    this.options = {
        onItemClick: this.onItemClick
    };

    jQuery.extend({
        context: function(context, fn) {
            return function() {
                return fn.apply(context, arguments);
            };
        }
    });

    jQuery.extend(this.options, options || {});

    var up = this;

    for(var i = 0; i<items.length; i++) {
        var item_element = jQuery('<div class="river-item" id="' + id + '-' + i + '">' + items[i] + '</div>')
        
        item_element.appendTo(up.element);
        item_element.bind('click', up.options.onItemClick);
    };
};

River.prototype = {

    onItemClick: function(e) {
        $(this).slideUp();
        return false;
    },

    hide: function() {
        this.element.hide();
    },

    show: function() {
        this.element.show();
    },

    toggle: function() {
        this.element.toggle();
    }
};
