var WindowController = new Class({
	
	Implements: [Options, Events],
	
	options: {
		maximizeEventTrigger: "click",
		minimizeEventTrigger: "click",
		
		morph: {
			duration:200,
			transition:"Quint:out"
		},
		loaderTween: {
			duration:300			
		}		
	},
	
	stepNumber 	: 0,
	stepTitle	: "Step title",
	
	initialize: function(container, options)
	{
		this.setOptions(options);
		this.container = $(container);
		this.setUp();
	},
	
	setUp: function()
	{
		this.createLoader();
		this.container.set("morph", {duration:this.options.morph.duration, transition:this.options.morph.transition});
		this.info = new Element("div", {"class":"info"});
		this.info.addEvent(this.options.maximizeEventTrigger, this.maximize.bind(this));
		
		this.minimizeButton = new Element("a", {href:"#", text:"[x]", title:"Cerrar", "class":"minimizeButton"});
		this.minimizeButton.addEvent(this.options.minimizeEventTrigger, function(event){event.stop()});
		this.minimizeButton.addEvent(this.options.minimizeEventTrigger, this.minimize.bind(this));
		
		this.maximizeButton = new Element("a", {href:"#", text:"+ info", title:"+ info", "class":"maximizeButton"});
		this.maximizeButton.addEvent(this.options.maximizeEventTrigger, function(event){event.stop()});
		this.maximizeButton.addEvent(this.options.maximizeEventTrigger, this.maximize.bind(this));
		
		this.createHeader();
	},
	
	createHeader: function()
	{
		this.header 		= new Element("h1", {"class":"stepTitle"}).inject(this.container, "top");
		//this.numberHeader	= new Element("span", {"class":"number", text:this.stepNumber}).inject(this.header);
		this.titleHeader	= new Element("span", {"class":"title", "html":"<span>"+this.stepTitle+"</span>"}).inject(this.header);
	},
	
	createLoader: function()
	{
		this.loader = new Element("div", {"class":"loaderContainer"});
		this.loader.set("tween", {duration:this.options.loaderTween.duration, onComplete:function(){this.loader.dispose()}.bind(this)})
		
		this.progress = new Element("div", {"class":"stepLoader"}).inject(this.loader);
		this.message = new Element("div", {"class":"message", text:"Cargando ..."}).inject(this.loader);
	},
	
	setOncompleteMorph: function(func)
	{
		var options = this.container.get("morph").options;
		options.onComplete = func;
		this.container.set("morph", options);
	},
	
	injectMinimizedInfo: function(element)
	{
		if($defined(this.info.infoElement))
		{
			this.info.infoElement.destroy();
		}
		
		this.info.infoElement = element;
		
		element.inject(this.info);
		this.info.inject(this.container, "top");
		this.maximizeButton.inject(this.info);
	},
	
	extractMinimizedInfo: function()
	{
		this.info.dispose();
	},
	
	hideChildren: function()
	{
		//this.container.getChildren().addClass("invisible");
	},
	
	showChildren: function()
	{
		this.container.getChildren().removeClass("invisible");
	},
	
	minimize: function()
	{
		/*this.extractMinimizedInfo();
		this.hideChildren();
		this.injectMinimizedInfo();*/
	},
	
	minimizeComplete: function(){},
	
	maximize: function()
	{
		/*this.showChildren();
		this.extractMinimizedInfo();*/
	},
	
	maximizeComplete: function(){},
	
	loading: function()
	{
		/*this.loader.setStyle("opacity", "1");
		this.loader.inject(this.container);*/
	},
	
	loaded: function()
	{
		//this.loader.tween("opacity", "0");
	}
})