var stepcarousel={ajaxloadingmsg:'<div style="margin: 1em; font-weight: bold"><img src="ajaxloadr.gif" style="vertical-align: middle" /> Fetching Content. Please wait...</div>',configholder:{},getCSSValue:function(a){return(a=="auto")?0:parseInt(a);
},getremotepanels:function(a,b){b.$belt.html(this.ajaxloadingmsg);
a.ajax({url:b.contenttype[1],async:true,error:function(c){b.$belt.html("Error fetching content.<br />Server Response: "+c.responseText);
},success:function(c){b.$belt.html(c);
b.$panels=b.$gallery.find("."+b.panelclass);
stepcarousel.alignpanels(a,b);
}});
},alignpanels:function(a,b){var c=0;
b.paneloffsets=[c];
b.panelwidths=[];
b.$panels.each(function(e){var d=a(this);
d.css({"float":"none",position:"absolute",left:c+"px"});
d.bind("click",function(f){return b.onpanelclick(f.target);
});
c+=stepcarousel.getCSSValue(d.css("marginRight"))+parseInt(d.get(0).offsetWidth);
b.paneloffsets.push(c);
b.panelwidths.push(c-b.paneloffsets[b.paneloffsets.length-2]);
});
b.paneloffsets.pop();
b.$belt.css({width:c+"px"});
this.statusreport(b.galleryid);
b.oninit();
b.onslideaction(this);
},stepTo:function(c,d){var a=stepcarousel.configholder[c];
if(typeof a=="undefined"){alert("There's an error with your set up of Carousel Viewer \""+c+'"!');
return;
}var d=Math.min(d,a.paneloffsets.length);
var b=a.paneloffsets[d]+(d==0?0:a.beltoffset);
a.$belt.animate({left:-b+"px"},"slow",function(){a.onslideaction(this);
});
a.currentpanel=d;
this.statusreport(c);
},stepBy:function(d,f){var a=stepcarousel.configholder[d];
if(typeof a=="undefined"){alert("There's an error with your set up of Carousel Viewer \""+d+'"!');
return;
}var b=(f>0)?"forward":"back";
var e=a.currentpanel+f;
e=(e>a.paneloffsets.length-1||e<0&&e-f>0)?0:(e<0)?a.paneloffsets.length+f:e;
var c=a.paneloffsets[e]+(e==0?0:a.beltoffset);
if(e==0&&b=="forward"||a.currentpanel==0&&b=="back"){a.$belt.animate({left:-a.paneloffsets[a.currentpanel]-(b=="forward"?100:-30)+"px"},"normal",function(){a.$belt.animate({left:-c+"px"},"slow",function(){a.onslideaction(this);
});
});
}else{a.$belt.animate({left:-c+"px"},"slow",function(){a.onslideaction(this);
});
}a.currentpanel=e;
this.statusreport(d);
},statusreport:function(c){var a=stepcarousel.configholder[c];
var e=a.currentpanel;
var g=0;
for(var b=e;
b<a.paneloffsets.length;
b++){g+=a.panelwidths[b];
if(g>a.gallerywidth){break;
}}e+=1;
b=(b+1==e)?e:b;
var f=[e,b,a.panelwidths.length];
for(var d=0;
d<a.statusvars.length;
d++){window[a.statusvars[d]]=f[d];
a.$statusobjs[d].html(f[d]);
}},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);
a.gallerywidth=a.$gallery.width();
a.$belt=a.$gallery.find("."+a.beltclass);
a.$panels=a.$gallery.find("."+a.panelclass);
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(){jQuery.each(a,function(b,c){c=null;
});
a=null;
});
},reloadPanels:function(b,c){var a=stepcarousel.configholder[b];
a.gallerywidth=a.$gallery.width();
a.$panels=a.$gallery.find("."+a.panelclass);
stepcarousel.alignpanels($,a);
stepcarousel.stepTo(b,(c==null)?0:c);
}};


