Increasing performance by removing the loop.

Removing the loop where the display property of the rest of div is set to 'none'.
Instead using a 'prev' variable to store the previous slide number and setting its display as none.