who wrote joy to the world three dog night