Ok let's take a look of it. U have two ways of doing it.
1 way, ur small image is just a big image but fixed to small size with style width and height. and u should call a function with this.src and ur function recieves needed path to show image.
2 way u'll need to know big image path, how u can do it -
it's ur business.
Now we need to make a function which shows a large image
(elem is an <img> tag which mouseovered or mouseclicked.
function ShowBigImage(elem,bigimagesrc)
{
smallleft=elem.style.left;
smalltop=elem.style.top;
newelement=document.createElement('img');
newelement.src=bigimagesrc;
document.body.appendChild(newelement);
newelement.style.left=smallleft+80;
newelement.style.top=smalltop;
newelement.style.position='absolute';
}
<body>
<img src='small.jpg' onmouseover=ShowBigImage(this,'bigimage.jpg') onclick=ShowBigImage(this,'bigimage.jpg')
</body>
This should place big image 80 pixels lefter smallimage.
I hope i was clear here) if something wrong, ask about it)
Good luck to you