﻿// JScript 文件
function ShowInfoMessage(text)
{
    var html;
   
    
//    html = '<div style="position: absolute; top: '+ (document.documentElement.scrollTop+400) +'px; left: 400px; background: white;width: 300px; height: 80px; border: 2px solid #cccccc;">';
//    html += '<div style="padding: 0px 10px;*padding:1px 10px;">';
//    html += '<p style="text-align:left; font-size: 14px;padding:0px;">';   
//       
//    html += text;   
//    
//    html += '</p>';
//    html += '<p style="text-align: right; padding-right: 10px;clear:both">';    
//    
//    html += '<input class="btn" type="button" value="确定" onclick="$(\'showinfo\').style.display=\'none\'" />';                   
//    html += '</p>'; 
//    html += '</div>';      
//    html += '</div>'; 
    
   
    
    
    
    html='<div class="ss">';
    html+='<div class="cc">';
    
    html+='<a class="a_link" href="###" onclick="$(\'showinfo\').style.display=\'none\'">[关闭]</a>';
    html+='</div>';

    html+='<div class="kk">'+text+'</div>';
    html+='</div>';
     $('showinfo').innerHTML = html;           
    $('showinfo').style.display='';   
 }
 
function Show(text)
{
    var html='';
    
    html+='<table width="158" border="0" cellspacing="0" cellpadding="0" style="background:url(../image/z-100.jpg) no-repeat; width:158px; height:60px;">';
    html+='<tr>';
    html+='<td height="30">&nbsp;';
    html+=text;
    html+='</td>'
    html+='</tr>';
    html+='<tr>';
  
    html+='<td height="30" align="right" valign="middle">';
    html+='<table width="150" border="0" align="center" cellpadding="0" cellspacing="0">';
    html+='<tr>';
    html+='<td width="89" align="right" valign="middle"><img src="../image/z-99.jpg" width="39" height="15" /></td>';
    html+='<td width="10" height="25" align="left" valign="middle">&nbsp;</td>'; 
    html+='<td width="51" align="left" valign="middle"><img src="../image/z-98.jpg" width="39" height="15" /></td>';   
    html+='</tr>';   
    html+='</table>';  
    html+='</td>';
    html+='</tr>'; 
    html+='</table>';
    $('showinfo1').innerHTML=html;
    $('showinfo1').style.display='';
  

}

//判段文本框是否为空
function TextIsNull(username,strmessage,divname,divjpg)
{
    if(username=='')
    {
        $(divname).innerHTML=strmessage;
        $(divname).style.display='';
        $(divjpg).style.display='none';
       
        
    }
    else
    {
        $(divname).style.display='none';
         $(divjpg).style.display='';
          
    }
}
//判段密码确认密码是否一至
function IsPassWrodAccord(password,password1,divname)
{
    if(password1=='')
    {
        $(divname).innerHTML='确认密码不能为空';
        $(divname).style.display='';
    }
    else if(password!=password1)
    {
        $(divname).innerHTML='密码与确认密码不一致';
        $(divname).style.display='';
        $('password1jpg').style.display='none';
    }
    else
    {
        $(divname).style.display='none';
        $('password1jpg').style.display='';
    }
    
}
function IsEmail(email,divname)
{
    
    var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
    if(email=='')
    {
        $(divname).innerHTML='邮箱地址不能为空';
        $(divname).style.display='';
        $('emailjpg').style.display='none';
    }
    else if(!myreg.test(email))
    {
        $(divname).innerHTML='邮箱格式不正确';
        $(divname).style.display='';
        $('emailjpg').style.display='none';
    }
    else
    {
         $(divname).style.display='none';
         $('emailjpg').style.display='';
    }
    

}
function IsUserExist(username,divname)
{
    if(username=='')
    {
       
        $(divname).innerHTML='用户名不能为空';
        $(divname).style.display='';
        $('usernamedivjpg').style.display='none';
       return;
        
    }
   
    else
    {
        _sendRequest('../user/Ajax.aspx?username='+username+'&t=userexist', function (responseText){

            var xml = getSingleNodeValue(responseText,'info');
            if(xml=='no')
            {
                $(divname).innerHTML='用户名已存在';
                 $(divname).style.display='';
                 $('usernamedivjpg').style.display='none';
                return;
            }
            if(xml=='yes')
            {
                $(divname).style.display='none';
                 $('usernamedivjpg').style.display='';
            }
        }, true, false);
    }
    
    
}

function Login(username,paswword,yanzhengtext)
{

    _sendRequest('../user/Ajax.aspx?username='+username+'&password='+paswword+'&yanzheng='+yanzhengtext+'&t=islogin', function (responseText)
    {
            var xml = getSingleNodeValue(responseText,'info');
            if(xml=='ok')
            {
                window.location.href='../index/index.aspx?type=ok';
               return;
            }
            if(xml=='no')
            {
                $('islogindiv').innerHTML='您输入的用户名或密码错误';
                $('islogindiv').style.display='';
                return;
            }
            if(xml=='no1')
            {
                $('islogindiv').innerHTML='您输入的验证码有错误';
                $('islogindiv').style.display='';
            }
          
           
            
        
        }, true, false);
}
function Login1(username,paswword,yanzhengtext,sender)
{
    window.location.href='../user/Ajax.aspx?username='+username+'&password='+paswword+'&yanzheng='+yanzhengtext+'&t=islogindex';
//    _sendRequest('../user/Ajax.aspx?username='+username+'&password='+paswword+'&yanzheng='+yanzhengtext+'&t=islogindex', function (responseText)
//    {
//            var xml = getSingleNodeValue(responseText,'info');
//            if(xml=='ok')
//            {
//                window.location.href='../index/index.aspx?type=ok';
//               return;
//            }
//            if(xml=='no')
//            {
//                $('isloginindexdiv').innerHTML='您输入的用户名或密码错误';
//                $('isloginindexdiv').style.display='';
//                return;
//            }
//            if(xml=='no1')
//            {
//                $('isloginindexdiv').innerHTML='您输入的验证码有错误';
//                $('isloginindexdiv').style.display='';
//            }
//            if(xml=="no2")
//            {
//                $('isloginindexdiv').innerHTML='账号被冻结,充值后自已解冻';
//                $('isloginindexdiv').style.display='';
//                $('chongzhi').style.display='';
//                 
//            }
//         
//           
//            
//        
//        }, true, false);
            
        
      
}
function validateUserRegister(oForm)
{
    var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
    var num = /^[0-9]*$/;
    if(oForm.username.value=='')
    {
        ShowInfoMessage('用户名不能为空');
        return;
    }
    else if(oForm.password.value=='')
    {
        ShowInfoMessage('密码不能为空');
        return 
    }
    else if(oForm.password1.value=='')
    {
        ShowInfoMessage('确认密码不能为空');
        return;
    }
     else if(oForm.password.value!=oForm.password1.value)
    {
        ShowInfoMessage('密码与确认密码不一样');
        return;
    }
    else if(oForm.email.value=='')
    {
        ShowInfoMessage('邮箱地址不能为空');
        return;
    }
    else if(oForm.passwordquestion.value=='')
    {
        ShowInfoMessage('问题提示不能为空');
        return;
    }
    else if(oForm.passanswer.value=='')
    {
        ShowInfoMessage('问题回答不能为空');
        return;
    }
    else if(oForm.phone.value=='')
    {
        ShowInfoMessage('电话号码不能为空');
        return;
    }
    else if(oForm.mobile.value=='')
    {
        ShowInfoMessage('手机号码不能为空');
        return;
    }
    else if(oForm.address.value=='')
    {
        ShowInfoMessage('地址不能为空');
        return;
    }
    else if(oForm.postcode.value=='')
    {
        ShowInfoMessage('邮编不能为空');
        return;
    }
   
    else if(!myreg.test(oForm.email.value))
    {
       ShowInfoMessage('邮箱格式不正确');
       return;
        
    }
    else if(!num.test(oForm.phone.value))
    {
        ShowInfoMessage('电话只能为数字格式');
        return;
    }
     else if(!num.test(oForm.postcode.value))
    {
        ShowInfoMessage('邮编只能为数字格式');
        return;
    }
     else if(!num.test(oForm.mobile.value))
    {
        ShowInfoMessage('手机号只能为数字格式');
        return;
    }
    else if(oForm.checkbox.value!='1')
    {
         ShowInfoMessage('请选择协议');
       return;
    }
    else 
    {
         _sendRequest('../user/Ajax.aspx?t=registeruser', function (responseText)
        {
            var xml = getSingleNodeValue(responseText,'info');
            if(xml=='No')
            {
                ShowInfoMessage('您注册用户时有错误');
                return;
            }
            if(xml=='Yes')
            {
                window.location.href='../index/index.aspx?type=ok';
            }
            if(xml=='No1')
            {
                ShowInfoMessage('用户名已存在');
            }
            if(xml=='No2')
            {
                ShowInfoMessage('密码和确认密码不一致');
            }
            if(xml=='No3')
            {
                ShowInfoMessage('验证码不正确');
            }
           
       }, true, getRequestBody(oForm));
    }
    
    
}
//修改用戶密碼
function UpdateUserPassWord(oForm)
{

     _sendRequest('../user/Ajax.aspx?t=updatepass', function (responseText)
     {
         var xml = getSingleNodeValue(responseText,'info');
         if(xml=='no1')
         {
            ShowInfoMessage('密码与确认密码不一致');
            return;
         }
         if(xml=='no2')
         {
            ShowInfoMessage('旧密码输入有误，请查证');
            return;
         }
         if(xml=='ok')
         {
            ShowInfoMessage('修改成功');
         }
         
          
           
     }, true, getRequestBody(oForm));
}

//修改用戶信息
function UpdateUserMessage(oForm)
{

     _sendRequest('../user/Ajax.aspx?t=updatemessage', function (responseText)
     {
         var xml = getSingleNodeValue(responseText,'info');
           if(xml=='emailNo')
           {
                ShowInfoMessage('邮箱格式不正确');
                return ;
           }
           if(xml=='nullNo')
           {
                ShowInfoMessage("以上选项不能为空");
                return;
           }
           if(xml=='ok')
           {
                ShowInfoMessage("修改成功");
                 window.location.href='../wdzh/UdateUserMessage.aspx';
                return;
           }
         
         
          
           
     }, true, getRequestBody(oForm));
}
function OutLogin()
{
     _sendRequest('../user/Ajax.aspx?&t=outlogin&time='+new Date().getTime()+'', function (responseText)
    {
          
            
            window.location.href='../user/login.aspx';
        
     }, true, false);
}
function ZhaoMM(oForm)
{
    if(oForm.username.value==''||oForm.email.vlaue==''||oForm.password3.value==''||oForm.password4.value=='')
    {
        alert('请您填写完整');
    }
    else
    {
    
     _sendRequest('../user/Ajax.aspx?t=zhaomm', function (responseText)
     {
         var xml = getSingleNodeValue(responseText,'info');
         if(xml=='nouser')
         {
            alert('没有这个用户');
         }
         if(xml=='no')
         {
            alert('您的密码查询问题或答案不正确')
         }
         if(xml=='yes')
         {
            alert('请到您邮箱中查找密码')
         }
         
          
           
     }, true, getRequestBody(oForm));
     }
}
function ChongZhi(username,cardid,cardpass)
{
      _sendRequest('../user/Ajax.aspx?&t=chongzhi&username='+username+'&cardid='+cardid+'&cardpass='+cardpass+'', function (responseText)
    {
           var xml = getSingleNodeValue(responseText,'info');
           if(xml=='yes')
           {
               alert('充值成功，请重请登陆');
                //window.location.href='../index/index.aspx';
              return; 
           }
           else
           {   
               alert(xml);
              return; 
           }
           
            
            
        
     }, true, false);
}
