	$(document).ready(function()
{


//// debut
	
	 	$("#diapogroupe").click(function() {
		
		$("div.bob").fadeOut("fast");
		$("div.team").fadeOut("fast");
		$("#text li").animate({  // on ferme les panneaux déjà ouverts
			width: "1px",
			left: "370px"
		  	}, 500 );
		$("div#loader").show();
		$('.images').removeClass('slideactif');
		//prechargement des 2 premières images
		
		var aleatoire1 = Math.random()*99999;
		var aleatoire2 = Math.random()*99999;
		$('<img/>')
     	.attr('src', 'images/bg/dentan15.jpg?' + aleatoire1)
   		.load(function () {
		
		checkFinal(); 
    	 }); 
		$('<img/>')
     	.attr('src', 'images/bg/dentan16.jpg?' + aleatoire2)
   		.load(function () {
		
		checkFinal(); 
    	 }); 
	 
	 	 var loaded = 0; 
	 	function checkFinal(){ 
	   loaded++; 
	   
	   // lorsque les 2 images sont charg&eacute;es
	   if(loaded == 2){ 
	   
	   $("div#loader").hide();
	   $('.images').addClass('slideactif');
 			$('.images').html('<img src="images/bg/dentan15.jpg?' + aleatoire1 + '"  title="Groupe G. Dentan SA" /><img src="images/bg/dentan16.jpg?' + aleatoire2 + '"  title="Groupe G. Dentan SA" /><img src="images/bg/dentan11.jpg"  title="Groupe G. Dentan SA" /><img src="images/bg/dentan12.jpg"  title="Groupe G. Dentan SA" /><img src="images/bg/dentan13.jpg"  title="Groupe G. Dentan SA" /><img src="images/bg/dentan14.jpg"  title="Groupe G. Dentan SA" />');
	$('.images').galleria();
	

	$("#boitegroupe").fadeIn("slow");
      
	
	}}
	});	
	
	
		 $("#diapogeorges").click(function() {
	$("div.bob").fadeOut("fast");
	$("div.team").fadeOut("fast");
	$("#text li").animate({  // on ferme les panneaux déjà ouverts
			width: "1px",
			left: "370px"
		  	}, 500 );
		$("div#loader").show();
		$('.images').removeClass('slideactif');
		//prechargement des 2 premières images
		var aleatoire1 = Math.random()*99999;
		var aleatoire2 = Math.random()*99999;
		$('<img/>')
     	.attr('src', 'images/bg/dentan21.jpg?' + aleatoire1)
   		.load(function () {
		checkFinal(); 
    	 }); 
		$('<img/>')
     	.attr('src', 'images/bg/dentan22.jpg?' + aleatoire2)
   		.load(function () {
		checkFinal(); 
    	 }); 
	 
	 	 var loaded = 0; 
	 	function checkFinal(){ 
	   loaded++; 
	   
	   // lorsque les 2 images sont charg&eacute;es
	   if(loaded == 2){ 
	     $("div#loader").hide();
		  $('.images').addClass('slideactif');
 			$('.images').html('<img src="images/bg/dentan21.jpg?' + aleatoire1 + '"  title="Georges Dentan SA" /><img src="images/bg/dentan22.jpg"  title="Georges Dentan SA" /><img src="images/bg/dentan23.jpg"  title="Georges Dentan SA" /><img src="images/bg/dentan24.jpg"  title="Georges Dentan SA" /><img src="images/bg/dentan26.jpg"  title="Georges Dentan SA" /><img src="images/bg/dentan27.jpg"  title="Georges Dentan SA" />');
	$('.images').galleria();
	
$("#boitegeorges").fadeIn("slow");
	
	}}
	});	
	
	
			 $("#diapogeneve").click(function() {
		$("div.bob").fadeOut("fast");
		$("div.team").fadeOut("fast");
			$("div#loader").show();
			$('.images').removeClass('slideactif');
		//prechargement des 2 premières images
		var aleatoire1 = Math.random()*99999;
		var aleatoire2 = Math.random()*99999;
		
		$('<img/>')
     	.attr('src', 'images/bg/dentan34.jpg?' + aleatoire1)
   		.load(function () {
		checkFinal(); 
    	 }); 
		$('<img/>')
     	.attr('src', 'images/bg/dentan35.jpg?' + aleatoire2)
   		.load(function () {
		checkFinal(); 
    	 }); 
	 
	 	 var loaded = 0; 
	 	function checkFinal(){ 
	   loaded++; 
	   
	   // lorsque les 2 images sont charg&eacute;es
	   if(loaded == 2){ 
	     $("div#loader").hide();
		  $('.images').addClass('slideactif');
 			$('.images').html('<img src="images/bg/dentan34.jpg?' + aleatoire1 + '" title="G. Dentan Gen&egrave;ve SA"   /><img src="images/bg/dentan35.jpg" title="G. Dentan Gen&egrave;ve SA"   /><img src="images/bg/dentan31.jpg" title="G. Dentan Gen&egrave;ve SA"   /><img src="images/bg/dentan32.jpg" title="G. Dentan Gen&egrave;ve SA"   /><img src="images/bg/dentan33.jpg" title="G. Dentan Gen&egrave;ve SA"   />');
	$('.images').galleria();
	
	$("#boitegeneve").fadeIn("slow");
	
	}}
	});	
	
			 $("#diaposiffert").click(function() {
		$("div.bob").fadeOut("fast");
		$("div.team").fadeOut("fast");
			$("div#loader").show();
			$('.images').removeClass('slideactif');
		//prechargement des 2 premières images
		var aleatoire1 = Math.random()*99999;
		var aleatoire2 = Math.random()*99999;
		
		$('<img/>')

     	.attr('src', 'images/bg/dentan46.jpg?' + aleatoire1)
   		.load(function () {
		checkFinal(); 
    	 }); 
		$('<img/>')
     	.attr('src', 'images/bg/dentan47.jpg?' + aleatoire2)
   		.load(function () {
		checkFinal(); 
    	 }); 
	 
	 	 var loaded = 0; 
	 	function checkFinal(){ 
	   loaded++; 
	   
	   // lorsque les 2 images sont charg&eacute;es
	   if(loaded == 2){ 
	     $("div#loader").hide();
		  $('.images').addClass('slideactif');
 			$('.images').html('<img src="images/bg/dentan46.jpg?' + aleatoire1 + '"  title="G. Dentan-Siffert SA"  /><img src="images/bg/dentan47.jpg?' + aleatoire2 + '"  title="G. Dentan-Siffert SA"  /><img src="images/bg/dentan41.jpg"  title="G. Dentan-Siffert SA"  /><img src="images/bg/dentan42.jpg"  title="G. Dentan-Siffert SA"  /><img src="images/bg/dentan43.jpg"  title="G. Dentan-Siffert SA"  /><img src="images/bg/dentan44.jpg"  title="G. Dentan-Siffert SA"  /><img src="images/bg/dentan45.jpg"  title="G. Dentan-Siffert SA"  />');
	$('.images').galleria();
	
$("#boitesiffert").fadeIn("slow");
	
	}}
	});	
	
			 $("#diapodentan").click(function() {
		$("div.bob").fadeOut("fast");
		$("div.team").fadeOut("fast");
			$("div#loader").show();
			$('.images').removeClass('slideactif');
		//prechargement des 2 premières images
		
		var aleatoire1 = Math.random()*99999;
		var aleatoire2 = Math.random()*99999;
		
		$('<img/>')
     	.attr('src', 'images/bg/dentan51.jpg?' + aleatoire1)
   		.load(function () {
		checkFinal(); 
    	 }); 
		$('<img/>')
     	.attr('src', 'images/bg/dentan52.jpg?' + aleatoire2)
   		.load(function () {
		checkFinal(); 
    	 }); 
	 
	 	 var loaded = 0; 
	 	function checkFinal(){ 
	   loaded++; 
	   
	   // lorsque les 2 images sont charg&eacute;es
	   if(loaded == 2){ 
	     $("div#loader").hide();
		  $('.images').addClass('slideactif');
 			$('.images').html('<img src="images/bg/dentan51.jpg?' + aleatoire1 + '"   title="Dentan SA"  /><img src="images/bg/dentan52.jpg?' + aleatoire2 + '"   title="Dentan SA"  /><img src="images/bg/dentan53.jpg"   title="Dentan SA"  /><img src="images/bg/dentan54.jpg"   title="Dentan SA"  /><img src="images/bg/dentan55.jpg"   title="Dentan SA"  /><img src="images/bg/dentan56.jpg"   title="Dentan SA"  />');
	$('.images').galleria();
	
	$("#boitedentan").fadeIn("slow");
	
	}}
	});	


$("#diaposchaub").click(function() {
		$("div.bob").fadeOut("fast");
		$("div.team").fadeOut("fast");
			$("div#loader").show();
			$('.images').removeClass('slideactif');
		//prechargement des 2 premières images
		var aleatoire1 = Math.random()*99999;
		var aleatoire2 = Math.random()*99999;
		
		$('<img/>')
     	.attr('src', 'images/bg/dentan61.jpg?' + aleatoire1)
   		.load(function () {
		checkFinal(); 
    	 }); 
		$('<img/>')
     	.attr('src', 'images/bg/dentan62.jpg?' + aleatoire2)
   		.load(function () {
		checkFinal(); 
    	 }); 
	 
	 	 var loaded = 0; 
	 	function checkFinal(){ 
	   loaded++; 
	   
	   // lorsque les 2 images sont charg&eacute;es
	   if(loaded == 2){ 
	     $("div#loader").hide();
		  $('.images').addClass('slideactif');
 			$('.images').html('<img src="images/bg/dentan61.jpg?' + aleatoire1 + '"   title="Dentan-Schaub SA"  /><img src="images/bg/dentan62.jpg?' + aleatoire2 + '"   title="Dentan-Schaub SA"  /><img src="images/bg/dentan69.jpg"   title="Dentan-Schaub SA"  /><img src="images/bg/dentan67.jpg"   title="Dentan-Schaub SA"  /><img src="images/bg/dentan63.jpg"   title="Dentan-Schaub SA"  /><img src="images/bg/dentan64.jpg"   title="Dentan-Schaub SA"  /><img src="images/bg/dentan65.jpg"   title="Dentan-Schaub SA"  /><img src="images/bg/dentan66.jpg"   title="Dentan-Schaub SA"  />');
	$('.images').galleria();
	
	$("#boiteschaub").fadeIn("slow");
	
	}}
	});	
	
	
	$("#diapoetancheite").click(function() {
		$("div.bob").fadeOut("fast");
		$("div.team").fadeOut("fast");
			$("div#loader").show();
			$('.images').removeClass('slideactif');
		//prechargement des 2 premières images
		var aleatoire1 = Math.random()*99999;
		var aleatoire2 = Math.random()*99999;
		
		$('<img/>')
     	.attr('src', 'images/bg/dentan71.jpg?' + aleatoire1)
   		.load(function () {
		checkFinal(); 
    	 }); 
		$('<img/>')
     	.attr('src', 'images/bg/dentan72.jpg?' + aleatoire2)
   		.load(function () {
		checkFinal(); 
    	 }); 
	 
	 	 var loaded = 0; 
	 	function checkFinal(){ 
	   loaded++; 
	   
	   // lorsque les 2 images sont charg&eacute;es
	   if(loaded == 2){ 
	     $("div#loader").hide();
		  $('.images').addClass('slideactif');
 			$('.images').html('<img src="images/bg/dentan71.jpg?' + aleatoire1 + '" title="&Eacute;tanch&eacute;it&eacute; 2000 SA"   /><img src="images/bg/dentan72.jpg?' + aleatoire2 + '"  title="&Eacute;tanch&eacute;it&eacute; 2000 SA"  /><img src="images/bg/dentan74.jpg"  title="&Eacute;tanch&eacute;it&eacute; 2000 SA"  /><img src="images/bg/dentan75.jpg"  title="&Eacute;tanch&eacute;it&eacute; 2000 SA"  /><img src="images/bg/dentan73.jpg"  title="&Eacute;tanch&eacute;it&eacute; 2000 SA"  />');
	$('.images').galleria();
	
	$("#boiteetancheite").fadeIn("slow");
	
	}}
	});	
	
	
//// debut
			// on cherche a créer tout les fonctions clique pour chaque diaporama dans le xm
	
				$.ajax({
				type: "GET",
				url: "slideshow.xml",
				dataType: "xml",
				success: function(xml) {
					$(xml).find("slideshow").each(function(){
						var id = $(this).attr('id');
						var dossier = $(this).find('dossier').text();
						
						
					// debut de la fonction clique	
						
						
						
		$("#diapo"+ dossier).click(function() {
															
		// on va chercher les infos des images du lien choisi
						
		
						
				
		// on met le loader le temps que les 2 premières images chargemnt	et on enlève la classe actif a tout les slideshows						  
									  
		$("div#loader").show();
		$('.images').removeClass('slideactif');
		
		//prechargement des 2 premières images
		var aleatoire1 = Math.random()*99999;
		var aleatoire2 = Math.random()*99999;
		$('<img/>')
     	.attr('src', 'images/ref/' + dossier + '/img1.jpg?' + aleatoire1)
   		.load(function () {
		
		checkFinal(); 
    	 }); 
		$('<img/>')
     	.attr('src', 'images/ref/' + dossier + '/img1.jpg?' + aleatoire2)
   		.load(function () {
		
		checkFinal(); 
    	 }); 
	 
	 	 var loaded = 0; 
		 
		// fonction qui va voir si les deux premières images sont chargés
		 
	 	function checkFinal(){ 
	   loaded++; 
	   
	   // lorsque les 2 images sont charg&eacute;es
	   if(loaded == 2){ 
	   
	   $.ajax({
				type: "GET",
				url: "slideshow.xml",
				dataType: "xml",
				success: function(xml) {
					$(xml).find("#" + id).each(function(){
						var id = $(this).attr('id');
						var nbr = $(this).find('nbr').text();						
						var dossier = $(this).find('dossier').text();	
						$(this).find('desc').each(function(){
							var nomlien = $(this).find('nomlien').text();
							var title = $(this).find('title').text();
	   // on cache le loader
	   $("div#loader").hide();
	   
	   // on active le slide -> on a cliqué sur un slide permet de retourner au slidshow principal
	   $('.images').addClass('slideactif');
	   
	   // on insere les deux premières images
 			$('.images').html('<img src="images/ref/' + dossier + '/img1.jpg?' + aleatoire1 + '"  title="' + title + '" /><img src="images/ref/' + dossier + '/img2.jpg?' + aleatoire2 + '"  title="' + title + '" />');
	
	//On insére les images suivantes si elles existent
	
	for (i=3; i<=nbr; i++){
  	$('.images').append('<img src="images/ref/' + dossier + '/img' + i + '.jpg"  title="' + title + '" />');
   } 	
	
	// on démarre ls slideshow		
	$('.images').galleria();
	
		// fin de la recherche xml des infos
						});
					});
				}
			});
	
	// fin de la fonction checkfinal
	}}
	

		
	// fin des fonctios clique
			
						});			
					});
				}
			});
	
	
		
		
	
	/////////////////////////////////////////////////
	
	
				 
			 
		





/////fin 	
}); 

