$(document).ready(function() {
$(".mm-navbars-bottom").find('.mm-navbar').find('a').text('\u00A9 2025 Travel Destinations').html();
$(".review").click(function() {
event.preventDefault();
event.stopPropagation();
var $this = $(this);
var reviewId = $(this).data('review-id');
$('.review[data-review-id='+reviewId+']').find('#review-read-more-link').hide();
$('.review[data-review-id='+reviewId+']').find('#review-part2').show();
$('.reviewFeedback[data-review-id='+reviewId+']').show();
});
$("a.addReviewFeedback").click(function() {
event.preventDefault()
event.stopPropagation()
var $this = $(this);
var reviewId = $(this).data('review-id');
var feedback = $(this).data('feedback');
if(feedback === 1) {
$('.addReviewFeedback[data-review-id='+reviewId+'][data-feedback='+'1'+']').css("background-color", "green");
$('.addReviewFeedback[data-review-id='+reviewId+'][data-feedback='+'1'+']').css("color", "white");
$('.addReviewFeedback[data-review-id='+reviewId+'][data-feedback='+'0'+']').css("background-color", "");
$('.addReviewFeedback[data-review-id='+reviewId+'][data-feedback='+'0'+']').css("color", "black");
} else {
$('.addReviewFeedback[data-review-id='+reviewId+'][data-feedback='+'0'+']').css("background-color", "green");
$('.addReviewFeedback[data-review-id='+reviewId+'][data-feedback='+'0'+']').css("color", "white");
$('.addReviewFeedback[data-review-id='+reviewId+'][data-feedback='+'1'+']').css("background-color", "");
$('.addReviewFeedback[data-review-id='+reviewId+'][data-feedback='+'1'+']').css("color", "black");
}
$.ajax({
type : 'get',
url : 'https://cancunmexico.guide/functions.cfc?method=add_review_feedback',
data : {review_id: reviewId, feedback: feedback},
success : function(data)
{
var data = JSON.parse(data);
console.log(data);
if(data["success"] === 1)
{
if(data["feedback"] === '1') {
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'1'+']').css("background-color", "green");
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'1'+']').css("color", "white");
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'0'+']').css("background-color", "");
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'0'+']').css("color", "black");
} else if(data["feedback"] === '0') {
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'0'+']').css("background-color", "green");
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'0'+']').css("color", "white");
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'1'+']').css("background-color", "");
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'1'+']').css("color", "black");
} else {
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'1'+']').css("background-color", "");
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'1'+']').css("color", "black");
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'0'+']').css("background-color", "");
$('.addReviewFeedback[data-review-id='+data["review_id"]+'][data-feedback='+'0'+']').css("color", "black");
}
console.log('Success');
}else{
if(data["error"] === 'login_required') {
$('#sign-in').modal('toggle');}
}
},
error: function (data) {
console.log(data);
}
});
});
$("a.addToFavorites").click(function() {
event.preventDefault()
event.stopPropagation()
var $this = $(this);
var type = $(this).data('type');
var id = $(this).data('id');
$.ajax({
type : 'get',
url : 'https://cancunmexico.guide/functions.cfc?method=add_to_favorites',
data : {type: type, id: id},
success : function(data)
{
var data = JSON.parse(data);
console.log(data);
if(data["success"] === 1)
{
$('.inFavorites[data-id='+id+']').show();
$('.addToFavorites[data-id='+id+']').hide();
$('.addToFavorites[data-id='+id+']').closest('.loc_open').hide();
console.log('Success');
}else{
if(data["error"] === 'not_logged_in') {
$('#sign-in').modal('toggle');}
}
},
error: function (data) {
console.log(data);
}
});
});
$("#submitResetPW").click(function() {
var form = $("#forgot-password-form");
if (form[0].checkValidity() === false) {
event.preventDefault()
event.stopPropagation()
} else {
var data = form.serialize();
// console.log(data);
$.ajax({
type : 'get',
url : 'https://cancunmexico.guide/functions.cfc?method=reset_password1',
data : data,
success : function(data)
{
var data = JSON.parse(data);
console.log(data);
if(data["success"] === 1)
{
$("#forgot-password-form #access-code-group").show();
$("#forgot-password-form #password-group").show();
$("#forgot-password-form #confirm-password-group").show();
$("#forgot-password-form #message1").hide();
$("#forgot-password-form #submitResetPWCode").show();
$("#forgot-password-form #submitResetPW").hide();
console.log('Success');
}else{
if(data["error"] === 'blank_email') {
$("#forgot-password-form #email-group").addClass("has-error");
$("#forgot-password-form #email-group").append(
'
' + data["message"] + "
");
console.log('Error'); }
}
},
error: function (data) {
console.log(data);
}
});
}
form.addClass('was-validated');
});
$("#submitResetPWCode").click(function() {
var form = $("#forgot-password-form");
if (form[0].checkValidity() === false) {
event.preventDefault()
event.stopPropagation()
} else {
var data = form.serialize();
// console.log(data);
$.ajax({
type : 'get',
url : 'https://cancunmexico.guide/functions.cfc?method=reset_password2',
data : data,
success : function(data)
{
var data = JSON.parse(data);
console.log(data);
if(data["success"] === 2)
{
$('#forgot-password').modal('toggle');
$('#sign-in').modal('toggle');
console.log('Password Changed');
}else{
$("#forgot-password-form .form-group").removeClass("has-error");
$("#forgot-password-form .help-block").remove();
if(data["error"] === 'blank_email') {
$("#forgot-password-form #email-group").addClass("has-error");
$("#forgot-password-form #email-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'invalid_access_code') {
$("#forgot-password-form #access-code-group").addClass("has-error");
$("#forgot-password-form #access-code-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'password_length') {
$("#forgot-password-form #password-group").addClass("has-error");
$("#forgot-password-form #password-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'blank_confirmation_password') {
$("#forgot-password-form #confirm-password-group").addClass("has-error");
$("#forgot-password-form #confirm-password-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'passwords_no_match') {
$("#forgot-password-form #password-group").addClass("has-error");
$("#forgot-password-form #password-group").append(
'' + data["message"] + "
");
$("#forgot-password-form #confirm-password-group").addClass("has-error");
$("#forgot-password-form #confirm-password-group").append(
'' + data["message"] + "
");
console.log('Error'); }
}
},
error: function (data) {
console.log(data);
}
});
}
form.addClass('was-validated');
});
$("#submitLogin").click(function() {
var form = $("#sign-in-form");
if (form[0].checkValidity() === false) {
event.preventDefault()
event.stopPropagation()
} else {
var data = form.serialize();
// console.log(data);
$.ajax({
type : 'get',
url : 'https://cancunmexico.guide/functions.cfc?method=check_login',
data : data,
success : function(data)
{
var data = JSON.parse(data);
console.log(data);
if(data["success"] === 1)
{
$('#reviewedBy').show();
$('#submitReviewBtn1').show();
$("#userName").val(data["user_first_name"]+" "+data["user_last_name"].substring(0,1)+".");
$('#sign-in').modal('toggle');
$('#submitReviewBtn2').hide();
$('#menu-sign-in').hide();
$('#menu-profile-setting').find('.name').text(data["user_first_name"]+" "+data["user_last_name"]);
$('#menu-profile-setting').find('.mail').text(data["user_email"]);
$('#menu-profile-setting').find('.profile-thumb-small').find('img').attr('src',"https://cancunmexico.guide/images/users/"+data["user_image_filename"]+"_50.jpg");
$('#menu-profile-setting').show();
console.log('Success');
}else{
$("#sign-in-form .form-group").removeClass("has-error");
$("#sign-in-form .help-block").remove();
if(data["error"] === 'blank_email') {
$("#sign-in-form #email-group").addClass("has-error");
$("#sign-in-form #email-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'blank_password') {
$("#sign-in-form #password-group").addClass("has-error");
$("#sign-in-form #password-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'invalid_login') {
$("#sign-in-form #password-group").addClass("has-error");
$("#sign-in-form #password-group").append(
'' + data["message"] + "
");
console.log('Error'); }
}
},
error: function (data) {
console.log(data);
}
});
}
form.addClass('was-validated');
});
$("#submitRegisterUser").click(function() {
var form = $('#sign-up-form')[0];
if (form[0].checkValidity() === false) {
event.preventDefault()
event.stopPropagation()
} else {
var data = new FormData(form);
data.append("CustomField", "This is some extra data, testing");
console.log(data);
$.ajax({
type : 'post',
url : 'https://cancunmexico.guide/register.cfm',
data : data,
contentType: false,
processData: false,
success : function(data)
{
var data = JSON.parse(data);
console.log(data);
if(data["success"] === 1)
{
$('#sign-up').modal('toggle');
$('#sign-in').modal('toggle');
console.log('Success');
}else{
$(".form-group").removeClass("has-error");
$(".help-block").remove();
if(data["error"] === 'blank_first_name') {
$("#sign-up-form #first-name-group").addClass("has-error");
$("#sign-up-form #first-name-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'blank_last_name') {
$("#sign-up-form #last-name-group").addClass("has-error");
$("#sign-up-form #last-name-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'blank_email') {
$("#sign-up-form #email-group").addClass("has-error");
$("#sign-up-form #email-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'password_length') {
$("#sign-up-form #password-group").addClass("has-error");
$("#sign-up-form #password-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'blank_confirmation_password') {
$("#sign-up-form #confirm-password-group").addClass("has-error");
$("#sign-up-form #confirm-password-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'passwords_no_match') {
$("#sign-up-form #password-group").addClass("has-error");
$("#sign-up-form #password-group").append(
'' + data["message"] + "
");
$("#sign-up-form #confirm-password-group").addClass("has-error");
$("#sign-up-form #confirm-password-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'invalid_login') {
$("#sign-up-form #password-group").addClass("has-error");
$("#sign-up-form #password-group").append(
'' + data["message"] + "
");
console.log('Error'); }
if(data["error"] === 'email_exists') {
$("#sign-up-form #email-group").addClass("has-error");
$("#sign-up-form #email-group").append(
'' + data["message"] + "
");
console.log('Error'); }
}
},
error: function (data) {
console.log(data);
}
});
}
form.addClass('was-validated');
});
$('input[type=radio][name=rating]').click(function() {
var ratingName = '';
if (this.value == 5) {
ratingName = 'Excellent';
}
if (this.value == 4) {
ratingName = 'Good';
}
if (this.value == 3) {
ratingName = 'Average';
}
if (this.value == 2) {
ratingName = 'Poor';
}
if (this.value == 1) {
ratingName = 'Terrible';
}
$("#ratingName").html('Overall rating: '+'"'+ratingName+'"');
});
});
$(function() {
$('.pop').on('click', function() {
$('.imagepreview').attr('src','');
$('.imagepreview').attr('src', $(this).find('img').attr('popsrc'));
$('#imagemodal').modal('show');
});
});