function BannerRotator(cls) {
	this.banners = HW.getElementsByClassName(cls,document.body,'div');
	for(var i=0;i<this.banners.length;i++) {
		this.bannerContents[i] = this.banners[i].innerHTML;
	}
	this.shuffle();
	this.rerender();
}

BannerRotator.prototype = {
	banners:[],
	bannerContents:[],
	shuffle:function() {
		this.bannerContents.shuffle();
	},
	rerender:function() {
		for(var i=0;i<this.banners.length;i++) {
			this.banners[i].innerHTML = this.bannerContents[i];
		}
	}
}

function BannerRotator2(cls) {
	this.banner = $(cls);
	if(this.banner) {
		this.shuffle();
		this.rerender();
	}
}

BannerRotator2.prototype = {
	banners:[
			 ['content/game_zone/online_games/individual_games/racing/index.aspx','images/whats-new/rally.gif'],
			 /*['content/info_zone/gallery/','images/whats-new/gallery.gif']
			 ['content/about_jcb/quiz/','images/whats-new/quiz.gif'],*/
			],
	bannerContents:[],
	shuffle:function() {
		this.banners.shuffle();
	},
	rerender:function() {
		this.banner.innerHTML = '';
		var a = document.createElement('a');
		a.href = this.banners[0][0];
		var img = document.createElement('img');
		img.src = this.banners[0][1];
		img.alt = '';
		a.appendChild(img);
		this.banner.appendChild(a);
	}
}

Array.prototype.shuffle = function() {
	this.sort(function(a,b) {return Math.random() - 0.5;});
}

HW.attachEvent(window,'load',function() {new BannerRotator('rotateBanner01');new BannerRotator2('rotateBanner02');});