hard to say, 500d can use 12800iso and seems to handle 3200iso bit better than 40f, but 40d has way better controls and isnt as much of a toy as 500d. I bet shooting video wont be easy with a dslr but you will be better resaults with it than a normal hd video cam. If you think video shooting will be really big deal and you like to shoot with high iso and you dont care about good controls, go with 500d. 40d is really really better to control than those cheap models, you got a joystick for changing focus point and wheel for f-number, these are soooo usefull that personally i wouldnt want a camera without them enymore, now that i have gotten used to them, now my old 400d(that my mate owns) feels like a pain to shoot with those stupid controls. Even tho video recording might sound like fun idea, but you should think if you will really use it so much that you would want otherways crappier camera so you would get to shoot video too.
I would prolly take 40d, but dunno if its the right choise for you.