﻿jQuery(window).bind("load", function() {
    var images = $(".auto-caption img").get();
    //images = images:not(".top-promo img").get();
    for (var i = 0; i < images.length; ++i) {
        var img = images[i];
        if ((img.getAttribute('alt') != null) & (img.getAttribute('alt') != '')) {
            // Lift the image out of the page and insert a div under it.
            var parent = img.parentNode;
            var frame = document.createElement('div');
            var cap = document.createElement('span');
            var txt = document.createTextNode(img.getAttribute('alt'));
            parent.insertBefore(frame, img);
            parent.removeChild(img);
            cap.appendChild(txt);
            
            frame.appendChild(img);
            frame.appendChild(cap);
            // These are special cases.  We always copy these from the image to the
            // div.
            frame.style.width = $(img).width() + 'px';
            cap.style.width = $(img).width() + 'px';
            frame.className = 'caption small ' + img.className;
        }
    }
});

