﻿// JScript 文件

 $(document).ready(
           function(){
                Go1();
                $("#btnLogin").click(function(){Login();})
                $("#goout").click(function(){Go2();})
                $("#scrollDiv").Scroll({line:3,speed:2000,timer:4000});
                $("#ButtonSearch").click(function(){Go3();})      
                 }
        );
        
        function Login()
        {
            if(Check())
            {
                Go();
            }
        }
        function Check()
        {
            if($("#txtUserID").val()=="")
            {
                alert("帐号不能为空!");
                $("#txtUserID").focus();
                return false;
            }
            if($("#txtPass").val()=="")
            {
                alert("密码不能为空!");
                $("#txtPass").focus();
                return false;
            }
            return true;
        }
        
        function Go()
        {
            if($("#txtUserID").val()==""){
                alert("请输入会员名！");
                return ;
            }
            if($("#txtPass").val()==""){
                alert("请输入密码！");
                return ;
            }
         
            var uname = $("#txtUserID").val();
            
            $.ajax({
                 url: "/LoginCheck.aspx",
                 type:"POST",
                 cache: false,
                 data:"UserID="+$("#txtUserID").val()+"&UserPass="+$("#txtPass").val(),
                 contentType:"application/x-www-form-urlencoded; charset=UTF-8",
                 dataType:"json",
                 processData:false,
                 
                 success: function (data){
                    if(data.result=="success")
                     {
                       $("#div01").show();
                       $("#div02").hide();
                       $("#iuser").html(data.username);
                     }
                     if(data.result=="Locking")
                     {
                      alert("您的账户已经被锁定，请与管理员联系！");
                     }
                      if(data.result=="NotActivated")
                     {
                      alert("您还没有激活您的帐户，请于24小时之内点击您邮箱中的链接激活您的账户！");
                      location.href='/supply/UserRegister3.aspx?email="' + data.email +'"';
                     }
                     if(data.result=="fail")
                     {
					 //alert(data.name);
                      alert("您输入的用户名或密码有误，请重新输入！");
                     }
		    }
        }); 
		}
       // function Go()
       //{
            //$.post("LoginCheck.aspx", { Action: "post", UserID: $("#txtUserID").val(),UserPass: $("#txtPass").val() },
		    //function (data){
                    //if(data.result=="success")
                    //{
                       //$("#div01").show();
                       //$("#div02").hide();
                       //$("#iuser").append(data.username);
                     //}
                     //if(data.result=="Locking")
                     //{
                      //alert("您的账户已经被锁定，请与管理员联系！");
                     //}
                      //if(data.result=="NotActivated")
                     //{
                      //alert("您还没有激活您的帐户，请于24小时之内点击您邮箱中的链接激活您的账户！");
                      //location.href='../supply/UserRegister3.aspx?email="' + data.email +'"';
                     //}
                     //if(data.result=="fail")
                     //{
                      //alert("您输入的用户名或密码有误，请重新输入！");
                     //}
		    //},
		     //"json");
			    //}
        function Go1()
        {
            $.post("SessionCheck.aspx", { Action: "post"},
		    function (data){
                      if(data.result!="fail")
                     {
                       $("#div01").show();
                       $("#div02").hide();
                       $("#iuser").append(data.result); 
                      }
		    },
		     "json");
		     
       }
       function Go2()
        {
            $.post("SessionCheck1.aspx", { Action: "post"},
		    function (data){
                      if(data.result=="success")
                     {
                       $("#div02").show();
                       $("#div01").hide();
                     }
		    },
		     "json");
		     
       }
        function Go3()
        {

        if ($("input:radio:checked[name='RadioButtonSearch']").val()==1)
        {
        location.href="/supply/Productlist.aspx?keyword=" + $("#kw").val();  
        }
        else
        {
        if ($("input:radio:checked[name='RadioButtonSearch'][checked]").val()==2)
        {
        location.href="/supply/Companylist.aspx?keyword=" + $("#kw").val();  
        }     
        }
        }
$(function(){   
       $("#kw").bind("keyup",function(event) {   
            // aa(event);   
          if(event.keyCode==13){   
                Go3();   
        }   
         });
      $("#txtUserID").bind("keyup",function(event) {   
            // aa(event);   
          if(event.keyCode==13){   
                Login();   
        }   
         });
      $("#txtPass").bind("keyup",function(event) {   
            // aa(event);   
          if(event.keyCode==13){   
                Login();   
        }   
         });                                           
     });  

(function($){
$.fn.extend({
        Scroll:function(opt,callback){
                //参数初始化
                if(!opt) var opt={};
                var _this=this.eq(0).find("ul:first");
                var        lineH=_this.find("li:first").height(), //获取行高
                        line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数，默认为一屏，即父容器高度
                        speed=opt.speed?parseInt(opt.speed,10):500, //卷动速度，数值越大，速度越慢（毫秒）
                        timer=opt.timer?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
                if(line==0) line=1;
                var upHeight=0-line*lineH;
                //滚动函数
                scrollUp=function(){
                        _this.animate({
                                marginTop:upHeight
                        },speed,function(){
                                for(i=1;i<=line;i++){
                                        _this.find("li:first").appendTo(_this);
                                }
                                _this.css({marginTop:0});
                        });
                }
                //鼠标事件绑定
                
                _this.hover(function(){
                        clearInterval(timerID);
                },function(){
                        timerID=setInterval("scrollUp()",timer);
                }).mouseout();
        }        
})
})(jQuery);

