var elements = {
  'anim1' : { start: 10, distance: 40, duration: 15500},
  'anim2' : { start: 20, distance: 30, duration: 17000},
  'anim3' : { start: 25, distance: 35, duration: 15000},
  'anim4' : { start: 30, distance: 23, duration: 19000},
  'anim5' : { start: 15, distance: 10, duration: 17000},
  'anim6' : { start: 0, distance: 15, duration: 13000},
  'anim7' : { start: 38, distance: 20, duration: 11000},
  'anim8' : { start: 0, distance: 15, duration: 17000}
}

function moove(k,v,engine) {

  var i = elements[v.id];
 /*if(engine == 'reverse') {
  //$(v).css('left', '-'+ i.start + 'px')
//    .animate({left: '-'+(i.start + i.distance) + 'px'}, i.duration );
//setTimeout("moove("+k+","+v+",'normal')",i.duration);
//} else {*/
  $(v).css('left', i.start + '%')
    .animate({left: ( i.distance) + '%'}, i.duration,function() {
  $(v).css('left', ( i.distance) + '%')
    .animate({left: i.start  + '%'}, i.duration );	
	});
	/*
//setTimeout("moove("+k+","+v+",'reverse')",i.duration);
//}
  */
  setTimeout(function() { moove(k,v,'move') },i.duration*2);
};

/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});
