Mechanics of isolated horizons