function product_addtocart(Obj){
    var product_ids = $(Obj).val();
    if(!(product_ids)){
        product_ids = $(Obj).attr("id");
    }
    $(Obj).parent().hide();
    $(Obj).parent().next().hide().next().show();
    $.ajax({
        type: "post",
        url : "/shoppingcart/addtocart_ajax",
        dataType:'json',
        data: 'product_ids=' + product_ids,
        error: function(msg){
            $(Obj).parent().show();
            $(Obj).parent().next().show().next().hide();
            alert("add to cart failed,If you have any urgent issues, please contact live support");
            return false;
        },
        success: function(json){
            $(Obj).parent().show();
            $(Obj).parent().next().show().next().hide();
            switch (json.flag) {
                case 1:
                    alert("add to cart failed,If you have any urgent issues, please contact live support");
                    break;
                case 2:
                    alert("add to cart failed,If you have any urgent issues, please contact live support");
                    break;
                case 3:
                    window.location.href = "/shoppingcart/";
                    break;
                default:
                    alert("add to cart failed,If you have any urgent issues, please contact live support");
                    break;
            }
        }
    });
}
function product_checkout(Obj){
    var product_ids = $(Obj).val();
    $(Obj).parent().hide();
    $(Obj).parent().next().hide().next().show();
    $.ajax({
        type: "post",
        url : "/shoppingcart/addtocart_ajax",
        dataType:'json',
        data: 'product_ids=' + product_ids,
        error: function(msg){
            $(Obj).parent().show();
            $(Obj).parent().next().show().next().hide();
            return false;
        },
        success: function(json){
            switch (json.flag) {
                case 1:
                    alert("Add to cart failed,If you have any urgent issues, please contact live support");
                    $(Obj).parent().show();
                    $(Obj).parent().next().show().next().hide();
                    break;
                case 2:
                    alert("Add to cart failed,If you have any urgent issues, please contact live support");
                    $(Obj).parent().show();
                    $(Obj).parent().next().show().next().hide();
                    break;
                case 3:
                    window.location.href = "https://www.pass4sure.com/checkout/";
                    break;
                default:
                    alert("Add to cart failed,If you have any urgent issues, please contact live support");
                    $(Obj).parent().show();
                    $(Obj).parent().next().show().next().hide();
                    break;
            }
        }
    });
}
function bundle_checkout(Obj){
    var product_ids = $(Obj).val();
    $(Obj).hide();
    $(Obj).next().show();
    $.ajax({
        type: "post",
        url : "/shoppingcart/addtocart_ajax",
        dataType:'json',
        data: 'product_ids=' + product_ids + "&product_type=2",
        error: function(msg){
            $(Obj).show();
            $(Obj).next().hide();
            window.location.reload();
            return false;
        },
        success: function(json){
            $(Obj).show();
            $(Obj).next().hide();
            switch (json.flag) {
                case 1:
                    window.location.reload();
                    break;
                case 2:
                    window.location.reload();
                    break;
                case 3:
                    window.location.href = "/shoppingcart/";
                    break;
                default:
                    window.location.reload();
                    break;
            }
        }
    });
}