Generalized Associated Legendre Functions and Their Applications