function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function VerifEmail(Email,IdMembre)
{
    $.post("/ajax/verif-email.php", { 
	Email: Email,
	IdMembre: IdMembre
	},
	
    function(data){
		var Retour = eval('(' + data + ')');
		if(Retour['EmailExiste'] == 1)
		{
			$("#VerifEmail").html('Email déjà existante');
			$("#ValiderFormulaire").css('display','none')
		}
		else
		{
			$("#VerifEmail").html('');
			$("#ValiderFormulaire").css('display','block')		
		}		
    }),'json';
}

function Suppr(Cible)
{
	if (confirm("Etes vous sûr de vouloir supprimer cet enregistrement?\r\nCette opération est irréversible !!!"))
	{
		window.document.location.href = Cible;
	}
}

function Number_Format(a, b, c, d) {
	// number_format(number, decimals, comma, formatSeparator)
	a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
	e = a + '';
	f = e.split('.');
	if(!f[0]) f[0] = '0';
	if(!f[1]) f[1] = '';
	if(f[1].length < b){
		g = f[1];
		for(i = f[1].length + 1; i <= b; i++) {
			g += '0';
		}
		f[1] = g;
	}
	if(d != '' && f[0].length > 3) {
		h = f[0];
		f[0] = '';
		for(j = 3; j < h.length; j += 3) {
			i = h.slice(h.length - j, h.length - j + 3);
			f[0] = d + i +  f[0] + '';
		}
		j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
		f[0] = j + f[0];
	}
	c = (b <= 0) ? '': c;
	return f[0] + c + f[1];
}

function affichOnglet(onglets,quel)
{
	var menu = eval(onglets);

	for(var i = 0; i < menu.length; i++)
	{
		if(menu[i] == quel)
		{
			if(quel != '')
			{
				obj1=document.getElementById(quel);
				// Version Survol
				/*
				obj1.style.display="";
				*/
				// Version Clik
				
				if (obj1.style.display=="none")
				{
					obj1.style.display="";
				}
				/*
				else
				{
					obj1.style.display="none";
				}
				*/
				
			}
		}
		else
		{
			obj=document.getElementById(menu[i]);
			obj.style.display="none";		
		}
	}
}


function ChangePhoto(Source,Cible)
{
	Destination = document.getElementById(Cible);
	Destination.src = Source;
}

function Clignonant()
{
	for(var i=0;i<chpClignotant.length;i++)
	{
		if (compteur[chpClignotant[i]]+1 == chpCouleur[chpClignotant[i]].length)
		{
			
			compteur[chpClignotant[i]]=0; 
		}
		else
		{	
			compteur[chpClignotant[i]]++;
		}
			
		document.getElementById(chpClignotant[i]).setAttribute('color',chpCouleur[chpClignotant[i]][compteur[chpClignotant[i]]]); 
	}
    setTimeout("Clignonant()",500); 
}

// Objet des champs obligatoires
function objObligatoire(id,nom_fr,nom_en)
{
	this.id = id;
	this.nom_fr = nom_fr;
	this.nom_en = nom_en;
}

// Objet des cgv
function objCgv(id,nom_fr,nom_en)
{
	this.id = id;
	this.nom_fr = nom_fr;
	this.nom_en = nom_en;
}

// Objet des champs email
function objEmail(id,nom_fr,nom_en)
{
	this.id = id;
	this.nom_fr = nom_fr;
	this.nom_en = nom_en;
}

// Objet des messages d'erreur
function objErreur(mess_fr,mess_en)
{
	this.mess_fr = mess_fr;
	this.mess_en = mess_en;
}

var regExpEmailAdress=/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/g;										// Accepte une adresse email. Ex : toto@toto.com

function matchRegularExpression(valeur, regularExpression)
{
	var resultat = valeur.match(regularExpression);
	if(resultat!=null && resultat.length==1) return true;
	else return false;
}

function doesntMatchRegularExpression(valeur, regularExpression)
{
	if(matchRegularExpression(valeur, regularExpression)) return false;
	else return true;
}

function isNotEmailAdress(valeur)
{
	return doesntMatchRegularExpression(valeur, regExpEmailAdress);
}
function VerifForm(Lang,Formulaire)
{
	champsVide = new Array();
	champsObligatoire = new Array();
	
	j = 0;
	for(i=0;i<listeObligatoire.length;i++)
	{
		if(document.getElementById(listeObligatoire[i]["id"]).value == '')
		{
			champsObligatoire[j] = listeObligatoire[i]['nom_'+Lang];
			j++;
		}
	}
	if(champsObligatoire.length > 0)
	{
		message = listeErreur[0]['mess_'+Lang]+'\n';
		for(i=0;i<champsObligatoire.length;i++)
		{
			message += ' - '+champsObligatoire[i]+'\n';
		}
		alert(message);
	}
	else
	{
		// Vérifie la syntaxe des mail
		if(document.getElementById('LivraisonEmail').value != '' && isNotEmailAdress(document.getElementById('FactureEmail').value))
		{
			alert(listeErreur[2]['mess_'+Lang]);
		}
		else
		{
			// Envoye du formulaire
			document.getElementById(Formulaire).submit();
		}
	}
}

function DesactiveSubmit(Formulaire){
	document.getElementById('Submit').disabled = "disabled";
}

function VerifAll()
{
	for(var i=1;i<arguments.length;i++)
	{
		if (eval(arguments[i]) == false) return false;
	}
//	DesactiveSubmit(arguments[0]);
}

function VerifSaisi()
{
	Message = '';

	for(var i=0;i<listeObligatoire.length;i++)
	{
		if(document.getElementById(listeObligatoire[i]["id"]).value == '')
		{
			Message += '- '+listeObligatoire[i]["nom_"+langue]+"\n";
		}
	}
	if(Message != '')
	{
		alert(Message);
		return false;
	}
	return true;
	
}

function VerifCgv()
{
	Message = '';

	for(var i=0; i<listeCgv.length;i++)
	{
		Cible = document.getElementById(listeCgv[i].id);
		if(Cible.checked == false)
		{
			Message += '- '+listeCgv[i]["nom_"+langue]+"\n";	
		}
	}
	if(Message != '')
	{
		alert(Message);
		return false;
	}
	else return true;	
}
/*
function VerifEmail(){
	Message = '';

	for(var i=0;i<listeEmail.length;i++)
	{
		if(isNotEmailAdress(document.getElementById(listeEmail[i]["id"]).value))
		{
			Message += '- '+listeEmail[i]["nom_"+langue]+"\n";
		}		

	}
	if(Message != '')
	{
		alert(Message);
		return false;
	}
	else return true;
}
*/
function EnvoiFormulaire(Formulaire)
{
	document.getElementById(Formulaire).submit();
}

function Majuscule(cible)
{
	cible.value = cible.value.toUpperCase();
}