
function CDate() {

 langue = new Array(4);
 NomMois = new Array(4);
 NomJours = new Array(4);

 NomMois = new Array(12);
 NomMois[1] = "janvier";
 NomMois[2] = "février";
 NomMois[3] = "mars";
 NomMois[4] = "avril";
 NomMois[5] = "mai";
 NomMois[6] = "juin";
 NomMois[7] = "juillet";
 NomMois[8] = "août";
 NomMois[9] = "septembre";
 NomMois[10] = "octobre";
 NomMois[11] = "novembre";
 NomMois[12] = "décembre";

 NomJours = new Array(7);
 NomJours[1] = "Dimanche";
 NomJours[2] = "Lundi";
 NomJours[3] = "Mardi";
 NomJours[4] = "Mercredi";
 NomJours[5] = "Jeudi";
 NomJours[6] = "Vendredi";
 NomJours[7] = "Samedi";

 var LaDate = "";
 var NowDate = new Date();

 var LeJour = NomJours[NowDate.getDay()+1];
 var LeMois = NomMois[NowDate.getMonth()+1];
 var LAnnee = NowDate.getFullYear();

 LaDate = LeJour + " " + NowDate.getDate() + " " + LeMois + " " + LAnnee;

 document.write( LaDate );

}



var sendToPop = new Class( {

	initialize: function( el ) {

		this.element	= el;
		this.script 	= '';
		this.widthPop	= '750';
		this.heightPop	= '600';
		this.scrollPop	= 'auto';
		this._param		= '';

	},

	active: function( event, script ) {
		if( script != null ) {
			this.script = script;
		}
		this.element.addEvent( event, this.sendPop.bindAsEventListener(this) );
	},


	popup: function ( script ) {
		strhei = "height=" + this.heightPop;
		strwid = "width=" + this.widthPop;
		if( script!=null ) {
			this.script = script;
		}
		scrol = "scrollbars=" + this.scrollPop;
		strf = strhei + "," + strwid + "," + scrol;
		window.open( this.script + this._param, '', strf );
	},


	sendPop: function() {
		if( this.element.getValue() != 0 ) {
			this._param = '?id=' + this.element.getValue();
			this.element.options[0].selected = true;
		}
		this.popup();
	}

} );








var listeToggle2 = new Class( {

	initialize: function(options) {
		this.listeTag	= '';
		this.groupTag	= '';
		this.width		= '100px';
		this.height		= 'auto';
		this.duration	= 300;
		this.showDelay  = 5000;
		this.options	= {};
		this.setParam(options);

	},

	setParam: function(options) {
		if( $chk( options ) ) {
			this.options = options;
		}
		if( $chk(this.options.groupTag) ) {
			this.groupTag = this.options.groupTag;
		}
		if( $chk(this.options.listeTag) ) {
			this.listeTag = this.options.listeTag;
		}
		if( $chk(this.options.height) ) {
			this.height = this.options.height;
		}
		if( $chk(this.options.width) ) {
			this.width = this.options.width;
		}
		if( $chk(this.options.duration) ) {
			this.duration = this.options.duration;
		}
		if( $chk(this.options.showDelay) ) {
			this.showDelay = this.options.showDelay;
		}
		if( $chk(this.options.listeStyle) ) {
			this.listeStyle = this.options.listeStyle;
		}
		$(this.groupTag).setStyle( 'width', this.width );
		$(this.listeTag).setStyle( 'height', this.height );
		$(this.listeTag).setStyle( 'width', this.width );

		$(this.listeTag).setStyles( this.listeStyle );
	},




	clickAction: function( link, groupe ) {
		if( $chk(groupe) ) { this.groupTag = groupe; }
		var sDelay = this.showDelay;
		var grTag = $(this.groupTag);
		var closeT;
		var fx = new Fx.Slide($(this.listeTag), {duration: this.duration});
		fx.hide();
		//alert( $(this.listeTag).getStyle('height') );
		/*if( $(this.listeTag).getStyle('height') == '0px' ) {
				alert( fx.vertical() );
		}*/
		$(link).addEvent('click', function(){
			fx.clearTimer();
			fx.toggle();
			grTag.addEvent( 'mouseout', function() {
				closeT = $clear(closeT);
				closeT = function() { fx.slideOut(); }.delay(sDelay);
			});
			grTag.addEvent( 'mouseover', function() {
				closeT = $clear(closeT);
			});
			//var closeT = function() { fx.toggle(); }.delay(sDelay);
		});
	}

});











var blocRefresh = new Class( {

	initialize: function( blocA, blocR ) {

		this.waitMessage		= '<div id="waiting">Chargement...</div>';
		this.method				= 'get';
		this.blocAction 		= blocA;
		this.blocResult 		= blocR;

		this.tabAction			= [];
		this.tabResult			= [];
		this.EventType			= [];

		this.param 				= '';
		this.ciblingTag 		= '';
		this.script 			= '';

		this.eventListenType 	= 'click';
		this.blocOnComplete		= '';
		this.setLightBoxOnComplete	= false;

		this.onCompleteOptions	= {};
		this.tempTab = {};
	},




	showLoad: function() {
		if( !$('tb_load') ) {
			new Element('div').setProperty('id', 'tb_load').injectInside(this.blocResult);
			$('tb_load').innerHTML = '<p align="center"><img src="images/indicator_snake.gif" /><br/>Chargement...</p>';
			this.tbLoadPosition();
		}
	},


	hideLoad: function() {
		if( $('tb_load') ) {
			$('tb_load').remove();
		}
	},


	tbLoadPosition: function() {
		if( $('tb_load') ) {
			$('tb_load').setStyles({
							position: 'absolute',
							top: '20px',
							left: '20px',
							width: '100px',
							margin: '0px auto',
							display: 'block'
					});
		}
	},


	setEventAjax: function( typeEvent ) {
		if( typeEvent != null ) {
			this.eventListenType = typeEvent;
		}
		$(this.blocAction).addEvent( this.eventListenType, this.traiteEvent.bind(this) );
	},

	setEventAjax2: function( typeEvent ) {
		if( typeEvent != null ) {
			this.eventListenType = typeEvent;
		}
		$(this.blocAction).addEvent( this.eventListenType, this.traiteEvent2.bind(this) );
	},

	setOnComplete: function( options ) {
		if( window.ie ) {
			options.evTypeOnComplete = 'click';
		}
		this.onCompleteOptions = options;
	},

	onComplete: function(e) {
		var e = new Event(e).stop();
		var el= e.target;
		this.param = el.name + '=' + el.value;
		new Ajax( this.onCompleteOptions.scriptOnComplete, { 	onStateChange: this.waitMessage,
											method: this.onCompleteOptions.method,
											postBody: this.param,
											update: this.onCompleteOptions.targetBloc }).request();
	},


	onCompleteAction: function(e) {
		this.hideLoad();
		if( this.setLightBoxOnComplete ) {
			window.addEvent('domready', Lightbox.init.bind(Lightbox));
		}
		//initNXGMap(document.getElementById('map'));
		//clearAll();showPoints(-1);
		if( $(this.blocOnComplete) ) {
			$(this.blocOnComplete).addEvent( this.eventListenType, this.traiteEvent.bind(this) );
		} else {
		//	alert( $(this.blocResult) );
		//	this.blocAction = this.blocResult;
		//	this.blocResult = '';
			$(this.blocResult).addEvent( this.eventListenType, this.traiteEvent.bind(this) );

			/*if( $(this.onCompleteOptions.actionBloc) != null ) {
				$(this.onCompleteOptions.actionBloc).addEvent( this.onCompleteOptions.evTypeOnComplete, this.onComplete.bind(this) );
			}*/
		}
	},


/*	onCompleteLightBox: function(e) {
		window.addEvent('domready', Lightbox.init.bind(Lightbox));
	},*/


	traiteEvent: function(e) {
		var e = new Event(e).stop();
		var el= e.target;
	//	alert( el.id + ' : ' + $(el).getTag() + ' : ' + this.ciblingTag );
		//alert( $(el).getParent() );
		if( $(el).getTag() == this.ciblingTag ) {
			if( this.script=='' ) {
				this.script = $(el).id != '' ? $(el).id : el.href;
				this.ajaxAction( this.script );
			} else {
				el2 = $(el).getTag();
				this.param = el2.name + '=' + el2.value;
			//	alert( this.param );
				this.ajaxAction( this.script );
			}
		} else {
			//alert( this.script );
			this.script = $(el).getParent();
			this.ajaxAction( this.script );
		}
	},


	traiteEvent2: function(e) {
		var e = new Event(e).stop();
		var el= e.target;
		//alert( el.id + ' : ' + $(el).getTag() + ' : ' + this.ciblingTag );
		//alert( $(el).getParent() );
		if( $(el).getTag() == this.ciblingTag ) {
			if( this.script=='' ) {
				this.script = $(this.blocAction).getProperty( 'ajaxscript' );
				/*
				this.script = $(el).id != '' ? $(el).id : el.href;
				this.ajaxAction2( this.script );*/
			} else {
				this.param = el.name + '=' + el.value;
				this.ajaxAction2( this.script );
			}
		} else {
			this.script = $(el).getParent();
			this.ajaxAction2( this.script );
		}
	},


	/**
	*	ouvre une boxe
	*/
	lightBoxAction: function( link ) {
		new Ajax( link, { 	onStateChange: this.showLoad(),
							method: this.method,
							update: this.blocResult,
							postBody: this.param,
							onComplete: Lightbox.init.bind(Lightbox)
				}).request();
	},



	ajaxAction: function( link ) {
		if( this.setLightBoxOnComplete ) {
			this.lightBoxAction( link );
		} else {
			new Ajax( link, { 	onStateChange: this.showLoad(),
								method: this.method,
								update: this.blocResult,
								postBody: this.param,
								onComplete: this.onCompleteAction.bind(this)
					}).request();
		}
		this.script = '';
	},


	onCompleteAction2: function(e) {
		this.hideLoad();
		initNXGMap(document.getElementById('map2'));
	/*	if( $(this.blocOnComplete) ) {
			$(this.blocOnComplete).addEvent( this.eventListenType, this.traiteEvent2.bind(this) );
		} else {
			$(this.blocResult).addEvent( this.eventListenType, this.traiteEvent2.bind(this) );
		}*/
	},

	ajaxAction2: function( link ) {
		if( this.setLightBoxOnComplete ) {
			this.lightBoxAction( link );
		} else {
			alert( link );
			new Ajax( link, { 	onStateChange: this.showLoad(),
								method: this.method,
								update: this.blocResult,
								postBody: this.param,
								onComplete: this.onCompleteAction2.bind(this)
					}).request();
		}
		this.script = '';
	}


} );








var accordeon = new Class( {

	initialize: function( masterBloc, options ) {
		this.options			= {};
		this.toggleBar 			= '';
		this.elementBloc 		= '';
		this.masterBloc			= masterBloc;
		this.setParam( options );

		Fx.Morph = Fx.Styles.extend({

			start: function(className){

				var to = {};

				$each(document.styleSheets, function(style){
					var rules = style.rules || style.cssRules;
					$each(rules, function(rule){
					//	alert( rule.selectorText );
						if (!rule.selectorText.test('\.' + className + '$')) return;
						Fx.CSS.Styles.each(function(style){
							if (!rule.style || !rule.style[style]) return;
							var ruleStyle = rule.style[style];
							to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
						});
					});
				});
				return this.parent(to);
			}

		});
	},


	setParam: function( options ) {
		if( $chk( options ) ) {
			this.options = options;
		}
	},

	morph: function( className ) {

		Fx.CSS.Styles = ["backgroundColor", "backgroundPosition", "color", "width", "height", "left", "top", "bottom", "right", "fontSize", "letterSpacing", "lineHeight", "textIndent", "opacity"];

		Fx.CSS.Styles.extend(Element.Styles.padding);
		Fx.CSS.Styles.extend(Element.Styles.margin);

		Element.Styles.border.each(function(border){
			['Width', 'Color'].each(function(property){
				Fx.CSS.Styles.push(border + property);
			});
		});
		var myMorph = new Fx.Morph('morpher', {wait: false});
		$('morph1').addEvent('click', function(e){
			new Event(e).stop();

			myMorph.start(className);

		});

	},

	start: function( d ) {
		var accordion = new Accordion( this.toggleBar, this.elementBloc, {
			opacity: false,
			display: d,
			fixedHeight: 200,
			onActive: function(toggler, element){
				toggler.setStyle('background-color', '#6D8BB3' );
				element.addClass( 'fleche' );
				//alert( toggler.getProperty( 'rel' ) );
			/*	globShow = element.getProperty( 'rel' );*/
			},

			onBackground: function(toggler, element){
				toggler.setStyle('background-color', '#F5B75F' );
				element.removeClass( 'fleche' );
			}
		}, this.masterBloc );
	}

} );









function init() {



	if( $('listeDispo') ) {
		var popVisite = new sendToPop( $('listeDispo') );
		popVisite.scrollPop	= 'yes';
		popVisite.widthPop = '600';
		popVisite.heightPop = '450';
		var script = $('listeDispo').getProperty( 'script' );
		popVisite.active( 'click', script );
	}


	if( $('accordion') ) {
		var accord = new accordeon( $('accordion') );
		accord.toggleBar = 'h3.atStart';
		accord.elementBloc =  'div.atStart';
	//	alert( accord.elementBloc.getProperty( 'rel' ) );
	//	accord.options = { show:2 }
		accord.start( $('accordion').getProperty( 'rel' ) );
	}


	if( $('listeResultat') ) {
		var contenu1 = new blocRefresh( 'listeResultat', 'listeResultat' );
		contenu1.setLightBoxOnComplete = true;
		var script = $('listeResultat').getProperty( 'ajaxscript' );
		contenu1.ajaxAction( script );
	}



	if( $('listeDiapo') ) {
		var contenu1 = new blocRefresh( 'listeDiapo', 'visuel' );
		contenu1.ciblingTag = 'img';
		contenu1.method = 'get';
		contenu1.setEventAjax( 'click' );
	}
	if( $('_bresult_') ) {
		var contenu1 = new blocRefresh( '_bresult_', '_bresult_' );
		contenu1.ciblingTag = 'a';
		contenu1.method = 'get';
		contenu1.blocOnComplete = '_bresult_';
		contenu1.setEventAjax( 'click' );
	}
	if( $('_baction2_') ) {
		var contenu1 = new blocRefresh( '_baction2_', '_bresult2_' );
		contenu1.ciblingTag = 'a';
		contenu1.method = 'get';
		contenu1.setLightBoxOnComplete = true;
		contenu1.setEventAjax( 'click' );
	}

	if( $('libdispo') ) {
		var mySlide = new Fx.Slide('tabDispo');
		mySlide.hide();
		$('libdispo').addEvent('click', function(e){
			e = new Event(e);
			mySlide.toggle();
			e.stop();
		});
	}


	if( $('_ok_' ) ){
		$('_ok_' ).addEvent('click', function(e){
			$('_moteur_').submit();
		});

	}




	if( $('_pub_') ) {
		var timer = 5;
		var periodical, dummy;
		var pub = $('_pub_');
		var script = $('_pub_').getProperty( 'ajaxscript' );
		var ajax = new Ajax( script, {
			update: pub,
			method: 'get',
			onComplete: function() {
				// when complete, we remove the spinner
				//pub.removeClass('ajax-loading');
			},
			onCancel: function() {
				// when we stop timed ajax while it's requesting
				// we forse to cancel the request, so here we
				// just remove the spinner
				//pub.removeClass('ajax-loading');
			}
		});

		/* our refresh function: it sets a dummy to prevent
		   caching of php and add the loader class */
		var refresh = (function() {
			// dummy to prevent caching of php
			dummy = $time() + $random(0, 100);
			// we add out fancy spinner
			//pub.empty().addClass('ajax-loading');
			// requests of our php plus dummy as query
			ajax.request(dummy);
		});

		periodical = refresh.periodical(timer * 1000, this);
	}

	var Tips1 = new Tips($$('.Tips1'));


/*
	if( $('morpher') ) {

		Fx.Morph = Fx.Styles.extend({

			start: function(className){

				var to = {};

				$each(document.styleSheets, function(style){
					var rules = style.rules || style.cssRules;
					$each(rules, function(rule){
						if (!rule.selectorText.test('\.' + className + '$')) return;
						Fx.CSS.Styles.each(function(style){
							if (!rule.style || !rule.style[style]) return;
							var ruleStyle = rule.style[style];
							to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
						});
					});
				});
				return this.parent(to);
			}

		});
		Fx.CSS.Styles = ["backgroundColor", "backgroundPosition", "color", "width", "height", "left", "top", "bottom", "right", "fontSize", "letterSpacing", "lineHeight", "textIndent", "opacity"];

		Fx.CSS.Styles.extend(Element.Styles.padding);
		Fx.CSS.Styles.extend(Element.Styles.margin);

		Element.Styles.border.each(function(border){
			['Width', 'Color'].each(function(property){
				Fx.CSS.Styles.push(border + property);
			});
		});



		var myMorph1 = new Fx.Morph('morpher', {wait: false});

		$('morpher').addEvent('click', function(e){
			new Event(e).stop();

			myMorph1.start('morph1');

		});

		$('morpher2').addEvent('click', function(e){
			new Event(e).stop();

			myMorph2.start('morph1');

		});
	}*/




}

Window.onDomReady( init );

