Microscopic calculations of stellar weak interaction rates and energy losses for fp- and fpg-shell nuclei