Auto Weight deform the mesh badly

Please help me, when i try to auto weight the mesh with the rig :


the mesh deform badly like this :


i’ve apply all modifiers, remove doubles and recalculate and turn on auto run python script, but the problem still exist. here’s the blend file : http://www.pasteall.org/blend/28991

The problem is the bone ik constraints. The Pole angle is wrong.
Disable the ik bone constraints, re-enable after when the other problems are fixed.

You should apply location rotation scale, for both mesh and armature, before parent to armature, Ctrl+A in object mode.
Recalculate bone roll with Ctrl+N in edit mode, I recommend Global Y for most the bones.
To get the IK bones to bend in the correct direction, in edit mode or pose mode, give the bones small bend in the direction you want them to bend.
Disable Deform for the ik target and pole target bones. Properties > Bones > Deform panel.
http://www.pasteall.org/blend/29004
Then parent with auto weights, test the deformation by moving the bones without using the ik’s.
Set the armature modifier before the subdivision surface modifier for better deformations, set Preserve Volume if desired.
When you re-enable the IK bone constraints, set the pole angle so the bend points towards the pole targets.

thank you for your long explanation. i’ll try it