<?xml version="1.0" encoding="utf-8"?>
<window width="500" height="240" titleBar="false" resizeMargins="3,3,3,3" onload="windowOnLoad();" onsize="windowOnSize();">
	<script src="common.js" />
	<script>
	<![CDATA[
		function windowOnLoad()
		{
			window.timeid=0;
			window.ShowAdSelector=function(ImgLeft,ImgRight)
			{
				if(window.timeid)
				{
					window.clearTimeout(window.timeid);
					window.timeid=0;
				}

				$("imgLeft").src=ImgLeft;
				$("imgRight").src=ImgRight;

				OnTimer(10);
				window.visible=true;
			}
		}
		function OnTimer(time)
		{
			if(window.timeid)
			{
				window.clearTimeout(window.timeid);
				window.timeid=0;
			}
			
			var showTime = "000" + time;
			$("lblTime").value=showTime.substring(showTime.length-2);
			if(time>0)
			{
				var nexttime = time-1;
				var exp = "OnTimer(" + nexttime + ")";
				window.timeid = window.setTimeout(exp, 1000);
			}
			else
			{
				SelectAD(0);
			}
		}
		function windowOnSize()
		{
			if(window.outerWidth<480 || window.outerHeight<210)
			{
				SelectAD(2);
				return;
			}

			$("btnLeft").top = (window.outerHeight - $("btnLeft").height)/2 + 20;
			$("btnRight").top = (window.outerHeight - $("btnRight").height)/2 + 20;

			$("btnLeft").left = window.outerWidth/2 - $("btnLeft").width - 20;
			$("btnRight").left = window.outerWidth/2 + 20;

			$("imgHead").top = $("btnLeft").top - 20 - $("imgHead").height;
			$("imgHead").left=(window.outerWidth-480)/2;
		}

		function SelectAD(nSelect)
		{
			if(window.timeid)
			{
				window.clearTimeout(window.timeid);
				window.timeid=0;
			}
			var  ad = Components.GetObject("AD");
			if(!ad) return;
			try
			{
				
				if(nSelect==-1) 
				{
					ad.SelectAd($("imgLeft").src);
				}
				else if(nSelect==1)
				{
					ad.SelectAd($("imgRight").src);
				}
				else if(nSelect==0)
				{
					ad.SelectAd("");
				}
				else
				{
					ad.SelectAd("2");
				}
			}
			catch (e)
			{
			}
		}
	]]>
	</script>
	<subwindow left="0" top="0" width="500" height="240" backgroundColor="#000000" passThrough="false" horizontalAlignment="stretch" verticalAlignment="stretch" ondblclick="EwaFullOrUnfull();">
		<image id="imgHead" left="10" top="0" width="480" height="20" stretchMode="stretch" src="adselector_title.jpg">
			<label id="lblTime" left="295" top="-4" width="60" height="24" value="00" fontSize="20" fontFace="微软雅黑" fontStyle="bold" foregroundColor="#faff03" passThrough="true"/>
		</image>
		<button id="btnLeft" left="0" top="0" width="220" height="165" onclick="SelectAD(-1);" cursor="hand">
			<image id="imgLeft"  left="0" top="0" width="220" height="165" stretchMode="stretch" horizontalAlignment="stretch" verticalAlignment="stretch"/>
		</button>
		<button id="btnRight" left="0" top="0" width="220" height="165" onclick="SelectAD(1);" cursor="hand">
			<image id="imgRight" left="0" top="0" width="220" height="165" stretchMode="stretch" horizontalAlignment="stretch" verticalAlignment="stretch"/>
		</button>
	</subwindow>
</window>