// #require mootools.js
if (window.addEvent) {
	window.addEvent('domready', function() {
		$$(['top-scoreboard']).each(function (block) {
			var img = block.getElement('span.status-icon img');
			if (img) {
				block.statusIcon = {
					'target': img,
					'normal': new Image,
					'rover': new Image
				};
				block.statusIcon.normal.src = img.src;
				block.statusIcon.rover.src = img.src.replace(
					/^(.+?)(?:-on)?(\.(gif|jpg|jpeg|xbm|png))$/,
					"$1-on$2");
			}
			block.addEvent('mouseenter', (function (event) {
				this.addClass('hover');
				if (this.statusIcon) {
					this.statusIcon.target.src = this.statusIcon.rover.src;
				}
			}).bindWithEvent(block));
			block.addEvent('mouseleave', (function (event) {
				this.removeClass('hover');
				if (this.statusIcon) {
					this.statusIcon.target.src = this.statusIcon.normal.src;
				}
			}).bindWithEvent(block));
			block.addEvent('click', (function(event) {
				event = new Event(event);
				var link = this.getElement('a');
				if (link) {
					event.stop();
					window.location.href = link.href;
				}
			}).bindWithEvent(block));
			block.setStyle('cursor', 'pointer');
		});
	});
}

