
function AjaxAddReview1(aLang)
  {
    //aRating, aCustomer, aEmail, aReview, 
  var xmlHttp;

  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }

    var url = "aeroforce.php?action=add_review";
    var params = "rating="+aRating+"&customers_name="+aCustomer+"&customers_email="+aEmail+"&reviews_text="+aReview+"&lang="+aLang+"";
    //http.open("POST", url, true);
    xmlHttp.open("POST", url, true);
    //Send the proper header information along with the request
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");

    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
            alert('ajax ready'); 

        }
      }


    
    xmlHttp.send(params);
    
  }


function GetRating(){
    if($('rating-1').checked){
        alert('checked 1');
        return 1;
    }
    else if($('rating-2').checked){
        return 2;
    }
    
    else if($('rating-3').checked){
        return 3;
    }
    else if($('rating-4').checked){
        return 4;
    }
    else if($('rating-5').checked){
        return 5;
    }
    else
        return 0;
}
function AjaxAddReview(aLang){
//aRating, aCustomer, aEmail, aReview, 
   var aRating = GetRating();//$('rating').value;
   var aCustomer = $('customers_name').value;
   var aEmail = $('customers_email').value;
   var aReview = $('reviews-text').value;
   
   //alert(aRating+" "+aCustomer+" "+aEmail+" "+aReview);
    if(check_form_review()){
        var a = new Ajax.Request("aeroforce.php?action=add_review",{
                                      method: 'post',
                                      parameters: {languages_id: ""+aLang+"", rating: ""+aRating+"", customers_name: ""+aCustomer+"", customers_email: ""+aEmail+"", reviews_text: ""+aReview+""},
                                      onSuccess: function(transport){
                                          $('aeroforce_review_form').style.display='none';
                                          $('aeroforce_send_confirmation_text').style.display='block';
                                      }
                                  }
                                )
        /*
        if(a.transport.responseText=='ok'){
            return true;
        }
        else{
            $('CheckEmail').innerHTML=a.transport.responseText;
            return false;
        }*/
    } 
    //return false;
}


function check_form_review()
{

    var aRating = GetRating()
    if(aRating==0){
	      alert( "Uw Waardering" );
        //$('customers_email').focus();
        return false;
	  }
	  
	  var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	  if(!$('customers_email').value.match(emailExp)){
	      alert( "Uw email address" );
        $('customers_email').focus();
        return false;
	  }

    if($('customers_name').value == "" ){
	      alert( "Uw Naam" );
        $('customers_name').focus();
        return false;
	  }
	  
	  if($('reviews-text').value == "" ){
	      alert( "Uw Recensie" );
        $('reviews-text').focus();
        return false;
	  }

return true;
}

