You can do this with much less code and much less headaches.
1. Store tablet position attributes in classes
.tablet1{ height:100px; width:140px; margin-left:-540px; top: 200px; z-index:10; }
2. Use a common function to handle all of your transitions.
The jQuery user interface will do all the work for you if you use switchClass
switchTabletsRight = function(){ var i, next, max = 5; for(i = 1; i <= max; i++){ next = (i < max)? i + 1 : 1; $(".tablet" + i).switchClass("tablet" + i, "tablet" + next); } };β
Here's a proof of JSfiddle concept: http://jsfiddle.net/nRHag/4/
source share