$(function() {
  $('#main_photo').cycle({slideExpr: 'img',timeout: 5000});
  $("a[rel^='prettyPhoto']").prettyPhoto({social_tools:false,autoplay_slideshow: false,autoplay: false,deeplinking: false});
  
  $("input[id$='dtCheckIn']").datepicker({ minDate: '0', numberOfMonths: 1, showOn: "button", dateFormat: 'dd/mm/yy', buttonImage: '/images/datePickerPopup.gif',altField: "#ci",altFormat: "yy-mm-dd",buttonText:"" });
  $("input[id$='dtCheckOut']").datepicker({ minDate: '0', numberOfMonths: 1, showOn: "button", dateFormat: 'dd/mm/yy', buttonImage: '/images/datePickerPopup.gif',altField: "#co",altFormat: "yy-mm-dd",buttonText:"" });
    
  var d = new Date();
  var checkInDate = $("input[id$='dtCheckIn']").datepicker('getDate');
  if (checkInDate < d) {
      checkInDate = d;
      $("input[id$='dtCheckIn']").datepicker('setDate', d);
  }
  var checkOutDate = $("input[id$='dtCheckOut']").datepicker('getDate');
  var nextDayDate = $("input[id$='dtCheckIn']").datepicker('getDate', '+1d');

  if (checkOutDate < nextDayDate) {
      nextDayDate.setDate(nextDayDate.getDate() + 1);
  } else {
      nextDayDate.setDate(checkOutDate.getDate());
  }
  $("input[id$='dtCheckOut']").datepicker('setDate', nextDayDate);
  $("input[id$='dtCheckOut']").datepicker('option', 'minDate', nextDayDate);

  //set the checkout date to be one day after of the checkin date
  $("input[id$='dtCheckIn']").change(function () {
      var nextDayDate = $("input[id$='dtCheckIn']").datepicker('getDate', '+1d');
      nextDayDate.setDate(nextDayDate.getDate() + 1);
      $("input[id$='dtCheckOut']").datepicker('setDate', nextDayDate);
      $("input[id$='dtCheckOut']").datepicker('option', 'minDate', nextDayDate);
  });

  $(".hide").show();
});

var coordsmap;

function initialize_map() {
  var mapOptions = {
    zoom: 11,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    center: mapmark
  };

  coordsmap = new google.maps.Map(document.getElementById("mymap"),mapOptions);
        
  marker = new google.maps.Marker({
    map:coordsmap,
    draggable:false,
    position: mapmark
  });
}


function init_map() {
  try {initialize_map()}catch(e){}  
}
