var xmlHttp;    // XMLHttpRequest对象
    // 创建XMLHttpRequest对象 
    function createXMLHttpRequest(){
        if(window.activeXObject){
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else if(window.XMLHttpRequest){
            xmlHttp = new XMLHttpRequest();
        }
    }
    
    // 使 txtBarcode 得到焦点
    function SetFocus()
    {
        form1.txtBarcode.focus();     
    }    
    
    function save(){
        if(window.event.keyCode == 13){
            var stock_box_id = '<%= Request.QueryString["stock_box_Id"] %>';
            var barcode = form1.txtBarcode.value;
            var url = "stock_scan.ashx?stock_box_id=" + stock_box_id + "&barcode=" + barcode;
            createXMLHttpRequest();
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = finishCall;
            xmlHttp.send(null);
        }        
    }
        
    function finishCall(){
        if(xmlHttp.readyState == 4){
            if(xmlHttp.status == 200){
                if(xmlHttp.responseText == ""){
                    document.getElementById("<%= lbl_msg.ClientID %>").innerText = "";
                    document.getElementById("<%= lbl_msg.ClientID %>").style.visibility = "hidden";
                    
                    var box_number = document.getElementById('<%= fv_jsp.FindControl("lbl_Box_Number").ClientID %>').innerHTML;
                    var lbl;
                    if( box_number.substr(box_number.length - 1) == "A")
                        lbl = document.getElementById('<%= fv_jsp.FindControl("lbl_A").ClientID %>');
                    else
                        lbl = document.getElementById('<%= fv_jsp.FindControl("lbl_B").ClientID %>');
                    
                    lbl.innerHTML = Number(lbl.innerHTML) + 1;
                }
                else{                
                    document.getElementById("<%= lbl_msg.ClientID %>").innerText = xmlHttp.responseText;
                    document.getElementById("<%= lbl_msg.ClientID %>").style.visibility = "visible";
                    
                }
            }     
        }          
    }