﻿// JScript 文件

var xmlHttp;//创造xmlHttpRequest对象
 function createXMLHttpRequest()
   {
      if(window.ActiveXObject)
          {
             xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
             
          }
          else if(window.XMLHttpRequest)
             {
               xmlHttp=new XMLHttpRequest();
             }
     }
function checklogin()   //登陆检测
  {
   var acookie=document.cookie.split("; ");
     var username=document.getElementById("username").value;
     var password=document.getElementById("password").value;
     var yanzheng=document.getElementById("yanzheng").value;
     if(username.length==0)
       {  
         document.getElementById("error").innerText="温馨提示:请输入用户名";
         window.event.returnValue=false;
         return false;
        }
        else
          {
              if(password.length==0)
                {
                     document.getElementById("error").innerText="温馨提示:请输入密码";
                     window.event.returnValue=false;
                      return false;
                }
                else
                {
                    if(yanzheng.length==0)
                        {
                           document.getElementById("error").innerText="温馨提示:请输入验证码";
                           window.event.returnValue=false;
                            return false;
                        }
                        else
                        {
                            var yz=getck(acookie);//验证码
                            if(yanzheng!=yz)
                                 {
                                     document.getElementById("error").innerText="温馨提示:验证码错误.";
                                     window.event.returnValue=false;
                                     return false;
                                 }
                        }
                }
          }
        createXMLHttpRequest();//创建对象
        var url="ajax.aspx?username="+username+"&password="+password+"&types=1";
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange=callback;
        xmlHttp.send(null);
  }
 function getck(acookie)
    {//获取cookies值
       var sname="CheckCode";
        for(var i=0;i<acookie.length;i++)
         {
            var arr=acookie[i].split("=");
            if(sname==arr[0])
            {
                if(arr.length>1)
                return unescape(arr[1]);
                else
                return "";
             }
          }
          return "";
    }

  //回调函数
  function callback()
    {
      document.getElementById("error").innerText="系统正在登陆中,请稍候...";
       if(xmlHttp.readyState==4)
           {
              if(xmlHttp.status==200)
                  {
                     if(xmlHttp.responseText=="true")
                      {
                         window.location.href="Admin_main.aspx";
                      }
                     if(xmlHttp.responseText=="false")
                      {
                        document.getElementById("error").innerText="温馨提示:用户名或密码错误";
                         window.event.returnValue=false;
                     }
                      if(xmlHttp.responseText=="repeat")
                      {
                        document.getElementById("error").innerText="温馨提示:此用户已经登陆,请勿重复登陆";
                         window.event.returnValue=false;
                     }
                  }
                 
            }
             window.event.returnValue=false;
      }
      
      function getmessage()
      {
         setInterval("getnewsmessage()",100)
         
      }
      function getnewsmessage()
      {
         createXMLHttpRequest();//创建对象
        var url="test.aspx?types=21";
        xmlHttp.open("GET",url,false);
       xmlHttp.onreadystatechange=checkbacks222;
        xmlHttp.send(null);
       }
        function checkbacks222()
    {
       if(xmlHttp.readyState==4)
           {
              if(xmlHttp.status==200)
                  {
//                     if(xmlHttp.responseText=="true")
//                      {
//                          alert("温馨提示:此用户名已经被注册,请选择其它用户名进行注册.");
//                           window.event.returnValue=false;
                            document.getElementById("TextBox1").innerText=xmlHttp.responseText;
//                      }
//                    else
//                      {
//                         alert("温馨提示:祝贺你,此用户名暂时没有被注册,您可以注册此用户.");
//                         window.event.returnValue=false;
//                     }
                  }
                 
            }
      }
     
 //检测用户名是不是有重复的
function checkrepeat() 
  {
     var username=document.getElementById("username").value;
    if(username.length==0)
       {  
         alert("温馨提示:请先输入用户名再检测.");
         document.getElementById("username").focus();
          window.event.returnValue=false;
          return false;
        }
        createXMLHttpRequest();//创建对象
        var url="Admin/ajax.aspx?username="+username+"&types=21";
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange=checkbacks;
        xmlHttp.send(null);
  }
      
      //回调函数
  function checkbacks()
    {
       if(xmlHttp.readyState==4)
           {
              if(xmlHttp.status==200)
                  {
                     if(xmlHttp.responseText=="true")
                      {
                          alert("温馨提示:此用户名已经被注册,请选择其它用户名进行注册.");
                           window.event.returnValue=false;
                      }
                    else
                      {
                         alert("温馨提示:祝贺你,此用户名暂时没有被注册,您可以注册此用户.");
                         window.event.returnValue=false;
                     }
                  }
                 
            }
             window.event.returnValue=false;
      }
      
      
      
      
//登陆用户是不是超时了.
  function checkout()
    {
      setInterval("yesnoout()",600000)
    }
    function yesnoout()
      {
              createXMLHttpRequest();//创建对象
              var url="ajax.aspx?types=5";
              xmlHttp.open("POST",url,false);
              xmlHttp.onreadystatechange=checkurl;
              xmlHttp.send(null);
      }
      function checkurl()
        {
          if(xmlHttp.readyState==4)
           {
              if(xmlHttp.status==200)
                  {
                   if(xmlHttp.responseText=="true")
                      {
                        //alert("温馨提示:由于您长时间对系统无任何操作,为了节省服务器资源,系统将自动退出,请重新登陆.");
                        window.open("Admin_Login.aspx","_parent")
                      }
                  }
             }
        }
      function setuser()//在关闭关闭页面之前执行在线人数的减少
      {
              createXMLHttpRequest();//创建对象
              var url="ajax.aspx?types=12";
              xmlHttp.open("GET",url,false);
              xmlHttp.onreadystatechange=seeback;
              xmlHttp.send(null);
         
      }
      function seeback()
      {
      }
       function  goout1()//关闭浏览器在线人数让在线人数减1
        {
        
              createXMLHttpRequest();//创建对象
              var url="ajax.aspx?types=11";
              xmlHttp.open("GET",url,true);
              xmlHttp.onreadystatechange=seeback;
              xmlHttp.send(null);
       }
       function seeaspx()//打开浏览器显示在线人数
      {
         
              createXMLHttpRequest();//创建对象
              var url="ajax.aspx?types=13";
              xmlHttp.open("GET",url,true);
              xmlHttp.onreadystatechange=seeback;
              xmlHttp.send(null);
        
      }
      function shishi()//每隔五秒钟调用一次在线人数统计
       {
          setInterval("selected1()",1000)
       }
      function selected1()
       {
          createXMLHttpRequest();//创建对象
          var url="Admin/ajax.aspx?types=14";
          xmlHttp.open("Post",url,false);
          xmlHttp.onreadystatechange=seecomeback;
          xmlHttp.send(null);
       }
      
      function seecomeback()
      {
        if(xmlHttp.readyState==4)
           {
              if(xmlHttp.status==200)
                  {
                    document.getElementById("Label3").innerText=xmlHttp.responseText;
                  }
             }
      }
      
      //验证用户是不是有权限
      
       function checkselect1()
      {
         var checkvalue= document.getElementById("forms").value;
          createXMLHttpRequest();//创建对象
              var url="ajax.aspx?types=15&classid="+checkvalue;
              xmlHttp.open("GET",url,true);
              xmlHttp.onreadystatechange=checkback;
              xmlHttp.send(null);
      }
       function checkselect2()
      {
       var checkvalue= document.getElementById("forms").value;
       if(parseInt(checkvalue)==0)
       {
         alert("温馨提示:请选择需要添加到那个分类下面.");
        document.getElementById("BtnSubmit").disabled=true;
          window.event.returnValue=false;
          return false;
       }
       else
       {
          document.getElementById("BtnSubmit").disabled=false;
       }
      }
       function checkselect3()
      {
       var checkvalue= document.getElementById("forms").value;
       if(parseInt(checkvalue)==0 || parseInt(checkvalue)==244)
       {
         alert("温馨提示:请选择需要添加到那个分类下面.");
        document.getElementById("BtnSubmit").disabled=true;
          window.event.returnValue=false;
          return false;
       }
       else
       {
          document.getElementById("BtnSubmit").disabled=false;
       }
      }
       function checkback()
      {
         if(xmlHttp.readyState==4)
            {
              if(xmlHttp.status==200)
                  {
                     if(xmlHttp.responseText=="true")
                      {
                         document.getElementById("BtnSubmit").disabled=false;
                      }
                   if(xmlHttp.responseText=="false")
                      {
                         alert("温馨提示:你没有在此栏目下添加新闻的权限,请与管理员联系.");
                         document.getElementById("BtnSubmit").disabled=true;
                      }
                      if(xmlHttp.responseText=="nohereadd")
                      {
                        alert("温馨提示:请选择他的子栏目.");
                          document.getElementById("BtnSubmit").disabled=true;
                      }
                        if(xmlHttp.responseText=="checkone")
                      {
                        alert("温馨提示:请选择一个子栏目.");
                        document.getElementById("BtnSubmit").disabled=true;
                      }
             }
        }
    }
      
      //新闻的浏览数加1
      function addclicks(nid)
        {
              createXMLHttpRequest();//创建对象
              var url="../Admin/ajax.aspx?types=16&id="+nid;
              xmlHttp.open("GET",url,true);
             xmlHttp.onreadystatechange=checkback1;
              xmlHttp.send(null);
        } 
      function checkback1()
      {
        if(xmlHttp.readyState==4)
           {
              if(xmlHttp.status==200)
                  {
                     document.getElementById("clicks").innerHTML=xmlHttp.responseText;
                  }
           }
      }
        //软件下载的人气数加1
       function addsoftclick(nid)
        {
            createXMLHttpRequest();//创建对
            var url="../Admin/ajax.aspx?types=17&id="+nid;
              xmlHttp.open("GET",url,true);
             xmlHttp.onreadystatechange=checkback2;
              xmlHttp.send(null);
        } 
      function checkback2()
      {
        if(xmlHttp.readyState==4)
           {
              if(xmlHttp.status==200)
                  {
                     var backvalue=xmlHttp.responseText;
                     var str=new Array();
                    str=backvalue.split(",");
                     document.getElementById("clicks").innerHTML=str[0];
                      document.getElementById("download").innerHTML=str[1];
                  }
             }
      }
   //产品与服务浏览次数加
      
    function addproclicks(nid)
        {
              createXMLHttpRequest();//创建对象
              var url="Admin/ajax.aspx?types=18&id="+nid;
              xmlHttp.open("GET",url,true);
             xmlHttp.onreadystatechange=checkback13;
              xmlHttp.send(null);
        } 
      function checkback13()
      {
        if(xmlHttp.readyState==4)
           {
              if(xmlHttp.status==200)
                  {
                     document.getElementById("clicks").innerHTML=xmlHttp.responseText;
                  }
           }
      }
     //检测用户的状态是不是登录
      
       function checkuserstate()
        {
              createXMLHttpRequest();//创建对象
              var url="Admin/ajax.aspx?types=19";
              xmlHttp.open("GET",url,true);
             xmlHttp.onreadystatechange=checkback14;
              xmlHttp.send(null);
        } 
      function checkback14()
      {
        if(xmlHttp.readyState==4)
           {
              if(xmlHttp.status==200)
                  {
                    if(xmlHttp.responseText=="false")
                     {
                         document.getElementById("loginstate").innerHTML="<a href=seereg.htm  target=parent title=欢迎注册>注册</a>&nbsp;&nbsp;<a href=error.aspx title=欢迎登录 target=parent>登录</a>&nbsp;&nbsp;<a href=getpwd.aspx title=忘记密码取回您的密码 target=parent>忘记密码</a>";
//                       document.getElementById("loginstate").className="txt5";
                    }
                    else
                    {
                       document.getElementById("loginstate").innerHTML=""+xmlHttp.responseText+":您已经成功登陆&nbsp;<a href=javascript:loginout() title=点击注销登录>退出</a>";
                    }
                  }
           }
      }
      
      //////////////////////////退出登录
 function loginout()
 {
        createXMLHttpRequest();//创建对象
        var url="Admin/ajax.aspx?types=46";
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange=callback15;
        xmlHttp.send(null);
 }
  function callback15()
    {
       if(xmlHttp.readyState==4)
           {
           
              if(xmlHttp.status==200)
                  {
                     if(xmlHttp.responseText=="true")
                      {
                          document.getElementById("loginstate").innerHTML="<a href=seereg.htm  target=parent title=欢迎注册>注册</a>&nbsp;&nbsp;<a href=error.aspx title=欢迎登录 target=parent>登录</a>&nbsp;&nbsp;<a href=getpwd.aspx title=忘记密码取回您的密码 target=parent>忘记密码</a>";
                      }
                  }  
            }
      }
      