window.addEvent('domready',function(){
	mainMenu();
	
	//	===========================================================================================
	//	SHADOWBOX PROJET
	//	===========================================================================================
	$$('a').addEvent('click', function(e) {
		if(this.get('class').match(/projet/))
			openShadowProject(this.get('rel'));
	});
	
	//	===========================================================================================
	//	SHADOWBOX CONNEXION
	//	===========================================================================================
	$$('#main-menu li.float-R a.disable').addEvent('click', function(e) {

		Shadowbox.open({ 
			content: _ROOT_URL+'routines.php?page=login',
			player: 'iframe',
			title: '',
			height: 572,
			width: 980
		});
	});
	
	//	===========================================================================================
	//	SHADOWBOX PARTICIPATION
	//	===========================================================================================
	$$('a.participate').addEvent('click', function(e) {

		Shadowbox.open({ 
			content: _ROOT_URL+'routines.php?page=participate',
			player: 'iframe',
			title: '',
			height: 572,
			width: 980
		});
	});
});


/**
 * commentaires slider
 */
function slideComment(a) {
	if(a=='home') {
	var width_box = 264;
	} else {
	var width_box = 230;	
	}
	var width_total = width_box * $$('#comments-slide-main div.comment-slide').length;
	$('comments-slide-wrap').setStyle('width',width_total);
	var loop_scroll = width_total;
	var main = $('comments-slide-main');
	
	var myHash = new Hash({
		counter : 0,
		max_width : width_total
	});
	
	var fx = new Fx.Scroll(main, {
		wait: false,
		duration: 1000,
		offset: {'x': 0, 'y': 0},
		transition: Fx.Transitions.Quad.easeInOut,
		wheelStops : false

	});
	function intervall() {
		myHash.counter += width_box;
		if(myHash.counter >= loop_scroll) {
			myHash.counter = 0;
		}
		fx.start(myHash.counter,0);
	}
	intervall.periodical(5000)
}

/**
 * main menu
 */
function mainMenu() {
	$('main-menu').MooDropMenu({
		onOpen: function(el){
			el.fade('in');
			el.getParent().getElement('.level-01').addClass('selected');
		},
		onClose: function(el){
			el.fade('out');
			el.getParent().getElement('.level-01').removeClass('selected');
		},
		onInitialize: function(el){
			el.fade('hide').set('tween',{duration:500});
		}
	});
	$$('#main-menu .sub-nav li:nth-child(even)').each(function(el) {
		el.getElement('a').addClass('fill-01');														   												   
	});
	$$('#main-menu .sub-nav li:nth-child(odd)').each(function(el) {
		el.getElement('a').addClass('fill-02');														   												   
	});
}

/**
 * Ouvre un shadow box pour afficher le détail d'un projet
 * @param (string) idProjet ID du projet à ouvrir
 */
function openShadowProject(urlProjet)
{

	Shadowbox.open({ 
		content: urlProjet,
		player: 'iframe',
		title: '',
		height: 572,
		width: 980
	});
}
