﻿var SecuritySearchBtn = 0;

function changecheckcode(){
   document.getElementById('imgcode').src='/share/VCode.aspx?key='+Math.random();
   
}
function codesearch(codename,vcodename,searchtype)
{
if($("#" + codename).val().length == 0){
     alert('对不起！防伪码不能为空，请您输入防伪码，谢谢！');
  $("#" + codename).focus();
   return false; 
}
  if ($("#" + vcodename).val().length==0)
 { 
   alert('对不起！ 验证码不能为空，请您输入验证码，谢谢！');
    $("#" + vcodename).focus();
   return false;
 }
 if ($("#" + codename).val().length !=16)
 {

  alert('对不起！您输入的防伪码有误，请重新输入，谢谢！');
  $("#" + codename).focus();
   return false;
 }
  if ($("#" + vcodename).val().length!=5)
 { 
   alert('对不起！您输入的验证码有误，请重新输入，谢谢！');
    $("#" + vcodename).focus();
   return false;
 }
  if(SecuritySearchBtn == 0){
       SecuritySearchBtn = 1;     
         $.ajax({
             type: "get",
             url: "/Server/Security.aspx",
             data: "code="+$("#" + codename).val()+"&vcode=" +$("#" + vcodename).val() +"&searchtype=" +searchtype ,
             dataType:"json",
             success:function (data, textStatus){
                   var returntype= data.msgtype;
                   var msg= data.msg;
                     SecuritySearchBtn = 0;
                   if(returntype == 1){
                
                        alert(data.msg);
                               changecheckcode(); 
                   }else  if(returntype == 2){
                        document.location = data.msg;
                   }else{                        
                        alert("网络繁忙，请稍后在试。"); 
                         changecheckcode(); 
                   }           
             },
             error :function (XMLHttpRequest, textStatus, errorThrown) {
                 
                    alert("网络繁忙，请稍后在试。");   
                           changecheckcode();   
             }
         
            });  
   }
}

