window.addEvent('domready', function() {
	$$('div.player-personalbox').each(function (personalbox) {
		var numberclothimg = personalbox.getElement('span.numbercloth img');
		if (numberclothimg) {
			personalbox.numbercloth = {
				'target': numberclothimg,
				'normal': new Image,
				'rover': new Image
			};
			personalbox.numbercloth.normal.src = numberclothimg.src;
			personalbox.numbercloth.rover.src = numberclothimg.src.replace(
				/^(.+?)(?:-on)?(\.(gif|jpg|jpeg|xbm|png))$/,
				"$1-on$2");
		}
		personalbox.addEvent('mouseenter', (function(event) {
			this.addClass('hover');
			if (this.numbercloth) {
				this.numbercloth.target.src = this.numbercloth.rover.src;
			}
		}).bindWithEvent(personalbox));
		personalbox.addEvent('mouseleave', (function(event) {
			this.removeClass('hover');
			if (this.numbercloth) {
				this.numbercloth.target.src = this.numbercloth.normal.src;
			}
		}).bindWithEvent(personalbox));
		personalbox.addEvent('click', (function(event) {
			event = new Event(event);
			var link = this.getElement('div.player-data a');
			if (link) {
				event.stop();
				window.location.href = link.href;
			}
		}).bindWithEvent(personalbox));
		personalbox.setStyle('cursor', 'pointer');
	});
});
