I didn't read everything, sorry. But here are a couple things that seem fishy, and a bit of advice, too.
First, these:
PHP Code:
temp.onwallx = (player.x + 1.5) + temp.movex;
temp.onwally = (player.y + 2) - temp.movey;
I've already changed those accordingly. You do want to use the center of the player as a base value, right? That's player.x + 1.5 and player.y + 2, not player.x + 1. Keep that in mind.
Also, you can very easily shorten your code right there:
PHP Code:
if(this.kdir == 0){player.dir = 2;}
elseif(this.kdir == 1){player.dir = 3;}
elseif(this.kdir == 2){player.dir = 0;}
elseif(this.kdir == 3){player.dir = 1;}
Can be turned into this:
PHP Code:
player.dir = (this.kdir + 2) % 4;
And that's basically it. I'm too darn lazy to analyze your problem, sorry

I suggest you get rid of the timeout stuff, though. Doing all that thingamajig at the top of doKnockback() every time it's being called seems a bit over the top. Just use a for-loop or something.