$(document).ready(function() {

  //$("#findDestForm").keyup(function(){
  $("#findDest").click(function(){
    //$("#searchbox").keyup(function(){

    $.get("findDest.php",{
      countryId: $("#countryId").val(),
      areaId: $("#areaId").val(),
      skiAreaSize: $("#skiAreaSize").val(),
      complexTypeId: $("#complexTypeId").val(),
      capacity: $("#capacity").val(),
      dateFromTo: $("#dateFromTo").val(),
      villageTypeId: $("#villageTypeId").val(),
      complexAttributeId: $("#complexAttributeId").val(),
      action: "find"

    }, function(data){
      $("#resultsContainer").html(data);
      $("#resultsContainer").show("blind");

      $("#nbrOfResults").html(data + " Results Found");
    });    
  });

  /*
  $("#countryId").click(function(){
    $.get("findDest.php",{
      countryId: $("#countryId").val(),
      action: "nbrOfComplexInCountry"
    }, function(data){
      $("#nbrOfComplexInCountry").html("("+data+")");
    });

  });
*/
  
  //$(":input").keyup(function(){
  $("#searchbox").click(function(event){
    if(event.keyCode == "13") {
      getResults();
    }
  });

  //$(":input").keyup(function(){
  $("#submitbutton").click(function(){

    //var firstname = $("#firstname").val();
    //$("#nbrOfResults").html(firstname);

    getResults();
  });

  function getResults(){
    $.get("search3.php",{
      firstname: $("#firstname").val(),
      lastname: $("#lastname").val(),
      email: $("#email").val(),
      type: "results"
    }, function(data){
      $("#resultsContainer").html(data);
      $("#resultsContainer").show("blind");
    });
  }
});
