/* Background Image Carousel * Created: Jan 17th, 2012 by DynamicDrive.com. This notice must stay intact for usage * Author: Dynamic Drive at http://www.dynamicdrive.com/ * Visit http://www.dynamicdrive.com/ for full source code */ //** Modified Jan 23th, 12'- Fixed bug with auto rotate bug in "manual" mode //** Modified Feb 21st, 12'- Fixed bug with carousel not always initializing in IE8 and less jQuery.noConflict() function bgCarousel(options){ var $=jQuery this.setting={displaymode:{type:'auto', pause:2000, stoponclick:false, cycles:2, pauseonmouseover:true}, activeslideclass:'selectedslide', orientation:'h', persist:true, slideduration:500} //default settings jQuery.extend(this.setting, options) //merge default settings with options this.setting.displaymode.pause+=400+this.setting.slideduration // 400ms is default fade in time var curslide=(this.setting.persist)? bgCarousel.routines.getCookie("slider-"+this.setting.wrapperid) : 0 this.curslide=(curslide==null || curslide>this.setting.imagearray.length-1)? 0 : parseInt(curslide) //make sure curslide index is within bounds this.curstep=0 this.animation_isrunning=false //variable to indicate whether an image is currently being slided in this.posprop=(this.setting.orientation=="h")? "left" : "top" options=null var slideshow=this, setting=this.setting, preloadimages=[], imagesloaded=0, slidesHTML='' for (var i=0, max=setting.imagearray.length; ithis.$imageslides.length-1)? 0 : targetslide //wrap around if (this.animation_isrunning==false) this.slide(targetslide, dir) }, rotate:function(){ var slideshow=this, setting=this.setting if (this.ismouseover){ //pause slideshow onmouseover this.rotatetimer=setTimeout(function(){slideshow.rotate()}, setting.displaymode.pause) return } var nextslide=(this.curslide' + '' ) .click(function(){ var keyword = this.getAttribute('data-dir') setting.curslide = (keyword == "right")? (setting.curslide == setting.content.length-1? 0 : setting.curslide + 1) : (setting.curslide == 0? setting.content.length-1 : setting.curslide - 1) slideshow.navigate(keyword) }) $controls.appendTo(this.$wrapperdiv) if (setting.displaymode.type=="auto"){ //auto slide mode? setting.displaymode.pause+=setting.slideduration this.maxsteps=setting.displaymode.cycles * this.$imageslides.length if (setting.displaymode.pauseonmouseover){ this.$wrapperdiv.mouseenter(function(){slideshow.ismouseover=true}) this.$wrapperdiv.mouseleave(function(){slideshow.ismouseover=false}) } this.rotatetimer=setTimeout(function(){slideshow.rotate()}, setting.displaymode.pause) } } } bgCarousel.routines={ getSlideHTML:function(setting, imgref, w, h, posprop){ var posstr=posprop+":"+((posprop=="left")? w : h) return '
' + ((imgref[1])? '\n' : '') + '
' }, getCookie:function(Name){ var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair if (document.cookie.match(re)) //if cookie found return document.cookie.match(re)[0].split("=")[1] //return its value return null }, setCookie:function(name, value){ document.cookie = name+"=" + value + ";path=/" }, createobj:function(){ var obj={} for (var i=0; i