all, I'm trying to building a ebay/kijiji like image item

Hello all,

I'm trying to building a ebay/kijiji like image item image slider where the top image becomes the small image. Example

Here's my code

I'm not sure where I'm going wrong. I'm pretty rusty with Javascript, so I'm not sure what I'm doing wrong?

Thank you very much!