President Obama's announcement that he supports same-sex marriage puts Timothy M. Kaine, a close friend and political ally, in a delicate position as he runs in a marquee Senate race in a swing state.