In the following sentence:
I thank you for arranging the wedding.
What type of phrase is for arranging the wedding?
For is a preposition, but the fact there is not only a noun following it but also "arranging" is confusing me a little.
Then, if we swap the order of the sentence around to
For arranging the wedding, I thank you.
What is for functioning as in this case?