	function ajouter(data) {
		if (document.form.top1.value == '')	{
			document.form.top1.value = data;
			return true;
		}
		if (document.form.top2.value == '')	{
			document.form.top2.value = data;
			return true;
		}
		if (document.form.top3.value == '')	{
			document.form.top3.value = data;
			return true;
		}
		if (document.form.top4.value == '')	{
			document.form.top4.value = data;
			return true;
		}
		if (document.form.top5.value == '')	{
			document.form.top5.value = data;
			return true;
		}
	}


	function erreur_logiciel() {
		if(document.form.commentaire.value == "") {
			alert('Vous devez spécifier l\'erreur rencontrée pour nous aider à corriger le problème. Merci.');
			document.form.commentaire.focus();
			return false;
		}
		document.form.post.disabled=true;
		return true;
	}





	/* ouverture d'une page dans une popup */
	function popup(url, largeur, hauteur, decalage_h){
	
		var top = (screen.height-hauteur)/2;
		var left = (screen.width-largeur)/2 + decalage_h;
		
		//alert ('top' + top + ' - left' + left);
		window.open(url, 'popup', 'width=' + largeur + ', height=' + hauteur + ', top=' + top + ', left=' + left + ', resizable=yes, scrollbars=no, toolbar=0, location=0, directories=0, status=no, copyhistory=0, menuBar=0,');
	} 


	
	function confirmation(url, type){
		if (confirm('Etes vous sûr de vouloir supprimer définitivement '+ type + ' ?'))
			window.open(url);
	}





	/************************ FORMULAIRE **************************/

	/* verification du formulaire d'ajout d'article dans la gazette */
	function verif_form(){
		if (document.formulaire.idRub.value==""){
			alert("Vous n'avez pas spécifié de rubrique");
			document.formulaire.idRub.focus();
			return false;
		}
		if (document.formulaire.title.value==""){
			alert("Vous n'avez pas spécifié de titre");
			document.formulaire.title.focus();
			return false;
		}
		if (document.formulaire.author.value==""){
			alert("Vous n'avez pas spécifié d'auteur");
			document.formulaire.author.focus();
			return false;
		}
	document.formulaire.post.disabled=true;
	return true;
	}
	
	/* coche et décoche tout */
	function switchCheckAll(tous){
		for (i=0; i<document.form.elements.length; i++){
			if (document.form.elements[i].checked == tous)
				document.form.elements[i].checked = tous;
    	else 
				document.form.elements[i].checked = tous;
		}
	}


	/* insère un smiley */
	function insertAtCaret (icon1, icon2, onfocus){
		if (document.form.body.createTextRange && document.form.body.caretPos){
			var caretPos = document.form.body.caretPos;
			selectedtext = caretPos.text;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? icon1 + '' : icon1;
			caretPos.text = caretPos.text + selectedtext + icon2;
		}
		else
			document.form.body.value = document.form.body.value + icon1 + '' + icon2
		
		if (onfocus == 1)
			document.form.body.focus();
	}


	/* submit galerie */
	function confirmation(){
		if (confirm('Etes vous sûr de vouloir supprimer définitivement ces photos ?'))
			document.form.submit();
	}

	/**************************************************************/
	
	



	
	/***************** GENERATEUR DE MOT DE PASSE *****************/
	
	function getRandomNum(lbound, ubound){
		return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
	}

	function getRandomChar() {
		var characteres = "123456789abcdefghijklmnopqrstuvwxyz";
		return characteres.charAt(getRandomNum(0, characteres.length));
	}

	function getPassword() {
		var rc = "";
		for (var i = 0; i < 8; i++)
			rc = rc + getRandomChar();
		return rc;
	}

	




	/************************** MENU.JS ************************/
	/*
	function hover(obj){
		if(document.all){
			UL = obj.getElementsByTagName('ul');
			if(UL.length > 0){
				sousMenu = UL[0].style;
				if(sousMenu.display == 'none' || sousMenu.display == ''){
					sousMenu.display = 'block';
				}else{
					sousMenu.display = 'none';
				}
			}
		}
	}
	
	function setHover(){
		LI = document.getElementById('menu').getElementsByTagName('li');
		nLI = LI.length;
		for(i=0; i < nLI; i++){
			LI[i].onmouseover = function(){
				hover(this);
			}
			LI[i].onmouseout = function(){
				hover(this);
			}
		}
	}
	*/
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
			var liveSearchReq = false;
			var t = null;
			var liveSearchLast = "";
				
			var isIE = false;
			// on !IE we only have to initialize it once
			if (window.XMLHttpRequest) {
				liveSearchReq = new XMLHttpRequest();
			}
			
			function liveSearchInit() {
				
				if (navigator.userAgent.indexOf("Safari") > 0) {
					document.getElementById('livesearch').addEventListener("keydown",liveSearchKeyPress,false);
			//		document.getElementById('livesearch').addEventListener("blur",liveSearchHide,false);
				} else if (navigator.product == "Gecko") {
					
					document.getElementById('livesearch').addEventListener("keypress",liveSearchKeyPress,false);
					document.getElementById('livesearch').addEventListener("blur",liveSearchHideDelayed,false);
					
				} else {
					document.getElementById('livesearch').attachEvent('onkeydown',liveSearchKeyPress);
			//		document.getElementById('livesearch').attachEvent("onblur",liveSearchHide,false);
					isIE = true;
				}
				
				document.getElementById('livesearch').setAttribute("autocomplete","off");
			
			}
			
			function liveSearchHideDelayed() {
				window.setTimeout("liveSearchHide()",400);
			}
				
			function liveSearchHide() {
				document.getElementById("LSResult").style.display = "none";
				var highlight = document.getElementById("LSHighlight");
				if (highlight) {
					highlight.removeAttribute("id");
				}
			}
			
			function liveSearchKeyPress(event) {
				
				if (event.keyCode == 40 )
				//KEY DOWN
				{
					highlight = document.getElementById("LSHighlight");
					if (!highlight) {
						highlight = document.getElementById("LSShadow").firstChild.firstChild;
					} else {
						highlight.removeAttribute("id");
						highlight = highlight.nextSibling;
					}
					if (highlight) {
						highlight.setAttribute("id","LSHighlight");
					} 
					if (!isIE) { event.preventDefault(); }
				} 
				//KEY UP
				else if (event.keyCode == 38 ) {
					highlight = document.getElementById("LSHighlight");
					if (!highlight) {
						highlight = document.getElementById("LSResult").firstChild.firstChild.lastChild;
					} 
					else {
						highlight.removeAttribute("id");
						highlight = highlight.previousSibling;
					}
					if (highlight) {
							highlight.setAttribute("id","LSHighlight");
					}
					if (!isIE) { event.preventDefault(); }
				} 
				//ESC
				else if (event.keyCode == 27) {
					highlight = document.getElementById("LSHighlight");
					if (highlight) {
						highlight.removeAttribute("id");
					}
					document.getElementById("LSResult").style.display = "none";
				} 
			}
			function liveSearchStart(idTop) {
				if (t) {
					window.clearTimeout(t);
				}
				t = window.setTimeout("liveSearchDoSearch('"+idTop+"')",200);
			}
			
			function liveSearchDoSearch(idTop) {
				if (idTop == 'top1') { idTop_value = document.forms.form.top1.value; document.getElementById("LSShadow").style.top="22px"; }
				if (idTop == 'top2') { idTop_value = document.forms.form.top2.value; document.getElementById("LSShadow").style.top="44px"; }
				if (idTop == 'top3') { idTop_value = document.forms.form.top3.value; document.getElementById("LSShadow").style.top="66px"; }
				if (idTop == 'top4') { idTop_value = document.forms.form.top4.value; document.getElementById("LSShadow").style.top="88px"; }
				if (idTop == 'top5') { idTop_value = document.forms.form.top5.value; document.getElementById("LSShadow").style.top="110px"; }
				
				if (typeof liveSearchRoot == "undefined") {
					liveSearchRoot = "";
				}
				if (typeof liveSearchRootSubDir == "undefined") {
					liveSearchRootSubDir = "";
				}
				if (typeof liveSearchParams == "undefined") {
					liveSearchParams = "";
				}
				//if (liveSearchLast != idTop_value) {
				if (liveSearchReq && liveSearchReq.readyState < 4) {
					liveSearchReq.abort();
				}
				if ( idTop_value == "") {
					liveSearchHide();
					return false;
				}
				if (window.XMLHttpRequest) {
				// branch for IE/Windows ActiveX version
				} else if (window.ActiveXObject) {
					liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
				}
				liveSearchReq.onreadystatechange= liveSearchProcessReqChange;
				liveSearchReq.open("GET", liveSearchRoot + "/top-five/livesearch.php?idTop="+ idTop + "&q=" + idTop_value + liveSearchParams);
				liveSearchLast = idTop_value;
				liveSearchReq.send(null);
				//}
			}
			
			function liveSearchProcessReqChange() {
				
				if (liveSearchReq.readyState == 4) {
					var  res = document.getElementById("LSResult");
					res.style.display = "block";
					var  sh = document.getElementById("LSShadow");
					
					sh.innerHTML = liveSearchReq.responseText;
				}
			}
			
			function liveSearchSubmit() {
				var highlight = document.getElementById("LSHighlight");
				if (highlight && highlight.firstChild) {
					window.location = liveSearchRoot + liveSearchRootSubDir + highlight.firstChild.nextSibling.getAttribute("href");
					return false;
				} 
				else {
					return true;
				}
			}
