// Belmar - JavaScript Document
window.addEvent('domready', function(){
	// JS
	$$('body').removeClass('no-js').addClass('js');
	
	// SWIFF : EXPRESS INSTALL
	Swiff.ExpressInstall = new Class({
		 Extends: Swiff,
			 options: {
			   expressInstall: '/swf/expressInstall.swf'
		   },
			 initialize: function(path, version, build, options){
			   if(Browser.Plugins.Flash.version >= version && Browser.Plugins.Flash.build >= build) this.parent(path, options);
			   else this.parent(this.options.expressInstall, $extend({vars: {
				   MMPlayerType: (Browser.Engine.trident) ? 'ActiveX' : 'PlugIn',
				   MMredirectURL: window.location,
				   MMdoctitle: document.title.slice(0, 47) + ' - Flash Player Installation'
			   }}, options));
		   }
	});
	
	// Edito
	if($('edito-flash')) {
		var player = new Swiff.ExpressInstall('/swf/edito.swf', 9, 0, {
			width: 165,
			height: 220,
			container: $('edito-flash'),
			params: {
				wmode: 'transparent'
			}
		});
	}
	
	// MENU
	$('menu-principal').getElement('ul').getChildren().each(function(item){
		if(item.getElement('ul')) item.getElement('ul').setOpacity(0);
		item.addEvents({
			'mouseenter':function(){
				this.addClass('hover');
				if(this.getElement('ul')) this.getElement('ul').get('tween', {property: 'opacity', duration: 'normal', onStart:function(e){e.setStyle('display', 'block');}}).start(1);
			},
			'mouseleave':function(){
				this.removeClass('hover');
				if(this.getElement('ul')) this.getElement('ul').get('tween', {property: 'opacity', duration: 'normal', onComplete:function(e){e.setStyle('display', 'none');}}).start(0.0001);
			}
		});
	});
	
	// Accordéon
	if($$('.accordion')){
		var myAccordion = new Fx.Accordion($$('.accordion h4'), $$('.accordion .element'), {
			display: -1,
			alwaysHide: true,
			onActive:function(toggler, element){
				toggler.removeClass('background').addClass('active');
			},
			onBackground:function(toggler, element){
				toggler.removeClass('active').addClass('background');
			}
		});
	}
	
	// ALIGNS & BORDER
	$$('*[align=left]').removeProperty('align').addClass('float-left');
	$$('*[align=right]').removeProperty('align').addClass('float-right');
});
