var Ranking = {
	initialize: function(){
		this.ref = document.id('ranking');

		this.handles = [];
		this.blocks = this.ref.getChildren();

		this.build();
	},

	build: function(){
		var i = 0;

		for(i; i < this.blocks.length; i++){
			this.blocks[i].setStyle('display', 'none');

			this.handles[i] = new Element('p').addEvent('click', this.show.pass([i],this)).inject(this.ref).adopt(
				this.blocks[i].addClass('item').getFirst().getNext()
			);
		}

		this.win = new myWin({
			width: 572,
			className: 'rwin',
			draggable: true,
			onShow: function(){
				if(this.overlay){
					this.overlay.show();
				}
				this.container.setOpacity(0).setStyle('display', 'block').retrieve('myFx').start('opacity', 0, 1);
			},
			onHide: function(){
				if(this.overlay){
					this.overlay.hide();
				}
				this.container.retrieve('myFx').start('opacity', 1, 0);
			}
		});

		this.win.container.store('myFx', new Fx.Tween(this.win.container, {
			onComplete: function(){
				if(this.element.getOpacity() === 0){
					this.element.setStyle('display', 'none');
				}
			}
		}));

		this.ref.setStyle('display', 'block');
	},

	show: function(i){
		for(var j = 0; j < this.blocks.length; j++){
			if(j === i){
				this.win.setContent(this.blocks[j].setStyle('display', 'block'));
			}else{
				this.ref.adopt(this.blocks[j].setStyle('display', 'none'));
			}
		}

		this.win.setTitle('&nbsp;').setPosition('center', 'center', false, false).show();
	},

	hide: function(){
		this.win.hide();
	}
};

Ranking.initialize();

