Afghan parliament elects speaker after bitter crisis