/*

Banner-Rotator by aNUbit.at (http://anubit.at/)

... because all other rotators we found are crap.

*/

function BannerRotator(id)
{
	this.id = id;
	this.bannerIdx = -1;
	this.items = [];
}

BannerRotator.prototype.add = function(type, src, width, height, href, duration)
{
	this.items.push(new Banner(type, src, width, height, href, duration));
}

function Banner(type, src, width, height, href, duration)
{
	this.type = type;
	this.src = src;
	this.width=width;
	this.height=height;
	this.href=href;
	this.duration=duration;
}

Banner.prototype.toString = function()
{
	var retVal = '';
	
	switch(this.type)
	{
		case 'IMG':
			retVal = '<img src="' + this.src + '" width="' + this.width + '" height="' + this.height + '" border="0" />';
			break;
		case 'SWF':
			retVal = '<object width="' + this.width + '" height="' + this.height + '" data="'
					+ this.src + '" type="application/x-shockwave-flash"><param name="movie" value="'
					+ this.src + '"></object>';
			break;			
	}
	
	if(this.href != '')
		retVal = '<a target="_blank" href="' + this.href + '">' + retVal + '</a>';
	
	return(retVal);
}

BannerRotator.prototype.showHere = function()
{
	document.write('<div id="' + this.id + '"></div>');
	this.rotate();
}

BannerRotator.prototype.rotate = function()
{
	if(this.items.length == 0)
		alert('No Banners specified');
	else
	{
		rotatorObj = document.getElementById(this.id);
		
		this.bannerIdx++;
		
		if(this.bannerIdx >= this.items.length)
			this.bannerIdx = 0;
		
		rotatorObj.innerHTML = this.items[this.bannerIdx].toString();		
		
		window.setTimeout(this.id + '.rotate()', this.items[this.bannerIdx].duration*1000);
	}
}