function TBanner()
{
	//create a contianer
	//====================================	
	this.container=document.createElement("div");
	//document.body.appendChild(this.banner); //this cannot work at unstandard env.
	var contianerID="TBannerContainer_"+this.container.uniqueID;
	document.write("<div id='"+contianerID+"'></div>");
	delete this.container;
	this.container=eval(contianerID);
			
	this.image=window.document.createElement("img");
	this.link=window.document.createElement("a");
	
	this.container.appendChild(this.link);
	this.link.appendChild(this.image);	
	//====================================
	
	this.id="banner_"+this.container.uniqueID;
	eval(this.id+"=this");//set the REAL bannerid as this object

	this.container.style.filter="revealTrans(Duration=2.0,Transition=1)";
	this.container.margin=0;
	this.container.padding=0;
	
	this.image.border=0;
	this.image.width=950;
	this.image.height=235;
	this.image.style.filter=this.container.style.filter;
	this.image.alt=this.id;
	
	this.link.target="_blank";	
	
	this.index=0;
	this.delaytime=5000;
	this.timer=null;

	
	//public:

	this.init = function(basepath,images,urls)
	{
		this.imagebasepath=basepath;
		this.images=images;
		this.urls=urls;
		this.PreloadImages(images);
					
		this.switchBanner();//show first banner
	}
	
	this.start = function(delaytime)
	{	
		this.delaytime=(delaytime==null)?this.delaytime:delaytime;
		this.timer=setInterval(this.id+".play()",this.delaytime);
	}
	
	this.stop = function()
	{
		window.clearTimeout(this.timer);
		this.timer=null;
	}
	
	this.setEffect = function(filter,fnSwitch)
	{
		this.container.style.filter=filter;
		this.image.style.filter=filter;
		this.switchEffect=(fnSwitch==null)?function(){}:fnSwitch;
	}
		
	//switch to next banner and play effection
	this.play = function()
	{
		obj=this.image;//this.container doesn't work, why???
		//obj.style.visibility="hidden";
		obj.filters[0].Apply();
		this.switchBanner();
		obj.style.visibility="visible";
		obj.filters[0].Play();		
		
		this.switchEffect(obj);
	};
	
	
	//private:
	
	//default Effect Action
	this.switchEffect = function(obj)
	{
		obj.filters[0].Transition = Math.floor(Math.random() * 23);
	}
		
	//show next banner
	this.switchBanner = function()
	{
		var banner=this;
		if (banner.index<banner.urls.length){//change link
			if (banner.urls[banner.index]!="")
			{
				banner.link.disabled=false;
				banner.link.href=banner.urls[banner.index];
				banner.link.target="_target";
			}
			else
			{
				banner.link.href="#";
				banner.link.target="_self";
				banner.link.disabled=true;
			}
		}
		else
		{
			if (banner.urls[0]!="")
			{
				banner.link.href=banner.urls[0];
				banner.link.title=banner.link.href;
				banner.link.disabled=false;
				banner.link.target="_self";
			}
			else
			{
				banner.link.href="#";
				banner.link.target="_self";
				banner.link.disabled=true;
			}
		}
		banner.image.src=banner.imagebasepath+banner.images[banner.index];

		banner.index++;
		if(banner.index >= banner.images.length)banner.index=0;
	}	

	//Load images before play
	this.PreloadImages = function(images)
	{
		var preloadedimages=new Array()
		for (i=0;i<images.length;i++)
		{
			preloadedimages[i]=new Image()
			preloadedimages[i].src=images[i];
		}
		delete preloadedimages;
	}
}
