﻿/*
* jquery.pulse.js (version 1.0)
*
* Pulses the background color.
*
* HTML:
* <p class="Updated">Some new text.</p>
*
* JavaScript:
* $('p.Updated').pulse();
*
* JavaScript with Options:
* $('p.Updated').pulse( { backgroundColor : 'red' } );
*
* Requires: jQuery 1.2.6, jquery.colors.js
*
* I made this. (SmallSharpTools.com - 2008)
*
* License: Creative Commons
*
*/
(function($) {

    $.fn.pulse = function(options, callback) {

        var opts = $.extend({}, $.fn.pulse.defaults, options);

        if (callback && opts['callback'] === undefined) {
            opts['callback'] = callback;
        }

        $(this).animate({ backgroundColor: opts.backgroundColor }, opts.delay, function() {
            $(this).animate({ backgroundColor: opts.originalBackgroundColor }, opts.delay, function() {
                if (opts.callback !== undefined) {
                    opts.callback();
                }
            });
        });

        return $(this);
    };

    // publicly accessible defaults
    $.fn.pulse.defaults = {
        backgroundColor: 'yellow',
        originalBackgroundColor: 'white',
        delay: 250
    };

})(jQuery);
