	var preLoadingRotator = new Class ({
		_pos: 0,
		_play: 1,
		_current: 1,
		_periodical: 1,
		_imgTotal: 0,
		_fadeImgOut: 0,
		_fadeImgIn: 0,
		_imgSrcs: [],


		Implements:[Options],
		
		options: {
			images: [],
			preloader: null,
			period: 0,
			fadeTime: 0
		},
		
		initialize: function(options) {
				this.setOptions(options);
				this._per = null;
				this._imgTotal = this.options.images.length-1;
			
				_imgSrcs = new Array();
				var tthis = this;

				//place image sources into an array for preloading
				this.options.images.each(function (el,l) {
					_imgSrcs[l] = el.src;
					// add buttons
					if ($('slide-buttons')) {
						var myButton = new Element('span', { 'html':l+1, 'id': 'button-'+l, 'class':'slide-buton-normal', 
						    'events': {
						        mouseenter: function() {
						        	if (!myButton.hasClass('slide-buton-activ')) myButton.addClass('slide-buton-hover');
								},
								mouseleave: function() {
									myButton.removeClass('slide-buton-hover');
								},
								click: function() {
									$('button-'+tthis._pos).removeClass('slide-buton-activ');
									$('button-'+l).addClass('slide-buton-activ');
									tthis.show(l);
								}
						    }
						});
						$('slide-buttons').grab(myButton);
					}
				});
				
				//pre load images from array once complete begin fade and remove preloading div
				var myImages = new Asset.images(_imgSrcs, {
					onComplete: function() {
						this.options.preloader.setStyle('visibility', 'hidden');
						this.options.images[0].setStyle('visibility', 'visible');
						this.options.images[0].setStyle('opacity', 1);
						$('button-0').addClass('slide-buton-activ');
						this._per = this.fadeImages.periodical(this.options.period, this);	
					}.bind(this)	
				});	
		},
				
				
		fadeImages: function() {
			//if last image reset to start of sequence
//			alert(this._pos);
			if (this._pos == this._imgTotal) {
				this._fadeImgOut=this._imgTotal;
				this._fadeImgIn=0;
				this._pos = 0;
			}
			//else move to next image and fade out current
			else {
				this._fadeImgOut=this._pos;
				this._fadeImgIn=this._pos+1;
				this._pos ++;
			}
			
			//do actual image fading
			var fadeOut = new Fx.Tween(this.options.images[this._fadeImgOut], {duration: this.options.fadeTime});
			var fadeIn = new Fx.Tween(this.options.images[this._fadeImgIn], {duration: this.options.fadeTime});
			fadeOut.start('opacity',[1,0]);
			fadeIn.start('opacity',[0,1]);
			$('button-'+this._fadeImgOut).removeClass('slide-buton-activ');
			$('button-'+this._fadeImgIn).addClass('slide-buton-activ');
		},
		
		show: function(pos) {
			$clear(this._per);
			this.hide_all();
			if (this._pos != pos) this._pos = pos;
			this.options.images[pos].setStyles({'opacity':1, 'visibility':'visible'});
			this._per = this.fadeImages.periodical(this.options.period, this);
		},
		
		hide_all: function() {
			var ttthis = this.options.images;
			this.options.images.each(function (el,l) {
				ttthis[l].setStyles({'opacity':0, 'visibility':'hidden'});
			});
			
		}
	});