When you hover over the thubmnail (in this case its an image, but it could be any element), the mouseover/hover event is triggered and a function is called. In that function, you change the source attribute of your image.
So in the examples you provided above, it should be the same approach that they are using. As you hover over the elements, you are executing a function. Depending on what paramater your are passing to the function will result in a different image appearing.
hope this helps, or at least gets you in the right direction.