Power it down
Remove the power cord and leave out for 15 seconds or so
If No, insert the original OS X disc and shut down the iMac
Hold down the Option key and power it up. Keep the key down.
You should get an option of which drive to boot from.
Shut down the iMac, then restart while holding down the Shift Key. Keep it down.
iMac should start up in Safe Mode.
Shut down the iMac
Remove the keyboard and the mouse.
If it works this time, then either your mouse or keyboard is causing the problem.
You may want to try this first