/*function initsousMenu() {
	var firstnbre_ul = document.getElementById("firstnivo").getElementsByTagName("UL").length;
	if(firstnbre_ul){
		for (var f=0;f<firstnbre_ul;f++) {
			var entrees = document.getElementById("firstnivo").getElementsByTagName("UL")[f].getElementsByTagName("LI");
			if(entrees){
				for (var i=0;i<entrees.length;i++) {
					entrees[i].onmouseover = function () {
						if (this.className=="") { 
							this.className="over";
						}
						else {
							this.className+=" over";
						}
					}
					entrees[i].onmouseout = function () {
						this.className=this.className.replace(/(\s)*over/g, "");
					}
					
				}
			}
		}
	}
}

addEvent(window,"load",initsousMenu,false);*/
function montre(id,nbre_menus,apparence) {
	//alert (apparence);
	;
	var themenu = document.getElementById('menu_appli_arno');
	var thecontainer = document.getElementById('container');
	var el = document.getElementById('firstmenu'+id);
	if(el){	
		var d = document.getElementById('smenu'+id);
		var largeur_niveau1 = (el.offsetWidth-6);				
		
		for (var i = 0; i<=nbre_menus; i++) {
			if (document.getElementById('smenu'+i)) {
				document.getElementById('smenu'+i).style.display='none';
			/*	document.getElementById('smenu'+i).style.visibility='hidden';*/
			}
		}
		if (d) {			
		widthamax = 10;	
		//good_pos = (pos1+pos3);
		
		//good_pos = good_pos+'px';
		//alert(pos1+'\n'+pos2+'\n'+pos3+'\n'+pos4+'\n'+good_pos);
		//alert('position_left = '+position_left+'\n\n sousmenu pos  = '+d.offsetLeft+'\n\n themenu pos  = '+themenu.offsetLeft+'\n\n thecontainer pos  = '+thecontainer.offsetLeft);		
		//alert('position_left = '+position_left+'\n\nsousmenu pos  = '+d.scrollLeft+'\n\themenu pos  = '+themenu.scrollLeft);		
		if(apparence==0 || apparence==2){					
			pos1 = el.offsetLeft;
		pos2 = thecontainer.offsetLeft;
		pos3 = themenu.offsetLeft;
		good_pos = (pos1-pos3+pos2);
		var position_left =  (good_pos)+'px';
			d.style.position='absolute';
			d.style.left=position_left;
			//d.style.left=good_pos;
			widthamax = largeur_niveau1;				
		}

		d.style.display='block';

		longueur =	d.getElementsByTagName("li").length;
		themawidth = '';
		for(p=0;p<longueur;p++){
			mawidth = d.getElementsByTagName("li")[p].getElementsByTagName("a")[0].offsetWidth;
			
			//alert ('0 => '+mawidth);
			if(mawidth>widthamax){
				widthamax = mawidth;
			}	
		}
						

	goodwidth = (widthamax+2);

		d.style.width=goodwidth+'px';		

		if(apparence==1){			
				d.style.zIndex='100';
				d.style.left='112px';
				d.style.top=(el.offsetTop+3)+'px';
				el.className='testttt';		
			}		
		}		
	}
}
function hide_my_menu(nbre_menus,idMenu) {
	for (var i = 0; i<=nbre_menus; i++) {
		if (document.getElementById('smenu'+i)) {
			document.getElementById('smenu'+i).style.display='none';
		//	document.getElementById('smenu'+i).style.visibility='hidden';
		}
	}
	var el = document.getElementById('firstmenu'+idMenu);
	el.className='';
}


function hide_my_background(idMenu) {
	var el = document.getElementById('firstmenu'+idMenu);
	el.className='';
}

function check_formulaire_de_commentaire(ValideCommParMail)
	{
		theform = document.getElementById('laisser_commentaire_public');
		if(theform){
			
			thetexte = document.getElementById('text_comm');	
			thepseudo =document.getElementById('pseudo');
				if(thepseudo.value!=""){
					if(document.getElementById('watcher').checked || ValideCommParMail==1){	
						themail = document.getElementById('email');
						if(!email_valide(themail.value)){
							//alert(' pas valide');
							themail.focus();
							return;
						}
					}
					if(thetexte.value==""){
				   		alert('Vous devez écrire votre message.');
				   		thetexte.focus();
				   		return;
		   			}
		   		}
		   		else{
		   			alert('Vous devez écrire votre nom.');
		   			thepseudo.focus();
		   			return;
		   		}
			theform.action='home/commentaire.php';
			theform.submit();
		}
	}
	
	function add_commentaire(idcom,libpers){
		document.getElementById("idreponse").value = idcom;
		document.getElementById("libreponse").value = libpers;
		document.getElementById("comm_titre2").style.display='block';
		document.getElementById("comm_titre").style.display='none';
		document.getElementById("text_comm").focus();
		document.getElementById("pseudo").focus();
		return;

	}
	
function viewInputMail(theInput){
	theBouton = document.getElementById('watcher');
	if(theBouton.checked){
//		var myinput = document.createElement('input');
//		myinput.setAttribute('type', 'text');
//		myinput.setAttribute('id', 'email');
//		myinput.setAttribute('name', 'email');
//		myinput.setAttribute('value', '');
//		document.getElementById('spanWatcher').appendChild(myinput);
//		theInput.style.display = 'block';
		theBouton.value="1";
		
	}
	else{
		//theInput.style.display = 'none';
		theBouton.value="0";
		//document.getElementById('spanWatcher').removeChild(document.getElementById('email'));

	}
}




