
  function closeTest()
  {
    $('#test_body').slideUp('slow');
    testOpened = false;
  }
  
  function redoTest()
  {
    $('#test_body').slideUp('slow', reopenTest);
    
    testOpened = false;
  }  
  
  function reopenTest()
  {
   testOpened = true;
   var params = new Array();
    params.push("page=ajax_begin_test");      
    $.ajax({
        type: "GET",
        url: "/index.php",
        data: params.join("&"),
        dataType: "text",
        success: openBuildNext
     });    
  }
  
  function openBuildNext(data, textStatus, jqXHR)
  {
     $('#test_domanda').replaceWith(data);
     $('#test_body').slideDown('slow');
  }  

  function buildNext(data, textStatus, jqXHR)
  {
     $('#test_domanda').replaceWith(data);
  }
  
  function execTest(direction)
  {

    var esito = document.frm.testAnsw;  
    var risposta;
    var no = 0;
    
    if (esito[0].checked) 
    {
      no++;
      risposta = "si";
    }
      
    if (esito[1].checked) 
    {
      no++;
      risposta = "avolte";
    } 
    if (esito[2].checked) 
    {
      no++;
      risposta = "no";
    }  
      
    if (no == 0 && direction == "1")
    {
    	  alert("Per proseguire, prima rispondi alla domanda");
        return false;
    }

    
    var params = new Array();
    params.push("page=ajax_test");      
    params.push("direction=" + direction);
    params.push("risposta=" + risposta);
    params.push("domanda=" + document.frm.domanda.value);
    $.ajax({
        type: "GET",
        url: "/index.php",
        data: params.join("&"),
        dataType: "text",
        success: buildNext
     });         
 
 }
 
 

