var interval = null
var margin = 0
var margintop = 120
var margintopoffre = -120
var encoursslide = 0
var pas = 50
var pas_margin = 10
var click_slide =0
var last_slide = null

function slide_block(id){
//alert(	document.getElementById('offre_thematique_' + id).style.display)
		if(last_slide!=id && last_slide!= null){
			document.getElementById('block_thematique_' + last_slide).style.marginTop = '0px';
			document.getElementById('offre_thematique_' + last_slide).style.display = 'none'
		}
		
		if (document.getElementById('offre_thematique_' + id).style.display == 'block'){
			document.getElementById('block_thematique_' + id).style.marginTop = '0px';
			document.getElementById('offre_thematique_' + id).style.display = 'none'
		}
		else{
			document.getElementById('offre_thematique_' + id).style.display = 'block'
			document.getElementById('block_thematique_' + id).style.marginTop = '-120px';	
		}
		last_slide = id
		majOffres()
}

/*
function slide_block(id) {
		if (document.getElementById('offre_thematique_' + id).style.display == 'block') {
			if(encoursslide==0){masque_slide(id)}
		} else {
			if(encoursslide==0){affiche_slide(id)}
		}
		
	}
*/

function affiche_slide(id) {

   show = document.getElementById('offre_thematique_' +id);
   document.getElementById('offre_thematique_' + id).style.display='block';
   size = margintop;
   timer = setInterval("slide("+id+",'affiche')", 50);
   time = new Date().getTime();

}

function masque_slide(id) {

   show = document.getElementById('offre_thematique_' +id);
   size = margintop;
   timer = setInterval("slide("+id+",'masque')", 50);
   time = new Date().getTime();

}

function slide(id,sens) {

   var slide = (new Date().getTime() - time) * 3/5;
 	encoursslide = 1
 	if(sens=="affiche"){
		if (slide <= size) {
      		slide = size;
      		clearInterval(timer)
	  		margin = 0;
			margintopoffre = -120;
			encoursslide=0
   		}
		
		margin = margin + slide;
		document.getElementById('block_thematique_' + id).style.marginTop = '-' + margin +'px';
	}
	if(sens=="masque") {
		if (slide <= size) {
      		slide = size;
      		clearInterval(timer)
	  		margin = 0;
			margintopoffre = -120;
			encoursslide = 0
			document.getElementById('offre_thematique_' + id).style.display = 'none'
			
			
   		}
		margintopoffre = margintopoffre + slide;
		document.getElementById('block_thematique_' + id).style.marginTop = margintopoffre +'px';
	}
 }



/*
/// retaille de la carte
function retailleDIV(element,LargFinale,HautFinale,Interval,Vitesse){
	
	parseInt(LargFinale)
	parseInt(HautFinale)
	parseInt(Vitesse)
	reductionHeight = null
	reductionWidth = null
	
	if(parseInt(document.getElementById(element).style.height)!=HautFinale){
	var boucleHeight = setInterval(function(){
								heightElement = parseInt(document.getElementById(element).style.height);
								if(heightElement==HautFinale)clearInterval(boucleHeight)
								if((heightElement < HautFinale) && reductionHeight==null){
									heightTemp = (heightElement + Vitesse)
								}
								else{
									heightTemp = (heightElement - Vitesse)
									reductionHeight = 1
								}
								document.getElementById(element).style.height=heightTemp+'px'
							 }
							,Interval)
	}
	else {
		clearInterval(boucleHeight);
	}
	
	if(parseInt(document.getElementById(element).style.width)!=LargFinale){
	var boucleWidth = setInterval(function(){
								WidthElement = parseInt(document.getElementById(element).style.width);
								if(WidthElement==LargFinale)clearInterval(boucleWidth)
								if((WidthElement < LargFinale) && reductionWidth==null){
									WidthTemp = (WidthElement + Vitesse)
								}
								else{
									WidthTemp = (WidthElement - Vitesse)
									reductionWidth = 1
								}
								document.getElementById(element).style.width=WidthTemp+'px'
							 }
							,Interval)
	}
	else {
		clearInterval(boucleWidth);
	}
	
}
*/
