﻿// JScript 文件


function IntLoad()
{
  var strContent=null;
  strContent="用户名：<input type=\"text\" id=\"txtusername\" class=\"inputwidth\" /> 密码：<input  id=\"txtpassword\" type=\"password\" class=\"inputwidth\"  /> <input type=\"button\" value=\"登录\"  id=\"btuser\" onclick=\"checkLogin();\"/>"
  strContent+="<img id=\"imgsrc\" src=\"\"   style=\"display:none\"/>"; 
  return strContent;
    

}


function checkLogin()
 { 
   var txtusername=$("#txtusername");
   var txtpassword=$("#txtpassword");
   
   if (txtpassword.val()==""||txtusername.val()=="")
   {
   alert('用户名或密码不能为空!');
 
   return ;
   }
  $.ajax({
        Type:"POST",
        dataType:"json",
        url:"/ajax/checkLogin.ashx",
        cache:false,
        data:"username="+encodeURI(txtusername.val())+"&password="+txtpassword.val(),
        success:function(json)
        { 
        
          json=json.checkLogin;
           
          if (json.length>0)
          {
          
           if (json[0].reslut==1)
             { 
                // alert(json[1].msg);
                 $("#imgsrc")[0].src=json[3].src;
                 
                 //alert($("#imgsrc")[0].src);  
                 
               $("#login").html("欢迎:<font color='red'>"+json[2].username+" </font> &nbsp;| &nbsp;<a href='http://bbs.wauxi.com/usercp.aspx'  target='_blank'> 用户中心</a> &nbsp;| &nbsp;<a href='###' onclick='tuichu()'  id='zhuxiao'>注销登陆</a>");
                
             
          
           }else
           { 
            alert(json[1].msg);
             
           }
           
          
          }
         
        }
       
        });
 
 }                     
function  hidelogin()
 {  
//  $("#login").html("<img id=\"imgsrc\" src='http://bbs.wauxi.com/IsNoCookie.aspx'   style=\"display:none\"/>");
  $.ajax({
        Type:"POST",
        dataType:"json",
        url:"/ajax/checkCookie.ashx",
         cache:false,
        data:"",
        success:function(json)
        { 
          json=json.checkCookie;
          //alert(json[0].reslut);
          
          if (json.length>0)
          {
           
           if (json[0].reslut==1)
           { 
             $("#login").html("欢迎:<font color='red'>"+json[2].username+" </font> &nbsp;|&nbsp; <a href='http://bbs.wauxi.com/usercp.aspx'  target='_blank'>用户中心</a> &nbsp;| &nbsp;<a href='###'  id='zhuxiao' onclick='tuichu()'>注销登陆</a>");
           
          
           }else
           {
         
            $("#login").html( IntLoad());
           
           
          
           }
           
         
          }
         
        }
       
        });
 

       
 }
 
 function tuichu()
 {
//  $.ajax({
//        Type:"POST",
//        dataType:"json",
//        url:"/ajax/clearCookie.ashx",
//         cache:false,
//        data:"",
//        success:function(json)
//        { 
//         
//        
//        }
//       
//        });

         alert("注销成功");
    $("#login").html( IntLoad());
     $("#imgsrc")[0].src="http://bbs.wauxi.com/userreser.aspx";
 }
 $(function (){
         hidelogin();
         
        // $("#zhuxiao").bind('click',function(){alert('ss');})
         $(this).keydown(function(e){
                                     if(e.keyCode==13)
                                     {
                                       $(".btnsybj").trigger('click');

                                     }
                                     });
 
		  })
             function moveR(leftwitdh) { 
              
               $("#login").css({"display":"block","top":"21px","left":document.documentElement.clientWidth-leftwitdh }); //$("#login").offset().top+
                          $("#login").draggable({  
                            cursor:'move'
                            
                           });    
                             $("#login>h1").dblclick(function (){  hidelogin(); });
                             $("#login>h1").css({ cursor: 'move' });
                             }
 
 

 
                           
 function  checkcookie()
 {
  $.ajax({
        Type:"POST",
        dataType:"json",
        url:"/ajax/checkCookie.ashx",
         cache:false,
        data:"",
        success:function(json)
        { 
          json=json.checkCookie;
          if (json.length>0)
          {
           
           if (json[0].reslut==1)
           { 
             $("#logincontent").html("<div id='login'>欢迎:  <span class=show  >"+json[2].username+"</span><a href='###'  id='zhuxiao' onclick='tuichu()'>注销登陆</a></div>");
             $("#login").removeClass("login");
             $("#login").addClass("loginno");    
             moveR(190);
           }else
           {
         
           $("#logincontent").html( IntLoad());
            moveR(215);
           }
           
            
          }
         
        }
       
        });
 
 }
               
               
               
               
               
               
               
               
