///////////////////////////////////////
//              POP-UP               //
///////////////////////////////////////
var MyWin = null;
function popupCentree(url,nom,largeur,hauteur,opt)	{
	//default value
	url = 		typeof(url) 		!= 'undefined' ? url 			: window.location;
	nom = 		typeof(nom) 		!= 'undefined' ? nom 			: 'pop_up';
	largeur = typeof(largeur) != 'undefined' ? largeur 	: 640;//largeur search
	hauteur = typeof(hauteur) != 'undefined' ? hauteur 	: 480;//hauteur search
	opt = 		typeof(opt) 		!= 'undefined' ? opt 			: 'menubar=no,scrollbars=yes,statusbar=no';
	//on rajoute des marges à la pop-up
	largeur+=20;
	hauteur+=100;
	//pop up position
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	//on ajoute top left width heigth aux options (compatibilité browser)
	if (opt!='') {
		opt += ',';
	}
	opt += 'top='+top+',left='+left+',width='+largeur+',height='+hauteur;
	//popup does not exist
	if (MyWin == null || MyWin.closed) {
		MyWin=window.open(url,nom,opt);
	} else {
	//else change location
		MyWin.location = url;
	}
	//position
	MyWin.moveTo(left,top);
	//size
	MyWin.resizeTo(largeur,hauteur);
	//show on top
	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 validHoraire(monForm)
	{
		//-- Famille
		if (monForm.h_date.value == "")
			{
				alert("Veuillez saisir une valeur dans le champ \"date\".");
				monForm.h_date.focus();
				return false;
			}	
		//-- Film
		if (monForm.id_film.selectedIndex == 0)
			{
				alert("Veuillez sélectionner un \"film\".");
				monForm.id_film.focus();
				return false;
			}
	return true;
	}
	
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 ******************************** */
		//prénom
		if (monForm.prenom.value=="")
			{
				alert("Vous devez indiquer votre \"PRENOM\".");
				monForm.prenom.focus();
				return false;
			}
		//nom
		if (monForm.nom.value=="")
			{
				alert("Vous devez indiquer votre \"NOM\".");
				monForm.nom.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;
	}
