/*
 *
 *	jQuery fadeSlider plugin v0.1
 */
 
jQuery.fadeSlider = function (interval, element_id, url)
{

    var interval = interval || 100;

    var $element_id = $("#" + element_id), url = url;

    var height = $element_id.height();

    _timer = function (interval, callback) {
        this.stop = function () {
            clearInterval(self.id);
        };
		
        this.internalCallback = function () {
            callback(self);
        };
		
        this.reset = function (val) {
            if (self.id)
                clearInterval(self.id);
			
            var val = val || 100;
            this.id = setInterval(this.internalCallback, val);
        };
		
        this.interval = interval;
        this.id = setInterval(this.internalCallback, this.interval);
		
        var self = this;
    };


    _timer(2000, function (timer) {

        $.ajax({
            url: url,
            data: { },
            success: function(data)

            {
                if (data != '')
                {
                    //alert($element_id.height() );
                    //Меняем картинку на новую
                    $element_id.fadeOut(2000, function() {

                        $element_id.html(data).height(height);
                        $element_id.show();

                    });
                }

                else
                {
            //Сервер возвратил пустой результат, оставляем все как есть.
            }
            }
        });

        timer.reset(interval);

    });
};