var categories = new Hash( {
	wAvedis					: "identity graphism",
	wBdcine					: "ecommerce maintenance audit",
	wCefcpe					: "identity",
	wCholleton				: "ecommerce development maintenance audit",
	wClicview				: "identity development audit",
	wConfidentialhotels		: "identity ecommerce development",
	wCubidon				: "ecommerce audit",
	wD15					: "identity",
	wDden					: "identity graphism development maintenance audit",
	wEuromip				: "graphism development",
	wIntellego				: "identity development",
	wMinedargent			: "graphism development",
	wPretfimmo				: "development audit",
	wShoes					: "ecommerce graphism development maintenance audit",
	wSpeedeal				: "identity graphism development",
	wSpeedealpro			: "identity graphism development",
	wSweetdelirium			: "ecommerce graphism",
	wTlcoptimumperformance	: "identity graphism",
	wVentenet				: "ecommerce graphism maintenance audit",
	wWrungdivision			: "identity development maintenance audit",
	wWrungshop				: "ecommerce development maintenance audit",
	wTrineo				: "identity development maintenance audit",
	wPetf					: "identity development maintenance audit",
	wEstetika				: "identity development maintenance audit",
	wTineoIntranet			: "development maintenance audit",
	wProjectstore			: "ecommerce development maintenance audit graphism",
	wFabricebouquet			: "development maintenance identity",
	wArvimultimedia			: "ecommerce development maintenance audit",
});

var curCat = null;

window.addEvent('domready', function() {

	// Inject the categories as classnames in each reference :
	categories.each(function(list, name) {
		$('references').getElement('.'+name).addClass(list);
	});

	// Togglers init :
	$('sdoih').getElements('.showToggler').each(function(el) {
		cat = el.className.substr(1+el.className.indexOf(' '));
		el.cat = cat;
		el.addEvent('click', function() {
			var categ = this.cat;
			if (curCat == categ) // already on this one ?
				$(this).highlight('#a00', this.getStyle('backgroundColor')); // flash the menu : change #a00 to any to-flash-to-value
			else {
				// Set a style to the currently selected category :
				if (curCat != null) // first we remove the style from the previous one
					$('sdoih').getElements('.showToggler').each(function(del) {
						del.removeClass("current");
					});
				this.addClass("current"); // and set the current one

				// The effect itself :
				curCat = categ;
				new Fx.Morph('references', {
							fps: 30,
							duration: 1000,
							onComplete: function() {
											$('references').getElements('.wetReferences').each(function(el2) {
												if (el2.hasClass(categ))
													el2.setStyles({'visibility': 'visible', 'display': 'block'});
												else
													el2.setStyles({'visibility': 'hidden', 'display': 'none'});
											});
	
											new Fx.Morph('references', { fps: 30, duration: 300 }).start( {
																						'opacity': [-1, 1],
																						'top': 0,
																						'left': 0
																						});
										}
						}).start( {
									'opacity': -0.5, // so opacity fades faster than the movement itself ;o)
									'top': -($('references').offsetHeight),
									'left': -($('references').offsetWidth)
								});
			}
		});
	});
});

