var aCarouselIDs = []; var aCarouselHiddenIDs = []; var nCarouselItemDivWidth = 0; var nNumberOfCarouselItems = 0; var bAcceptInput = true; var nDivActualWidth = 240; var nMathmaticalPaddingRequired = 0; var nCarouselItemHeight = 0; var nCurrentlySelectedOption = 1; //this is linked the the number of buttons you want to change the contents of your slider //the default for this is -> in the html ensure that anything with the 'carousel-item' //class also has an 'carousel-option-x' //currently only works if they have at least 1 of of each option var nNumberOfOptions = 3; window.addEventListener("orientationchange", function() { setTimeout(function(){fCarouselHeightChecker();}, 1000); }, false); //after the DOM is loaded $(window).load(function(){ // run the calculate initial width and height checker functions fCalculateInitialWidth(); processHeightAdjust('carousel-product-name'); fCarouselHeightChecker(); fCategoryButtonColor(1); processHeightAdjust('category-box-text-positioning'); fRecalcOnResize(); }); //when the window is resized $(window).resize(function() { // only do this if they havent clicked in an input box if($(document.activeElement).attr('type') !== 'text') { //use a timeout the fires 'resize end' 500 ms after you have stopped resizing if(this.resizeTO) clearTimeout(this.resizeTO); this.resizeTO = setTimeout(function() { //fire resizeEnd $(this).trigger('resizeEnd'); }, 100); } }); //creates new funtion that is fired on the trigger $(window).bind('resizeEnd', function() { //runs the recalculate on resize method fRecalcOnResize(); }); //This is used to calculate the simulated width of the carousel items function fCalculateInitialWidth(){ //Gets the outer width of the carousel container nContainerWidth = $("#carousel-container").outerWidth(); //this divides the width of the divs by the width of the container than rounds down //to show the maximum number of whole items that can be shown on the carousel at once nNumberOfProducts = Math.floor(nContainerWidth/nDivActualWidth); //this finds the sum of those divs then minuses it from the total width to show how many pixels //would be left over, i then divides bu the number of items being show to calculate the distribution //of left over pixels amongst the iteme nMathmaticalPaddingRequired = ((nContainerWidth-(nDivActualWidth*nNumberOfProducts))/(nNumberOfProducts)); //it then adds that number the to width of the div so that the positional maths leaves enoughs space between them nCarouselItemDivWidth = nDivActualWidth + nMathmaticalPaddingRequired; //calls the function to handle the array that tracks the locations fRearrangeInitialArray(); } function fRearrangeInitialArray(){ //This resets an incremental id nIDToBEIncremented = 0; // Ensures there are at least 6 of every option for (y = 1; y <= nNumberOfOptions; y++){ if($(".carousel-item.carousel-option-"+(y)).length<6 && $(".carousel-item.carousel-option-"+(y)).length>0) { var nClonesNeeded = Math.ceil(6/$(".carousel-item.carousel-option-"+(y)).length)-1; var oClones = $(".carousel-item.carousel-option-"+(y)); for(var i=0; i