var loader = null;

window.addEvent('load', function() {
	
	app = new Application({
	});
	
	initLang();
	initAntiSpam('content');
		
});


var initAntiSpam = function(where) {
	$(where).getElements('a[href^=mailto:]').each( 
		function(el) {
			el.href = el.href.replace(/\[@\]/,'@');
		}
	
	);
}

var initLang = function() {
	var container = $('lang_select').getParent();
	var lis = container.getElements('li:not(#lang_select)');
	lis.each(function(el, index) {
		el.setStyle('display', 'block');
		el.store('height', el.getSize().y);
		el.setStyle('height', 0);
		el.set('tween', {duration: 300, transition: Fx.Transitions.Quad.easeOut});
	});
	container.addEvents({
		'mouseenter': function() {
			lis.each(function(el) {
			 el.tween('height', el.retrieve('height'));
			});
		},
		'mouseleave':function() {
			lis.each(function(el) {
			 el.tween('height', 0);
			});
		}
	});
}

var HM = new HistoryManager();

var getGets = function(url) {
	var obj = {};
	if(!URL_REWRITE) {
		var gets = url.match(/([a-z]*)=([0-9]*)/g);
		if(!gets) return false;
		for(var i=0; i<gets.length; i++) {
			var vs = gets[i].split('=');
			eval('obj.'+vs[0]+' = '+vs[1]);
		}
	}
	else {
		var gets = url.match(/\/([0-9]+)/g);
		if(gets[0]) obj.cat = gets[0].replace('/', '');
		if(gets[1]) {
			if(obj.cat == RECRUTEMENT) obj.emploi = gets[1].replace('/', '');
			else obj.rub = gets[1].replace('/', '');
		}
		if(gets[2]) {
			if(obj.rub == ALBUM_FR_ID || obj.rub == ALBUM_EN_ID) obj.alb = gets[2].replace('/', '');
		}
	}
	return obj;
}
