/********************************************************
 ***************** SUR TOUTES LES PAGES *****************
 *******************************************************/
 
$(window).load(function(){ 
	var contenuHight = ($('#contenu').height());
	$('#contenu .bandeDroite').height(contenuHight);
});

/********************************************************
 ********************* PAGE ACCUEIL *********************
 *******************************************************/
/*
 * SlideShow
 */
$('#photoAccueil').bxSlider({
	mode: 'fade',
	controls: false,
	auto: true,
	pause: 6000,
	speed:500
});

/*
 * Transition couleurs
 */


if(url_p == 1){
	var iterateur = 2;
	var color;

	function getColorFromIte(){
		if(iterateur==1){color=color1;}
		else if(iterateur==2){color=color2;}
		else if(iterateur==3){color=color3;}
		else if(iterateur==4){color=color4;}
		else{color=color5;}
		if(color==''){
			if(iterateur>4){iterateur=1}
			else{iterateur++;}
			getColorFromIte();
			return false;
		}else{
			return color;
		}
	}
	function changeColor(color1, color2, color3, color4, color5){
		getColorFromIte();
		$('#contenu .bandeDroite, #collierSep').animate({backgroundColor:'#'+color}, 500);
		if(iterateur>4){iterateur=1}
		else{iterateur++;}
	}
	setInterval('changeColor(color1, color2, color3, color4, color5)', 6000 );
}


/********************************************************
 ********************* MENU PROJET **********************
 *******************************************************/
var bgColor = $('#collierSep').css('background-color');
$('#menuProjet li a').not('#menuProjet li a.active').hover(
	function(){$(this).stop().animate({ color: bgColor }, 80)},
	function(){$(this).stop().animate({ color:'#fff' }, 80)}
);
$('#menuProjet li a.active').css("color",bgColor);

/********************************************************
 ***************** MODULE DE RECHERCHE ******************
 *******************************************************/
 
/*
 * Onglet du haut
 */
// Initialisation
$('#ongletHaut .parProjet').addClass('actif');
$('#ongletGauche .parProjet').css('display', 'block');
// Effet onClik	
$('#ongletHaut .parVille, #ongletHaut .parProjet').click(function(){
	var selectedTab = $(this).attr('class');
	$('#ongletHaut .parVille, #ongletHaut .parProjet').removeClass('actif');
	$(this).addClass('actif');
	if(selectedTab != 'parVille actif' && selectedTab != 'parProjet actif'){
		$('#ongletGauche .parVille, #ongletGauche .parProjet, #moduleRecherche fieldset').hide(
			1,
			function(){ $('#ongletGauche .'+selectedTab).fadeIn('fast');}
		);
	}
});

/*
 * Onglet de gauche
 */
// Effet Hover
$('#ongletGauche .parVille li, #ongletGauche .parProjet li').hover(
	function(){
		$(this).find('h4').stop().animate({marginLeft:'20px', 'color':'#033f70'}, 100);
		$(this).find('p').stop().animate({marginLeft:'20px', 'color':'#033f70'}, 100);
	},
	function(){
		$(this).not('.actif').find('h4').stop().animate({marginLeft:'0px', 'color':'#000'}, 100);
		$(this).not('.actif').find('p').stop().animate({marginLeft:'0px', 'color':'#000'}, 100);
	}
);
// Effet onClick
$('#ongletGauche .parVille li, #ongletGauche .parProjet li').click(function(){
	// Initialise
	$('#ongletGauche .parVille li.actif h4, #ongletGauche .parProjet li.actif h4, #ongletGauche .parVille li.actif p, #ongletGauche .parProjet li.actif p').stop().animate({marginLeft:'0px', 'color':'#000'}, 100);
	$('#ongletGauche .parVille li.actif, #ongletGauche .parProjet li.actif').removeClass('actif');
	$('#moduleRecherche form fieldset').hide();
	// Applique
	var selectedsTab = $(this).attr('class');
	$(this).addClass('actif');
	$('#moduleRecherche form fieldset.'+selectedsTab).fadeIn('fast');
});

/*
 * Formulaire
 */
// BOUTTON POUR TOUT SELECTIONNER
$('#moduleRecherche form fieldset input.selectAll, #moduleRecherche form fieldset label.selectAll').toggle(
	function(){
		var parentClass = $(this).parent().attr('class');
		var $checkbox = $('#moduleRecherche form fieldset.'+parentClass).find(':checkbox');
		$checkbox.attr('checked', 'checked');
	},
	function(){
		var parentClass = $(this).parent().attr('class');
		var $checkbox = $('#moduleRecherche form fieldset.'+parentClass).find(':checkbox');
		$checkbox.removeAttr('checked');
	}
);

/*
 * Boutton hover automatique selon couleur de fond de «#collierSep»
 */
 var actualBgColor;
 $('.futurProjet, .btnValider div').hover(
 	function(){
		$(this).fadeTo('fast', 1)
	},		
 	function(){
		$(this).fadeTo(50, 0.4)
	}
);


/********************************************************
 ***************** MODULE DE DEMANDE ******************
 *******************************************************/
 
/*
 * Onglet du haut
 */
// Initialisation
$('#ongletHaut .'+ongletActive).addClass('actif');
$('form.'+ongletActive).css('display', 'block');
// Effet onClik	
$('#ongletHaut .info, #ongletHaut .rdv').click(function(){
	var selectedTab = $(this).attr('class');
	$('#ongletHaut .info, #ongletHaut .rdv').removeClass('actif');
	$(this).addClass('actif');
	if(selectedTab != 'info actif' && selectedTab != 'rdv actif'){
		$('form.info, form.rdv').hide(
			1,
			function(){ $('form.'+selectedTab).fadeIn('fast');}
		);
	}
});

