var imgWidth=500;              //图片宽
var imgHeight=220;             //图片高
var textFromHeight=0;         //焦点字框高度 (单位为px)
var textStyle="f12";           //焦点字class style (不是连接class)
var textLinkStyle="p1"; //焦点字连接class style
var buttonLineOn="#ff8f33";           //button下划线on的颜色
var buttonLineOff="#dbdbdd";          //button下划线off的颜色
var TimeOut=5000;              //每张图切换时间 (单位毫秒);
var imgtext=new Array();
var imgContent=new Array();
var adNum=0;
var theTimer;
var firstTime=true;
//焦点字框高度样式表 开始
document.write('<style type="text/css">' + 
			  '#focuseFrom{width:'+(imgWidth)+';margin: 0px; padding:0px;height:'+(imgHeight+textFromHeight)+'px; overflow:hidden;}' + 
			  '#txtFrom{height:'+textFromHeight+'px;line-height:'+textFromHeight+'px;width:'+imgWidth+'px;overflow:hidden;}' + 
			  '#imgTitle{width:'+imgWidth+';top:-'+(textFromHeight+20)+'px;height:18px}' + 
			  '</style>' + '<div id="focuseFrom">');

// Modify by Hu. Jianan
// @2011-4-8
// 将广告用数组形式表达

// 这里定义广告的内容
// {@img 图片地址 @text 链接文字 @link 链接页面地址 @alt 图片替换文字}
var __adItems = [
    {img:"picture/20111229-1.jpg",text:"1",link:"http://www.jiujiajiu.cn/news/news20112134.html",alt:"1"},
	{img:"picture/20111212-1.jpg",text:"1",link:"http://www.jiujiajiu.cn/news/news20112133.html"},
	{img:"picture/banner1.jpg",text:"1",link:"http://www.jiujiajiu.cn/jiameng.html",alt:"1"},
	//{img:"picture/01.jpg",text:"1",link:"#",alt:"1"},
	{img:"picture/2011070802.jpg",text:"2",link:"#",alt:"2"}
];

var count=__adItems.length;	// 广告数量

function changeimg(n)
{
	adNum=n - 1;
	window.clearInterval(theTimer);
	//	TimeOut = 5000;
	nextAd();
	firstTime=false;
	document.getElementById("imgstart").style.display="none";
	document.getElementById("imgstop").style.display="";
}
function goUrl(){
  var link = __adItems[adNum-1].link;	// 链接地址
  link != "#" ? window.open(link,'_blank') : null;
}

function playTran(){
	//if (document.all) {
		if ( imgInit.filters.item( 0 ).Transition == 23 ){ // 改变切换样式，在23种样式中循环。
			imgInit.filters.item( 0 ).Transition = 1 ;
		}else{
			imgInit.filters.item( 0 ).Transition++ ;
		}
		imgInit.filters.item( 0 ).apply();
		imgInit.filters.item( 0 ).play();
		//imgInit.filters.revealTrans.play();
	//}
}
var key=0;

var nextAd = new function(){};

function nextAdNetscape(){
	if(TimeOut==5000) {
		if(adNum<count)adNum++ ;
		else adNum=1;
		
		var _imgSrc = __adItems[adNum - 1].img;	// 图片地址
		var _imgAlt = __adItems[adNum - 1].alt;	// 图片替换文字
		
		document.images.imgInit.src=_imgSrc;
		document.images.imgInit.alt=_imgAlt;
		document.getElementById('focustext').innerHTML=imgtext[adNum];
		//document.getElementById('advtitle').innerHTML=imgtext[adNum];
		//document.getElementById('link'+adNum).style.backgroundColor=buttonLineOn;
		document.getElementById('imglink'+adNum).src="image/num_"+adNum+"_on.gif";
		//document.getElementById('advtd'+adNum).style.backgroundColor="#ff8500";
		for (var i=1;i<=count;i++)
		{
			if (i!=adNum){
			  //document.getElementById('link'+i).style.backgroundColor=buttonLineOff;
			  document.getElementById('imglink'+i).src="image/num_"+i+"_off.gif";
			  //document.getElementById('advtd'+i).style.backgroundColor="#393939";
			}
		}
	}
	theTimer=setTimeout("nextAdNetscape()", TimeOut);

}
function nextAdIE(){
	if(TimeOut==5000) {
		if(adNum<count)adNum++ ;
		else adNum=1;

		if( key==0 ){
			key=1;
		} else if (document.all){
			playTran();
		}
		
		var _imgSrc = __adItems[adNum - 1].img;	// 图片地址
		var _imgAlt = __adItems[adNum - 1].alt;	// 图片替换文字
		
		document.images.imgInit.src=_imgSrc;
		document.images.imgInit.alt=_imgAlt;
		/*if(firstTime){}else{
			document.getElementById('advtitle').innerHTML=imgtext[adNum];
		}*/
		//document.getElementById('link'+adNum).style.backgroundColor=buttonLineOn;
		document.getElementById('imglink'+adNum).src="image/num_"+adNum+"_on.gif";
		//document.getElementById('advtd'+adNum).style.backgroundColor="#ff8500";
		for (var i=1;i<=count;i++)
		{
			if (i!=adNum){
			  //document.getElementById('link'+i).style.backgroundColor=buttonLineOff;
			  document.getElementById('imglink'+i).src="image/num_"+i+"_off.gif";
			  //document.getElementById('advtd'+i).style.backgroundColor="#393939";
			}
		}
		focustext.innerHTML=__adItems[adNum - 1].text;
	}
	theTimer=setTimeout("nextAdIE()", TimeOut);
}

function start(){
	//TimeOut = 5000;
	theTimer = setTimeout("nextAd()", TimeOut);
	document.getElementById("imgstart").style.display="none";
	document.getElementById("imgstop").style.display="";
}

function stop(){
	//TimeOut = 5000*1000;
	document.getElementById("imgstart").style.display="";
	document.getElementById("imgstop").style.display="none";
}

//NetScape开始
if (navigator.appName == "Netscape")
{
nextAd = nextAdNetscape;
document.write('<style type="text/css">');
document.write('.buttonDiv{height:4px;width:21px;}');
document.write('</style>');
document.write('<a target=_self href="javascript:goUrl()"><img style="FILTER: revealTrans(duration=1,transition=5);" src="javascript:nextAd()" width='+imgWidth+' height='+imgHeight+' border=0 vspace="0" name=imgInit class="imgClass"></a>');
document.write('<div id="txtFrom"><span id="focustext" class="'+textStyle+'"></span></div>');
document.write('<div id="imgTitle">');
document.write(' <div id="imgTitle_down">');
//数字按钮代码开始
for(var j=1;j<__adItems.length + 1;j++){document.write('&nbsp;<a href="javascript:changeimg('+j+')" style="cursor:hand" title="'+__adItems[j-1].text+'" onFocus="this.blur()"><img id="imglink'+j+'" src="image/num_'+j+'_on.gif" border="0"></a>');}
document.write('&nbsp;');
document.write('<a href="javascript:start();" style="cursor:hand" title="开始" onFocus="this.blur()"><img id="imgstart" src="image/num_play.gif" border="0" style="display:none;"></a>');
document.write('<a href="javascript:stop();" style="cursor:hand" title="暂停" onFocus="this.blur()"><img id="imgstop" src="image/num_stop.gif" border="0"></a>');
//数字按钮代码结束
document.write('</div>');
document.write('</div>');
document.write('</div>');
nextAd();
}
//NetScape结束
//IE开始
else
{
nextAd = nextAdIE;
document.write('<a target=_self href="javascript:goUrl()"><img style="FILTER: revealTrans(duration=1,transition=5);" src="javascript:nextAd()" width='+imgWidth+' height='+imgHeight+' border=0 vspace="0" name=imgInit class="imgClass"></a>');
document.write('<div id="txtFrom"><span id="focustext" class="'+textStyle+'"></span></div>');
document.write('<div id="imgTitle">');
document.write(' <div id="imgTitle_down">');
//数字按钮代码开始
//for(var i=1;i<imgUrl.length;i++){document.write('<a id="link'+i+'"  href="javascript:changeimg('+i+')" class="button" style="cursor:hand" title="'+imgAlt[i]+'" onFocus="this.blur()">'+i+'</a>');}
for(var j=1;j<__adItems.length + 1;j++){document.write('&nbsp;<a href="javascript:changeimg('+j+')" style="cursor:hand" title="'+__adItems[j-1].text+'" onFocus="this.blur()"><img id="imglink'+j+'" src="http://www.gome.com.cn/mall/red/images/num_'+j+'_on.gif" border="0"></a>');}
document.write('&nbsp;');
document.write('<a href="javascript:start();" style="cursor:hand" title="开始" onFocus="this.blur()"><img id="imgstart" src="image/num_play.gif" border="0" style="display:none;"></a>');
document.write('<a href="javascript:stop();" style="cursor:hand" title="暂停" onFocus="this.blur()"><img id="imgstop" src="image/num_stop.gif" border="0"></a>');
//数字按钮代码结束
document.write('</div>');
document.write('</div>');
document.write('</div>');
changeimg(1)
}
//IE结束

function simplePreload()
{
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

simplePreload();
