
let hoverColor = "#e9b82f";
let normalColor = "#efbd95";

var rep2 = "assets/map/";

function get_name(id){
    return id.replace("map-", "");
}

function clicked(elem){
    $.alert({
        title: 'Chargement...',
        content: function () {
            let self = this;
            let object = {
                "function": 'get_map_info',
                'selector': get_name(elem.id),
            };
            return $.ajax({
                url: rep2+'ajax.php',
                data: object,
                method: 'get'
            }).done(function (data) {
                if (data.length > 0) {
                    self.setTitle(data[0]['title']);
                    self.setContent(data[0]['description']);
                } else {
                    self.setTitle('Erreur');
                    self.setContent('Une erreur est survenue')
                }
            }).fail(function(){
                self.setContent('Something went wrong.');
            });
        },
    });
}

function hover_in(elem){
    $(elem).css({
        "fill": hoverColor,
        'cursor': 'pointer',
    });
}

function hover_out(elem){
    $(elem).css("fill", normalColor);
}