/* ///////// VERIF MAIL //////// */
function arobaceok(EMAIL) {
	var a=document.forms[0].mail.value;
	var test="" + a;
	for(var k = 0; k < test.length;k++) {
		var c = test.substring(k,k+1);		
		if(c == "@") {
			return true;
		}
	}
	alert("Veuillez précisez votre adresse email, merci");
	return false;
}

/* ///////// ONGLET HORAIRES //////// */
function ShowTimes(id_times, id_previous_li, id_text) {
	// variables div horaires : this and all divs 'all_horaires'
	var this_id_times = document.getElementById(id_times);	
	var div_all_horaires = document.getElementById('all_horaires').getElementsByTagName('div');
	// variables li previous onglet
	var this_id_previous_li = document.getElementById(id_previous_li);
	// variables div textes : this and all divs 'all_horaires'
	var this_id_text = document.getElementById(id_text);	
	var div_all_text = document.getElementById('all_text').getElementsByTagName('div');

	var li_all_onglet=document.getElementById('all_onglets').getElementsByTagName('li');
	//alert(div_all_onglet.length);
	var li_selected_class="onglet_nw_li_selected";
	var li_standard_class="onglet_nw_li";

	// hide all div in div 'all_horaires'
	for(i=0;i<div_all_horaires.length;i++) {
		var div_all_tab=div_all_horaires[i];
		div_all_tab.style.display = "none";
	}
	
	// hide all p in div 'all_text'
	for(i=0;i<div_all_text.length;i++) {
		var p_all_tab=div_all_text[i];
		p_all_tab.style.display = "none";
	}

	// cancel class for all <li>
	for(i=0;i<li_all_onglet.length;i++) {
 		var li_onglets=li_all_onglet[i];
 		li_onglets.className = li_standard_class;
 	}
	

	// show this div horaire
	this_id_times.style.display = "block";
	// show this p text
	this_id_text.style.display = "block";
	// add selected class to this li onglet	
	this_id_previous_li.className = li_selected_class;
	return false;
}
	
/* ////////////////////////////////////
FONCTIONS ADMIN
//////////////////////////////////// */

/* confirmer avant de supprimer */
function valid_suppr(){
	var reponse=confirm("Attention, si vous validez, vous supprimerez l'ensemble des informations de cette prestation, quelle que soit la saison. Pour supprimer certains éléments seulement, passer par la rubrique 'modifier'");
	if(reponse) {
		return true;
		} else {
		return false;
	}
}

/* Montre/cache les horaires */
function showtoggle(id_li) {
	var itm = document.getElementById(id_li);
	if(itm.style.display == "none") {
		itm.style.display = "block";
		} else {
		itm.style.display = "none";
	}
	return false;
}

/* controle largeur de l'image */
function control_largeur(idimg){
	var nameimg=document.getElementById(idimg);
	alert(nameimg);
}

/* contrôle accents et espace dans le nom d'une photo */
function controlimage(idimg){
	var nameimg=document.getElementById(idimg);
	var test=nameimg.value;
	var montest=test.substring(test.lastIndexOf("/"));

 	resultat = montest.match(/[ àáâãäåòóôõöøèéêëçìíîïùúûüÿñ]/gi); 
	if(resultat) {
		alert("Le titre de cette photo est incorrect");
		return false;
	} else {
		return true;
	}
}

/* //////////////////////////
SCRIPTS GALERIE
////////////////////////// */
var n=1;

// descriptif
function descript(desc){
	document.getElementById('description').innerHTML = desc
}

// bouton
function bouton(d,ndt) {
		var NbrImg = (ndt.length - 1);
        n = n + d;
        if (n < 1) {
        n = NbrImg;
        }
        if (n > NbrImg) {
        n = 1;
        }
		document.getElementById('vision').src = "images/" + ndt[n];
		document.getElementById('description').innerHTML =  description[n];
}