/**
 	*<z:config type="SiteIndexTemplate" />
 	*/

(function(){		

	//需要获得的json数据格式如下，此处先定义为静态数据
	var imgplayjson=${(Data)};
	
	
	if(!imgplayjson || imgplayjson.ImageData.length == 0 ){
			return;			
	}else {
		  showADContent(imgplayjson);  //将代码插入到页面
	}
	
	
	//拼写内容html
	function showADContent(imgplayjson) {
		var imgs = imgplayjson.ImageData;
		var flashVars=['xml='];
		flashVars.push('<data>');
		flashVars.push('<channel>');
		for(var i=0;i<imgs.length;i++){
			flashVars.push('<item>');
			flashVars.push('<link>');
			flashVars.push(encodeURIComponent(imgs[i].URL));
			flashVars.push('</link>');
			flashVars.push('<image>');
			flashVars.push(encodeURIComponent(imgs[i].ImgSrc));
			flashVars.push('</image>');
			flashVars.push('<title>');
			flashVars.push(encodeURIComponent(imgs[i].Alt));
			flashVars.push('</title>');
			flashVars.push('</item>');
		}
		flashVars.push('</channel>');
		flashVars.push('<config>');
		flashVars.push('<windowOpen>_blank</windowOpen>');
		flashVars.push('</config>');
		flashVars.push('</data>');
		flashVars=flashVars.join('');
		
		var html='<embed name="ImagePlayer'+imgplayjson.PlayerID+'" id="ImagePlayer'+imgplayjson.PlayerID+'" width="'+imgplayjson.Width+'" height="'+imgplayjson.Height+'" src="'+imgplayjson.StyleDirPath+'bcastr4.swf"  flashVars="'+flashVars+'" menu="false" quality="high" wmode="transparent" type="application/x-shockwave-flash"/>';
		
		
		var div=document.createElement('div');
		div.innerHTML=html;
		var adNode=document.getElementById("imgplayblockjs_" + imgplayjson.PlayerID);
		adNode.parentNode.insertBefore(div.firstChild,adNode.nextSibling);
		div=null;
	}	
	
})();