Added Jagged Array to store jquery object references and replaced jquery code for finding neighbors with function that uses array.