function radioValue(radio){
  for (var i = 0; i < radio.length; i++){
    if (radio[i].checked) return radio[i].value;
  }  
  return;
}

function checkFormType(form){
  var formType = radioValue(form.formtype);
  document.getElementById('address_mandatory').style.visibility = (formType == "2" ? 'visible' : 'hidden');
}

function validate(form){
  var errors = [];
  if (!form.fullname.value) errors.push("Name");
  if (!form.nationality.value) errors.push("Nationality");
  if (!radioValue(form.injapan)) errors.push("Are you in Japan now?");
  if (!radioValue(form.interest)) errors.push("Interested in");
  if (!form.email.value) errors.push("Email Address");
  if (!form.body.value) errors.push("Your Inquiry");
//  if (!radioValue(form.gender)) errors.push("Gender");
//  if (!form.age.value) errors.push("Age");
//  if (!form.educational.value) errors.push("Last official education in your country");
//  if (!form.japanese.value) errors.push("What is your Japanese level?");
 
  if (errors.length > 0)
  {
    var errorString = "";
    for( var i = 0; i < errors.length; i++)
    {
      errorString += "Field '" + errors[i] + "' is mandatory.\n\r";
    }
    alert(errorString);
    return false;
  }
  else
  {
    return true;
  }  
}
