var activeSlide = 1; var moveRight = true; var sliderWidth = 906; var dontSlide = false; var dotPressed = false; var slideSpeed = 600; var slideCount = 0; $(document).ready(function(){ function slide(){ if(dotPressed){ $( "#bigSlider" ).animate({ "margin-left": -sliderWidth*(activeSlide-1) }, slideSpeed, function() { }); if(moveRight){ if(activeSlide >= 3) moveRight = false; }else{ if(activeSlide <= 1) moveRight = true; } }else{ if(moveRight){ $( "#bigSlider" ).animate({ "margin-left": -sliderWidth*activeSlide }, slideSpeed, function() { }); activeSlide++; if(activeSlide >= slideCount) moveRight = false; }else{ $( "#bigSlider" ).animate({ "margin-left": -sliderWidth*(activeSlide-2) }, slideSpeed, function() { }); activeSlide--; if(activeSlide <= 1) moveRight = true; } } bgAppearence(); dotAppearence(); } //Left right buttons $( "#sliderNext" ).click(function() { if(activeSlide > 1){ moveRight = false; slide(); } dontSlide = true; }); $( "#sliderPrev" ).click(function() { if(activeSlide < slideCount){ moveRight = true; slide(); } dontSlide = true; }); //Dot appearence function dotAppearence(){ $(".dot-a").addClass("dot-i").removeClass("dot-a"); $("#dot"+activeSlide).addClass("dot-a").removeClass("dot-i"); } //Dot clicked function dotClicked(dotId){ if(dotId > activeSlide){ moveRight = true; }else if(dotId < activeSlide){ moveRight = false; } activeSlide = dotId; dotPressed = true; slide(); dotPressed = false; dontSlide = true; } //Background appearence var bgImages = [ ] var nextBGimage = "uploads/images/featurebg3.png"; function bgAppearence(){ if(pageMode == "sliderAlone"){ $( "#imageBG" ).animate({ "opacity": 0 }, slideSpeed/2, function() { $("#imageBG").css('background-image', 'url(' + bgImages[activeSlide-1] + ')'); $( "#imageBG" ).animate({ "opacity": 1 }, slideSpeed/2, function() { }); }); } $("#imageBG").css('background-size', 'cover'); } });