var stepcarousel={ defaultbuttonsfade: 0.4, //fade degree for disabled nav buttons (0=completely transparent, 1=completely opaque) configholder: {}, getcssvalue:function(val){ //returns either 0 (if val contains 'auto') or val as an integer return (val=="auto")? 0 : parseint(val) }, getoffset:function(what, offsettype){ return (what.offsetparent)? what[offsettype]+this.getoffset(what.offsetparent, offsettype) : what[offsettype] }, 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 }, fadebuttons:function(config, currentpanel){ config.$leftnavbutton.fadeto('fast', currentpanel==0? this.defaultbuttonsfade : 1) config.$rightnavbutton.fadeto('fast', currentpanel==config.lastvisiblepanel? this.defaultbuttonsfade : 1) }, addnavbuttons:function(config, currentpanel){ config.$leftnavbutton=$('
').css({"cursor":"pointer"}).appendto(config.$gallery) config.$rightnavbutton=$('
').css({"cursor":"pointer"}).appendto(config.$gallery) config.$leftnavbutton.bind('click', function(){ //assign nav button event handlers clearinterval(config.steptimer) stepcarousel.stepby(config.galleryid, -config.defaultbuttons.moveby) config.steptimer=setinterval(function(){stepcarousel.stepby(config.galleryid, config.defaultbuttons.moveby)}, config.autostep.pause) }) config.$rightnavbutton.bind('click', function(){ //assign nav button event handlers clearinterval(config.steptimer) stepcarousel.stepby(config.galleryid, config.defaultbuttons.moveby) config.steptimer=setinterval(function(){stepcarousel.stepby(config.galleryid, config.defaultbuttons.moveby)}, config.autostep.pause) }) if (config.panelbehavior.wraparound==false){ //if carousel viewer should stop at first or last panel (instead of wrap back or forth) this.fadebuttons(config, currentpanel) } return config.$leftnavbutton.add(config.$rightnavbutton) }, alignpanels:function($, config){ var paneloffset=0 config.paneloffsets=[paneloffset] //array to store upper left offset of each panel (1st element=0) config.panelwidths=[] //array to store widths of each panel config.$panels.each(function(index){ //loop through panels var $currentpanel=$(this) $currentpanel.css({float: 'none', position: 'absolute', left: paneloffset+'px'}) //position panel $currentpanel.bind('click', function(e){return config.onpanelclick(e.target)}) //bind onpanelclick() to onclick event paneloffset+=stepcarousel.getcssvalue($currentpanel.css('marginright')) + parseint($currentpanel.get(0).offsetwidth || $currentpanel.css('width')) //calculate next panel offset config.paneloffsets.push(paneloffset) //remember this offset config.panelwidths.push(paneloffset-config.paneloffsets[config.paneloffsets.length-2]) //remember panel width }) config.paneloffsets.pop() //delete last offset (redundant) var addpanelwidths=0 var lastpanelindex=config.$panels.length-1 config.lastvisiblepanel=lastpanelindex for (var i=config.$panels.length-1; i>=0; i--){ addpanelwidths+=(i==lastpanelindex? config.panelwidths[lastpanelindex] : config.paneloffsets[i+1]-config.paneloffsets[i]) if (config.gallerywidth>addpanelwidths){ config.lastvisiblepanel=i //calculate index of panel that when in 1st position reveals the very last panel all at once based on gallery width } } config.$belt.css({width: paneloffset+'px'}) //set belt div to total panels' widths config.currentpanel=(config.panelbehavior.persist)? parseint(this.getcookie(window[config.galleryid+"persist"])) : 0 //determine 1st panel to show by default config.currentpanel=(typeof config.currentpanel=="number" && config.currentpanel0)? 'forward' : 'back' //if "steps" is negative, that means backwards var pindex=config.currentpanel+steps //index of panel to stop at if (config.panelbehavior.wraparound==false){ //if carousel viewer should stop at first or last panel (instead of wrap back or forth) pindex=(direction=="back" && pindex<=0)? 0 : (direction=="forward")? math.min(pindex, config.lastvisiblepanel) : pindex if (config.defaultbuttons.enable==true){ //if default nav buttons are enabled, fade them in and out depending on if at start or end of carousel stepcarousel.fadebuttons(config, pindex) } } else{ //else, for normal stepby behavior if (pindex>config.lastvisiblepanel && direction=="forward"){ //if destination pindex is greater than last visible panel, yet we're currently not at the end of the carousel yet pindex=(config.currentpanel0)? 0 : config.lastvisiblepanel /*wrap around left*/ } } var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset) //left distance for belt div to travel to if (pindex==0 && direction=='forward' || config.currentpanel==0 && direction=='back' && config.panelbehavior.wraparound==true){ //decide whether to apply "push pull" effect config.$belt.animate({left: -config.paneloffsets[config.currentpanel]-(direction=='forward'? 100 : -30)+'px'}, 'normal', function(){ config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)}) }) } else config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)}) config.currentpanel=pindex this.statusreport(galleryid) }, statusreport:function(galleryid){ var config=stepcarousel.configholder[galleryid] var startpoint=config.currentpanel //index of first visible panel var visiblewidth=0 for (var endpoint=startpoint; endpointconfig.gallerywidth){ break } } startpoint+=1 //format startpoint for user friendiness endpoint=(endpoint+1==startpoint)? startpoint : endpoint //if only one image visible on the screen and partially hidden, set endpoint to startpoint var valuearray=[startpoint, endpoint, config.panelwidths.length] for (var i=0; i