// JavaScript Document
/*Change les coordonnées de la ville au survol*/
function changeVille(id)
{
	/*Recuperation du nombre de département*/
	var nbDepart = window.document.getElementById('nbDepartement').value;
	
	for(var i=0; i<nbDepart; i++){
		if(i==id){
		  window.document.getElementById('dep_'+i).className="departement-on";
		  window.document.getElementById('ctel').innerHTML=window.document.getElementById('tel'+i).value;
		  window.document.getElementById('cfax').innerHTML=window.document.getElementById('fax'+i).value;
		  window.document.getElementById('cad').innerHTML=window.document.getElementById('adresse'+i).value;
		}else{
			window.document.getElementById('dep_'+i).className="departement-off";
			}
	}
	
}


function setHeightContent()
{
  var hgd=window.document.getElementById('gauchedynam').offsetHeight;
  hgd=hgd-36;
  window.document.getElementById('contdynam').style.height=hgd+'px';
}

function selectMenu(id)
{
	window.document.getElementById('menu_'+id).className="visible";
}

// Défilement automatique des annonces
var decalage = 1;
var pause = false;

function stoppe()
{
	
	 pause = true;
	 //alert("pause");
}

function reprend()
{
	 pause = false;	
	 //alert("reprend");
}

function scrollAuto()
{
	if(pause==false)
	{
		//alert( document.getElementById("annonces").scrollTop);
		var position = document.getElementById("annonces").scrollTop;
		var hauteur = document.getElementById("annonces").scrollHeight;
		var hauteurDiv = document.getElementById("annonces").offsetHeight;
		
		//Decalage
		document.getElementById("annonces").scrollTop = position + decalage;
	
		var totalHauteur = position + hauteurDiv;
		
		//Si arrivé à la fin de la div
		if(totalHauteur==document.getElementById("annonces").scrollHeight)
		{
			//Remise en haut du scrollTop
			document.getElementById("annonces").scrollTop = 0;
		}
	}
}

setInterval(scrollAuto,50);
