﻿// jquery.clickThumbnails.js
// Built by Fullhouse 2009

/// <reference path="jquery-1.2.6-vsdoc.js"/>

(function($) {

    $.fn.clickThumbnails = function(options) {

        var opts = $.extend({}, $.fn.clickThumbnails.defaults, options);

        return this.each(function() {
            var context = $(this);

            var clickThumbnail = function(e) {
                e.preventDefault();
                var img = $('> img', this);
                var src = $(img).attr('src');
                var alt = $(img).attr('alt');
                var title = $(img).attr('title');
                var largeSrc = src.replace(opts.thumbSuffix, opts.largeSuffix);
                $(opts.fullImageSelector, context).attr('src', largeSrc).attr('alt', alt);
                $(opts.captionSelector, context).text(title);
            };

            $(opts.thumbnailSelector, context).click(clickThumbnail);
        });

    };

    // publicly accessible defaults
    $.fn.clickThumbnails.defaults = {
        thumbnailSelector: 'div.Thumbnail',
        fullImageSelector: 'div.FullImage > img',
        thumbSuffix: '_thumb',
        largeSuffix: '_full',
        captionSelector: 'span.Caption'
    };

})(jQuery);
