/****
* Banner Ad Rotater v3.02
* Anarchos > anarchos3@hotmail.com
* http://anarchos.xs.mw/bannerad.phtml
**/

function Tout(refreshTime, width, height, altText, start, random){
	this.objName = "toutImg" + (Tout.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;
	if (random == null) this.random = 1; else this.random = random;
	this.altText = altText;
	this.imgs = [];
	if (start) this.currentImg = start-1; else start = null;
	this.mySize = 0;

	this.Img = function(src, href, target, mouseover) {
		var tempImage = new Image();
		tempImage.src = src;
		this.imgs[this.mySize] = new Object();
		var img = this.imgs[this.mySize];
		img.src = src;
		if (typeof(target) == "undefined" || target == null) img.target = "_self"; else img.target = target;
		img.href = href;
		img.mouseover = mouseover;
		this.mySize++;
	}

	this.link = function(){
		var	img = this.imgs[this.currentImg];
		if (img.target == "_self"){
			location.href = img.href;
		}
		else if (img.target == "_blank" || img.target == "_new"){
			open(img.href,this.objName + "Win");
		}
		else top.frames[img.target].location.href = img.href;
	}

	this.showStatus = function(){
		var img = this.imgs[this.currentImg];
		if (img.mouseover) status = img.mouseover;
		else status = img.href;
	}

	this.randomImg = function(){
		var n;
		do { n = Math.floor(Math.random() * (this.mySize)); } 
		while(n == this.currentImg);
		this.currentImg = n;
	}

	this.output = function(){
		var tempCode = "";
		if (this.mySize > 1){
			if (this.currentImg == null) this.randomImg();
			if (this.currentImg >= this.mySize) this.currentImg = 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.imgs[this.currentImg].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.nextImg();
		} else document.write("Error: at least two images must be defined for the script to work.");
	}

	this.newImg = function(){
		if (!this.random){	
			this.currentImg++;
			if (this.currentImg >= this.mySize)
			   this.currentImg = 0;
		}
		else {
			this.randomImg();
		}
		this.nextImg();
	}

	this.nextImg = function(){
		document.images[this.objName+ 'Img'].src = this.imgs[this.currentImg].src;
		setTimeout(this.objName+'.newImg()',this.refreshTime)
	}
}
Tout.count = 0;