    (function($) {

        // preload
        $.extend({
            preload: function(images, callback){
                for (var i in images) {
                    var image = images[i];
                    var $image = $('<img />').load(function() {
                        callback(this);
                    });

                    for (var attribute in image)
                        $image.attr(attribute, image[attribute]);
                }
            }
        });

        $.extend({
            featured: function(element, options) {
                var targetEvent = 'mouseenter';

                var items = $(element).find('li');
                var interval = null;
                var paused = false;
                var actived = false;
                var nextItem = 1;
                var prevItem = items.length - 1;

                if (!options) { options = {}; }
                if (!options.timer) { options.timer = 5000; }
                if (!options.rotate) { options.rotate = true; }
                if (options.slide) { options.rotate = false; }

                if (options.slide) {
                    var targetEvent = 'click';

                    if ($(items).length == 1) {
                        if ($.browser.msie) {
                            var image = $('<img />');
                            image
                            .attr('title', $(items).find('a').attr('title'))
                            .attr('src', $(items).find('a').attr('data-image'))
                            .attr('index', $(items).index());
                            imageLoaded(image[0]);
                        } else {
                            loader($(items).find('a:last-child').attr('title'), $(items).find('a').attr('data-image'), $(items).index());
                        }

                        return;
                    }

                    $(element).find('div').append('<span class="previous-base"></span><span class="previous"></span><span class="next-base"></span><span class="next"></span>');

                    $(element + ' .previous').click(function () {
                        previous();
                    });

                    $(element + ' .next').click(function () {
                        next();
                    });

                    $(element + ' .next , ' + element + ' .previous').hover(function() {
                        paused = true;
                        actived = true;
                    }, function() {
                        paused = false;
                        actived = false;
                    })
                }

                function previous() {
                    $(items).eq(prevItem).trigger(targetEvent);

                    setActive(prevItem);

                    prevItem--;
                    nextItem--;

                    if (nextItem < 0) { nextItem = items.length - 1; }
                    if (prevItem < 0) { prevItem = items.length - 1; }
                }

                function next() {
                    $(items).eq(nextItem).trigger(targetEvent);

                    setActive(nextItem);

                    prevItem++;
                    nextItem++;

                    if (nextItem >= items.length) { nextItem = 0; }
                    if (prevItem >= items.length) { prevItem = 0; }
                }

                if (!(options.slide)) {
                    $(items).mouseover(function () {
                        actived = true;
                        nextItem = $(this).index() + 1;
                        setActive($(this).attr('index'));
                    });

                    $(items).mouseout(function () {
                        actived = false;
                    });
                }

                if (!(options.slide)) {
                    $(element).find('#entry-image').live('mouseover', function () {
                        paused = true;
                    });

                    $(element).find('#entry-image').live('mouseout', function () {
                        paused = false;
                    });
                }

                if (options.slide) {
                    $(items).click(function () {
                        paused = true;

                        if ($.browser.msie) {
                            var image = $('<img />');
                            image
                            .attr('title', $(this).find('a').attr('title'))
                            .attr('src', $(this).find('a').attr('data-image'))
                            .attr('index', $(this).index());
                            imageLoaded(image[0]);
                        } else {
                            loader($(this).find('a:last-child').attr('title'), $(this).find('a').attr('data-image'), $(this).index());
                        }
                    });
                } else {
                    $(items).mouseenter(function () {
                        paused = true;

                        if ($.browser.msie) {
                            var image = $('<img />');
                            image
                            .attr('title', $(this).find('a').attr('title'))
                            .attr('src', $(this).find('a').attr('data-image'))
                            .attr('index', $(this).index());
                            imageLoaded(image[0]);
                        } else {
                            loader($(this).find('a:last-child').attr('title'), $(this).find('a').attr('data-image'), $(this).index());
                        }
                    });
                }

                function loader(title, src, index) {
                    $.preload([{ 'title': title, 'src': src, 'index': index }], imageLoaded);
                }

                function imageLoaded(image) {
                    var index = parseInt($(image).attr('index'));
                    paused = false;

                    $(element).find('#entry-image').remove();

                    var imageContainer = options.imageContainer ? options.imageContainer : element + ' div';

                    $(imageContainer).prepend('<a id="entry-image" href="' + $(element).find('.link-' + index).attr('href') + '"><img src="' + $(image).attr('src') + '" /></a>').fadeIn();

                    setActive(index);

                    $('#entry-image').fadeIn();
                }

                function rotate(timer) {
                    if ($(items).length == 1) { return; }

                    interval = setInterval(function () {
                        if (paused || actived) { return; }

                        next();
                    }, timer);
                }

                function setActive(index) {
                    $(element).find('li a').removeClass('active');

                    if (options.slide) {
                        $(element).find('li a').hide();
                    }

                    $(element + ' .link-' + index).addClass('active').show();
                }

                $(items).eq(0).trigger(targetEvent);
                setActive(0);

                if (options.rotate) {
                    rotate(options.timer);
                }
            }
        });
    })(jQuery);
