How to determine position from gyroscope and accelerometer input?
Here's a tutorial on implementing a direction cosine matrix for an IMU:
http://gentlenav.googlecode.com/files/DCMDraft2.pdf

Take a look at the ArduIMU pages:
http://code.google.com/p/ardu-imu/wiki/Theory

Here are a couple of open source projects which do this. Reading the code should give some clues:

http://code.google.com/p/gluonpilot/source/browse/trunk/Firmware/#Firmware/rtos_pilot%3Fstate%3Dclosed

http://code.google.com/p/sf9domahrs/