Untested, but I think this does it: function init(){ LastPic = $('#slide-images li').slice(1).hide().length; }
In jQuery there is probably a better way to do the rest of the code than using a global variable for LastPic, but it depends on what the rest of the code looks like.