function zxcStepCarousel(o) {
	var mde = typeof (o.Mode) == 'string'
			&& o.Mode.charAt(0).toUpperCase() == 'V' ? [ 'top', 'offsetHeight',
			'offsetTop', 'height' ] : [ 'left', 'offsetWidth', 'offsetLeft',
			'width' ];
	var obj = document.getElementById(o.ID), slide = obj
			.getElementsByTagName('DIV')[0], psz = obj[mde[1]], ssz = slide[mde[1]], ctr = typeof (o.Center) == 'boolean'
			&& o.Center;
	var elcls = typeof (o.ElementClassName) == 'string' ? o.ElementClassName
			: false, imgs = elcls && this.bycls(elcls, slide)[0] ? this.bycls(
			elcls, slide) : slide.getElementsByTagName('IMG');
	var z0, z1, z1a, z2, but, nu = 0, acls = typeof (o.ActiveClassName) == 'string' ? o.ActiveClassName
			: '', cls, clss = [];
	this.mde = mde;
	obj.style.overflow = 'hidden';
	slide.style[mde[3]] = ssz + 100 + 'px';
	this.imgs = imgs;
	this.imgnu = imgs.length - 1;
	this.pos = [];

	for (z0 = 0; z0 <= this.imgnu; z0++) {
		imgs[z0][mde[3]] += (imgs[z0][mde[3]] % 2 == 0 ? 0 : 1);

		if (z0 > 0) {
			this.pos[z0 - 1] = ctr ? (imgs[z0][mde[2]] + (imgs[z0][mde[1]]) / 2)
					- (imgs[z0 - 1][mde[2]] + (imgs[z0 - 1][mde[1]]) / 2)
					: imgs[z0][mde[2]] - imgs[z0 - 1][mde[2]];
		}
	}

	this.lstpos = [ (ctr ? (psz - imgs[0][mde[1]]) / 2 : 0) - imgs[0][mde[2]]
			- ssz + (typeof (o.Offset) == 'number' ? o.Offset : 0) ];
	this.pos.push(ctr ? ssz
			- (imgs[z0 - 1][mde[2]] + (imgs[z0 - 1][mde[1]]) / 2)
			+ imgs[0][mde[2]] + (imgs[0][mde[1]]) / 2 : imgs[0][mde[2]] + ssz
			- imgs[z0 - 1][mde[2]]);
	this.pos.reverse();
	this.slides = [];
	this.nu = Math.max(Math.ceil(psz / ssz + 2), 4);

	for (z1 = 0; z1 <= this.nu; z1++) {
		slide = z1 > 0 ? slide.cloneNode(true) : slide;
		slide.style[mde[0]] = this.lstpos[z1] + 'px';
		obj.appendChild(slide);
		this.slides[z1] = new zxcAnimate(mde[0], slide);
		imgs = elcls && this.bycls(elcls, slide)[0] ? this.bycls(elcls, slide)
				: slide.getElementsByTagName('IMG');

		for (z1a = 0; z1a < imgs.length; z1a++) {
			cls = imgs[z1a].className || '';
			clss.push([ imgs[z1a], cls, cls + ' ' + acls ]);
		}

		if (z1 < this.nu) {
			this.lstpos[z1 + 1] = this.lstpos[z1] + ssz;
		}
	}

	for (z2 = 0; z2 < clss.length; z2++) {
		this.addevt(clss[z2][0], 'mouseover', 'cngcls', clss[z2]);
		this.addevt(clss[z2][0], 'mouseout', 'cngcls', clss[z2]);
	}

	but = document.getElementById(o.BackID);

	if (but) {
		this.addevt(but, 'mouseup', 'Next', 1);
	}

	but = document.getElementById(o.ForwardID);

	if (but) {
		this.addevt(but, 'mouseup', 'Next', -1);
	}

	this.ssz = ssz;
	this.ctr = ctr;
	this.ud = -1;
	this.cnt = 0;
	this.to = null;
	this.cntF = -1;
	this.pages = [];

	if (o.Paginate) {
		this.Paginate(o.Paginate);
	}

	this.nme = o.ID + '=';
	this.days = typeof (o.DaysPersistance) == 'number' ? o.DaysPersistance
			: false;

	if (this.days && this.cookie && this.cookie(this.nme)) {
		this.ms = 50;
		nu = this.cookie(this.nme) * 1;

		for ( var z5 = 0; z5 < nu; z5++) {
			this.Next(-1);
		}
	}

	this.ms = typeof (o.AnimationSpeed) == 'number' ? o.AnimationSpeed : 1000;
	this.hold = typeof (o.AutoRotateHold) == 'number' ? o.AutoRotateHold
			+ this.ms : this.ms * 4;

	if (typeof (o.AutoRotateEvents) == 'boolean' && o.AutoRotateEvents) {
		this.addevt(obj, 'mouseover', 'Pause');
		this.addevt(obj, 'mouseout', 'Auto');
	}

	if (typeof (o.AutoRotateStart) == 'boolean' && o.AutoRotateStart) {
		this.Auto(this.hold);
	}
}

zxcStepCarousel.prototype = {
	Next : function(ud) {
		this.Pause();
		this.lstcnt = this.cnt;
		ud = typeof (ud) == 'number' && ud < 0 ? -1 : 1;
		this.cnt = this.ckcnt(this.cnt -= ud);
		this.cntF = this.ckcnt(this.cntF += ud);
		this.moveby = this.pos[ud < 0 ? this.cntF : this.ckcnt(this.cntF - 1)];
		this.ud = ud;
		this.slide(ud);
	},

	Auto : function(ms) {
		this.Pause();
		var oop = this;
		this.to = setTimeout(function() {
			oop.auto();
		}, ms || 500);
	},

	Pause : function() {
		clearTimeout(this.to);
	},

	GoTo : function(nu) {
		if (this.imgs[nu]) {
			var mde = this.mde, ud = this.ud;
			this.Pause();
			this.lstcnt = this.cnt;
			this.moveby = (this.imgs[nu][mde[2]] + (this.ctr ? this.imgs[nu][mde[1]] / 2
					: 0))
					- (this.imgs[this.cnt][mde[2]] + (this.ctr ? this.imgs[this.cnt].offsetWidth / 2
							: 0));
			this.ud = -1;
			this.cnt = nu;
			this.cntF = nu;
			this.slide();
			this.ud = ud;
		}
	},

	slide : function() {
		for ( var moveby = this.moveby * this.ud, z0 = 0; z0 <= this.nu; z0++) {
			this.slides[z0].animate(this.lstpos[z0], this.lstpos[z0] + moveby,
					this.ms, [ 0, this.pos[0] ]);
			this.lstpos[z0] += moveby;

			if ((this.ud > 0 && this.lstpos[z0] > this.ssz * (this.nu - 2))
					|| (this.ud < 0 && this.lstpos[z0] < -this.ssz * 2)) {
				this.lstpos[z0] -= (this.ssz * this.nu * this.ud);
			}
		}

		if (this.pages[this.cnt]) {
			this.pages[this.lstcnt].className = this.defcls;
			this.pages[this.cnt].className = this.actcls;
		}

		if (this.days && this.cookie) {
			document.cookie = this.nme
					+ this.cnt
					+ ';expires='
					+ (new Date(new Date().getTime() + this.days * 86400000)
							.toGMTString()) + ';path=/';
		}
	},

	ckcnt : function(cnt) {
		var nu = this.imgnu;
		return cnt < 0 ? nu : cnt > nu ? 0 : cnt;
	},

	auto : function(nu) {
		this.Next(this.ud);
		var oop = this;
		this.to = setTimeout(function() {
			oop.auto();
		}, this.hold);
	},

	cngcls : function(data, e) {
		data[0].className = data[e.type == 'mouseover' ? 2 : 1];
	},

	addevt : function(o, t, f, p) {
		var oop = this;
		if (o.addEventListener)
			o.addEventListener(t, function(e) {
				return oop[f](p, e);
			}, false);
		else if (o.attachEvent)
			o.attachEvent('on' + t, function(e) {
				return oop[f](p, e);
			});
	},

	bycls : function(nme, el) {
		for ( var reg = new RegExp('\\b' + nme + '\\b'), els = el
				.getElementsByTagName('*'), ary = [], z0 = 0; z0 < els.length; z0++) {
			if (reg.test(els[z0].className)) {
				ary.push(els[z0]);
			}
		}
		return ary;
	},

	// Optional Paginate Code.
	Paginate : function(o) {
		var obj = document.getElementById(o.ID);
		if (obj) {
			this.defcls = o.DefaultClassName;
			this.msecls = this.defcls + ' ' + (o.MouseOverClassName || '');
			this.actcls = this.defcls + ' ' + (o.ActiveClassName || '');
			var ps = this.bycls(this.defcls, obj);
			if (!ps[0]) {
				ps[0] = document.createElement(o.NodeName || 'DIV');
				obj.appendChild(ps[0]);
			}
			var c = ps[0].cloneNode(true), html = o.HTML || [];
			for ( var z0 = 0; z0 < this.nu; z0++) {
				if (!ps[z0]) {
					ps[z0] = document.createElement(ps[0].nodeName);
					obj.appendChild(ps[z0]);
				}
				p = ps[z0];
				ps[z0].className = z0 != this.cnt ? this.defcls : this.actcls;
				if (html[z0]) {
					ps[z0].innerHTML = html[z0];
				}
				this.addevt(ps[z0], 'mouseup', 'GoTo', z0);
				this.addevt(ps[z0], 'mouseover', 'mse', z0);
				this.addevt(ps[z0], 'mouseout', 'mse', z0);
				this.pages[z0] = ps[z0];
			}
		}
	},

	mse : function(nu, e) {
		if (nu != this.cnt) {
			this.pages[nu].className = e.type == 'mouseout' ? this.defcls
					: this.msecls;
		}
	},

	// Optional Persistence Code.
	cookie : function(nme) {
		var split = document.cookie.split(';'), s, z0;
		for (z0 = 0; z0 < split.length; z0++) {
			s = split[z0];
			while (s.charAt(0) == ' ') {
				s = s.substring(1, s.length);
			}
			if (s.indexOf(nme) == 0) {
				return s.substring(nme.length, s.length);
			}
		}
		return null;
	}
}

