// JavaScript Document for the rotating images on the top of the site

function Banner(refreshTime, width, height, altText, start, random){

	this.objName = "bannerAd" + (Banner.count++);

	eval(this.objName + "=this");

	if (!refreshTime) this.refreshTime = 5000; else this.refreshTime = refreshTime*1000;

	if (!width) this.width = 205; else this.width = width;

	if (!height) this.height = 150; else this.height = height;

	if (random == null) this.random = 1; else this.random = random;

	this.altText = altText;

	this.ads = [];

	if (start) this.currentAd = start-1; else start = null;

	this.mySize = 0;



	this.Ad = function(src) {

		var tempImage = new Image();

		tempImage.src = src;

		this.ads[this.mySize] = new Object();

		var ad = this.ads[this.mySize];

		ad.src = src;

		this.mySize++;

	}



	this.link = function(){

		var ad = this.ads[this.currentAd];

	}



	this.showStatus = function(){

		var ad = this.ads[this.currentAd];

	}



	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 > 1){

			if (this.currentAd == null) this.randomAd();

			if (this.currentAd >= this.mySize) this.currentAd = this.mySize - 1;

			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>';

			document.write(tempCode);

			this.nextAd();

		} else document.write("Error: two banners must be defined for the script to work.");

	}



	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;

		setTimeout(this.objName+'.newAd()',this.refreshTime)

	}

}

Banner.count = 0;