var activeItem = null;

function showMenu(id)
{
  var el = document.getElementById('menu_' + id);
  if (el)
  {
    el.style.display = 'block';
    activeItem = el;
  }
}

function hideMenu()
{
  if (activeItem)
    activeItem.style.display = 'none';
}

function addScore()
{
  var dest = document.getElementById('sum');
  if (dest)
  {
    var form = document.getElementById('Form1');
    var fields = form.getElementsByTagName('input');
    var value = 0;

    for (i=0; i < fields.length; i++)
    {
      if (fields[i].type == 'radio' && fields[i].checked)
      {
        value = value + parseInt(fields[i].value);
      }
    }

    dest.value = value;
  }
}

function calculate() {
  var flag=0;
  for (var i=0; i < document.Question1.radiobutton.length; i++)
   {
   if (document.Question1.radiobutton[i].checked)
      {
      var a1 = document.Question1.radiobutton[i].value;
      flag=1;
      }
   if (flag==0)
      {
      var a1 = 0;
      }
   }
   flag = 0;
   for (var i=0; i < document.Question2.radiobutton.length; i++)
   {
   if (document.Question2.radiobutton[i].checked)
      {
      var a2 = document.Question2.radiobutton[i].value;
      flag=1;
      }
   if (flag==0)
     { 
     var a2 = 0;
     }
   }
   flag=0;
   for (var i=0; i < document.Question3.radiobutton.length; i++)
   {
   if (document.Question3.radiobutton[i].checked)
      {
      var a3 = document.Question3.radiobutton[i].value;
      flag=1;
      }
   if (flag==0)
      {
      var a3 = 0;
      }
      
   }
   flag=0;
   for (var i=0; i < document.Question4.radiobutton.length; i++)
   {
   if (document.Question4.radiobutton[i].checked)
      {
      var a4 = document.Question4.radiobutton[i].value;
      flag=1;
      }
   if (flag==0)
      {
      var a4 = 0;
      }
   }
   flag=0;
   for (var i=0; i < document.Question5.radiobutton.length; i++)
   {
   if (document.Question5.radiobutton[i].checked)
      {
      var a5 = document.Question5.radiobutton[i].value;
      flag=1;
      }
   if (flag==0)
      {
      var a5 = 0;
      }
   }
   flag=0;
   for (var i=0; i < document.Question6.radiobutton.length; i++)
   {
   if (document.Question6.radiobutton[i].checked)
      {
      var a6 = document.Question6.radiobutton[i].value;
      flag=1;
      }
   if (flag==0)
      {
      var a6 = 0;
      }
   }
   flag=0;
   for (var i=0; i < document.Question7.radiobutton.length; i++)
   {
   if (document.Question7.radiobutton[i].checked)
      {
      var a7 = document.Question7.radiobutton[i].value;
      flag=1;
      }
   if (flag==0)
      {
      var a7 = 0;
      }
   }
   flag=0;
   for (var i=0; i < document.Question8.radiobutton.length; i++)
   {
   if (document.Question8.radiobutton[i].checked)
      {
      var a8 = document.Question8.radiobutton[i].value;
      flag=1;
      }
   if (flag==0)
      {
      var a8 = 0;
      }
   }
  
  var result = eval(a1) + eval(a2) + eval(a3) + eval(a4) + eval(a5) + eval(a6) + eval(a7)  + eval(a8);

  document.sumform.Textfield_result.value = result;

}

