/**
 * @author jfdesgagne
 */
var EcoVision = new Class({
	language:"",
	currentPage:null,

    initialize: function(){
		this.getLanguage();
		this.initProperty();
		this.initPage();
		this.initFx();
		this.initProperty();
		this.initEvents();
    },
	
	
	getLanguage:function() {
		$$('meta').each(function(el) {
			if(el.getProperty("http-equiv") == "content-language") {
				this.language = el.getProperty("content");
				return;
			}
		}.bind(this));
	},
	
	initPage:function() {
		if($("splash"))this.currentPage = new Splash(this);
		if($("splash2"))this.currentPage = new Splash(this, true);
	},
	
	writeError:function(parent, text) {
		var error_div = new Element('div', {'class':'error'}).inject(parent);
		var errorLeft_div = new Element('div', {'class':'error_left'}).inject(error_div, 'inside');
		var errorText_div = new Element('div', {'class':'error_text'}).inject(error_div, 'inside').set('text', text);
		var errorRight_div = new Element('div', {'class':'error_right'}).inject(error_div, 'inside');
		
		return error_div;
	},
	
	writeWarning:function(parent, text) {
		var warn_div = new Element('div', {'class':'error warning'}).inject(parent);
		var warnLeft_div = new Element('div', {'class':'warn_left'}).inject(warn_div, 'inside');
		var warnText_div = new Element('div', {'class':'warn_text'}).inject(warn_div, 'inside').set('text', text);
		var warnRight_div = new Element('div', {'class':'warn_right'}).inject(warn_div, 'inside');
		
		return warn_div;
	},
	
	initEvents:function() {
		// About Click Button (open the description keyword text)
		$('about').addEvent('click', this.aboutClickHandler.bind(this));	
	},
	
	initFx:function() {
		$('about_container').set('morph', {duration: 'long', transition:'expo:out'});	
	},
	
	aboutClickHandler:function() {
		if($('about_container').retrieve('isOpened') == 'opened') {
			$('about_container').store('isOpened', '');
			$('about_container').morph('.about_containerClosed');
		} else {
			$('about_container').store('isOpened', 'opened');
			$('about_container').morph('.about_container');
		}
	},
	
	initProperty:function() {
		$('about_container').store('isOpened', '');	
	}
});

window.addEvent('domready', function() {
	var ecoVision = new EcoVision();
});