var BestRatedBlock = new Class({
	
    Implements: Options,
	
    options: {
        tab_pfx:				'bestrated-category-',
        container_pfx:			'bestrated-container-',
		
        active_category:		-1,
		
        category_count:			3
    },
	
    initialize: function(options) {
        this.setOptions(options);
		
        for (var i = 0; i < this.options.category_count; i++) {
            if($(this.options.tab_pfx + i))
                $(this.options.tab_pfx + i).addEvent('click', this.setActiveCategory.bind(this, i));
        }
		
        this.setActiveCategory(0);
    },
	
    setActiveCategory: function(index) {
        if($(this.options.tab_pfx + index) == null) {
            return;
        }
		
        if(this.options.active_category == index) {
            this.options.active_category = index;
            return;
        }
		
        if ($(this.options.tab_pfx + this.options.active_category)) {
            $(this.options.tab_pfx + this.options.active_category).className = "simple";
            $(this.options.tab_pfx + this.options.active_category).firstChild.className = "simple";
        }
		
        this.hideObjectContainer(this.options.active_category);
        this.options.active_category = index;
		
        $(this.options.tab_pfx + this.options.active_category).className = "act";
        $(this.options.tab_pfx + this.options.active_category).firstChild.className = "act";
		
        this.showObjectContainer(index);
		
        return false;
    },

    hideObjectContainer: function(index) {
        if($(this.options.container_pfx + index) == null) {
            return;
        }
		
        $(this.options.container_pfx + index).className = "hide";
    },
	
    showObjectContainer: function(index) {
        if($(this.options.container_pfx + index) == null) {
            return;
        }
		
        $(this.options.container_pfx + index).className = "show";
    }
});


var ListTest = new Class({ });

BestRatedBlock.update = function(url, container_id, data) {

    data['action'] = 'get_items';
    var request = new Request.JSON({
        url : url,
        method : 'post',
        data: data,
        async: false,
        onSuccess: function(responseJSON, responseText) {
            if (responseJSON.isError == 0) {
                $(container_id).innerHTML = responseJSON.data;
                //highlight(div);
            }
        }
    });

    request.send();
}