function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('content').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
			}
			else {
				footerElement.style.top = '0px';
			}
		}
	}
}

window.onload = function() {
	setFooter();
}

window.onresize = function() {
	setFooter();
}

function affiche(thediv) {
		var div=document.getElementById(thediv);
			div.style.display='block';
	}
	
var photo_en_cour = 1;

function affiche_divm(thedivprefx,num,total) {
		for(d=1;d<=total;d++)
			{
				var div=document.getElementById(thedivprefx+d);
				if(d==num)
					div.style.display='block';
				else
					div.style.display='none';
			}
	}

function suivante(total) {
		photo_en_cour = (photo_en_cour<total) ? photo_en_cour+1 : 1;
		affiche_divm('photo',photo_en_cour,total)
	}
	
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function actualise_secteurs(dept) {
	if(dept==null)
		dept = document.formu.code_postal.value.substring(0,2);
	nbre_precedent = document.formu.elements['id_secteur[]'].size;
	
	if(secteur[dept])
		{
		document.formu.elements['id_secteur[]'].size=secteur[dept].length-1;
		for (a=1;a<secteur[dept].length;a++)
			{
				nouveau = new Option(secteur[dept][a][1],secteur[dept][a][0],false,false);
				document.formu.elements['id_secteur[]'].options[a-1] = nouveau;
			}
		for (b=secteur[dept].length;b<=nbre_precedent;b++)
				document.formu.elements['id_secteur[]'].options[secteur[dept].length-1] = null;
		}
	else
		{
		document.formu.elements['id_secteur[]'].size=1;
		nouveau = new Option("aucun secteur pour ce departement",'',false,false);
		document.formu.elements['id_secteur[]'].options[0] = nouveau;
		for (b=1;b<=nbre_precedent;b++)
			document.formu.elements['id_secteur[]'].options[1] = null;

		}
	}
	
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function actualise_agences(dept) {

	nbre_precedent = document.formu.elements['id_agence'].length;
	
	if(agences[dept])
		{
		//document.formu.elements['id_agence'].size=agences[dept].length-1;
		for (a=1;a<agences[dept].length;a++)
			{
				nouveau = new Option(agences[dept][a][1],agences[dept][a][0],false,false);
				document.formu.elements['id_agence'].options[a] = nouveau;
			}
		for (b=agences[dept].length;b<=nbre_precedent;b++)
				document.formu.elements['id_agence'].options[agences[dept].length] = null;
		}
	else
		{
		//document.formu.elements['id_agence'].size=1;
		nouveau = new Option("Sélectionnez une agence",'',false,false);
		document.formu.elements['id_agence'].options[0] = nouveau;
		nouveau = new Option("Sélectionnez un département",'',false,false);
		document.formu.elements['id_agence'].options[1] = nouveau;
		for (b=2;b<=nbre_precedent;b++)
			document.formu.elements['id_agence'].options[2] = null;

		}
	}
	
function envoi_courriel(str1,str2,str3)	
	{
	return "mailto:"+str1+"@"+str2+"."+str3;
	}
