jQuery: too much recursion But I need recursion for minesweeper
<p>I am relatively new to javascript. I am trying to code my web version of minesweeper. Here is a recursive function I needed, and it looks to work fine until browser gives this "too much recursion" error. The problem is that i need that recursion. Is there any other way to code minesweeper?  Here is the demo: <a href="http://altynachar.com/minesweeper/" rel="nofollow">http://altynachar.com/minesweeper/</a></p>

<p>I can post my php code if needed.</p>

<pre><code>function recursive(id){
                var id = id;
                //Determine what kind of cell this is: Clean, Bomb or Adjasent to bomb
                if($("#"+id).hasClass("adj")== true)
                    var under = "adj";
                if($("#"+id).hasClass("bomb")==true)
                    var under = "bomb";
                if($("#"+id).hasClass("clean")==true)
                    var under = "clean";

                //open up the cell          
                $("#"+id).hide();
                $("#under_"+id).show(); 

                //if it is bomb, open up whole grid and button for restart
                if(under == 'bomb')
                {       
                    $(".cover").hide();
                    $(".under").show();
                    $("body").append("&lt;br /&gt;&lt;input type='button' value='restart' onClick='javascript:window.location.reload();' /&gt;");
                } else {        

                    //if it is clean cell       
                    if(under == "clean")
                    {
                        //get all the adjasent cell ids
                        var split = id.split('-');
                        var row = parseInt(split[0]);
                        var col = parseInt(split[1]);
                        var adjasent = new Array();
                        adjasent[0] = (row-1)+"-"+ (col+1);
                        adjasent[1] =  row +"-"+(col+1);
                        adjasent[2] = (row+1)+"-"+(col+1);
                        adjasent[3] = (row+1)+"-"+col;
                        adjasent[4] = (row+1)+"-"+(col-1);
                        adjasent[5] =  row+"-"+(col-1);
                        adjasent[6] = (row -1)+"-"+(col-1);
                        adjasent[7] = (row -1)+"-"+col;

                        //loop through adjasent cells
                        for(var i=0; i&lt;adjasent.length; i++)
                        {
                            var split2 = adjasent[i].split('-');
                            var row2 = parseInt(split2[0]);
                            var col2 = parseInt(split2[1]);

                            //check if cell is existent
                            if(row2 &gt; 0 &amp;&amp; row2 &lt; 17)
                            {
                                if(col2 &gt; 0 &amp;&amp; col2 &lt; 17)
                                {
                                    //perform recursion
                                    var adj = adjasent[i];
                                    recursive(adj);
                                } 
                            }                               
                        }
                    }
                } 
            }           
</code></pre>
