(function($) { 'use strict'; // Initialize when document is ready $(document).ready(function() { // Disable next button initially const $nextBtn = $('.next-btn'); $nextBtn.prop('disabled', true).addClass('disabled'); // Price option selection $('.price-option').on('click', function() { const $this = $(this); const $allOptions = $('.price-option'); // Toggle selection $allOptions.removeClass('selected'); $this.addClass('selected'); // Enable next button $nextBtn.prop('disabled', false).removeClass('disabled'); }); // Next button handler $nextBtn.on('click', function() { const $selectedOption = $('.price-option.selected'); if (!$selectedOption.length) { return; } const escrowUrl = $selectedOption.data('escrow'); const offerUrl = $selectedOption.data('offer'); // If it's the first option (Buy Now) and escrow URL exists if ($selectedOption.index() === 0 && escrowUrl) { window.location.href = escrowUrl; } // If it's the second option (Make Offer) and offer URL exists else if ($selectedOption.index() === 1 && offerUrl) { window.location.href = offerUrl; } }); // FAQ Functionality $('.faq-button').on('click', function(e) { e.preventDefault(); const $item = $(this).closest('.faq-item'); const $answer = $item.find('.faq-answer'); const isActive = $item.hasClass('active'); // Close other FAQs $('.faq-item').not($item).removeClass('active') .find('.faq-answer').slideUp(300); // Toggle current FAQ if (isActive) { $answer.slideUp(300, function() { $item.removeClass('active'); }); } else { $item.addClass('active'); $answer.slideDown(300); } }); // Newsletter Form Validation const $newsletterForm = $('.newsletter-form'); if ($newsletterForm.length) { $newsletterForm.on('submit', function(e) { const $emailInput = $(this).find('input[type="email"]'); const email = $emailInput.val().trim(); if (!isValidEmail(email)) { e.preventDefault(); showError($emailInput, 'Please enter a valid email address'); } }); } // Email Validation Helper function isValidEmail(email) { const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(String(email).toLowerCase()); } // Error Display Helper function showError($input, message) { const $existingError = $input.siblings('.error-message'); if ($existingError.length) { $existingError.remove(); } const $errorDiv = $('