<?xml version="1.0" encoding="utf-8"?>
<window id="window" screenLeft="3" screenTop="27" width="347" height="208" titleBar="false" resizeMargins="0,0,0,0" maximizable="false" onload="initColorAdjust();">
	<script src="common.js" />
	<script>
	<![CDATA[
	function initColorAdjust()
	{
		window.memory = 0;
		var ppp = Components.GetObject("PPP");
		if (ppp)
		{
			var procAmp=ppp;
			var caps = procAmp.capability;
			if (caps&0x0001)
			{
				$("brightness").disabled = false;
				$("brightness").value = procAmp.brightness;
				window.brightness = $("brightness").value;
			}
			if (caps&0x0002)
			{
				$("contrast").disabled = false;
				$("contrast").value = procAmp.contrast;
				window.contrast = $("contrast").value;
			}
			if (caps&0x0008)
			{
				$("saturation").disabled = false;
				$("saturation").value = procAmp.saturation;
				window.saturation = $("saturation").value;
			}
			window.memory = ppp.VideoProcAmpMemory;
			if(window.memory==1)$("alwaysApply").checked=true;
			ppp.VideoProcAmpMemory=-1;	//开始设置
		}
	}
	function onok()
	{
		var ppp = Components.GetObject2("PPP");
		if (ppp)
		{
			ppp.brightness=$("brightness").value;
			ppp.contrast = $("contrast").value;
			ppp.saturation= $("saturation").value;
			if ($("alwaysApply").checked)
			{
				ppp.VideoProcAmpMemory=1;
			}
			else
			{	
				ppp.VideoProcAmpMemory=0;
			}
		}
		window.close();
	}
	function oncancel()
	{
		var ppp = Components.GetObject("PPP");
		if (ppp)
		{
			var procAmp = ppp;
			if (procAmp)
			{
				if (typeof(window.brightness) != "undefined")
				{
					procAmp.brightness = window.brightness;
				}
				if (typeof(window.contrast) != "undefined")
				{
					procAmp.contrast = window.contrast;
				}
				if (typeof(window.saturation) != "undefined")
				{
					procAmp.saturation = window.saturation;
				}
			}
			ppp.VideoProcAmpMemory=window.memory;
		}
		window.close();
	}
	function onBrightnessChange(value)
	{
		if (typeof(window.brightness) == "undefined")
		{
			return;
		}

		var ppp = Components.GetObject("PPP");
		if (ppp)
		{
			var procAmp = ppp;
			if (procAmp)
			{
				procAmp.brightness = value;
			}
		}
	}
	function onContrastChange(value)
	{
		if (typeof(window.contrast) == "undefined")
		{
			return;
		}

		var ppp = Components.GetObject("PPP");
		if (ppp)
		{
			var procAmp = ppp;
			if (procAmp)
			{
				procAmp.contrast = value;
			}
		}
	}
	function onSaturationChange(value)
	{
		if (typeof(window.saturation) == "undefined")
		{
			return;
		}

		var ppp = Components.GetObject("PPP");
		if (ppp)
		{
			var procAmp = ppp;
			if (procAmp)
			{
				procAmp.saturation = value;
			}
		}
	}
	]]>
	</script>
	<!-- top left -->
	<subwindow left="0" top="0" width="80" height="27" backgroundImage="bg_left_top.bmp" clippingColor="#FF00FF" />
	<!-- top -->
	<subwindow left="80" top="0" width="259" height="27" backgroundImage="bg_top.bmp" clippingColor="#FF00FF" horizontalAlignment="stretch" backgroundImageStretchMode="stretch" backgroundColor="#000000"/>
	<!-- top right -->
	<subwindow left="339" top="0" width="8" height="27" backgroundImage="bg_right_top.bmp" clippingColor="#FF00FF" horizontalAlignment="right"/>
	<!-- right -->
	<subwindow left="345" top="27" width="2" height="179" backgroundImage="bg_right.bmp" clippingColor="#FF00FF" horizontalAlignment="right" verticalAlignment="stretch" backgroundImageStretchMode="stretch" backgroundColor="#000000" />
	<!-- bottom right -->
	<subwindow left="345" top="206" width="2" height="2" backgroundImage="set_bg_right_bot.bmp" clippingColor="#FF00FF" horizontalAlignment="right" verticalAlignment="bottom" />
	<!-- bottom -->
	<subwindow left="2" top="206" width="343" height="2" backgroundImage="set_bg_bot.bmp" clippingColor="#FF00FF" horizontalAlignment="stretch" verticalAlignment="bottom"  backgroundImageStretchMode="stretch" backgroundColor="#000000"/>
	<!-- bottom left -->
	<subwindow left="0" top="206" width="2" height="2" backgroundImage="set_bg_left_bot.bmp" clippingColor="#FF00FF" horizontalAlignment="left" verticalAlignment="bottom" />
	<!-- left -->
	<subwindow left="0" top="27" width="2" height="179" backgroundImage="bg_left.bmp" clippingColor="#FF00FF" horizontalAlignment="left" verticalAlignment="stretch" backgroundImageStretchMode="stretch" backgroundColor="#000000"/>
	<!-- center -->
	<subwindow left="2" top="27" width="343" height="179" horizontalAlignment="stretch" verticalAlignment="stretch" backgroundColor="#efefef" passThrough="false">
	</subwindow>

	<!-- close button -->
	<button left="315" top="0" width="26" height="23" image="close.bmp" hoverImage="close_hover.bmp" downImage="close_down.bmp" onclick="oncancel();" tooltip="关闭"/>
	<label left="60" top="4" width="200" height="18" value="色彩调节" textAlignment="left vcenter" fontFace="Arial" fontSize="13" foregroundColor="#F0F8FF" passThrough="true" fontStyle="bold"/>

	<label left="20" top="46" width="110" height="30" value="亮  度" />
	<slider id="brightness" left="78" top="48" width="246" height="11" backgroundImage="brightness.png" thumbImage="color_thumb.png" borderSize="7" min="-100" value="0" max="100" disabled="true" onchange="onBrightnessChange(this.value);"/>
	<label left="20" top="76" width="110" height="30" value="饱和度" />
	<slider id="saturation" left="78" top="78" width="246" height="11" backgroundImage="saturation.png" thumbImage="color_thumb.png" borderSize="7" min="-100" value="0" max="100" disabled="true" onchange="onSaturationChange(this.value);"/>
	<label left="20" top="106" width="110" height="30" value="对比度" />
	<slider id="contrast" left="78" top="108" width="246" height="11" backgroundImage="contrast.png" thumbImage="color_thumb.png" borderSize="7" min="-100" value="0" max="100" disabled="true" onchange="onContrastChange(this.value);"/>
	<checkbox id="alwaysApply" left="15" top="140" width="200" height="27" label="始终使用该设置" backgroundColor="#efefef"  textAlignment="left vcenter"/>
	<button id="restore" left="10" top="170" width="74" height="27" image="button.bmp" hoverImage="button_hover.bmp" downImage="button_down.bmp" label="恢复默认" onclick="$('brightness').value=$('saturation').value=$('contrast').value=0;$('alwaysApply').checked=false;" />
	<button id="ok"      left="175" top="170" width="70" height="27" image="button.bmp" hoverImage="button_hover.bmp" downImage="button_down.bmp" label="确定" onclick="onok();"/>
	<button id="cancel" left="258" top="170" width="70" height="27" image="button.bmp" hoverImage="button_hover.bmp" downImage="button_down.bmp" label="取消" onclick="oncancel();"/>
</window>
