function ConfirmLien(MessageConfirme, Lien) {
	if (confirm(MessageConfirme)) {
		window.location = Lien;
	}
}

function ChoisirDate(ChampFormulaire) {
	window.open("Pages/Popups/AfficheCalendrier.popup.php?ChampFormulaire="+ChampFormulaire, "Calendrier", "width=290,height=265");	
}

function FichierJoint(Action) {
	switch (Action) {
		case 'Ajout':
			window.open("Pages/Popups/AjoutFichierJoint.popup.php", "FichierJoint", "width=290,height=265");
		break;
		
		case 'Voir':
			listeFichiers = document.forms[0].FichiersJoints.value;
			if (listeFichiers == "") {
				alert("Il n'y a pas de fichier joints à cet article.");	
			}
			else {
				window.open("Pages/Popups/VoirFichierJoint.popup.php?ListeFichiers="+listeFichiers, "FichierJoint", "scrollbars=yes,resizable,width=350,height=265");	
			}
		break;
		
		case 'Effacer':
			window.open("Pages/Popups/VoirFichierJoint.popup.php?ListeFichiers="+listeFichiers, "FichierJoint", "scrollbars=yes,resizable,width=350,height=265");	
		break;
	}
}

function Popup(UrlPage, LargeurPopup, HauteurPopup) {
	LargeurEcran = window.screen.availWidth;
	HauteurEcran = window.screen.availHeight;
	
	PositionX = parseInt(LargeurEcran / 2) - parseInt(LargeurPopup / 2);
	PositionY = parseInt(HauteurEcran / 2) - parseInt(HauteurPopup / 2);
	
	window.open(UrlPage, "", "scrollbars=no,resizable=no,width="+LargeurPopup+",height="+HauteurPopup+",top="+PositionY+",left="+PositionX);
}

function PopupFolio(UrlPage, LargeurPopup, HauteurPopup) {
	LargeurEcran = window.screen.availWidth;
	HauteurEcran = window.screen.availHeight;
	
	PositionX = parseInt(LargeurEcran / 2) - parseInt(LargeurPopup / 2);
	PositionY = parseInt(HauteurEcran / 2) - parseInt(HauteurPopup / 2);
	
	window.open(UrlPage, "", "scrollbars=no,resizable=no,width="+LargeurPopup+",height="+HauteurPopup+",top="+PositionY+",left="+PositionX);
}

function ModifierResponsable(idResponsable) {
	var idSaisie = document.forms[0].idSaisie.value;
	alert(idSaisie+" -- "+idResponsable);
	window.open("index.php", "LePopup", "scrollbars=yes,resizable=yes,width=500,height=375");
}

function ValideFormDemande() {
	//--> TEST DES CHAMPS VIDES 
	var ListeChamps = new Array("LocalisationPoste", "Nom", "Prenom", "Adresse", "CodePostal", "Ville", "Telephone", "Email", "Motivations", "ExperiencePro", "CentreInteret");
	var ErreurForm = false;
	
	for (i=0; i < ListeChamps.length; i++) {
		var leChamp	= eval("document.forms[0]."+ListeChamps[i]+".value");
		if (leChamp == "") {
			ErreurForm = true;	
		}
	}
	
	if (!ErreurForm) {
		document.forms[0].submit();	
	}
	else {
		alert("Veuillez renseigner tous les champs en rouge\nMerci.");
	}
}

function ValideFormOffre() {
	//--> TEST DES CHAMPS VIDES 
	var ListeChamps = new Array("LocalisationPoste", "TypeContrat", "Remuneration", "Description", "ProfilRecherche", "InfosComplementaires");
	var ErreurForm = false;
	
	for (i=0; i < ListeChamps.length; i++) {
		var leChamp	= eval("document.forms[0]."+ListeChamps[i]+".value");
		if (leChamp == "") {
			ErreurForm = true;	
		}
	}
	
	if (!ErreurForm) {
		document.forms[0].submit();	
	}
	else {
		alert("Veuillez renseigner tous les champs en rouge\nMerci.");
	}
}

function ValideFormContact() {
	//--> TEST DES CHAMPS VIDES 
	var ListeChamps = new Array("Nom", "Email", "Message");
	var ErreurForm = false;
	
	for (i=0; i < ListeChamps.length; i++) {
		var leChamp	= eval("document.forms[0]."+ListeChamps[i]+".value");
		if (leChamp == "") {
			ErreurForm = true;	
		}
	}
	
	if (!ErreurForm) {
		document.forms[0].submit();	
	}
	else {
		alert("Les champs Nom, Email et Message sont obligatoires.\nMerci.");
	}
}

function verifie_email(objet)
{
	resultat = true;
	
	if ((objet.value.length > 0) & (objet.value.length < 7))
		{
		resultat = false;
		}
	
	var nb1 = objet.value.indexOf("@");
	var nb2 = objet.value.lastIndexOf("@");
	
	if((nb1 != nb2)||(nb1 == '-1'))
		{
		resultat = false;
		}
		
	var adr_temp = objet.value.substring(nb1+1,objet.value.length);
	var nbdot = adr_temp.lastIndexOf(".");
	var elem1 = objet.value.substring(0,nb1);
	var elem2 = adr_temp.substring(0,nbdot);
	var elem3 = adr_temp.substring(nbdot+1,objet.value.length);
	
	if((elem1.length==0)||(elem1.indexOf(" ")!=-1))
		{
		resultat = false;
		}
		
	if((elem2.length<2)||(elem2.indexOf(" ")!=-1))
		{
		resultat = false;
		}
		
	if((elem3.length<2)||(elem3.length>3)||(elem3.indexOf(" ")!=-1))
		{
		resultat = false;
		}
		
	if (resultat == false)
		{
		alert("Veuillez saisir une adresse e-mail valide.\nMerci");
		Gimefocus(objet);
		}
}

function VerifNbCaracteres(ChampFormulaire, MaxChar){
	
	if (ChampFormulaire.value.length > MaxChar) {
		alert("Vous ne disposez que de "+MaxChar+" caractères pour ce champ.");
		ChampFormulaire.value = ChampFormulaire.value.substring(0, MaxChar);
	}
}

function ChangePageGuide(PageGuide) {
	if (PageGuide != "") {
		window.location = PageGuide;
	}
}