function playMines(cols, rows, bombs, start, sound, promode, gfxs, snds)
{
  if(cols<8) cols=8;
  if(cols>40) cols=40;
  if(rows<5) rows=5;
  if(rows>25) rows=25;
 
  var minb=Math.ceil(cols*rows/20);
  var maxb=Math.floor(cols*rows/2);
  if(bombs<minb) bombs=minb;
  if(bombs>maxb) bombs=maxb;

  start=start ? 1 : 0;
  sound=sound ? 1 : 0;
  promode=promode ? 1 : 0;

  gfxs=gfxs.split(";");
  snds=snds.split(";");

  var width=cols*24+13;
  var height=rows*24+51;

  html="<applet code=\"net/sberk/games/inetmines/InetMines.class\" archive=\"inetmines.jar\" width=\""+width+"\" height=\""+height+"\" oncontextmenu=\"return false\">"
      +"<param name=\"cols\" value=\""+cols+"\" />"
      +"<param name=\"rows\" value=\""+rows+"\" />"
      +"<param name=\"bombs\" value=\""+bombs+"\" />"
      +"<param name=\"start\" value=\""+start+"\" />"
      +"<param name=\"sounds\" value=\""+sound+"\" />"
      +"<param name=\"promode\" value=\""+promode+"\" />"
      +"<param name=\"image\" value=\""+gfxs[0]+"\" />"
      +"<param name=\"bgnd\" value=\""+gfxs[1]+"\" />"
      +"<param name=\"fgnd\" value=\""+gfxs[2]+"\" />"
      +"<param name=\"light\" value=\""+gfxs[3]+"\" />"
      +"<param name=\"shadow\" value=\""+gfxs[4]+"\" />"
      +"<param name=\"wonsnd\" value=\""+snds[0]+"\" />"
      +"<param name=\"lostsnd\" value=\""+snds[1]+"\" />"
      +"<param name=\"quitsnd\" value=\""+snds[2]+"\" />"
      +"</applet>"
      +"<input type=\"hidden\" name=\"cols\" value=\""+cols+"\" />"
      +"<input type=\"hidden\" name=\"rows\" value=\""+rows+"\" />"
      +"<input type=\"hidden\" name=\"bombs\" value=\""+bombs+"\" />"
      +"<input type=\"hidden\" name=\"promode\" value=\""+promode+"\" />";

  var el=document.getElementById("mines");
  el.setAttribute("style", "width: "+width+"px;");

  var el=document.getElementById("content");
  el.innerHTML=html;
}

function showHighscores(cols, rows, bombs, promode)
{
  if(cols<8) cols=8;
  if(cols>40) cols=40;
  if(rows<5) rows=5;
  if(rows>25) rows=25;

  var minb=Math.ceil(cols*rows/20);
  var maxb=Math.floor(cols*rows/2);
  if(bombs<minb) bombs=minb;
  if(bombs>maxb) bombs=maxb;

  promode=promode ? 1 : 0;

  window.location.href="highscores.php?cols="+cols+"&rows="+rows+"&bombs="+bombs+"&promode="+promode;
}

function showInetMines(cols, rows, bombs, promode)
{
  if(cols<8) cols=8;
  if(cols>40) cols=40;
  if(rows<5) rows=5;
  if(rows>25) rows=25;

  var minb=Math.ceil(cols*rows/20);
  var maxb=Math.floor(cols*rows/2);
  if(bombs<minb) bombs=minb;
  if(bombs>maxb) bombs=maxb;

  promode=promode ? 1 : 0;

  window.location.href="/InetMines?cols="+cols+"&rows="+rows+"&bombs="+bombs+"&promode="+promode;
}

function loadScoresInto(element, cols, rows, bombs, promode)
{
  var el=document.getElementById(element);

  if(el)
  {
    // now let's try to load scores using an XMLHttpRequest
    var xmlReq=null;

    // first let's create an XMLHTTPRequest and load the document using the mozilla or IE way
    if(window.XMLHttpRequest)
      xmlReq=new XMLHttpRequest();
    else if(window.ActiveXObject)
    {
      try
      {
        xmlReq=new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch(e)
      {
        try
        {
          xmlReq=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e2) { }
      }
    }

    if(xmlReq)
    {
      promode=promode ? 1 : 0;
    
      xmlReq.open("GET", "scores.php?cols="+cols+"&rows="+rows+"&bombs="+bombs+"&promode="+promode, false);
      xmlReq.send(null);

      // 0 is returned when loading from file system not using HTTP !!!
      if(xmlReq.status>0 && (xmlReq.status<200 || xmlReq.status>=400))
        el.innerHTML="<h3>Error during XMLHttpRequest: "+xmlReq.status+" - "+xmlReq.statusText+"</h3>";
      else
        el.innerHTML=xmlReq.responseText;
    }
    else
    {
      el.innerHTML="<h3>Error: XMLHttpRequest not supported by your browser</h3>";
    }
  }
}


