Changes for issue #284

These changes fix 2 bugs that were occurring in IE.

3a60110 fixes an error when map.layers is undefined.

The remaining commits fix the problem where the animation controls were never activated after all the images were loaded. The heart of the problem was the way we checked if the image was loaded is not working in IE.

The original problem mentioned in #284 is now fixed but I don't think it was the changes made here that fixed it.

There are a fair few tidy-up and whitespace commits so I suggest you look at each commit individually rather than viewing the changes file-by-file.