// affiche les rubriques
function deroul(obj,nbr) {  

if (document.getElementById(obj).className == 'masquageHide') {
       for (i=1; i<=nbr; i++) {
       document.getElementById("obj" + i).className = "masquageHide";
       document.getElementById("img" + i).src = "../img/btn_closed.jpg";
        }       
	   document.getElementById( obj ).className = "masquageShow";
	   document.getElementById("img"+ obj.substr(3) ).src = "../img/btn_open.jpg";
}
else { 
   document.getElementById(obj).className = 'masquageHide' ; 
   document.getElementById("img"+ obj.substr(3) ).src = "../img/btn_closed.jpg";
   }
}


// affiche les rubriques
function deroul2(obj) {  
nbr=$('#conteneurG2 h2').length;
if (document.getElementById(obj).className == 'masquageHide') {
       for (i=1; i<=nbr; i++) {
       document.getElementById("obj" + i).className = "masquageHide";
       document.getElementById("img" + i).src = "../img/btn_closed.jpg";
        }       
	   document.getElementById( obj ).className = "masquageShow";
	   document.getElementById("img"+ obj.substr(3) ).src = "../img/btn_open.jpg";
}
else { 
   document.getElementById(obj).className = 'masquageHide' ; 
   document.getElementById("img"+ obj.substr(3) ).src = "../img/btn_closed.jpg";
   }
}



//prepare un email crypté
function ecrit_mail(address, libelle,domain) {  

	var first = 'ma';
	var second = 'il';
	var third = 'to:';
	var address = address;
	//var domain = 'pfdlex';
	//var ext = 'com'; 
	document.write('<a href="');
	document.write(first+second+third);
	document.write(address);
	document.write('&#64;');
	document.write(domain);
	//document.write('.');
	//document.write(ext);  
	document.write('" class="lien">'); 
	document.write( libelle + '</a>');

}


function auto_slide(){
	slide_auto=1;
}


$(document).ready(function(){
 
    lar_m =  580 ;

	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.75, /* Value betwee 0 and 1 */
		showTitle: false, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
		overlay_gallery: true,
		callback: function(){}
	});



 

 
  currentPosition = 0;
  slideWidth = 580;
  slides = $('.slide');
  numberOfSlides = slides.length;

  // Remove scrollbar in JS
  $('#slidesContainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert controls in the DOM
  $('#slideshow')
    .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
    .append('<span class="control" id="rightControl">Clicking moves right</span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    clearTimeout(mytime);
	// Determine new position
	currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    
	// Hide / show controls
    manageControls(currentPosition);
    // Move slideInner using margin-left
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });
    mytime=window.setTimeout('declenche('+lar_m+');' , 5000); 

  });

  // manageControls: Hides and Shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
	if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
	// Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
  }	


mytime=window.setTimeout('declenche('+lar_m+');' , 5000); 


});


function declenche(px){
var nbr = numberOfSlides;
var margeG = $('#slideInner').css('marginLeft') ;
margeG=margeG.match(/[0-9]+/) ;
//alert(margeG);
if(margeG== lar_m*(nbr-1) ){ margeG=(-lar_m) ; }
//if(margeG==  lar_m*(nbr-1) ){ margeG=(-lar_m) ; $('#leftControl').hide() ; $('#rightControl').show() ;}
//if(margeG== 0){ $('#leftControl').show() ;}
 	$('#slideInner').animate({
    marginLeft: - (parseInt(margeG)+parseInt(px))
  }, 800, 'linear', function() {
  var margeG = $('#slideInner').css('marginLeft') ;
  margeG=margeG.match(/[0-9]+/) ;
  if(margeG== 0){ $('#leftControl').hide() ;$('#rightControl').show() ;currentPosition = 0;}
  else if(margeG== lar_m*(nbr-1)){ $('#rightControl').hide() ; currentPosition = nbr;}
  else if(margeG< lar_m*(nbr-1)  && margeG>0){ $('#rightControl').show() ;$('#leftControl').show() ;currentPosition++;}
 });
    mytime=window.setTimeout('declenche('+lar_m+');' , 5000);
    
 }
  
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

function change_staff(){
 document.form_staff.action = document.form_staff.staff.value; 
 document.form_staff.submit() ; 


}
  
