// Begin jQuery laundrylist plugin
// Cycles through lots of HTML span tags in rapid succession
// Usage: jQuery(".laundrylist").laundrylist();
// Slower cycle: jQuery(".laundrylist").laundrylist({ delay: 3000 });
jQuery.fn.laundrylist = function(options) {

   var opts = jQuery.extend({}, jQuery.fn.laundrylist.defaults, options);

   jQuery(this).each(function() {
      var code = jQuery(this).html();
      if (code != null) {
         code = code.replace('<!--', '');
         code = code.replace('-->', '');
         jQuery(this).html(code);
      }

      //alert(jQuery(this).html());
      var children = jQuery(this).children(opts.subquery);

      var total = children.length;
      var step = 0;
      var timer;

      // Move to the next step in the cycle
      function cycle() {
         jQuery(children.get(step)).hide();
         step = (step+1) % total;
         jQuery(children.get(step)).fadeIn().show();
      }

      // Make sure this layer is visible
      jQuery(this).show();

      // Hide all SPAN elements within this DIV tag
      children.hide();
      children.eq(0).show();

      // Step through each cycle
      timer = setInterval(cycle, opts.delay);

      // If they hover over the laundry list, pause it
      // If they move away, keep it going
      children
         .mouseover(function() { clearInterval(timer); })
         .mouseout(function() { timer = setInterval(cycle, opts.delay); })
      ;
   });

   return jQuery(this);
};

jQuery.fn.laundrylist.defaults = {
   delay : 1000,
   subquery : "span"
};
// End laundrylist plugin

jQuery.noConflict();

jQuery(function() {
   //jQuery(".laundrylist").laundrylist();
   jQuery(".laundrylist").laundrylist({ delay: 3000 });
});
