/*
*
* Fonctions de gestion des éléments de la page
*
*/
		
if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, actuatorId, typepage) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

    //if (window.opera) return; // I'm too tired

    actuator.onmouseover = function() {
        this.showMenu();
    }
	
    actuator.onmouseout = function() {
		menu.style.height = 59 + "px";
        currentMenu = null;
    }

    actuator.showMenu = function() {
		menu.style.height = "auto";
        currentMenu = menu;
    }
}

function P7_swapClass(){ //v1.4 by PVII
 var i,x,tB,j=0,tA=new Array(),arg=P7_swapClass.arguments;
 if(document.getElementsByTagName){for(i=4;i<arg.length;i++){tB=document.getElementsByTagName(arg[i]);
  for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
  if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
  }else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
  }else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}

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('contenu').offsetHeight;
			var content2Height = document.getElementById('header').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			
			if (windowHeight - (contentHeight + content2Height + footerHeight) >= 0) {
				document.getElementById('conteneur').style.height = '100%';
				document.getElementById('ombre').style.height = '100%';
				footerElement.style.position = 'absolute';
				footerElement.style.top = (windowHeight - footerHeight) + 'px';
			}
			else {
				footerElement.style.position = 'static';
			}
		}
	}
}

function searchText(thisfocus) {
	var rechercheInput = document.getElementById('rechercheInput');
	if(thisfocus) {
		if (rechercheInput.value == 'Rechercher') { rechercheInput.value = ''; }
	} else {
		if (rechercheInput.value == '') { rechercheInput.value = 'Rechercher'; }
	}
}

onload = setFooter;
onresize = setFooter;
