  <!--
  var UC_URL='http://center.zmrgame.com/center';

  $(document).ready(function(){
       initUserLoginInfoDlg();
	   initUserLoginDlg();
       $(window).scroll(function(e){
	       moveUserLoginInfoDlg();
	   });

	   $(window).resize(function(){
           moveUserLoginInfoDlg();
	   });
  });

  function moveUserLoginInfoDlg(){
	       var top = $(this).scrollTop()+$(this).height()-96;
		   $("#UserLoginInfoDlg").css("top",top+"px");  
  }

  function initUserLoginInfoDlg(){
      var dlgHtml = '<div id="UserLoginInfoDlg" style="width:175px; height:96px; position:absolute; left:0px; text-align:left;">'+
		            '</div>';
	  $("body").append(dlgHtml);
      moveUserLoginInfoDlg();
	  checkUserLoginInfo();
  }

  function checkUserLoginInfo(){
	  var nickname = getCookie('ZmrNickname');
	  var uid      = getCookie('ZmrUid');
      if(uid==null || nickname==null){ //未登录
	     $("#UserLoginInfoDlg").html('');
	     return false;
	  }

	  var dlgHtml = '<table width="175" height="96" border="0" cellpadding="0" cellspacing="0" style="background:url(http://file.zmrgame.com/images/ts.png); margin:0; padding:0; font-size:12px;">'+
		            '<tr>'+
		            '<td width="87"><div style="z-index:-13; margin-left:12px; margin-top:33px; "><img src="'+UC_URL+'/avatar.php?uid='+uid+'&size=small" width="48" height="48" /></div></td>'+
		            '<td width="88"><table width="88" border="0" cellpadding="0" cellspacing="0">'+
		            '<tr>'+
		            '<td height="46" valign="bottom" style="color:#CCCCCC;">'+nickname+'</td>'+
		            '</tr>'+
		            '<tr>'+
		            '<td height="32"><div style="margin-left:26px; font-size:12px; text-decoration: underline;"><font style="color:red;cursor:pointer;" id="lgout">退出</font></div></td>'+
		            '</tr>'+
		            '</table>'+
		            '</td>'+
		            '</tr>'+
		            '</table>';

      $("#UserLoginInfoDlg").html(dlgHtml);
	  $("#lgout").click(function(){
	              delCookie('ZmrUid');
				  delCookie('ZmrNickname');
				  delCookie('ZmrUsername');
				  checkUserLoginInfo();
				  alert('退出成功！');
	  });
  }
  
  function initUserLoginDlg(){
      var dlgHtml = '<div id="UserLoginDlg" style="position:absolute; text-align:left;">' +
		            '<table width="451" height="200" border="0" cellpadding="0" cellspacing="0" style="border:5px #FF9900 solid; background-color:#F7F7F7;">'+
		            '<tr>'+
		            '  <td width="250" height="50" valign="middle" style=" padding-left:20px; font-size:14px; font-weight:bold;">用户登录</td>'+
		            '  <td align="right" valign="middle" style="padding-right:20px;"><img style="cursor:pointer;" onClick="closeUserLoginDlg()" src="http://file.zmrgame.com/images/png-error.png" width="20" height="20" border="0" /></td>'+
		            '</tr>'+
		            '<tr>' +
                    '  <td valign="middle" style=" padding-left:20px; border-right:1px #CCCCCC solid;"><table width="230" border="0" cellpadding="0" cellspacing="0">'+
		            '<tr>'+ 
		            '<td height="32"> 账号：'+
		            '<label>'+
		            '<input id="lgusername" name="lgusername" type="text" size="20" maxlength="20" style="border:0px; border-color: #999999;border-bottom:1px solid;" />'+
		            '</label></td>'+
		            '</tr>'+
		            '<tr>'+
		            '<td height="32">密码：'+
		            '<label>'+
		            '<input id="lgpassword" name="lgpassword" type="password" size="20" maxlength="16" style="border:0px; border-color: #999999;border-bottom:1px solid;" />'+
		            '</label></td>'+
		            '</tr>'+
		            '<tr>'+
		            '<td height="32"><div id="lgstatus" style="color:red;"></div></td>'+
		            '</tr>'+
		            '</table></td>'+
		            '<td valign="middle" style="font-size:14px; line-height:22px; padding-left:40px; ">没有帐号？<a href="http://www.zmrgame.com/platform/reg.php" style="color:#FF6600;" target="_blank">注册</a><br />'+
		            '<a href="http://www.zmrgame.com/platform/lostpwd.html" style="color:#FF6600;" target="_blank">找回密码</a>'+
		            '</td>'+
		            '</tr>'+
		            '<tr>'+
		            '<td height="50" valign="middle" style=" padding-left:20px;"><label>'+
		            '<input id="bnlogin" type="submit" name="Submit" value="登录" />'+
		            '</label>'+
		            '</td>'+
		            '<td valign="middle">&nbsp;</td>'+
		            '</tr>';
	                '</table>'
		            '</div>';
		$("body").append(dlgHtml);
		$("#UserLoginDlg").hide();
		$("#bnlogin").click(function(){
		       var username = $("#lgusername").val();
			   var password = $("#lgpassword").val();
			   if(username.length<1 || password.length<1){
			       $("#lgstatus").text("账号和密码都不能为空!");
				   return false;
			   }

			   $.ajax({
			           type     : "GET",
				       url      : "/zmr.php?m=zmr&c=login&a=in&username="+encodeURIComponent(username)+"&password="+password,
                       dataType : "json",
				       global   : false,
					   timeout  : 5000,
				       success  : function(data){
					                 if(data.status){
										setCookie('ZmrUid',data.uid,3600);
                                        setCookie('ZmrNickname',data.nickname,3600); 
										setCookie('ZmrUsername',data.user,3600); 
										checkUserLoginInfo();  
										closeUserLoginDlg();
									 }else{
									    $("#lgstatus").text("登录失败账号或密码不正确!");
									 }
					              },
	                    complete : function (XMLHttpRequest, textStatus){
								       if(textStatus=='timeout'){
									      $("#lgstatus").text("登录失败账号或密码不正确!");
									   }
								   },
			            beforeSend : function (){
								       $("#lgstatus").text("正在登录...");
								   }						
				}); 

		});
  }
  
  //检测登录状态
  function isUserLogin(){
	  var nickname = getCookie('ZmrNickname');
	  var uid      = getCookie('ZmrUid');
      if(uid==null || nickname==null){ //未登录
	     return false;
	  }else{
	     return true;
	  }
  }

  function showUserLoginDlg(){
	    var top = $(this).height()/2 - 100 + $(this).scrollTop();
		var left = $(this).width()/2 - 225
        $("#UserLoginDlg").css({"top":top+"px","left":left+"px"});
        $("#UserLoginDlg").show();
  }

  function closeUserLoginDlg(){
      $("#lgusername").val('');
	  $("#lgpassword").val('');
	  $("#lgstatus").text('');
      $("#UserLoginDlg").hide();
  }

  function getCookie(name){
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return decodeURIComponent(arr[2]); return null;
  }

  function delCookie(name){
    var exp = new Date();
    exp.setTime(exp.getTime() - 100);
    var cval=getCookie(name);
    if(cval!=null) setCookie(name,cval,-100);
  }

  function setCookie(name,value,second){
    var exp  = new Date();  
    exp.setTime(exp.getTime() + second*1000);
    document.cookie = name + "="+ encodeURIComponent (value) + ";expires=" + exp.toGMTString() + ";path=/";
  }
  -->
