
// JavaScript Document
window.addEvent('domready', function() {
									 
	if($('fb-modal')){
		/* hide using opacity on page load */
		$('fb-modal').setStyles({
			opacity:0,
			display:'block'
		});
		/* hiders */
		$('fb-close').addEvent('click',function(e) { $('fb-modal').fade('out'); });
		window.addEvent('keypress',function(e) { if(e.key == 'esc') { $('fb-modal').fade('out'); } });
		$(document.body).addEvent('click',function(e) { 
			if($('fb-modal').get('opacity') == 1 && !e.target.getParent('.generic_dialog')) { 
				$('fb-modal').fade('out'); 
			} 
		});
		/* click to show */
		$('fb-trigger').addEvent('click',function(e) {
			new Event(e).stop();
			$('fb-modal').fade('in');
		});
	}
	
	if($('btn_unjour')){
		$('btn_unjour').addEvent('click', function(e){
			new Event(e).stop();
			$$('#boxSousOnglet a').each(function(element) {
				element.removeClass('actif');
			});
			$('btn_unjour').addClass('actif');
			$$('.boxDayResult').each(function(element) {
				element.removeClass('actif');
			});
			$('result_unjour').addClass('actif');
		});
	}
	if($('btn_deuxjours')){
		$('btn_deuxjours').addEvent('click', function(e){
			new Event(e).stop();
			$$('#boxSousOnglet a').each(function(element) {
				element.removeClass('actif');
			});
			$('btn_deuxjours').addClass('actif');
			$$('.boxDayResult').each(function(element) {
				element.removeClass('actif');
			});
			$('result_deuxjours').addClass('actif');
		});
	}
	if($('btn_septjours')){
		$('btn_septjours').addEvent('click', function(e){
			new Event(e).stop();
			$$('#boxSousOnglet a').each(function(element) {
				element.removeClass('actif');
			});
			$('btn_septjours').addClass('actif');
			$$('.boxDayResult').each(function(element) {
				element.removeClass('actif');
			});
			$('result_septjours').addClass('actif');
		});
	}
	if($('btn_trentejours')){
		$('btn_trentejours').addEvent('click', function(e){
			new Event(e).stop();
			$$('#boxSousOnglet a').each(function(element) {
				element.removeClass('actif');
			});
			$('btn_trentejours').addClass('actif');
			$$('.boxDayResult').each(function(element) {
				element.removeClass('actif');
			});
			$('result_trentejours').addClass('actif');
		});
	}
	
	if($('idArtCatAll')){
		$('idArtCatAll').addEvent('click', function(e){
			$$('input.checkRub').each(function(element) {
				if(element.checked == true){
					element.checked = false;
				}else{
					element.checked = true;
				}
			});
		});
	}
	
	if($('idChroCatAll')){
		$('idChroCatAll').addEvent('click', function(e){
			$$('input.checkChro').each(function(element) {
				if(element.checked == true){
					element.checked = false;
				}else{
					element.checked = true;
				}
			});
		});
	}
									 
	var list = $$('a.expandBanner');
	list.each(function(element) {
		
		//var fx = new Fx.Styles(element, {duration:200, wait:false});

		element.addEvent('mouseenter', function(){
			this.set('tween', {duration: 1}); 
			this.tween(this.getAttribute('type'), this.getAttribute('max'));
		});
	 
		element.addEvent('mouseleave', function(){
			this.set('tween', {duration: 1}); 
			this.tween(this.getAttribute('type'), this.getAttribute('min'));
		});
	 
	});
	
	
	$$('#shareBox a.btnComments').each(function(element) {
		element.addEvent('click', function(e){
			new Event(e).stop();
			if($('listCom')){
				var commentBox = $('listCom');
				if(commentBox.style.display == 'block'){
					commentBox.style.display = 'none';
				}else{
					commentBox.style.display = 'block';
				}
			}
		});
	});
	
	$$('#shareBox a.btnReact').each(function(element) {
		element.addEvent('click', function(e){
			new Event(e).stop();
			$('cryptogram').src='./crypt/cryptographp.php?cfg=0&&'+Math.round(Math.random(0)*1000)+1
			if($('commentBox')){
				var commentBox = $('commentBox');
				if(commentBox.style.display == 'block'){
					commentBox.style.display = 'none';
				}else{
					commentBox.style.display = 'block';
				}
			}
		});
	});
	
	$('selectFast').addEvent('change', function(){
		document.location = $('selectFast').get('value');
	});
	
	if($('fastPageNav')){
		$('fastPageNav').addEvent('change', function(){
			document.location = $('fastPageNav').get('value');
		});
	}
	
	
	if($('txtRoll')){
		var sliderWord = new mooquee($('txtRoll'), {marWidth: 726, marHeight: 21, direction: 'left'});
	}
	
	if($('sDate')){
		new CalendarEightysix('sDate', { 'toggler': 'sDate-picker', 'theme': 'vista', 'prefill': false });
	}
	if($('eDate')){
		new CalendarEightysix('eDate', { 'toggler': 'eDate-picker', 'theme': 'vista', 'prefill': false  });
	}
	if($('curDate')){
		new CalendarEightysix('curDate', { 'toggler': 'curDate-picker', 'theme': 'vista', 'prefill': false  });
	}
	
});

function confirmAlert(url){
	var confirmVar = confirm('Voulez-vous vraiment supprimer cette annonce ?');
	if(confirmVar){
		document.location = url;
	}
}

function goFastLink(){
	var linkVal = $('selectFast').get('value');
	if(linkVal != ''){
		document.location = linkVal;
	}
}
