﻿/** jquery extensions **/

// registers a product info tooltip (using title="[Image.ObjectID]")
$.fn.imageThumbnailTip = function(tributeGUID, caption) {

    // n.b. we use iteration rather than direct jQuery call on the result set
    // this allows us to pass over items that have already been processed, or do not contain valid data
    this.each(function() {

        var anchor = $(this);

        var oid = anchor.attr("title");

        if (oid.length > 0) {

            var FORMAT = "<img src=\"{0}\" />{1}";
            var html = doStringFormat(FORMAT, [getImageUri(tributeGUID, oid, '_thumbnail'), typeof (caption) == 'undefined' ? '' : '<br/>' + caption]);


            anchor.tooltip({
                delay: 0,
                showURL: false,
                extraClass: "noBg",
                bodyHandler: function() {
                    return html;
                }
            });

            // lose the title - tidy for display and prevents re-registration
            anchor.attr("title", "");

        };

    });

};
