function fDelete(){
	$$('.fDelete').each(function(el){
		el.addEvent('click', function(e){
			e = new Event(e);
			if( !confirm(el.title ? el.title : 'Etes vous sûr de vouloir supprimer cet élément ?')){
				e.stop();
			}
		});
	});
}

function popup( href, name, h, l ) {
	var hauteur = Math.round( ( screen.availHeight - h ) / 2 );
	var largeur = Math.round( ( screen.availWidth - l ) / 2 );
	var popup = window.open( href, name, 'toolbar=0,location=0,directories=0,status=0, scrollbars=1,resizable=1,menubar=0,top='+hauteur+',left='+largeur+',width='+l+',height='+h);
	popup.focus();
	return false;	
}
function fFlashMessage() {
	new mooFlashMessage($$('.flash'));
}

function fMooSlideMenu() {
	if($('list'))
		new mooSlideMenu('list','previous','next');
}

function fInitKeywordsHidden(){
	if($$('.hiddentitle').length>0)
	new keywordsHidden($$('.hiddentitle'));	
}

function fInitSlideshow(){
	var aRequest = new Request.JSON({
		url:'js/brands.js.php',
		method:'get',
		onComplete:function(responseJSON){
			//console.log(responseJSON.elements);
			//console.log(responseJSON.root);
			new Slideshow('brandslide', responseJSON.elements, { controller: false, hu: responseJSON.root }); 
		}
	}).send();
}

function fInitAccordion(){
	if($('tricks')){
		var myAccordion = new Accordion($('tricks'), 'h3.trick_toggler', 'div.trick_element', {
			opacity: false,
			alwaysHide:true,
			display:-1,
			onActive: function(toggler, element){
				toggler.addClass('toggler-on');
			},
			onBackground: function(toggler, element){
				toggler.removeClass('toggler-on');
			}
		});
	}
}

function fInit(){
	fDelete();
	fFlashMessage();
	fMooSlideMenu();
	fInitKeywordsHidden();
	fInitSlideshow();
	fInitAccordion();
}
window.addEvent('domready', fInit);
