/*
*	图片轮换代码 V1.0.0.0
*	created:	2007-8-10
*	laoqiming@gmail.com
*/
if (typeof RolloverManager !="object")
{
	RolloverManager=new Array();
}

function Rollover(ImageID,Files){
	this.ImageID=ImageID;
	RolloverManager[this.ImageID] = this;
	this.Files=Files;
	this.Position=0;
	this.Interval=4;
	this.timer={};
	this.play=function(){
		var oImg = document.getElementById(this.ImageID);
		if (document.all){oImg.filters.blendTrans.apply();}
		this.Position = (this.Position<this.Files.length)?this.Position:0;
		oImg.src=this.Files[this.Position].src;
		if(this.Files[ this.Position ].link){
			var _self = this;
			var ps = this.Position;
			oImg.onclick=function(){ window.location = _self.Files[ ps ].link };
		}
		if (document.all){oImg.filters.blendTrans.play();}
		this.Position++;
		this.timer = setTimeout('RolloverManager["' + this.ImageID + '"].play();',this.Interval *1000);
	}
	this.stop = function(){ clearTimeout(this.timer) }
	this.init=function(){
		var _self = this;
		if(typeof document.addEventListener=="undefined"){
			document.getElementById(this.ImageID).attachEvent("onmouseover",function(){ _self.stop() });
			document.getElementById(this.ImageID).attachEvent("onmouseout",function(){ _self.play() });
			document.getElementById(this.ImageID).style.cursor="pointer";
			var duration=Number(this.Interval/2).toFixed();
			duration = duration < 1 ? 1 : duration;
			document.getElementById(this.ImageID).style.filter="blendTrans(duration=" + duration + ")";
		}else{
			document.getElementById(this.ImageID).addEventListener("mouseover",function(){ _self.stop() },false);
			document.getElementById(this.ImageID).addEventListener("mouseout",function(){ _self.play() },false);
			document.getElementById(this.ImageID).style.cursor="pointer";
		}
		this.play();
	}
	if(this.Position<this.Files.length){
		document.getElementById(this.ImageID).src=this.Files[this.Position].src;
		if(this.Files[this.Position].link)
			document.getElementById(this.ImageID).onclick=function(){window.location=this.Files[this.Position++].link };
	}
}