/****
* Banner Ad Rotater v3.1
* http://chrisken.utacm.org/
**/

function Banner(refreshTime, width, height, altText, start, random)
{
	this.objName = "bannerAd" + (Banner.count++);
	window[this.objName] = this;
	this.refreshTime = refreshTime || 5;
	this.width = width || 460;
	this.height = height || 68;
	this.random = random || 1;
	this.altText = altText || "banner ad";
	this.ads = [];
	this.currentAd = (start? start-1 : null);
	this.mySize = 0;

	this.Ad = function(src, href, target, mouseover, adText)
	{
		var tempImage = new Image();
		tempImage.src = src;
		this.ads[this.mySize] = new Object();
		var ad = this.ads[this.mySize];
		ad.src = src;
		if (typeof(target) == "undefined" || target == null)
		{
			ad.target = "_self";
		}
		else
		{
			ad.target = target;
		}
		ad.href = href;
		ad.mouseover = mouseover || "";
		ad.adText = adText || "";
		this.mySize++;
	}

	this.link = function()
	{
		var	ad = this.ads[this.currentAd];
		if (ad.target == "_self")
		{
			location.href = ad.href;
		}
		else if (ad.target == "_blank" || ad.target == "_new")
		{
			window.open(ad.href, this.objName + "Win");
		}
		else
		{
			top.frames[ad.target].location.href = ad.href;
		}
	}

	this.showStatus = function()
	{
		var ad = this.ads[this.currentAd];
		if (ad.mouseover)
		{
			window.status = ad.mouseover;
		}
		else
		{
			window.status = ad.href;
		}
	}

	this.randomAd = function()
	{
		var n;
		do {
			n = Math.floor(Math.random() * (this.mySize));
		} while (n == this.currentAd);
		this.currentAd = n;
	}

	this.output = function()
	{
		var tempCode = "";
		if (this.mySize > 0)
		{
			if (this.currentAd == null)
			{
				this.randomAd();
			}
			if (this.currentAd >= this.mySize)
			{
				this.currentAd = this.mySize - 1;
			}
			tempCode = '<a href="javascript:'+this.objName+'.link();"';
			tempCode += ' onmouseover="' + this.objName + '.showStatus(); return true"';
			tempCode += ' onmouseout="window.status=\'\';return true">';
			tempCode += '<img src="' + this.ads[this.currentAd].src + '" width="' + this.width;
			tempCode += '" name="' + this.objName + 'Img" height="' + this.height + '" ';
			if (this.altText)
			{
				tempCode += 'alt="' + this.altText + '" ';
			}
			tempCode += 'border="0" /></a><div id="' + this.objName + 'Div"'
				+ ' style="font-family: verdana; font-size: 8pt">'
				+ this.ads[this.currentAd].adText + '</div>';
			document.write(tempCode);
			this.nextAd();
		}
		else
		{
			document.write("Error: no banners defined.");
		}
	}

	this.newAd = function()
	{
		if (!this.random)
		{
			this.currentAd++;
			if (this.currentAd >= this.mySize)
			{
				this.currentAd = 0;
			}
		}
		else
		{
			this.randomAd();
		}
		this.nextAd();
	}

	this.nextAd = function()
	{
		document.images[this.objName+ 'Img'].src = this.ads[this.currentAd].src;
		document.getElementById(this.objName + 'Div').innerHTML = this.ads[this.currentAd].adText;
		setTimeout(this.objName+'.newAd()',this.refreshTime * 1000)
	}
}
Banner.count = 0;
