var adNum=0;
var buttonShow=1;//显示按扭开关 1:显示 0:不显示
if(imgUrl.length>2) buttonShow=1; else buttonShow=0; //自动判断是否显示按扭
//var buttonPos=1;//按扭显示位置 1:右上 2:右下 3:左上 4:左下
var buttonX;//按扭X坐标
var buttonY;//按扭Y坐标

var imgPre=new Array();
var dakularCode="";//将生成按扭HTML代码
var adNum=0;

for (i=1;i<6;i++)

{
	imgPre[i]=new Image();
	imgPre[i].src=imgUrl[i];
}

function setTransition()
{
	if (document.all)
	{
		imgUrlrotator.filters.revealTrans.Transition=10//Math.floor(Math.random()*23)
		imgUrlrotator.filters.revealTrans.apply();
	}
}

function playTransition()
{
	if (document.all)
	imgUrlrotator.filters.revealTrans.play();
}

function nextAd(toNum)
{
	if(adNum<imgUrl.length-1)
	adNum++ ;
	else
	adNum=1;
	if(toNum!=null) adNum=toNum;
	setTransition();
	
	document.images.imgUrlrotator.src=imgUrl[adNum];
	document.images.imgUrlrotator.alt=text[adNum];
	//如果要显示文字标题，取消下面的注释
	document.getElementById('linktext').innerHTML=text[adNum]; 
	playTransition();
	if(buttonShow==1){checkButton();}
	if(toNum!=null) toNum=null;
	theTimer=setTimeout("nextAd()", 6000);
}

function jump2url()
{
	jumpUrl=imgLink[adNum];jumpTarget='_blank';
	if (jumpUrl != '')
	{
		if (jumpTarget != '')
		window.open(jumpUrl,jumpTarget);
		else location.href=jumpUrl;
	}
}

function displayStatusMsg()
{
	status=imgLink[adNum];
	document.returnValue = true;
	}

function checkButton()
{
	for(i=1;i<=imgUrl.length-1;i++)
		{if(i==adNum)
		//document.getElementById('bt'+i).style.backgroundColor='#00FF00';
		eval("bt"+i+".style.backgroundColor='#ffffff';bt"+i+".style.color='#2A2A2A';");
		else
		eval("bt"+i+".style.backgroundColor='#2A2A2A';bt"+i+".style.color='#ffffff';");
		}
	}

function dakularButtons()
{if(buttonShow==1){
	//table的定位样式，用以消除错位的Bug!
	document.getElementById('newsTable').style.position="relative";
	document.getElementById('newsTable').style.top="-10px";
	switch(buttonPos){
		case 1:{buttonX=220-imgUrl.length*8;buttonY=8;break;}
		case 2:{buttonX=220-imgUrl.length*15;buttonY=220;break;}
		case 3:{buttonX=imgUrl.length*10-150;buttonY=15;break;}
		case 4:{buttonX=imgUrl.length*2-10;buttonY=125;break;}
		default:{buttonX=220-imgUrl.length*20;buttonY=15;break;}
		}
	for(i=1;i<=imgUrl.length-1;i++)
		{
		dakularCode=dakularCode+"<div id='bt"+i+"' style='display:inline; margin-left: 3px;padding:0 5px 0 5px; border:1px solid #ffffff; background-color:#CCCCCC; color:#003B5A; filter: Alpha(Opacity=100);' align='center' onMouseOver=this.style.backgroundColor='#FFFFFF';this.style.color='#014EA5';this.style.cursor='hand' onMouseOut=checkButton(); onClick='clearTimeout(theTimer);nextAd("+i+");'>"+i+"</div>";
		}
	dakularCode="<div style='display:inline; position:relative;left:"+buttonX+"px; top:"+buttonY+"px; z-index:1;'>"+dakularCode+"</div>"
	document.write(dakularCode);
	 }
	}