function checkEmail(email){
  var at = email.value.indexOf('@');
  var dot = email.value.lastIndexOf('.');
  if((at+1>=dot) | (at<1) | (email.value.indexOf(' ')!=-1)) {
    alert("Invalid email address: " + email.value + "!" );
    email.focus();
    return false;
  }
  return true;
}

function checkEmpty(component,error_message) {
  if (component.value=="") {
    alert(error_message);
    component.focus();
    return false
  }
  return true;
}

function checkField(component,good_condition,error_message) {
  if (String(good_condition)=="") return checkEmpty(component,error_message);
  if (!good_condition) {
    alert(error_message);
    component.focus();
    return false
  }
  return true;
}

function prompt_radio(para){
	//alert(para)
	if(!para){
		alert("You have not select a radio button");
		return false;
	}

}
function validForm(f) {

  f.From.value = f.Email.value
  var radval,rad_str
  var para = true
  for (var i=0; i<f.Training_Needs.length; i++)
    if (f.Training_Needs[ i ].checked){
      radval=f.Training_Needs[ i ].value;
	  rad_str = rad_str + radval;
	} 
	
	if(rad_str == null){
		para = false;
	}
 
  return checkEmpty(f.Name,"Please enter your name!")
  && checkEmpty(f.CompanyName,"Please enter your company name!")
  && checkEmpty(f.Email,"Please enter your email!")
  && checkEmail(f.Email)
  && prompt_radio(para)
  }

