/****
* BAR v3.02
* Anarchos > anarchos3@hotmail.com
* http://anarchos.xs.mw/bannerad.phtml
**/

function Anuncio(refreshTime, altText,random){
	this.objName = "myPhoto" + (Anuncio.count++);
	eval(this.objName + "=this");
	if (!refreshTime) this.refreshTime = 5000; else this.refreshTime = refreshTime*1000;
	if (random == null) this.random = 1; else this.random = random;
	this.altText = altText;
	this.photos = [];
	//if (start) this.currentAd = start-1; else start = null;
	this.mySize = 0;
	this.currentPhoto = null; 
	

	this.Photo = function(src, href,target, mouseover) {
		var tempImage = new Image();
		tempImage.src = src;
		this.photos[this.mySize] = new Object();
		var photo = this.photos[this.mySize];
		photo.src = src;
		if (typeof(target) == "undefined" || target == null) photo.target = "_self"; else photo.target = target;
		photo.href = href;
		photo.mouseover = mouseover;
		this.mySize++;
	}

	this.link = function(){
		var	photo = this.photos[this.currentPhoto];
				if (photo.target == "_self"){
					location.href = photo.href;
				}
				else if (photo.target == "_blank" || photo.target == "_new"){
					open(photo.href,this.objName + "Win");
				}
				else top.frames[photo.target].location.href = photo.href;
	}

	this.showStatus = function(){
		var photo = this.photos[this.currentPhoto];
		if (photo.mouseover) status = photo.mouseover
		else status = photo.href;
	}

	this.randomPhoto = function(){
		var n;
		do { n = Math.floor(Math.random() * (this.mySize)); } 
		while(n == this.currentPhoto);
		this.currentPhoto = n;
	}

	this.output = function(){
		var tempCode = "";
		if (this.mySize > 1){
			if (this.currentPhoto == null) this.randomPhoto();
			if (this.currentPhoto >= this.mySize) this.currentPhoto = 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.photos[this.currentPhoto].src + '"';
			tempCode += ' name="' + this.objName + 'Img" ';
			if (this.altText) tempCode += 'alt="'+this.altText + '" ';
			tempCode += 'border="0" /></a>';
			document.write(tempCode);
			this.nextPhoto();
		} else document.write("Error: two banners must be defined for the script to work.");
	}

	this.newPhoto = function(){
		if (!this.random){	
			this.currentPhoto++;
			if (this.currentPhoto >= this.mySize)
			   this.currentPhoto = 0;
		}
		else {
			this.randomPhoto();
		}
		this.nextPhoto();
	}

	this.nextPhoto = function(){
		document.images[this.objName+ 'Img'].src = this.photos[this.currentPhoto].src;
		setTimeout(this.objName+'.newPhoto()',this.refreshTime)
	}
}
Anuncio.count = 0;