function trimAll(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function ValideRech() {
    window.document.formcrit.vin.value = trimAll(window.document.formcrit.vin.value);
   	window.document.formcrit.plat.value = trimAll(window.document.formcrit.plat.value);

    if (window.document.formcrit.vin.value == "" && window.document.formcrit.plat.value == "") {
        alert("Veuillez saisir un nom de vin ou de plat.");
        return false;
    }
    if (window.document.formcrit.vin.value != "" && window.document.formcrit.plat.value != "") {
        alert("ATTENTION, vous avez saisi un nom de vin ET de plat.\nPar défaut la recherche s'effectuera sur le nom du vin saisi.");
        window.document.formcrit.plat.value = "";
    }
    if (window.document.formcrit.vin.value != "" && window.document.formcrit.vin.value.length <= 3) {
		alert("Pour une recherche plus pertinente, veuillez saisir un nom de vin d'au minimum 4 caractères.");
        return false;
    }
    if (window.document.formcrit.vin.value != "" && window.document.formcrit.vin.value.length > 3) return true;
    if (window.document.formcrit.plat.value != "" && window.document.formcrit.plat.value.length <= 2) {
		alert("Pour une recherche plus pertinente, veuillez saisir un nom de plat d'au minimum 3 caractères.\nActuce : mettez le nom du plat au pluriel pour gagner une lettre !");
        return false;
    }
    return true;
}

function popupnotemillesime(page) {
	window.open(page,'','resizable=yes, location=yes, width=800, height=600, menubar=yes, status=no, scrollbars=yes');
}

function GetId(id) {
	return window.document.getElementById(id);
}
var i=false; // La variable i nous dit si la bulle est visible ou non

function move(e) {
	if(i) {  // Si la bulle est visible, on calcul en temps reel sa position ideale
		if (navigator.appName!="Microsoft Internet Explorer") { // Si on est pas sous IE
			GetId("curseur").style.left=e.pageX - 80+"px";
			GetId("curseur").style.top=e.pageY + 10+"px";
		}
		else { // Modif proposé par TeDeum, merci à lui
			if(window.document.documentElement.clientWidth>0) {
				GetId("curseur").style.left=-80+event.x;//+window.document.documentElement.scrollLeft+"px";
				GetId("curseur").style.top=10+event.y;//+window.document.documentElement.scrollTop+"px";
			}
			else {
				GetId("curseur").style.left=-80+event.x;//+window.document.body.scrollLeft+"px";
				GetId("curseur").style.top=10+event.y;//+window.document.body.scrollTop+"px";
			}
		}
	}
}

function montre(text) {
	if(i==false) {
		GetId("curseur").style.visibility="visible"; // Si il est cacher (la verif n'est qu'une securité) on le rend visible.
		GetId("curseur").innerHTML = text; // Cette fonction est a améliorer, il parait qu'elle n'est pas valide (mais elle marche)
		i=true;
	}
}

function cache() {
	if(i==true) {
		GetId("curseur").style.visibility="hidden"; // Si la bulle etais visible on la cache
		i=false;
	}
}

window.document.onmousemove=move; // des que la souris bouge, on appelle la fonction move pour mettre a jour la position de la bulle.