var stepcarousel={ajaxloadingmsg:'<div style="margin: 1em; font-weight: bold"><img src="ajaxloadr.gif" style="vertical-align: middle" /> Fetching Content. Please wait...</div>',defaultbuttonsfade:.4,configholder:{},getCSSValue:function(a){return a=="auto"?0:parseInt(a)},getremotepanels:function(b,a){a.$belt.html(this.ajaxloadingmsg);b.ajax({url:a.contenttype[1],async:true,error:function(b){a.$belt.html("Error fetching content.<br />Server Response: "+b.responseText)},success:function(c){a.$belt.html(c);a.$panels=a.$gallery.find("."+a.panelclass);stepcarousel.alignpanels(b,a)}})},getoffset:function(a,b){return a.offsetParent?a[b]+this.getoffset(a.offsetParent,b):a[b]},getCookie:function(b){var a=new RegExp(b+"=[^;]+","i");return document.cookie.match(a)?document.cookie.match(a)[0].split("=")[1]:null},setCookie:function(b,a){document.cookie=b+"="+a},fadebuttons:function(a,b){a.$leftnavbutton.fadeTo("fast",b==0?this.defaultbuttonsfade:1);a.$rightnavbutton.fadeTo("fast",b==a.lastvisiblepanel?this.defaultbuttonsfade:1);b==a.lastvisiblepanel&&stepcarousel.stopautostep(a)},addnavbuttons:function(c,a,b){(function(f){var c="px",e="absolute",d='<img src="';a.$leftnavbutton=f(d+a.defaultbuttons.leftnav[0]+'">').css({zIndex:50,position:e,left:a.offsets.left+a.defaultbuttons.leftnav[1]+c,top:a.offsets.top+a.defaultbuttons.leftnav[2]+c,cursor:"hand",cursor:"pointer"}).attr({title:"Back "+a.defaultbuttons.moveby+" panels"}).appendTo("body");a.$rightnavbutton=f(d+a.defaultbuttons.rightnav[0]+'">').css({zIndex:50,position:e,left:a.offsets.left+a.$gallery.get(0).offsetWidth+a.defaultbuttons.rightnav[1]+c,top:a.offsets.top+a.defaultbuttons.rightnav[2]+c,cursor:"hand",cursor:"pointer"}).attr({title:"Forward "+a.defaultbuttons.moveby+" panels"}).appendTo("body");a.$leftnavbutton.bind("click",function(){stepcarousel.stepBy(a.galleryid,-a.defaultbuttons.moveby)});a.$rightnavbutton.bind("click",function(){stepcarousel.stepBy(a.galleryid,a.defaultbuttons.moveby)});a.panelbehavior.wraparound==false&&this.fadebuttons(a,b);return a.$leftnavbutton.add(a.$rightnavbutton)})(jQuery)},alignpanels:function(f,a){var b="px",e=this,c=0;a.paneloffsets=[c];a.panelwidths=[];a.$panels.each(function(){var d=f(this);d.css({"float":"none",position:"absolute",left:c+b});d.bind("click",function(b){return a.onpanelclick(b.target)});c+=stepcarousel.getCSSValue(d.css("marginRight"))+parseInt(d.get(0).offsetWidth||d.css("width"));a.paneloffsets.push(c);a.panelwidths.push(c-a.paneloffsets[a.paneloffsets.length-2])});a.paneloffsets.pop();var i=0,g=a.$panels.length-1;a.lastvisiblepanel=g;for(var d=a.$panels.length-1;d>=0;d--){i+=d==g?a.panelwidths[g]:a.paneloffsets[d+1]-a.paneloffsets[d];if(a.gallerywidth>i)a.lastvisiblepanel=d}a.$belt.css({width:c+b});a.currentpanel=a.panelbehavior.persist?parseInt(e.getCookie(a.galleryid+"persist")):0;a.currentpanel=typeof a.currentpanel=="number"&&a.currentpanel<a.$panels.length?a.currentpanel:0;var k=a.paneloffsets[a.currentpanel]+(a.currentpanel==0?0:a.beltoffset);a.$belt.css({left:-k+b});if(a.defaultbuttons.enable==true){var j=e.addnavbuttons(f,a,a.currentpanel);f(window).bind("load resize",function(){a.offsets={left:stepcarousel.getoffset(a.$gallery.get(0),"offsetLeft"),top:stepcarousel.getoffset(a.$gallery.get(0),"offsetTop")};a.$leftnavbutton.css({left:a.offsets.left+a.defaultbuttons.leftnav[1]+b,top:a.offsets.top+a.defaultbuttons.leftnav[2]+b});a.$rightnavbutton.css({left:a.offsets.left+a.$gallery.get(0).offsetWidth+a.defaultbuttons.rightnav[1]+b,top:a.offsets.top+a.defaultbuttons.rightnav[2]+b})})}if(a.autostep&&a.autostep.enable){var h=a.$gallery.add(typeof j!="undefined"?j:null);h.bind("click",function(){a.autostep.status="stopped";stepcarousel.stopautostep(a)});h.hover(function(){stepcarousel.stopautostep(a);a.autostep.hoverstate="over"},function(){if(a.steptimer&&a.autostep.hoverstate=="over"&&a.autostep.status!="stopped"){a.steptimer=setInterval(function(){stepcarousel.autorotate(a.galleryid)},a.autostep.pause);a.autostep.hoverstate="out"}});a.steptimer=setInterval(function(){stepcarousel.autorotate(a.galleryid)},a.autostep.pause)}e.createpaginate(f,a);e.statusreport(a.galleryid);a.oninit();a.onslideaction(e)},stepTo:function(c,b){var a=stepcarousel.configholder[c];if(typeof a=="undefined")return;stepcarousel.stopautostep(a);var b=Math.min(b-1,a.paneloffsets.length-1),d=a.paneloffsets[b]+(b==0?0:a.beltoffset);a.panelbehavior.wraparound==false&&a.defaultbuttons.enable==true&&this.fadebuttons(a,b);a.$belt.animate({left:-d+"px"},a.panelbehavior.speed,function(){a.onslideaction(this)});a.currentpanel=b;this.statusreport(c)},stepBy:function(f,h,i){var e="back",d="forward",a=stepcarousel.configholder[f];if(typeof a=="undefined")return;!i&&stepcarousel.stopautostep(a);var c=h>0?d:e,b=a.currentpanel+h;if(a.panelbehavior.wraparound==false){b=c==e&&b<=0?0:c==d?Math.min(b,a.lastvisiblepanel):b;a.defaultbuttons.enable==true&&stepcarousel.fadebuttons(a,b)}else if(b>a.lastvisiblepanel&&c==d)b=a.currentpanel<a.lastvisiblepanel?a.lastvisiblepanel:0;else if(b<0&&c==e)b=a.currentpanel>0?0:a.lastvisiblepanel;var g=a.paneloffsets[b]+(b==0?0:a.beltoffset);if(a.panelbehavior.wraparound==true&&a.panelbehavior.wrapbehavior=="pushpull"&&(b==0&&c==d||a.currentpanel==0&&c==e))a.$belt.animate({left:-a.paneloffsets[a.currentpanel]-(c==d?100:-30)+"px"},"normal",function(){a.$belt.animate({left:-g+"px"},a.panelbehavior.speed,function(){a.onslideaction(this)})});else a.$belt.animate({left:-g+"px"},a.panelbehavior.speed,function(){a.onslideaction(this)});a.currentpanel=b;this.statusreport(f)},autorotate:function(a){var b=stepcarousel.configholder[a];this.stepBy(a,b.autostep.moveby,true)},stopautostep:function(a){clearTimeout(a.steptimer)},statusreport:function(g){var a=stepcarousel.configholder[g];if(a.statusvars.length==3){for(var d=a.currentpanel,e=0,b=d;b<a.paneloffsets.length;b++){e+=a.panelwidths[b];if(e>a.gallerywidth)break}d+=1;b=b+1==d?d:b;for(var f=[d,b,a.panelwidths.length],c=0;c<a.statusvars.length;c++){window[a.statusvars[c]]=f[c];a.$statusobjs[c].text(f[c]+" ")}}stepcarousel.selectpaginate(jQuery,g)},createpaginate:function(c,a){var e="data-over";if(a.$paginatediv.length==1){var b=a.$paginatediv.find('img["data-over"]:eq(0)'),h=[],m=[],j=[],f=b.attr("data-moveby")||1,l=(f==1?0:1)+Math.floor((a.lastvisiblepanel+1)/f),k=c("<div>").append(b.clone()).html();srcs=[b.attr("src"),b.attr(e),b.attr("data-select")];for(var d=0;d<l;d++){var g=Math.min(d*f,a.lastvisiblepanel);j.push(k.replace(/>$/,' data-index="'+d+'" data-moveto="'+g+'" title="Move to Panel '+(g+1)+'">')+"\n");h.push(g)}var i=c("<span></span>").replaceAll(b).append(j.join("")).find("img");i.css({cursor:"pointer"});a.$paginatediv.bind("click",function(d){var b=c(d.target);b.is("img")&&b.attr(e)&&stepcarousel.stepTo(a.galleryid,parseInt(b.attr("data-moveto"))+1)});a.$paginatediv.bind("mouseover mouseout",function(d){var b=c(d.target);if(b.is("img")&&b.attr(e))parseInt(b.attr("data-index"))!=a.pageinfo.curselected&&b.attr("src",srcs[d.type=="mouseover"?1:0])});a.pageinfo={controlpoints:h,$controls:i,srcs:srcs,prevselected:null,curselected:null}}},selectpaginate:function(d,c){var a=stepcarousel.configholder[c];if(a.$paginatediv.length==1){for(var b=0;b<a.pageinfo.controlpoints.length;b++)if(a.pageinfo.controlpoints[b]<=a.currentpanel)a.pageinfo.curselected=b;typeof a.pageinfo.prevselected!=null&&a.pageinfo.$controls.eq(a.pageinfo.prevselected).attr("src",a.pageinfo.srcs[0]);a.pageinfo.$controls.eq(a.pageinfo.curselected).attr("src",a.pageinfo.srcs[2]);a.pageinfo.prevselected=a.pageinfo.curselected}},loadcontent:function(b,c){var a=stepcarousel.configholder[b];a.contenttype=["ajax",c];stepcarousel.stopautostep(a);stepcarousel.resetsettings($,a);stepcarousel.init(jQuery,a)},init:function(b,a){var c="undefined";a.gallerywidth=a.$gallery.width();a.offsets={left:stepcarousel.getoffset(a.$gallery.get(0),"offsetLeft"),top:stepcarousel.getoffset(a.$gallery.get(0),"offsetTop")};a.$belt=a.$gallery.find("."+a.beltclass);a.$panels=a.$gallery.find("."+a.panelclass);a.panelbehavior.wrapbehavior=a.panelbehavior.wrapbehavior||"pushpull";a.$paginatediv=b("#"+a.galleryid+"-paginate");if(a.autostep)a.autostep.pause+=a.panelbehavior.speed;a.onpanelclick=typeof a.onpanelclick==c?function(){}:a.onpanelclick;a.onslideaction=typeof a.onslide==c?function(){}:function(c){b(c).stop();a.onslide()};a.oninit=typeof a.oninit==c?function(){}:a.oninit;a.beltoffset=stepcarousel.getCSSValue(a.$belt.css("marginLeft"));a.statusvars=a.statusvars||[];a.$statusobjs=[b("#"+a.statusvars[0]),b("#"+a.statusvars[1]),b("#"+a.statusvars[2])];a.currentpanel=0;stepcarousel.configholder[a.galleryid]=a;if(a.contenttype[0]=="ajax"&&typeof a.contenttype[1]!=c)stepcarousel.getremotepanels(b,a);else stepcarousel.alignpanels(b,a)},resetsettings:function(b,a){a.$gallery.unbind();a.$belt.stop();a.$panels.remove();if(a.$leftnavbutton){a.$leftnavbutton.remove();a.$rightnavbutton.remove()}if(a.$paginatediv.length==1){a.$paginatediv.unbind();a.pageinfo.$controls.eq(0).attr("src",a.pageinfo.srcs[0]).removeAttr("data-index").removeAttr("data-moveto").removeAttr("title").end().slice(1).remove()}if(a.autostep)a.autostep.status=null;a.panelbehavior.persist&&stepcarousel.setCookie(window[a.galleryid+"persist"],0)},setup:function(a){document.write('<style type="text/css">\n#'+a.galleryid+"{overflow: hidden;}\n</style>");jQuery(document).ready(function(b){a.$gallery=b("#"+a.galleryid);stepcarousel.init(b,a)});jQuery(window).bind("unload",function(){stepcarousel.resetsettings($,a);a.panelbehavior.persist&&stepcarousel.setCookie(a.galleryid+"persist",a.currentpanel);jQuery.each(a,function(b,a){a=null});a=null})}};
