Why does the context change in this JS snippet?
<p><a href="http://jsfiddle.net/raylu/C6Tkn/" rel="nofollow">http://jsfiddle.net/raylu/C6Tkn/</a></p>

<pre><code>function a() {
    document.write(this + '&lt;br /&gt;');
}

a();
a.apply('hello');

var b = function() {
    a();
}
b.apply('hi');​
</code></pre>

<p>I would expect the last line to output 'hi', but instead it outputs window.</p>
