function submitIt(carForm) {
	if (!validEmail(carForm.email_faq.value)) {
		alert("Adresse email invalide")
		carForm.email_faq.focus()
		carForm.email_faq.select()
		return false
	}
	return true
}
function validEmail(adrEmail) {
	invalidChars="/:,;"
	if (adrEmail=="") {
		return false
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar=invalidChars.charAt(i)
		if (adrEmail.indexOf(badChar,0)>-1) {
			return false
		}
	}
	atPos=adrEmail.indexOf("@",1)
	if (atPos==-1) {
		return false
	}
	if (adrEmail.indexOf("@",atPos+1)>-1) {
		return false
	}
	periodPos=adrEmail.indexOf(".",atPos)
	if (periodPos==-1) {
		return false
	}
	if (periodPos+3>adrEmail.length) {
		return false
	}
	return true
}

function codeTouche(evenement)
{
	for (prop in evenement)
	{
		if(prop == 'which') return(evenement.which);
	}
	return(evenement.keyCode);
}
function scanTouche_chiffre(evenement)
{
	var reCarValides=/[\d]/;
	var codeDecimal=codeTouche(evenement);
	var car=String.fromCharCode(codeDecimal);
	var autorisation=reCarValides.test(car);
	return autorisation;
}

function confirmationNews(titre, date, id)
{
	if (confirm("Etes vous certain de vouloir supprimer la news intitulée '"+titre +"' du " + date + " de la base de données du site ?")) {
		window.location.replace("index.php?rubrique=admin&action=kill_news&supprimer_news=" + id)
	}
}

function confirmationActu(titre, date, id)
{
	if (confirm("Etes vous certain de vouloir supprimer l'actu intitulée '"+titre +"' du " + date + " de la base de données du site ?")) {
		window.location.replace("index.php?rubrique=admin&action=kill_actu&supprimer_actu=" + id)
	}
}

function titreMaj(contenu) {
	var m=contenu.charAt(0).toUpperCase();
	var n=contenu.substring(1,contenu.length);
	var mn=m+n;
	return mn;
}

function showIFrame(page) {
	//document.getElementById("module").data=page;
	//ancien=document.getElementById("module"); 
	//nouveau=ancien.cloneNode(true);
	//nouveau.data=page;
	//ancien.parentNode.replaceChild(nouveau,ancien); 
	window.location.replace(page);
}

function changeCase(frmObj) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	tmpStr = frmObj.value.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0)
	{
		for (index = 0; index < strLen; index++)
		{
			if (index == 0)
			{
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			}
			else
			{
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1))
			{
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
	frmObj.value = tmpStr;
}

function confirmationFaq(date, id, sujet,page)
{
	if (confirm("Etes vous certain de vouloir supprimer le message du " + date + " de la base de données du site ?")) {
		window.location.replace("index.php?rubrique=faq&kill="+id+"&sujet="+sujet+"&action=null&page="+page)
	}
}

function confirmationMailing(nom, prenom, id)
{
	if (confirm("Etes vous certain de vouloir supprimer "+ prenom + " " + nom + " de la liste des inscrits à la mailing list du site ?")) {
		window.location.replace("index.php?rubrique=admin&action=mailing&supprimer_mailing=" + id)
	}
}

function verifUp() {
	var hDebut=document.entree_agenda.selectH_debut.selectedIndex;
	var hFin=document.entree_agenda.selectH_fin.selectedIndex;
	if (hDebut>hFin) {
		alert("L'heure de fin doit être au moins égale à "+document.entree_agenda.selectH_debut[hDebut].value);
		document.entree_agenda.selectH_fin.selectedIndex=hDebut-1;
		return false;
	}
	document.entree_agenda.notes.focus();
}

function afficheMasque() {
	var nb = document.entree_agenda.selectH_debut.selectedIndex;
	document.getElementById('h_fin').style.display = 'block';
	document.forms["entree_agenda"].selectH_fin.selectedIndex=nb-1;
	document.entree_agenda.notes.focus();
}

function verifEntrees() {
	if (document.entree_agenda.selectH_debut.selectedIndex!=0) {
	if (verifDate=document.entree_agenda.hidden_timestamp.value) {
	if (verifNote=document.entree_agenda.notes.value) {
	return true; } else { alert("Aucun événement n'est enregistré."); document.entree_agenda.notes.focus(); return false; } } else { alert("Veuillez renseigner une date d'événement."); document.entree_agenda.hidden_timestamp.focus(); return false; } } else { alert("Veuillez renseigner une heure de début d'événement."); document.entree_agenda.selectH_debut.focus(); return false; }
}

function retourTimestamp(valeur, Mvaleur) {
	document.getElementsByName('selectD_date')[0].value=Mvaleur;
	document.getElementsByName('hidden_timestamp')[0].value=valeur;
}

function confirmationIntrusion()
{
  if (confirm("Etes vous certain de vouloir supprimer la trace de l'ensemble des intrusions ?")) { window.location.replace("index.php?rubrique=admin&action=intrusion&del_all_intrusion") }
}

function confirmationLogin()
{
  if (confirm("Etes vous certain de vouloir supprimer la trace de l'ensemble des tentatives de login ?")) { window.location.replace("index.php?rubrique=admin&action=intrusion&del_all_login") }
}
function seeDoc(id) {
  //alert(id);
  for (i=1; i<4; i++) {
    oId = 'id' + i;
    //alert(oId);
    document.getElementById(oId).className = "hidden";    
  }
  //alert(id);
  document.getElementById(id).className = "visible";
}