//var objRA= new RollAnimation("div1",320,150,[["告诉你我有多爱你-蔡健东","","/Play/12-1-gaosuniwoyouduoaini-caijiandong.html"],["怎么说走就走-蔡健东","","/Play/11-1-zenmeshuozoujiuzou-caijiandong.html"]]);
//objRA.StartTimer();

//RollAnimation(实例名,要放在哪个位置的ID名称,宽度,高度,[[文字,图片,网址]])
function RollAnimation(backName,PlaceName,nWidth,nHeight,gether){
	var objPlace=document.getElementById(PlaceName);
	if(objPlace==null){alert('初始滚动动画失败，位置ID不能为空！');return;}
	objPlace.style.width=nWidth+"px";
	objPlace.style.height=nHeight+"px";
	var me=this;
	this.AdTimer;
	this.Index=0;
	this.arrText=[];
	this.arrPic=[];
	this.arrLink=[];
	this.getherL=-1;
	this.gnLocationWidth=20;

    //过滤图片地址为空/网址为空/文字为空的
	for(var i=0,len=gether.length;i<len;i++){//>
		if(!(gether[i] instanceof Array) || gether[i][0]=="" || gether[i][1]=="" || gether[i][2]=="")continue;
		me.arrText.push(gether[i][0]);
		me.arrPic.push(gether[i][1]);
		me.arrLink.push(gether[i][2]);
		this.getherL++;
	}
	this.CreateDiv=function(){
	    var sTemplate='<div id="#name#DivRect" style="width:#width#px;height:#height#px;overflow:hidden;position:absolute;z-index:1">';
	    sTemplate+='<a id="#name#LinkActive" target="_blank" href="#" style="width:#width#px;height:#height#px;text-decoration:none;font-size:12px;font-weight:bold"><img id="#name#ImgActive" src="#firstpic#" style="FILTER: RevealTrans(duration=1;ransition=12);width:#width#px;border:0px;visibility:visible;position:absolute;z-index:2" />';
	    sTemplate+='<span style="display:block;width:100%;height:40px;filter:alpha(opacity=40);opacity:0.4;background-color:black;position:absolute;z-index:90;margin-top:'+(nHeight-40)+'px"></span>';
	    sTemplate+='<span style="position:absolute;z-index:91;width:97%;color:white;margin:3px;text-indent:10px;break-word:break-all;margin-top:'+(nHeight-35)+'px" id="#name#SpanText">V符音乐</span>';
	    sTemplate+='</a></div><div id="#name#AdLocation" style="width:#width#px;position:absolute;z-index:2;margin-top:'+(nHeight-15)+'px;"></div>';

	    sTemplate=sTemplate.replace(/#width#/g,nWidth);
	    sTemplate=sTemplate.replace(/#height#/g,nHeight);
	    sTemplate=sTemplate.replace(/#name#/g,objPlace.id);
	    sTemplate=sTemplate.replace(/#firstpic#/g,me.arrPic[0]);
	    objPlace.innerHTML=sTemplate;
	}
	this.InitLocation=function(iI){
		var AdLocation=document.getElementById(objPlace.id+"AdLocation");
		var sTemp="<div style='float:right'>";
		var II=iI-1
		for(var i=0,len=me.getherL+1;i<len;i++){//>
				if(iI==i){ sTemp+="<span onclick=\""+backName+".SetIndex("+i+")\" style=\"display:block;float:left;width:"+me.gnLocationWidth+"px;cursor:hand;background-color:#2d2d2d;text-decoration:none;text-align:center;font-size:12px;line-height:15px;font-weight:bold;color:white;cursor:pointer;\">"+(i+1)+"</span>";
				}else{ sTemp+="<span onclick=\""+backName+".SetIndex("+i+")\" style=\"display:block;float:left;width:"+me.gnLocationWidth+"px;cursor:hand;background-color:#dddddd;filter:alpha(opacity=40);opacity:0.4;color:black;text-decoration:none;text-align:center;font-size:12px;line-height:15px;cursor:pointer;\">"+(i+1)+"</span>";}
		}
		AdLocation.innerHTML=sTemp+"</div>";
	}
	this.ChangePic=function (I){
		var imgActive=document.getElementById(objPlace.id+"ImgActive");
		var spanText=document.getElementById(objPlace.id+"SpanText");
		var linkActive=document.getElementById(objPlace.id+"LinkActive");
		try{
			imgActive.filters.revealTrans.transition=Math.floor(Math.random()*23);
			imgActive.filters.revealTrans.apply();
		}catch(err){}

		imgActive.src=me.arrPic[I];
		try{imgActive.filters.revealTrans.play();}catch(err){};
		linkActive.href=me.arrLink[I];
		spanText.innerHTML=me.arrText[I];
		me.InitLocation(I);

 		me.Index++;
		if(me.Index>me.getherL){ me.Index=0;}
	}
	this.Run=function(){
		if(me.getherL==-1){return;}
		this.CreateDiv();
		me.ChangePic(me.Index);
		me.StartTimer();
	}
	this.SetIndex=function (iI){
		me.ClearTimer();
		me.ChangePic(iI)
		me.StartTimer();
	}
	this.StartTimer=function(){me.AdTimer=setInterval(function(){me.ChangePic(me.Index)},3000);}
	this.ClearTimer=function (){clearInterval(me.AdTimer);}
}




