<?xml version="1.0" encoding="utf-8"?>
<window screenLeft="0" screenTop="0" width="310" height="160" titleBar="false" resizeMargins="0,0,0,0" maxWidth="310" maxHeight="160" maximizable="false" onload="$('username').focus();TextBoxHelper.call($('text_password'),$('password')); ComboBoxHelper.call($('combo_username'),'signin_combo.xml',$('dropbutton'),$('username'));InitUserProfile();signinOnLoad();" onok="Login();" onunload="signinOnUnload();$('combo_username').clear();">
	<script src="common.js" />
	<script src="signin.xml.js" />
	<script src="ComboBoxHelper.js" />
	<script src="TextBoxHelper.js" />
	<subwindow left="0" top="0" width="310" height="160">
		<!-- top left -->
		<subwindow left="0" top="0" width="40" height="129" backgroundImage="exbg_left_top.bmp" clippingColor="#FF00FF"/>
		<!-- top -->
		<subwindow left="40" top="0" width="250" height="129" backgroundImage="exbg_top.bmp" clippingColor="#FF00FF" horizontalAlignment="stretch" backgroundImageStretchMode="stretch" backgroundColor="#000000"/>
		<!-- top right -->
		<subwindow left="290" top="0" width="20" height="129" backgroundImage="exbg_right_top.bmp" clippingColor="#FF00FF" horizontalAlignment="right"/>
		<!-- right -->
		<subwindow left="290" top="129" width="20" height="10" backgroundImage="exbg_right.bmp" clippingColor="#FF00FF" horizontalAlignment="right" verticalAlignment="stretch" backgroundImageStretchMode="stretch" backgroundColor="#FF0000" />
		<!-- bottom right -->
		<subwindow left="290" top="139" width="20" height="21" backgroundImage="exbg_right_bot.bmp" clippingColor="#FF00FF" horizontalAlignment="right" verticalAlignment="bottom" />
		<!-- bottom -->
		<subwindow left="40" top="139" width="250" height="21" backgroundImage="exbg_bot.bmp" clippingColor="#FF00FF" horizontalAlignment="stretch" verticalAlignment="bottom"  backgroundImageStretchMode="stretch" backgroundColor="#000000"/>
		<!-- bottom left -->
		<subwindow left="0" top="139" width="40" height="21" backgroundImage="exbg_left_bot.bmp" clippingColor="#FF00FF" horizontalAlignment="left" verticalAlignment="bottom" />
		<!-- left -->
		<subwindow left="0" top="129" width="40" height="10" backgroundImage="exbg_left.bmp" clippingColor="#FF00FF" horizontalAlignment="left" verticalAlignment="stretch" backgroundImageStretchMode="stretch" backgroundColor="#000000"/>
		<!-- center -->
		<subwindow id="r_center" left="40" top="129" width="250" height="10" horizontalAlignment="left" verticalAlignment="stretch" backgroundColor="#121212"/>
		<subwindow left="0" top="0" width="310" height="160" backgroundImage="login_bg.png" clippingColor="#FF00FF"/>
		<subwindow left="0" top="0" width="310" height="140" horizontalAlignment="stretch" verticalAlignment="stretch" >
			<label left="22" top="8" width="120" height="20" foregroundColor="#efefef"  fontSize="13"  fontStyle="bold" fontFace="Arial" value="登 录" passThrough="true"/>
			<label id="errorMsg" left="80" top="24" width="130" height="18" value="" foregroundColor="#D27E4E" backgroundColor="#F8F8C8" textAlignment="center vcenter" visible="false"/>
			<label left="20" top="50" width="45" height="20" fontSize="12" fontFace="宋体" foregroundColor="#CCCCCC" value="用户名：" passThrough="true"/>
			<label left="233" top="50" width="110" height="14" value="新用户注册" fontSize="12" fontFace="宋体" foregroundColor="#45ACF6" cursor="hand" onclick="window.close();var uiMainWindow = Components.GetObject2('@pplive.com/ui/mainwindow;1');if(uiMainWindow)uiMainWindow.ShowRegUser();"/>
			<!-- 从ComboBoxHelper继承 -->
			<subwindow id="combo_username" left="69" top="43" width="162" height="26" passThrough="false" backgroundImage="login_input_normal.png">
				<image id="dropbutton" left="137" top="1" width="24" height="24" src="login_dropdown_btn_1.png" passThrough="false" cursor="hand"/>
				<textbox id="username" left="5" top="7" width="132" fontFace="tahoma" height="12" border="false" backgroundColor="white" passThrough="false"/>
			</subwindow>
			<label left="20" top="80" width="45" height="20" foregroundColor="#CCCCCC" fontSize="12" fontFace="宋体" value="密  码：" passThrough="true"/>
			<label left="233" top="80" width="110" height="14" value="忘记密码" fontSize="12" fontFace="宋体" foregroundColor="#45ACF6" cursor="hand" onclick="window.shellExecute('open', 'http://passport.pplive.com/fetchpassword.do');"/>
			<subwindow id="text_password" left="69" top="73" width="162" height="26" passThrough="false" backgroundImage="login_input_normal.png">
				<textbox id="password" left="5" top="7" width="152" height="12" border="false" backgroundColor="white" passThrough="false" type="password" fontSize="12" fontFace="tahoma"/>
			</subwindow>
			<button id="btnLogin" left="215" top="115" width="74" height="26" image="ex_button.bmp" hoverImage="ex_button_hover.bmp" downImage="ex_button_down.bmp" onclick="Login();">
				<label left="0" top="0" width="74" height="26" value="" fontSize="14" fontStyle="bold" foregroundColor="#121212" passThrough="true" textAlignment="center vcenter"/>
			</button>
			<checkbox id="savepassword" left="21" top="118" width="70" height="15" label="记住密码" backgroundColor="#121212" fontSize="12" fontFace="宋体" foregroundColor="#CCCCCC"/>
			<checkbox id="autosign" left="108" top="118" width="70" height="15" label="自动登录" backgroundColor="#121212" fontSize="12" fontFace="宋体" foregroundColor="#CCCCCC" onclick="if(!$('autosign').checked)$('savepassword').checked=true;$('savepassword').disabled=!$('autosign').checked;"/>
		</subwindow>
		<!-- close button -->
		<button left="272" top="0" width="26" height="23" image="close.bmp" hoverImage="close_hover.bmp" downImage="close_down.bmp" onclick="window.close();" tooltip="关闭"/>
		<widget id="passport" left="0" top="0" width="0" height="0" contractId="@pplive.com/passport;1" useService="true" onlogin="OnLogin(arguments[0]);"/>
	</subwindow>
	<script>
	<![CDATA[
		$("username").isMatch = false;
		$("username").lastInput = "";
		$("username").inputSliceSelect = "";
		$("username").onselchange = function(event)
		{
			var username = $("username").value;
			var selstart = event.start;
			var selend = event.end;
			$("username").inputSliceSelect = username.substring(0,selstart) + username.substring(selend,username.length);
		}
		$("username").onchanged = function()
		{
			var nfirstMarchIndex = 0;
			var lastinput = $("username").lastInput;
			$("username").lastInput = $("username").value;
			var count = $('combo_username').count;
			if(count>5) count=5
			if(count==0) return;
			var Items = $('combo_username').Items;
			$("autosign").checked = false;
			$('savepassword').checked = false;
			$('savepassword').disabled=false;
			for(var i=0;i<count;i++)
			{
				var index = i+1;
				if($("username").value==Items[index].name)
				{
					$("password").value = Items[index].rndpass;
					if($("password").value.length>0)
					{
						$('savepassword').checked = true;
						if($("passport").DefaultUser==$("username").value)
						{
							var registry = Components.CreateObject("@pplive.com/registry;1");
							if (registry.open(registry.HKCU, "Software\\PPLive\\passport", IRegistry.KEY_READ))
							{
								if (registry.queryType("autologin") != 4 || registry.readDWORD("autologin"))
								{
									$("autosign").checked = true;
									$('savepassword').disabled=true;
								}
							}
						}		
					}
					$("username").isMatch = true;
					return;
				}
				if(nfirstMarchIndex==0)
				{
					var regxp = new RegExp("^" + $("username").value + ".*","i");
					if(regxp.test(Items[index].name))
					{
						if($("username").value.length>=lastinput.length)
							nfirstMarchIndex = index;
						else if($("username").inputSliceSelect.length<=$("username").value.length && $("username").value != $("username").inputSliceSelect)
							nfirstMarchIndex = index;
					}
					delete regxp;
				}
			}
			if(nfirstMarchIndex>0)
			{
				$("username").isMatch = true;
				var aEnd = Items[nfirstMarchIndex].name.length;
				var aStart = $("username").value.length;
				$("username").value = Items[nfirstMarchIndex].name;
				$("username").setsel(aStart,aEnd);
				//其他会在onchange里面更改
				return;
			}
			if($("username").isMatch)
			{
				$("username").isMatch = false;
				$("password").value = "";
			}
		}
		$('text_password').OnPaint=function(focus,bgmousehover,edtmousehover)
		{
			if(focus || bgmousehover || edtmousehover)
			{
				this.backgroundImage="login_input_hover.png";
			}
			else{
				this.backgroundImage="login_input_normal.png";
			}
		}
		$('combo_username').OnPaint=function(focus,btnmousehover,btndisabled,popupvisible,edtmousehover,bgmousehover)
		{
			if(focus || popupvisible || btnmousehover || edtmousehover || bgmousehover)
			{
				this.backgroundImage="login_input_hover.png";
			}
			else{
				this.backgroundImage="login_input_normal.png";
			}

			if(btndisabled)
			{
				this.button.src="login_dropdown_btn_disabled.png";
			}
			else if(popupvisible)
			{
				this.button.src="login_dropdown_btn_down.png";
			}
			else if (btnmousehover)
			{
				this.button.src="login_dropdown_btn_hover.png";
			}
			else
			{
				this.button.src="login_dropdown_btn_normal.png";
			}
		}
		$('combo_username').OnSelect=function(Item)
		{
			InitUserProfile();
			if(typeof(Item)=="undefined" || Item==null) return;
			$("password").value = Item.rndpass;
			$("username").value = Item.name;
		}
		function InitUserProfile()
		{
			$('combo_username').ClearAllItems();
			try{
				var userprofile = Components.GetObject("@pplive.com/UserProfile;1");
				userprofile.Sort();
				var count = userprofile.Count;
				for(var i=count-1;i>=0;i--){
					var name = userprofile.Attribute(i,"name");
					var rndpass = userprofile.Attribute(i,"rndpass");
					var Item = {"name":name,"rndpass":rndpass};
					$('combo_username').AddItem(Item);
				}
			}
			catch(e){
			}
		}
		window.OnDeleteItem=function(name)
		{
			if($("username").value==name)$("username").value="";
		}
	]]>
	</script>

</window>