function isInt(str)
{
  i = parseInt(str);

  if (isNaN (i))
  {
//    alert("the inserted string does not begin with a number " + str);
    return false;
  }
  
  i = i.toString ();
  if (i != str)
  {
//    alert("the input string contains an integer followed by sth else: " + str);
    return false;
  }
  return true;
}

function oneRadioChecked(buttongroup)
{
  var button_chosen = false;

  // Loop from zero to the one minus the number of radio button selections
  for (counter = 0; counter < buttongroup.length; counter++)
  {
   if (buttongroup[counter].checked)
     button_chosen = true; 
  }
  
  //if none was chosen return false
  if (!button_chosen)
  {
    return false;
  }
  
  return true
}

function checkInput()
{
  var scoreForm = document.ms_date_receiver;
  
  //LEVEL check
  var levels = scoreForm.ms_scores_level_id;
  
  if (!oneRadioChecked(levels))
  {
    // If there were no selections made display an alert box 
    alert("Please choose a playing Level");
    return false;
  }
  
  //CLONE check
  var clones = scoreForm.ms_scores_clone_id;

  if (!oneRadioChecked(clones))
  {
    // If there were no selections made display an alert box 
    alert("Please choose the Clone where your game was played");
    return false;
  }

  //INTEGER SCORE check
  var score = scoreForm.ms_scores_score.value;
  
  if(!isInt(score))
  {
    alert("the inserted Integer Score is not an integer. Please correct!");
    return false;
  }

  //TIME check
  var time = scoreForm.ms_scores_time.value;
  time.replace(",",".");
  var time_f = parseFloat(time);
  var score_i= parseInt(score); 
  if(isNaN(score_i))
  {
    alert("the inserted Time is not a number. Please correct!");
    return false;
  }
  if(score_i==0)
  {
    alert("You must enter an integer score! Scores start at 1.");
    return false;
  }
  if( (time_f < (score_i - 1)) || (time_f >= (score_i + 1)) )
  {
    alert("the inserted Time does not correspond to the Integer score field. Please correct!");
    return false;
  }

/*  
  //TIME check
  var time = scoreForm.ms_scores_time.value;

  alert("time " +time);  

  if(isNaN(time))
  {
    alert("the inserted Time is not a number. Please correct!");
    return false;
  }
  
  //INTEGER SCORE and TIME coherence check
  var time_f = parseFloat(time);
  var score_i= parseInt(score); 
  if( (time_f < (score_i - 1)) || (time_f > (score_i + 1)) )
  {
    alert("the inserted Time does not correspond to the Integer score field. Please correct!");
    return false;
  }
*/
   
  
  return true;
}