function checkMail(email)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test( document.contactusform.email.value ))
		return false;
	else 
		return "- Sähköpostiosoite ei kelpaa.\n";

}

function checkAndSubmit()
{
	var errormsg = "";
	
	x = document.contactusform;
	
	if (x.firstname.value == "") errormsg += "- Etunimi on välttämätön.\n";
	if (x.lastname.value == "") errormsg += "- Sukunimi on välttämätön.\n";
	if (x.address1.value == "") errormsg += "- Osoite on välttämätön.\n";
	if (x.town.value == "") errormsg += "- Kaupunki on välttämätön.\n";
	if (x.postcode.value == "") errormsg += "- Postinumero on välttämätön.\n";
	//if (x.country.value == "") errormsg += "- Country is required.\n"; 
	if (x.email.value == "") errormsg += "- Sähköpostiosoite on välttämätön.\n";
	else
	{
	   if (msg = checkMail(x.email.value))
	      errormsg += msg;
	}
	if (x.day.selectedIndex == 0)  errormsg += "- Päivä on välttämätön.\n";
	if (x.month.selectedIndex == 0) errormsg += "- Kuukausi on välttämätön.\n";
	if (x.year.selectedIndex == "") errormsg += "- Vuosi on välttämätön.\n";
	if (x.message.value == "") errormsg += "- Viesti on välttämätön.\n";
	
	if( x.feedback[0].checked==false &&  x.feedback[1].checked==false &&  x.feedback[2].checked==false ) errormsg += "- Palaute on välttämätön.\n";

	var fount = false;
	for( var i=0; i<8; i++ ){
		if( x.product[i].checked==true ){
			fount = true;
			break;
		}
	}
	if( !fount ) errormsg += "- Ole hyvä ja valitse tuote.\n";
	
	if (errormsg != "")
	{
	  alert (errormsg);
	  set_focus();
	  return false;
	}
	else
	{
	  var today = new Date();
	  var currage = x.year[ x.year.selectedIndex ].value;
	  var currentyear = today.getFullYear();
	  var age = currentyear - currage;
	  if (age < 14)
	  { alert ("Sorry, but we cannot accept submissions from persons under 14.\n");
	    x.year.focus();
	    return false;
	  }/*
	  else if (age >=14 & age<=17)
	  { var conf = confirm("Leider dürfen wir Personen, die jünger sind als 18 Jahren,
	   nicht antworten, ohne dass die Erlaubnis der Eltern vorliegt. \n\n\Klicken Sie hier, wenn Sie die Erlaubnis Ihrer Eltern haben.");
	    if(!conf)
	    {
	      x.year.focus();
	      return false;
	    }
	  }*/
	}
	
	if( x.accept.checked == false ){
		alert ("You must accept the Privacy Statement before submitting.\n");
	  	return false;
	}
	
	x.submit();
	return true;
}

function set_focus()
{
  x = document.contactusform;
  
  if (x.firstname.value == "")
  {
    x.firstname.focus();
    return false;
  }
  if (x.lastname.value == "")
  {
    x.lastname.focus();
    return false;
  }
  if (x.address1.value == "")
  {
    x.address1.focus();
    return false;
  }
  if (x.town.value == "")
  {
    x.town.focus();
    return false;
  }
  if (x.postcode.value == "")
  {
    x.postcode.focus();
    return false;
  }
  if (x.country.value == "")
  {
    x.country.focus();
    return false;
  }
  if (x.email.value == "" || msg != "")
  {
    x.email.focus();
    return false;
  }
  if (x.day.selectedIndex == 0)
  {
    x.day.focus();
    return false;
  }
  if (x.month.selectedIndex == 0)
  {
    x.month.focus();
    return false;
  }
  if (x.year.selectedIndex == 0)
  {
    x.year.focus();
    return false;
  }
  if (x.message.value == "")
  {
    x.message.focus();
    return false;
  }
}