function checkForm()
{
 var name      = document.getElementById('contact_name');
 var email     = document.getElementById('contact_email');
 var comments  = document.getElementById('contact_comments');
 var result    = document.getElementById('result');
 var submitForm = true;
 
 result.innerHTML = '';
 result.className = '';
 if(name.value=='' || email.value=='' ||comments.value=='')
 {
    result.innerHTML = 'Fill form correctly first';
    result.className = 'error';
    submitForm = false;
 }
 if(submitForm)
 {
    sendEmail(name.value,email.value,comments.value);
 }
}
function sendEmail(name,email,comments)
{
//Send email via AJAX
ajax.setParameter('name',name);
ajax.setParameter('email',email);
ajax.setParameter('comments',comments);
ajax.setProcessMethod('sendEmail');
ajax.makeCustomRequest('./scripts/php/sendemail.php');
}
ajax.methods['sendEmail'] = function()
{
  var response = ajax.responseText;
  if(response == 'send')
  {
     var name      = document.getElementById('contact_name');
     var email     = document.getElementById('contact_email');
     var comments  = document.getElementById('contact_comments');
     var result    = document.getElementById('result');
     
     name.value = email.value = comments.value = '';
     result.className = '';
     result.innerHTML = 'Email has been sent correctly';
  }
  else
  {
     var result    = document.getElementById('result');
     
     result.className = 'error';
     result.innerHTML = 'Email has NOT been sent';
  }
}