﻿// JScript 文件


        function addfavorite()
        {
           if (document.all)
           {
              window.external.addFavorite('http://www.Gogo198.cn','旅行商城');
           }
           else if (window.sidebar)
           {
              window.sidebar.addPanel('旅行商城', 'http://www.Gogo198.cn', "");
           }
        }
        
        function jump_code()    
        { 
            var reg = /\w+[@]\w+[.]\w+/;
            var txtEmail = $("#txtEmail");
            if(reg.test(txtEmail.val()))
            {
                $.ajax
                ({                                 //调用jquery的ajax方法    
                    type: "POST",                          //设置ajax方法提交数据的形式    
                    url: "GogoUser.ashx",                                          
                    data: "action=2&email="+txtEmail.val(),
                    success: function(msg)
                    {                 //提交成功后的回调，msg变量是输出的内容。    
                    //alert("数据提交成功");                //如果有必要，可以把msg变量的值显示到某个DIV元素中
                       if(msg == "true")
                       {
                       $("#btnOK").attr("disabled" , false);
                       }
                       else
                       {
                       alert("该用户已经存在！");
                       $("#btnOK").attr("disabled" , true);
                       }
                    }
                });  
            }
         
        } 
        function Register()
        {
            var flag = CheckInput();
            if(flag)
            {
                $.post("GogoUser.ashx",{action:3,email:$("#txtEmail").val(),nick:$("#txtNickName").val(),pass:$("#txtPassword").val(),sex:$("#rblSex").val()},function(response){
                    var src = response.split(",");
                    parent.SetCookie("GogoUID",src[0],0);
                    parent.SetCookie("GogoUName",src[1],0);
//                    parent.tb_remove();
                    parent.btnOKclick();
                })
            }
        }
        function Login()
        {
            var flag = Check();
            if(flag)
            {
                $.post("GogoUser.ashx",{action:4,email:$("#txtEmail").val(),pass:$("#txtPassword").val()},function(response){
                    if(response == "false")
                    {
                        alert("用户名不存在或密码错误！");
                    }
                    else
                    {
                        var src = response.split(",");
                        parent.SetCookie("GogoUID",src[0],0);
                        parent.SetCookie("GogoUName",src[1],0);
//                        parent.tb_remove();
                        parent.btnOKclick();
                    }
                })
            }
        }
        
        function Check()
        {
            var txtEmail = document.getElementById("txtEmail");
            var reg = /\w+[@]\w+[.]\w+/;
            var txtPassword = document.getElementById("txtPassword");
            if(txtEmail.value.length == 0)
            {
                alert("账号不能为空！");
                txtEmail.focus();
                return false;
            }
            if(txtPassword.value.length == 0)
            {
                alert("登录密码不能为空！");
                txtPassword.focus();
                return false;
            }
            if(!reg.test(txtEmail.value))
            {
                alert("账号格式错误！");
                txtEmail.focus();
                txtEmail.select();
                return false;
            }
            return true;
        }
        
        function CheckInput()
        {
            var txtEmail = document.getElementById("txtEmail");
            var reg = /\w+[@]\w+[.]\w+/;
            var txtNickName = document.getElementById("txtNickName");
            var txtPassword = document.getElementById("txtPassword");
            var txtConfirmPwd = document.getElementById("txtConfirmPwd");
            if(txtEmail.value.length == 0)
            {
                alert("账号不能为空！");
                txtEmail.focus();
                return false;
            }
            if(txtNickName.value.length == 0)
            {
                alert("昵称不能为空！");
                txtNickName.focus();
                return false;
            }
            if(txtPassword.value.length == 0)
            {
                alert("登录密码不能为空！");
                txtPassword.focus();
                return false;
            }
            if(txtConfirmPwd.value.length == 0)
            {
                alert("确认密码不能为空！");
                txtConfirmPwd.focus();
                return false;
            }
            if(!reg.test(txtEmail.value))
            {
                alert("账号格式错误！");
                txtEmail.focus();
                txtEmail.select();
                return false;
            }
            if(txtConfirmPwd.value != txtPassword.value)
            {
                alert("两次输入的密码不一致！");
                txtConfirmPwd.focus();
                txtConfirmPwd.select();
                return false;
            }
            return true;
        }

