var CE_Project_Details_Controller = new Class({
    options: {
		id: null,
		current_detail: 0,
		num_details: 0,
		fx_duration: 200
    },

    initialize: function(options) {
		this.setOptions(options);
		this.thumbnails = $("thumbnails");
		this.details = [];

		for (var x = 0; x < this.options.num_details; x++) {
			this.details.push($("detail" + x));
		}
	},
	
	clean: function(str) {
		return str.replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;");
	},
	
	show: function(which) {
		this.transition(this.thumbnails, this.details[which]);
		this.current_detail = which;
	},

	back: function() {
		this.transition(this.details[this.current_detail], this.thumbnails);
	},

	transition: function(from, to) {
		var f = new Fx.Style(from, "opacity", { duration:this.options.fx_duration, onComplete:function(elem) { elem.style.display = "none"; } });
		var t = new Fx.Style(to, "opacity", { duration:this.options.fx_duration });
		
		f.start(1, 0).chain(
			function() {
				$(to).setStyles({ opacity: 0, display:"block" });
				t.start(0, 1);
			}
		);
	}
});

CE_Project_Details_Controller.implement(new Options);
