function ImagePlayer(options) {
	this.options = {
		"period": 10,
		"container": "",
		"path": "/pages/software/slides/csi/"
	};
	Object.extend(this.options, options || {});
	
	var dv1 = new Element("div",{ 'id': 'object_slide_show_player_box' });
	this.dv2 = new Element("div",{ 'class': 'object_slide_show_player_pannel' });
	
	$(this.options.container).insert(dv1).insert(this.dv2);
	
};
ImagePlayer.prototype.nextSlide = function (pannel, filepath) {
	pannel.fade({
		"duration": 3.0,
		"afterFinish": function () {
			pannel.setStyle({"background":"url("+filepath+")"}).appear();
		}
	});
};
ImagePlayer.prototype.play = function () {
	var counter = 1, imageplayer = this;
	
	this.nextSlide(this.dv2, this.options.path + "0.jpg");

	new PeriodicalExecuter(function (pe) {
		filepath = imageplayer.options.path + counter + ".jpg";
		
		new Ajax.Request(filepath, {
			  "method": "get",
			  "asynchronous": false,
  			  "onSuccess": function(transport) {
				if(!transport.getHeader("Content-Type").match(/^image/)){
					counter = 0;
					filepath = imageplayer.options.path + "0.jpg";
				}
			   }
		});
		
		imageplayer.nextSlide(imageplayer.dv2, filepath);
		
		counter += 1;
	},this.options.period);
};
