$( document ).ready(function() {
  $("#form").submit(function(e) {
    $("#form-content").css({"display": "none"})
    $(".loader").css({"display": "block"})
    e.preventDefault(); // avoid to execute the actual submit of the form.
    var form = $(this);
    var url = form.attr('action');
    
    $.ajax({
      type: "POST",
      url: url,
      data: form.serialize(), // serializes the form's elements.
      success: function(data)
      {
        $(".loader").css({"display": "none"})
        $("#success").css({"display": "block"})
        console.log(data);
      },
      error: function(data){
        $(".loader").css({"display": "none"})
        $("#error").css({"display": "block"})
        console.log(data);
      }
    });
  });
  
  $('.btn-volver').click(function(){
    console.log("xd");
    $("#form-content").css({"display": "block"});
    $("#error").css({"display": "none"});
    $("#success").css({"display": "none"});
  });
  Modernizr.on('webp', function (result) {
    // `result == Modernizr.webp`
    console.log(result);  // either `true` or `false`
    if (result) {
      console.log("webp support");
    }
    else {
     console.log("webp no  support");
    }
  });
  var headerSize = function() {
    $('.header-slider').width()
  }
  $(window).resize(function(){
    headerSize()
  })
});

// Galería de equipos - cambiar imagen principal
function changeMainImage(mainImgId, thumb) {
  var mainImg = document.getElementById(mainImgId);
  mainImg.style.opacity = '0';
  setTimeout(function() {
    mainImg.src = thumb.src;
    mainImg.style.opacity = '1';
  }, 200);
  var thumbs = thumb.parentElement.querySelectorAll('.equipo-thumb');
  thumbs.forEach(function(t) { t.classList.remove('active'); });
  thumb.classList.add('active');
}

//MAPA
/*
var map;
function initialize() {
  // Create a simple map.
  map = new google.maps.Map(document.getElementById('map'), {
    zoom: 16,
    center: {
      lat: 53.668398,
      lng: -2.167713
    },
    styles:[ {
        "elementType": "geometry",
        "stylers": [ {
            "color": "#19375d"
          },
          {
            "lightness": -5
          }
        ]
      },
      {
        "elementType": "geometry.fill",
        "stylers": [
          {
            "color": "#e53d2f"
          },
          {
            "weight": 1
          }
        ]
      },
      {
        "elementType": "labels.icon",
        "stylers": [
          {
            "color": "#afbcad"
          }
        ]
      },
      {
        "elementType": "labels.text",
        "stylers": [
          {
            "color": "#fcfffe"
          },
          {
            "weight": 2
          }
        ]
      },
      {
        "elementType": "labels.text.fill",
        "stylers": [
          {
            "color": "#fafafa"
          }
        ]
      },
      {
        "elementType": "labels.text.stroke",
        "stylers": [
          {
            "color": "#4f72ca"
          },
          {
            "weight": 2
          }
        ]
      },
      {
        "featureType": "administrative",
        "elementType": "labels.text",
        "stylers": [
          {
            "weight": 1
          }
        ]
      },
      {
        "featureType": "administrative",
        "elementType": "labels.text.stroke",
        "stylers": [
          {
            "color": "#19385e"
          },
          {
            "weight": 3
          }
        ]
      },
      {
        "featureType": "administrative.country",
        "elementType": "geometry.stroke",
        "stylers": [
          {
            "color": "#4b6878"
          }
        ]
      },
      {
        "featureType": "administrative.land_parcel",
        "elementType": "labels.text",
        "stylers": [
          {
            "color": "#fafff7"
          }
        ]
      },
      {
        "featureType": "administrative.land_parcel",
        "elementType": "labels.text.fill",
        "stylers": [
          {
            "color": "#fafff7"
          }
        ]
      },
      {
        "featureType": "administrative.locality",
        "elementType": "labels.text.fill",
        "stylers": [
          {
            "color": "#fcfff3"
          }
        ]
      },
      {
        "featureType": "administrative.province",
        "elementType": "geometry.stroke",
        "stylers": [
          {
            "color": "#4b6878"
          }
        ]
      },
      {
        "featureType": "landscape.man_made",
        "elementType": "geometry.stroke",
        "stylers": [
          {
            "color": "#334e87"
          }
        ]
      },
      {
        "featureType": "landscape.natural",
        "elementType": "geometry",
        "stylers": [
          {
            "color": "#023e58"
          }
        ]
      },
      {
        "featureType": "poi",
        "elementType": "geometry",
        "stylers": [
          {
            "color": "#283d6a"
          }
        ]
      },
      {
        "featureType": "poi",
        "elementType": "labels.text.fill",
        "stylers": [
          {
            "color": "#6f9ba5"
          }
        ]
      },
      {
        "featureType": "poi",
        "elementType": "labels.text.stroke",
        "stylers": [
          {
            "color": "#1d2c4d"
          }
        ]
      },
      {
        "featureType": "poi.park",
        "elementType": "geometry.fill",
        "stylers": [
          {
            "color": "#023e58"
          }
        ]
      },
      {
        "featureType": "poi.park",
        "elementType": "labels.text.fill",
        "stylers": [
          {
            "color": "#3C7680"
          }
        ]
      },
      {
        "featureType": "road",
        "elementType": "geometry",
        "stylers": [
          {
            "color": "#304a7d"
          }
        ]
      },
      {
        "featureType": "road",
        "elementType": "labels.text.fill",
        "stylers": [
          {
            "color": "#98a5be"
          }
        ]
      },
      {
        "featureType": "road",
        "elementType": "labels.text.stroke",
        "stylers": [
          {
            "color": "#1d2c4d"
          }
        ]
      },
      {
        "featureType": "road.highway",
        "elementType": "geometry",
        "stylers": [
          {
            "color": "#2c6675"
          }
        ]
      },
      {
        "featureType": "road.highway",
        "elementType": "geometry.stroke",
        "stylers": [
          {
            "color": "#122c32"
          }
        ]
      },
      {
        "featureType": "road.highway",
        "elementType": "labels.text.fill",
        "stylers": [
          {
            "color": "#b0d5ce"
          }
        ]
      },
      {
        "featureType": "road.highway",
        "elementType": "labels.text.stroke",
        "stylers": [
          {
            "color": "#023e58"
          }
        ]
      },
      {
        "featureType": "transit",
        "elementType": "labels.text.fill",
        "stylers": [
          {
            "color": "#98a5be"
          }
        ]
      },
      {
        "featureType": "transit",
        "elementType": "labels.text.stroke",
        "stylers": [
          {
            "color": "#1d2c4d"
          }
        ]
      },
      {
        "featureType": "transit.line",
        "elementType": "geometry.fill",
        "stylers": [
          {
            "color": "#283d6a"
          }
        ]
      },
      {
        "featureType": "transit.station",
        "elementType": "geometry",
        "stylers": [
          {
            "color": "#3a4762"
          }
        ]
      },
      {
        "featureType": "water",
        "elementType": "geometry",
        "stylers": [
          {
            "color": "#0e1626"
          }
        ]
      },
      {
        "featureType": "water",
        "elementType": "geometry.fill",
        "stylers": [
          {
            "color": "#19385e"
          }
        ]
      },
      {
        "featureType": "water",
        "elementType": "labels.text.fill",
        "stylers": [
          {
            "color": "#4e6d70"
          } ]
      }]
  });
  // Load a GeoJSON from the same server as our demo.
  //map.data.loadGeoJson('https://pixelsandcode.local:5757/map.json');
}
google.maps.event.addDomListener(window, 'load', initialize);
*/