jQuery.fn.mig = function(ops){
 
  // настройки по умолчанию
  var ops = jQuery.extend({
      time: 1000,
      timeout: 1000
  },ops);
  
  var fl_mig = true;

  return this.each(function() 
  {
      mig(this);     
  });
  
  function mig(obj)
  {
        if (fl_mig){
          $(obj).animate({"opacity": 0.1}, ops.time, function(){
              fl_mig = false;               
              mig(obj);
          });
        } else {
          $(obj).animate({"opacity": 1}, ops.time, function(){
              fl_mig = true;
              setTimeout(function() {
                  mig(obj);
              }, ops.timeout);
          });        
        } 
  }

};

$(document).ready(function()
{   
    $("span.mig").mig();
});



