var groupe_logo = 1;
function changeDisplay(id,value){	var element_style=null;	if (document.getElementById) 	{element_style=document.getElementById(id).style;}	else if (document.all) 			{element_style=document.all[id].style;}	else if (document.layers) 		{element_style=document.layers[id];}	element_style.display=value;}
function affiche(id)
{
	changeDisplay(id,'block');
}
function masque(id)
{
	changeDisplay(id,'none');
}
function popuplarge(page,percent)
{
	var w=(screen.height * percent)/100;
	var h=(screen.width * percent)/100;
	var top=(screen.height-h)/2;
    var left=(screen.width-w)/2;
	window.open(page,'_blank',"top="+top+",left="+left+",width="+w+",height="+h+",scrollbars=yes, resizable=yes");
}
function switchGroupeLogo(step)
{
	masque('logos_'+groupe_logo);
	groupe_logo += step;
	if(groupe_logo > nb_groupes_logo)
	{
		groupe_logo = 1;
	}
	if(groupe_logo < 1)
	{
		groupe_logo = nb_groupes_logo;
	}
	affiche('logos_'+groupe_logo);
}
function popup(code,width,height)
{
	window.open('popup.php?code='+code,'_blank','width='+width+',height='+height+',toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, left=50, top=50');
}
function popup2(code,width,height)
{
	window.open('popup2.php?code='+code,'_blank','width='+width+',height='+height+',toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, left=50, top=50');
}
function checkNon()
{
	document.identification.passyes.checked='checked';
}
function verifContactForm()
{
	var alertMsg = '';
	if(document.contact.numero.value=='')
	{
		alertMsg = 'Veuillez remplir le champ "numéro de réception"';
	}
	else if(document.contact.email.value=='')
	{
		alertMsg = 'Veuillez remplir le champ "adresse E-mail"';
	}
	else if(document.contact.probleme.value=='')
	{
		alertMsg = 'Veuillez remplir le champ "description du problème"';
	}
	else if(document.contact.reference.value=='')
	{
		alertMsg = 'Veuillez remplir le champ "code référence de votre sélection"';
	}
	else if(document.contact.description.value=='')
	{
		alertMsg = 'Veuillez remplir le champ "description de votre contenu"';
	}
	if(alertMsg != '')
	{
		alert(alertMsg);
		return false;
	}
	else
	{
		return true;
	}
}

function champEstNombre(strChamp, longueur, obligatoire)
{
	if (!obligatoire && !strChamp)
		return true;
	if (!strChamp || strChamp.length != longueur)
		return false;

	// only allow numbers to be entered
	var checkOK = "0123456789";
	var checkStr = strChamp;
	var allValid = true;
	var allNum = "";
	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 (ch != ",")
		allNum += ch;
		}
	/*
	if (!allValid)
	{
	alert("Please enter only digit characters in the \"numbers\" field.");
	theForm.numbers.focus();
	return (false);
	}
	*/
	return allValid
}

function verifAboPersoForm()
{
	var alertMsg = '';
	
	// alert(document.form_abo_perso.submitButton.value);
	if (document.form_abo_perso.submitButton.value == 1)
		return;
	
	// Vérification des boutons radio Opérateurs
	var radioSelected = false;
	for (i = 0;  i < document.form_abo_perso.strOperateur.length;  i++)
	{
		if (document.form_abo_perso.strOperateur[i].checked)
			radioSelected = true;
	}
	
	// test if valid email address, must have @ and .
	var EmailValid = false;
	var checkEmail = "@.";
	var checkStr = document.form_abo_perso.strEmail.value;
	var EmailAt = false;
	var EmailPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)
		{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkEmail.length;  j++)
			{
			if (ch == checkEmail.charAt(j) && ch == "@")
				EmailAt = true;
			if (ch == checkEmail.charAt(j) && ch == ".")
				EmailPeriod = true;
		  	if (EmailAt && EmailPeriod)
				break;
		  	if (j == checkEmail.length)
				break;
			}
		// if both the @ and . were in the string
		if (EmailAt && EmailPeriod)
			{
			EmailValid = true
			break;
			}
		}
	/*
	if (!EmailValid)
	{
	alert("The \"email\" field must contain an \"@\" and a \".\".");
	theForm.Email.focus();
	return (false);
	}
	*/

	if(document.form_abo_perso.strNom.value=='')
	{
		alertMsg = 'Veuillez remplir le champ "Nom"';
	}
	else if(document.form_abo_perso.strPrenom.value=='')
	{
		alertMsg = 'Veuillez remplir le champ "Prénom"';
	}
	else if(!champEstNombre(document.form_abo_perso.strTelephone.value, 10, 1) || document.form_abo_perso.strTelephone.value.substr(0, 2) != '06')
	{
		alertMsg = 'Veuillez remplir le champ "N° de téléphone mobile" ou indiquer un numéro valide';
	}
	else if(!radioSelected)
	{
		alertMsg = 'Veuillez sélectionner un élément du champ "Opérateur"';
	}
	else if(!EmailValid)
	{
		alertMsg = 'Veuillez remplir le champ "E-mail" ou indiquer un e-mail valide';
	}
	else if(!champEstNombre(document.form_abo_perso.strCP.value, 5))
	{
		alertMsg = 'Veuillez indiquer un code postal valide';
	}
	if (alertMsg)
	{
		alert(alertMsg);
		return false;
	}
	else
	{
		return true;
	}
}
