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 = 1, divAg, idDivToMov = 0, divToMov, nbBis = nbAg;
		var nbAg = $('nbAg') ? $('nbAg').value : 1;
		var sens = 1;


		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 () {

			if( idDivToMov != 0 ) {
			//	divToMov = $('section' + idDivToMov.toString());
			//	divToMov_clone = divToMov.clone();
			//	divToMov_clone.inject( $('main_content') );
			//	divToMov.remove();
			//	divToMov_clone.setProperty( 'id', 'section' + (idDivToMov).toString() )
			}


			idDivToMov++;
			if ( idDivToMov > nbAg ) {

				idDivToMov = 1;
			}
		});

		function timedScroll() {




			if ( idSection == nbAg || idSection == 0 ) {
				//idSection = 1;
				//alert( idSection );
				if( sens == 1 ) {
					sens = 0;
					idSection--;
				} else {
					sens = 1;
					idSection++;
				}
			} else {
				if( sens ) idSection++; else idSection--;
			}

			if( idSection != 0 ) {
				scroll.toElement('section' + idSection.toString());
			}


			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' });
}



