function verifnewsletter(){
	myst = 0;
	email = document.formnewsletter.email;
	email.style.backgroundColor = "";
	if (email.value == "")
		{
			myst = myst + 1;
			email.style.backgroundColor = "EDE652";
		}
	if (myst != 0)
		{
			alert("Veuillez renseigner votre adresse mail !")
			return false;
		}
	else{
			return true;
		}
}
function verifanswer(){
	error = 0;
	m = document.formanswer.motivations;
	m.style.backgroundColor = "";
	if (m.value == "")
		{
			error = error + 1;
			m.style.backgroundColor = "EDE652";
		}
	if (error != 0)
		{
			alert("Veuillez renseigner le champ MOTIVATIONS !")
			return false;
		}
	else{
			return true;
		}
}

function VerifFormatDate(id)
{
	ladate = document.getElementById(id);
	madate = ladate.value;
	ladate.style.backgroundColor = "";
	
	var error = 0;

	var regex = new RegExp("[/-]");
	var date = madate.split(regex);
	var nbJours = new Array('',31,28,31,30,31,30,31,31,30,31,30,31);
	var result = true;
	
	if ( date['2']%4 == 0 && date['2']%100 > 0 || date['2']%400 == 0 )
		nbJours['2'] = 29;
	
	if( isNaN(date['2']) )
		error = error + 1;
		
	if ( isNaN(date['1']) || date['1'] > 12 || date['1'] < 1 )
		error = error + 1;
	
	if ( isNaN(date['0']) || date['0'] > nbJours[Math.round(date['1'])] || date['0'] < 1 )
		error = error + 1;

	if (error > 0)
		{
			ladate.style.backgroundColor = "EDE652";
			return 1;
		}
	else{
			return 0;
		}
}


function verifpubli(){
	error = 0;
	/*mat = document.formpubli.autrematiere;
	mat.style.backgroundColor = "";
	if (mat.value == "")
		{
			error = error + 1;
			mat.style.backgroundColor = "EDE652";
		}*/
	etab = document.formpubli.nometablissement;
	etab.style.backgroundColor = "";
	if (etab.value == "")
		{
			error = error + 1;
			etab.style.backgroundColor = "EDE652";
		}	
	em = document.formpubli.email2;
	em.style.backgroundColor = "";
	if (em.value == "")
		{
			error = error + 1;
			em.style.backgroundColor = "EDE652";
		}
	texte = document.formpubli.messagefr;
	texte.style.backgroundColor = "";
	if (texte.value == "")
		{
			error = error + 1;
			texte.style.backgroundColor = "EDE652";
		}
	dte = document.formpubli.datepubli;
	if (VerifFormatDate("datepubli")==1)
		{
			alert("La date saisie est erronée !");
			return false
		}
	if (error != 0)
		{
			alert("Veuillez renseigner les champs marqués * !")
			return false;
		}
	else{
			//if(confirm("Attention, votre compte client sera débité d\'un crédit après votre demande de publication.")){
				return true;
			//}else{
				//return false;
			//}
		}
}


function verifpubli2(){
	error = 0;
	/*mat = document.formpubli.autrematiere;
	mat.style.backgroundColor = "";
	if (mat.value == "")
		{
			error = error + 1;
			mat.style.backgroundColor = "EDE652";
		}*/
	etab = document.formpubli.nometablissement;
	etab.style.backgroundColor = "";
	if (etab.value == "")
		{
			error = error + 1;
			etab.style.backgroundColor = "EDE652";
		}	
	em = document.formpubli.email2;
	em.style.backgroundColor = "";
	if (em.value == "")
		{
			error = error + 1;
			em.style.backgroundColor = "EDE652";
		}
	texte = document.formpubli.messagefr;
	texte.style.backgroundColor = "";
	if (texte.value == "")
		{
			error = error + 1;
			texte.style.backgroundColor = "EDE652";
		}
	dte = document.formpubli.datepubli;
	if (VerifFormatDate("datepubli")==1)
		{
			alert("La date saisie est erronée !");
			return false
		}

	if (error != 0)
		{
			alert("Veuillez renseigner les champs marqués * !")
			return false;
		}
	else{
			return true;
		}
}


function verifclient(){
	error = 0;
	errorbis = 0;
	errorter = 0;
	v = document.formclient.nom;
	v.style.backgroundColor = "";
	if (v.value == "")
		{
			error = error + 1;
			v.style.backgroundColor = "EDE652";
		}
	p = document.formclient.prenom;
	p.style.backgroundColor = "";
	if (p.value == "")
		{
			error = error + 1;
			p.style.backgroundColor = "EDE652";
		}
	t = document.formclient.tel
	t.style.backgroundColor = "";
	if (t.value == "")
		{
			error = error + 1;
			t.style.backgroundColor = "EDE652";
		}
	e = document.formclient.email;
	e.style.backgroundColor = "";
	if (e.value == "")
		{
			error = error + 1;
			e.style.backgroundColor = "EDE652";
		}
	ebis = document.formclient.emailbis;
	ebis.style.backgroundColor = "";
	if (ebis.value == "")
		{
			error = error + 1;
			ebis.style.backgroundColor = "EDE652";
		}	
	if (ebis.value != e.value)
		{
			errorbis = 1;
			ebis.style.backgroundColor = "EDE652";
		}
	et = document.formclient.etablissement;
	et.style.backgroundColor = "";
	if (et.value == "")
		{
			error = error + 1;
			et.style.backgroundColor = "EDE652";
		}	
	adr = document.formclient.adr1;
	adr.style.backgroundColor = "";
	if (adr.value == "")
		{
			error = error + 1;
			adr.style.backgroundColor = "EDE652";
		}		
		
	cp = document.formclient.codepostal;
	cp.style.backgroundColor = "";
	if (cp.value == "")
		{
			error = error + 1;
			cp.style.backgroundColor = "EDE652";
		}		
		
	v = document.formclient.ville;
	v.style.backgroundColor = "";
	if (v.value == "")
		{
			error = error + 1;
			v.style.backgroundColor = "EDE652";
		}		
		
		
		
		
		
		
	pwd = document.formclient.pwd;
	pwd.style.backgroundColor = "";
	if (pwd.value == "")
		{
			error = error + 1;
			pwd.style.backgroundColor = "EDE652";
		}
	pwdb = document.formclient.pwdbis;
	pwdb.style.backgroundColor = "";
	if (pwdb.value == "")
		{
			error = error + 1;
			pwdb.style.backgroundColor = "EDE652";
		}
	if (pwdb.value != pwd.value)
		{
			errorter = 1;
			pwdb.style.backgroundColor = "EDE652";
		}
	ckcgv = document.formclient.cgv;
	ckcgv.style.backgroundColor = "";
	if (ckcgv.checked == false)
		{
			error = error + 1;
			ckcgv.style.backgroundColor = "EDE652";
		}
		
	if (error != 0)
		{
			alert("Veuillez remplir les champs obligatoires !")
			return false;
		}
	else if (errorbis !=0)
		{
			alert('La confirmation de votre email est différente !');
			return false;
		}
	else if (errorter !=0)
		{
			alert('La confirmation de votre mot de passe est différente !');
			return false;
		}
	
	
	
	
	
	
	else{
			return true;
		}
}

/*function rendSelectSensible() {
    document.getElementById("pays").onchange = afficheCacheInput;
    document.getElementById("region").style.display = "none";
	document.getElementById("region").value = "-";
}

function afficheCacheInput() {
    document.getElementById("pays").onchange = afficheCacheInput;
    if ( document.getElementById("pays").value == "France") {
        document.getElementById("region").style.display = "inline";
    } else {
        document.getElementById("region").style.display = "none";
		document.getElementById("region").value = "-";
    }
}*/

function rendSelectSensible2() {
    document.getElementById("poste").onchange = afficheCacheInput2;
    document.getElementById("autreposte").style.display = "none";
	document.getElementById("autreposte").value = "-";

    document.getElementById("matiere").onchange = afficheCacheInput2;
    document.getElementById("autrematiere").style.display = "none";
	document.getElementById("autrematiere").value = "-";
}

function afficheCacheInput2() {
    document.getElementById("poste").onchange = afficheCacheInput2;
    if ( document.getElementById("poste").value == 5) {
        document.getElementById("autreposte").style.display = "inline";
			//alert("coucou");

    } else {
        document.getElementById("autreposte").style.display = "none";
		document.getElementById("autreposte").value = "";
    }
	
	
	
	
	document.getElementById("matiere").onchange = afficheCacheInput2;
    if ( document.getElementById("matiere").value == 8) {
        document.getElementById("autrematiere").style.display = "inline";
			//alert("coucou");

    } else {
        document.getElementById("autrematiere").style.display = "none";
		document.getElementById("autrematiere").value = "";
    }
}



function calendrier(formulaire,element)
{
	posY = event.clientY + document.body.scrollTop - 450;
	posX = event.clientX + document.body.scrollLeft + 70;

	wCalendrier = window.open("calendrier.php?origine="+element+"&forml="+formulaire,"Calendrier","width=165,height=100,top="+posY+",left="+posX);		
}