jQuery(function($) {ServicesModuleInitialize();});function ServicesModuleInitialize() {$(document).on('s123.page.ready', function( event ) {var $section = $('section.s123-module-services');$section.each(function( index ) {var $sectionThis = $(this);var categories = new ModuleLayoutCategories({$items :  $sectionThis.find('.services-category'),$categoriesContainer : $sectionThis.find('.categories-panel'),$filterButton : $sectionThis.find('.items-responsive-filter'),$categories : $sectionThis.find('.items-categories-container li')});if ( $sectionThis.hasClass('layout-10') ) {$sectionThis.find('.service-item-description').each(function() {const $paragraph = $(this);const element = $paragraph.get(0);if (element.scrollHeight > element.clientHeight) {$paragraph.addClass('show-more');$paragraph.attr('data-rel', 'tooltip');$paragraph.off('click.openMore').on('click.openMore', function() {var $this = $(this);if ( $this.hasClass('show-more-disabled') ) return;bootbox.alert({title: $this.data('title'),message: $this.html(),backdrop: true});});}});}
if ( $sectionThis.hasClass('layout-13') ) {$sectionThis.find('.services-category').each(function() {$sectionThis.find('.service-item').removeClass('active');$sectionThis.find('.service-image').removeClass('active');$sectionThis.find('.service-info').addClass('service-more-info-hidden');var $firstItem = $(this).find('.service-item').first();$firstItem.addClass('active');var imgKey = $firstItem.data('img-key');if (imgKey !== undefined) {$sectionThis.find('.service-image[data-img-key="' + imgKey + '"]').addClass('active');var $firstInfo = $sectionThis.find('.service-info[data-img-key="' + imgKey + '"]');if ($firstInfo.length > 0) {$firstInfo.removeClass('service-more-info-hidden');}}});$sectionThis.find('.service-items .service-item').on('click mouseenter',function() {let $this = $(this);if ( $this.hasClass('active') ) return;let imgKey = $this.data('img-key');$sectionThis.find('.service-item').removeClass('active');$sectionThis.find('.service-image.active').stop().fadeOut(500).removeClass('active');$sectionThis.find('.service-info').addClass('service-more-info-hidden');$sectionThis.find('.service-item[data-img-key="' + imgKey + '"]').addClass('active');var $newImage = $sectionThis.find('.service-image[data-img-key="' + imgKey + '"]');$newImage.addClass('active').stop().fadeIn(500);var $targetInfo = $sectionThis.find('.service-info[data-img-key="' + imgKey + '"]');if ($targetInfo.length > 0) {$targetInfo.removeClass('service-more-info-hidden');}});$sectionThis.off('module_layout_categories.shown').on('module_layout_categories.shown', function( event, catID ) {var $category = $(this).find('.services-category[data-categories-filter="'+catID+'"]');$sectionThis.find('.service-item').removeClass('active');$sectionThis.find('.service-image.active').fadeOut(500).removeClass('active');$sectionThis.find('.service-image').removeClass('active');$sectionThis.find('.service-info').addClass('service-more-info-hidden');var imgKey = $category.find('.service-item:first-child').data('img-key');if (imgKey !== undefined) {$sectionThis.find(`.service-item[data-img-key="${imgKey}"]`).addClass('active');$sectionThis.find(`.service-image[data-img-key="${imgKey}"]`).addClass('active').fadeIn(500);var $targetInfo = $sectionThis.find(`.service-info[data-img-key="${imgKey}"]`);if ($targetInfo.length > 0) {$targetInfo.removeClass('service-more-info-hidden');}}});}
$modulesMobileCarouselViewOBJ = new ModulesMobileCarouselView({$section : $sectionThis});if ( $sectionThis.find('.mapPopupActivator').length > 0 ) {$sectionThis.find('.mapPopupActivator').each(function() {var $mapLink = $(this);var location = $mapLink.data('location');$mapLink.off('click.mapPopup').on('click.mapPopup', function(e) {e.preventDefault();buildPopup('popupServiceMap','','', $GLOBALS["maps-display-domain"] + '/include/globalMapDisplay.php?cad=1&q=' + encodeURIComponent(location) + '&fl=1&l=' + encodeURIComponent(languageCode) + '&ilfc=' + encodeURIComponent(longFreeCustomer), true, false, true, '', '');});});}
initPseudoLinks($sectionThis);initAttributePopovers($sectionThis);});});function initPseudoLinks($container) {var $pseudoLinks = $container.find('[data-link-element="true"][data-href]');if ( $pseudoLinks.length === 0 ) return;$pseudoLinks.off('mousedown.pseudoLink').on('mousedown.pseudoLink', function(e) {if (e.which === 2) {e.preventDefault();e.stopPropagation();var href = $(this).data('href');if (href) {window.open(href, '_blank');}}});$pseudoLinks.off('click.pseudoLink').on('click.pseudoLink', function(e) {e.preventDefault();e.stopPropagation();var $el = $(this);var href = $el.data('href');var target = $el.data('target');if ( !href ) return;var open_in_new_tab_boo = e.ctrlKey || e.metaKey || target === '_blank';if ( open_in_new_tab_boo ) {window.open(href, '_blank');} else {window.location.href = href;}});$pseudoLinks.off('auxclick.pseudoLink').on('auxclick.pseudoLink', function(e) {if (e.which === 2) {e.preventDefault();e.stopPropagation();}});}
function initAttributePopovers($container) {var $attrElements = $container.find('.service-extra-attr');if ( $attrElements.length === 0 ) return;$attrElements.each(function() {var $attrEl = $(this);var titleText = $attrEl.attr('title');if ( !titleText || titleText.trim() === '' ) return;$attrEl.popover({container: 'body',content: titleText,html: false,trigger: 'hover',placement: 'top',template: '<div class="popover service-attr-popover" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>'});});}}
function Comments_Initialize( settings ) {var that = this;var $s123CommentsContainer = $('#'+settings.id);var $commentsForm = $s123CommentsContainer.find('.commentsForm');var $commentsContainer;var Rating = {};var submitMessage = {};var hasRating = false;that.onLoad = settings.onLoad;that.onFormSubmit = settings.onFormSubmit;that.customLabels = settings.customLabels ? settings.customLabels : {};switch( settings.type ) {case 0:$commentsContainer 	= $s123CommentsContainer.find('#commentsContainer');submitMessage.title = translations.sent;submitMessage.message = translations.blogReviewMessage;break;case 1:$commentsContainer 	= $s123CommentsContainer.find('#commentsContainer');hasRating = true;break;default:return;break;}
that.init = function() {that.loadComments(false);};that.showSubcomments = function ( subComments, $commentsContainer ) {$.each(subComments,function( index, comment ) {var $parentComments = $commentsContainer.find('.commentBox');$.each($parentComments,function( index, parentComment ) {if ($(this).data('comment-id') == comment.parentID ) {$(parentComment).find('.sub-comments-div').append(that.comment_HTML(comment.title,comment.time,comment.message,comment.isAdmin));}});});};that.comment_HTML = function ( title, time, message, isAdmin ) {var html ='';html += '<div class="sub-comments-div-box">';html += '<h4 class="title">'+(isAdmin ? (S123.s123IconToSvg.getHtml('shield','') + ' ' + translations.admin) : title)+'</h4>';html += '<small class="time">'+time+'</small><br/>';html += '<div class="message">'+message+'</div>';html += '</div>';return html;};that.submitHandler = function ( $form ) {var forms_GoogleRecaptcha = new Forms_GoogleRecaptcha();forms_GoogleRecaptcha.init($form);$form.validate({errorElement: 'div',errorClass: 'help-block',focusInvalid: true,ignore: "",highlight: function (e) {$(e).closest('.form-group').removeClass('has-info').addClass('has-error');},success: function (e) {$(e).closest('.form-group').removeClass('has-error');$(e).remove();}});$form.off('submit.commentsForm').off('submit.commentsForm').on('submit.commentsForm', function( event ) {event.preventDefault();if ( hasRating ) {var formValid = $form.valid();var ratingValid = Rating.valid();if ( !formValid || !ratingValid ) return;} else {if ( !$form.valid() ) return;}
if ( forms_GoogleRecaptcha.isActive && !forms_GoogleRecaptcha.isGotToken ) {forms_GoogleRecaptcha.getToken();return false;}
$form.find('.blogSubmitButton').prop('disabled', true);$form.find('.blogSubmitButton').html(S123.s123IconToSvg.getHtml('spinner','fa-spin',''));$.ajax({type: "POST",url: "/versions/2/wizard/comments/addShowComments.php",data: $form.serialize(),success: function( data ) {var dataObj = tryParseJSON(data);if ( dataObj.blockComment  == '1' ) {that.showManagerApproveMessage();}
that.loadComments(data.commentsHtml);$form.trigger('reset');forms_GoogleRecaptcha.reset();$form.find('.blogSubmitButton').prop('disabled', false);$form.find('.blogSubmitButton').html($form.find('.blogSubmitButton').data('text'));WizardNotificationUpdate();if ( that.onFormSubmit ) that.onFormSubmit.call(this,dataObj.newCommentID,dataObj.blockComment);}});return false;});};that.showManagerApproveMessage = function () {if ( !submitMessage.message ) return;bootbox.alert({title: submitMessage.title,message: submitMessage.message,className: 'contactUsConfirm',buttons: {ok: {label: translations.Ok}},backdrop: true});};that.showReplyModal = function (t,childForm) {var x = '';x += '<form class="row" method="post" style="margin:0px;">';x += '<div class="col-xs-12 col-sm-12">';x += '<div class="form-group">';x += '<textarea class="form-control comment_message" name="comment_message" placeholder="'+(that.customLabels.commentResponseText ? that.customLabels.commentResponseText : t.data('tran-comment'))+'" style="min-height: 150px;" required data-msg-required="'+t.data('tran-this-field-is-required')+'"></textarea>';x += '</div>';x += '<div class="row">';x += '<div class="col-xs-12 col-sm-6">';x += '<div class="form-group">';x += '<input type="text" name="contact_name" placeholder="'+(that.customLabels.commentName ? that.customLabels.commentName : t.data('tran-name'))+'" class="form-control" required data-msg-required="'+t.data('tran-this-field-is-required')+'">';x += '</div>';x += '</div>';x += '<div class="col-xs-12 col-sm-6">';x += '<div class="form-group">';x += '<input type="text" name="contact_email" placeholder="'+(that.customLabels.commentEmail ? that.customLabels.commentEmail : t.data('tran-email-address'))+'" class="form-control" required data-msg-required="'+t.data('tran-this-field-is-required')+'" data-rule-email="true" data-msg-email="'+t.data('tran-please-enter-valid-email')+'">';x += '</div>';x += '</div>';x += '</div>';x += '<div class="text-center">';x += '<button type="submit" class="btn btn-primary blogSubmitButton" data-text="'+t.data('tran-post-reply')+'">'+(that.customLabels.replyButtonText ? that.customLabels.replyButtonText : t.data('tran-post-reply'))+'</button>';x += '</div>';x += '<div class="text-center comments-message-text">';x += '<small>* '+(that.customLabels.commentMessage ? that.customLabels.commentMessage : t.data('tran-the-email-will-not-be-published-on-the-website'))+'</small>';x += '</div>';x += '</div>';x += '<input type="hidden" name="w" value="'+t.data('hidden-w')+'">';x += '<input type="hidden" name="websiteID" value="'+t.data('hidden-website-id')+'">';x += '<input type="hidden" name="uniquePageID" value="'+t.data('hidden-unique-page-id')+'">';x += '<input type="hidden" name="moduleID" value="'+t.data('module-id')+'">';x += '<input type="hidden" name="moduleTypeNUM" value="'+t.data('module-type')+'">';x += '<input type="hidden" name="tranW" value="'+websiteLanguageCountryFullCode+'">';x += '<input type="hidden" class="commentTo" name="commentTo" value="'+t.data('hidden-comment-to')+'">';x += '<input type="hidden" name="act" value="addShow">';x += '</form>';childForm.html(x);that.submitHandler(childForm.find('form'));};Rating = new function() {var R = this;R.init = function( settings ) {if ( !settings.hasRating ) return;R.$form = settings.$form;R.$input = settings.$input;R.$json = settings.$json;if ( R.$form.length === 0 ) return;R.$raty = R.$form.find('.rating-plugin');R.$raty.raty({starType: 'i',cancel: false,number: 5,hints: R.getHints(),starHalf: (IsIE11() ? 'fa fa-star-half star-half' : 'star-half svg-m'),starOff: (IsIE11() ? 'fa fa-star-o star-o' : 'star-o svg-m'),starOn: (IsIE11() ? 'fa fa-star star' : 'star svg-m'),click: function( rating ,event ) {R.$input.val(rating);R.valid();}});};R.getHints = function() {var json = tryParseJSON(R.$json.val());if ( !json ) {return hints = [translations.reviewBad,translations.reviewPoor,translations.reviewRegular,translations.reviewGood,translations.reviewGorgeous];} else {return hints = json.hints;}};R.valid = function() {var valid = $.isNumeric(R.$input.val()) && parseInt(R.$input.val()) > 0;var $parent = R.$raty.closest('.form-group');$parent.removeClass('.has-error');$parent.find('#ratingError').remove();if ( !valid ) {$parent.addClass('has-error');$parent.append('<div id="ratingError" class="text-center help-block">'+R.$raty.data('msg-required')+'</div>');}
return valid;};};that.loadComments = function( commentsHtml ) {if ( !commentsHtml ) {loadCommentsByAjax();} else {addCommentsToPage(commentsHtml);}
$commentsForm.find('.blogCommentsBox #comment_message').focus(function() {$commentsForm.find('.blogCommentsBox').addClass('active');});that.submitHandler($commentsForm);Rating.init({$form: $commentsForm,$input: $commentsForm.find('.rating'),$json: $commentsForm.find('.rating-plugin-data'),hasRating: hasRating});};function loadCommentsByAjax() {$.ajax({type: "POST",url: '/versions/2/wizard/comments/addShowComments.php',data: {w: $('#w').val(),websiteID: $('#websiteID').val(),disableCssFiles: 1,moduleID: $commentsContainer.data('module-id'),moduleTypeNUM: $commentsContainer.data('module-type-num'),uniquePageID: $commentsContainer.data('unique-page-id'),tranW: $commentsContainer.data('tran-w'),act: $commentsContainer.data('action')},success: function( data ) {data = tryParseJSON(data);if ( !data ) return;addCommentsToPage(data.commentsHtml);}});}
function addCommentsToPage( commentsHtml ) {$commentsContainer.html(commentsHtml);$commentsContainer.find('.blog-reply-to').each(function( index, replyLink ) {$(replyLink).off('click').on('click',function() {$childForm = $(this).closest('.commentBox').find('.blogReplyForm');if ($childForm.hasClass('hidden')) {that.showReplyModal($(this),$childForm);$('.blogReplyForm').addClass('hidden');$('.blog-reply-to').html($(this).data('text-reply'));$(this).html($(this).data('text-hide'));$childForm.removeClass('hidden');} else {$childForm.addClass('hidden');$(this).html($(this).data('text-reply'));}
$childForm.find('.comment_message').select();});});var subComments = tryParseJSON($commentsContainer.find('.sub-comments').html());that.showSubcomments(subComments,$commentsContainer);if ( hasRating) {if ( that.onLoad ) that.onLoad.call(this,$commentsContainer.find('.commentBox').length,$commentsContainer.find('#reviewAvg').val(),false);}}
that.init();}
jQuery(function($) {TwitterTweetsModuleInitialize();});function TwitterTweetsModuleInitialize() {$(document).on('s123.page.ready', function( event ) {var $section = $('section.s123-module-twitter-tweets');$section.each(function( index ) {var $sectionThis = $(this);$sectionThis.find('.tweet-settings').each(function(){const $settings = $(this);const settings = tryParseJSON($settings.val());if ( !settings ) return;$settings.replaceWith(`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${settings.theme}"><a href="${settings.tweetURL}">${settings.title}</a></blockquote><script class="twitter-tweet-script" async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>`);});});});}
jQuery(function($) {TwitterTweetsLayout2ModuleInitialize();});function TwitterTweetsLayout2ModuleInitialize() {$(document).on('s123.page.ready', function(event) {var $sections = $('section.s123-module-twitter-tweets.layout-2');$sections.each(function(index) {var $sectionThis = $(this);initializeTwitterTweetsLayout2($sectionThis);});});}
var twitterWidgetsLoaded = false;var twitterWidgetsLoading = false;var logCounters = {initializeSection: 0,loadWidgets: 0,setupEventListeners: 0,monitoringSetup: 0,tweetProcessing: 0};function initializeTwitterTweetsLayout2($section) {logCounters.initializeSection++;if (logCounters.initializeSection > 3) {return;}
var tweetSettings = $section.find('.item-set-1 .tweet-settings').length;var existingTweets = $section.find('.item-set-1 .twitter-tweet').length;if (tweetSettings === 0 && existingTweets === 0) {return;}
if (existingTweets > 0) {setTimeout(function() {var $allTwitterIframes = $('iframe[id*="twitter-widget"]');if ($allTwitterIframes.length > 0) {$allTwitterIframes.each(function() {var $iframe = $(this);var currentLoading = $iframe.attr('loading');if (currentLoading !== 'lazy') {$iframe.attr('loading', 'lazy');}});}}, 2000);}
if (tweetSettings > 0) {$section.find('.item-set-1 .tweet-settings').each(function(index) {const $settings = $(this);const $tweetBody = $settings.closest('.tweet-body');if ($tweetBody.find('[data-tweet-processed="true"]').length > 0) {return;}
logCounters.tweetProcessing++;const settings = tryParseJSON($settings.val());if (!settings) {$tweetBody.html('<div class="tweet-error">Invalid tweet configuration</div>');return;}
const $existingTweet = $tweetBody.find('.twitter-tweet[data-iframe-loaded="true"], .twitter-tweet[data-iframe-preserved="true"]');if ($existingTweet.length > 0) {return; // Skip recreating tweet
}
$tweetBody.html('<div class="tweet-loading"></div>');try {const tweetHTML = `<blockquote class="twitter-tweet" data-dnt="true" data-theme="${settings.theme}" data-conversation="none" data-cards="hidden" data-width="300" data-lang="en" data-limit="1" data-tweet-url="${settings.tweetURL}" data-tweet-title="${settings.title}">
<div class="tweet-placeholder" style="min-height: 200px; border: 1px solid #e1e8ed; border-radius: 12px; padding: 20px; background: #f7f9fa; display: flex; align-items: center; justify-content: center; color: #657786; font-size: 14px;">
<div style="text-align: center;">
<div style="margin-bottom: 8px;">🐦</div>
<div>Tweet will load when visible</div>
</div>
</div>
<a href="${settings.tweetURL}" style="display: none;">${settings.title}</a>
</blockquote>`;$settings.replaceWith(tweetHTML);const $newTweet = $tweetBody.find('.twitter-tweet');$newTweet.attr('role', 'article');$newTweet.attr('aria-label', 'Twitter Tweet');const $correspondingItem = $tweetBody.closest('.global-layout-2-item');const uniqueId = $correspondingItem.data('unique-id');if (uniqueId) {const $correspondingItemSet2 = $section.find('.item-set-2 .global-layout-2-item[data-unique-id="' + uniqueId + '-copy"]');if ($correspondingItemSet2.length > 0) {const $tweetBodySet2 = $correspondingItemSet2.find('.tweet-body');$tweetBodySet2.html($tweetBody.html());}}} catch (error) {$tweetBody.html('<div class="tweet-error">Error loading tweet</div>');}});}
loadTwitterWidgetsOnce();if (!$section.data('twitter-monitoring-setup')) {logCounters.monitoringSetup++;$section.data('twitter-monitoring-setup', true);monitorTweetLoading($section);}}
function loadTwitterWidgetsOnce() {logCounters.loadWidgets++;if (logCounters.loadWidgets > 5) {return;}
if (twitterWidgetsLoaded || twitterWidgetsLoading) {return;}
if (typeof twttr !== 'undefined') {twitterWidgetsLoaded = true;setupTwitterEventListeners();return;}
if (!document.querySelector('script[src*="platform.twitter.com/widgets.js"]')) {twitterWidgetsLoading = true;const script = document.createElement('script');script.async = true;script.src = 'https://platform.twitter.com/widgets.js';
script.charset = 'utf-8';script.className = 'twitter-widgets-script';script.onload = function() {twitterWidgetsLoaded = true;twitterWidgetsLoading = false;if (typeof twttr !== 'undefined') {setupTwitterEventListeners();}};script.onerror = function() {twitterWidgetsLoading = false;$('.tweet-loading').each(function() {$(this).replaceWith('<div class="tweet-error">Failed to load Twitter widgets</div>');});};document.head.appendChild(script);} else {twitterWidgetsLoading = true;}}
function setupTwitterEventListeners() {logCounters.setupEventListeners++;if (logCounters.setupEventListeners > 2) {return;}
if (window.twitterEventListenersSetup) {return;}
window.twitterEventListenersSetup = true;if (typeof twttr !== 'undefined') {twttr.events.bind('rendered', function(event) {const $iframe = $(event.target);if ($iframe.length) {const iframeId = $iframe.attr('id');if (iframeId && iframeId.includes('twitter-widget')) {$iframe.attr('loading', 'lazy');try {const iframeDoc = $iframe[0].contentDocument || $iframe[0].contentWindow.document;const images = iframeDoc.querySelectorAll('img');images.forEach(function(img) {img.setAttribute('loading', 'lazy');});} catch (e) {}}
$iframe.css({'width': '100%','max-width': 'none','height': '240px','max-height': '240px'});try {$iframe.contents().find('span').css('font-size', '13px');$iframe.contents().find('body').css('font-size', '13px');} catch (e) {$iframe.closest('.twitter-tweet').css({'font-size': '13px','line-height': '1.3'});}
applyLazyLoadingToTweetImages($iframe);$iframe.closest('.twitter-tweet').attr('data-iframe-loaded', 'true');$iframe.closest('.global-layout-2-item').find('.tweet-loading').remove();}});twttr.events.bind('loaded', function(event) {});}}
function monitorTweetLoading($section) {setTimeout(function() {$section.find('.twitter-tweet').each(function() {const $tweet = $(this);if (!$tweet.attr('data-rendered') && !$tweet.find('iframe').length) {const $errorDiv = $('<div class="tweet-error">Tweet could not be loaded</div>');$tweet.replaceWith($errorDiv);}});}, 15000); // Wait 15 seconds for tweets to load (increased from 10s)
}
function refreshTwitterTweetsLayout2($section) {initializeTwitterTweetsLayout2($section);}
function initializeTwitterTweetsLayout2ManualCarousel($section) {$section.find('.global-layout-2-column').each(function() {var $column = $(this);var $grid = $column.find('.global-layout-2-grid');if ($grid.length > 0 && $column.data('animate') === true) {var animationDuration = $column.data('animation-duration') || 60;var direction = $column.data('direction') || 'up';$grid.css('animation-duration', animationDuration + 's');$column.on('mouseenter', function() {$grid.css('animation-play-state', 'paused');});$column.on('mouseleave', function() {$grid.css('animation-play-state', 'running');});}});}
function tryParseJSON(jsonString) {try {return JSON.parse(jsonString);} catch (e) {return null;}}
window.TwitterTweetsLayout2 = {initialize: TwitterTweetsLayout2ModuleInitialize,refresh: refreshTwitterTweetsLayout2,loadWidgets: loadTwitterWidgetsOnce};function showLoggingSummary() {if (logCounters.initializeSection > 5) {}
if (logCounters.loadWidgets > 3) {}
if (logCounters.setupEventListeners > 1) {}
if (logCounters.tweetProcessing > 20) {}}
setTimeout(function() {showLoggingSummary();setInterval(showLoggingSummary, 30000); // Every 30 seconds
}, 10000); // First summary after 10 seconds
function optimizeTwitterIframeRendering($section) {$section.find('iframe[id^="twitter-widget"]').each(function() {const iframe = this;$(iframe).css({'transform': 'translateZ(0)','backface-visibility': 'hidden','will-change': 'auto'});});}
$(document).ready(function() {if (typeof window.GlobalLayout2 === 'undefined') {const script = document.createElement('script');script.src = '/versions/2/wizard/modules/globalLayouts/globalLayout-vertical-scroll/js/module.globalLayout-2.js';document.head.appendChild(script);}
setTimeout(function() {$('.s123-module-twitter-tweets.layout-2').each(function() {optimizeTwitterIframeRendering($(this));});}, 2000); // Wait for tweets to load
});function addLazyLoadingToExistingTwitterIframes($section) {const $twitterIframes = $section.find('iframe[id*="twitter-widget"]');if ($twitterIframes.length === 0) {return;}
$twitterIframes.each(function(index) {const $iframe = $(this);const iframeId = $iframe.attr('id');const currentLoading = $iframe.attr('loading');if (currentLoading !== 'lazy') {$iframe.attr('loading', 'lazy');try {const iframeDoc = $iframe[0].contentDocument || $iframe[0].contentWindow.document;const images = iframeDoc.querySelectorAll('img');images.forEach(function(img) {if (img.getAttribute('loading') !== 'lazy') {img.setAttribute('loading', 'lazy');}});} catch (e) {}}});}
function setupPeriodicTwitterIframeScan($section) {if ($section.data('twitter-iframe-scanner-setup')) {return;}
$section.data('twitter-iframe-scanner-setup', true);let scanCount = 0;const maxScans = 30; // Safety limit to prevent infinite scanning
const scanInterval = setInterval(function() {scanCount++;const $pendingBlockquotes = $section.find('.twitter-tweet-lazy');if ($pendingBlockquotes.length === 0) {clearInterval(scanInterval);return;}
const $newIframes = $section.find('iframe[id*="twitter-widget"]:not([loading="lazy"])');if ($newIframes.length > 0) {$newIframes.each(function() {const $iframe = $(this);const iframeId = $iframe.attr('id');$iframe.attr('loading', 'lazy');try {const iframeDoc = $iframe[0].contentDocument || $iframe[0].contentWindow.document;const images = iframeDoc.querySelectorAll('img:not([loading="lazy"])');images.forEach(function(img) {img.setAttribute('loading', 'lazy');});} catch (e) {}});}
if (scanCount >= maxScans) {clearInterval(scanInterval);}}, 1000); // Scan every 1 second
}
function setupTwitterIframeLazyLoading($section) {const $lazyTweets = $section.find('.twitter-tweet-lazy[data-lazy-load="true"]');if ($lazyTweets.length === 0) {const $allTweets = $section.find('.twitter-tweet');return;}
const observer = new IntersectionObserver(function(entries) {entries.forEach(function(entry) {if (entry.isIntersecting) {const $tweet = $(entry.target);if ($tweet.data('loading') || $tweet.attr('data-iframe-loaded') === 'true') {return;}
$tweet.data('loading', true);const tweetURL = $tweet.attr('data-tweet-url');const tweetTitle = $tweet.attr('data-tweet-title');if (tweetURL && tweetTitle) {$tweet.html(`<a href="${tweetURL}">${tweetTitle}</a>`);$tweet.removeAttr('data-lazy-load')
.removeAttr('data-tweet-url')
.removeAttr('data-tweet-title')
.removeClass('twitter-tweet-lazy');if (typeof twttr !== 'undefined' && twttr.widgets && twttr.widgets.load) {twttr.widgets.load($tweet[0]);}}
observer.unobserve(entry.target);}});}, {root: null, // Use viewport as root
threshold: 0.1, // Trigger when 10% visible
rootMargin: '100px' // Start loading 100px before entering viewport
});$lazyTweets.each(function(index) {observer.observe(this);});}
function applyLazyLoadingToTweetImages($iframe) {try {const iframe = $iframe[0];if (!iframe || !iframe.contentDocument) {return;}
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;const images = iframeDoc.querySelectorAll('img');if (images.length === 0) {return;}
const observer = new IntersectionObserver(function(entries) {entries.forEach(function(entry) {if (entry.isIntersecting) {const img = entry.target;const lazySrc = img.getAttribute('data-src') || img.getAttribute('data-lazy-src');if (lazySrc && !img.src) {img.src = lazySrc;img.removeAttribute('data-src');img.removeAttribute('data-lazy-src');}
observer.unobserve(img);}});}, {root: null, // Use viewport as root
threshold: 0.1,rootMargin: '50px' // Start loading 50px before image enters viewport
});images.forEach(function(img) {if (img.src && !img.getAttribute('data-src') && !img.getAttribute('data-lazy-src')) {img.setAttribute('data-lazy-src', img.src);img.removeAttribute('src');}
observer.observe(img);});} catch (error) {}}
function addSmoothAnimationResetHandling($iframe) {try {const $grid = $iframe.closest('.global-layout-2-grid');const $column = $iframe.closest('.global-layout-2-column');if ($grid.length === 0 || $column.length === 0) {return;}
const animationDuration = parseFloat($column.data('animation-duration')) || 17;const animationDurationMs = animationDuration * 1000;let lastTransform = '';let resetCount = 0;const checkAnimationReset = () => {const currentTransform = window.getComputedStyle($grid[0]).transform;if (currentTransform.includes('matrix(1, 0, 0, 1, 0, 0)') ||currentTransform.includes('matrix(1, 0, 0, 1, 0, -')) {if (lastTransform && lastTransform !== currentTransform) {resetCount++;$grid.css('opacity', '0.98');setTimeout(() => {$grid.css('opacity', '1');}, 50); // Very brief opacity change to mask the flash
}}
lastTransform = currentTransform;};const resetInterval = setInterval(checkAnimationReset, animationDurationMs / 10);setTimeout(() => {clearInterval(resetInterval);}, 300000); // 5 minutes
} catch (error) {}}
jQuery(function($) {RichPageModuleInitialize();});function RichPageModuleInitialize() {$(document).on('s123.page.ready', function( event ) {if ( !IsWizard() ) {RichPagePromosHandler.init();}});var RichPagePromosHandler = function() {var _ = {fixColors: false};_.init = function() {_.$section = $('section.s123-module-rich-page');if ( _.$section.length === 0 ) return;_.$sections = _.$section.siblings();_.$sections.each(function( index, section ) {var $thisSection = $(this);if ( $thisSection.attr('class').indexOf('s123-promo-module') != -1 ) {$thisSection.remove();_.fixColors = true;} else if ( !(whatScreen.any() == 'mobile' && $thisSection.hasClass('h-s-f-hm') ) ) {return false;}});if ( _.fixColors ) {fixModuleColors();}};function fixModuleColors() {_.$sections.filter(':visible').each( function( index, module ) {var $module = $(this);if ( index % 2 == 0 ) {$module.addClass('bg-primary');} else {$module.removeClass('bg-primary');}});}
return _;}();}
