Use MacBook as a monitor and controller for iMac
You can't really use the MacBook as display or keyboard. What you can do is control the iMac remotely via Screen Sharing. This is a builti in function in OS X since 10.5: 
Screen Sharing.

Please note that his is not a workable solutions for anything that requires fast display refreshes as all data is send via your network.

There are several instruction out there:
http://macs.about.com/od/usingyourmac/qt/Mac-Screen-Sharing-How-To-Connect-To-Another-Macs-Desktop.htm