function right(str, n)
   {
    	if (n <= 0)
       		return "";
    	else if (n > String(str).length)
       		return str;
    	else {
       		var iLen = String(str).length;
       		return String(str).substring(iLen, iLen - n);
    }
   }

function getRandomNum(lbound, ubound)
   {
	return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
   }


function changeBanner()
   {
	var random=getRandomNum(1,10);
	if (random >= 10) random=9;
	parent.frames["banner"].window.document.getElementById("bannerX").src = '../../banners/banner'+random.toString()+'.jpg';
   }


function changeIframe()
   {
	var IFrameObj
	IFrameObj = parent.frames["menu"].window.document.getElementById('horaire');
	// IFrameObj.src='/scripts/foxisapi.dll/pescheIsapi.vcx.showPage?page=horaire&nihil='+getRandomNum(1,9999999999).toString();
   }


function updateWindow()
   {
	if (self.name=='menu') {
		var tabobj2=parent.frames["banner"].window.document.getElementById("ddimagetabs086")
		tabobjlinks2=tabobj2.getElementsByTagName("A");
		for (i=0; i<tabobjlinks2.length; i++)
			tabobjlinks2[i].id='ddimagetabs'+right(tabobjlinks2[i].id,3);
	}
	changeBanner();
	changeIframe();
   }

function validate_infoform() 
   {
	var s = document.infoform.email.value.toString();
	var l = s.length;
	if (l == 0) {
		alert("Le courriel ne peut être vide !");
		return(false);
	}
	if (l < 6) {
		alert("Le courriel est une chaîne de caractères trop courte !");
		return(false);
	}
	if (s.indexOf("@") == -1) {
		alert("Le courriel n'est pas valide !");
		return(false);
	}
 	if (!((s.charAt(l-3) == ".")||(s.charAt(l-4) == "."))) {
		alert("Le courriel ne contient pas un nom de domaine correct !");
		return(false);
	}

	var error_string = "Les champs suivants doivent être remplis :\n";
	var error_flag = false;
	var f = document.infoform;
	if(f.nom.value.toString().length == 0) {
		error_flag = true;
		error_string += "     Nom\n";
	}
	if(f.tel.value.toString().length == 0) {
		error_flag = true;
		error_string += "     Téléphone\n";
	}
	if(f.note.value.toString().length == 0) {
		error_flag = true;
		error_string += "     Note\n";
	}

	if(error_flag) {
		alert(error_string);
		return(false);
	} else 
            {return(true);
	}
   }

function validate_diffusionform() 
   {
	var s = document.diffusionform.email.value.toString();
	var l = s.length;
	if (l == 0) {
		alert("Le courriel ne peut être vide !");
		return(false);
	}
	if (l < 6) {
		alert("Le courriel est une chaîne de caractères trop courte !");
		return(false);
	}
	if (s.indexOf("@") == -1) {
		alert("Le courriel n'est pas valide !");
		return(false);
	}
 	if (!((s.charAt(l-3) == ".")||(s.charAt(l-4) == "."))) {
		alert("Le courriel ne contient pas un nom de domaine correct !");
		return(false);
	}
       return(true);
	
   }

function refuser(sText,ValidChars2)
{   
   var ValidChars = "0123456789abcdefghijklmnopqrstuvwxyz"+ValidChars2;
   var refuser = false;
   var Char;
   for (i = 0; i < sText.length && refuser == false; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         refuser = true;
         }
      }
   return refuser;
   }

function validate_demande_mail() 
   {
	var f=document.demande_mail;	
	if (f.prenom.value.toString().length == 0) {
		alert("Le prénom ne peut être vide !");
		return(false);
	}
	if (f.nom.value.toString().length == 0) {
		alert("Le nom ne peut être vide !");
		return(false);
	}
	if (f.password.value.toString().length == 0) {
		alert("Le mot ne peut être vide !");
		return(false);
	}
	if (f.password.value.toString().length < 6) {
		alert("Le mot de passe doit compter au moins 6 caractères !");
		return(false);
	}
	if (refuser(f.prenom.value.toString(),"")) {
		alert("Le prénom contient des caractères non valides !");
		return(false);
	}
	if (refuser(f.nom.value.toString(),"")) {
		alert("Le nom contient des caractères non valides !");
		return(false);
	}
	if (refuser(f.password.value.toString(),"")) {
		alert("Le mot de passe contient des caractères non valides !");
		return(false);
	}
	if (f.alias1.value.toString().length > 0) {
		if (refuser(f.alias1.value.toString(),".")) {
			alert("L'alias 1 contient des caractères non valides !");
			return(false);
		}
	}
	if (f.alias2.value.toString().length > 0) {
		if (refuser(f.alias2.value.toString(),".")) {
			alert("L'alias 2 contient des caractères non valides !");
			return(false);
		}
	}
	if (f.alias3.value.toString().length > 0) {
		if (refuser(f.alias3.value.toString(),".")) {
			alert("L'alias 3 contient des caractères non valides !");
			return(false);
		}
	}
	if (f.previous_host.value.toString().length > 0) {
		if (f.previous_host.value.toString().indexOf(".") == -1) {
			alert("Le serveur de la précédente boîte n'est pas valide !");
			return(false);
		}
		if (f.previous_login.value.toString().length == 0) {
			alert("Si le serveur de la précédente boîte est non vide, alors le nom de boîte doit aussi être complété !");
			return(false);
		}
		if (f.previous_password.value.toString().length == 0) {
			alert("Si le serveur de la précédente boîte est non vide, alors le mot de passe doit aussi être complété !");
			return(false);
		}
	}
	if (f.previous_login.value.toString().length > 0) {
		if (f.previous_host.value.toString().length == 0) {
			alert("Si le nom de la précédente boîte est non vide, alors le serveur doit aussi être complété !");
			return(false);
		}
		if (f.previous_password.value.toString().length == 0) {
			alert("Si le nom de la précédente boîte est non vide, alors le mot de passe doit aussi être complété !");
			return(false);
		}
	}
	if (f.previous_password.value.toString().length > 0) {
		if (f.previous_host.value.toString().length == 0) {
			alert("Si le mot de passe de la précédente boîte est non vide, alors le serveur doit aussi être complété !");
			return(false);
		}
		if (f.previous_login.value.toString().length == 0) {
			alert("Si le mot de passe de la précédente boîte est non vide, alors le nom doit aussi être complété !");
			return(false);
		}
	}
	if (f.tel.value.toString().length == 0) {
		alert("Le n° de téléphone / GSM ne peut être vide !");
		return(false);
	}

	
       return(true);
   }
