﻿/// <reference path="jquery-1.3.2-vsdoc.js" />

(function($) {

    $.fn.vSlider = function(options) {

        var opts = $.extend({}, $.fn.vSlider.defaults, options);

        return this.each(function() {
            var box = this;
            $(box).stop();
            var visible = $(box).is(':visible');
            if (visible) {
                $(box).animate({ width: 0 }, opts.duration, opts.easing, function() {
                    $(box).hide();
                    if ($.isFunction(opts.callback)) {
                        opts.callback(!visible);
                    }
                });
            }
            else {
                $(box).css('width', '0').css('display', opts.container).show();
                $(box).animate({ width: opts.width }, opts.duration, opts.easing, function() {
                    if ($.isFunction(opts.callback)) {
                        opts.callback(!visible);
                    }
                });
            }
        });

    };

    // publicly accessible defaults
    $.fn.vSlider.defaults = {
        duration: 250,
        container: 'block',
        easing: 'linear',
        width: '100%',
        callback: function() { }
    };

})(jQuery);

