Bearing in mind that energy cannot be created or distroyed-only changed, can you tell me the answer to a question? When light enters a medium, such as glass or water, it is deflected because it slows down while passing through it and loses energy (glass gets warm in sunlight). However when it exits it is back to its original speed. Where did the energy come from to accelerate it back to its full speed?
Refraction takes place as photons of light entering a transparent medium are temporarily absorbed by the atoms in a transparent medium. The atoms quickly release the photons of light after absorption to return to a normal energy level. Once released the photons travel at the only speed they can, the velocity of light.
just as a side issue, the heat that warms up the window pane is a form of light called infra red and it is not visible to the eye (just like ultra violet). The light that you see is not 'losing energy' is it refracting through the medium. I dont know if you've noticed but depending on the angle of 'incidence' the light beam can exit the medium wider than entering. To the point where it will seperate out into the 7 colours making up white light -a rainbow!
When the light enters the denser medium the light waves contract. Light does not lose any energy as a result of passing through different mediums such as glass or water and does not gain energy on exiting the medium although it will revert back to c. The upshot of this is that it does not accelerate back up to full speed but rather has different speeds based on the medium involved.