var stepcarousel={ajaxloadingmsg:'<div style="margin: 1em; font-weight: bold"><img src="ajaxloadr.gif" style="vertical-align: middle" /> Fetching Content. Please wait...</div>',defaultbuttonsfade:0,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(c){a.$belt.html("Error fetching content.<br />Server Response: "+c.responseText)},success:function(c){a.$belt.html(c);a.$panels=a.$gallery.find("."+a.panelclass);stepcarousel.alignpanels(b,a)}})},getoffset:function(b,a){return(b.offsetParent)?b[a]+this.getoffset(b.offsetParent,a):b[a]},getCookie:function(a){var b=new RegExp(a+"=[^;]+","i");if(document.cookie.match(b)){return document.cookie.match(b)[0].split("=")[1]}return null},setCookie:function(a,b){document.cookie=a+"="+b},fadebuttons:function(a,b){if(b==0){a.$leftnavbutton.addClass("carouselButtonHidden")}else{a.$leftnavbutton.removeClass("carouselButtonHidden")}if(b==a.lastvisiblepanel){a.$rightnavbutton.addClass("carouselButtonHidden")}else{a.$rightnavbutton.removeClass("carouselButtonHidden")}},addnavbuttons:function(a,b){a.$leftnavbutton=$('<img class="carouselButton" src="'+a.defaultbuttons.leftnav[0]+'">').css({zIndex:50,position:"absolute",left:a.offsets.left+a.defaultbuttons.leftnav[1]+"px",top:a.offsets.top+a.defaultbuttons.leftnav[2]+"px",cursor:"hand",cursor:"pointer"}).attr({title:"Back "+a.defaultbuttons.moveby+" panels"}).appendTo("body");a.$rightnavbutton=$('<img class="carouselButton" src="'+a.defaultbuttons.rightnav[0]+'">').css({zIndex:50,position:"absolute",left:a.offsets.left+a.$gallery.get(0).offsetWidth+a.defaultbuttons.rightnav[1]+"px",top:a.offsets.top+a.defaultbuttons.rightnav[2]+"px",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)});if(a.panelbehavior.wraparound==false){this.fadebuttons(a,b)}return a.$leftnavbutton.add(a.$rightnavbutton)},stopautostep:function(a){clearTimeout(a.steptimer);clearTimeout(a.resumeautostep)},alignpanels:function(c,a){var g=0;a.paneloffsets=[g];a.panelwidths=[];a.$panels.each(function(i){var k=c(this);k.css({"float":"none",position:"absolute",left:g+"px"});k.bind("click",function(l){return a.onpanelclick(l.target)});g+=stepcarousel.getCSSValue(k.css("marginRight"))+parseInt(k.get(0).offsetWidth||k.css("width"));a.paneloffsets.push(g);a.panelwidths.push(g-a.paneloffsets[a.paneloffsets.length-2])});a.paneloffsets.pop();var e=0;var h=a.$panels.length-1;a.lastvisiblepanel=h;for(var d=a.$panels.length-1;d>=0;d--){e+=(d==h?a.panelwidths[h]:a.paneloffsets[d+1]-a.paneloffsets[d]);if(a.gallerywidth>e){a.lastvisiblepanel=d}}a.$belt.css({width:g+"px"});a.currentpanel=(a.panelbehavior.persist)?parseInt(this.getCookie(window[a.galleryid+"persist"])):0;a.currentpanel=(typeof a.currentpanel=="number"&&a.currentpanel<a.$panels.length)?a.currentpanel:0;if(a.currentpanel!=0){var j=a.paneloffsets[a.currentpanel]+(a.currentpanel==0?0:a.beltoffset);a.$belt.css({left:-j+"px"})}if(a.defaultbuttons.enable==true){var b=this.addnavbuttons(a,a.currentpanel);c(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]+"px",top:a.offsets.top+a.defaultbuttons.leftnav[2]+"px"});a.$rightnavbutton.css({left:a.offsets.left+a.$gallery.get(0).offsetWidth+a.defaultbuttons.rightnav[1]+"px",top:a.offsets.top+a.defaultbuttons.rightnav[2]+"px"})})}if(a.autostep&&a.autostep.enable){var f=a.$gallery.add(typeof b!="undefined"?b:null);f.bind("click",function(){stepcarousel.stopautostep(a);a.autostep.status="stopped"});f.hover(function(){stepcarousel.stopautostep(a);a.autostep.hoverstate="over"},function(){if(a.steptimer&&a.autostep.hoverstate=="over"&&a.autostep.status!="stopped"){a.resumeautostep=setTimeout(function(){stepcarousel.autorotate(a.galleryid);a.autostep.hoverstate="out"},500)}});a.steptimer=setTimeout(function(){stepcarousel.autorotate(a.galleryid)},a.autostep.pause)}this.statusreport(a.galleryid);a.oninit();a.onslideaction(this)},stepTo:function(c,b){var a=stepcarousel.configholder[c];if(typeof a=="undefined"){alert("There's an error with your set up of Carousel Viewer \""+c+'"!');return}stepcarousel.stopautostep(a);var b=Math.min(b-1,a.paneloffsets.length-1);var d=a.paneloffsets[b]+(b==0?0:a.beltoffset);if(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(d,a){var c=stepcarousel.configholder[d];if(typeof c=="undefined"){alert("There's an error with your set up of Carousel Viewer \""+d+'"!');return}stepcarousel.stopautostep(c);var e=(a>0)?"forward":"back";var b=c.currentpanel+a;if(c.panelbehavior.wraparound==false){b=(e=="back"&&b<=0)?0:(e=="forward")?Math.min(b,c.lastvisiblepanel):b;if(c.defaultbuttons.enable==true){stepcarousel.fadebuttons(c,b)}}else{if(b>c.lastvisiblepanel&&e=="forward"){b=(c.currentpanel<c.lastvisiblepanel)?c.lastvisiblepanel:0}else{if(b<0&&e=="back"){b=(c.currentpanel>0)?0:c.lastvisiblepanel}}}var f=c.paneloffsets[b]+(b==0?0:c.beltoffset);if(b==0&&e=="forward"||c.currentpanel==0&&e=="back"&&c.panelbehavior.wraparound==true){c.$belt.animate({left:-c.paneloffsets[c.currentpanel]-(e=="forward"?100:-30)+"px"},"normal",function(){c.$belt.animate({left:-f+"px"},c.panelbehavior.speed,function(){c.onslideaction(this)})})}else{c.$belt.animate({left:-f+"px"},c.panelbehavior.speed,function(){c.onslideaction(this)})}c.currentpanel=b;this.statusreport(d)},autorotate:function(b){var a=stepcarousel.configholder[b];if(a.$gallery.attr("_ismouseover")!="yes"){this.stepBy(b,a.autostep.moveby)}a.steptimer=setTimeout(function(){stepcarousel.autorotate(b)},a.autostep.pause)},statusreport:function(d){var b=stepcarousel.configholder[d];var a=b.currentpanel;var e=0;for(var f=a;f<b.paneloffsets.length;f++){e+=b.panelwidths[f];if(e>b.gallerywidth){break}}a+=1;f=(f+1==a)?a:f;var g=[a,f,b.panelwidths.length];for(var c=0;c<b.statusvars.length;c++){window[b.statusvars[c]]=g[c];b.$statusobjs[c].text(g[c]+" ")}},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);if(a.$gallery.length>0){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.wraparound=(a.autostep&&a.autostep.enable)?true:a.panelbehavior.wraparound;a.onpanelclick=(typeof a.onpanelclick=="undefined")?function(c){}:a.onpanelclick;a.onslideaction=(typeof a.onslide=="undefined")?function(){}:function(c){b(c).stop();a.onslide()};a.oninit=(typeof a.oninit=="undefined")?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]!="undefined"){stepcarousel.getremotepanels(b,a)}else{stepcarousel.alignpanels(b,a)}}});jQuery(window).bind("unload",function(){if(a.panelbehavior.persist){stepcarousel.setCookie(window[a.galleryid+"persist"],a.currentpanel)}jQuery.each(a,function(b,c){c=null});a=null})}};
