I can't assign a class to an element opened in new window
<p>hi every body I'm trying to open an image in a new window ,using javascript, by clicking on a button, then set a class to the image, using this code:</p>

<pre><code>    OpenWindow=window.open("", "newwin","height=100,width=1000"); 
    OpenWindow.document.write("&lt;img id='img1' src='webfonts.jpg'&gt;");
    OpenWindow.document.getElementById("img1").className = "larger";
    OpenWindow.document.close();
</code></pre>

<p>and this is the internal style I have included in my code in a style tag:
.larger{ width:10px; }
and in the body tag 
1:I have include my image source by an img tag
2:make a button tag with an onclick=larger() attribute</p>

<p>but unfortunately I have a problem with last sentence, the class is not assigned at all to the image.
 I have tried to use classname also instead of setttribute but it generates the same result. 
any ideas?
thx </p>
