window.addEvent('domready', function(){
	
	if($('leftMenuLink')){
		$('leftMenuBox').removeClass('hide');
		var myHorizontalSlide = new Fx.Slide('leftMenuLink', {mode: 'horizontal'});
		var myHorizontalSlide2 = new Fx.Slide('leftMenuContain', {mode: 'horizontal'});
		myHorizontalSlide.show();
		myHorizontalSlide2.hide();
		$('leftMenuLink').addEvent('click', function(e){
				myHorizontalSlide.toggle().chain( function() { myHorizontalSlide2.toggle(); } );
		});
		$('closeMenuLink').addEvent('click', function(e){
				myHorizontalSlide2.toggle().chain( function() { myHorizontalSlide.toggle(); } );
				
		});
	}
	
	linkConfirm();
	activeOpenClose();
		
	//var myTips = new Tips('.helpIcon',{className :'tips'});
	
	if($('homeBoxLike')){
		var boxLike = new ajaxBoxHome('homeBoxLike','homeBoxLikeContainer','homeBoxLikeRefresh',{source:'ajaxBox.php?type=LIKE',showDuration:9500,showRefresh:false});
		boxLike.start();
	}
	
	if($('homeBoxPromo')){
		var boxPromo = new ajaxBoxHome('homeBoxPromo','homeBoxPromoContainer','homeBoxPromoRefresh',{source:'ajaxBox.php?type=PROMO',showDuration:9600,showRefresh:true});
		boxPromo.start();
	}
	
	if($('homeBoxMember')){
		var boxMember = new ajaxBoxHome('homeBoxMember','homeBoxMemberContainer','homeBoxMemberRefresh',{source:'ajaxBox.php?type=MEMBER',showDuration:9700,showRefresh:true});
		boxMember.start();
	}
	
	if($('homeBoxRotator')){
		var slideshow = new SimpleSlideshow('homeBoxRotator','#homeBoxRotator div.item');
		slideshow.start();
	}
	
	/*$('searchInputWhere').addEvent('click', function(e){
		$('searchInputWhere').set('value','');
		popupBox('Ou?', 'REG');
	});*/
	
	/*$('searchInputWho').addEvent('click', function(e){
		$('searchInputWho').set('value','');
		popupBox('Quoi?', 'CAT');
	});*/
	
	
	$('searchInputWho').addEvent('click', function(e){
		$('searchInputWho').set('value','');
	});
	
	if($('searchInputWho')){
			new Autocompleter.Request.JSON('searchInputWho', 'ajaxBox.php?type=SEARCH-WHO', {
				'postVar': 'search',
				'width': 'auto'
			});
	}
	
	$('searchInputWhere').addEvent('click', function(e){
		$('searchInputWhere').set('value','');
	});
	
	if($('searchInputWhere')){
			new Autocompleter.Request.JSON('searchInputWhere', 'ajaxBox.php?type=SEARCH-WHERE', {
				'postVar': 'search',
				'width': 'auto',
				'typeInput': 'where'
			});
	}
	
	if($('btnClose')){
		$('btnClose').addEvent('click', function(e){
			popupBoxClose();
		});
	}
									 
	
	
	$$('div.tipsEdit').each(function(element){
		element.addEvent('mouseover', function(e){
			this.addClass('tipsEditActive');
		});
		element.addEvent('mouseout', function(e){
			this.removeClass('tipsEditActive');
		});
		var loadAjax = element.getAttribute('loadMod');
		var container = element;
		var mode = container.getAttribute('mode');
		var idEle = container.getAttribute('idEle');
		if(mode != 'add'){ mode = 'show'; }
		if(loadAjax != '' && loadAjax != null){
			loadAjaxModule(loadAjax,container,mode,idEle);
		}
	});
	
	$$('a.btn_edit').each(function(element){
		element.addEvent('click', function(e){
			var edit = element.getAttribute('edit');
			var container = $(edit);
			var loadAjax = container.getAttribute('loadMod');
			var mode = container.getAttribute('mode');
			var idEle = container.getAttribute('idEle');
			if(mode == '' || mode == 'undefined' || mode == 'null' || mode == null){ mode = 'form'; }
			loadAjaxModule(loadAjax,container,mode,idEle);
		});
	});
	
	if($('homeBoxMeteo')){
		var container = $('homeBoxMeteo');
		urlAjax = 'meteoBox.php';
		container.empty();
		container.addClass('loading');
		var request = new Request({
			container: container,
			url:urlAjax,
			evalScripts:false,
			method:'post',
			onComplete: function(response) {
				container.set('html',response);
				container.removeClass('loading');
				if (Browser.Engine.name=='trident' && Browser.Engine.version==4) {
					var images = $$('#homeBoxMeteo img'); // liste de tous les élément <img /> du document
					images.each(function(e){
						var this_src = e.getProperty('src');
						//var size = e.getSize();
						var this_height = e.height;
						var this_width = e.width;
						var styleImg = e.getStyles('float', 'margin', 'padding');
						if (this_src.toUpperCase().contains('.PNG')){
							var this_new = new Element('span', {
							'styles': {
							'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+this_src+'\', sizingMethod=\'scale\')',
							'display': 'inline-block',
							'height': this_height,
							'width': this_width
							}});
							this_new.replaces(e);
							this_new.setStyles(styleImg);
						}
					});
				}
			}
		}).send();
	}
	
	//setUpload();
	
	//create the tooltips
	var tipPromo = new Tips('.tips-promo',{
		className: 'tips-promo',
		fixed: true,
		offset: {
		'y': -147,
		'x': -8
		},
		hideDelay: 50,
		showDelay: 50
	});
	//create the tooltips
	var tipNews = new Tips('.tips-news',{
		className: 'tips-news',
		fixed: true,
		offset: {
		'y': -147,
		'x': -8
		},
		hideDelay: 50,
		showDelay: 50
	});
	//create the tooltips
	var tipJob = new Tips('.tips-job',{
		className: 'tips-job',
		fixed: true,
		offset: {
		'y': -147,
		'x': -8
		},
		hideDelay: 50,
		showDelay: 50
	});
	//create the tooltips
	var tipRab = new Tips('.tips-rabais',{
		className: 'tips-rabais',
		fixed: true,
		offset: {
		'y': -147,
		'x': -10
		},
		hideDelay: 50,
		showDelay: 50
	});
								 
	// ENTER HACK IN FORM
	$$('input.enterhack').each(function(input){
		input.addEvent('keydown', function(event){
			if (event.key == 'enter'){
				this.getParent("form").submit();
			} //Executes if the user hits ENTER.
		});
	});
	
	/*SCRIPT POUR CENTRER LA BANNER TEXT*/
	if($('bannerBoxBgText')){
		var bannerSize = $('bannerBoxBgText').getSize();
		if(bannerSize.y < 147){
			var rest = (147-bannerSize.y)/2;
			$('bannerBoxBgText').setStyle('margin-top',rest);
		}
		
	}
	
	fix_inline_PNGs();
	
	
});
// JavaScript Document
function in_array (needle, haystack, argStrict) {
		var key = '', strict = !!argStrict; 
		if (strict) {
			for (key in haystack) {
				if (haystack[key] === needle) {
					return true;            }
			}
		} else {
			for (key in haystack) {
				if (haystack[key] == needle) {
					return true;
				}
			}
		}
		 return false;
}
	
function array_search (needle, haystack, argStrict) {
		var strict = !!argStrict;
		var key = '';
	 
		for (key in haystack) {
			if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
				return key;
			}
		}
		return false;
}
	
function array_slice (arr, offst, lgth, preserve_keys) {
		var key = '';
	 
		if (!(arr instanceof Array) || (preserve_keys && offst !== 0)) { // Assoc. array as input or if required as output
			var lgt =0, newAssoc = {};
			for (key in arr) {            //if (key !== 'length') {
				lgt += 1;
				newAssoc[key] = arr[key];
				//}
			}        arr = newAssoc;
	 
			offst = (offst < 0) ? lgt + offst : offst;
			lgth  = lgth === undefined ? lgt : (lgth < 0) ? lgt + lgth - offst : lgth;
			 var assoc = {};
			var start = false, it=-1, arrlgth=0, no_pk_idx=0;
			for (key in arr) {
				++it;
				if (arrlgth >= lgth) {                break;
				}
				if (it == offst){
					start = true;
				}            if (!start) {
					continue;
				}
				++arrlgth;
				if (this.is_int(key) && !preserve_keys) {                assoc[no_pk_idx++] = arr[key];
				} else {
					assoc[key] = arr[key];
				}
			}        //assoc.length = arrlgth; // Make as array-like object (though length will not be dynamic)
			return assoc;
		}
		
		if (lgth === undefined) {        return arr.slice(offst);    
		} else if (lgth >= 0) {
			return arr.slice(offst, offst + lgth);
		} else {
			return arr.slice(offst, lgth);    }
}
	
	function is_int (mixed_var) { 
		if (typeof mixed_var !== 'number') {
			return false;
		}
	 
		return !(mixed_var % 1);
	}

function do_login(){
	$('loginForm').submit();
}

function openExplo(id){
		var title = 'Explorateur d\'image';
		var bodySize = $('body').getScrollSize();
		$('cacheLayer').setStyle('height',bodySize.y);
		
		$('cacheLayer').removeClass('hide');
		
		$('titleBarText').set('html',title);
		$('popupBoxContain').addClass('loading');
		$('popupBox').removeClass('hide');
		$('popupBox').removeClass('where');
		$('popupBox').removeClass('who');
		$('popupBox').removeClass('explo');
		$('popupBox').addClass('explo');
				
		var scrollPos = window.getScroll();
		$('popupBox').setStyle('top',scrollPos.y+100);
		
		var url = '';
		var src = '';
		src = $('picSrcHidden_'+id).get('value');
		url = 'explorateur.php?type=LIST&src='+src+'&id='+id;
		var request = new Request({
			url:url,
			evalScripts:true,
			method:'get',
			onComplete: function(response) {
				$('popupBoxContain').removeClass('loading');
				$('popupBoxContain').set('html',response);
				setUpload();
			}
		}).send();
}

function deletePic(id,del,us){
		$('popupBoxContain').empty();
		$('popupBoxContain').addClass('loading');
		var url = '';
		var src = '';
		src = $('picSrcHidden_'+id).get('value');
		url = 'explorateur.php?type=LIST&src='+src+'&id='+id+'&del='+del;
		var request = new Request({
			url:url,
			evalScripts:true,
			method:'get',
			onComplete: function(response) {
				$('popupBoxContain').removeClass('loading');
				$('popupBoxContain').set('html',response);
				setUpload();
			}
		}).send();
}

function choosePic(id,src,us){
	$('picSrcHidden_'+id).set('value','data/members/member_'+us+'/images/'+src);
	//$('picPreviewBox_'+id).setStyle('background','#fff url(resizer.php?imgfile=data/member_'+id+'/images/'+src+'&max_width=125&max_height=125) center center no-repeat;');
	$('picPreviewBox_'+id).set('style','background: #fff url(resizer.php?imgfile=data/members/member_'+us+'/images/'+src+'&max_width=125&max_height=125) center center no-repeat;');
	popupBoxClose();
}

function popupBox(title, type){
	var hiddenMode = $('hidden_mode').get('value');
	if((type == 'CAT' && hiddenMode == 'cat') || type == 'REG' ){
		var bodySize = $('body').getScrollSize();
		$('cacheLayer').setStyle('height',bodySize.y);
		$('cacheLayer').removeClass('hide');
		
		$('titleBarText').set('html',title);
		$('popupBoxContain').addClass('loading');
		//$('popupBox').fade('hide');
		$('popupBox').removeClass('hide');
		//$('popupBox').fade('in');
		var url = '';
		var listID = '';
		switch(type){
			case"REG":
				listID = $('hidden_reg').get('value');
				url = 'ajaxBox.php?type=REG&listID='+listID;
				$('popupBox').removeClass('who');
				$('popupBox').removeClass('explo');
				$('popupBox').addClass('where');
			break;
			case"CAT":
				listID = $('hidden_cat').get('value');
				url = 'ajaxBox.php?type=CAT&listID='+listID;
				$('popupBox').removeClass('where');
				$('popupBox').removeClass('explo');
				$('popupBox').addClass('who');
			break;
		}
		var request = new Request({
			url:url,
			evalScripts:true,
			method:'get',
			onComplete: function(response) {
				$('popupBoxContain').removeClass('loading');
				$('popupBoxContain').set('html',response);
				switch(type){
					case"REG":
						activeRegLink();
						activeSearchReg();
					break;
					case"CAT":
						activeCatLink();
						activeSearchCat();
					break;
				}
				
			}
		}).send();
	}
}
	
	function popupBoxClose(){
		$('popupBoxContain').empty();
		$('popupBoxContain').removeClass('loading');
		$('popupBox').addClass('hide');
		$('cacheLayer').addClass('hide');
		$('popupBox').setStyle('top',null);
	}
	
	function activeSearchReg(){
		$('regSearch').addEvent('click', function(e){
			$('regSearch').set('value','');
		});
		$('regSearch').addEvent('keyup', function(e){
			var val = $('regSearch').get('value');
			if(val.length >= 3){
				$('listAllReg').empty();
				$('listAllReg').addClass('loading');
				var url = 'ajaxBox.php?type=REG&listOnly=true&search='+val;
				var request = new Request({
					url:url,
					evalScripts:true,
					method:'get',
					onComplete: function(response) {
						$('listAllReg').removeClass('loading');
						$('listAllReg').set('html',response);
						activeRegLink();
					}
				}).send();
			}
		});
	}
	
	function activeSearchCat(){
		$('catSearch').addEvent('click', function(e){
			$('catSearch').set('value','');
		});
		$('catSearch').addEvent('keyup', function(e){
			var val = $('catSearch').get('value');
			if(val.length >= 3){
				$('listAllCat').empty();
				$('listAllCat').addClass('loading');
				var url = 'ajaxBox.php?type=CAT&listOnly=true&search='+val;
				var request = new Request({
					url:url,
					evalScripts:true,
					method:'get',
					onComplete: function(response) {
						$('listAllCat').removeClass('loading');
						$('listAllCat').set('html',response);
						activeCatLink();
					}
				}).send();
			}
		});
	}
	
	function activeRegLink(){
		$$('#listAllReg li').each(function(element){
			element.addEvent('mouseover', function(e){
				this.addClass('over');
			});
			element.addEvent('mouseout', function(e){
				this.removeClass('over');
			});
		});
		$$('#listAllReg a.haveChild').each(function(element){
			element.addEvent('click', function(e){
				new Event(e).stop();
				var idR = element.get('title');
				$('listAllReg').addClass('loading');
				var listID = $('hidden_reg').get('value');
				var url = 'ajaxBox.php?type=REG&listOnly=true&parent='+idR+'&listID='+listID;
				var request = new Request({
					url:url,
					evalScripts:true,
					method:'get',
					onComplete: function(response) {
						$('listAllReg').removeClass('loading');
						$('listAllReg').set('html',response);
						activeRegLink();
					}
				}).send();
			});
		});
		$$('#listAllReg a.noChild').each(function(element){
			element.addEvent('click', function(e){
				new Event(e).stop();
				var idR = element.get('title');
				$('hidden_reg').set('value',idR);
				$('searchInputWhere').set('value',element.get('alt'));
				popupBoxClose();
			});
		});
	}
	
	function activeCatLink(){
		$$('#listAllCat li').each(function(element){
			element.addEvent('mouseover', function(e){
				this.addClass('over');
			});
			element.addEvent('mouseout', function(e){
				this.removeClass('over');
			});
		});
		$$('#listAllCat a.haveChild').each(function(element){
			element.addEvent('click', function(e){
				new Event(e).stop();
				var idR = element.get('title');
				$('listAllCat').addClass('loading');
				var listID = $('hidden_cat').get('value');
				var url = 'ajaxBox.php?type=CAT&listOnly=true&parent='+idR+'&listID='+listID;
				var request = new Request({
					url:url,
					evalScripts:true,
					method:'get',
					onComplete: function(response) {
						$('listAllCat').removeClass('loading');
						$('listAllCat').set('html',response);
						activeCatLink();
					}
				}).send();
			});
		});
		$$('#listAllCat a.noChild').each(function(element){
			element.addEvent('click', function(e){
				new Event(e).stop();
				var idR = element.get('title');
				$('hidden_cat').set('value',idR);
				$('searchInputWho').set('value',element.get('alt'));
				popupBoxClose();
			});
		});
	}
	
	function choiceRegLink(){
		$$('#listAllReg a.noChild').each(function(element){
			element.addEvent('click', function(e){
				new Event(e).stop();
				var idR = element.get('title');
				$('listActiveReg').addClass('loading');
				$('listActiveReg').empty();
				var listID = $('hidden_reg').get('value');
				
				var arrayID = listID.split(';');
				if(in_array(idR,arrayID) == false){
					arrayID.push(idR);
				}
				
				var no = 0;
				var cleanArray = Array();
				for(var x=0;x<arrayID.length;x++){
					if(arrayID[x]!=''){
						cleanArray[no] = arrayID[x];
						no++;
					}
				}
				
				var strID = cleanArray.join(';');
				$('hidden_reg').set('value',strID);
				var url = 'ajaxBox.php?type=REGCHOICE&listID='+strID;
				var request = new Request({
					url:url,
					evalScripts:true,
					method:'get',
					onComplete: function(response) {
						$('listActiveReg').removeClass('loading');
						$('listActiveReg').set('html',response);
						$('input_reg').set('html',response);
						choiceDelLink();
					}
				}).send();
			});
		});
	} 
	
var ajaxBoxHome = new Class({
	options: {
		showRefresh: true,
		autoRefresh: false,
		showDuration: 10000,
		source: 'ajaxBox.php'
	},
	Implements: [Options,Events],
	initialize: function(boxID,containerID,refreshID,options) {
		this.boxID = $(boxID);
		this.container = $(containerID);
		this.refresh = $(refreshID);
		
		if(options.source != ''){ this.source = options.source }
		if(options.showRefresh != ''){ this.showRefresh = options.showRefresh }
		if(options.autoRefresh != ''){ this.autoRefresh = options.autoRefresh }
		if(options.showDuration != ''){ this.showDuration = options.showDuration }
		
		//active refresh
		this.activeRefresh();
		
		//events
		this.container.addEvents({
			mouseenter: function() { this.stop(); }.bind(this),
			mouseleave: function() { this.start(); }.bind(this)
		});
		
		//this.show();
		
	},
	show: function() {
		this.container.empty();
		this.container.fade('hide');
		var container = this.container;
		var request = new Request({
			container: this.container,
			url:this.source,
			evalScripts:true,
			method:'get',
			onComplete: function(response) {
				container.set('html',response);
				container.fade('in');
				$$("#"+container.getAttribute('id')+" a").filter(function(el) {
					return el.rel && el.rel.test(/^lightbox/i);
				}).slimbox({/* Put custom options here */}, null, function(el) {
					return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
				});
			}
		}).send();
	},
	start: function() {
		if(this.autoRefresh == true){
			this.interval = this.show.bind(this).periodical(this.showDuration);
		}
	},
	stop: function() {
		if(this.autoRefresh == true){
			$clear(this.interval);
		}
	},
	activeRefresh: function() {
		if(this.showRefresh == true){
			var container = this.container;
			var source = this.source;
			this.refresh.addEvent('click', function(e){
				new Event(e).stop();
				container.empty();
				container.fade('hide');
				//var container = this.container;
				var request = new Request({
					container: container,
					url:source,
					evalScripts:true,
					method:'get',
					onComplete: function(response) {
						container.set('html',response);
						container.fade('in');
						$$("#"+container.getAttribute('id')+" a").filter(function(el) {
							return el.rel && el.rel.test(/^lightbox/i);
						}).slimbox({/* Put custom options here */}, null, function(el) {
							return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
						});
					}
				}).send();
			});
		}else{
			this.refresh.setStyle('display','none');
		}
	}
});

var SimpleSlideshow = new Class({
	options: {
		showControls: true,
		showDuration: 10000,
		showTOC: false,
		tocWidth: 20,
		tocClass: 'toc',
		tocActiveClass: 'toc-active'
	},
	Implements: [Options,Events],
	initialize: function(container,elements,options) {
		//settings
		this.container = $(container);
		this.elements = $$(elements);
		this.currentIndex = 0;
		this.interval = '';
		if(this.options.showTOC) this.toc = [];
		
		//assign
		this.elements.each(function(el,i){
			if(this.options.showTOC) {
				this.toc.push(new Element('a',{
					text: i+1,
					href: '#',
					'class': this.options.tocClass + '' + (i == 0 ? ' ' + this.options.tocActiveClass : ''),
					events: {
						click: function(e) {
							if(e) e.stop();
							this.stop();
							this.show(i);
						}.bind(this)
					},
					styles: {
						left: ((i + 1) * (this.options.tocWidth + 10))
					}
				}).inject(this.container));
			}
			if(i > 0) el.set('opacity',0);
		},this);
		
		//next,previous links
		if(this.options.showControls) {
			this.createControls();
			
		}
		//events
		this.container.addEvents({
			mouseenter: function() { this.stop(); }.bind(this),
			mouseleave: function() { this.start(); }.bind(this)
		});

	},
	show: function(to) {
		this.elements[this.currentIndex].fade('out');
		if(this.options.showTOC) this.toc[this.currentIndex].removeClass(this.options.tocActiveClass);
		this.elements[this.currentIndex = ($defined(to) ? to : (this.currentIndex < this.elements.length - 1 ? this.currentIndex+1 : 0))].fade('in');
		if(this.options.showTOC) this.toc[this.currentIndex].addClass(this.options.tocActiveClass);
	},
	start: function() {
		this.interval = this.show.bind(this).periodical(this.options.showDuration);
	},
	stop: function() {
		$clear(this.interval);
	},
	//"private"
	createControls: function() {
		
		/*var next = $('arrowRight');
		next.addEvent('click', function(e){
			if(e){
				e.stop();
			}
			SimpleSlideshow.stop();
			SimpleSlideshow.show();
		});
		var previous = $('arrowLeft');
		previous.addEvent('click', function(e){
			if(e){
				e.stop();
			}
			SimpleSlideshow.stop();
			SimpleSlideshow.show(this.currentIndex != 0 ? this.currentIndex -1 : this.elements.length-1);
		});*/
		var next = new Element('a',{
			href: '#',
			events: {
				click: function(e) {
					if(e) e.stop();
					this.stop();
					this.show();
				}.bind(this)
			}
		}).inject(this.container);
		next.set('class','arrowRight');
		var previous = new Element('a',{
			href: '#',
			events: {
				click: function(e) {
					if(e) e.stop();
					this.stop();
					this.show(this.currentIndex != 0 ? this.currentIndex -1 : this.elements.length-1);
				}.bind(this)
			}
		}).inject(this.container);
		previous.set('class','arrowLeft');
	}
});


function activeOpenClose(){
	var toggles = $$('.titleToClick');
	var content = $$('.blockToHide');
	
	var AccordionObject = new MultipleOpenAccordion($('AccordionMulti'), {
		togglers : toggles,
		elements : content,
		openAll : true, 
		height : true,
		width : false,
		opacity: true,
		fixedHeight: false, 
		fixedWidth: false,
		onActive : function(toggler,section){ toggler.removeClass('btn_more'); toggler.addClass('btn_less'); },
		onBackground : function(toggler,section){ toggler.removeClass('btn_less'); toggler.addClass('btn_more'); }
	});
}

function showNews(idN){
	var btnNews = $('btnNews_'+idN);
	var resumeNews = $('newsResume_'+idN);
	var allNews = $('newsAll_'+idN);
	
	var resumeEffect = new Fx.Slide('newsResume_'+idN);
	var allEffect = new Fx.Slide('newsAll_'+idN,{createWrap:false});

	if(btnNews.hasClass('btn_voir_la_suite')){
		btnNews.removeClass('btn_voir_la_suite');
		btnNews.addClass('btn_refermer');
		resumeEffect.slideOut();
		allEffect.slideIn();
	}else{
		btnNews.addClass('btn_voir_la_suite');
		btnNews.removeClass('btn_refermer');
		/*var wrapperResume = resumeNews.retrieve('wrapper');
		var wrapperAll = allNews.retrieve('wrapper');
		wrapperResume.setStyle('height',0);
		wrapperAll.setStyle('height',0);
		resumeEffect.slideIn();*/
		allEffect.slideOut();
		resumeEffect.slideIn();
	}
}

function showJob(idJ){
	var btnJob = $('btnJob_'+idJ);
	var resumeJob = $('jobResume_'+idJ);
	var allJob = $('jobAll_'+idJ);
	
	var resumeEffect = new Fx.Slide('jobResume_'+idJ);
	var allEffect = new Fx.Slide('jobAll_'+idJ,{createWrap:false});

	if(btnJob.hasClass('btn_voir_la_suite')){
		btnJob.removeClass('btn_voir_la_suite');
		btnJob.addClass('btn_refermer');
		resumeEffect.slideOut();
		allEffect.slideIn();
	}else{
		btnJob.addClass('btn_voir_la_suite');
		btnJob.removeClass('btn_refermer');
		/*var wrapperResume = resumeNews.retrieve('wrapper');
		var wrapperAll = allNews.retrieve('wrapper');
		wrapperResume.setStyle('height',0);
		wrapperAll.setStyle('height',0);
		resumeEffect.slideIn();*/
		allEffect.slideOut();
		resumeEffect.slideIn();
	}
}

function linkConfirm(){
	$$('a.confirm').each(function(element){
		element.removeEvents('click');
		element.addEvent('click', function(e){
			new Event(e).stop();
			var msg = 'Voulez-vous vraiment supprimer cet item ?';
			if(this.getAttribute('msg') != null){ msg = this.getAttribute('msg'); }
			var promptResult = confirm(msg);
			if(promptResult){
				if(this.hasClass('doubleconfirm')){
					var msg2 = 'Êtes vous vraiment sur de vouloir supprimer cet item ?';
					if(this.getAttribute('msg2') != null){ msg2 = this.getAttribute('msg2'); }
					var promptResult2 = confirm(msg2);
					if(promptResult2){
						document.location = this.href;
					}
				}else{
					document.location = this.href;
				}
			}
		});
	});
}



function emptyBoxPic(sufix){
	$('picSrcHidden_'+sufix).set('value','');
	$('picPreviewBox_'+sufix).set('style','');
}

function loadAjaxModule(urlAjax, container, mode, idEle){
	urlAjax = 'inc/app/block/compte/ajax/'+urlAjax+'.php?m='+mode+'&id='+idEle;
	container.empty();
	container.addClass('loading');
	var request = new Request({
		container: container,
		url:urlAjax,
		evalScripts:true,
		method:'post',
		onComplete: function(response) {
			container.set('html',response);
			container.removeClass('loading');
			if($(container.getAttribute('id')+'Form')){
				setAjaxForm(container.getAttribute('id')+'Form',container);
			}
			if($(container.getAttribute('id')+'Editor')){
				var editorClass = $(container.getAttribute('id')+'Editor').get('class');
				loadEditor(editorClass,container.getAttribute('id')+'Editor');
			}
			if($('date')){
				new CalendarEightysix('date',{ theme:'default', format: '%d/%m/%Y' });
			}
			if($('date2')){
				new CalendarEightysix('date2',{ theme:'default', format: '%d/%m/%Y' });
			}
			linkConfirm();
			
			// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
				$$("#"+container.get('id')+" a").filter(function(el) {
					return el.rel && el.rel.test(/^lightbox/i);
				}).slimbox({/* Put custom options here */}, null, function(el) {
					return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
				});
		}
	}).send();
}

function addVote(idP){
	urlAjax = 'exe.php?m=addLike&idP='+idP;
	var container = $('boxVoteNb'+idP);
	var request = new Request({
		container: container,
		url:urlAjax,
		evalScripts:true,
		method:'post',
		onComplete: function(response) {
			container.set('html',response);
		}
	}).send();
}

function setAjaxForm(formID,container){
	var form = $(formID);
	form.addEvent('submit', function(e) {
		new Event(e).stop();
		$$('#'+container.getAttribute('id')+' textarea').each(function(eleForm){
			toggleEditor(eleForm.getAttribute('id'));
		});

		var logContainer = container.addClass('loading');
		this.set('send',{
			evalScripts: true, 
			onRequest: function(response) {
				logContainer.empty();
			},
			onComplete: function(response) {
				logContainer.removeClass('loading');
				logContainer.set('html', response);
				if($(logContainer.getAttribute('id')+'Form')){
					setAjaxForm(logContainer.getAttribute('id')+'Form',logContainer);
				}
				if($(logContainer.getAttribute('id')+'Editor')){
					var editorClass = $(logContainer.getAttribute('id')+'Editor').getAttribute('class');
					loadEditor(editorClass,logContainer.getAttribute('id')+'Editor');
				}
				if($('date')){
					new CalendarEightysix('date',{ theme:'default', format: '%d/%m/%Y' });
				}
				if($('date2')){
					new CalendarEightysix('date2',{ theme:'default', format: '%d/%m/%Y' });
				}
				linkConfirm();
			}
		});
		this.send();
	});
}

function setUpload(){
	window.addEvent('domready', function() {
	/* SCRIPT UPLOAD */
				var pathUp = 'inc/app/block/compte/upload.php?m=upload&us='+$('hiddenUS').get('value');
				var up = new FancyUpload3.Attach('list-upload', '#btn-upload', {
							path: 'inc/app/script/upload/source/Swiff.Uploader.swf',
							url: pathUp,
							fileSizeMax: 1 * 1024 * 1024,
					 		typeFilter: {
								'Images (*.jpg, *.jpeg, *.gif)': '*.jpg; *.jpeg; *.gif;'
							},
							verbose: true,
					 		timeLimit: 30,
							onSelectFail: function(files) {
								files.each(function(file) {
									new Element('li', {
										'class': 'file-invalid',
										events: {
											click: function() {
												this.destroy();
											}
										}
									}).adopt(
										new Element('span', {html: file.validationErrorMessage || file.validationError})
									).inject(this.list, 'bottom');
								}, this);	
							},
					 
							onFileSuccess: function(file,txt) {
								var result = JSON.decode(file.response.text, true); // secure decode
								file.ui.element.highlight('#e6efc2');
								openExplo($('hiddenID').get('value'));
							},
					 
							onFileError: function(file) {
								file.ui.cancel.set('html', 'Retry').removeEvents().addEvent('click', function() {
									file.requeue();
									return false;
								});
					 
								new Element('span', {
									html: file.errorMessage,
									'class': 'file-error'
								}).inject(file.ui.cancel, 'after');
							},
					 
							onFileRequeue: function(file) {
								file.ui.element.getElement('.file-error').destroy();
					 
								file.ui.cancel.set('html', 'Cancel').removeEvents().addEvent('click', function() {
									file.remove();
									return false;
								});
					 
								this.start();
							}
					 
						});
	});

}

function showHide(idEle){
	var ele = $(idEle);
	if(ele.hasClass('hide')){
		ele.removeClass('hide');
	}else{
		ele.addClass('hide');
	}
}

function switchSearchMode(){
	var hiddenMode = $('hidden_mode');
	if(hiddenMode.get('value') == 'cat'){
		$('searchBox').addClass('who');
		$('searchInputWho').set('value','Recherche par nom d\'entreprise');
		hiddenMode.set('value','who');
		$('linkSwitchMode').set('html','Cherchez par cat&eacute;gorie');
	}else{
		$('searchBox').removeClass('who');
		$('searchInputWho').set('value','Recherche par mot cle');
		hiddenMode.set('value','cat');
		$('linkSwitchMode').set('html','Cherchez par nom d\'entreprise');
	}
}

function fix_inline_PNGs(){
	if (Browser.Engine.name=='trident' && Browser.Engine.version==4) {
		var images = $$('img'); // liste de tous les élément <img /> du document
		images.each(function(e){
			var this_src = e.getProperty('src');
			//var size = e.getSize();
			var this_height = e.height;
			var this_width = e.width;
			var styleImg = e.getStyles('float', 'margin', 'padding');
			if (this_src.toUpperCase().contains('.PNG')){
				var this_new = new Element('span', {
				'styles': {
				'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+this_src+'\', sizingMethod=\'scale\')',
				'display': 'inline-block',
				'height': this_height,
				'width': this_width
				}});
				this_new.replaces(e);
				this_new.setStyles(styleImg);
			}
		});
		var images = $$('input'); // liste de tous les élément <img /> du document
		images.each(function(e){
			if(e.getAttribute('type') == 'image'){
				var this_src = e.getProperty('src');
				//var size = e.getSize();
				var this_height = e.height;
				var this_width = e.width;
				var styleImg = e.getStyles('float', 'margin', 'padding');
				if (this_src.toUpperCase().contains('.PNG')){
					var this_new = new Element('a', {
					'styles': {
					'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+this_src+'\', sizingMethod=\'scale\')',
					'display': 'inline-block',
					'height': this_height,
					'width': this_width,
					'cursor': 'pointer'
					}});
					this_new.replaces(e);
					this_new.setStyles(styleImg);
					this_new.set('href','#');
					this_new.addEvent('click', function(e){
						this.getParent('form').submit();
					});
				}
			}
		});
	}
}