var config = new Array();
config['time'] = 5000;
config['imgwidth'] = 250;
config['imgheight'] = 180;


var adNum=0;
var rolateImage = new Array(
    {
      "title":"高行镇慰问世博安保部队",
      "src":"/assets/images/photo/2010-06-10-10-54-38-rlpy.jpg",
      "href":"http://www.gaohang.gov.cn/index.php?id=1503"
    },{
      "title":"高行镇举行第八次市民沙龙活动",
      "src":"assets/images/shiminshalongeighth.jpg",
      "href":"http://www.gaohang.gov.cn/index.php?id=637"
    },{
      "title":"高行镇召开深入学习实践科学发展观活动总结大会 ",
      "src":"assets/images/photo/kexuefazhanzongjie.jpg",
      "href":"http://www.gaohang.gov.cn/index.php?id=1179"
    },{
      "title":"高行镇人大组织代表调研和视察城市管理工作",
      "src":"/assets/images/photo/2010-07-12-15-28-29-jzhm.jpg",
      "href":"http://www.gaohang.gov.cn/index.php?id=1532"
    });

var preloadedimages=new Array();
for (i=0;i<rolateImage.length-1;i++)
{
	preloadedimages[i]=new Image();
	preloadedimages[i].src=rolateImage[i].src;
}

function setTransition()
{
	if (document.all)
	{
		document.images.bannerADrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23);
		document.images.bannerADrotator.filters.revealTrans.apply();
	}
}

function playTransition()
{
	if (document.all)
	{
		document.images.bannerADrotator.filters.revealTrans.play();
	}
}
function scrollStart()
{
	theTimer=setTimeout("nextAd()", config['time']);
	document.getElementById("a_0").style.background="#c00";
}

function nextAd()
{
	if(adNum<rolateImage.length-1)
	{
		adNum++ ;
	}
	else
	{
		adNum=0;
	}
	setTransition();
	document.images.bannerADrotator.src=rolateImage[adNum].src;
	playTransition();
	changeImageInfo(adNum);
	theTimer=setTimeout("nextAd()", config['time']);
}

function changeImageInfo(adNum)
{
	document.getElementById("a_scroll_title").innerHTML=rolateImage[adNum].title;
	document.getElementById("a_scroll_title").href=rolateImage[adNum].href;
	document.getElementById("a_scroll_title").title=rolateImage[adNum].title;
	document.getElementById("img_scroll").alt=rolateImage[adNum].title;
	document.getElementById("a_scroll").href=rolateImage[adNum].href;
	for(var i=0;i<rolateImage.length;i++)
	{
		if(i==adNum)
		{
			document.getElementById("a_"+i).style.background="#c00";//亮
		}
		else
		{
			document.getElementById("a_"+i).style.background="";//不亮
		}
	}
}

function showAd(index)
{
	adNum=index;
	setTransition();
	document.images.bannerADrotator.src=rolateImage[adNum].src;
	playTransition();
	changeImageInfo(adNum);
}

function initAd()
{
  var s = '<table border="0" cellspacing="0" cellpadding="0">';
  s += '  <tr>';
  s += '  <td class="picnews">';
  s += '    <a target="_blank" id="a_scroll" href="blank"><img id="img_scroll" style="FILTER: revealTrans(duration=3,transition=100)" width="250" height="180" border="0"  name="bannerADrotator" alt="anbcdefghijklmnop" /></a>';
  s += '    <div class="no">';
	for(var i=0;i<rolateImage.length;i++){
  s += '      <a id="a_'+i+'" href="javascript:void(0)" onmouseover="javascript:clearTimeout(theTimer);showAd('+i+');" onmouseout="theTimer=setTimeout(\'nextAd()\', '+config['time']+');">'+(i+1)+'</a>';
  }
  s += '    </div>';
  s += '    <h4><a target="_blank" id="a_scroll_title" href="#" class="flashtitle" title="">0101010101</a><a class="more" href="http://www.gaohang.gov.cn/index.php?id=307" target="_blank" title="更多">&lt;&lt; 更多</a></h4>';
  s += '  </td>';
  s += '</tr>';
  s += '</table>';

  document.write(s);

  adNum=0;
  document.images.bannerADrotator.src=rolateImage[adNum].src;
  changeImageInfo(adNum);
  scrollStart();
}

initAd();
