var adRotator = {
	ads: new Array(),
	
	add: function(path) {
		this.ads.push(path);
	},
	
	start: function(container_id, timer) {
		timer = timer * 1000;
		this.display(container_id, timer);
	},
	
	display: function(container_id, timer) {
		var rand = Math.round( (adRotator.ads.length - 1) * Math.random() ) + 1;
		// if rand is bigger than count of ads use the last one
		if(rand >= adRotator.ads.length) {
			rand = adRotator.ads.length-1;
		}
		document.getElementById(container_id).style.backgroundImage = "url(" + adRotator.ads[rand] + ")";
		setTimeout("adRotator.display('" + container_id + "', " + timer + ")", timer);
	}
};