// all.js

function checkQte(id) {
	var qte = document.getElementById(id).value;
	var exp = new RegExp("^[0-9.]{1,99}$","g");
	
	if(qte != '') {
		if(exp.test(qte) == false) {
			alert('Valeur incorrecte');
			document.getElementById(id).value = '';
		}
	}
}

function switchArrow() {
	img = document.getElementById('fleche_menu_left').src.split('/');
	if(img[img.length-1] == 'fleche_bas.gif') {
		document.getElementById('fleche_menu_left').src = 'images/fleche_haut.gif';
	} else {
		document.getElementById('fleche_menu_left').src = 'images/fleche_bas.gif';
	}
}

function souris(event) {
	var x = event.clientX;
	var y = event.clientY;
	coords = new Array(x, y);
	
	return coords;
}

function changeEvent(id_event) {
	document.getElementById('img_event').src = 'images/accueil/bandeau_left_'+id_event+'.jpg';
	document.getElementById('link_event').href = id_event+'.html';
	
	for(i=0; i<=events.length; i++) {
		if(events[i] == id_event) {
			document.getElementById('menu_event_'+events[i]).className = 'li_menu_event_selected';
//			alert(events[i]+' IS selected');
		} else {
			document.getElementById('menu_event_'+events[i]).className = 'li_menu_event';
//			alert(events[i]+' NOT selected');
		}
	}
	return true;
}

function hide_sub() {
	lettres = new Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
	
	for(i=0; i<36; i++) {
		if(document.getElementById('sous_menu_'+lettres[i])) {
//			document.getElementById('sous_menu_'+lettres[i]).style.visibility = "hidden";
			document.getElementById('sous_menu_'+lettres[i]).style.display = "none";
		}
	}
}


function showpage(selection) { 
//	alert(selection);
	eval("document.location='"+selection.options[selection.selectedIndex].value+"'");
}


function popup(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=480,left = 312,top = 184');");
}


function popupcol(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=550,left = 312,top = 184');");
}


// PAGE CONTACT, CHAMPS PRESENTS ?
function champsContact() {
	
	champsRequis = new Array('nom','prenom','email','objet','message');
	err = 0;
	
	for(i=0; i<champsRequis.length; i++) {
		if(document.getElementById(champsRequis[i]).value == "") {
			document.getElementById(champsRequis[i]).style.backgroundColor = "#fcc";
			document.getElementById(champsRequis[i]).focus();
			err++;
		} else {
			document.getElementById(champsRequis[i]).style.backgroundColor = "#fff";
		}
	}
	
	if(err > 0) {
		alert("Veuillez remplir tous les champs obligatoires.");
		return false;
	}
	
	
	var verif 	= /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z.]{2,20}$/
	
	if(verif.exec(document.getElementById('email').value) == null) {
		err++;
	}
	
	if(err > 0) {
		alert('Adresse e-mail invalide.');
		document.getElementById('email').style.backgroundColor = '#fcc';
		return false;
	} else {
		return true;
	}

}


// PAGE FABRICATION ASIE, CHAMPS PRESENTS ?
function champsFabAsie() {
	
	champsRequis = new Array('objet','nom','prenom','email');
	err = 0;
	
	for(i=0; i<champsRequis.length; i++) {
		if(document.getElementById(champsRequis[i]).value == "") {
			document.getElementById(champsRequis[i]).style.backgroundColor = "#fcc";
			document.getElementById(champsRequis[i]).focus();
			err++;
		} else {
			document.getElementById(champsRequis[i]).style.backgroundColor = "#fff";
		}
	}
	
	if(err > 0) {
		alert("Veuillez remplir tous les champs obligatoires.");
		return false;
	}
	
	
	var verif 	= /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z.]{2,20}$/
	
	if(verif.exec(document.getElementById('email').value) == null) {
		err++;
	}
	
	if(err > 0) {
		alert('Adresse e-mail invalide.');
		document.getElementById('email').style.backgroundColor = '#fcc';
		return false;
	} else {
		return true;
	}

}



