/* Définition des comportements javascript du site */
function setCSSBehaviours() {
	$$('.themes select').each( function (select) {
		select.addEvent('change', function(e) { select.form.submit(); new Event(e).stop(); });
	} );
	$$('#nav-contenu .print').each( function(element) {
		element.addEvent('click', function(e) { window.print(); new Event(e).stop(); });
	});
	$$('#pied p a, #pagination a').each( function(element) {
		element.setStyle('line-height', '0.1em');
		var fx = new Fx.Styles(element, {duration:200, wait:false});
		element.addEvent('mouseover', function() { fx.start({ 'font-size': [11,18] }); });
		element.addEvent('mouseout', function() { fx.start({ 'font-size': [18,11] }); });
	});
	$$('a.back').each( function(element) {
		element.addEvent('click', function(e) { history.back(); new Event(e).stop(); });
	});
	if (document.getElements('body')[0].hasClass('index')) {
		var f = function() { nextflash(); }
		t = f.periodical(5000);
		$$('#une div').each( function (div) {
			div.addEvent('mouseover', function(e) { clearTimeout(t); });
			div.addEvent('mouseout', function(e) { t = f.periodical(3000); });
		});
	}
	$$('form.valid textarea').each( function(textarea) {
		textarea.addEvent('focus', function() { this.rows = this.rows * 2; });
		textarea.addEvent('blur', function() { this.rows = this.rows / 2; });
	});
}

Window.addEvent('domready', setCSSBehaviours);

var current = 0;
function nextflash() {
	f = new Fx.Style('flashinfo'+current, 'opacity', { duration: 1000 });
	f.start(1, 0);
	current++;
	if (!$('flashinfo'+current)) { current = 0; }
	f = new Fx.Style('flashinfo'+current, 'opacity', { duration: 1000 });
	f.start(0, 1);
}
