var slideshow_timeout=4000;

function on_slideshow(id_slideshow)
{
 var slideshow=$('#'+id_slideshow); 
 var slides=$('.slide',slideshow);   
 var index=slideshow.data('index');
   
 if(index===undefined)
  index=0;

 var timer=slideshow.data('timer');
  
 window.clearTimeout(timer);

 timer=window.setTimeout('on_slideshow(\''+id_slideshow+'\')',slideshow_timeout);
    
 slideshow.data('timer',timer);
 
 if(slideshow.data('over'))
 {
 }
 else
 {  
  index++;
  
  if(index>=slides.length)
   index=0;
  
  slideshow.data('index',index);
  
  for(i=0;i<slides.length;i++)
  {
   slide=$(slides[i]);
   
   if(i===index)
    slide.show();
   else
    slide.hide();
  }
 }
}

$(document).ready
(
 function()
 {
  $.fn.slideshow=function()
  {
   this.hover
   (
    function()
    {
     $(this).data('over',true);
    },
    function()
    {
     $(this).data('over',false);
    }
   );
    
   var timer=window.setTimeout('on_slideshow(\''+this.auto_id()+'\')',slideshow_timeout);
   
   this.data('timer',timer);   
   
   var slides=$('.slide',this);
   var height=slides.max_height();
   
   $(this).height(height);
  }
  
  $('.slides').slideshow();
 }
);

