You can't be serious to ask us to comment that volume of code, are you? You're asking us to do your grunt work, and sorry, but that just suggests you're being lazy.
If I were you, I'd go to the code's source, your friend, and see if they can help you through it. They created it after all (I assume).
If you still need our help, then I recomend that YOU slog through the code, find specific parts that you don't understand, and then come on back with any questions that can reasonably answered in a forum such as this.
Again, what specific segment(s) of code do you not understand???
Asking us to read through that whole code without first showing at least a tiny bit of effort on your part does not reflect well on you. Please show that you've put in as much work asking your question as you're requesting others to put in to answer it.
I'm out of here.