You must realise that cameras - not just digital ones - are not all that clever. When you look through a window, you don't have to think about it, you automatically focus on what is outside.
When you aim a camera through a window, it focuses on what you aim it at, i.e. the window.
In order to focus it correctly, you need to control the automatic focus. There is probably more than one way of doing it, but Jet II's suggestion is probably the simplest.
Do you still have the user manual? If not, you should be able to download it. I'm sure it will explain it there better than I can.