 




var diapo;


 

//SETTING UP OUR POPUP  
    //0 means disabled; 1 means enabled;  
      

    //loading popup with jQuery magic!  
    function loadPopup(PushedButton){
 
    //loads popup only if it is disabled  
     
 $("#backgroundPopup").css({  
 "opacity": "0.7",
"z-index":"49"
 });
 
 $("#backgroundPopup").fadeIn("fast");


  $(PushedButton).next().show("slow");
/*
   
   $(PushedButton).next().animate({
    
    //left : windowWidth/2-popupWidth/2-300
"width" : 700
  }, 10000)
  */
   

    
   }  
    

 
   function disablePopup(PushedButton_close){
   
   /*
   $(PushedButton_close).prev().animate({
    
    //left : windowWidth/2-popupWidth/2-300
"width" : 5
  }, 1000)
  */
    $(PushedButton_close).hide("fast");



 $(PushedButton_close).prev().fadeOut("fast");
$(PushedButton_close).prev().hide("fast");




$("#backgroundPopup").hide("fast");


}
//centering popup  
   function centerPopup(PushedButton){

   
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;

    var popupHeight = $(PushedButton).next().height();

   var popupWidth =$(PushedButton).next().width();

  
  
$(PushedButton).next().next().css({

 "display": "block",
 "position": "fixed",
   "top": windowHeight/2-popupHeight/2  ,
   "left": windowWidth/2-popupWidth/2 +725
 });
   //centering  
var scrollTop = $(window).scrollTop();


   
$(PushedButton).next().css({
  "position": "fixed",
   "top": windowHeight/2-popupHeight/2  ,
   "left": windowWidth/2-popupWidth/2 
   });  
   //only need force for IE6
   
   

    height_back = $(".background_milieu").height();
  
  $("#backgroundPopup").css({

 "height": height_back +280
 });  
/*
    $("#fermer_photo").css({
        "top": windowHeight/2-popupHeight/2 -260,
        "left": windowWidth/2-popupWidth/2
    });
    */
  }  




function load_anim_photo(conteneur,photo,texte,path,pics)

{
scroll(0,0);
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;

conteneur.show();

/////////////background///////////////////

height_back = $(".background_milieu").height();
  
$("#backgroundPopup").css({
 "opacity": "1",
"z-index":"39",
 "height": height_back +280
});  
/*
popupHeight = 500;
popupWidth = 600;
*/
$("#backgroundPopup").fadeIn();    
////////////////////////////////

//première photo :
photo_1 = photo;

texte_ = texte;
path_ = path;
pics_ = pics;

anim_gauche(photo_1,texte_,path_,pics_);
 
//photo_2 = photo_1.next();

diapo = new Chang_photo(pics_,path_,photo_1);   

//window.setTimeout("Chang_photo(photo_1)",11000);

}

function Chang_photo(tab,path,photoDiv)
{

_self = this;

this.PhotoDiv_ = photoDiv;
this.tableau_photo = tab;
this.timer_change;
this.waitfadeOutEnd;
this.count_photo = 2;

this.photo_courante;

this.start = function()
{
_self.configure();

}

this.configure = function(){
/*
 $("#ferme_diapo").css({
 "opacity": "1",
"z-index":41,
 

 });  
*/

$(".ferme_diapo").fadeIn();


var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
//popupHeight = 500;
//popupWidth = 600;

//popupWidth_string = photo.width();
//popupWidth = parseInt(popupWidth_string);
image = '<img src="'+path+_self.tableau_photo[_self.count_photo]+'"  height='+windowHeight+'>';

_self.PhotoDiv_.html(image);

//$("#photo_pop2").html(image);
_self.count_photo = _self.count_photo +1;


popupWidth = photo_width;

/*
$("#photo_pop2").css({  
   "position": "absolute",  
	
   "top": 0 ,  
   "left" : windowWidth/2-popupWidth/2,
	"z-index" : 40,

   });
*/
   
   _self.PhotoDiv_.css({  
   "position": "absolute",  
	
   "top": 0 ,  
   "left" : windowWidth/2-popupWidth/2,
	"z-index" : 40,

   });

  





_self.affich_photo();


}

this.affich_photo = function(){

_self.PhotoDiv_.fadeIn();
	
//$("#photo_pop2").fadeIn();

_self.temp_affich_photo();


}


this.temp_affich_photo = function()
{


_self.timer_change = window.setTimeout("_self.hidephoto()", 5000);

}

this.hidephoto = function()

{

	_self.PhotoDiv_.fadeOut();
	
//$("#photo_pop2").fadeOut();

_self.waitfadeOutEnd = window.setTimeout("_self.select_next_photo()",500);

}


this.select_next_photo = function(){



if(_self.count_photo == _self.tableau_photo.length)
{
_self.end();
}
else
{ 
_self.configure();
}

}


this.end = function(){

	
	
	_self.PhotoDiv_.fadeOut();
//$("#photo_pop2").fadeOut();
$("#diapo_pointe_a_pitre_conteneur").hide();
clearTimeout(_self.timer_change);  
clearTimeout(_self.waitfadeOutEnd);
$("#backgroundPopup").fadeOut();
$(".ferme_diapo").fadeOut();
  _self.count_photo = 2;  


}



}










function suppr_debut_sans_diapo(pop)

{
_pop = pop;

_pop.fadeOut();
_pop.next().fadeOut();
$("#diapo_pointe_a_pitre_conteneur").hide();
$("#diapo_velo_conteneur").hide();
$("#diapo_pointe_a_pitrePort_conteneur").hide();
$("#diapo_lycee_conteneur").hide();
$("#diapo_epaves_conteneur").hide();

$("#diapo_boeuf_conteneur").hide();
$("#backgroundPopup").fadeOut();

}







function suppr_debut(pop)
{
_pop = pop;

_pop.fadeOut();
	
_pop.next().fadeOut();

//diapo.start(pics);
diapo.start();

}


function anim_gauche(photo,texte,path,pics)
{
photo_ = photo;
path_=path;
pics_=pics;



var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;

photo_.css({  
   "position": "absolute",  
   "top": 5 ,  
   "left": windowWidth/2, 
"z-index" : 88,

   });  

photo_width = windowWidth/2-50;
photo_height = windowHeight/2+200;

image = '<img src="'+path+pics[0]+'" width='+photo_width+' height='+photo_height+'>';

photo_.html(image);

//photo.show();

photo_.fadeIn();
photo_.animate({
    
    left : 50
  }, 1000)


texte_=texte;
window.setTimeout("anim_haut(photo_,texte_,path_,pics_)",2000);

}


function anim_haut(photo,texte,path,pics)
{
texte_ = texte;

path_ = path;
pics_=pics;
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
photo_left = windowWidth/2+20;
photo.next().css({  
   "position": "absolute",  
   "top": windowHeight/2 -200 ,  
   "left": photo_left, 
	"z-index" : 88,

   });  

photo_width = windowWidth/2-50;
photo_height = windowHeight/2+200;
image = '<img src="'+path+pics[1]+'"   width='+photo_width+'  height='+photo_height+'>';

photo.next().html(image);
 


photo.next().fadeIn();
photo.next().animate({
    
    //left : windowWidth/2-popupWidth/2-300
"top" : 7
  }, 1000)

texte.css({  
"left" : 50,
   "position": "absolute",  
   "top": photo_height+15 ,  
	"width" : "90%",
  "z-index" : 88,
"color" : "white",
   });  



//photo_suppr = photo;
window.setTimeout("texte_.fadeIn()",2000);


}



function close_diapo()
{

diapo.end();
}


