$(function() {
  // initialize scrollable
  $("div.scrollable").scrollable({
    size: 1,
    items: '#slides',
    hoverClass: 'hover'
  });

  $("body.contact form").submit(function() {
    $('.spinner').show(200);
    $('#ajax_notice').hide(200).html('');
    var str = $(this).serialize();
    $.post(
      "/contact/submit.php",
      str,
      function(data, status) {
        console.log(status,": ", data);
        $('.spinner').hide(200);
        $("#ajax_notice").ajaxComplete(function(event, request, settings){
          if(data == 'OK') {
            // Message Sent? Show the 'Thank You' message and hide the form
            result = '<div class="success"><span>Thanks! Your message has been sent</span></div>';
          $("form")[0].reset();
        } else {
          result = '<div class="error"><span>Oops!</span> Please correct the following:</div>' + data;
        }
        $(this).hide().html('').html(result)
         .css('backgroundColor', '#ffffe0')
         .show(600, function(){
           $(this).animate({ backgroundColor: "#fff" }, 1800);
         });
       });
     }
  );
  return false;
 });

 // Toggle fading of the service cards
 $('.flippable img').hover(function() {
   $(this).fadeTo(250, 0);
 }, function() {
   $(this).fadeTo(250, 1.0);
 });
});
 
