function AdBox(id, x, y, width, height, adImageUrls, adLinkUrls) {
	this.id = id;
	this.currentAd = 0;

	this.boxLayer = document.zbAppendLayer(id, width, height, null);
	this.boxLayer.zbSetLocation(x, y);

	this.adImages = new Array(adImageUrls.length);
	for (var i=0; i < adImageUrls.length; i++) {
		this.adImages[i] = new Image();
		this.adImages[i].src = adImageUrls[i];
	}

	this.adLinkUrls = adLinkUrls;

	var html = "<a href='javascript:void(0)'>" + 
				"<img border='0' name='" + id+"img" + 
				"' src='" + adImageUrls[0] + 
				"' width='" + width + "' height='" + height + "'>" +
				"</a>";

	this.boxLayer.zbSetContent(html);

	this.boxLayer.zbAddEventListener("click", AdBox_doClick, false);
	this.boxLayer.owner = this;

	this.start = AdBox_start;
	this.rotate = AdBox_rotate;

	if (typeof document.adBoxes == "undefined") 
		document.adBoxes = new Array();

	document.adBoxes[id] = this;

	return this;
}

function AdBox_start(t) {
	var sCode = "document.adBoxes['" + this.id + "'].rotate()";
	window.setInterval(sCode, t);
}

function AdBox_rotate() {
	if (++this.currentAd >= this.adImages.length) 
		this.currentAd = 0;

	var imgCollect = document.zbGetImages(this.boxLayer);
	imgCollect[this.id+"img"].src = this.adImages[this.currentAd].src;
}

function AdBox_doClick() {
	var adBox = this.owner;
	setTimeout("window.location.href = '"+adBox.adLinkUrls[adBox.currentAd]+"'", 500);
}

