// FONCTIONS DE TEST DE FORMULAIRE //

var color_error = "#A8B9CB";
var color = "#FFFFFF";

//centrage des popup
/*function ouvre(fichier,w,h,titreprod) {
  ff=window.open(fichier,"pop","width="+w+",height="+h
	                 +",left=10,top=10,scrollbars=no") ;
  titre="Galerie";
  if (ff) {
  ff.document.open(); 
  ff.document.write('<head><title>' + titre + '<\/title><link href="style.css" rel="stylesheet" type="text/css" /><\/head>');
  ff.document.write('<body background=" '+ 'images/bgzoom.gif'  
                               + ' " onBlur="top.close()">');
  ff.document.write('<table border="0" cellspacing="0" cellpadding="0"><tr><td height="100" width="500">&nbsp;</td></tr><tr><td height="16">&nbsp;</td></tr><tr><td height="404" align="center" valign="middle"><img src="' + fichier + '" /></td></tr><tr><td valign="middle" align="center" height="30" class="titrezoom">' + titreprod + '</td></tr></table>');
  ff.document.write('<\/body>');
  ff.document.close();
         }
  }*/

//affiche la galerie flash dans un popup
function galerie()
{
window.open('', 'popup', 'resizable=no, location=no,  width=750, height=450, left=' + ((screen.width - 750)/2) + ',top=' + ((screen.height - 550)/2)+ ', menubar=no, status=no, scrollbars=no, menubar=no');
}
//gére le nb d'articles dans le panier de commande et l'image du panier
function panier()
{
	if(document.cookie!="")
	{
		tableau= document.cookie.split(";");
		drawing = new Array;
		//on regarde si des cookies sont vides, on les retire alors de la longueur totale du tableau
		/*for(i=1;i<=tableau.length;i++)
		{
			
			if(tableau[i]=="")
			{
				x=x+1;
			}
			else
			{
			x=0;	
			}
	    }*/
		//drawing[0] = tableau.length-x;
		if(tableau.length >1)
		{
		drawing[0] = (tableau.length-1);
		drawing[1] = "<img src=\"images/panierplein.gif\" alt=\"\" width=\"51\" height=\"40\" border=\"0\" />";
		return drawing;
		}
	
		else
		{
			drawing = new Array;
			drawing[0] = 0;
			drawing[1] = "<img src=\"images/paniervide.gif\" alt=\"\" width=\"51\" height=\"40\" border=\"0\" />";
			return drawing;
		}
	}
}

//vérifie le formulaire d'ajout et de modif de marque
/*function check_form_ajout_marque(form)
{
	if(!check_length(form.nom_marque,"nom de la marque")) return false;
	if(!check_length(form.site,"site web")) return false;
	if(form.mail.value.length!=0)
	{
		if(!check_mail(form.mail)) return false;
	}
}*/

//effectue un trim sur les form pour eviter les champs pseudo-vides remplis par des espaces
function trim(string)
{
return string.replace(/(^\s*)|(\s*$)/g,'');
} 


//permet de gerer le champs carac. de 4 lignes si nouveaute==0 ou 1
/*function disablecarac(nouvo, carac)
{
	if(nouvo.value=='1')
	{
		carac.disabled="";
	}
	else 
	{
		carac.disabled="disabled";
	}
}*/

//Vérifie le formulaire d'ajout de produit/nouveaute
function check_form_ajout_produit(form)
{

	if(!check_length(form.nom_produit,"nom du produit")) return false;
	if(!check_length(form.titre_produit,"titre du produit")) return false;
	
	form.description.value = trim(form.description.value);
	if(!check_length(form.description,"description")) return false;
		
	if(!check_length(form.prix,"prix")) return false;
	if(!check_number(form.prix)) return false;
	
	if(!check_length(form.delai,"délai")) return false;
	if(!check_number(form.delai)) return false;
	
	/*if(!check_length(form.poids,"poids")) return false;
	if(!check_number(form.poids)) return false;*/
	
	if(!check_length(form.conditionnement,"conditionnement")) return false;
	if(!check_number(form.conditionnement)) return false;
			
	if(form.fichier_server1.value=="")
	{
		alert("Attention ! Vous n'avez pas choisi d'image par défaut pour ce produit !");
		return false;	
	}	

}

//Vérifie le formulaire d'ajout de carte
function check_form_ajout_carte(form)
{

	if(!check_length(form.nom_produit,"nom du produit")) return false;
	if(!check_length(form.titre_produit,"titre du produit")) return false;
	
	/*form.description.value = trim(form.description.value);
	if(!check_length(form.description,"description")) return false;*/
		
	if(!check_length(form.prix,"prix")) return false;
	if(!check_number(form.prix)) return false;
	
	if(!check_length(form.delai,"délai")) return false;
	if(!check_number(form.delai)) return false;
	
	/*if(!check_length(form.poids,"poids")) return false;
	if(!check_number(form.poids)) return false;*/
	
	/*if(!check_length(form.conditionnement,"conditionnement")) return false;
	if(!check_number(form.conditionnement)) return false;*/
			
	if(form.fichier_server1.value=="")
	{
		alert("Attention ! Vous n'avez pas choisi d'image par défaut pour ce produit !");
		return false;	
	}	

}

//vérifie le formulaire de promo flash
function check_form_flash(form)
{
	if(!check_length(form.debut,"date de début")) return false;
	if(!check_length(form.fin,"date de fin")) return false;
	if(!check_date_inf(form.debut, form.fin)) return false;	
	
	if(!check_length(form.pourcentage,"pourcentage de remise")) return false;
	if(!check_number(form.pourcentage)) return false;
	
	if(!check_length(form.montant,"montant minimum")) return false;
	if(!check_number(form.montant)) return false;
	

}

//Vérifie le formulaire de modification de produitnouveaute
function check_form_modif_photoaccueil(form)
{
	if(!check_length(form.texte,"texte")) return false;
	if(!check_length(form.url,"url")) return false;
				
	//si on a coché la case pour supprimer mais qu'on a pas remplacé l'image, message alerte. Chaque produit doit avori OBLIGATOIREMENT UNE IMAGE
	if(form.suppr_image_produit1.checked==true && form.fichier_server1.value=="")
	{
		alert("Vous n'avez pas choisi de nouvelle image par défaut ! Si c'est une erreur, décochez la case !");
		return false;
	}
	
	/*form.fichier.value = trim(form.fichier.value);
	if(!check_length(form.fichier,"fichier")) return false;*/
}

function check_form_modif_pubvitrine(form)
{
	//if(!check_length(form.texte,"texte")) return false;
	if(!check_length(form.url,"url")) return false;
				
	//si on a coché la case pour supprimer mais qu'on a pas remplacé l'image, message alerte. Chaque produit doit avori OBLIGATOIREMENT UNE IMAGE
	if(form.suppr_image_produit1.checked==true && form.fichier_server1.value=="")
	{
		alert("Vous n'avez pas choisi de nouvelle image par défaut ! Si c'est une erreur, décochez la case !");
		return false;
	}
	
	/*form.fichier.value = trim(form.fichier.value);
	if(!check_length(form.fichier,"fichier")) return false;*/
}

//Vérifie le formulaire de modification de produitnouveaute
function check_form_modif_pubs(form)
{
				
	//si on a coché la case pour supprimer mais qu'on a pas remplacé l'image, message alerte. Chaque produit doit avori OBLIGATOIREMENT UNE IMAGE
	if(form.suppr_image_produit1.checked==true && form.fichier_server1.value=="")
	{
		alert("Vous n'avez pas choisi de nouvelle image par défaut ! Si c'est une erreur, décochez la case !");
		return false;
	}
	
	/*form.fichier.value = trim(form.fichier.value);
	if(!check_length(form.fichier,"fichier")) return false;*/
}

//vérifie le formulaire de recherche coté client
function check_form_recherche(form)
{
	if(!check_length(form.terme,"recherche")) return false;
}

//vérifie le formulaire de recherche coté client
function check_form_budget(form)
{
	if(!check_length(form.somme,"budget")) return false;
	if(!check_number(form.somme)) return false;
}

//vérifie les champs du formulaire de contact coté client
function check_form_contact(form)
{
	if(!check_length(form.nom,"nom")) return false;
	if(!check_length(form.prenom,"prénom")) return false;
	if(!check_length(form.adresse, "adresse")) return false;	
	if(!check_length(form.tel,"téléphone")) return false;
	if(!check_length(form.mail, "e-mail")) return false;	
	if(!check_mail(form.mail)) return false;
	//if(!check_length(form.motif,"motif")) return false;
	if(!check_length(form.contenu_message, "message")) return false;	
	if(!check_length(form.code, "code")) return false;
}

//Vérifie le formulaire d'ajout de destock
/*function check_form_ajout_destock(form)
{
	if(!check_length(form.titre,"titre")) return false;
	
	form.desc.value = trim(form.desc.value);
	if(!check_length(form.desc,"description")) return false;
	
	form.carac.value = trim(form.carac.value);
	if(!check_length(form.carac,"caractéristiques")) return false;
	
	if(!check_length(form.prix_avant,"prix avant")) return false;
	if(!check_number(form.prix_avant)) return false;
	
	if(!check_length(form.reduction,"reduction")) return false;
		
	if(!check_length(form.prix_apres,"prix apres")) return false;
	if(!check_number(form.prix_apres)) return false;

	if(!check_length(form.ecotaxe,"écotaxe")) return false;
	if(!check_number(form.ecotaxe)) return false;

	
	if(!check_length(form.garantie," garantie")) return false;
	
	if(!check_length(form.extension_garantie,"extension de garantie")) return false;
	if(form.extension_garantie.value!='1' && form.extension_garantie.value!='0')
	{
		alert("le champ extension de garantie doit avoir comme valeur 1 ou 0 exclusivement");
		return false;
	}
	
	if(form.extension_garantie.value!='0')
	{
		if(!check_length(form.prix_ext,"prix extension garantie")) return false;
		if(!check_number(form.prix_ext)) return false;
	}
	
	if(form.piece_stock.value.length!=0)
	{
		if(!check_number(form.piece_stock)) return false;
	}

	if(form.fichier_server.value=="")
	{
		alert("Attention ! Vous n'avez pas choisi d'image pour ce produit !");
		return false;	
	}
}*/

//Vérifie le formulaire de modification de destockage
/*function check_form_modif_destock(form)
{
	if(!check_length(form.titre,"titre")) return false;
	
	form.desc.value = trim(form.desc.value);
	if(!check_length(form.desc,"description")) return false;
	
	form.carac.value = trim(form.carac.value);
	if(!check_length(form.carac,"caractéristiques")) return false;
	
	if(!check_length(form.prix_avant,"prix avant")) return false;
	if(!check_number(form.prix_avant)) return false;
	
	if(!check_length(form.reduction,"reduction")) return false;
	
	if(!check_length(form.prix_apres,"prix après")) return false;
	if(!check_number(form.prix_apres)) return false;
	
	if(!check_length(form.ecotaxe,"écotaxe")) return false;
	if(!check_number(form.ecotaxe)) return false;
	
	if(!check_length(form.garantie," garantie")) return false;
		
	if(!check_length(form.extension_garantie,"extension de garantie")) return false;
	if(form.extension_garantie.value!='1' && form.extension_garantie.value!='0')
	{
		alert("le champ extension de garantie doit avoir comme valeur 1 ou 0 exclusivement");
		return false;
	}
	
	if(form.extension_garantie.value!='0')
	{
		if(!check_length(form.prix_ext,"prix extension garantie")) return false;
		if(!check_number(form.prix_ext)) return false;
	}
	
	if(form.piece_stock.value.length!=0)
	{
		if(!check_number(form.piece_stock)) return false;
	}

	
	//si on a coché la case pour supprimer mais qu'on a pas remplacé l'image, message alerte. Chaque produit doit avori OBLIGATOIREMENT UNE IMAGE
	if(form.suppr_image_destock.checked==true && form.fichier_server.value=="")
	{
		alert("Vous n'avez pas choisi de nouvelle image ! Si c'est une erreur, décochez la case !");
		return false;
	}
}*/

//vérification du formaulire de commande infos clients
function check_form_infos_clients(form)
{
	if(!check_length(form.mail,"e-mail")) return false;
	if(!check_mail(form.mail)) return false;
	
	if(!check_length(form.conf_mail,"e-mail de confirmation")) return false;
	if(!check_mail(form.conf_mail)) return false;
	
	if(form.mail.value != form.conf_mail.value)
	{
		alert("Merci de vérifier l'adresse mail et sa confirmation !");
		form.mail.style.background = color_error;
		form.conf_mail.style.background = color_error;
		form.mail.focus();
		return false;
		
	}
	
	if(!check_length(form.nom_client,"nom")) return false;
	if(!check_length(form.prenom,"prenom")) return false;
	if(!check_length(form.adresse_fact,"adresse de facturation")) return false;
	if(!check_length(form.cp_fact,"code postal de l'adresse de facturation")) return false;
	if(!check_number(form.cp_fact)) return false;
	if(!check_length(form.ville_fact,"ville de l'adresse de facturation")) return false;
	
	//au moins un numéro de tél doit être renseigné
	if(form.tel_fixe.value.length==0 && form.tel_gsm.value.length==0)
	{
		alert("Merci de préciser au moins 1 numéro de téléphone (fixe ou GSM) !");
		form.tel_fixe.style.background = color_error;
		form.tel_gsm.style.background = color_error;
		form.tel_fixe.focus();
		return false;
	}
	if(!check_number(form.tel_fixe)) return false;
	if(form.tel_gsm.value.length!=0)
	{
		if(!check_number(form.tel_gsm)) return false;
	}
	
	
	if(form.cadeau[0].checked!=true && form.cadeau[1].checked!=true)
	{
		alert("Vous devez préciser si il s'agit d'un cadeau !");
		return false;
	}
	
	//pour l'adresse de livraison différente
	if(form.adresse_differente.checked==true)
	{
		if(!check_length(form.nom_client_livr,"nom de la livraison")) return false;
		if(!check_length(form.prenom_livr,"prénom de la livraison")) return false;
		if(!check_length(form.adresse_livr,"adresse de livraison")) return false;
		if(!check_length(form.cp_livr,"code postal de l'adresse de livraison")) return false;
		if(!check_number(form.cp_livr)) return false;
		if(!check_length(form.ville_livr,"ville de l'adresse de livraison")) return false;
	}

	if(form.choix_paiement[0].checked!=true && form.choix_paiement[1].checked!=true && form.choix_paiement[2].checked!=true)
	{
		alert("Vous devez choisir un mode de paiement !");
		return false;
	}
	

	
	if(form.cgvok.checked!=true)
	{
		alert("Vous devez comprendre et accepter les CGV pour effectuer votre paiement !");
		return false;
	}
	
	form.submit();
	
	
}

//vérifie la creation de la newsletter dans l'admin
function check_form_create_newsletter(form)
{
	if(form.fichier_server.value=="")
	{
		alert("vous devez associer une image avant de voir un apercu");
		return false;
	}
}

//pour l'utilisation de upload.php et popup_upload => si case décochée, alors bouton parcourir grisé, sinon...
function decoche(bouton, check, texte)
{
	if(check.checked==true)
	{
		bouton.disabled="";
		texte.disabled="";
	}
	else
	{
		bouton.disabled="disabled";
		texte.disabled="disabled";
	}
}

function decoche2(a,b,c,d,e,f,g,check)
{
	if(check.checked==true)
	{
		a.disabled="";
		b.disabled="";
		c.disabled="";
		d.disabled="";
		e.disabled="";
		f.disabled="";
		g.disabled="";
		
	}
	else
	{
		a.disabled="disabled";
		b.disabled="disabled";
		c.disabled="disabled";
		d.disabled="disabled";
		e.disabled="disabled";
		f.disabled="disabled";
		g.disabled="disabled";
	}
}

/*function decoche3(a,selectpays)
{
	if(selectpays.selectedIndex==0)
	{
		
		a[0].disabled="";
		a[1].disabled="";
	}
	else
	{
		a[0].checked=false;
		a[0].disabled="disabled";
		a[1].checked=false;
		a[1].disabled="disabled";
	}
}*/

// Confirmation de la validation d'un formulaire (suppression d'un élément)

/*function confirm_send_mail(champ_activation, champ_mail,champ_cache)
{
	if(champ_mail.value.length != 0 & champ_activation.checked==true )
	{
		if (confirm("Voulez-vous envoyer un e-mail confirmant l'activation ?")) 
		{
			//return true;
			champ_cache.value=1;
			return true;
		}
		else
		{
			//return false;
			champ_cache.value=0;
			return true;
		}
	}
}*/

// Confirmation de la validation d'un formulaire (suppression d'un élément)
/*function confirm_del() {
	if (confirm("Etes vous sûr de vouloir supprimer cet élément ?")) 
		return true;
	else
		return false;
}*/

/*function is_checked(myChamp, champ_name)
{
	if (!myChamp.checked)
	{
		myChamp.style.background = color_error;
		alert("La case "+champ_name+" n'est pas cochée");
		return false;
	}
	else
	{
		myChamp.style.background = color;
		return true;
	}
}*/

// Vérifie si le champ est un nombre et s'il est comprise entre
// les valeurs start et end
// Vérifie si le champ est un nombre et s'il est compris entre
// les valeurs start et end
/*function check_range(myChamp, start, end, champ_name)
{
	if (check_number(myChamp))
	{
		if (myChamp.value < start || myChamp.value > end)
		{
			myChamp.style.background = color_error;
			myChamp.focus();
			alert(myChamp.value+" n'est pas compris dans l'intervalle "+start+" "+end);
    	   	return false;
		}
		if (myChamp.value >= start && myChamp.value <= end)
		{
			myChamp.style.background = color;
    	   	return true;
		}
		
	}
	else
	{
		myChamp.style.background = color_error;
		myChamp.focus();
       	return false;
	}
	
	return true;
}*/

// Cette fonction vérifie le format JJ/MM/AAAA saisi et la validité de la date.
// Le séparateur est défini dans la variable separateur
/*function check_date(myDate, myChamp)
{ 	 
      var amin=1900; // année mini
      var amax=2900; // année maxi
      var separateur="/"; // separateur entre jour/mois/annee
      var j=(myDate.value.substring(0,2));
      var m=(myDate.value.substring(3,5));
      var a=(myDate.value.substring(6,myDate.value.length));
      var ok=true;
	 
	  if (myDate.value.length != 0)
	  {
		  if (((isNaN(j))||(j<1)||(j>31)) && (ok==1) ) {
			 alert("Le jour de "+myChamp+" n'est pas correct."); ok=false;
		  }
		  if (((isNaN(m))||(m<1)||(m>12)) && (ok==1) ) {
			 alert("Le mois de "+myChamp+" n'est pas correct."); ok=false;
		  }
		  if (((isNaN(a))|| (a<amin)||(a>amax)) && (ok==1) ) {		  				
			 alert("L'année de "+myChamp+" n'est pas correcte."); ok=false;					
		  }
		  if (((myDate.value.substring(2,3)!=separateur)||(myDate.value.substring(5,6)!=separateur)) && (ok==1) ) {
			 alert("Les séparateurs de "+myChamp+" doivent être des "+separateur); ok=false;
		  }*/
		  /*if (ok==1) {
			 var d2=new Date(a,m-1,j);
			 j2=d2.getDate();
			 m2=d2.getMonth()+1;
			 a2=d2.getYear();
			 if (a2<=100) {a2=1900+a2}
			 if ( (j!=j2)||(m!=m2)||(a!=a2) ) {
				alert("La date "+myDate.value+" n'existe pas !");
				ok=false;
			 }
		  }*/
	  /*}
	  else
	  {
	  	  ok = true;
	  }
	  
	  if (ok == false)
	  {
		myDate.focus();		
		myDate.style.background = color_error;
	  }
	  else
	  {
	  	myDate.style.background = color;
	  }

      return ok;
}*/

// Vérifie que date_inf est inférieure à date_sup
function check_date_inf(date_inf, date_sup)
{
	var j_inf = (date_inf.value.substring(0,2));
    var m_inf = (date_inf.value.substring(3,5));
    var a_inf = (date_inf.value.substring(6,date_inf.value.length));
	var j_sup = (date_sup.value.substring(0,2));
    var m_sup = (date_sup.value.substring(3,5));
    var a_sup = (date_sup.value.substring(6,date_sup.value.length));

	
	if (a_inf <= a_sup)
	{	
		if (a_inf ==  a_sup)
		{
			if (m_inf <= m_sup)
			{
				if (m_inf == m_sup)
				{	
					if (j_inf <= j_sup)
					{
						date_sup.style.background = color;
						return true;
					}
					else
					{	
						date_sup.style.background = color_error;
						date_sup.focus();
						alert(date_inf.value+" est supérieure à "+date_sup.value);
						return false;
					}
				}
				else
				{
					date_sup.style.background = color;
					return true;
				}				
			}
			else
			{
				date_sup.style.background = color_error;
				date_sup.focus();
				alert(date_inf.value+" est supérieure à "+date_sup.value);			
				return false;
			}
		}
		else
		{
			date_sup.style.background = color;
			return true;
		}
	}
	else
	{
		date_sup.style.background = color_error;
		date_sup.focus();
		alert(date_inf.value+" est supérieure à "+date_sup.value);
		return false;
	}
}

// Vérifie si un champs contient une valeur
function check_length(myChamp, champ_name)
{
	if (myChamp.value.length == 0)
	{
		alert("Le champ "+champ_name+" est vide.");
		myChamp.style.background = color_error;
		myChamp.focus();		
		return false;
	}
	else
	{
		myChamp.style.background = color;
		return true;
	}
}

// Vérifie si le champ est un mail
function check_mail(myMail) 
{
	if (myMail.value.length != 0)
	{
		var reg = new RegExp("^[a-zA-Z0-9\-_]+[a-zA-Z0-9\.\-_]*@[a-zA-Z0-9\-_]+\.[a-zA-Z\.\-_]{1,}[a-zA-Z\-_]+", "g");		
		if (reg.test(myMail.value)) 
		{
    		return true;
    	} else {
       		alert("Mail invalide !");
			myMail.style.background = color_error;
			myMail.focus();
       		return false;
		}
	}
	else
	{
		myMail.style.background = color;
		return true;
	}
}

// Vérifie le numéro de tel
/*function check_tel(myTel, champ_name)
{
	if (myTel.value.length != 0)
	{
		var reg = new RegExp("^[0-9]{2}?[0-9]{2}?[0-9]{2}?[0-9]{2}?[0-9]{2}?$");		
		if (reg.test(myTel.value)) 
		{
    		return true;
    	} else {
       		myTel.style.background = color_error;
			myTel.focus();
			alert("Le numéro de "+ champ_name+" est invalide ! il ne doit comporter que des chiffres et aucun espace");
       		return false;
		}
	}
	else
	{
		myTel.style.background = color;
		return true;
	}
}*/

// Vérifie si le champ est un nombre
function check_number(myNum)
{
	if (!isNaN(myNum.value))
	{	
		myNum.style.background = color;
		return 1;
	}
	else
	{
		myNum.style.background = color_error;
		alert(myNum.value+" n'est pas un nombre");
		myNum.focus();
		return 0;
		
	}
}

// Vérifie si le champ est monnaitaire
/*function check_monnaie(myNum, champ_name)
{
	if (check_number(myNum))
	{
		myNum.style.background = color;	
		return true;
	}
	else
	{	
		myNum.style.background = color_error;	
		//alert("Prix "+myNum.value+" invalide");
		return false;
	}
}*/

// Vérifie si le champ est un nombre et s'il est compris entre
// les valeurs start et end
/*function check_cp(myChamp, start, end, champ_name)
{
	if (check_number(myChamp))
	{
		if (myChamp.value < start || myChamp.value > end)
		{
			myChamp.style.background = color_error;
			myChamp.focus();
			alert(myChamp.value+" n'est pas compris dans l'intervalle "+start+" "+end+" des codes postaux enregistrés");
    	   	return false;
		}
		if (myChamp.value >= start && myChamp.value <= end)
		{
			myChamp.style.background = color;
    	   	return true;
		}
		
	}
	else
	{
		myChamp.focus();
		myChamp.style.background = color_error;
       	return false;
	}
	
	return true;
}*/

//repere si un element de lsite déroulante est sélectionné
/*function check_liste(Mylist, champ_name)
{
	if(Mylist.selectedIndex==0)
		{
			alert("Choisir une valeur dans la liste " + champ_name);
			Mylist.focus();
			//Mylist.style.background = color_error;	
			return false;
		}
		else
		{
			Mylist.style.background = color;	
			return true;
		}
}*/

/*function check_form_agenda(form)
{
	if(!check_length(form.titre,"titre")) return false;
	if(!check_length(form.date_debut,"date début")) return false;
	if(!check_date(form.date_debut, "date début")) return false;	
	
	if(form.date_fin.value.length!=0)
	{
		if(!check_date(form.date_fin, "date fin")) return false;
		if(!check_date_inf(form.date_debut, form.date_fin)) return false;	
	}
	if(form.formdescription.value.length==0)
	{
			alert("Vous devez rentrer une description");
			return false;
	}
	
}*/

/*function check_form_alaune(form)
{
	if(!check_length(form.titre,"titre")) return false;
	if(!check_length(form.date_moment,"date")) return false;
	if(!check_date(form.date_moment, "date")) return false;
	if(!check_length(form.desc_rap,"description rapide")) return false;	
	
	if(form.en_ce_moment.value.length==0)
	{
			alert("Vous devez rentrer une description");
			return false;
	}
	
}*/

/*function check_form_commerce(form)
{
	if(!check_length(form.nom,"nom")) return false;
	if(!check_length(form.prenom,"prénom")) return false;
	if(!check_length(form.raison,"raison sociale")) return false;
	//if(!check_length(form.type,"activité")) return false;
	if(!check_length(form.tel,"téléphone")) return false;
	if(!check_tel(form.tel,"téléphone")) return false;
	
	if(form.fax.value.length!=0)
	{
		if(!check_length(form.fax,"fax")) return false;
		if(!check_tel(form.fax,"fax")) return false;
	}
	
	if(form.portable.value.length!=0)
	{
		if(!check_length(form.portable,"portable")) return false;
		if(!check_tel(form.portable,"portable")) return false;
	}
	
	if(form.mail.value.length!=0)
	{
		if(!check_mail(form.mail)) return false;
	}
	
	if(form.adresse.value.length==0)
	{
			alert("Vous devez rentrer une adresse");
			return false;
	}
	
}*/

/*function check_form_conseil(form)
{
	if(!check_length(form.titre,"titre")) return false;
	if(!check_length(form.date_moment,"date")) return false;
	if(!check_date(form.date_moment, "date")) return false;
	if(!check_length(form.fichier,"fichier .pdf ou .doc")) return false;
	
}*/

/*function check_form_etatcivil(form)
{
	if(form.contenuetatcivil.value.length==0)
	{
			alert("Vous devez rentrer une description");
			return false;
	}
}*/

/*function check_form_geo(form)
{
	if(form.contenugeo.value.length==0)
	{
			alert("Vous devez rentrer une description");
			return false;
	}
}*/

/*function check_form_histoire(form)
{
	if(form.contenuhsitoire.value.length==0)
	{
			alert("Vous devez rentrer une description");
			return false;
	}
}*/

/*function check_form_infoslegales(form)
{
	if(form.description.value.length==0)
	{
			alert("Vous devez rentrer une description");
			return false;
	}
}*/

/*function check_form_liens(form)
{
	if(!check_length(form.newurl,"adresse")) return false;
	if(!check_length(form.newintitule,"intitulé")) return false;
}*/

/*function check_form_loisirs(form)
{
	if(!check_length(form.nom,"nom")) return false;
	if(!check_length(form.prenom,"prénom")) return false;
	if(!check_length(form.raison,"raison sociale")) return false;
	//if(!check_length(form.type,"activité")) return false;
	if(!check_length(form.tel,"téléphone")) return false;
	if(!check_tel(form.tel,"téléphone")) return false;
	
	if(form.fax.value.length!=0)
	{
		if(!check_length(form.fax,"fax")) return false;
		if(!check_tel(form.fax,"fax")) return false;
	}
	
	if(form.portable.value.length!=0)
	{
		if(!check_length(form.portable,"portable")) return false;
		if(!check_tel(form.portable,"portable")) return false;
	}
	
	if(form.mail.value.length!=0)
	{
		if(!check_mail(form.mail)) return false;
	}
	
	if(form.adresse.value.length==0)
	{
			alert("Vous devez rentrer une adresse");
			return false;
	}
	
}*/

/*function check_form_marches(form)
{
	if(!check_length(form.titre,"titre")) return false;
	if(!check_length(form.date_moment,"date")) return false;
	if(!check_date(form.date_moment, "date")) return false;	
	if(!check_length(form.fichier,"fichier .pdf ou .doc")) return false;
	
}*/

/*function check_form_new_galerie(form)
{
	if(!check_length(form.titre,"titre")) return false;
	if(!check_length(form.date_moment,"date")) return false;
	if(!check_date(form.date_moment, "date")) return false;
	if(!check_length(form.description,"description")) return false;
	
}*/

/*function check_form_services(form)
{
	if(!check_length(form.titre,"intitulé")) return false;
	if(!check_length(form.responsable,"responsable")) return false;

	if(!check_length(form.tel,"téléphone")) return false;
	if(!check_tel(form.tel,"téléphone")) return false;
		
	if(form.fax.value.length!=0)
	{
		if(!check_length(form.fax,"fax")) return false;
		if(!check_tel(form.fax,"fax")) return false;
	}
	
	if(form.adresse.value.length==0)
	{
			alert("Vous devez rentrer une adresse");
			return false;
	}	
}*/

/*function check_form_travaux(form)
{
	if(!check_length(form.titre,"titre")) return false;
	if(!check_length(form.date_moment,"date")) return false;
	if(!check_date(form.date_moment, "date")) return false;	
	if(!check_length(form.fichier,"fichier .pdf ou .doc")) return false;
	
}*/

//vérifie la chaine mail pour l'inscription newsletter
function check_form_mail(form)
{
	if(!check_length(form.mail,"e-mail")) return false;
	if(!check_mail(form.mail)) return false;
	//var txt=form.description.value;
	//var nb=txt.length;*/
	/*if(nb<30)
	{
		alert("La description doit faire au moins 30 caractères");	
		//form.description.focus();
		return false;	
	}*/
	//if(!check_length(form.email,"e-mail")) return false;			
	//if(!check_mail(form.email)) return false;

}

/*function check_form_xlagenda_culturel(form)
{
	if(!check_length(form.date_debut,"date début")) return false;
	if(!check_date(form.date_debut, "date début")) return false;	
	
	if(form.date_fin.value.length!=0)
	{
		if(!check_date(form.date_fin, "date fin")) return false;
		if(!check_date_inf(form.date_debut, form.date_fin)) return false;	
	}	
	
	if(!check_length(form.nom,"nom")) return false;
	
	if(form.description.value.length==0)
	{
		alert("Vous devez rentrer une description");
		return false;
	}
	
	//if(!check_liste(categorie, "catégorie")) return false;
	
	if(form.categorie.selectedIndex==0)
	{
		alert ("Veuillez sélectionner une catégorie dans la liste");
		//form.categorie.focus();
		return false;
	}
	if(form.email.value.length!=0)
	{
		if(!check_mail(form.email)) return false;
	}
	if(form.telephone.value.length!=0)
	{
		if(!check_tel(form.telephone,"téléphone")) return false;
	}
	
	if(form.fax.value.length!=0)
	{
		if(!check_tel(form.fax,"fax")) return false;
	}
	
}*/

function popup_upload1(form, remote_path, db_path, mask, size_max, width_max, height_max)
{	
	chemin="../includes/upload1.php?form="+form+"&remote_path="+remote_path+"&db_path="+db_path+"&mask="+mask+"&size_max="+size_max+"&width_max="+width_max+"&height_max="+height_max;
	window.open(chemin,'',"toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=no, copyhistory=no, width=600, height=150, left=300, top=200");	
}

function popup_upload2(form, remote_path, db_path, mask, size_max, width_max, height_max)
{	
	chemin="../includes/upload2.php?form="+form+"&remote_path="+remote_path+"&db_path="+db_path+"&mask="+mask+"&size_max="+size_max+"&width_max="+width_max+"&height_max="+height_max;
	window.open(chemin,'',"toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=no, copyhistory=no, width=600, height=150, left=300, top=200");	
}

function popup_upload3(form, remote_path, db_path, mask, size_max, width_max, height_max)
{	
	chemin="../includes/upload3.php?form="+form+"&remote_path="+remote_path+"&db_path="+db_path+"&mask="+mask+"&size_max="+size_max+"&width_max="+width_max+"&height_max="+height_max;
	window.open(chemin,'',"toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=no, copyhistory=no, width=600, height=150, left=300, top=200");	
}

function popup_uploadnews(form, remote_path, db_path, mask, size_max, width_max, height_max)
{	
	chemin="../includes/uploadnews.php?form="+form+"&remote_path="+remote_path+"&db_path="+db_path+"&mask="+mask+"&size_max="+size_max+"&width_max="+width_max+"&height_max="+height_max;
	window.open(chemin,'',"toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=no, copyhistory=no, width=600, height=150, left=300, top=200");	
}
/*function popup_upload2(form, remote_path, db_path, mask, size_max, width_max, height_max)
{	
	chemin="../includes/upload2.php?form="+form+"&remote_path="+remote_path+"&db_path="+db_path+"&mask="+mask+"&size_max="+size_max+"&width_max="+width_max+"&height_max="+height_max;
	window.open(chemin,'',"toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=no, copyhistory=no, width=600, height=150, left=300, top=200");	
}*/

/*function popup_upload_agenda(form, remote_path, db_path, mask, size_max, width_max, height_max)
{	
	chemin="../../includes/upload.php?form="+form+"&remote_path="+remote_path+"&db_path="+db_path+"&mask="+mask+"&size_max="+size_max+"&width_max="+width_max+"&height_max="+height_max;
	window.open(chemin,'',"toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=no, copyhistory=no, width=600, height=150, left=300, top=200");	
}*/

/*function popup_uploadpdf(form, remote_path, db_path, mask)
{	
	chemin="../includes/uploadpdf.php?form="+form+"&remote_path="+remote_path+"&db_path="+db_path+"&mask="+mask;
	window.open(chemin,'',"toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=no, copyhistory=no, width=600, height=150, left=300, top=200");	
}*/


// Sélection de ville
/*function popupmessage(id_exp, id_dest)
{
		chemin="popupmess.php?id_exp="+id_exp+"&id_dest="+id_dest;
		window.open(chemin,'',"target=_self, toolbar=no, location=no, directories=no, status=yes, scrollbars=no, resizable=no, copyhistory=no, width=400, height=250, left=300, top=50");
}*/

/*function popupreadmess(id_mess)
{
		chemin="popupreadmess.php?id_mess="+id_mess;
		window.open(chemin,'',"toolbar=no, location=no, directories=no, status=yes, scrollbars=no, resizable=no, copyhistory=no, width=400, height=250, left=300, top=50");
}*/
/*function popupprofil(id_exp)
{
		chemin="popupprofil.php?id_exp="+id_exp;
		window.open(chemin,'',"location=no, directories=no, status=yes, scrollbars=no, resizable=no, copyhistory=no, width=400, height=250, left=300, top=50");
}*/
/*function popupville(cp,ville,id_ville)
{
	chemin="includes/popupville.php?cp="+cp+"&ville="+ville+"&id_ville="+id_ville;
	window.open(chemin,'',"toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=no, copyhistory=no, width=300, height=400, left=300, top=50");
}*/

/*function compter(max_char,champ_degressif,textarea) 
{
	var txt=textarea.value;
	var nb=txt.length;
	if (nb>max_char) 
	{ 
		alert("Pas plus de "+max_char+" caractères dans ce champ");
		textarea.value=txt.substring(0,max_char);
		nb=max_char;
	}
		champ_degressif.value=max_char-nb;
}*/
