$(document).ready(function() {
    $(".col_mid img[alt]").each(function() {
        // ugly, but no idea to make it another way. there are some smaller images in the content with alt attributes with
        // are more like headers and reading helpers instead of real content
        var nextNode = $(this).next(".foto_bijschrift");
        if (nextNode != null && nextNode.hasClass("foto_bijschrift")) {
            return;
        }
        if (this.className != "inzetimage" && this.width > 50 && this.alt != null && this.alt.length > 0) {
            if (this.align == "right") {
                $(this).before("<div class='alignright xinha_img'><p class='xinha_img_caption'>"+this.alt+"</p></div>");
            } else {
                $(this).before("<div class='alignleft xinha_img'><p class='xinha_img_caption'>"+this.alt+"</p></div>");
            }
            this.removeAttribute("align");
            $(this).prev().css("width", this.width+"px");
            $(this).prev().prepend($(this).detach());
        }
    });
});

