function ProductStocks(){
            var Amount=document.getElementById("Amount").value;
            var Stocks=document.getElementById("Stocks").value;
            
            Amount=Amount.replace(/^\s * /,"");//去左空格
            Amount=Amount.replace(/ \s * $ /,"");//去右空格
           
            if(isNaN(Amount) || Amount==""){Amount="1";document.getElementById("Amount").value="1";}
            
            if(parseInt(Amount)>parseInt(Stocks)){
                    document.getElementById("Amount").value=Stocks;
                    Amount=Stocks;
                    
            }else if(parseInt(Amount)<=0){
                    document.getElementById("Amount").value="1";
                    Amount=1;
            }
            
            var UnitPrice=document.getElementById("UnitPrice").value;
            document.getElementById("TotalAmount").innerHTML=parseFloat(UnitPrice)*parseInt(Amount);
            document.getElementById("s_TotalAmount").innerHTML=parseFloat(UnitPrice)*parseInt(Amount);
        }
        
        
function CouponDiscount(c){
            if(isNaN(c)){
                document.getElementById("CouponCount").value="0";
                c="0";
            }
            var Ratio=document.getElementById("CouponRatio").value;
            var Balance=document.getElementById("CouponBalance").value;
            c=c.replace(/^\s * /,"");//去左空格
            c=c.replace(/ \s * $ /,"");//去右空格
            
            if(c==""){c=0;document.getElementById("CouponCount").value="0";}
            
            
            if(parseInt(c)>parseInt(Balance)){
                    document.getElementById("CouponCount").value=Balance;
                    c=Balance;
            }
            else{
                var count=parseFloat(c).toFixed(0);
                document.getElementById("CouponCount").value=count;
                c=count;
            }
            var discount=c/Ratio;       
            
            document.getElementById("coupon_count").innerHTML=c;
            document.getElementById("coupon_discount").innerHTML=parseFloat(discount);
            document.getElementById("s_coupon_count").innerHTML=c;
            document.getElementById("s_coupon_money").innerHTML=parseFloat(discount);
            document.getElementById("CouponQuantity").value=c;
        }
        
function CouponUse(){
            var CouponH=document.getElementById("CouponH").value;
            if(CouponH=="none"){
                document.getElementById("CouponDiv").style.display="block";
                document.getElementById("couponStateShow").innerHTML="-";
                document.getElementById("CouponH").value="block";
            }else{
                document.getElementById("CouponDiv").style.display="none";
                document.getElementById("couponStateShow").innerHTML="+";
                document.getElementById("CouponH").value="none";
            }
            
        }
       