
/**
 * ----------------------------------------------------------------------------- 
 * Создание MD5 из получаемой строки 
 *
 * Обращение к функции:
 * hex_md5(something); 
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('q I=0;r R(a){s O(S(J(a)))}r 19(a,b){s O(T(J(a),J(b)))}r 1a(){s R("1b").1c()=="1d"}r S(a){s P(D(K(a),a.x*8))}r T(c,f){q e=K(c);A(e.x>16){e=D(e,c.x*8)}q a=L(16),d=L(16);B(q b=0;b<16;b++){a[b]=e[b]^1e;d[b]=e[b]^1f}q g=D(a.U(K(f)),V+f.x*8);s P(D(d.U(g),V+z))}r O(c){1g{I}1h(g){I=0}q f=I?"1i":"1j";q b="";q a;B(q d=0;d<c.x;d++){a=c.M(d);b+=f.W((a>>>4)&15)+f.W(a&15)}s b}r J(c){q b="";q d=-1;q a,e;1k(++d<c.x){a=c.M(d);e=d+1<c.x?c.M(d+1):0;A(1l<=a&&a<=1m&&1n<=e&&e<=1o){a=1p+((a&X)<<10)+(e&X);d++}A(a<=1q){b+=E.F(a)}Q{A(a<=1r){b+=E.F(1s|((a>>>6)&1t),z|(a&C))}Q{A(a<=N){b+=E.F(1u|((a>>>12)&15),z|((a>>>6)&C),z|(a&C))}Q{A(a<=1v){b+=E.F(1w|((a>>>18)&7),z|((a>>>12)&C),z|((a>>>6)&C),z|(a&C))}}}}}s b}r K(b){q a=L(b.x>>2);B(q c=0;c<a.x;c++){a[c]=0}B(q c=0;c<b.x*8;c+=8){a[c>>5]|=(b.M(c/8)&Y)<<(c%G)}s a}r P(b){q a="";B(q c=0;c<b.x*G;c+=8){a+=E.F((b[c>>5]>>>(c%G))&Y)}s a}r D(p,k){p[k>>5]|=z<<((k)%G);p[(((k+1x)>>>9)<<4)+14]=k;q o=1y;q n=-1z;q m=-1A;q l=1B;B(q g=0;g<p.x;g+=16){q j=o;q h=n;q f=m;q e=l;o=t(o,n,m,l,p[g+0],7,-1C);l=t(l,o,n,m,p[g+1],12,-1D);m=t(m,l,o,n,p[g+2],17,1E);n=t(n,m,l,o,p[g+3],22,-1F);o=t(o,n,m,l,p[g+4],7,-1G);l=t(l,o,n,m,p[g+5],12,1H);m=t(m,l,o,n,p[g+6],17,-1I);n=t(n,m,l,o,p[g+7],22,-1J);o=t(o,n,m,l,p[g+8],7,1K);l=t(l,o,n,m,p[g+9],12,-1L);m=t(m,l,o,n,p[g+10],17,-1M);n=t(n,m,l,o,p[g+11],22,-1N);o=t(o,n,m,l,p[g+12],7,1O);l=t(l,o,n,m,p[g+13],12,-1P);m=t(m,l,o,n,p[g+14],17,-1Q);n=t(n,m,l,o,p[g+15],22,1R);o=u(o,n,m,l,p[g+1],5,-1S);l=u(l,o,n,m,p[g+6],9,-1T);m=u(m,l,o,n,p[g+11],14,1U);n=u(n,m,l,o,p[g+0],20,-1V);o=u(o,n,m,l,p[g+5],5,-1W);l=u(l,o,n,m,p[g+10],9,1X);m=u(m,l,o,n,p[g+15],14,-1Y);n=u(n,m,l,o,p[g+4],20,-1Z);o=u(o,n,m,l,p[g+9],5,24);l=u(l,o,n,m,p[g+14],9,-25);m=u(m,l,o,n,p[g+3],14,-26);n=u(n,m,l,o,p[g+8],20,27);o=u(o,n,m,l,p[g+13],5,-28);l=u(l,o,n,m,p[g+2],9,-29);m=u(m,l,o,n,p[g+7],14,2a);n=u(n,m,l,o,p[g+12],20,-2b);o=v(o,n,m,l,p[g+5],4,-2c);l=v(l,o,n,m,p[g+8],11,-2d);m=v(m,l,o,n,p[g+11],16,2e);n=v(n,m,l,o,p[g+14],23,-2f);o=v(o,n,m,l,p[g+1],4,-2g);l=v(l,o,n,m,p[g+4],11,2h);m=v(m,l,o,n,p[g+7],16,-2i);n=v(n,m,l,o,p[g+10],23,-2j);o=v(o,n,m,l,p[g+13],4,2k);l=v(l,o,n,m,p[g+0],11,-2l);m=v(m,l,o,n,p[g+3],16,-2m);n=v(n,m,l,o,p[g+6],23,2n);o=v(o,n,m,l,p[g+9],4,-2o);l=v(l,o,n,m,p[g+12],11,-2p);m=v(m,l,o,n,p[g+15],16,2q);n=v(n,m,l,o,p[g+2],23,-2r);o=w(o,n,m,l,p[g+0],6,-2s);l=w(l,o,n,m,p[g+7],10,2t);m=w(m,l,o,n,p[g+14],15,-2u);n=w(n,m,l,o,p[g+5],21,-2v);o=w(o,n,m,l,p[g+12],6,2w);l=w(l,o,n,m,p[g+3],10,-2x);m=w(m,l,o,n,p[g+10],15,-2y);n=w(n,m,l,o,p[g+1],21,-2z);o=w(o,n,m,l,p[g+8],6,2A);l=w(l,o,n,m,p[g+15],10,-2B);m=w(m,l,o,n,p[g+6],15,-2C);n=w(n,m,l,o,p[g+13],21,2D);o=w(o,n,m,l,p[g+4],6,-2E);l=w(l,o,n,m,p[g+11],10,-2F);m=w(m,l,o,n,p[g+2],15,2G);n=w(n,m,l,o,p[g+9],21,-2H);o=y(o,j);n=y(n,h);m=y(m,f);l=y(l,e)}s L(o,n,m,l)}r H(h,e,d,c,g,f){s y(Z(y(y(e,h),y(c,f)),g),d)}r t(g,f,k,j,e,i,h){s H((f&k)|((~f)&j),g,f,e,i,h)}r u(g,f,k,j,e,i,h){s H((f&j)|(k&(~j)),g,f,e,i,h)}r v(g,f,k,j,e,i,h){s H(f^k^j,g,f,e,i,h)}r w(g,f,k,j,e,i,h){s H(k^(f|(~j)),g,f,e,i,h)}r y(a,d){q c=(a&N)+(d&N);q b=(a>>16)+(d>>16)+(c>>16);s(b<<16)|(c&N)}r Z(a,b){s(a<<b)|(a>>>(G-b))};',62,168,'||||||||||||||||||||||||||var|function|return|md5_ff|md5_gg|md5_hh|md5_ii|length|safe_add|128|if|for|63|binl_md5|String|fromCharCode|32|md5_cmn|hexcase|str2rstr_utf8|rstr2binl|Array|charCodeAt|65535|rstr2hex|binl2rstr|else|hex_md5|rstr_md5|rstr_hmac_md5|concat|512|charAt|1023|255|bit_rol||||||||||hex_hmac_md5|md5_vm_test|abc|toLowerCase|900150983cd24fb0d6963f7d28e17f72|909522486|1549556828|try|catch|0123456789ABCDEF|0123456789abcdef|while|55296|56319|56320|57343|65536|127|2047|192|31|224|2097151|240|64|1732584193|271733879|1732584194|271733878|680876936|389564586|606105819|1044525330|176418897|1200080426|1473231341|45705983|1770035416|1958414417|42063|1990404162|1804603682|40341101|1502002290|1236535329|165796510|1069501632|643717713|373897302|701558691|38016083|660478335|405537848|||||568446438|1019803690|187363961|1163531501|1444681467|51403784|1735328473|1926607734|378558|2022574463|1839030562|35309556|1530992060|1272893353|155497632|1094730640|681279174|358537222|722521979|76029189|640364487|421815835|530742520|995338651|198630844|1126891415|1416354905|57434055|1700485571|1894986606|1051523|2054922799|1873313359|30611744|1560198380|1309151649|145523070|1120210379|718787259|343485551'.split('|'),0,{}));

/**
 * -----------------------------------------------------------------------------
 * jQuery Tooltip plugin 1.3 - Всплывающие подсказки
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 * http://docs.jquery.com/Plugins/Tooltip
 *
 * Copyright (c) 2006 - 2008 Jorn Zaefferer
 *
 * $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(b($){g 2={},c,l,C,D=$.1G.1H&&/1I\\s(5\\.5|6\\.)/.1J(1K.1L),K=L;$.j={w:L,1e:{T:"::",U:1M,t:L,1f:L,V:"",m:25,f:-15,W:0.1N,X:"j"},1O:b(){$.j.w=!$.j.w}};$.M.1g({j:b(7){7=$.1g({},$.j.1e,7);1h(7);d 3.E(b(){$.1i(3,"j",7);3.Y=2.9.k("W");3.Z=3.l;$(3).1P("l");3.1Q=""}).1R(1j).1S(o).1T(o)},N:D?b(){d 3.E(b(){g O=$(3).k(\'10\');a(O.1U(/^p\\(["\']?(.*\\.1V)["\']?\\)$/i)){O=1W.$1;$(3).k({\'10\':\'1X\',\'1k\':"1Y:1Z.20.21(22=23, 24=26, 1l=\'"+O+"\')"}).E(b(){g F=$(3).k(\'F\');a(F!=\'27\'&&F!=\'1m\')$(3).k(\'F\',\'1m\')})}})}:b(){d 3},1n:D?b(){d 3.E(b(){$(3).k({\'1k\':\'\',10:\'\'})})}:b(){d 3},1o:b(){d 3.E(b(){$(3)[$(3).G()?"n":"o"]()})},p:b(){d 3.1p(\'28\')||3.1p(\'1l\')}});b 1h(7){a(2.9)d;2.9=$(\'<u X="\'+7.X+\'"><11></11><u 1q="e"></u><u 1q="p"></u></u>\').29(P.e).o();a($.M.Q)2.9.Q();2.l=$(\'11\',2.9);2.e=$(\'u.e\',2.9);2.p=$(\'u.p\',2.9)}b 7(1r){d $.1i(1r,"j")}b 1s(q){a(7(3).U)C=2a(n,7(3).U);r n();K=!!7(3).K;$(P.e).2b(\'12\',z);z(q)}b 1j(){a($.j.w||3==c||(!3.Z&&!7(3).13))d;c=3;l=3.Z;a(7(3).13){2.l.o();g H=7(3).13.2c(3);a(H.2d||H.2e){2.e.1t().14(H)}r{2.e.G(H)}2.e.n()}r a(7(3).T){g 16=l.2f(7(3).T);2.l.G(16.2g()).n();2.e.1t();2h(g i=0,17;(17=16[i]);i++){a(i>0)2.e.14("<2i/>");2.e.14(17)}2.e.1o()}r{2.l.G(l).n();2.e.o()}a(7(3).1f&&$(3).p())2.p.G($(3).p().2j(\'2k://\',\'\')).n();r 2.p.o();2.9.18(7(3).V);a(7(3).N)2.9.N();1s.2l(3,2m)}b n(){C=19;a((!D||!$.M.Q)&&7(c).t){a(2.9.R(":1u"))2.9.1a().n().1b(7(c).t,c.Y);r 2.9.R(\':1v\')?2.9.1b(7(c).t,c.Y):2.9.2n(7(c).t)}r{2.9.n()}z()}b z(q){a($.j.w)d;a(q&&q.2o.2p=="2q"){d}a(!K&&2.9.R(":1v")){$(P.e).1w(\'12\',z)}a(c==19){$(P.e).1w(\'12\',z);d}2.9.1c("A-B").1c("A-1x");g f=2.9[0].1y;g m=2.9[0].1z;a(q){f=q.2r+7(c).f;m=q.2s+7(c).m;g B=\'1A\';a(7(c).2t){B=$(I).1B()-f;f=\'1A\'}2.9.k({f:f,B:B,m:m})}g v=A(),h=2.9[0];a(v.x+v.1C<h.1y+h.1D){f-=h.1D+7(c).f;2.9.k({f:f+\'1d\'}).18("A-B")}a(v.y+v.1E<h.1z+h.1F){m-=h.1F+8+7(c).m;2.9.k({m:m+\'1d\'}).18("A-1x");2.9.k({f:f-4+\'1d\'})}}b A(){d{x:$(I).2u(),y:$(I).2v(),1C:$(I).1B(),1E:$(I).2w()}}b o(q){a($.j.w)d;a(C)2x(C);c=19;g J=7(3);b S(){2.9.1c(J.V).o().k("W","")}a((!D||!$.M.Q)&&J.t){a(2.9.R(\':1u\'))2.9.1a().1b(J.t,0,S);r 2.9.1a().2y(J.t,S)}r S();a(7(3).N)2.9.1n()}})(2z);',62,160,'||helper|this||||settings||parent|if|function|current|return|body|left|var|||tooltip|css|title|top|show|hide|url|event|else||fade|div||blocked|||update|viewport|right|tID|IE|each|position|html|bodyContent|window|tsettings|track|false|fn|fixPNG|image|document|bgiframe|is|complete|showBody|delay|extraClass|opacity|id|tOpacity|tooltipText|backgroundImage|h3|mousemove|bodyHandler|append||parts|part|addClass|null|stop|fadeTo|removeClass|px|defaults|showURL|extend|createHelper|data|save|filter|src|relative|unfixPNG|hideWhenEmpty|attr|class|element|handle|empty|animated|visible|unbind|bottom|offsetLeft|offsetTop|auto|width|cx|offsetWidth|cy|offsetHeight|browser|msie|MSIE|test|navigator|userAgent|200|85|block|removeAttr|alt|mouseover|mouseout|click|match|png|RegExp|none|progid|DXImageTransform|Microsoft|AlphaImageLoader|enabled|true|sizingMethod||crop|absolute|href|appendTo|setTimeout|bind|call|nodeType|jquery|split|shift|for|br|replace|http|apply|arguments|fadeIn|target|tagName|OPTION|pageX|pageY|positionLeft|scrollLeft|scrollTop|height|clearTimeout|fadeOut|jQuery'.split('|'),0,{}));

/**
 * -----------------------------------------------------------------------------
 * Step Carousel Viewer- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com
 * Script Download/ http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm
 * Usage Terms: http://www.dynamicdrive.com/notice.htm
 * Current version (Sept 29th, 09'): 1.8 See http://www.dynamicdrive.com/dynamicindex4/stepcarouselchangelog.txt for details
 */
var stepcarousel={
	ajaxloadingmsg: '<div style="margin: 1em; font-weight: bold"><img src="/templates/images/loading.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)
		if (currentpanel==config.lastvisiblepanel){
			stepcarousel.stopautostep(config)
		}

	},

	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:'Назад на '+config.defaultbuttons.moveby+' кадр'}).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:'Вперед на '+config.defaultbuttons.moveby+' кадр'}).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)
		}
		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(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
		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
			var $navbuttons=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'})
			})
		}
		if (config.autostep && config.autostep.enable){ //enable auto stepping of Carousel?		
			var $carouselparts=config.$gallery.add(typeof $navbuttons!="undefined"? $navbuttons : null)
			$carouselparts.bind('click', function(){
				config.autostep.status="stopped"
				stepcarousel.stopautostep(config)
			})
			$carouselparts.hover(function(){ //onMouseover
				stepcarousel.stopautostep(config)
				config.autostep.hoverstate="over"
			}, function(){ //onMouseout
				if (config.steptimer && config.autostep.hoverstate=="over" && config.autostep.status!="stopped"){
					config.steptimer=setInterval(function(){stepcarousel.autorotate(config.galleryid)}, config.autostep.pause)
					config.autostep.hoverstate="out"
				}
			})
			config.steptimer=setInterval(function(){stepcarousel.autorotate(config.galleryid)}, config.autostep.pause) //automatically rotate Carousel Viewer
		} //end enable auto stepping check
		this.createpaginate($, config)
		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
		}
		stepcarousel.stopautostep(config)
		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, isauto){
		var config=stepcarousel.configholder[galleryid]
		if (typeof config=="undefined"){
			//alert("There's an error with your set up of Carousel Viewer \""+galleryid+ "\"!")
			return
		}
		if (!isauto) //if stepBy() function isn't called by autorotate() function
			stepcarousel.stopautostep(config)
		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
			if (pindex>config.lastvisiblepanel && direction=="forward"){
				//if destination pindex is greater than last visible panel, yet we're currently not at the end of the carousel yet
				pindex=(config.currentpanel<config.lastvisiblepanel)? config.lastvisiblepanel : 0
			}
			else if (pindex<0 && direction=="back"){
				//if destination pindex is less than 0, yet we're currently not at the beginning of the carousel yet
				pindex=(config.currentpanel>0)? 0 : config.lastvisiblepanel /*wrap around left*/
			}
		}
		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)
	},

	autorotate:function(galleryid){
		var config=stepcarousel.configholder[galleryid]
		this.stepBy(galleryid, config.autostep.moveby, true)
	},

	stopautostep:function(config){
		clearTimeout(config.steptimer)
	},

	statusreport:function(galleryid){
		var config=stepcarousel.configholder[galleryid]
		if (config.statusvars.length==3){ //if 3 status vars defined
			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
			}
		}
		stepcarousel.selectpaginate(jQuery, galleryid)
	},

	createpaginate:function($, config){
		if (config.$paginatediv.length==1){
			var $templateimg=config.$paginatediv.find('img["data-over"]:eq(0)') //reference first matching image on page
			var controlpoints=[], controlsrc=[], imgarray=[], moveby=$templateimg.attr("data-moveby") || 1
			var asize=(moveby==1? 0:1) + Math.floor((config.lastvisiblepanel+1) / moveby) //calculate # of pagination links to create
			var imghtml=$('<div>').append($templateimg.clone()).html() //get HTML of first matching image
			srcs=[$templateimg.attr('src'), $templateimg.attr('data-over'), $templateimg.attr('data-select')] //remember control's over and out, and selected image src
			for (var i=0; i<asize; i++){
				var moveto=Math.min(i*moveby, config.lastvisiblepanel)
				imgarray.push(imghtml.replace(/>$/, ' data-index="'+i+'" data-moveto="'+moveto+'" title="Move to Panel '+(moveto+1)+'">') +'\n')
				controlpoints.push(moveto) //store panel index each control goes to when clicked on
			}
			var $controls=$('<span></span>').replaceAll($templateimg).append(imgarray.join('')).find('img') //replace template link with links and return them
			$controls.css({cursor:'pointer'})
			config.$paginatediv.bind('click', function(e){
				var $target=$(e.target)
				if ($target.is('img') && $target.attr('data-over')){
					stepcarousel.stepTo(config.galleryid, parseInt($target.attr('data-moveto'))+1)
				}
			})
			config.$paginatediv.bind('mouseover mouseout', function(e){
				var $target=$(e.target)
				if ($target.is('img') && $target.attr('data-over')){
					if (parseInt($target.attr('data-index')) != config.pageinfo.curselected) //if this isn't the selected link
						$target.attr('src', srcs[(e.type=="mouseover")? 1 : 0])
				}
			})
			config.pageinfo={controlpoints:controlpoints, $controls:$controls,  srcs:srcs, prevselected:null, curselected:null}
		}
	},

	
	selectpaginate:function($, galleryid){
		var config=stepcarousel.configholder[galleryid]
		if (config.$paginatediv.length==1){
			for (var i=0; i<config.pageinfo.controlpoints.length; i++){
				if (config.pageinfo.controlpoints[i] <= config.currentpanel) //find largest control point that's less than or equal to current panel shown
					config.pageinfo.curselected=i
			}
			if (typeof config.pageinfo.prevselected!=null) //deselect previously selected link (if found)
				config.pageinfo.$controls.eq(config.pageinfo.prevselected).attr('src', config.pageinfo.srcs[0])
			config.pageinfo.$controls.eq(config.pageinfo.curselected).attr('src', config.pageinfo.srcs[2]) //select current paginate link
			config.pageinfo.prevselected=config.pageinfo.curselected //set current selected link to previous
		}
	},


	loadcontent:function(galleryid, url){
		var config=stepcarousel.configholder[galleryid]
		config.contenttype=['ajax', url]
		stepcarousel.stopautostep(config)
		stepcarousel.resetsettings($, config)
		stepcarousel.init(jQuery, config)

	},

	init:function($, config){
		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.$paginatediv=$('#'+config.galleryid+'-paginate') //get pagination DIV (if defined)
		if (config.autostep)
			config.autostep.pause+=config.panelbehavior.speed
		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
	},

	resetsettings:function($, config){
		config.$gallery.unbind()
		config.$belt.stop()
		config.$panels.remove()
		if (config.$leftnavbutton){
			config.$leftnavbutton.remove()
			config.$rightnavbutton.remove()
		}
		if (config.$paginatediv.length==1){
			config.$paginatediv.unbind()
			config.pageinfo.$controls.eq(0).attr('src', config.pageinfo.srcs[0]).removeAttr('data-index').removeAttr('data-moveto').removeAttr('title') //reset first pagination link so it acts as template again
			.end().slice(1).remove() //then remove all but first pagination link
		}
		if (config.autostep)
			config.autostep.status=null
		if (config.panelbehavior.persist){
			stepcarousel.setCookie(window[config.galleryid+"persist"], 0) //set initial panel to 0, overridden w/ current panel if window.unload is invoked
		}
	},

	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)
			stepcarousel.init($, config)
		}) //end document.ready
		jQuery(window).bind('unload', function(){ //clean up on page unload
			stepcarousel.resetsettings($, config)
			if (config.panelbehavior.persist)
				stepcarousel.setCookie(config.galleryid+"persist", config.currentpanel)
			jQuery.each(config, function(ai, oi){
				oi=null
			})
			config=null
		})
	}
};



