$( document ).ready(function() {

    if($('.gallery').length > 0) {

        var lightbox = $('.gallery a').simpleLightbox({
            additionalHtml:' '
        });

        lightbox.on('shown.simplelightbox', function(e){
            var img = $(".sl-image > img");
            $(".sl-additional-html").html("");
            $(".sl-additional-html").html($(this).attr("data-description"));
            img.attr("alt", $(this).attr("data-description"));
            img.attr("title", $(this).attr("title"));
        });

        lightbox.on('changed.simplelightbox', function(e){
            var img = $(".sl-image > img");
            $(".sl-additional-html").html("");
            $(".sl-additional-html").html($(this).attr("data-description"));
            img.attr("alt", $(this).attr("data-description"));
            img.attr("title", $(this).attr("title"));
        });
    }
});