As for "optimizations", instead of, "while j > 0", you could use, "while j > length*.5", since you've already checked the first n/2 letters of the word. :P
(I might be off by one. Sorry for that, if so.)
'm a web developer by profession, but a game developer by heart.
Uh oh! The princess is in another signature!