Well, when you've fixed all the array indices, post your code.
(note to mods: this is virtually unusable.)