var slideshow = Class.create();
Object.extend(
	Object.extend(slideshow.prototype, Abstract.prototype),{
		initialize: function(target, options) {
			this.wrapper    = $('container');
			this.target 	= $(target);
			this.options    = Object.extend( {duration:1, images: Array()}, options || {});
			this.IE6 = false;
			if( Prototype.Browser.IE ) {
				var ua      = navigator.userAgent;
				var offset  = ua.indexOf('MSIE ');
				var version = parseFloat(ua.substring(offset+5, ua.indexOf(';', offset)));
			
				this.IE6 = (version == 6);
			 }
				
			_this = this;
			this.start();
		},
		start:function(){
			if(!this.IE6)this.cBackground = this.target.getStyle('background-image').match(/url\((.*)\)/)[1].toString();
			else this.cBackground = this.target.getStyle('filter').match(/src=\'(.*)\'/)[1];

			this.options.images = this.options.images.invoke('replace', /.*\//, "");
			var filename = this.cBackground.match(/.*\/(.*\.[a-z]{3})/, "")[1];
			this.location = this.cBackground.replace(filename, '');

			var temp = -1;
			this.options.images.each(function(s,i){
				if(s == filename)temp = i;
			});
			if(temp != -1){
				this.currentImage = temp;
				// this.newImage();
				new PeriodicalExecuter(this.newImage, this.options.duration);
			}				
		},
		newImage: function(){
			_this.currentImage = ( _this.currentImage+1 < _this.options.images.length) ? _this.currentImage+1 : 0;
			var newImage = _this.location.replace(/\/"/,"/").replace(/.*(")/,"") + _this.options.images[_this.currentImage].replace(/(").*/,"");

			if(!_this.IE6)_this.target.setStyle({'background': 'transparent url('+newImage+') no-repeat left top'});
			else {
				_this.target.setStyle({
					'background': 'none',
					'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src="'+newImage+'")'
				});
				//alert( 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src="'+newImage.replace("url(","")+')');
			}
		}
	}
);
