/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
var kucunreal_num=0;
function GetKucun(county_id){
    var goodid = $('#goods_id').val();
    var kucun_num=parseInt($('.sale_text').val());
    if(county_id == '' || goodid == ''){
        return false;
    }
    
    $.ajax({
        url:'/shop/index/Goodskucun',
        data:{'goodsid':goodid,'county_id':county_id},
        type:'post',
        success:function(e){
            if(e == 'wu'){
                $('.kucun_real').html('0件');
                $('.fleft.fbold.font_14').html('无货');
                kucunreal_num = 0;
                $("#buynow_class").addClass('bugnow_none');
                $("#buynow_class").next().addClass('addcar_none');
                
                $("#buynow_class").attr('onclick','');
                $("#buynow_class").next().removeAttr('href');
                $("#buynow_class").next().attr('onclick','');
                $(".com_cart").hide();
                $(".xg_com_cart").show();
                $('.com_cart').attr('href','javascript:;');

                $('#kuncun_sn').val(0);
            }else{
            	$(".com_cart").show();
                $(".xg_com_cart").hide();
                $('.kucun_real').html(e+'件');
                kucunreal_num = e;
                $('#kuncun_sn').val(e);
                $('.fleft.fbold.font_14').html('有货');
                $("#buynow_class").removeClass('bugnow_none');
                $("#buynow_class").next().removeClass('addcar_none');
                //$("#buynow_class").attr("onclick","nowpay('"+goodid+"')");
                $("#buynow_class").click(function(){
                    if ($('#kuncun_sn').val()>0){
                        var kucun_num=parseInt($('.sale_text').val());
                        var goods_number = parseInt($('#goods_l0_number').val())
                        if(kucun_num>=goods_number){
                            window.location.href='/shop/order/AddReceving/rec_type/2/gcount/'+kucun_num+'/gid/'+goodid;
                        }else{
                            alert('最低起订量：'+goods_number);return false;
                        }
                    }
                })
                $("#buynow_class").next().click(function(){
                    
                    if ($('#kuncun_sn').val()>0){
                        var kucun_num=parseInt($('.sale_text').val());
                        var goods_number = parseInt($('#goods_l0_number').val());
                        if(kucun_num>=goods_number){
                            window.location.href='/shop/cart/AddCart/pid/'+goodid+'/ptype/1/pcount/'+kucun_num;
                        }else{
                            alert('最低起订量：'+goods_number);return false;
                        }
                    }
                    
                })
                $(".com_cart").next().click(function(){
                    if ($('#kuncun_sn').val()>0){
                        var kucun_num=parseInt($('.sale_text').val());
                        var goods_number = parseInt($('#goods_l0_number').val())
                        if(kucun_num>=goods_number){
                            window.location.href='/shop/cart/AddCart/pid/'+goodid+'/ptype/1/pcount/'+kucun_num;
                        }else{
                            alert('最低起订量：'+goods_number);return false;
                        }
                    }
                })
        
            }
        }
    });
    
}


function cartKucun(county_id){
    if(county_id == ''){
        return false;
    }
    location.reload(true);
}