/***** IMAGE SLIDESHOW ******/
var running = 0;

function updateSlideshow(withFade, tempo) {
  if(!withFade)
    withFade = false;

  var active_button = jQuery('div#image_slide div#img_buttons a.active');
  var next_button = active_button.next().length ? active_button.next(): jQuery('div#image_slide div#img_buttons a:first-child');
 
  var active_img = jQuery('div#image_slide div#images div.active');
  var next_img = active_img.next().length ? active_img.next(): jQuery('div#image_slide div#images>div:first-child');
  
  if(withFade)
  {
//    if(!tempo)
    {
      tempo = 1500; 
      tempo2 = 2000;
    }
    if(running != 1)
    {
      running = 1;
      jQuery('div#images>div#'+active_img.attr("id")).fadeOut(tempo, function(){
        jQuery('div#images>div#'+next_img.attr("id")).fadeIn(tempo2);
        active_img.removeClass('active');
        next_img.addClass('active');
        active_button.removeClass('active');
        next_button.addClass('active');
        running=0;
      });
    }
  }
  else
  {
    active_button.removeClass('active');
    active_img.removeClass('active'); 
  
    jQuery(active_img).css("display", "none");
    jQuery(next_img).css("display", "block");
  
    next_button.addClass('active');
    next_img.addClass('active');
  }
}



