// Calcul de la taille de la fenetre du navigateur
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;
}

// Placement du footer et de l'image du background
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('container').offsetHeight;
			var headerHeight = document.getElementById('header_site').offsetHeight;
			var footerElement = document.getElementById('footer_site');
			var decoElement = document.getElementById('deco_centrale');
			var footerHeight  = footerElement.offsetHeight;
			var decoHeight = decoElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.position = 'absolute';
				footerElement.style.top = (windowHeight - footerHeight) + 'px';
				decoElement.style.height = (windowHeight - footerHeight - headerHeight) + 'px';
				decoElement.style.bottom = 0 + 'px';
			}
			else {
				footerElement.style.position = 'static';
				decoElement.style.top = headerHeight + 'px';
				decoElement.style.height = 355 + 'px';
			}
		}
	}
}

// Soumission du formulaire de recherche
function validForm(){
	if(document.formRecherche.pattern.value != "") {
		return true;
	}
	else {
		document.getElementById("erreurForm").style.display="";
		return false;
	}
}

//Affichage des messages d'erreur dans le formulaire de recherche
function oteErreur(){
	if(document.formRecherche.pattern.value != "") {
		document.getElementById("erreurForm").style.display="none";
	}
	else {
		document.getElementById("erreurForm").style.display="";
	}
}

// Recherche rapide dans le header du site
function validQuickSearch() {
	pattern = document.getElementById("quicksearch").value;
	window.location.replace("/webstats/resultRechercher.php?pattern="+pattern);
}

// Soumission du formulaire de notation
function validFormNote(){
	if(document.formNotation.site.value != "") {
		return true;
	}
	else {
		document.getElementById("erreurForm").style.display="";
		document.getElementById("erreurSite").style.display="none";
		return false;
	}
}
