// attribue une fonction anonyme a onresize
//window.onresize = function(){ surveille(); }
//alert('11');

function surveille() {
	
	//alert('on rentre dans la fonction surveille...');
	
	// hauteur de contenu mini
	var htzoneInt = js_htDiv('zoneInt');
	if (document.getElementById('zoneContenuInt')) {
		var htzoneContenuInt = js_htDiv('zoneContenuInt');
		var zoneInt = (document.getElementById ? document.getElementById('zoneInt') : document.all['zoneInt']);
		//alert('hauteur de zoneInt AVANT : ' + zoneInt.style.height);
		zoneInt.style.height = '300px';
		if (parseInt(htzoneContenuInt) > 300) {
			var zoneContenuInt = (document.getElementById ? document.getElementById('zoneContenuInt') : document.all['zoneContenuInt']);
			zoneInt.style.height = zoneContenuInt.style.height;
		}
	}

	var largeur = getTotalWidth(); // largeur de la fenetre
	var htDivContenu = js_htDiv('contenu');
	
	var fondsite = (document.getElementById ? document.getElementById('fondsite') : document.all['fondsite']);
	fondsite.style.height = parseInt(htDivContenu)+'px';
	fondsite.style.width = parseInt(largeur)+'px';
	fondsite.style.left = '0px';
	fondsite.style.top = '0px';
	
	placeLogoDklik();
}

function placeLogoDklik() {
	
	var htDivContenu = js_htDiv('contenu');

	// Pour placer le logo DKLIK
	var dklik = (document.getElementById ? document.getElementById('dklik') : document.all['dklik']);
	dklik.style.top = parseInt(htDivContenu-114)+'px';
	
  dklik.style.display = 'block';
}

function ajusteIntranet() {
	var htDivContenu = js_htDiv('contenu');
	var zoneInt = (document.getElementById ? document.getElementById('zoneInt') : document.all['zoneInt']);
	zoneInt.style.height = parseInt(htDivContenu-450)+'px';
}
function ajusteIntranet2(divStats, sens) {
	var htDivContenu = js_htDiv('contenu');
	var htDivStat = js_htDiv(divStats);
	var zoneInt = (document.getElementById ? document.getElementById('zoneInt') : document.all['zoneInt']);
	if (sens == 'plus') {
		zoneInt.style.height = parseInt(htDivContenu-450+parseInt(htDivStat))+'px';
	}else{
		zoneInt.style.height = parseInt(htDivContenu-450-parseInt(htDivStat))+'px';
	}
	surveille();
}

function js_htDiv(nomDiv) {
	// Pour placer le logo DKLIK
	var doc = (document.getElementById ? document.getElementById(nomDiv) : document.all[nomDiv]);
  // on retrouve la hauteur du calque contenu, ok I.E sinon firefox.0.9.2 , pas mozilla.1.0 ni netscape.7.02
  // on recupere un truc du style '328px' sous firefox et 328 sous IE.... alors on enleve le 'px' SOUS Firefox
  var newHt = (document.all ? doc.offsetHeight : document.defaultView.getComputedStyle(doc, null).height);
  if (!document.all) newHt = newHt.substr(0,newHt.length-2);
  return newHt;
}
function getTotalHeight() {

  // firefox is ok
  var height = document.documentElement.scrollHeight;

  // now IE 7 + Opera with "min window"
  if(document.documentElement.clientHeight > height ) {
    height  = document.documentElement.clientHeight;
  }
  // last for safari
  if(document.body.scrollHeight > height) {
    height = document.body.scrollHeight;
  }
  
  return height;
}
function getTotalWidth() {

  // firefox is ok
  var largeur = document.documentElement.scrollWidth;

  // now IE 7 + Opera with "min window"
  if(document.documentElement.clientWidth > largeur ) {
    largeur  = document.documentElement.clientWidth;
  }
  // last for safari
  if(document.body.scrollWidth > largeur) {
    largeur = document.body.scrollWidth;
  }
  
  return largeur;
}


//js_positionnement();
// on relance automatiquement le script au bout de 2sec (pour les vieux navigateurs)
//setTimeout("js_positionnement()", 2000);

