$(document).ready(function(){
var masterCount = $('.sheets-gallery ul li').size();
$(".sheets-gallery ul li").each(function(idx, item) {
var itemNum = idx+1;
var p = $(this).parent()[0];
if(itemNum != masterCount){
$('#li'+itemNum).toggle(function(e) {
e.preventDefault();
var mLeft = $(this).css('margin-left').replace("px", "");
var total = parseInt(mLeft) - 700;
$(this).animate({'margin-left':total},500);
if(p != "undefined"){
$(this).prev('li').click();
}
},function() {
var mLeft3 = $(this).css('margin-left').replace("px", "");
var total3 = parseInt(mLeft3) + 700;
$(this).animate({'margin-left':total3},500);
});
}
});
});