Influence of habitat quality and gender on the variable mating system of a territorial passerine, the savannah sparrow