var quoteSectionBackground = $('#quote-section-background'); var productBottomText = $(".product-bottom-text"); var quoteImgWrapper = $('#quote-img-wrapper'); var quoteTextWrapper = $('#quote-text-wrapper'); var quoteSection = $('#quote-section'); var quoteTitleWrapper = $('#quote-title-wrapper'); var quoteLeftBootstrapCol = $('#quote-left-bootstrap-col'); var quoteRightBootstrapCol = $('#quote-right-bootstrap-col'); var blogTitleContainer = $(".blog-title-container"); var blogPreviewImg = $(".blog-preview-img"); var firstRightBlogContainer = $(".blog-right-container:first"); var processHeightJsNodes = []; nBGStartPos = 0; nCachedWindowHeight = 0; $(document).ready(function(){ fProductsHeightChecker(); fResponsiveHandler(); nBGStartPos = 0; if($('#quote-section').length) nBGStartPos = $('#quote-section').offset().top; nCachedWindowHeight = $(window).height(); }); $(window).resize(function() { fProductsHeightChecker(); fResponsiveHandler(); nCachedWindowHeight = $(window).height(); processHeightAdjust('info-text-title'); processHeightAdjust('info-text-body'); processHeightAdjust('blog-title-container'); processHeightAdjust('blog-date-container'); fAdjustFontSize(); }); $(window).scroll(function(){ nBGNewPos = $(window).scrollTop() - nBGStartPos + nCachedWindowHeight; if(quoteSectionBackground.length && nBGNewPos > 0 && nBGNewPos < $(window).height()){ quoteSectionBackground.css("top", (-nBGNewPos*0.4) +"px"); } }); fScrollToDivOffset = (function(){ return 100+$("#header-wrapper").outerHeight(); }); $(window).on("load", function(){ $(".slide").each(function(element){ aSlideIDs.push($(this).attr("id")); }); $('
').appendTo(".slides-container"); oSlideshowInterval = setInterval(function(){ if(bTransitioning) return; bTransitioning = true; nPointer++; if(nPointer>(aSlideIDs.length-1)) nPointer = 0; fRenderSlides(); },nSeconds*1000); processHeightAdjust('info-text-title'); processHeightAdjust('info-text-body'); processHeightAdjust('blog-title-container'); processHeightAdjust('blog-date-container'); fAdjustFontSize(); }); function fProductsHeightChecker(){ var nProductsTextHeight = 0; productBottomText.each(function(element){ if($(this).innerHeight() >= nProductsTextHeight){ nProductsTextHeight = $(this).outerHeight(); } }); productBottomText.each(function(element){ $(this).css("height",(nProductsTextHeight +"px")); }); } function fResponsiveHandler(){ if(quoteSectionBackground.length) { quoteImgWrapper.height(quoteTextWrapper.height()); quoteTextWrapper.innerHeight($('#quote-text-container').height()); quoteSectionBackground.width(quoteSection.width()); quoteSectionBackground.height((quoteSection.height())*3); } if($(window).width() > 992){ if(quoteSectionBackground.length) { quoteTitleWrapper.height(quoteTextWrapper.height()); } $(".blog-title-container").each(function(element){ $(this).text($(this).text().substring(0,100)); }); blogPreviewImg.each(function(element){ $(this).height("180px"); }); nPreCalcHeight = firstRightBlogContainer.height(); nPreCalcWidth = firstRightBlogContainer.width(); blogTitleContainer.each(function(element){ $(this).css("left", "15px"); $(this).css("width", (nPreCalcWidth)+"px"); }); if(quoteSectionBackground.length) { quoteLeftBootstrapCol.removeClass("col-xs-12").addClass("col-xs-4"); quoteRightBootstrapCol.removeClass("col-xs-12").addClass("col-xs-8"); } } if($(window).width() < 992){ blogPreviewImg.each(function(element){ $(this).height($(this).width()); }); if(quoteSectionBackground.length) { quoteLeftBootstrapCol.removeClass("col-xs-4").addClass("col-xs-12"); quoteRightBootstrapCol.removeClass("col-xs-8").addClass("col-xs-12"); } } } function processHeightAdjust(){ var processHeightJsNodes = processHeightJsNodes || []; if(! processHeightJsNodes[0]){ for (i = 0; i < arguments.length; i++) { processHeightJsNodes.push(document.getElementsByClassName(arguments[i])); } } for (i = 0; i < processHeightJsNodes.length; i++) { var max = 0; var elements = []; elements = processHeightJsNodes[i]; for (x = 0; x < elements.length; x++) { elements[x].removeAttribute("style"); if(elements[x].clientHeight > max) max=Math.ceil(elements[x].clientHeight); } for (y = 0; y < elements.length; y++) { elements[y].setAttribute("style","height:"+max+"px"); } } } var oSlideshowInterval = null; var nPointer = 0; var aSlideIDs = []; var bTransitioning = false; var nSeconds = 6; $(window).on("load", function(){ $(".slide").each(function(element){ aSlideIDs.push($(this).attr("id")); }); $('
').appendTo(".slides-container"); oSlideshowInterval = setInterval(function(){ if(bTransitioning) return; bTransitioning = true; nPointer++; if(nPointer>(aSlideIDs.length-1)) nPointer = 0; fRenderSlides(); },nSeconds*1000); }); function fRenderSlides(){ var $oLastImage = $(".slide[id='"+aSlideIDs[nPointer]+"']").last(); $(".slide[id!='"+aSlideIDs[nPointer]+"']").each(function(){ $(this).fadeOut(1000); }); $oLastImage.fadeIn(1000); setTimeout(function(){ bTransitioning = false; }, 1000); } function fRight(){ if(bTransitioning) return; bTransitioning = true; if(oSlideshowInterval!=null) clearInterval(oSlideshowInterval); nPointer++; if(nPointer>(aSlideIDs.length-1)) nPointer = 0; fRenderSlides(); } function fLeft(){ if(bTransitioning) return; bTransitioning = true; if(oSlideshowInterval!=null) clearInterval(oSlideshowInterval); nPointer--; if(nPointer<0) nPointer = aSlideIDs.length-1; fRenderSlides(); } // font size adjuster function fAdjustFontSize() { if($('.quote-title-wrapper').length && $('.quote-title').length) { $('.quote-title-wrapper').css('font-size', '1.5'); var nFontSize = 1.5; while ($('.quote-title')[0].clientHeight > $('.quote-title-wrapper').height() && $('.quote-title-wrapper').height()>0) { nFontSize -= 0.1; $('.quote-title-wrapper').css('font-size', nFontSize+'em'); } } }