// JavaScript Document
var pd=0;
var a=0;
var js=1;
var ds;

//格式化BANNER，并优先读取第一张
function formatBanner() {
	document.getElementById("dy1").style.width=bw+"px";
	document.getElementById("dy1").style.height=bh+"px";
	document.getElementById("dy2").style.width=bw+"px";
	document.getElementById("dy2").style.height=bh+"px";
	
	
	
	document.write("<style>.sz1{font-family:Verdana, Arial, Helvetica, sans-serif; border:1px solid #FFFFFF; background-color:#FF6600; font-size:10px; font-weight:bold; color:#FFFFFF; width:15px; height:15px; text-align:center; margin-right:5px; float:left; cursor:pointer;}");
	document.write(".sz2{font-family:Verdana, Arial, Helvetica, sans-serif; border:1px solid #FFFFFF; background-color:#333333; font-size:10px; font-weight:bold; color:#FFFFFF; width:15px; height:15px; text-align:center; margin-right:5px; float:left; cursor:pointer;}</style>");
	
	document.write("<div style=\"text-align:right; z-index:10; position:absolute; margin-left:0px; margin-top:"+(bh-28)+"px; *margin-top:"+(bh-27)+"px; padding:5px; filter:alpha(opacity=70); opacity:0.7;");
	if(dispText!=0) {
		document.write(" background-color:#000000;");	
	}
	document.write("\">");
	document.write("<div id=\"ptxt\" style=\"font-family:Verdana, Arial, Helvetica, sans-serif; font-weight:bold; font-size:12px; overflow:hidden; color:#ffffff; float:left; width:"+(bw-(sNum*20)-31)+"px!important; width:"+(bw-(sNum*20)-46)+"px; text-align:left; margin-right:5px; margin-left:10px; padding-top:3px\">");
	if(dispText!=0) {
		document.write(PicText[0]);
	}
	document.write("</div>")
	if(dispSz!=0) {
		for(i=0;i<sNum;i++) {	
			document.write("<div id=\"s"+i+"\" class=\"sz2\" onclick=\"clear_time("+i+")\">"+(i+1)+"</div>");//切换点击数字显示的BANNER
		}
	}
	document.write("</div>");
	
	show(0);
}

function show(sid) {
	if(sid>sNum-1||sid<0){
		sid=0;
	}
	if(js==1){js=2}else{js=1}
	if(fname(PicURL[sid])=="SWF") {
		document.getElementById("dy"+js).innerHTML="<embed src='"+PicURL[sid]+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+bw+"' height='"+bh+"' wmode='transparent'></embed>";
	}
	else { 
		
		document.getElementById("dy"+js).innerHTML="<img src='"+PicURL[sid]+"' width='"+bw+"' height='"+bh+"'>";
	}
	showbanner(sid);
}

function clear_time(sid) {
	clearTimeout(i_timer);
	show(sid);
}

//BANNER循环
function showbanner(sid) {
	if(dispSz!=0) {
		for(i=0;i<sNum;i++){
			document.getElementById("s"+i).className="sz2";
		}
		document.getElementById("s"+sid).className="sz1";
	}
	xx=document.getElementById("dy1").style.zIndex;
	document.getElementById("dy1").style.zIndex=document.getElementById("dy2").style.zIndex;
	document.getElementById("dy2").style.zIndex=xx;
	showa(sid);
}

function showa(sid) {
	if(a < 100)
	{
		a=a+20;
		ff=a/100;
		document.getElementById("dy"+js).style.opacity = ff;
		document.getElementById("dy"+js).style.filter = "alpha(opacity="+a+")";
		timer=setTimeout("showa("+sid+")", speed);
	}
	else
	{
	  	a=0;
		clearTimeout(timer);
				
		document.getElementById("dy"+js).onclick=function(){location.href=LinkURL[sid]};
		if(dispText!=0) {
			document.getElementById("ptxt").innerHTML=PicText[sid];
		}
		i_timer=setTimeout("show("+(sid+1)+")", timeout);
	}
}

//获取文件后缀名
function fname(f) {
	ff=f.substr(f.length-3,3);
	return ff.toUpperCase();
}