function update_cart_controls_add() {
    $('a.add_to_selection').click(function() {
        var myClass = $(this).attr('class');
        if (myClass == 'add_to_selection') {
            $.get(
                    this.href,
                    function(data) {
                        $('#selection').html(data);
                    }
                    );
            if($('img', this).attr('src') == '/images/ro_layout_r21_c11.jpg') {
                $('img', this).attr('src', '/images/suprimer.png');
            } else {
                $('img', this).attr('src', '/images/suprimer_1.png');
            }
            var new_href = site_url + 'removeFromSelection/' + this.href.substring(site_url.length + 15);
            $(this).attr('href', new_href);
            $(this).attr('class', 'remove_from_selection');
            jAlert('Votre véhicule a été sauvegardé dans votre sélection. Retrouvez là en haut de page.', 'Ma sélection');
            return false;
        } else {
            $.get(
                    this.href,
                    function(data) {
                        $('#selection').html(data);
                    }
                    );
            if($('img', this).attr('src') == '/images/suprimer.png') {
                $('img', this).attr('src', '/images/ro_layout_r21_c11.jpg');
            } else {
                $('img', this).attr('src', '/images/annonce_toolbox_add_to_my_basket.png');
            }
            var new_href = site_url + 'addToSelection/' + this.href.substring(site_url.length + 20);
            $(this).attr('href', new_href);
            $(this).attr('class', 'add_to_selection');
            return false;
        }
    })
}
function update_cart_controls_remove() {
    $('a.remove_from_selection').click(function() {
        var myClass = $(this).attr('class');
        if (myClass == 'remove_from_selection') {
            $.get(
                    this.href,
                    function(data) {
                        $('#selection').html(data);
                    }
                    );
            if($('img', this).attr('src') == '/images/suprimer.png') {
                $('img', this).attr('src', '/images/ro_layout_r21_c11.jpg');
            } else {
                $('img', this).attr('src', '/images/annonce_toolbox_add_to_my_basket.png');
            }
            var new_href = site_url + 'addToSelection/' + this.href.substring(site_url.length + 20);
            $(this).attr('href', new_href);
            $(this).attr('class', 'add_to_selection');
            return false;
        } else {
            $.get(
                    this.href,
                    function(data) {
                        $('#selection').html(data);
                    }
                    );
            if($('img', this).attr('src') == '/images/ro_layout_r21_c11.jpg') {
                $('img', this).attr('src', '/images/suprimer.png');
            } else {
                $('img', this).attr('src', '/images/suprimer_1.png');
            }
            var new_href = site_url + 'removeFromSelection/' + this.href.substring(site_url.length + 15);
            $(this).attr('href', new_href);
            $(this).attr('class', 'remove_from_selection');
            jAlert('Votre véhicule a été sauvegardé dans votre sélection. Retrouvez là en haut de page.', 'Ma sélection');
            return false;

        }
    })
}

$(document).ready(function() {
    update_cart_controls_add();
    update_cart_controls_remove();
})



