function slideSwitch() {
  var activeImage = $('#slideshow IMG.active');
  if (activeImage.length == 0) {
    activeImage = $('#slideshow IMG:last');
  }
  var nextImage = activeImage.next().length ? activeImage.next() : $('#slideshow IMG:first');
  activeImage.addClass('lastActive');
  if("\v"!="v"){
    animate_bg($('#slideshow li:nth-child('+nextImage.attr('position')+') a'), 0, 10);
    $('#slideshow li a.active').css("background-color", "transparent").removeClass('active');
    $('#slideshow li:nth-child('+nextImage.attr('position')+') a').addClass('active');
  }
  nextImage.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function() {
    activeImage.removeClass('active lastActive');
  });
}
$(function() { setInterval( "slideSwitch()", 3500 ); });


function animate_bg(element, from, to) {
    element.css("background-color", "rgba(139, 139, 139, " + (from += from > to ? -1 : 1) / 10 + ")"); 
    if(from != to)  
        setTimeout(function() { animate_bg(element, from, to) }, 50);
}
