genio.catalogue = {};

genio.catalogue.addToWishlist = function(productId)
{
    var baseQuery = "#product_" + productId + " .wishlist ";
    $(baseQuery + ".post").hide();
    $(baseQuery + ".loading").show();
    var item = { "product_id": productId };
    $.ajax({
        url: genio.catalogue_wishlist_rest_post,
        data: item,
        type: "POST",
        success: function() {
            $(baseQuery + ".delete").show();
        },
        error: function() {
            alert("<?php echo __('Error') ?>");
            $(baseQuery + ".post").show();
        },
        complete: function() {
            $(baseQuery + ".loading").hide();
        }
    });
}

genio.catalogue.removeFromWishlist = function(productId)
{
    var baseQuery = "#product_" + productId + " .wishlist ";
    $(baseQuery + ".delete").hide();
    $(baseQuery + ".loading").show();
    $.ajax({
        url: genio.catalogue_wishlist_rest_post + "/" + productId,
        type: "DELETE",
        success: function() {
            $(baseQuery + ".post").show();
        },
        error: function() {
            alert("<?php echo __('Error') ?>");
            $(baseQuery + ".delete").show();
        },
        complete: function() {
            $(baseQuery + ".loading").hide();
        }
    });
}
