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+"' class='ads'></div>");
	delete this.container;
	this.container=eval(contianerID);
	
	this.imgSelector = document.createElement("div");
	var imgSelectorID = "TBannerContainer_"+this.imgSelector.uniqueID;
	document.write("<div id='"+imgSelectorID+"'></div>");
	delete this.imgSelector;
	this.selector = eval(imgSelectorID);
	this.selector.className = "adsSelector";
			
	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=982;
	this.image.height=260;
	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.makeLinks();
	}
	
	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???

		for(var i=0;i<this.images.length;i++){
			if(i==this.index){
				document.getElementById("adsLink"+this.index).className = "adslNow";
			}
			else{
				document.getElementById("adsLink"+i).className = "";
			}
		}

		//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);
		//obj.filters[0].Transition = 23
	}
		
	//show next banner
	this.switchBanner = function()
	{
		var banner=this;
		if (banner.index<banner.urls.length)//change link
			banner.link.href=banner.urls[banner.index];
		else
		{
			if (banner.urls[0]!=null)
			{
				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;
	}
	//make links buttons
	this.makeLinks=function(){
		for(var i=0;i<this.images.length;i++)
		{
					
			var link=window.document.createElement("a");
			link.innerText = i+1;
			link.href = "javascript:banner_test.changeLink("+i+")";
			link.id = "adsLink"+i;
			if(i==0)
			{
				link.className = "adslNow";
			}
			
			this.selector.appendChild(link);
			
		}
	}
//change link
	this.changeLink=function(n){
		this.stop();
		this.index = n;
		this.play();
		this.start();
	}
}

	

////////////////////////////////////////////////////////////////////
function changLink(n){
	for(var i=1;i<7;i++)
	{
		if(i==n)
		{
			document.getElementById(i).className="now";
		}
		else{
			document.getElementById(i).className="";
		}
	}
}