function component_IndexScrollProfileList(auto_id)
{
    this.DOMConstruct('IndexScrollProfileList', auto_id);
	
    var handler = this;
	
    this.references = [];
	
    this.delegates = {
		
    };
}

component_IndexScrollProfileList.prototype =
    new SK_ComponentHandler({
		
        $list_prototype: undefined,
        $item_prototype: undefined,

        $lists_cont: undefined,

        $menu_cont: undefined,
		
        $menu_node: undefined,
		
        $menu_prototype: undefined,
		
        active_list: undefined,
		
        items_count: 6,

        lists: {},

        loading: false,

        construct : function(items_count) {

            var handler = this;

            if (items_count != undefined) {
                this.items_count = items_count;
            }

            this.$lists_cont = this.$(".profile_list_cont");
            this.$list_prototype = this.$lists_cont.find(".prototype_node")
            .removeClass("prototype_node")
            .remove();
			
            this.$item_prototype = this.$list_prototype.find(".item").remove();

            this.$menu_cont = this.$(".menu").removeClass("prototype_node");
            this.$menu_node = this.$menu_cont.find("ul");
            this.$menu_prototype = this.$menu_cont.find(".tab").remove();
			
            this.$(".block_toolbar").hide();
            //this.$("#view_prev_btn").hide();
            //this.$("#view_prev_btn").addClass('disabled');

            this.$("#view_more_btn").click(function(){

                var list_name = this.rel;

                if ( list_name == handler.active_list.list_name )
                {
                    if (!handler.loading)
                    {
                        handler.loading = true;
                        handler.lists[list_name].last++;
                        var items_offset = handler.lists[list_name].last;
                        if (typeof handler.lists[list_name].items[items_offset] == 'undefined')
                        {
                            handler.ajaxCall('ajax_LoadItem', {
                                list_name: list_name,
                                count: 1,
                                offset: items_offset
                            }, {
                                success: function(){
                                    handler.moveRight(list_name);
                                    handler.loading = false;
                                }
                            });
                        

                        }
                        else
                        {
                            handler.moveRight(list_name);
                            handler.loading = false;
                        }
                    }
                }
            });


            this.$("#view_prev_btn").click(function(){

                var list_name = this.rel;

                if ( list_name == handler.active_list.list_name )
                {
                    handler.moveLeft(list_name);
                }

            });

        },

        moveLeft: function(list_name)
        {
            var handler = this;

            if(handler.lists[list_name].first == 0 || handler.lists[list_name].first == handler.items_count)
            {
                return;
                //handler.$("#view_prev_btn").hide();
                //handler.$("#view_prev_btn").addClass('disabled');
            }

            handler.lists[list_name].items[handler.lists[list_name].last].$node.hide();
            handler.lists[list_name].last--;

            handler.lists[list_name].first--;
            handler.lists[list_name].items[handler.lists[list_name].first].$node.show();


            //handler.$("#view_more_btn").show();
        },

        moveRight: function(list_name)
        {
            var handler = this;

            if ( typeof handler.lists[list_name].items[handler.lists[list_name].last] != 'undefined' )
            {
                handler.lists[list_name].items[handler.lists[list_name].first].$node.hide();
                handler.lists[list_name].first++;
                handler.lists[list_name].items[handler.lists[list_name].last].$node.show();
            }
            else
            {
                handler.lists[list_name].last--;
                //handler.$("#view_more_btn").hide();
            }

            /*if(handler.lists[list_name].first > 0)
            {
                //handler.$("#view_prev_btn").show();
                //handler.$("#view_prev_btn").removeClass('disabled');
            }*/
        },

        addItem: function(list_name, item, offset){

            var handler = this;

            var $node = this.$item_prototype.clone();

            var list_item = {
                $node: $node,
                loaded: false
            }

            var $img = $("<img>");

            $img.load(function(){
                list_item.loaded = true;
            });

            $img.attr("src", item.img_src);
            $node.find(".image").prepend($img);
            $node.find("a").attr("href", item.img_url);

            $node.find('.sex_line').addClass('sex_line_' + item.sex);

            $node.find(".label").text(item.label)
            $node.attr('id', 'index_scroll_profile_list_item_'+offset);
            $node.css('display', 'none');

            handler.lists[list_name].items.push(list_item);

            $node.appendTo(handler.lists[list_name].$list_node);

        },

        addList: function(list_name, label, url){
			
            var handler = this;
			
            var $menu_node = this.$menu_prototype.clone();
            $menu_node.find("span").text(label);
						
            $menu_node.appendTo(this.$menu_node);
			
            $menu_node.find("a").click(function(){
                handler.activateList(list_name);
            }).addClass(list_name);
			
            this.lists[list_name] = {
                list_name: list_name,
                $menu_node: $menu_node,
                list_url: url,
                first: 0,
                last: 0
            }

        },
		
        activateList: function(list_name) {
            var handler = this;

            if ( !this.loading )
            {
                this.loading = true;

                if(this.lists[list_name].$list_node != undefined) {
                    this.loading = false;
                    if (this.active_list != undefined) {
                        this.active_list.active = false;
                        this.active_list.$list_node.hide();
                        this.active_list.$menu_node.removeClass("active");
                    }
				
                    this.active_list = this.lists[list_name];
                    this.lists[list_name].active = true;
                    this.active_list.$list_node.show();
                    this.active_list.$menu_node.addClass("active");
                    this.$("#view_prev_btn").attr("rel", list_name);
                    this.$("#view_more_btn").attr("rel", list_name);

                    /*if ( this.lists[list_name].items.length < this.items_count )
                    {
                        handler.$("#view_more_btn").hide();
                    }
                    else
                    {
                        handler.$("#view_more_btn").show();
                    }

                    if(handler.lists[list_name].first == 0)
                    {
                        //handler.$("#view_prev_btn").hide();
                        //handler.$("#view_prev_btn").addClass('disabled');
                    }
                    else
                    {
                        //handler.$("#view_prev_btn").removeClass('disabled');
                    }*/

                    var ping_count = 0;
                    var ping = function() {
                        if (ping_count < 100) {
                            for (var key in handler.lists[list_name].items) {
                                if (!handler.lists[list_name].items[key].loaded) {
                                    ping_count++;
                                    return false;
                                }
                            }
                        }
                        return true;
                    }
				
                    if (ping()) {
                        handler.hidePreloader();
                        return true;
                    }
				
                    var interval = window.setInterval(function(){
                        if (ping()) {
                            window.clearInterval(interval);
                            handler.hidePreloader();
                        }
                    }, 5);
				
                    return true
                }
                this.active_list.$menu_node.removeClass("active");
                this.lists[list_name].$menu_node.addClass("active");
                this.showPreloader();
                this.ajaxCall('ajax_LoadList', {
                    list_name: list_name,
                    count: this.items_count,
                    offset: this.lists[list_name].last
                }, {
                    success: function(){

                        
                    }
                });
        }
    },
		
    $preloader: undefined,
    preloader_height: undefined,
    showPreloader: function() {
        if (this.$preloader == undefined) {
            this.$preloader = $('<div class="content_preloader preloader" style="float: left; width: 976px;"></div>');
            //alert(this.preloader_height);
            if (this.preloader_height != undefined) {
                this.$preloader.height(this.preloader_height);
            }
				
            this.$lists_cont.hide().before(this.$preloader);
        }
			
    },
		
    hidePreloader: function() {
        if (this.$preloader != undefined) {
            this.$preloader.remove();
            this.$preloader = undefined;
            this.$lists_cont.show();
            this.preloader_height = this.$lists_cont.height();
        }
    },
		
    fillList: function(list_name, items) {
        var handler = this;

        this.lists[list_name].$list_node = this.$list_prototype.clone();

        this.lists[list_name].$list_node.attr('id', 'index_scroll_profile_list_'+list_name);
			
        this.lists[list_name].items = [];
						
        //            var $item_prototype = $list_node.find(".item").remove();
									
        this.showPreloader();
			
        if (items.length != 0) {
				
            $.each(items, function(i, item){
					
                handler.addItem(list_name, item, i);
                handler.lists[list_name].items[i].$node.show();
                handler.$(".block_toolbar").show();
            });
        } else {
            this.lists[list_name].$list_node.append(this.$(".empty_list_msg:eq(0)").clone().show());
            this.$(".block_toolbar").hide();
            if (this.lists.length == 1) {
                this.lists[list_name].$menu_node.hide();
            }
        }

        this.lists[list_name].first = 0;
        this.lists[list_name].last = items.length-1;
        this.lists[list_name].$list_node.prependTo(this.$lists_cont);
						
        if (!this.lists[list_name].active) {
            this.lists[list_name].$list_node.hide();
        }
        handler.loading = false;
    },
		
    complete: function() {
        this.$menu_node.find('.tab').removeClass('first').removeClass('last');
        this.$menu_node.find('.tab:first').addClass('first');
        this.$menu_node.find('.tab:last').addClass('last');
    },
		
    debug: function(x) {
			
        window.setTimeout(function(){
            console.debug(x);
        }, 500);
    }
		
    });

