function TextBannerInfo(linkURL, linkText, sid){
	this.linkText = linkText;
	this.linkURL = linkURL;
	this.sid = sid;
}

function TextBannerObject(bArr, divObj, sec){
	this.XmlHttpObject = bannerGetXmlHttp_Object();
	this.bannerArray = bArr;
	this.divObject = divObj;
	this.second = sec;
	
	this.i = -1;
	
	this.play = function (){
		try{
			if(this.bannerArray.length == 0)return;
			if (this.i == (bArr.length - 1))
			{this.i=0;}
			else
			{this.i++;}
			var textBannerLink = divObj.getElementsByTagName("A");
			
			if(textBannerLink.length > 0){
				if(browser_type() == "ie"){
					textBannerLink[0].filters.revealTrans.apply();
					textBannerLink[0].href = this.bannerArray[this.i].linkURL;
					textBannerLink[0].innerHTML = this.bannerArray[this.i].linkText;
					textBannerLink[0].filters.revealTrans.play();
				}else{
					textBannerLink[0].href = this.bannerArray[this.i].linkURL;
					textBannerLink[0].innerHTML = this.bannerArray[this.i].linkText;
				}
			}
			
//			this.XmlHttpObject.open("GET", "ad/onlinetime.html?sid=" + this.bannerArray[this.i].sid, true);
		    this.XmlHttpObject.setRequestHeader("If-Modified-Since","0");
			this.XmlHttpObject.send(null);
		}catch(e){
//			alert(e);
		}
	}
}

function BannerInfo(linkURL, imgURL, altText, sid){
	this.imgURL = imgURL;
	this.linkURL = linkURL;
	this.altText = altText;
	this.sid = sid;
}

function BannerObject(bArr, divObj, sec){
	this.XmlHttpObject = bannerGetXmlHttp_Object();
	this.bannerArray = bArr;
	this.divObject = divObj;
	this.second = sec;
	
	this.i = -1;
	
	this.play = function (){
		try{
			if(this.bannerArray.length == 0)return;
			if (this.i == (bArr.length - 1))
			{this.i=0;}
			else
			{this.i++;}
			var bannerImg = divObj.getElementsByTagName("img");
			var bannerLink = divObj.getElementsByTagName("a");
			
			if(bannerImg.length > 0 && bannerLink.length > 0){
				if(browser_type() == "ie"){
					bannerImg[0].filters.revealTrans.apply();
					bannerImg[0].src = this.bannerArray[this.i].imgURL;
					bannerLink[0].href = this.bannerArray[this.i].linkURL;
					bannerImg[0].alt = this.bannerArray[this.i].altText;
					bannerImg[0].title = this.bannerArray[this.i].altText;
					bannerImg[0].filters.revealTrans.play();
				}else{
					bannerImg[0].src = this.bannerArray[this.i].imgURL;
					bannerLink[0].href = this.bannerArray[this.i].linkURL;
					bannerImg[0].alt = this.bannerArray[this.i].altText;
					bannerImg[0].title = this.bannerArray[this.i].altText;
				}
			}
			
//			this.XmlHttpObject.open("GET", "ad/onlinetime.html?sid=" + this.bannerArray[this.i].sid, true);
		    this.XmlHttpObject.setRequestHeader("If-Modified-Since","0");
			this.XmlHttpObject.send(null);

		}catch(e){
//			alert(e);
		}
	}
}

function bannerControl(){
	this.banners = new Array();
	
	this.addBanner = function (bArr, divObj, sec){
		this.banners.push(new BannerObject(bArr, divObj, sec));
	}
	
	this.addTextBanner = function (bArr, divObj, sec){
		this.banners.push(new TextBannerObject(bArr, divObj, sec));
	}
	
	var index = 0;
	var playInterval;
	
	var toPlay = function(){
		try{
			doPlay(bControl.banners[index], bControl.banners[index].second);
			index++;
			if(index == bControl.banners.length){
				window.clearInterval(playInterval);
			}
		}catch(e){}
	}
	
	this.play = function (){
		try{
			playInterval = window.setInterval(toPlay, 1000);
		}catch(e){}
	}
}

function doPlay(banner, sec){
	var play = function(){
		banner.play();
	};
	
	window.setInterval(play, sec * 1000);
}

var bControl = new bannerControl();

function bannerGetXmlHttp_Object(){
	var isIE=document.all?1:0;
	
	var xmlhttp = null; 
	
	if(isIE){
		try { 
		    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
		}catch(e){ 
		    try { 
		        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
		    }catch(e2){} 
		} 
	}else{
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

