I'm not sure I fully understand what you want to do; but here's a suggestion based on my understanding of it.
Whatever the image is you want to change the source of, give it a unique id, and access it via:
document.getElementById('imageID').src='images/newimage.jpg';