You need a variable(s) that keep track of the currently shown 'picture sprite' index(es). (set to -1 if none is shown)
Assuming the click event is on the 'cards', you have to keep track of the index of which 'picture sprite' it is hiding.
Upon clicking, if the indexes are set to -1, set them to the correct values, then show the picture.
If however the indexes are not set to -1, then check if the shown picture is the same as the one just clicked (still using indexes and what not).