// PARAMETRAGE DU SCRIPT : modifié par V. Duffaut le 27 mai 2002 : ajout paramètres toujours en haut et à droite
var tjs_delai=10; // Délai dans le mouvement de déplacement
var tjs_max=10; // 2è paramètre du délai
var tjs_mode=1; // 0 - calque toujours en haut de page / 1 - calque en bas
var tjs_gauche=0; // 0 - calque toujours à gauche de la page / 1 - calque à droite

// LE RESTE NE CHANGE PAS
var tjs_hauteur=0;
function PrintCalque(left,top,width,height,contenu) {
	
	tjs_hauteur=height;
	if (tjs_gauche==1) {// toujours à gauche
		if (document.getElementById) {					 //IE5 
			left=document.body.clientWidth-width;
		}
		if ((document.getElementById)&&(!document.all)) { //NS6
			var availLargeur=window.clientWidht;
		}
		if ((document.all)&&(!document.getElementById)) { //IE4 seul
			var availLargeur=document.body.clientWidht;
		}
		if (document.layers) {							 //NS4.X seul
			var availLargeur=window.clientWidht;
		}
	}
	if ((document.all)||(document.getElementById)) {
		var Z="<DIV id='tomber' style='position:absolute;left:"+left+";top:"+top+";width:"+width+";height:"+height+"'>"+contenu+"</DIV>";
	} else {
		var Z="<LAYER name='tomber' left="+left+" top="+top+" width="+width+" height="+height+">"+contenu+"</LAYER>";
	}
	document.write(Z);
	setTimeout("Start()",tjs_delai);
}
function Start() {
	MoveLayer("tomber",GetTop("tomber"));
	setTimeout("Start()",tjs_delai);
}
function Debug() {
	var obj=document.body
	var Z="";
	for (var i in obj) {
		Z+=i+"="+obj[i]+"\n";
	}
	alert(Z);
}
function MoveLayer(nom,top) {
	if (document.getElementById) { //IE5 et NS6
		document.getElementById(nom).style.top=top;
	}
	if ((document.all)&&(!document.getElementById)) { //IE4 seul
		document.all[nom].style.top=top;
	}
	if (document.layers) { //NS4.X seul
		document.layers[nom].top=top;
	}
}
function GetTop(nom) {
	// Partie 1 : Récupération de la position du calque et de la page
	if (document.getElementById) { //IE5 
		var pos=parseInt(document.getElementById(nom).style.top);
		var wintop=parseInt(document.body.scrollTop);
		var avail=document.body.clientHeight;
	}
	if ((document.getElementById)&&(!document.all)) { //NS6
		var pos=parseInt(document.getElementById(nom).style.top);
		var wintop=parseInt(window.pageYOffset);
		var avail=window.innerHeight;
	}
	if ((document.all)&&(!document.getElementById)) { //IE4 seul
		var pos=parseInt(document.all[nom].style.top);
		var wintop=parseInt(document.body.scrollTop);
		var avail=document.body.clientHeight;
	}
	if (document.layers) { //NS4.X seul
		var pos=parseInt(document.layers[nom].top);
		var wintop=parseInt(window.pageYOffset);
		var avail=window.innerHeight;
	}

	// Partie 2 : Traitement de la position
	if (tjs_mode==0) { // toujours en haut
		var delta=Math.ceil((pos-wintop)/3);
		if (delta>tjs_max) {delta=tjs_max;}
		if (delta<-1*tjs_max) {delta=-1*tjs_max;}
		var top=pos-delta;
	}
	if (tjs_mode==1) {// toujours en bas
		var delta=Math.ceil((pos-(wintop+avail-tjs_hauteur)));
		if (delta>tjs_max) {delta=tjs_max;}
		if (delta<-1*tjs_max) {delta=-1*tjs_max;}
		var top=pos-delta;
	}
	return top;
}




function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("E-mail Invalide");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		  alert("E-mail Invalide");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("E-mail Invalide");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("E-mail Invalide");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("E-mail Invalide");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("E-mail Invalide");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("E-mail Invalide");
		    return false;
		 }

 		 return true	;				
	}

function validateForm(mail){
	var emailID=document.getElementById(mail);
	var nom=document.getElementById("nom");
	var prenom=document.getElementById("prenom");
	var commentaires=document.getElementById("commentaires");
	if (name.indexOf(" ")!=-1){
		   alert("E-mail Invalide");
		    return false;
		 }
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Merci de renseigner votre E-mail");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus();
		return false;
	}
	return true
 }

function sendAction (){
	if(validateForm('mail')){
		alert("Merci de votre temoignage le livre d'or sera mis a jour tres prochainement");
		document.getElementById('formulaireMail').submit();
	}
}