$(function() {
  $('a[rel="external"]').each(function() {
    $(this).attr('target', '_blank')
  });
});
// Load google map
$(function() {
  if ($('#googlemap').get().length > 0) {
    var mapOptions = {
      zoom: 16,
      center: new google.maps.LatLng(54.3982, -5.649),
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      navigationControl: true,
      navigationControlOptions: {
        style: google.maps.NavigationControlStyle.ZOOM_PAN
      },
      mapTypeControl: false
    };
    var map = new google.maps.Map($('#googlemap').get(0), mapOptions);
    var logoImage = new google.maps.MarkerImage('/images/map-logo.png',
      new google.maps.Size(46, 35), // size
      new google.maps.Point(0, 0),  // origin
      new google.maps.Point(13, 35)// anchor
    );
    var logo = new google.maps.Marker({
      position: new google.maps.LatLng(54.39716242047816, -5.64647912979126),
      map: map,
      icon: logoImage,
      clickable: false,
      title: 'Quaybliss Apartment'
    });
  }
});
// fade out instructions and error messages
$(function() {
  $('#instructions').fadeOut(8000)
  if (document.getElementById('errors') && $('#errors').hasClass('fade')) {
    $('#errors').fadeOut(8000)
  }
});
// hide form labels on focus
$(function() {
  $('input[type=text], textarea').focus(function() {
    if ($(this).hasClass('inline-label')) {
      if (typeof $(this).attr('rel') == 'undefined') {
        $(this).attr('rel', $(this).attr('value'))
      }
      if ($(this).attr('value') == $(this).attr('rel')) {
        $(this).attr('value', '')
      }
    }
  })
  $('input[type=text], textarea').blur(function() {
    if ($(this).hasClass('inline-label')) {
      if ($(this).attr('value') == '') {
        $(this).attr('value', $(this).attr('rel'))
      }
    }
  })
});
// quaybliss bespoke stuff
$(function() {
  if (typeof jQuery.fn.pngFix != 'undefined') {
    $(document).pngFix()
  }
  // id test: if ($('#id').get().length > 0) etc.
  if ($('a').hasClass('fancybox')) {
    $('a.fancybox').fancybox({
      'zoomSpeedIn': 600,
      'zoomSpeedOut': 500,
      'overlayShow': true,
      'easingIn': 'easeOutBack',
      'easingOut': 'easeInBack',
      'overlayOpacity': 0.5
    });
  }
	if ($('#easyslider').get().length > 0) {
    $("#easyslider").easySlider({
  		auto: true,
  		continuous: true,
  		pause: 3000,
  		speed: 1200,
  		controlsShow: false
  	});
  }
  $('#date_from').datepicker({dateFormat: 'dd/mm/yy', minDate: '+1D', maxDate: '+1Y +6M'});
  $('#date_to').datepicker({dateFormat: 'dd/mm/yy', minDate: '+2D', maxDate: '+1Y +6M'});
});