var thisLang = "es";
var pI = "12188";
var todaysDate = "01/05/2025";
var calendarTitle = "Por favor selecciona un rango de fechas";
var bookedTitle = "No disponible";
var availableTitle = "Disponible";
var unavailableUIAMDates = ["1-5-2025","5-6-2025","26-7-2025","15-9-2025"];
var unavailableUIPMDates = ["4-5-2025","12-6-2025","24-8-2025","15-11-2025"];
var unavailableUIDates = ["1-5-2025","2-5-2025","3-5-2025","4-5-2025","5-6-2025","6-6-2025","7-6-2025","8-6-2025","9-6-2025","10-6-2025","11-6-2025","12-6-2025","26-7-2025","27-7-2025","28-7-2025","29-7-2025","30-7-2025","31-7-2025","1-8-2025","2-8-2025","3-8-2025","4-8-2025","5-8-2025","6-8-2025","7-8-2025","8-8-2025","9-8-2025","10-8-2025","11-8-2025","12-8-2025","13-8-2025","14-8-2025","15-8-2025","16-8-2025","17-8-2025","18-8-2025","19-8-2025","20-8-2025","21-8-2025","22-8-2025","23-8-2025","24-8-2025","15-9-2025","16-9-2025","17-9-2025","18-9-2025","19-9-2025","20-9-2025","21-9-2025","22-9-2025","23-9-2025","24-9-2025","25-9-2025","26-9-2025","27-9-2025","28-9-2025","29-9-2025","30-9-2025","1-10-2025","2-10-2025","3-10-2025","4-10-2025","5-10-2025","6-10-2025","7-10-2025","8-10-2025","9-10-2025","10-10-2025","11-10-2025","12-10-2025","13-10-2025","14-10-2025","15-10-2025","16-10-2025","17-10-2025","18-10-2025","19-10-2025","20-10-2025","21-10-2025","22-10-2025","23-10-2025","24-10-2025","25-10-2025","26-10-2025","27-10-2025","28-10-2025","29-10-2025","30-10-2025","31-10-2025","1-11-2025","2-11-2025","3-11-2025","4-11-2025","5-11-2025","6-11-2025","7-11-2025","8-11-2025","9-11-2025","10-11-2025","11-11-2025","12-11-2025","13-11-2025","14-11-2025","15-11-2025"];
var unavailableAMDates = ["2025-05-01","2025-06-05","2025-07-26","2025-09-15"];
var unavailablePMDates = ["2025-05-04","2025-06-12","2025-08-24","2025-11-15"];
var unavailableDates = [["01/05/2025","02/05/2025","03/05/2025","04/05/2025"],["05/06/2025","06/06/2025","07/06/2025","08/06/2025","09/06/2025","10/06/2025","11/06/2025","12/06/2025"],["26/07/2025","27/07/2025","28/07/2025","29/07/2025","30/07/2025","31/07/2025","01/08/2025","02/08/2025","03/08/2025","04/08/2025","05/08/2025","06/08/2025","07/08/2025","08/08/2025","09/08/2025","10/08/2025","11/08/2025","12/08/2025","13/08/2025","14/08/2025","15/08/2025","16/08/2025","17/08/2025","18/08/2025","19/08/2025","20/08/2025","21/08/2025","22/08/2025","23/08/2025","24/08/2025"],["15/09/2025","16/09/2025","17/09/2025","18/09/2025","19/09/2025","20/09/2025","21/09/2025","22/09/2025","23/09/2025","24/09/2025","25/09/2025","26/09/2025","27/09/2025","28/09/2025","29/09/2025","30/09/2025","01/10/2025","02/10/2025","03/10/2025","04/10/2025","05/10/2025","06/10/2025","07/10/2025","08/10/2025","09/10/2025","10/10/2025","11/10/2025","12/10/2025","13/10/2025","14/10/2025","15/10/2025","16/10/2025","17/10/2025","18/10/2025","19/10/2025","20/10/2025","21/10/2025","22/10/2025","23/10/2025","24/10/2025","25/10/2025","26/10/2025","27/10/2025","28/10/2025","29/10/2025","30/10/2025","31/10/2025","01/11/2025","02/11/2025","03/11/2025","04/11/2025","05/11/2025","06/11/2025","07/11/2025","08/11/2025","09/11/2025","10/11/2025","11/11/2025","12/11/2025","13/11/2025","14/11/2025","15/11/2025"]];
var reserveURL = "https://www.coastalpropertiesmojacar.com/es/reservacion.html";
$(document).ready(function() {
var cHeight = $("#mainPhotos").height();
$("#mainPhotos li a").height(cHeight + "px");
$('[data-fancybox="gallery"]').fancybox({
loop: true,
transitionEffect: "slide"
});
$('#mainPhotos').slick({
centerMode: true,
centerPadding:"0",
slidesToShow: 1,
infinite: true,
arrows: false,
adaptiveHeight:true,
speed: 600
});
$('#thumbsCarousel').slick({
slidesToShow: 1,
slidesToScroll: 1,
dots: false,
centerMode: true,
focusOnSelect: true,
arrows: false,
infinite: false,
asNavFor: '#mainPhotos'
});
$(document).on("click", "#previousPhoto", function () {
$('#mainPhotos').slick('slickPrev');
});
$(document).on("click", "#nextPhoto", function () {
$('#mainPhotos').slick('slickNext');
});
$("#mainPhotos").on("afterChange", function(event, slick, currentSlide) {
var slideCount = parseInt(currentSlide) + 1;
$("#slideCount span").html(slideCount);
var slideNo = parseInt(currentSlide);
$("#thumbsCarousel").slick('slickGoTo', slideNo);
});
$(document).on("click", "#propertyFeatureLinks a", function () {
var scrollDownTo = $(this).data("lt");
if ($.trim(scrollDownTo) != "") {
$("html,body").animate({
scrollTop:$("#" + scrollDownTo).offset().top - 60
},1000);
}
});
var sD = $("#propertyRentalDatesH").val();
$("#propertyRentalDates").dateRangePicker({
language:thisLang,
separator: " - ",
format: "DD/MM/YYYY",
startOfWeek: "monday",
startDate: todaysDate,
customArrowPrevSymbol: '',
customArrowNextSymbol: '',
setValue: function(s,s1,s2) {
$("#propertyRentalDates").val(s1 + ' - ' + s2);
$("#propertyRentalDatesH").val(s1 + '|' + s2);
var nD = s1 + '|' + s2;
if (sD == nD) {
} else {
getBookingPrices(pI);
sD = s1 + '|' + s2;
}
},
minDays: 1,
autoClose: true,
beforeShowDay: function(t) {
var thisDate = moment(t).format("DD/MM/YYYY");
var isValid = true;
var _class = "";
var _tooltip = "";
for (var ii = 0; ii < unavailableDates.length; ii++) {
var thisBlock = unavailableDates[ii];
for (var iii = 0; iii < thisBlock.length; iii++) {
if (thisDate == thisBlock[iii]) {
if (_class == "bookedDateEnd") {
_class = "bookedDate";
_tooltip = bookedTitle;
isValid = false;
} else if (iii == 0) {
_class = "bookedDateStart";
} else if (iii == thisBlock.length - 1) {
_class = "bookedDateEnd";
} else {
_class = "bookedDate";
_tooltip = bookedTitle;
isValid = false;
}
}
}
}
return [isValid,_class,_tooltip];
}
});
$(document).on("change", "#noGuests", function() {
getBookingPrices(pI);
});
$(document).on("click", ".showBookingBtn", function() {
if ($("#propertyBookingColumn").hasClass("showBooking")) {
$("body").removeClass("fixed");
$("#propertyBookingColumn").removeClass("showBooking");
} else {
$("body").addClass("fixed");
$("#propertyBookingColumn").addClass("showBooking");
}
});
$(document).on("click", "#closeBookingForm", function() {
var screenHeight = $(window).height();
var titleHeight = $("#propertyBookingTitle").height() + 20;
var closedOffset = screenHeight - titleHeight;
$("body").removeClass("fixed");
$("#propertyBookingColumn").removeClass("showBooking");
});
$(document).on("click", "#pbSendEnq, #pSendIEnq", function() {
$("body").addClass("fixed");
$("#enquiryBGContainer").addClass("unfold");
$("nav").removeClass("is-active");
$("#showMenu").removeClass("is-active");
});
$("#enquiryDates").dateRangePicker({
language:thisLang,
separator: " - ",
format: "DD/MM/YYYY",
startOfWeek: "monday",
startDate: todaysDate,
customArrowPrevSymbol: '',
customArrowNextSymbol: '',
minDays: 1,
setValue: function(s,s1,s2) {
$("#enquiryDates").val(s1 + ' - ' + s2);
$("#enquiryDatesH").val(s1 + '|' + s2);
}
});
/*
$(document).on("click", "#propertyBookingButton", function() {
var sVID = $("#sVID").val();
$("body").addClass("fixed");
$.ajax({
type:"GET",
url: "/property-booking-darcy.php?lang=" + thisLang,
data:"sVID=" + sVID,
cache:false,
success:function(popContent) {
$("#bookingIFContainer").html(popContent);
$("#bookingBGContainer").addClass("unfold");
$("nav").removeClass("is-active");
$("#showMenu").removeClass("is-active");
}
});
});
*/
$(document).on("click", "#sendContact", function() {
$("#sendContact, #eFormError").slideUp("fast");
$("#eFormEError").css("display", "none");
$("#enquiryName").parents(".formInput").removeClass("formError");
$("#enquiryEmail").parents(".formInput").removeClass("formError");
$("#enquiryMessage").parents(".formInput").removeClass("formError");
var eN = $("#enquiryName").val();
var eE = $("#enquiryEmail").val();
var eT = $("#enquiryTel").val();
var eD = $("#enquiryDatesH").val();
var eM = $("#enquiryMessage").val();
var dCon;
if ($("#dataConsent").is(":checked")) {
dCon = "&consent=true";
} else {
dCon = "";
}
var formValid = true;
if ($.trim(eN) == "") {
formValid = false;
$("#enquiryName").parents(".formInput").addClass("formError");
}
if ($.trim(eE) == "") {
formValid = false;
$("#enquiryEmail").parents(".formInput").addClass("formError");
}
if ($.trim(eM) == "") {
formValid = false;
$("#enquiryMessage").parents(".formInput").addClass("formError");
}
if (formValid == true) {
$("#contactWaiting").fadeIn('fast');
var dataVars = "pT=holiday&pI=" + pI + "&eN=" + encodeURIComponent(eN) + "&eE=" + encodeURIComponent(eE) + "&eT=" + encodeURIComponent(eT) + "&eD=" + encodeURIComponent(eD) + "&eM=" + encodeURIComponent(eM) + dCon;
$.ajax({
url:"/property-enquiry.php?lang=" + thisLang,
data: dataVars,
type: "POST",
dataType:"JSON",
cache: false,
success: function(data) {
var responseType = data.responseType;
if (responseType == 'valid') {
$("#enquiryResponse").html(data.contactResponse);
$("#enquiryFormInput").slideUp('slow', function(){
$("#contactWaiting").fadeOut('fast');
$("#enquiryResponse").slideDown("slow");
});
} else {
$("#eFormEOError").html(data.contactResponse);
$("#eFormEError").css("display", "none");
$("#eFormEOError").css("display", "block");
$("#sendContact").delay(600).fadeIn('slow', function(){
$("#contactWaiting").fadeOut('fast');
$("#eFormError").slideDown("slow");
});
}
}
});
} else {
$("#eFormEOError").css("display", "none");
$("#eFormEError").css("display", "block");
$("#sendContact, #eFormError").slideDown("slow");
}
return false;
});
$(document).on("click", "#enquiryBG", function(e) {
var thisID = $(e.target).attr('id');
if (thisID == "enquiryBG") {
$("#enquiryBGContainer").addClass("out");
setTimeout(function() {
$("#enquiryBGContainer").removeClass("unfold").removeClass("out");
$("body").removeClass("fixed");
}, 1200);
}
});
$(document).on("click", "#closeEnquiry", function() {
$("#enquiryBGContainer").addClass("out");
setTimeout(function() {
$("#enquiryBGContainer").removeClass("unfold").removeClass("out");
$("body").removeClass("fixed");
}, 1200);
});
$(document).on("click", "#showMoreFeatures", function() {
var isHidden = $("#moreFeatures").css("display");
if (isHidden == "none") {
$("#moreFeatures").slideDown("slow", function() {
$("#showMoreFeatures i").removeClass("fa-caret-down").addClass("fa-caret-up");
});
} else {
$("#moreFeatures").slideUp("slow", function() {
$("#showMoreFeatures i").removeClass("fa-caret-up").addClass("fa-caret-down");
});
}
});
$(document).on("click", "#bookingBG", function(e) {
var thisID = $(e.target).attr('id');
if (thisID == "bookingBG") {
$("#bookingBGContainer").addClass("out");
setTimeout(function() {
$("#bookingBGContainer").removeClass("unfold").removeClass("out");
$("body").removeClass("fixed");
}, 1200);
}
});
$(document).on("click", "#closeBooking", function() {
$("#bookingBGContainer").addClass("out");
setTimeout(function() {
$("#bookingBGContainer").removeClass("unfold").removeClass("out");
$("body").removeClass("fixed");
}, 1200);
});
$(document).on("click", "#termsBtn", function() {
if ($(this).hasClass("termsAccepted")) {
$(this).removeClass("termsAccepted");
$("#tca").val("0");
} else {
$(this).addClass("termsAccepted");
$("#tca").val("1");
}
});
$(document).on("click", "#reservationSubmit", function() {
var sVID = $("#sVID").val();
var bN = $("#bookingName").val();
var bT = $("#bookingTel").val();
var bE = $("#bookingEmail").val();
var uC = $("#userCode").val();
var tAC = $("#tca").val();
$("#rFormError").slideUp("fast");
$("#bookingName").parents(".formInput").removeClass("formError");
$("#bookingEmail").parents(".formInput").removeClass("formError");
$("#termsBtn").parents(".formInputW").removeClass("formError");
var formValid = true;
if ($.trim(bN) == "") {
formValid = false;
$("#bookingName").parents(".formInput").addClass("formError");
}
if ($.trim(bE) == "") {
formValid = false;
$("#bookingEmail").parents(".formInput").addClass("formError");
}
if (tAC == "0") {
formValid = false;
$("#termsBtn").parents(".formInputW").addClass("formError");
}
if (formValid == true) {
$("#reservationSubmit").slideUp("fast");
$("#reservationWaiting").fadeIn('fast');
var dataVars = "rC=true&sVID=" + sVID + "&bN=" + encodeURIComponent(bN) + "&bT=" + encodeURIComponent(bT) + "&bE=" + encodeURIComponent(bE) + "&uC=" + encodeURIComponent(uC);
$.ajax({
url:"/property-booking-darcy.php?lang=" + thisLang,
data: dataVars,
type: "POST",
dataType:"JSON",
cache: false,
success: function(data) {
var responseType = data.responseType;
if (responseType == 'valid') {
} else {
$("#rFormError").html(data.contactResponse);
$("#reservationSubmit").stop();
$("#reservationSubmit").delay(600).slideDown('slow', function(){
$("#reservationWaiting").fadeOut('fast');
$("#rFormError").slideDown("slow");
});
}
}
});
}
});
getBookingPrices(pI);
var screenWidth = $(window).width();
if ($("#availabilityCalendar").length) {
setupCalendar(screenWidth);
}
var doIt;
$(window).on("resize", function() {
clearTimeout(doIt);
doIt = setTimeout(resizedW, 100);
});
function resizedW() {
var screenDWidth = $(window).width();
if (screenDWidth != screenWidth) {
$("#availabilityCalendar").datepicker("destroy");
setupCalendar(screenDWidth);
screenWidth = $(window).width();
}
}
function setupCalendar(screenWidth) {
var divW = $("#availabilityCalendar").width();
var noMonthsS = Math.floor(divW / 270);
var noMonths;
var noSteps;
if (screenWidth < 1000) {
noMonths = [3,noMonthsS];
noSteps = 3 * noMonthsS;
} else if (screenWidth < 1400) {
noMonths = [4,noMonthsS];
noSteps = 4 * noMonthsS;
} else {
noMonths = [3,4];
noSteps = 12;
}
$('#availabilityCalendar').datepicker({
numberOfMonths:noMonths,
minDate: 0,
firstDay:1,
stepMonths: noSteps,
beforeShowDay:bookedDates
});
}
function bookedDates(date) {
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
if ( ($.inArray(dmy, unavailableUIDates) == -1)) {
return [true, "", "Available"];
} else {
if (($.inArray(dmy, unavailableUIAMDates) != -1) && ($.inArray(dmy, unavailableUIPMDates) != -1)) {
return [false,"datePickerChangeover", bookedTitle];
} else if ($.inArray(dmy, unavailableUIAMDates) != -1) {
return [true,"datePickerAMAvailable", availableTitle];
} else if ($.inArray(dmy, unavailableUIPMDates) != -1) {
return [true,"datePickerPMAvailable", availableTitle];
} else {
return [false,"datePickerLT", bookedTitle];
}
}
}
function getBookingPrices(propID) {
$("#propertyBookingButton").slideUp("fast", function() {
$("#propertyBookingResponse").slideUp("fast");
var setDates = $("#propertyRentalDatesH").val();
var noGuests =$("#noGuests").val();
if ( ($.trim(setDates) != "") && ($.trim(noGuests) != "") ) {
$.ajax({
url:"/property-booking-darcy.php?lang=" + thisLang,
data: "gV=true&pI=" + propID + "&bD=" + setDates + "&nG=" + noGuests,
type: "POST",
dataType: "JSON",
cache: false,
success: function(sessionData) {
var sessionVar = sessionData.sessionVar;
var dLink = sessionData.dLink;
$("#sVID").val(sessionVar);
if ($("#propertyBookingButton").hasClass("propertyBookingButtonDSB")) {
} else {
$("#propertyBookingButton").attr("href", dLink);
}
}
});
$.ajax({
url:"/property-booking-darcy.php?lang=" + thisLang,
data: "bC=true&pI=" + propID + "&bD=" + setDates + "&nG=" + noGuests,
type: "POST",
cache: false,
success: function(bookingCost) {
$("#propertyBookingResponse").html(bookingCost);
$("#propertyBookingResponse").slideUp();
$("#propertyBookingResponse").slideDown("slow", function() {
if ($("#bookingPriceWarning").length) {
} else {
if ($("#propertyBookingButton").hasClass("propertyBookingButtonDSB")) {
} else {
$("#propertyBookingButton").slideDown("slow");
}
}
});
}
});
}
});
}
});