New Approach to Electronic Structure Calculations for Diatomic Molecules: Application to F2 and Cl2