Ummm...that was a complete demo page, only. I can't help you integrate it with your code until/unless I see your code.
You never did show your HTML, for example.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.