﻿// JScript 文件
function uplogin()
{
  if (event.keyCode==13)
  {
    mylogins();
  }
}
var insers=''
    +'用户名：<input type="text" name="username" class="swap_value" id="Name"  onkeydown="uplogin()"  />'
    +'&nbsp;&nbsp;密码：'
    +'<input type="password" name="username" class="swap_value" id="Pwd"    onkeydown="uplogin()" />'
    +'&nbsp;'
    +'  <input name="login" type="button" class="dl" onclick="mylogins()" />'
    +'&nbsp; <a href="code/register.aspx"><img src="images/images-1.gif" border="0" /></a>&nbsp; <a   onclick="AddFavorite(window.location,document.title)"  ><img src="images/images-2.gif" border="0" /></a>'
;

function GetNames(data)
{
var nss=''

+'欢迎：'+data
    +'&nbsp;&nbsp;'
    +''
    +'&nbsp;'
    +'  <a onclick="zhuxiao()" style=" cursor:pointer;">注销</a>'
    +'&nbsp; &nbsp; <a   onclick="AddFavorite(window.location,document.title)" ><img src="images/images-2.gif" border="0" /></a>'


var snss='<a onclick="zhuxiao()" style=" cursor:pointer;color:white;">注销</a>';
//$('#conslogin').html(ns);
$('#conslogin').html(nss);
}





//----------------
function mylogins()
{
    names=$('#Name').val();
    $.ajax(
         {
            type:'POST',
            url:sjzsmsServiceUrl+'/NJSQLogin',
            data:{
               name:$('#Name').val(),  pwd:$('#Pwd').val()              
            },
            dataType:'xml',
            beforeSend:function(){$('#conslogin').html('<div>登陆中...</div>');},
            success:function(data)
            {
              if($(data).find('string ').text()!='0')
              {
               
               sGetXmlValues('NJSQUsersSession',GetNames);
              }
              else
              {
                $('#conslogin').html(insers);
                alert('用户或密码错误');
               
              }
              
            }
         }
       );
     
  
}
function zhuxiao()
{
 $.ajax(
         {
            type:'POST',
            url:sjzsmsServiceUrl+'/NJSQLoginOut ',            
            dataType:'xml',
            beforeSend:function(){},
            success:function(data)
            {
              $('#conslogin').html(insers);
              
            }
         }
       );//onload();
       $('#conslogin').html(insers);
       
        $('#toplogin').html('<a href="code/login.shtm">网站登录</a>');
}
$(function()
{
  $.ajax(
         {
            type:'POST',
            url:sjzsmsServiceUrl+'/NJSQUsersHasLogin',            
            dataType:'xml',
            beforeSend:function(){$('#conslogin').html('<div>验证用户...</div>');},
            success:function(data)
            {
              if($(data).find('string ').text()!='0')
              {
                
                sGetXmlValues('NJSQUsersSession',GetNames);
              }
              else
              {
                $('#conslogin').html(insers);
                $('#toplogin').html('<a href="code/login.shtm">网站登录</a>');
               
              }
              
            }
         }
       );
       
}
)

function onload()
{
 $.ajax(
         {
            type:'POST',
            url:sjzsmsServiceUrl+'/NJSQUsersHasLogin',            
            dataType:'xml',
            beforeSend:function(){},
            success:function(data)
            {
              if($(data).find('string ').text()!='0')
              {
                sGetXmlValues('NJSQUsersSession',GetNames);
              }
              else
              {
                $('#conslogin').html(insers);
                
               
              }
              
            }
         }
       );
}


