
//Ad Data Init
var adBlankImg="http://plug.csonline.com.cn/WebTemplate/Img/Blank.gif";
var adTempTimeAry=(adTimeAry==null)?new Array():adTimeAry;
var adTempDataAry=(adDataAry==null)?new Array():adDataAry;
var adTimeAry=adTempTimeAry;
var adDataAry=adTempDataAry;
adTimeAry['Single']=null;

adDataAry['Single']=new Array('138','Single','','0','0','');

//Ad Function

function SwitchPhoto_Single(CodeName,adData,WidthNum,HeightNum,PassNum,isText)
{
    try
	{
	    var adDataTempAry=adData.split('$');
	    var adDataAry=new Array(adDataTempAry.length);
	    for(var i=0;i< adDataAry.length;i++)
	    {
	        adDataAry[i]=adDataTempAry[i].split('|');
	    }
	    var PlayNum=1;		
		var Pcount=adDataAry.length-1;
		if(PassNum!=null){
			PlayNum=parseInt(PassNum)+1;
			if(PlayNum>Pcount)PlayNum=1;
		}else{
			PlayNum=parseInt(Math.random()*Pcount)+1;
		}
		//
		var Ptype=adDataAry[PlayNum-1][1];
		var Photo=adDataAry[PlayNum-1][2];
		var Url=adDataAry[PlayNum-1][3];
		var Level=adDataAry[PlayNum-1][4];
		var Ptime=adDataAry[PlayNum-1][5];
		var Intro=adDataAry[PlayNum-1][6];		
		var Auto=adDataAry[PlayNum-1][7];
		//如果要支持Flash连接要开启 wmode='transparent',降低Flash优先度 wmode='opaque'
		var InnerHtmlCont="";
		if(Ptype=="GIF")InnerHtmlCont="<img src='"+Photo+"' id='"+CodeName+"_GIF' width='"+WidthNum+"' height='"+HeightNum+"' border='0'>";
		if(Ptype=="SWF")InnerHtmlCont="<embed src='"+Photo+"' id='"+CodeName+"_SWF' width='"+WidthNum+"' height='"+HeightNum+"' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed>";
		if(Ptype=="SWFT")InnerHtmlCont="<embed src='"+Photo+"' id='"+CodeName+"_SWFT' width='"+WidthNum+"' height='"+HeightNum+"' type='application/x-shockwave-flash' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed>";
		if(Ptype=="SWFO")InnerHtmlCont="<embed src='"+Photo+"' id='"+CodeName+"_SWFO' width='"+WidthNum+"' height='"+HeightNum+"' type='application/x-shockwave-flash' wmode='opaque' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed>";
		if(Ptype=="MMS")InnerHtmlCont="<embed src="+Photo+" id='"+CodeName+"_MMS' width='"+WidthNum+"' height='"+HeightNum+"' type='application/x-mplayer2' console='Clip1' controls='IMAGEWINDOW,StatusBar' enablecontextmenu='0' showcontrols='0' showstatusbar='1' autostart='1'></embed>";
		if(Ptype=="RTSP")InnerHtmlCont="<embed src="+Photo+" id='"+CodeName+"_RTSP' width='"+WidthNum+"' height='"+HeightNum+"' type='audio/x-pn-realaudio-plugin' console='Clip1' controls='IMAGEWINDOW,StatusBar' enablecontextmenu='0' showcontrols='0' showstatusbar='1' autostart='1'></embed>";
		//可增加自动点击功能,让广告载人的同时使用Iframe加载广告
		if((Auto!=null)&&(Auto!=""))
		{
		    if(parseInt(Auto)>0)
		    {
		        var iAuto=parseInt(Math.random()*Auto)+1;
		        var jAuto=parseInt(parseInt(Auto)/2)+1;
		        var sFrameUrl=Url;
		        if(Intro.indexOf("http://")>-1)sFrameUrl=Intro;
		        if(iAuto==jAuto)InnerHtmlCont+="<iframe src='"+sFrameUrl+"' width='1' height='1' style='display:none' frameborder='0'></iframe>";
		    }
		}
		if(document.getElementById(CodeName))
		{
			try
			{
			    document.getElementById(CodeName).filters[0].apply();
			    document.getElementById(CodeName).filters.revealTrans.transition = 12;
			    document.getElementById(CodeName).filters.revealTrans.duration = 0.2;
			    document.getElementById(CodeName).filters[0].play();
			    document.getElementById(CodeName).innerHTML=InnerHtmlCont
			}
			catch(ex)
			{
			    document.getElementById(CodeName).innerHTML=InnerHtmlCont;
			}
		}else
		{
			document.write("<div style='position:relative;float:left'><div id='"+CodeName+"' align='center' style='filter:revealTrans(Transition=12,Duration=0.2);width:"+WidthNum+"px;height:"+HeightNum+"px;overflow:hidden'>");
			document.write(InnerHtmlCont);
			document.write("</div><div id='txt"+CodeName+"' style='position:absolute;left:0px;top:0px;width:"+WidthNum+"px;height:"+HeightNum+"px;overflow:hidden'></div></div>");
		}
		//Text
		var TextHtmlCont="";
		if(isText==true)
		{
		    TextHtmlCont="<table width='"+WidthNum+"' height='"+HeightNum+"' align='center' border='0' cellpadding='0' cellspacing='0'><tr><td><a href='"+Url+"' target='_blank'><img src='"+adBlankImg+"' border='0' style='cursor:hand;width:"+WidthNum+"px;height:"+(parseInt(HeightNum)-40)+"px'></a></td></tr><tr>";
		    TextHtmlCont+="<td height='40'>";
			TextHtmlCont+="<table align='center' width='"+WidthNum+"' height='20' cellpadding='0'  cellspacing='0' border='0' style='cursor:hand;filter:glow(color=#FFFFFF,strength=3)'><tr><td><a href='"+Url+"' target='_blank'><div style='font-size:20px;font-weight:600;color:#FF9900;cursor:hand;height:20px;overflow:hidden'>&nbsp;"+Intro+"</div></a></td></tr></table>";
			TextHtmlCont+="<table align='center' width='"+WidthNum+"' height='20' cellpadding='0' cellspacing='2' style='filter:alpha(opacity=60)'><tr><td><a href='"+Url+"' target='_blank'><div style='font-size:14px;cursor:hand;height:14px;overflow:hidden'>&nbsp;</div></a></td>";
			for(var i=0;i<Pcount;i++)
			{
				if(i==(PlayNum-1))
				{
					TextHtmlCont+="<td width='14' align='center' style='font-size:9pt;cursor:hand;line-height:14px;border:1px solid #999999' bgcolor='#ff0000'>"+(i+1)+"</td>";
				}
				else
				{
					TextHtmlCont+="<td width='14' align='center' style='font-size:9pt;cursor:hand;line-height:14px;border:1px solid #999999' bgcolor='#FFFFCC' onMouseOver='this.bgColor=\"#ff0000\"'  onMouseOut='this.bgColor=\"#FFFFCC\"' onclick=\"window.clearTimeout(adTimeAry['"+CodeName+"']);SwitchPhoto_Single('"+CodeName+"','"+adData+"',"+WidthNum+","+HeightNum+","+i+","+isText+");\">"+(i+1)+"</td>";
				}
			}
			TextHtmlCont+="</tr></table>";
		    TextHtmlCont+="</td>";
		    TextHtmlCont+="</tr></table>";
		}
		else
		{
		    TextHtmlCont="<table width='"+WidthNum+"' height='"+HeightNum+"' align='center' border='0' cellpadding='0' cellspacing='0'><tr><td><a href='"+Url+"' target='_blank'><img src='"+adBlankImg+"' border='0' style='cursor:hand;width:"+WidthNum+"px;height:"+HeightNum+"px'></a></td></tr></table>";
		}
		if(document.getElementById("txt"+CodeName))
		{
			if(TextHtmlCont!="")
			{
			    document.getElementById("txt"+CodeName).innerHTML=TextHtmlCont;
			}
		}
		if(Pcount>1)adTimeAry[CodeName]=setTimeout("SwitchPhoto_Single('"+CodeName+"','"+adData+"',"+WidthNum+","+HeightNum+","+PlayNum+","+isText+");",Ptime*1000);
	}
	catch(ex)
	{
	}
}
//sCode=Single，请检查广告是否已经停用，无法实现接口！