To factory reset the phone:
Power down the phone completely. Long-press power and select "power off". Or just keep pressing the power button until it forces it down. Or pull the battery and put it back in.
Start the phone by pressing POWER - HOME - VOLUME UP simultaneously until you see a blue "BOOTING TO RECOVERY" message at the top of the screen.
Let go of all buttons when you see this and a little android with a spinning thing in his belly will appear. Wait that screen out and you will get the the "Android System Recovery" menu.
Use the volume down button to highlight "wipe data/factory reset" and select that option by pressing the POWER key. Then you'll be presented with a menu of "NO", "NO", "NO", "YES -- DELETE ALL USER DATA", "NO". Scroll down to "YES" and select that. You may be asked again if you are really sure you want to wipe your device.