function setMenuHover() {
	var menu = document.getElementById('header_menu');
	var links, nb, menu2;
	if (menu) {
		links = menu.getElementsByTagName('li');
		nb = links.length;
		for(cpt=0;cpt<nb;cpt++){
			if(links[cpt].className == "deplier"){
				links[cpt].onmouseover = function () {
					menu2 = this.getElementsByTagName('ul');
					for(cpt2=0;cpt2<menu2.length;cpt2++){
						menu2[cpt2].style.display = 'block';
					}
				}
				
				links[cpt].onmouseout = function () {
					menu2 = this.getElementsByTagName('ul');
					for(cpt2=0;cpt2<menu2.length;cpt2++){
						menu2[cpt2].style.display = 'none';
					}
				}
			}
		}
	}
}

function setVerification(){
	var form=document.getElementById('verification');	
	if (form){
		form.setAttribute("onSubmit","return setRequired()");
	}
}

function setRequired(){
	var input=document.getElementsByTagName('input');
	var textarea=document.getElementsByTagName('textarea');
	var selectform=document.getElementsByTagName('select');
	var nom="";
	for(cpt=0;cpt<input.length;cpt++){
		if (input[cpt].className=="required"){
			if (input[cpt].value==""){
				nom=input[cpt].name;
				alert("Veuillez remplir le champ '"+nom+"'");
				input[cpt].focus();
				return false;
			}
		}
	}
	for(cpt=0;cpt<textarea.length;cpt++){
		if (textarea[cpt].className=="required"){
			if (textarea[cpt].value==""){
				nom=textarea[cpt].name;
				alert("Veuillez remplir le champ '"+nom+"'");
				textarea[cpt].focus();
				return false;
			}
		}
	}
	for(cpt=0;cpt<selectform.length;cpt++){
		if (selectform[cpt].className=="required"){
			if (selectform[cpt].value==""){
				nom=selectform[cpt].name;
				alert("Veuillez remplir le champ '"+nom+"'");
				selectform[cpt].focus();
				return false;
			}
		}
	}
}

function changerApercu(nom){
	var img=document.getElementById("apercu");
	img.setAttribute('src','upload/galerie/'+nom);
}

window.onload = setMenuHover;
window.onload = setVerification;
