<!--

function setTotal(box)
{
   var s = document.survey;

   with(box)
   {
       if( box.value.match(/\D/) )
       {
         alert("input is not a digit");
       }
       else
       {
               s.p50q1t.value = 0;
               s.p50q1t.value = s.p50q1a.value*1 +s.p50q1b.value*1 +s.p50q1c.value*1+s.p50q1d.value*1 +s.p50q1e.value*1 +s.p50q1f.value*1;
         }
   }
}

function setTotal70(box)
{
   var s = document.survey;

   with(box)
   {
       if( box.value.match(/\D/) )
       {
         alert("input is not a digit");
       }
       else
       {
               s.p70t.value = 0;
               s.p70t.value = s.p70a.value*1 +s.p70b.value*1 +s.p70c.value*1+s.p70d.value*1 +s.p70e.value*1 +s.p70f.value*1 +s.p70g.value*1;
         }
   }
}

function ck30()
{
   var s = document.survey;
   finish = 1;
   var ckCounter = 0;

   if(s.p30q1a.checked)
   {
      ckCounter++;
   }

   if(s.p30q1b.checked)
   {
      ckCounter++;
   }

   if(s.p30q1c.checked)
   {
      ckCounter++;
   }

   if(s.p30q1d.checked)
   {
      ckCounter++;
   }

   if(s.p30q1e.checked)
   {
      ckCounter++;
   }

   if(s.p30q1f.checked)
   {
      ckCounter++;
   }

   if(ckCounter == 0)
   {
      alert("Please check at least one answer.");
      finish = 0;
   }

   if(s.p30q1f.checked && (s.p30q1a.checked || s.p30q1b.checked || s.p30q1c.checked || s.p30q1d.checked || s.p30q1e.checked))
   {
      alert("You have selected 'none of these' along with other choices, please double check your answers.");
      finish = 0;
   }

   if(finish)
   {
     s.submit();
   }
}


function ck50()
{
   var s = document.survey;
   finish = 1;
   var ckCounter = 0;

   if(s.p50q1t.value != 100)
   {
      alert("Sum is not 100 for the first question.");
     finish = 0;
   }

   if(finish)
   {
        if( s.p50q2a.checked)
     {   ckCounter++; }
        if( s.p50q2b.checked)
     {   ckCounter++; }
        if( s.p50q2c.checked)
     {   ckCounter++; }
        if( s.p50q2d.checked)
     {   ckCounter++; }
        if( s.p50q2e.checked)
     {   ckCounter++; }

     if(ckCounter == 0)
     {
        alert("Please answer the second question.");
       finish = 0;
     }

     if( ckCounter > 3)
     {
        alert("Please select no more than 3 for the second question.");
       finish = 0;
     }
   }

   if(finish)
   {
     s.submit();
   }
}


function ck60(box)
{
   var s = document.survey;
   var ranks = [0,0,0,0,0];
   var i = 0;
   finish = 1;

   for(i=0; i<5; i++)
   {
      if(s.p60a.options[i].selected)
        {  ranks[i]++;  }
   }

   for(i=0; i<5; i++)
   {
      if(s.p60b.options[i].selected)
        {  ranks[i]++;  }
   }

   for(i=0; i<5; i++)
   {
      if(s.p60c.options[i].selected)
        {  ranks[i]++;  }
   }

   for(i=0; i<5; i++)
   {
      if(s.p60d.options[i].selected)
        {  ranks[i]++;  }
   }

   for(i=0; i<5; i++)
   {
      if(s.p60e.options[i].selected)
        {  ranks[i]++;  }
   }

   if(ranks[0] > 1 || ranks[1] > 1 || ranks[2] > 1 || ranks[3] > 1 || ranks[4] > 1)
   {
      finish = 0;
   }

   if( finish )
   {
        s.submit();
   }
   else
   {
        alert("Please check your answer.  Each number can be used only once.");
   }
}


function ck70(box)
{
  var s = document.survey;
  var finish=1;

  var i;

  if(s.p70t.value != 100)
  {
     alert("Please make sure sum is 100.");
     finish = 0;
  }

  if ( finish )
  {
     s.submit();
  }
}


function ck130(box)
{
  var s = document.survey;
  var finish=1;

  var i;

  for (i=0; i< s.length && finish; i++)
  {
    // namename contains the name of the form array element[i]
    var namename = s.elements[i].name;
   
   // can not handle the case when the user enters white spaces   
   if ((s.elements[i].type == 'text') || (s.elements[i].type == 'textarea'))
    {
        if(s.elements[i].value == "" || s.elements[i].value == null)      
        {
         alert("Please answer all the questions.");
         s.elements[i].focus();
          finish = 0;
       }
      
      if(finish && (s.elements[i].value.match(/\D/)))
      {
          alert("Please input whole numbers");
         s.elements[i].focus();
         finish = 0;
      }
    } // end text
  } // end for loop
   
  if ( finish )
  {
     s.submit();
  }
}

function stimer()
{
   var s = document.survey;
   var timeLen = 10;
   var finish = 1;

   var ctime=new Date();

   var diff=Math.floor( (ctime.getTime()-stime.getTime())/1000 );

   if(diff < timeLen)
   {
        alert("You only viewed this screen for "+diff+" second(s).  During our tests of this survey, the median time was 30 seconds.  Please spend a little more time reviewing this material");
        finish = 0;
   }

   if(finish)
   {
        s.submit();
   }
}



//-->

