/*Pour centrer la popup au centre de la page*/
Int_w = 740;
Int_h = 550;
Float_larg = (screen.width/2) - (Int_w/2);
Float_haut = (screen.height/2) - (Int_h/2);

/*Pour la popup du mot de pass oublié*/
Int_larg = 300;
Int_haut = 100;
Float_w = (screen.width/2) - (Int_larg/2);
Float_h = (screen.height/2) - (Int_haut/2);

/*Pour la popup de mention légal*/
Int_large = 300;
Int_haute = 500;
Float_we = (screen.width/2) - (Int_large/2);
Float_he = (screen.height/2) - (Int_haute/2);
/* -------- SCRIPT MENU ---------- */
function rollOver(el){ 
	return function() {
		el.addClassName('cv_menuHover');
		if(el.childElements().length > 1){
			if($$(".cv_menuOn")[0]) $$(".cv_menuOn")[0].childElements()[0].addClassName('cv_SubMenuHide');
		}
	}
}

function rollOut(el){ 
	return function() {
		el.removeClassName('cv_menuHover');
		if(el.childElements().length > 1){
			if($$(".cv_menuOn")[0]) $$(".cv_menuOn")[0].childElements()[0].removeClassName('cv_SubMenuHide');
		}
	}
}

function menuDynamic(){
	if($("navigation")){
		$("navigation").childElements().each( function(menu){
			if(menu.hasClassName("cv_menuOn") == false){		
				menu.observe('mouseover', rollOver(menu));
				menu.observe('mouseout', rollOut(menu));
			}
		});
	}
}

function menuActif(menu, smenu, ssmenu, sssmenu){
	if($(menu))	$(menu).addClassName('cv_menuOn');
	if($(smenu)) $(smenu).addClassName('cv_SubMenuOn');
	if($(ssmenu)) $(ssmenu).addClassName('cv_SubSubMenuOn');
	if($(sssmenu)) $(sssmenu).addClassName('cv_SubSubSubMenuOn');	
	menuDynamic();
}

/* Fonction pour afficher les formulaires de recrutemenet */
function displayForm(){
	if($('check_condition').checked == true){
		$('form_field').setStyle({
			display: 'block'
		});
	}
	else{
		$('form_field').setStyle({
			display: 'none'
		});
	}
		
}

/*Fonction pour centrer les images en accueil */
function imageCenter(){
	var decalage = -($("img_roll").getWidth() / 2);	
	$("img_roll").setStyle({
		left: decalage+"px"
		//display: "none"
	});
}
iscroll=0;
seconde = 5;
function scrollImage(){		

			$("img_roll").src = $$( "#img_aleatoire img")[iscroll].src;
			$("img_roll").alt = $$( "#img_aleatoire img")[iscroll].alt;
			$("img_roll").width = $$( "#img_aleatoire img")[iscroll].getWidth();
			//alert("img"+iscroll+"= "+$$( "#img_aleatoire img")[iscroll].getWidth()+" et "+$("img_roll").getWidth());
			imageCenter();
			Effect.toggle($("img_roll"), 'appear' );//apparait
			setTimeout("Effect.toggle($('img_roll'), 'appear' );", seconde*1000); //disparait
			if( iscroll == $$("#img_aleatoire img").length - 1){
				iscroll = 0;
			}
			else{
				iscroll++;
			}	
		
			setTimeout("scrollImage()", seconde*1300);		
		
		
		/*if(seconde == 1){
			$("img_roll").src = $$( "#img_aleatoire img")[iscroll].src;
			$("img_roll").alt = $$( "#img_aleatoire img")[iscroll].alt;
			$("img_roll").width = $$( "#img_aleatoire img")[iscroll].getWidth();
			//alert("img"+iscroll+"= "+$$( "#img_aleatoire img")[iscroll].getWidth()+" et "+$("img_roll").getWidth());
			imageCenter();
			Effect.toggle($("img_roll"), 'appear' );
			seconde = 5;			
			setTimeout("scrollImage()", seconde*1000);
		}
		else{
			Effect.toggle($("img_roll"), 'appear' );
			if( iscroll == $$("#img_aleatoire img").length - 1){
				iscroll = 0;
			}
			else{
				iscroll++;
			}	
			seconde = 1;			
			setTimeout("scrollImage()", seconde*1000);		
		}		*/
}
x=420;
y=2;
function scrollText(){
	/*new Effect.Move( $$(".scrolltextContent")[0],{
		duration: 30.0, 
		transition: Effect.Transitions.linear,
		x: - $$(".scrolltextContent")[0].getWidth(),
		y:0,
		mode: 'relative'
	});*/
	$$(".scrolltextContent")[0].observe('mouseover', function(){
		y=0;
	});
	$$(".scrolltextContent")[0].observe('mouseout', function(){
		y=2;
	});
	x -= y;
	$$(".scrolltextContent")[0].setStyle({ left: x+"px"});
	if(x <= - $$(".scrolltextContent")[0].getWidth()) x=420;
	setTimeout("scrollText()", 50);
}



/*------------------- PLAN SITE --------------------*/

function accordionPlan(){
	$$(".accordion_toggle").each(function(toggy){
		Event.observe(toggy, 'mouseover', function(){
			if(toggy.childElements()[1].getStyle('display') == 'none'){
				$$(".accordion_content").each(function(conty){
					if(conty.getStyle('display') != 'none'){
						Effect.SlideUp(conty, {duration:0.2});
					}
				});
				Effect.SlideDown(toggy.childElements()[1], {duration:0.3});
				toggy.childElements()[1].setStyle({
					height: ''
				});
			}
		});
	});
}