/**
 * @author gary
 */
$(document).ready(function()
{
  $("#ajax-contact-form").submit(function()
  {
    //bindWaitCursor("sendContactEmail", "right", "middle", 5, 0);
    $("#note").slideUp(postContactForm);
  });
  
  function postContactForm()
  {
    // 'this' refers to the current submitted form
    var str = $("#ajax-contact-form").serialize();
    
    $.ajax(
    {
      type: "POST",
      url: "inc/jcontact/contact.php",
      data: str,
      success: function(msg)
      {
        $("#note").ajaxComplete(function(event, request, settings)
        {
          if (msg == 'OK') 
          {
            result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
            //$("#fields").hide();
            
            $(':input', '#ajax-contact-form').not(':button, :submit, :reset, :hidden, #name, #email').val('').removeAttr('checked').removeAttr('selected');
            
          }
          else 
          {
            result = msg;
          }
          
          $("#note").html(result);
          
          setTimeout(function()
          {
            $("#note").slideDown()
          }, 100);
          ;
        });
      }
    });
    
    //unbindWaitCursor();
    
    return false;
  }
});
