$(document).ready(function() {
  $$.init();

  var map = new $$.Map('ymap-mini', 308, 187, false);
  map.limit = 20;
  map.disableKeyControls();
  map.disablePopups();
  map.mapType('hyb');
  map.load(1, true);
  // mini map link
  $('#miniMapOverlay').click(function() { document.location.href="/map/"; });
  // contact form
  $('#formContact input[@name=send]').click(function() {
    var f = $('#formContact')[0];
    if(f['name'].value.length &&
       f['subject'].value.length &&
       f['message'].value.length &&
       f['email'].value.match(/^[A-Za-z_0-9\-.]+@([A-Za-z_0-9\-]+\.)+[A-Za-z]+$/)) {
      var button = this;
      button.disabled = true;
      $(this.form).ajaxSubmit({
        url: "/cgi-bin/data/contact",
        type: 'POST',
        dataType: 'json',
        resetForm: true,
        success: function() {
          $('#formContact .error').hide();
          $('#formContact .thanks').show();
          button.disabled = false;
        }
      });
    } else {
      $('#formContact .thanks').hide();
      $('#formContact .error').show();
    }
  });
});

