
function popupCentree(url,nom,largeur,hauteur,opt) 
	{
		var top=(screen.height-hauteur)/2;
		var left=(screen.width-largeur)/2;
		var MyWin=window.open(url,nom,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+opt);
		MyWin.focus(); 
	}
	
function alertRedirect(fichier)
	{
		if(confirm('Si vous changez de partie, vos modifications ne seront pas enregistrées.\r  Souhaitez-vous continuer ?'))
				{
				location.href = fichier;
				}
	}
function validForm(monForm,typvalid)
	{
		if (typvalid=="recommand")
			{
				//destinataires
				if ((monForm.dest1.value=="")&&(monForm.dest2.value=="")&&(monForm.dest3.value=="")&&(monForm.dest4.value==""))
					{
						alert("Vous devez entrer l'e-mail d'au moins un \"DESTINATAIRE\".");
						monForm.dest1.focus();
						return false;
					}
				if (monForm.dest1.value!="")
					{
						var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒþŒŽšœžŸÀÁÂÃÆÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßáâåëìíîïñóôøúýþÿ0123456789-@-_.";
						var checkStr = monForm.dest1.value;
						var allValid = true;
						for (i = 0;  i < checkStr.length;  i++)
							{
								ch = checkStr.charAt(i);
								for (j = 0;  j < checkOK.length;  j++)
									if (ch == checkOK.charAt(j))
											break;
								if (j == checkOK.length)
									{
										allValid = false;
										break;
									}
							}
						if (!allValid)
							{
								alert("Entrez seulement des caractères, chiffres et \".@_-\" dans les champ \"DESTINATAIRES\".");
								monForm.dest1.focus();
								return false;
							}
						adresse = monForm.dest1.value;
						var place = adresse.indexOf("@",1);
						var point = adresse.indexOf(".",place+1);
						if (!((place > -1)&&(adresse.length >2)&&(point > 1)))
							{
								alert('\"DESTINATAIRE \" non valide.\r exemple : nom@domaine.com');
								monForm.dest1.focus();
								return false;
							}
					}
				if (monForm.dest2.value!="")
					{
						var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒþŒŽšœžŸÀÁÂÃÆÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßáâåëìíîïñóôøúýþÿ0123456789-@-_.";
						var checkStr = monForm.dest2.value;
						var allValid = true;
						for (i = 0;  i < checkStr.length;  i++)
							{
								ch = checkStr.charAt(i);
								for (j = 0;  j < checkOK.length;  j++)
									if (ch == checkOK.charAt(j))
											break;
								if (j == checkOK.length)
									{
										allValid = false;
										break;
									}
							}
						if (!allValid)
							{
								alert("Entrez seulement des caractères, chiffres et \".@_-\" dans les champ \"DESTINATAIRES\".");
								monForm.dest2.focus();
								return false;
							}
						adresse = monForm.dest2.value;
						var place = adresse.indexOf("@",1);
						var point = adresse.indexOf(".",place+1);
						if (!((place > -1)&&(adresse.length >2)&&(point > 1)))
							{
								alert('\"DESTINATAIRE \" non valide.\r exemple : nom@domaine.com');
								monForm.dest2.focus();
								return false;
							}
					}
				if (monForm.dest3.value!="")
					{
						var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒþŒŽšœžŸÀÁÂÃÆÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßáâåëìíîïñóôøúýþÿ0123456789-@-_.";
						var checkStr = monForm.dest3.value;
						var allValid = true;
						for (i = 0;  i < checkStr.length;  i++)
							{
								ch = checkStr.charAt(i);
								for (j = 0;  j < checkOK.length;  j++)
									if (ch == checkOK.charAt(j))
											break;
								if (j == checkOK.length)
									{
										allValid = false;
										break;
									}
							}
						if (!allValid)
							{
								alert("Entrez seulement des caractères, chiffres et \".@_-\" dans les champ \"DESTINATAIRES\".");
								monForm.dest3.focus();
								return false;
							}
						adresse = monForm.dest3.value;
						var place = adresse.indexOf("@",1);
						var point = adresse.indexOf(".",place+1);
						if (!((place > -1)&&(adresse.length >2)&&(point > 1)))
							{
								alert('\"DESTINATAIRE \" non valide.\r exemple : nom@domaine.com');
								monForm.dest3.focus();
								return false;
							}
					}
				if (monForm.dest4.value!="")
					{
						var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒþŒŽšœžŸÀÁÂÃÆÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßáâåëìíîïñóôøúýþÿ0123456789-@-_.";
						var checkStr = monForm.dest4.value;
						var allValid = true;
						for (i = 0;  i < checkStr.length;  i++)
							{
								ch = checkStr.charAt(i);
								for (j = 0;  j < checkOK.length;  j++)
									if (ch == checkOK.charAt(j))
											break;
								if (j == checkOK.length)
									{
										allValid = false;
										break;
									}
							}
						if (!allValid)
							{
								alert("Entrez seulement des caractères, chiffres et \".@_-\" dans les champ \"DESTINATAIRES\".");
								monForm.dest4.focus();
								return false;
							}
						adresse = monForm.dest4.value;
						var place = adresse.indexOf("@",1);
						var point = adresse.indexOf(".",place+1);
						if (!((place > -1)&&(adresse.length >2)&&(point > 1)))
							{
								alert('\"DESTINATAIRE \" non valide.\r exemple : nom@domaine.com');
								monForm.dest4.focus();
								return false;
							}
					}
				//message
				if (monForm.msg.value=="")
					{
						alert("Vous devez écrire un \"MESSAGE\".");
						monForm.msg.focus();
						return false;
					}
			}
		/* ******************************** COMMUN ******************************** */
		//nom
		if (monForm.nom.value=="")
			{
				alert("Vous devez indiquer votre \"NOM\".");
				monForm.nom.focus();
				return false;
			}
		//prénom
		if (monForm.prenom.value=="")
			{
				alert("Vous devez indiquer votre \"PRENOM\".");
				monForm.prenom.focus();
				return false;
			}
		//email
		if (monForm.email.value=="")
			{
				alert("Vous devez préciser votre \"E-MAIL\".");
				monForm.email.focus();
				return false;
			}
		if (monForm.email.value!="")
			{
				var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒþŒŽšœžŸÀÁÂÃÆÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßáâåëìíîïñóôøúýþÿ0123456789-@-_.";
				var checkStr = monForm.email.value;
				var allValid = true;
				for (i = 0;  i < checkStr.length;  i++)
					{
						ch = checkStr.charAt(i);
						for (j = 0;  j < checkOK.length;  j++)
							if (ch == checkOK.charAt(j))
									break;
						if (j == checkOK.length)
							{
								allValid = false;
								break;
							}
					}
				if (!allValid)
					{
						alert("Entrez seulement des caractères, chiffres et \".@_-\" dans le champ \"E-MAIL\".");
						monForm.email.focus();
						return false;
					}
				adresse = monForm.email.value;
				var place = adresse.indexOf("@",1);
				var point = adresse.indexOf(".",place+1);
				if (!((place > -1)&&(adresse.length >2)&&(point > 1)))
					{
						alert('\"E-MAIL \" non valide.\r exemple : nom@domaine.com');
						monForm.email.focus();
						return false;
					}
			}
		/* ************************************************************************ */
		if (typvalid=="contact")
			{
				//objet
				/*if (monForm.obj.value=="")
					{
						alert("Vous devez écrire un \"OBJET\".");
						monForm.obj.focus();
						return false;
					}*/
				//message
				if (monForm.msg.value=="")
					{
						alert("Vous devez écrire un \"MESSAGE\".");
						monForm.msg.focus();
						return false;
					}
			}
		
		if (typvalid=="faq")
			{
				//question
				if (monForm.question.value=="")
					{
						alert("Vous devez écrire une \"QUESTION\".");
						monForm.question.focus();
						return false;
					}
			}
	return true;
	}
	
window.addEvent('domready', function () {
		if($('linkRetour')!=null){
			$('linkRetour').addEvent('mouseover', function (e){
				$('imgRetour').set('src', '../composants/img/retour_over.jpg');
			});
			$('linkRetour').addEvent('mouseout', function (e){
				$('imgRetour').set('src', '../composants/img/retour.jpg');
			});
		}
		if($('em')!=null){
			$('em').addEvent('focus', videChamp);
		}
		if($('mp')!=null){
			$('mp').addEvent('focus', videChamp);
		}
});
function videChamp(e){
	this.removeEvent('focus',videChamp);
	this.set('value', '');
	if(this.get("id")=="mp"){
		this.set("type","password");
	}
}

function addSociete(){
	if($("societeNew")&&$("societeNew").get("value")!=""){
			var myvalue = $("societeNew").get("value");
			var myRequest = new Request({url: '../ajaxphp/addSociete.php', method: 'get', onSuccess: function(responseText, responseXML) {
    			var res = responseText.split("|");
				if(res[0]!="existe"){
					var myNewOpt = new Element('option', {
					'value': res[0],
					'id': 'ss'+res[0],
					'selected': 'selected'});
					myNewOpt.appendText(myvalue);
					$('selectSoc').adopt(myNewOpt);
				}
				else{
					$('ss'+res[1]).set("selected","selected");
				}
			}});
			myRequest.send('societeNew='+myvalue);
	}
}

