<?xml version="1.0" encoding="utf-8"?>
<window left="0" top="0" width="46" height="100" titleBar="false" resizeMargins="0,0,0,0" onload="Onload();" onunload="OnUnload();" onactivate="OnActive(event.activated);">
	<script src="common.js" />
	<script src="playcontrolcommon.js" />
	<script>
	<![CDATA[
		function Onload()
		{
			//获取播放控制接口
			GetPPPlayer();

			//添加窗口
			if (ppplayer)
			{
				var mframe = ppplayer.get_MFRAME();
				if (mframe)
				{
					mframe.AddWnd("DataRateChangeWnd",window);
				}
			}

			if (ppplayer)
			{
				var linkid = ppplayer.linkid;
				if (!linkid)
				{
					window.close();
					return ;
				}

				var rt = ppplayer.rt;
				if (rt & 0x0002)  //蓝光频道关联普通高清频道
				{	
					$("spot1").visible = false;
					$("spot2").visible = true;
				}
				else if (rt & 0x004)  //高清频道关联蓝光频道
				{	
					$("spot1").visible = true;
					$("spot2").visible = false;
				}
				else //没有对应的关联关系，则不显示切换列表窗体
				{	
					window.close();
					return ;
				}
			}
			DisableAccelset(true);
		}

		function OnUnload()
		{
			//移除窗口
			if (ppplayer.DataRateWnd == window)
			{
				if (ppplayer)
				{
					var mframe = ppplayer.get_MFRAME();
					if (mframe)
					{
						mframe.RemoveWnd("DataRateChangeWnd");
					}
					DisableAccelset(false);
				}
			}			
		}

		function OnShiftbtn(n)
		{
			if (ppplayer)
			{
				var rt = ppplayer.rt;
				var ppp = ppplayer.get_PPP();
				if (ppp)
				{
					if (n == 1)
					{
						if(rt & 0x0002)  //蓝光频道关联普通高清频道
						{
							ppp.BitrateSwitch(-1)=1;
							var registry = Components.CreateObject("@pplive.com/registry;1");
							if (registry && registry.create(registry.HKCU, "Software\\PPLive\\PPTV\\UserEdu"))
							{	
								var LowBitrateSwitch = registry.readDWORD("LowBitrateSwitch");
								registry.writeDWORD("LowBitrateSwitch",LowBitrateSwitch+1);
							}
							var ppplayercontrol = Components.GetObject2("PPPlayerControl");
							if (ppplayercontrol)
							{
								ppplayercontrol.OnDisabledShiftBtn(true);
							}
							window.close();
						}
					}
					else if (n == 2)
					{
						if(rt & 0x004)  //高清频道关联蓝光频道
						{
							ppp.BitrateSwitch(1)=1;
							var registry = Components.CreateObject("@pplive.com/registry;1");
							if (registry && registry.create(registry.HKCU, "Software\\PPLive\\PPTV\\UserEdu"))
							{	
								var HighBitrateSwitch = registry.readDWORD("HighBitrateSwitch");
								registry.writeDWORD("HighBitrateSwitch",HighBitrateSwitch+1);
							}
							var ppplayercontrol = Components.GetObject2("PPPlayerControl");
							if (ppplayercontrol)
							{
								ppplayercontrol.OnDisabledShiftBtn(true);
							}
							window.close();
						}
					}				
				}
			}
		}

		function OnActive(bActived)
		{
			if (!bActived)
			{	
				if (!PtInRect("unmutebtn") && !PtInRect("shiftbtn"))
				{
					window.visible = false;
				}
				window.setTimeout("if(!window.closed)window.close();", 3000);
				DisableAccelset(false);
			}
		}
	]]>
	</script>
	<subwindow left="0" top="0" width="46" height="100" visible="true" passThrough="false" backgroundColor="#FF00FF">
		<subwindow left="0" top="0" width="46" height="33" visible="true" passThrough="false" backgroundColor="#FF00FF">
			<button id="shiftbtn1" left="0" top="0" width="46" height="33" image="stream_bg.bmp" hoverImage="stream_hover.bmp" downImage="stream_hover.bmp" stretchMode="ninegrid" nineGridMargins="2,2,2,2" onclick="OnShiftbtn(1);" label="高清" foregroundColor="RGB(182,182,182)"/>
			<image id="spot1"  left="3" top="16" width="4" height="4" src="stream_spot.bmp" visible="true"/>
		</subwindow>
		<subwindow left="0" top="33" width="46" height="33" visible="true" passThrough="false" backgroundColor="#FF00FF">
			<button id="shiftbtn2" left="0" top="0" width="46" height="33" image="stream_bg.bmp" hoverImage="stream_hover.bmp" downImage="stream_hover.bmp" stretchMode="ninegrid" nineGridMargins="2,2,2,2" onclick="OnShiftbtn(2);" label="蓝光" foregroundColor="RGB(182,182,182)"/>
			<image id="spot2" left="3" top="16" width="4" height="4" src="stream_spot.bmp" visible="true"/>
		</subwindow>
		<subwindow left="0" top="66" width="46" height="33" visible="true" passThrough="false" backgroundColor="#FF00FF">
			<button id="shiftbtn3" left="0" top="0" width="46" height="33" image="stream_bg.bmp" hoverImage="stream_hover.bmp" downImage="stream_hover.bmp" stretchMode="ninegrid" nineGridMargins="2,2,2,2" onclick="OnShiftbtn(3);" label="标清" foregroundColor="RGB(182,182,182)"/>
			<image id="spot3" left="3" top="16" width="4" height="4" src="stream_spot.bmp" visible="true"/>
		</subwindow>
	</subwindow>
</window> 