Javascript simple onclick image swap
<p>I am trying to use Javascript to swap an image, so far I can get it from A to B, but not back.</p>

<p>Here is what I'm using to create one swap:</p>

<pre><code>&lt;img src="pic1.png" name="pic" onclick="window.document.pic.src='pic2.png';"/&gt;
</code></pre>

<p>This swaps image 1 to image 2, simple enough. But I want to be able to revert back to image 1 by clicking on the new image 2. I tried using this:</p>

<pre><code>&lt;img src="pic1.png" name="pic" onclick="
if (window.document.pic.src='pic1.png'){
window.document.pic.src='pic2.png';
} 
else if (window.document.pic.src='pic2.png'){
window.document.pic.src='pic1.png';
}"/&gt;
</code></pre>

<p>It doesn't seem to work in this instance. It will switch to pic2, but not switch back to pic1. Is it something to do with onclick? My if statements? Thanks</p>
