$(document).ready(function() { // Pager if ($('#notice-photos .photoGalleryElement .thumbnail').length == 1) { $('.bx-pager .bx-pager-item + .bx-pager-item').remove(); } else if ($('#notice-photos .photoGalleryElement .thumbnail').length == 2) { $('.bx-pager .bx-pager-item + .bx-pager-item + .bx-pager-item').remove(); } else if ($('#notice-photos .photoGalleryElement .thumbnail').length == 3) { $('.bx-pager .bx-pager-item + .bx-pager-item + .bx-pager-item + .bx-pager-item').remove(); } else if ($('#notice-photos .photoGalleryElement .thumbnail').length == 4) { $('.bx-pager .bx-pager-item + .bx-pager-item + .bx-pager-item + .bx-pager-item + .bx-pager-item').remove(); } else if ($('#notice-photos .photoGalleryElement .thumbnail').length == 5) { $('.bx-pager .bx-pager-item + .bx-pager-item + .bx-pager-item + .bx-pager-item + .bx-pager-item + .bx-pager-item').remove(); } else { $('.bx-pager').remove(); } // BX SLIDER FOR BLOG CAPTIONS bannerSlideshow(); // BACKSTRETCH FOR IMAGES if($('#notice-photos .photoGalleryElement .thumbnail').find('img').length) { var list = new Array(); $('#notice-photos .photoGalleryElement .thumbnail').each(function(){ list.push($("a", this).attr("href")); }); $("#backstretch").backstretch(list, {centeredY: false, duration: 999999, fade: 500}); } else { //Default Image $("#backstretch").backstretch(["/MainFolder/default-images/default-home-banner.jpg"], {centeredY: false, duration: 999999, fade: 500}); } $('.bx-pager-item:nth-child(1) a').click(function(){ $('#backstretch').backstretch("show", 0); }); $('.bx-pager-item:nth-child(2) a').click(function(){ $('#backstretch').backstretch("show", 1); }); $('.bx-pager-item:nth-child(3) a').click(function(){ $('#backstretch').backstretch("show", 2); }); $('.bx-pager-item:nth-child(4) a').click(function(){ $('#backstretch').backstretch("show", 3); }); $('.bx-pager-item:nth-child(5) a').click(function(){ $('#backstretch').backstretch("show", 4); }); $('.bx-pager-item:nth-child(6) a').click(function(){ $('#backstretch').backstretch("show", 5); }); }); /*------------------------------------------------------------------------------------------------------------------ ON WINDOW RESIZE -------------------------------------------------------------------------------------------------------------------*/ $(window).resize(function() { bannerSlideshow(); $('#backstretch').backstretch("show", 0); }); /*------------------------------------------------------------------------------------------------------------------ RE-USABLE FUNCTIONS -------------------------------------------------------------------------------------------------------------------*/ /* BANNER SLIDESHOW -------------------------------------------------------------------------------------------------------------------*/ function bannerSlideshow() { if($('#notice-message .bx-viewport').length) { bannerslider.reloadSlider(); } else { bannerslider = $('#notice-message .blogentries ul').bxSlider({ mode: 'fade', auto: true, controls: false, pagerCustom: '.bx-pager', pause: '7000', speed: 500, displaySlideQty: 1, touchEnabled: true, moveSlideQty: 1, onSlideNext: function($slideElement, oldIndex, newIndex){ $('#backstretch').backstretch("next"); } }); } }