$(document).ready(function(){
  rotatePics(1);
});

function rotatePics(currentPhoto) {
  var numberOfPhotos = $('#photos img').length;
  currentPhoto = currentPhoto % numberOfPhotos;
	
  $('#photos img').eq(currentPhoto).fadeOut(function() {
		// re-order the z-index
    $('#photos img').each(function(i) {
      $(this).css(
        'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos
      );
    });
    $(this).show();
    setTimeout(function() {rotatePics(++currentPhoto);}, 5000);
  });
}



$(document).ready(function(){
  rotatePromoPics(1);
});

function rotatePromoPics(currentPromoPhoto) {
  var numberOfPromoPhotos = $('#promo img').length;
  currentPromoPhoto = currentPromoPhoto % numberOfPromoPhotos;
	
  $('#promo img').eq(currentPromoPhoto).fadeOut(function() {
		// re-order the z-index
    $('#promo img').each(function(i) {
      $(this).css(
        'zIndex', ((numberOfPromoPhotos - i) + currentPromoPhoto) % numberOfPromoPhotos
      );
    });
    $(this).show();
    setTimeout(function() {rotatePromoPics(++currentPromoPhoto);}, 5000);
  });
}



$(document).ready(function(){
  rotateMarqueePics(1);
});

function rotateMarqueePics(currentMarqueePhoto) {
  var numberOfMarqueePhotos = $('#marquee img').length;
  currentMarqueePhoto = currentMarqueePhoto % numberOfMarqueePhotos;
	
  $('#marquee img').eq(currentMarqueePhoto).fadeOut(function() {
		// re-order the z-index
    $('#marquee img').each(function(i) {
      $(this).css(
        'zIndex', ((numberOfMarqueePhotos - i) + currentMarqueePhoto) % numberOfMarqueePhotos
      );
    });
    $(this).show();
    setTimeout(function() {rotateMarqueePics(++currentMarqueePhoto);}, 5000);
  });
}



$(document).ready(function(){
  rotateproduct_swapPics(1);
});

function rotateproduct_swapPics(currentproduct_swapPhoto) {
  var numberOfproduct_swapPhotos = $('#product_swap img').length;
  currentproduct_swapPhoto = currentproduct_swapPhoto % numberOfproduct_swapPhotos;
	
  $('#product_swap img').eq(currentproduct_swapPhoto).fadeOut(function() {
		// re-order the z-index
    $('#product_swap img').each(function(i) {
      $(this).css(
        'zIndex', ((numberOfproduct_swapPhotos - i) + currentproduct_swapPhoto) % numberOfproduct_swapPhotos
      );
    });
    $(this).show();
    setTimeout(function() {rotateproduct_swapPics(++currentproduct_swapPhoto);}, 1700);
  });
}




