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.currentpanel