/*
function verif()
{
if ((document.forms['newuser'].participant_nom.value == "" || document.forms['newuser'].participant_prenom.value == "" || document.forms['newuser'].participant_adresse.value == "" || document.forms['newuser'].participant_cp.value == "" || document.forms['newuser'].participant_ville.value == "" || document.forms['newuser'].participant_email.value == "" || document.forms['newuser'].participant_datenais.value == ""))
	{alert("Tous les champs doivent être renseignés !");return false;}
else
	{
	if (isNaN(document.forms['newuser'].participant_cp.value)){alert("Votre code postal doit être un nombre");return false;}
	if (isNaN(document.forms['newuser'].participant_datenais.value)){alert("Votre date de naissance doit être un nombre");return false;}
	if (document.forms['newuser'].participant_email.value == ""){alert("Merci d'indiquer votre e-mail");return false;}else{if (!document.forms['newuser'].participant_email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi)){alert("E-mail invalide");return false;}}
	}
return true;
}

function verif_cp()
{	MM_validateForm("participantcp_nom","Nom","R","participantcp_prenom","Prénom","R","participantcp_email","Email","NisEmail","participantcp_discipline","Discipline","R","participantcp_niveau","Niveau","R","participantcp_nomet","Nom établissement","R","participantcp_adresseet","Adresse ","R","participantcp_cpet","Code postal ","R","participantcp_villeet","Ville ","R","participantcp_telet","Téléphone","R","participantcp_emailet","Email ","NisEmail","participantcp_siteet","Site de l'établissement","R","participantcp_login","Login","R","participantcp_pass","Mot de passe","R");
	
	if (document.MM_returnValue)
	{				
		obj = MM_findObj('participantcp_regle');
		if(!obj.checked){
			alert ("Merci de cocher la case signifiant votre accord sur le règlement");
			return false;
		}
		else {
			return true;
		}		
	}
	else{
		return false;
	}
}*/

function verif_question()
{
	if(document.getElementById('answer_txt'))
	{
		isanswser = true;
	}
	else
	{ 
		isanswser = false;
	} 
	if (document.forms['question'].elements && !isanswser)
	{
		checked=false;
		for (i=0;i<document.forms['question'].elements.length;i++)
		{
			if (document.forms['question'].elements[i].checked)
			{
				checked=true;
				break;
			}
		}
		if (!(checked))
		{
				alert("Une reponse est obligatoire ! ");
				return false;
		}
	}
	else 
	if (document.getElementById('answer_txt'))
	{
	
		if (document.getElementById('answer_txt').value=="")
		{
				alert("Une reponse est obligatoire !");
				return false;
		}
	}
	
	return true;
}


function next_page(check)
{
	if(document.forms['newuser']){
		submit_form('newuser');
	}
	else if(document.forms['newuser_cp']){
		submit_form('newuser_cp');
	}
	else if (document.forms['question']){
		submit_form(document.forms['question'].name,check);		
	}
	else {
		window.location="index-v2.php";
	}
}

function compteur()
{
	counter-=1;
	document.getElementById("compteur").innerHTML = counter+" ";
	if (counter>0){
		tmp=setTimeout("compteur()",1000);
	}
	else{
		tmp=setTimeout("next_page(false)",1000);
	}
}

function clear_tempo()
{
clearTimeout(tmp)
}

function submit_form(name,check)
{
//alert(name);
if (name=="question"){
	if (check){
		if (verif_question()){
			document.forms[name].submit();
		}
	}
	else{
		document.forms[name].submit();
	}
}
else if (name=="inscription"){
	document.forms[name].submit();
}
/*else if (name=="newuser"){
	if (verif()){
		document.forms[name].submit();
	}
}*/
//else if (name=="newuser_cp"){
	//alert("goof");
	//if (verif_cp()){
		//document.forms[name].submit();
	//}
//}
} 

/*function MM_findObj(n, d) 
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}*/

function replace(string,text,by)
{
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

