Brane dynamics in the Randall-Sundrum model, inflation and graceful exit