Moved login function in to documen ready function