<?xml version="1.0" encoding="utf-8"?>
<window left="0" top="0" width="32" height="92" titleBar="false" resizeMargins="0,0,0,0" onload="Onload();" onunload="OnUnload();">
	<script src="common.js" />
	<script>
	<![CDATA[
		function DisableAccelset(bDisabled)
		{
			var mainWnd = Components.GetObject2("@pplive.com/ui/mainwindow;1");
			if (mainWnd)
			{
				var accelset = mainWnd.getElementById("accelset"); 
				if (accelset)
				{
					accelset.disabled = bDisabled;
				}
				var accelsetPlayer = mainWnd.getElementById("accelsetPlayer"); 
				if (accelsetPlayer)
				{
					accelsetPlayer.disabled = bDisabled;
				}
				var accelsetUI = mainWnd.getElementById("accelsetUI"); 
				if (accelsetUI)
				{
					accelsetUI.disabled = bDisabled;
				}
			}
		}
		function OnVolumeSliderDragBegin(pos)
		{
			var EWA = Components.GetObject2("EWA");
			if(EWA) window.parent.beforeDragVolume = EWA.Volume;
		}
		function OnVolumeSliderDragEnd(pos)
		{
			var EWA = Components.GetObject2("EWA");
			if(EWA && pos==0)
			{
				EWA.Mute=true;
				EWA.Volume=window.parent.beforeDragVolume;
			}
		}
		function Onload()
		{
			window.checkHoverTimeid = window.setInterval("checkHover();",200);
			window.OnChangeMute=function(mute)
			{
				var EWA = Components.GetObject2("EWA");
				if(!EWA) { return; }
				var vol = EWA.Volume;
				if(mute) vol=0;
				window.SetVolume(vol);
			}
			window.OnVolSliderChange =function(pos)
			{
				var EWA = Components.GetObject2("EWA");
				if(!EWA) { return; }
				if(pos>0)
				{
					if(EWA.Mute)EWA.Mute=false;
					if(EWA.Volume!=pos)EWA.Volume = pos;
				}
				else
				{
					if(!EWA.Mute)EWA.Mute=true;
				}
			}
			window.SetVolume=function(vol)
			{
				if(vol>1000){ return;}
				var EWA = Components.GetObject2("EWA");
				if(!EWA) { return; }
				var nVol = vol;
				if (nVol > 100)
				{
					nVol = 100;
				}
				else if (nVol <= 0)
				{
					nVol = 0;
				}
				$("volumeslider").value = nVol;
				if(vol!=0)
				{
					EWA.Mute=false;
					EWA.Volume=vol;
				}
				else EWA.Mute=true;
				var txt = "音量："+vol+"%";
				if(vol>=100 && vol<1000)
				{
					var accKey = "↑";
					var mainwindow = Components.GetObject2("@pplive.com/ui/mainwindow;1");
					if(mainwindow) accKey = mainwindow.getHotKeyText("key_volumeInc");
					txt = txt + "  \r\n按 " + accKey + " 继续放大音量";
				}
				if($("volumeslider").lasttooltip!=txt)
				{
					$("volumeslider").tooltip =txt;
					$("volumeslider").lasttooltip=txt;
				}
				//window.parent.updateMute();
			}
			//DisableAccelset(true);
			var EWA = Components.GetObject2("EWA");
			if(EWA) 
			{ 
				var vol = EWA.Volume;
				if(EWA.Mute) vol=0;
				window.SetVolume(vol);
			}
			// 添加窗口
			var mframe = Components.GetObject2("mframe");
			if (mframe)
			{
				mframe.AddWnd("VolumePopDlg",window);
			}
		}

		function OnUnload()
		{
			// 删除窗口
			var mframe = Components.GetObject2("mframe");
			if (mframe)
			{
				mframe.RemoveWnd("VolumePopDlg");
			}
			window.clearInterval(window.checkHoverTimeid);
			//DisableAccelset(false);
		}
		function PtInRectEx(element,win)
		{
			var left = 0;
			var right = 0;
			var width = 0;
			var height = 0;

			if (win)
			{
				if (element && !element.disabled && element.visible)
				{
					left = win.screenLeft + element.offsetLeft;
					right = win.screenTop + element.offsetTop;
					width = element.width;
					height = element.height;
					var mframe = Components.GetObject2("mframe");
					if (mframe)
					{
						return mframe.PtInRect(left,right,width,height);
					}
				}
			}
			return false;
		}
		function checkHover()
		{
			if(PtInRectEx($("winx"),window))
			{
				window.parent.hover_volpop=true;
			}
			else
			{
				window.parent.hover_volpop=false;
			}
			window.parent.execScript("checkVolumeHover.call(null);");
		}
	]]>
	</script>
	<subwindow id="winx" left="0" top="0" width="32" height="92" visible="true" passThrough="false" backgroundColor="#FF00FF" onmouseover="checkHover();" onmouseout="checkHover();">
		<image left="0" top="0" width="32" height="3" src="volume_bg_top.bmp" visible="true" passThrough="true"/>
		<image left="0" top="3" width="32" height="86" src="volume_bg_m.bmp" visible="true" stretchMode="stretch" verticalAlignment="stretch" passThrough="true"/>
		<image left="0" top="89" width="32" height="3" src="volume_bg_bottom.bmp" visible="true" passThrough="true"/>
		<slider id="volumeslider" left="5" top="5" width="22" height="82" direction="vertical" backgroundImage="volume_bar_1.png" foregroundImage="volume_bar_2.png" thumbImage="volume_thumb_normal.png" thumbHoverImage="volume_thumb_hover.png" thumbDownImage="volume_thumb_down.png" borderSize="0" min="0" value="0" max="100" disabled="false" onchange="window.OnVolSliderChange(this.value);" foregroundImageStretchMode="bottom" thumbOverlay="false" onmouseover="checkHover();" onmouseout="checkHover();" ondragbegin="OnVolumeSliderDragBegin(this.value);" ondragend="OnVolumeSliderDragEnd(this.value);"/>
	</subwindow>
</window> 
