Allow multiple windows to be opened if the windows don't already exist
<p>I have an application that opens a new window on clicking a button.</p>

<p>There are many buttons to open multiple windows if the windows don't already exist.</p>

<p>All the buttons and url are dynamic, therefore, I use a function to open window with the following codes:</p>

<pre><code>function openwin(url, winname)
{   
    var winRef = window[winname];

    if( typeof winRef =='undefined' || winRef.closed)
    {    
        winRef = window.open (url, 'winname');
        winRef.focus();
    }
}
</code></pre>

<p>But there is problem/bug:</p>

<p>When I click on button A, it opens new window A.<br>
When I click on button B, it "overwrite A" and the window become B.<br>
When I click on button A again, it "overwrite B" and the window become A.<br></p>

<p>Therefore, I always open one new window.</p>
