A simple Javascript function to split images into columns and rows