Javascript version of the 8 tile puzzle