/****
* Banner Ad Rotater v3.02
* Modified by Bax - so that begin banner display at random number banner, then proceed sequentially (alphabetically 
* through banners.
*
* Original Author: Anarchos > anarchos3@hotmail.com > http://anarchos.xs.mw/bannerad.phtml
* Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/
**/

function fill_in_banners(){
// Parameters:  myAd.Ad(image source file, web site URL, target, mouseover text) 
// Bax:  place ads in alphabetical order
myAd.Ad( "greater_north_fulton_coc_logo.gif", "http://www.gnfcc.com/", "blank", "Greater North Fulton Chamber of Commerce");
myAd.Ad( "drake_house_logo.gif", "http://www.thedrakehouse.org/", "blank", "The Drake House");
;
return true;

}

function Banner(refreshTime, width, height, altText, start, random){
// parameters:
//1: time between rotations (seconds), 
//2: width of image
//3: height of image, 
//4: alt text, 
//5: starting banner, and rycca changed to randomly picked ad
//6: random (0 means it iterates through banners, 1 means it randomly picks the next banner

	var NumberofBannersHave = 2;  //BAX - keep value updated, for max value for random calculation

	this.objName = "bannerAd" + (Banner.count++);
	eval(this.objName + "=this");
	if (!refreshTime) 
		this.refreshTime = 5000; 
	else 
		this.refreshTime = refreshTime*1000;
		
	if (!width) 
		this.width = 460; 
	else 
		this.width = width;
		
	if (!height) 
		this.height = 68; 
	else 
		this.height = height;
		
	// BAX - set to 0 to display images sequentially
	this.random = 0; 
		
	this.altText = altText;
	this.ads = [];
	
	//BAX - set start banner to randomly generated number
	if (start) 
		this.currentAd = (Math.round(Math.random() * NumberofBannersHave));
	else 
		start = null;
	
	this.mySize = 0;
	this.Ad = function(src, href, target, mouseover) {
		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;
		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"){
			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) 
			status = ad.mouseover;
		else 
			status = ad.href;
	}

	this.randomAd = function(){
		var n;
		
		// Bax - changed to use round, instead of floor function
	    do { n = (Math.round(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 = '<a href="javascript:'+this.objName+'.link();"';
			tempCode += ' onMouseOver="' + this.objName + '.showStatus(); return true"';
			tempCode += ' onMouseOut="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>';
			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;

