<!--//--><![CDATA[//><!
if (document.all) {
	iniWinWidth = getWindowWidth();
	iniWinHeight= getWindowHeight();
}

function submitFormEmail() {
	if (document.layers) {
		var submitmail = document["submitmail"];
		var changecaptcha = document["changecaptcha"];
		var imgcaptcha = document["imgcaptcha"];
	}
	if (document.getElementById) {
		var submitmail = document.getElementById("submitmail");
		var changecaptcha = document.getElementById("changecaptcha");
		var imgcaptcha = document.getElementById("imgcaptcha");
	}
	if (document.all) {
		var submitmail = document.all["submitmail"];
		var changecaptcha = document.all["changecaptcha"];
		var imgcaptcha = document.all["imgcaptcha"];
	}
	if (changecaptcha) {
		changecaptcha.onclick = function(event) {
			var k=0;
			var car="";
			for (k=0 ; k<5 ; k++) {
				if (Math.random()>.5) {car += String.fromCharCode(Math.round(Math.random()*9+48));} else {car += String.fromCharCode(Math.round(Math.random()*25+97));}
			}
			//alert(car);
			if (document.contactmail) {document.contactmail.captchaval.value=car;}
			if (document.addcommentaire) {document.addcommentaire.captchaval.value=car;}
			imgcaptcha.src="captcha.php?captcha="+car;
			return false;
		}
	}
	if (submitmail) {
		submitmail.onclick = function(event) {
			if (document.contactmail.subject.value=="") {alert("Merci de donner un titre à votre message !");document.contactmail.subject.focus();document.contactmail.subject.select();return false;}
			if (document.contactmail.message.value=="") {alert("Merci de saisir le texte de votre message !");document.contactmail.message.focus();document.contactmail.message.select();return false;}
			if (document.contactmail.email.value=="") {alert("Merci de bien vouloir saisir votre email !");document.contactmail.email.focus();document.contactmail.email.select();return false;}
			if (!isValid(document.contactmail.email.value)) {alert("Adresse email invalide !");document.contactmail.email.focus();document.contactmail.email.select();return false;}
			if (document.contactmail.captcha.value=="") {alert("Merci de recopier les caractères de l'image !");document.contactmail.captcha.focus();document.contactmail.captcha.select();return false;}
			if (document.contactmail.captchaval.value!=document.contactmail.captcha.value) {alert("Vous avez fait une erreur en recopiant le code !");document.contactmail.captcha.focus();document.contactmail.captcha.select();return false;}
			document.contactmail.submit() ;
		}
	}
}

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 getWindowWidth() {
	var windowWidth=0;
	if (typeof(window.innerWidth)=='number') {
		windowWidth=window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		} else {
			if (document.body&&document.body.clientWidth) {
				windowWidth=document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}

function rafraichir() {
	// pour résoudre bug IE redimensionnement des div
	if (document.all) {if(iniWinWidth!=getWindowWidth()&&iniWinHeight!=getWindowHeight){history.go(0);}}
}

function showComment(i) {
	if (document.layers) {
		var idComment = document["comment"+i];
		var idImg = document["imgcomment"+i];
	}
	if (document.getElementById) {
		var idComment = document.getElementById("comment"+i);
		var idImg = document.getElementById("imgcomment"+i);
	}
	if (document.all) {
		var idComment = document.all["comment"+i];
		var idImg = document.all["imgcomment"+i];
	}
	if(idComment.style.display=="none") {
		idComment.style.display="block";
		idImg.className="cartoucheh1 imgmoins";
	} else {
		idComment.style.display="none";
		idImg.className="cartoucheh1 imgplus";
	}
}

function showFormComment() {
	if (document.layers) {
		var idFormComment = document["formaddcommentaire"];
	}
	if (document.getElementById) {
		var idFormComment = document.getElementById("formaddcommentaire");
	}
	if (document.all) {
		var idFormComment = document.all["formaddcommentaire"];
	}
	if(idFormComment.style.display=="none") {
		idFormComment.style.display="block";
	} else {
		idFormComment.style.display="none";
	}
}
function submitFormComment() {
	if (document.layers) {
		var submitcomment = document["submitcomment"];
	}
	if (document.getElementById) {
		var submitcomment = document.getElementById("submitcomment");
	}
	if (document.all) {
		var submitcomment = document.all["submitcomment"];
	}
	if (submitcomment) {
		submitcomment.onclick = function(event) {
			// controle des valeurs utilisateurs
			if (document.addcommentaire.titre.value=="") {
				alert("Merci de donner un titre à votre commentaire !");
				document.addcommentaire.titre.focus();
				document.addcommentaire.titre.select();
				return false;
			} else {
			}
			if (document.addcommentaire.commentaire.value=="") {
				alert("Merci de saisir le texte de votre commentaire !");
				document.addcommentaire.commentaire.focus();
				document.addcommentaire.commentaire.select();
				return false;
			}

			if (document.addcommentaire.captcha.value=="") {
				alert("Merci de recopier les caractères de l'image !");
				document.addcommentaire.captcha.focus();
				document.addcommentaire.captcha.select();
				return false;
			}
			if (document.addcommentaire.captchaval.value!=document.addcommentaire.captcha.value) {
				alert("Vous avez fait une erreur en recopiant le code !");
				document.addcommentaire.captcha.focus();
				document.addcommentaire.captcha.select();
				return false;
			}
			// construction chaine de parametres
			var params = "";
			params += "no_personne=" + encodeURI(document.addcommentaire.no_personne.value);
			params += "&no_table=" + encodeURI(document.addcommentaire.no_table.value);
			params += "&no_tableliee=" + encodeURI(document.addcommentaire.no_tableliee.value);
			params += "&titre=" + encodeURI(document.addcommentaire.titre.value);
			params += "&commentaire=" + encodeURI(document.addcommentaire.commentaire.value);
			params += "&nom=" + encodeURI(document.addcommentaire.nom.value);
			params += "&email=" + encodeURI(document.addcommentaire.email.value);
			params += "&niveau=" + encodeURI(document.addcommentaire.niveau.value);
			params += "&ordre=" + encodeURI(document.addcommentaire.ordre.value);
			params += "&captcha=" + encodeURI(document.addcommentaire.captcha.value);
			params += "&captchaval=" + encodeURI(document.addcommentaire.captchaval.value);
			document.addcommentaire.innerHTML=file("commentRecord.php?"+params);
		}
	}
}

addLoadListener(submitFormComment);
addLoadListener(submitFormEmail);

function addLoadListener(func) {
   if (window.addEventListener) {
      window.addEventListener("load", func, false);
   } else if (document.addEventListener) {
      document.addEventListener("load", func, false);
   } else if (window.attachEvent) {
      window.attachEvent("onload", func);
   }
}
function isValid(email) { // vérif validité email par REGEXP
   var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
   return (reg.exec(email)!=null)
}
function file(fichier) {
	// fonction ajax pour envoi données get
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else 	if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
		else return(false);
}

//window.onresize=rafraichir;
//window.onload=Init0;
//--><!]]>
