function npcMove(var d)
{
var dir = d;
That part is redundant. Why make a new var to get the d var info?
also, since only one of those "ifs" could work you should "return" the function to help speed up processing time. I know it's very little time but every bit helps.
Are you making a side scroller game? if so you will need to wait until the player gets within the screen width to start them using any of their main functions, however you will still need to check to see how close they are. If it is not then regular code will need to be used as rendering will not be done on anything outside of the screen view.
I would have it create and destroy the panels as need, as per level. However I would think 200 would be fine.