//检测用户
function checkuser2()
{
    var user =$("#"+globals.controlIdentities.host).val();
    if(user.length <=10)
    {
        $('#'+globals.controlIdentities.callBackMessage).html("Pls enter your cellphone number correctly");
        return false;
    }
    document.getElementById(globals.controlIdentities.callNotIsRegist).style.display = "none";
	document.getElementById(globals.controlIdentities.callIsRegist).style.display = "none";
    $('#'+globals.controlIdentities.callBackMessage).html("Checking the user’s name...");
    
    $.get("/English/AjaxAshx/Eajax.ashx?action=checkuser&mobile="+user+"&r="+ Math.random(),
    function(data){
          if(data != null )
          {
            if(data== "0")
            {
                $('#chargeuservilid').val("0");
                document.getElementById(globals.controlIdentities.callNotIsRegist).style.display = "";
                 $('#c1').hide();
                $('#c2').hide();
                $('#'+globals.controlIdentities.callBackMessage).html("Pls register first");
                return false;
            }
            else if(data == "-1")
            {
                $('#chargeuservilid').val("-1");
                $('#'+globals.controlIdentities.callBackMessage).html("Pls check your cellphone number");
                return false;
            }
            else if(data == "1")
            {
                $('#chargeuservilid').val("1");
                if(getCookie("czAnyCall")==null){
                    document.getElementById(globals.controlIdentities.callIsRegist).style.display = "block";
                }
                $('#c1').show();
                $('#c2').show();
                $('#'+globals.controlIdentities.callBackMessage).html("Valid User");
            }
          }
          else
          {
            $('#chargeuservilid').val("0");
            $('#'+globals.controlIdentities.callBackMessage).html("Pls check your cellphone number");
          }
    });   
}
//免费体验
function IsCallBackClick()
{
    var user = $("#"+globals.controlIdentities.host).val(); 
    var client = $('#'+globals.controlIdentities.client).val();
    var pwd = $('#'+globals.controlIdentities.callpwd).val();
    var card = $('#'+globals.controlIdentities.callValidate).val();
    var myreg = /^(((13[0-9]{1})|(18[0-9]{1}))|147|(15[0-9]{1}))+\d{8}$/;
    if(IsEmpty(user))
    {
         $('#'+globals.controlIdentities.callBackMessage).html("Pls enter cellphone number");
         return false;
    }
    if(user.length>11)
    {
         $('#'+globals.controlIdentities.callBackMessage).html("Pls enter your cellphone number correctly");
         return false;
    }
     if(!myreg.test(user))
    {
         $('#'+globals.controlIdentities.callBackMessage).text("Pls enter your cellphone number correctly");
            return false;
    }
    if(user=="Number to Dial:")
    {
        $('#'+globals.controlIdentities.callBackMessage).html("Pls enter cellphone number");
        return false;
    }
     if(IsEmpty(client))
    {
         $('#'+globals.controlIdentities.callBackMessage).html("Pls enter the cellphone number to dial");
         return false;
    }
    if(client=="Your Number:")
    {
        $('#'+globals.controlIdentities.callBackMessage).html("Pls enter the cellphone number to dial");
        return false;
    }
    if(IsEmpty(card))
    {
         $('#'+globals.controlIdentities.callBackMessage).html("pls enter the security code");
         return false;
    }
     return true;
}
//套餐切换
function MenuTab(str)
{
    if(str=='1')
    {
        document.getElementById("menutab1").className="Menu1_active";
        document.getElementById("menutab2").className="Menu1";
        document.getElementById("menutab3").className="Menu1";
        document.getElementById("home_taocan_content_1").style.display="block";
        document.getElementById("home_taocan_content_2").style.display="none";
        document.getElementById("home_taocan_content_3").style.display="none";
    }
    else if(str=='2')
    {
        document.getElementById("menutab1").className="Menu1";
        document.getElementById("menutab2").className="Menu1_active";
        document.getElementById("menutab3").className="Menu1";
        document.getElementById("home_taocan_content_1").style.display="none";
        document.getElementById("home_taocan_content_2").style.display="block";
        document.getElementById("home_taocan_content_3").style.display="none";
    }
    else if(str=='3')
    {
        document.getElementById("menutab1").className="Menu1";
        document.getElementById("menutab2").className="Menu1";
        document.getElementById("menutab3").className="Menu1_active";
        document.getElementById("home_taocan_content_1").style.display="none";
        document.getElementById("home_taocan_content_2").style.display="none";
        document.getElementById("home_taocan_content_3").style.display="block";
    }
    else{}
}
//网银充值
function checkpayment()
{
    $('#chargemsg').html('');
    var user = $('#'+globals.controlIdentities.chageuser).val();    
    
    var items = $("input[type='radio'][name='chargevalue']");

    if(items == null ||items.length <=0)
    {
        return false;
    }
    var money =0;
    var selected = 0;
    for(var i =0; i < items.length; i ++)
    {
        if(items[i].checked == true)
        {
            selected ++;
            money = items[i].value;
        }
    }
   if(money <= 0)
   {
    $('#chargemsg').html('pls choose topping up amount');
    return false;
   }
   if(money %10 != 0)
   {
    $('#chargemsg').html('Topping up rates must be in multiples of 10');
    return false;
   }
   
   if(user == "" || user == null)
   {
     $('#chargemsg').html('pls enter your cellphone number');
    return false;
   }
   
   if($('#chargeuservilid').val()== "-1")
   {
    $('#chargemsg').html('Pls enter your cellphone number correctly');
    return false;
   }
   
   if($('#chargeuservilid').val()== "0")
   {
    $('#chargemsg').html('Pls register first');
    return false;
   }
          
    var url = "/Recharge/ChinaPay/sendDateToChinaPay.aspx?m="+money + "&mobile="+ user+"&r="+ Math.random();
    document.getElementById("mypayment").href=url;
    return true;
}
//-----充值检测手机号
function checkuser()
{
    var user = $('#'+globals.controlIdentities.chageuser).val(); 
    
    if(user.length <=10)
    {
        $('#chargemsg').html('Pls enter cellphone number');
        return false;
    }
    
    $('#chargemsg').html('Checking the user’s name...');
     $.get("/English/AjaxAshx/Eajax.ashx?action=checkuser&mobile="+user+"&r="+ Math.random(),
    function(data){
          
          if(data != null )
          {
            if(data== "0")
            {
                $('#chargeuservilid').val("0");
                $('#chargemsg').html('Pls register first');
                return false;
            }
            else if(data == "-1")
            {
                $('#chargeuservilid').val("-1");
                $('#chargemsg').html('Pls check your cellphone number');
                return false;
            }
            else if(data == "1")
            
            {
                $('#chargeuservilid').val("1");
                $('#chargemsg').html('Valid User');
            }
          }
          else
          {
            $('#chargeuservilid').val("0");
            $('#chargemsg').html('Pls check your cellphone number');
          }
         
    });   
}
//支付宝支付检测手机号
function checkuserAliPay()
{
     var user = $('#'+globals.controlIdentities.chageuserAliPay).val(); 
    if(IsEmpty(user))
    {
        $('#AliPayMsg').html('Pls enter cellphone number');
        return false;
    }
    if(user.length <=10)
    {
        $('#AliPayMsg').html('Pls enter cellphone number');
        return false;
    }
    
    $('#AliPayMsg').html('Checking the user’s name...');
     $.get("/English/AjaxAshx/Eajax.ashx?action=checkuser&mobile="+user+"&r="+ Math.random(),
    function(data){
          
          if(data != null )
          {
            if(data== "0")
            {
                $('#chargeuservilid').val("0");
                $('#AliPayMsg').html('Pls register first');
                return false;
            }
            else if(data == "-1")
            {
                $('#chargeuservilid').val("-1");
                $('#AliPayMsg').html('Pls check your cellphone number');
                return false;
            }
            else if(data == "1")
            {
                $('#chargeuservilid').val("1");
                $('#AliPayMsg').html('Valid User');
            }
          }
          else
          {
            $('#chargeuservilid').val("0");
            $('#AliPayMsg').html('Pls check your cellphone number');
          }
         
    });   
}
//支付宝充值
function checkpaymentAliPay()
{
    $('#AliPayMsg').html('');
    var user = "86"+$('#'+globals.controlIdentities.chageuserAliPay).val();    
    
    var items = $("input[type='radio'][name='chargeAliPay']");

    if(items == null ||items.length <=0)
    {
        return false;
    }
    var money =0;
    var selected = 0;
    for(var i =0; i < items.length; i ++)
    {
        if(items[i].checked == true)
        {
            selected ++;
            money = items[i].value;
        }
    }
   if(money <= 0)
   {
    $('#AliPayMsg').html('pls choose topping up amount');
    return false;
   }
   if(money %10 != 0)
   {
    $('#AliPayMsg').html('Topping up rates must be in multiples of 10');
    return false;
   }
   
   if(user == "86" || user == null)
   {
     $('#AliPayMsg').html('pls enter your cellphone number');
    return false;
   }
   
   if($('#chargeuservilid').val()== "-1")
   {
    $('#AliPayMsg').html('Pls enter your cellphone number correctly');
    return false;
   }
   
   if($('#chargeuservilid').val()== "0")
   {
    $('#AliPayMsg').html('Pls register first');
    return false;
   }
          
    var url = "/Recharge/Alipay/AlipayPost.aspx?M="+money + "&Phone="+ user+"&r="+ Math.random();
    document.getElementById("myPayAliPay").href=url;

    return true;
}
//手机充值卡检测手机号
 function checkUserMobile()
{
     var user = $('#'+globals.controlIdentities.txtelianMobile).val(); 
   if(user.length <=10)
    {
    $('#'+globals.controlIdentities.elianMess).html('Pls check your cellphone number');
        return false;
    }
    $.get("/English/AjaxAshx/Eajax.ashx?action=checkuser&mobile="+user+"&r="+ Math.random(),
    function(data){
          if(data != null )
          {
            if(data== "0")
            {
                $('#chargeuservilid').val("0");
                document.getElementById(globals.controlIdentities.callNotIsRegist).style.display = "";
               $('#'+globals.controlIdentities.elianMess).html('Pls register first');
                
                return false;
            }
            else if(data == "-1")
            {
                $('#chargeuservilid').val("-1");
               $('#'+globals.controlIdentities.elianMess).html('Pls check your cellphone number');
                return false;
            }
            else if(data == "1")
            {
                $('#chargeuservilid').val("1");
                if(getCookie("czAnyCall")==null){
                    document.getElementById(globals.controlIdentities.callIsRegist).style.display = "";
                }
               $('#'+globals.controlIdentities.elianMess).html('Valid User');
            }
          }
          else
          {
            $('#chargeuservilid').val("0");
           $('#'+globals.controlIdentities.elianMess).html('Pls check your cellphone number');
          }
    });   
}
//手机卡充值
 function MyCardElian()
{
   var items = $("input[type='radio'][name='myradio']");
   var no=$("#"+globals.controlIdentities.txtelianNo).val();
   var pwd= $("#"+globals.controlIdentities.txtelianPwd).val();
   var mobile=$("#"+globals.controlIdentities.txtelianMobile).val();

  if(items == null ||items.length <=0)
  {
      $('#'+globals.controlIdentities.elianMess).text("pls choose topping up amount");
     return false; 
  }
    var money =0;
    for(var i =0; i < items.length; i ++)
    {
      if(items[i].checked == true)
        {
          money = items[i].value;
        }              
    } 
    
   var url="/English/AlertWindow/ShowElian.aspx?moeny="+money+"&cardno="+no+"&cardpwd="+pwd+"&mobile="+mobile;
   document.getElementById("facy11").href=url;
   
    if(IsEmpty(no))
    {
        $('#'+globals.controlIdentities.elianMess).text("pls enter the topping up card number");
        return false;
    }
     if(IsEmpty(pwd))
    {
        $('#'+globals.controlIdentities.elianMess).text("pls enter the topping up card password");
        return false;
    }
    if(IsEmpty(mobile))
    {
        $('#'+globals.controlIdentities.elianMess).text("pls enter the cellphone number to top up");
        return false;
    }
    if(mobile.length>11)
    {
        $('#'+globals.controlIdentities.elianMess).text("Phone number can not be greater than 11");
        return false;
    }
}
//卡密充值
function  MyCardRechard()
{
var user=$("#"+globals.controlIdentities.chageuser2).val();
var no=$("#"+globals.controlIdentities.txtCardNo).val();
var pwd=$("#"+globals.controlIdentities.txtCardPwd).val();
var card=$("#"+globals.controlIdentities.txtCardValite).val();


 if(IsEmpty(no))
{
    $('#'+globals.controlIdentities.lblMessage).text("pls enter the topping up card number");
    return false;
}
 if(IsEmpty(pwd))
{
    $('#'+globals.controlIdentities.lblMessage).text("pls enter the topping up card password");
    return false;
}
if(IsEmpty(card))
{
    $('#'+globals.controlIdentities.lblMessage).text("pls enter the security code");
    return false;
}
if(IsEmpty(user))
{
    $('#'+globals.controlIdentities.lblMessage).text("pls enter the cellphone number to top up");
    return false;
}

 var params ="chanheuser="+user+"&cardno="+no+"&cardpwd="+pwd+"&cardvalite="+card;
    $.ajax({
        url:'/English/AjaxAshx/ECardCheck.ashx',
        type:'post',
        async:false,
        data:params,
        success:function(msg){
            switch(msg){
                case "1":
                    $("#"+globals.controlIdentities.lblMessage).text("The user does not exist");
                    break;
                case "2":
                    $("#"+globals.controlIdentities.lblMessage).text("Pls enter your cellphone number correctly");
                    break;
                case "3":
                    $("#"+globals.controlIdentities.lblMessage).text("The user does not exist");
                    break;
                case "4":
                    $("#"+globals.controlIdentities.lblMessage).text("Please enter the correct security code");
                    break;
                case "5":
                    $("#"+globals.controlIdentities.lblMessage).text("pls enter the topping up card number");
                    break;
                case "6":
                    $("#"+globals.controlIdentities.lblMessage).text("pls enter the topping up card password");
                    break;
                case "7":
                    $("#"+globals.controlIdentities.lblMessage).text("The linker account does not exist");
                    break;
                case "8":
                    $("#"+globals.controlIdentities.lblMessage).text("For toppin up,please visit www.linker.com");
                    break;
                case "10":
                    $("#"+globals.controlIdentities.lblMessage).text("Top up failed, the topping up card has been used");
                    break;
                case "11":
                    $("#"+globals.controlIdentities.lblMessage).text("Top up failed, the topping card has not been activated");
                    break;
                case "12":
                    $("#"+globals.controlIdentities.lblMessage).text("Top up failed, the topping card has been expired");
                    break;
                case "13":
                    $("#"+globals.controlIdentities.lblMessage).text("Top up failed, the card number is incorrect");
                    break;
                 case "14":
                    $("#"+globals.controlIdentities.lblMessage).text("Top up failed, pls try again later");
                    break;
                case "15":
                    $("#"+globals.controlIdentities.lblMessage).text("Top up failed, the card password is incorrect");
                    break;
                case "16":
                    $("#"+globals.controlIdentities.lblMessage).text("Top up failed");
                    break;
                case "17":
                    $("#"+globals.controlIdentities.lblMessage).text("The register card can’t be topped up twice");
                    break;
                default:
                    $("#"+globals.controlIdentities.lblMessage).text(msg);
                    break;
            }
        }
    });  
}
//查询余额
function QueryBlance()
{
   var v_Mobile = $("#"+globals.controlIdentities.q_Mobile).val();
   var v_Pwd = $("#"+globals.controlIdentities.q_Pwd).val(); 
if(IsEmpty(v_Mobile))
{
    $('#'+globals.controlIdentities.QueryMsg_BL).text("Pls enter the cellphone number to search！");
    return false;
}
if(IsEmpty(v_Pwd))
{
    $('#'+globals.controlIdentities.QueryMsg_BL).text("pls enter the password！");
    return false;
}
$.get("/English/AjaxAshx/EQueryBlance.ashx?UserName="+v_Mobile+"&PassWord="+v_Pwd, function(data){
    switch(data)
    {
        case "-2.00":
             $("#"+globals.controlIdentities.QueryMsg_BL).html("user or password is incorrect！"); 
             break;
        case "-1.00":
             $("#"+globals.controlIdentities.QueryMsg_BL).html("user or password is incorrect！");
             break;
        default:
             $("#"+globals.controlIdentities.mes).html("Your balance is:￥"+data);
             document.getElementById("showmoeny").style.display="block";
             document.getElementById("none0").style.display="none";
             document.getElementById("none1").style.display="none";
             document.getElementById("none2").style.display="none";
             document.getElementById("none3").style.display="none";
             break;  
    }
});
}
 //保存电话本
function SaveNum()
{
   var AObj = document.getElementById(globals.controlIdentities.hidOperateData);
   AObj.value = "";
   var numText1 = "";
   var numText2 = "";
   var numText3 = "";
   var numText4 = "";
   var numText5 = "";
   $('[num="'+globals.controlIdentities.tr1+'"]').each(function(){
        numText1 = numText1 + $(this).val() + ",";
   });
   numText1 = numText1.substring(0,numText1.length-1);
   $('[num="'+globals.controlIdentities.tr2+'"]').each(function(){
        numText2 = numText2 + $(this).val() + ",";
   });
   numText2 = numText2.substring(0,numText2.length-1);
   $('[num="'+globals.controlIdentities.tr3+'"]').each(function(){
        numText3 = numText3 + $(this).val() + ",";
   });
   numText3 = numText3.substring(0,numText3.length-1);
   $('[num="'+globals.controlIdentities.tr4+'"]').each(function(){
        numText4 = numText4 + $(this).val() + ",";
   });
   numText4 = numText4.substring(0,numText4.length-1);
   $('[num="'+globals.controlIdentities.tr5+'"]').each(function(){
        numText5 = numText5 + $(this).val() + ",";
   });
   numText5 = numText5.substring(0,numText5.length-1);
   var bl1 = "true";
   var bl2 = "true";
   var bl3= "true";
   var bl4= "true";
   var bl5= "true";
   $('[num="'+globals.controlIdentities.tr1+'"]').each(function(){
        if($(this).val() == "")
        {
            bl1 = "false";
        }
   });
   $('[num="'+globals.controlIdentities.tr2+'"]').each(function(){
        if($(this).val() == "")
        {
            bl2 = "false";
        }
   });
   $('[num="'+globals.controlIdentities.tr3+'"]').each(function(){
        if($(this).val() == "")
        {
            bl3 = "false";
        }
   });
   $('[num="'+globals.controlIdentities.tr4+'"]').each(function(){
        if($(this).val() == "")
        {
            bl4 = "false";
        }
   });
   $('[num="'+globals.controlIdentities.tr5+'"]').each(function(){
        if($(this).val() == "")
        {
            bl5 = "false";
        }
   });
   
   if(bl1 == "true")
   {
        AObj.value =AObj.value + numText1;
   }
   
   if(bl2 == "true")
   {
        AObj.value =AObj.value +"|"+ numText2;
   }
   
   if(bl3 == "true")
   {
        AObj.value =AObj.value +"|"+ numText3;
   }
   
   if(bl4 == "true")
   {
        AObj.value =AObj.value +"|"+ numText4;
   }
   
   if(bl5 == "true")
   {
        AObj.value =AObj.value +"|"+ numText5;
   }
   if(AObj.value.substring(0,1) == "|") //如果前几行没有填充的情况
   {
        AObj.value = AObj.value.substring(1);
   }
    if(getCookie("czAnyCall")!=null)//判断是否登录了
    {
        if(AObj.value == "")
        {
            alert("The contacts can’t be empty");
            return;
        }
        $("#"+globals.controlIdentities.btnSavePhoneNum).click();
    }
    else
    {
        //alert("没有登录，请登录..."+AObj.value);
        document.getElementById("facy10").href="AlertWindow/LoginAndRegist.aspx?id=2&param="+AObj.value;
        $('#facy10').click();
    }
    
}
