Problem with function calls [javascript]
<pre><code>&lt;script language="javascript"&gt;
function toggle(id) {
    alert('call');
    if (document.getElementById(id).style.display == "none") {
        alert('now visible');
        document.getElementById(id).style.display = "";
    } else {
        alert('now invisible');
        document.getElementById(id).style.display = "none";
    }
}
&lt;/script&gt;

&lt;/head&gt;
&lt;body onload="toggle('image1');alert('test_body');toggle('image2')"&gt;

&lt;script language="javascript"&gt;
alert('test_pre_function');
toggle('image1');
alert('test_after_function');
toggle('image2');
&lt;/script&gt;
</code></pre>

<p>Looks like a lot of code but it's pretty simple so i think most of you won't have troubles with it. toggle() should toggle the display status of divs containing images.</p>

<p>When the user enters the site the divs should hide, when everything is loaded the divs should show up. (onload)</p>

<p>Strangely enough, the funtion in the body (not in the body tag) only work half, i get and alert 'test_pre_function' and i get an alert 'call' (out of the function), but that's it.
The code in the body tag runs just fine.</p>

<p>I find this weird because it's supposed to do exactly the same twice and one time it runs, another time not, so i guess i must have made some stupid mistake.</p>

<p>Thanks for any help!</p>
