window.onDomReady( function(){
	hideLoad();
	
	
	if ( $('saisie2') ) {
		$('saisie2').addEvent( 'focus', function (e) { if ( $('saisie2').value == 'recherche' ) $('saisie2').value = ''; });
		$('saisie2').addEvent( 'blur', function (e) { if ( $('saisie2').value == '' ) $('saisie2').value = 'recherche'; });
	}
	
	// Gestion des "sites à découvrir"
	if ( $('id_art') ) {
		$('id_art').addEvent( 'change', function (e) {
			var id_art = this.getValue();
			Lightbox.show( 'detailarticle.php3?id=' + id_art, '', 'width=750, height=550' );
		});
	}
	
	// Cacher le menu déroulant "Hebergement" si l'on se trouve dans la page hébergement
	if ( $('saisie3') ) $('saisie1').replaceWith('tte1');
	
	
	
	for (j = 0; j < 4; j++ ) {
		navRoot = $("nav" + j.toString());
		
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover=function() {  this.className = ( this.className.match( "current" ) ) ? "current over" : "over"; }
				node.onmouseout=function() { this.className = ( this.className.match( "current" ) ) ? "current" : ""; }
			}
		}
	}
	
	
	
	if ( $('agendaJSHome') || $('agendaJS') ) {
		var myTimer, idSection = 2, divAg, idDivToMov = 1, divToMov, nbBis = nbAg;
		var nbAg = $('nbAg') ? $('nbAg').value : 0;
		
		if ( $('agendaJSHome') )	divAg = 'agendaJSHome';
		else						divAg = 'agendaJS';
	
		var scroll = new Fx.Scroll(divAg, {
			wait: false,
			duration: 3500,
			offset: {'x': -200, 'y': 0},
			transition: Fx.Transitions.Quad.easeInOut
		});
		
		scroll.addEvent( 'onComplete', function () {
			divToMov = $('section' + idDivToMov.toString());
			divToMov_clone = divToMov.clone();
			divToMov_clone.setProperty( 'id', 'section' + (++nbBis).toString() )
			divToMov_clone.inject( $('main_content') );
			
			idDivToMov++;
			if ( idDivToMov > nbAg ) idDivToMov = 1;
		});
			
		function timedScroll() {
			scroll.toElement('section' + idSection.toString());
			idSection++;
	//		if ( idSection > nbAg ) idSection = 1;
			
			myTimer = timedScroll.delay(8500);
		}
		
		myTimer = timedScroll.delay(5000);
	}
});



function ar( go_url, div, param ) {
	new Ajax(go_url, {
		onStateChange: showLoad(),
		onComplete: function() { hideLoad(); window.addEvent('domready', Lightbox.init.bind(Lightbox)); },
		postBody: param,
		update: $(div),
		method: 'get' }).request();
}


function arForm( go_url, div, param ) {
	$(param).send({
		onStateChange: showLoad(),
		onComplete: function() { hideLoad(); },
		update: div });
}


function showLoad()
{
	// Montrer le div de chargement en haut a gauche de l'écran
	$('page_loading').setStyles({ visibility: 'visible' });
}

// Cacher img chargement
//
function hideLoad()
{
	// Cacher le div de chargement en haut a gauche de l'écran
	$('page_loading').setStyles({ visibility: 'hidden' });
}


