Implemented jQuery doc ready and fixed undefined variables