Added ready functionality

Probally replace with jquery for cross browser