Calculate X,Y coordinates dynamically in jQuery Windows Engine
<p>I got a small problem with jQuery Windows Engine</p>

<p>I will just send no of windows (1, 2, 3, 4, ...) and based on this number, the windows have to generate dynamically by adjusting height, width, posx, posy. Can anyone please provide me the logic to calculate the to calculate heights, widths, posx, posy dynamically in JavaScript or jQuery?</p>

<p>If I pass 1 then the height and  widths will be <code>screen.X</code> and <code>screen.Y</code>. If I pass <code>2</code> then the height will be the same and width will be half of screen width, if I pass 4 <code>height=screen.Y/2</code> and <code>width=screen.X/2</code> and so on.</p>

<p>Hope it's understandable.</p>

<p>I am trying like this:</p>

<pre><code>     for(i=1;i&lt;=noOfWindows;i++)
     {
      if((i-1)%3==0 &amp;&amp; (i-1)!=0)
      {
       newWidth=0;
       posWidth=0;
       posHeight = posHeight+parseInt(maxHeight/(noOfWindows/3))+50;
      }

      posWidth = posWidth+newWidth+10;

      newHeight = parseInt(maxHeight/Math.ceil(noOfWindows/3));
      newWidth= parseInt(maxWidth/Math.ceil(noOfWindows/3));
      //newHeight = parseInt(maxHeight/(noOfWindows/3));
      //newWidth= parseInt(maxWidth/(noOfWindows/3));

      $.newWindow({
       id:"window"+i,
       posx:10+posWidth,
       posy:50+posHeight,
       width:newWidth+"px",
       height:newHeight+"px",
       title:"",
       content:"", 
       type:"iframe",
       minimizeButton: true,
       maximizeButton: true,
       closeButton: true,
       draggable: true,
       statusBar: true,
       resizeable: true
      });
   }
</code></pre>
