Select Menu > Settings > Rest. factory sett. Enter the security code. The default security code is 12345. Your phone starts restoring without extra notification.

Restoring factory settings resets all settings to their defaults, but your contacts, messages, and other personal files are not affected.