//----------------------------- PopUP centre ------------------------//

function popup_centre(url,nom,largeur,hauteur,options) {
	var haut=(screen.height-hauteur)/2;
	var Gauche=(screen.width-largeur)/2;
	fencent=window.open(url,nom,"top="+haut+",left="+Gauche+",width="+largeur+",height="+hauteur+","+options);
}

<!-----------------Activer un champ avec un radio------------------>
function active_input(a,b,c,d)
{
   if (document.getElementById(a).checked)
      document.getElementById(d).disabled=true;
	if (document.getElementById(b).checked)
      document.getElementById(d).disabled=false;
	  if (document.getElementById(c).checked)
      document.getElementById(d).disabled=true;
   
}
<!-----------------Script pour faire apparaitre des champs------------------>


function showMe (it, box) { 
	  var vis = (box.checked) ? "block" : "none"; 
	  document.getElementById(it).style.display = vis;
} 

function OuvrirPopup(page,nom,option) {
  window.open(page,nom,option);
}

function check_aff_par() { 
    
	var chkCer = document.getElementById('choix[1]'); 
	var chkTlm = document.getElementById('choix[0]'); 
    var chkAff = document.getElementById('choix[2]'); 
    var chkPar = document.getElementById('choix[3]'); 
	
	chkAff.checked = chkTlm.checked;
	chkPar.checked = chkTlm.checked;
	chkCer.checked = chkTlm.checked;
} 

function afficher(theid,thevalue) {
	document.getElementById(theid).style.display = thevalue;

}

<!-----------------Script pour checker tout les check boxes------------------>

function ManagementCheckBox (ValNumber)
{

if (document.form1.allselect.checked == true)
{
var Loop = 1;
for (var x=1;x<=ValNumber;x++)
{ 
document.getElementsByName("checkbox"+Loop)[0].checked=true;
Loop++;
}
}
else
{
var Loop = 1;
for (var x=1;x<=ValNumber;x++)
{ 
document.getElementsByName("checkbox"+Loop)[0].checked=false;
Loop++;
}
}
}

function ManagementCheckBox2 (ValNumber)
{

if (document.form1.allselect.checked == true)
{
var Loop = 1;
for (var x=1;x<=ValNumber;x++)
{ 
document.getElementById("checkbox"+Loop).checked=true;
Loop++;
}
}
else
{
var Loop = 1;
for (var x=1;x<=ValNumber;x++)
{ 
document.getElementById("checkbox"+Loop).checked=false;
Loop++;
}
}
}


<!-----------------Script pour autocomplet ville par le code postal------------------>

var url = "AjaxVille.php?param="; // The server-side script
function handleHttpResponse() {
  if (http.readyState == 4) {
    if (http.responseText.indexOf('invalid') == -1) {
      // Use the XML DOM to unpack the city and state data 
      var xmlDocument = http.responseXML; 
      var city = xmlDocument.getElementsByTagName('city').item(0).firstChild.data;
      document.getElementById('city').value = city;
      isWorking = false;
    }
  }
}
var isWorking = false;
function updateCityState() {
  if (!isWorking && http) {
    var zipValue = document.getElementById("zip").value;
    http.open("GET", url + escape(zipValue), true);
    http.onreadystatechange = handleHttpResponse;
    isWorking = true;
    http.send(null);
  }
}
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
	  xmlhttp.overrideMimeType("text/xml"); 
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object

<!-----------------Script affichant d autres champs quand un radio est selectionne------------------>

function show(champs)
{
      if (document.getElementById(champs).style.display == 'none')
      {
            document.getElementById(champs).style.display = 'block';
      }
}

function hide(champs)
{
      if (document.getElementById(champs).style.display == 'none')
      {
            document.getElementById(champs).style.display = 'none';
      }
      else
      {
            document.getElementById(champs).style.display = 'none';
      }
}


<!-----------------Info bulles pour la config------------------>
function GetId(id)
{
return 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 + 5+"px";
    GetId("curseur").style.top=e.pageY + 10+"px";
    }
    else { // Modif proposé par TeDeum, merci à  lui
    if(document.documentElement.clientWidth>0) {
GetId("curseur").style.left=20+event.x+document.documentElement.scrollLeft+"px";
GetId("curseur").style.top=10+event.y+document.documentElement.scrollTop+"px";
    } else {
GetId("curseur").style.left=20+event.x+document.body.scrollLeft+"px";
GetId("curseur").style.top=10+event.y+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; // on copie notre texte dans l'élément html
  i=true;
  }
}
function cache() {
if(i==true) {
GetId("curseur").style.visibility="hidden"; // Si la bulle est visible on la cache
i=false;
}
}
document.onmousemove=move; // dès que la souris bouge, on appelle la fonction move pour mettre à jour la position de la bulle.

<!-----------------Verif du formulaire contact------------------>
function verif_contact() 
{ 
	var nom = document.contactform.nom.value;
	
	if (document.contactform.nom.value == "")
	{
		alert ('Veuillez entrer votre nom');
		document.contactform.nom.focus();
		return false;
	}
	if(document.contactform.prenom.value == "")
	{
		alert ('Veuillez entrer votre prénom');
		document.contactform.prenom.focus();
		return false;
	}
	if(document.contactform.email.value == "")
	{
		alert ('Veuillez entrer votre email');
		document.contactform.email.focus();
		return false;
	} else {
		var str = document.contactform.email.value ;
		var regexp = new RegExp("^[a-zA-Z0-9_\\-\\.]{3,}@[a-zA-Z0-9\\-_]{2,}\\.[a-zA-Z]{2,4}$", "g");
		if (!regexp.test(str)) {
		alert("L'adresse e-mail n'est pas valide !");
		document.contactform.email.focus();
		return false;
		}
	}
	if(document.contactform.telephone.value == "")
	{
		alert ('Veuillez entrer un n° de téléphone');
		document.contactform.telephone.focus();
		return false;
	}
	if(document.contactform.motif.value == "Non précisé")
	{
		alert ('Veuillez choisir Motif à votre email');
		document.contactform.motif.focus();
		return false;
	}
	if(document.contactform.telephone.value.length != 10)
	{ 
		alert ('Le n° de téléphone doit comporter 10 chiffres'); 
		document.contactform.telephone.focus();
		return false; 
	}
	if(document.contactform.message.value == "")
	{ 
		alert ("Vous n'avez pas ecrit de message"); 
		document.contactform.message.focus();
		return false; 
	}
	else {return true;}
}

<!-----------------Verif du formulaire du permis------------------>
function verif_permis() { 
	
	if (document.form1.nom_stagiaire.value == "")
	{
		alert ('Veuillez entrer votre nom');
		document.form1.nom_stagiaire.focus();
		return false;
	}
	if(document.form1.prenom_stagiaire.value == "")
	{
		alert ('Veuillez entrer votre prénom');
		document.form1.prenom_stagiaire.focus();
		return false;
	}	
	if (document.form1.naissance_stagiaire.value == "")
	{
		alert ('Veuillez entrer votre date de naissance');
		document.form1.naissance_stagiaire.focus();
		return false;
	}
	if (document.form1.adresse_stagiaire.value == "")
	{
		alert ('Veuillez entrer votre adresse');
		document.form1.adresse_stagiaire.focus();
		return false;
	}
	if (document.form1.zip.value == "")
	{
		alert ('Veuillez entrer votre code postal');
		document.form1.zip.focus();
		return false;
	}
	if (document.form1.city.value == "")
	{
		alert ('Veuillez entrer votre ville');
		document.form1.city.focus();
		return false;
	}
	if(document.form1.tel_stagiaire.value == "")
	{
		alert ('Veuillez entrer un n° de téléphone');
		document.form1.telephone_stagiaire.focus();
		return false;
	}
	if(document.form1.tel_stagiaire.value.length != 10)
	{ 
		alert ('Le n° de téléphone doit comporter 10 chiffres sans espace'); 
		document.form1.tel_stagiaire.focus();
		return false; 
	}
	if(document.form1.email_stagiaire.value == "")
	{
		alert ('Veuillez entrer votre email');
		document.form1.email_stagiaire.focus();
		return false;
	} else {
		var str = document.form1.email_stagiaire.value ;
		var regexp = new RegExp("^[a-zA-Z0-9_\\-\\.]{3,}@[a-zA-Z0-9\\-_]{2,}\\.[a-zA-Z]{2,4}$", "g");
		if (!regexp.test(str)) {
		alert("L'adresse e-mail n'est pas valide !");
		document.form1.email_stagiaire.focus();
		return false;
		}
	}
	
}

<!-----------------Verif du formulaire de recherche de stage------------------>
function verif_recherche() 
{ 
	var nom = document.rechercheform.nom.value;
	
	if(document.rechercheform.prenom.value == "")
	{
		alert ('Veuillez entrer votre prénom');
		document.rechercheform.prenom.focus();
		return false;
	}
	if (document.rechercheform.nom.value == "")
	{
		alert ('Veuillez entrer votre nom');
		document.rechercheform.nom.focus();
		return false;
	}
	/*if(document.rechercheform.email.value == "")
	{
		alert ('Veuillez entrer votre email');
		document.rechercheform.email.focus();
		return false;
	} else {
		var str = document.rechercheform.email.value ;
		var regexp = new RegExp("^[a-zA-Z0-9_\\-\\.]{3,}@[a-zA-Z0-9\\-_]{2,}\\.[a-zA-Z]{2,4}$", "g");
		if (!regexp.test(str)) {
		alert("L'adresse e-mail n'est pas valide !");
		document.rechercheform.email.focus();
		return false;
		}
	}*/
	if(document.rechercheform.telephone.value == "")
	{
		alert ('Veuillez entrer un n° de téléphone');
		document.rechercheform.telephone.focus();
		return false;
	}
	if(document.rechercheform.stages.value == "Non précisé")
	{
		alert ('Veuillez choisir un type de stage');
		document.rechercheform.stages.focus();
		return false;
	}
	if(document.rechercheform.telephone.value.length != 10)
	{ 
		alert ('Le n° de téléphone doit comporter 10 chiffres'); 
		document.rechercheform.telephone.focus();
		return false; 
	}
	if(document.rechercheform.message.value == "Entrez votre message ici")
	{ 
		alert ("Vous n'avez pas ecrit de message"); 
		document.rechercheform.message.focus();
		return false; 
	}
	else {return true;}
}
<!-----------------Ajax pour affichage des regions departements et ville------------------>
var Ld1Id='';
var Ld2Id='';
var id_liste='';

function ValideReg(val) {
	Ld1Id=val; //id_département
	id_liste='2';//Utilisé dans la fonction ChargeLd() pour identifier la liste déroulante
	var LD_URL = 'departements.php?reg='+Ld1Id;
	ObjetXHR(LD_URL)
	// Réinitialisation de Ld3 si modification de LD1 après passage en Ld2
	if (Ld2Id!='') {ValideLd3('');	}
}

function ValideDept(val) {
	Ld2Id=val; //id_commune
	id_liste='3'; //Utilisé dans la fonction ChargeLd() pour identifier la liste déroulante
	var LD_URL = 'villes.php?reg='+Ld1Id+'&dept='+Ld2Id;
	if (Ld2Id=='') {var LD_URL = 'ListeCP.php';}
	ObjetXHR(LD_URL)
}

function ObjetXHR(LD_URL) {
	//creation de l'objet XMLHttpRequest
	if (window.XMLHttpRequest) { // Mozilla,...
		xmlhttp=new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) {
			xmlhttp.overrideMimeType('text/xml');
		}	
		xmlhttp.onreadystatechange=ChargeLd;
		xmlhttp.open("GET", LD_URL, true);
		xmlhttp.send(null);
	} else if (window.ActiveXObject) { //IE 
		xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
		if (xmlhttp) {
			xmlhttp.onreadystatechange=ChargeLd;
			xmlhttp.open('GET', LD_URL, false);
			xmlhttp.send();
		}
	}
	
	return xmlhttp ;
	
}

// fonction pour manipuler l'appel asynchrone
function ChargeLd() {
		if (xmlhttp.readyState==2) { 
			document.getElementById('txt').style.display='block';
		}
		if (xmlhttp.readyState==4) {
			document.getElementById('txt').style.display='none';
			if (xmlhttp.status==200) { 
				//span id="niv2" ou "niv3"
				document.getElementById('niv'+id_liste).innerHTML=xmlhttp.responseText; 
				if (xmlhttp.responseText.indexOf('disabled')<=0) {
					//focus sur liste déroulante 2 ou 3
					document.getElementById('Liste'+id_liste).focus(); 
				}	
			}
		}
}

<!-----------------Validation de la date pour la recherche de stage------------------>
/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strDay=dtStr.substring(0,pos1)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("Le format de la date doit etre de la forme dd-mm-yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Entrer un mois valide")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Entrer un jour valide")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Entrer 4 chiffre pour l'année")
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Entrer une date valide")
		return false
	}
return true
}

function Validate_date(){
	var dt=document.form1.date1_stage
	if (dt.value != "") {
		if (isDate(dt.value)==false){
			dt.focus()
			return false
		}
	    return true
	} else {
		return true
	}
 }
 
<!-----------------Verif du formulaire d inscription------------------>

var dtCh2= "/";

function isDate2(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh2)
	var pos2=dtStr.indexOf(dtCh2,pos1+1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strDay=dtStr.substring(0,pos1)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("Le format de la date doit etre de la forme dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Entrer un mois valide")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Entrer un jour valide")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Entrer 4 chiffre pour l'année")
		return false
	}
	if (dtStr.indexOf(dtCh2,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh2))==false){
		alert("Entrer une date valide")
		return false
	}
return true
}

function verif_form() { 
	
	var naissance = document.form1.naissance_stagiaire ;
	if(naissance.value != "") {
		if (isDate2(naissance.value)==false){
			naissance.focus()
			return false
		}
		return true;
	} else {
		return true;
	}
	
}