Hi
It seems that this code was patch together from pieces of code. You are calling var canvas twice and are try to print images all together. If you want to better understand how things work, please have a look at:
http://www.w3schools.com/html/html5_canvas.asp[
^]
http://www.w3schools.com/js/js_functions.asp[
^]
Start from the basic and work your way up.
However, if you feel like you can do this starting from half way, have a look on this Tip/Trick
Image Sliding Effect with JavaScript[
^] and adapt it to clicking instead of the timer. If it looks to difficult to do it, then maybe you should look and practice at the first 2 links.
Good Luck
Regards