Moving mail javascript function to an independent file