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 fFlashMessage() {
	new mooFlashMessage($$('.flash'));
}

function fMenu() {
	if ($('menu')) {
		new Menu($('menu'));
	}
}

function fInit(){
	fDelete();
	fFlashMessage();
	fMenu();
}
window.addEvent('domready', fInit);

window.addEvent('domready', function(){
    if( $('slide-header-inner') ){
        new mooFading('slide-header-inner', '#slide-header-inner div', {'waitDuration':5000});
    }
});


/*Menu avec onglet*/
function multiClass(eltId) {
	
	arrLinkId = new Array('ong_0','ong_1','ong_2','ong_3');
	intNbLinkElt = new Number(arrLinkId.length);
	arrClassLink = new Array('on','off');
	strContent = new String();
	
	for (i=0; i<intNbLinkElt; i++) {
		
		strContent = "content_"+arrLinkId[i];
		
		if ( arrLinkId[i] == eltId ) {
			document.getElementById(arrLinkId[i]).className = arrClassLink[0];
			document.getElementById(strContent).className = 'display';
		} else {
			document.getElementById(arrLinkId[i]).className = arrClassLink[1];
			document.getElementById(strContent).className = 'no_display';
		}
		
	}	
	
}

// fancy form
window.addEvent('domready', function(){
    // FancyForm.start();
    
    FancyForm.start( $$('#fancy-form-checkbox input') );
});

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 popupOrder( Obj ) {
	return popup( Obj.href, 'order', 600, 580 );
}


function maxLengthTextarea( field, countField, limitChar ) {
	var fieldDom = document.getElementById( field );
	var countFieldDom = document.getElementById( countField );
	
	if( !fieldDom || !countFieldDom ) {
		return;
	}

	fieldDom.value = fieldDom.value.replace( /([ \r\n\t\0\x0B])([ \r\n\t\0\x0B])([ \r\n\t\0\x0B])+/, '$1$2' );
	if( fieldDom.value.length > limitChar ) {
		fieldDom.value = fieldDom.value.substring( 0, limitChar );
	}
	countFieldDom.innerHTML = limitChar - fieldDom.value.length;
}


function fNewsletterFocus() {
    if( $('emailnewsletter') ) {    
        $('emailnewsletter').addEvent('focus', function(){
            $('emailnewsletter').setProperty('value','');
        });
    }
}
window.addEvent('domready', fNewsletterFocus);



// function formHiddenLabelInit(){
    // if( $('emailnewsletter') ) {
        // console.log('aa');
        // new formHiddenLabels( 'emailnewsletter' );
        // console.log('aa');
    // }
// }
// window.addEvent('domready', formHiddenLabelInit);

function fTips() {
    //store titles and text
	$$('a.tipslanguage').each(function(element,index) {
		var content = element.get('title').split('::');
		element.store('tip:title', content[0]);
		element.store('tip:text', '');
	});
    var myTips = new Tips('.tipslanguage');
    // myTips.addEvent('hide', function(tip, el){
        // tip.fade('out');
    // });
}
window.addEvent('domready', fTips);