	/* fonction utilisée par les petites annonces */
	function Image_Popup(Adresse)
	{
		if (document.all)
			var xMax = screen.width, yMax = screen.height;
		else
			if (document.layers)
				var xMax = window.outerWidth, yMax = window.outerHeight;
			else
				var xMax = 640, yMax=480;
				var xOffset = (xMax - 300)/2, yOffset = (yMax - 300)/2;
				window.open(Adresse,'windowbis','width=300,height=300,scrollbars=yes,resizable=yes,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
	}
	
	
	/* 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=no, scrollbars=yes, 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);
	}



	/* image */
	function getSizeImage(URLImage){
		image = new Image();
		URLImage = 'file:///' + URLImage;
		image.src = URLImage;
		
		width = image.width;
		height = image.height;
		
		if (width < mini_width) var mini_width = 200; else var mini_width = width;
		if (height < mini_height) var mini_height = 150; else var mini_height = height;
		
		rapport_width  = mini_width  / width;
		rapport_height = mini_height / height;
		if (rapport_width < rapport_height)
			mini_height = height / (width/mini_width);
		else
			mini_width  = width / (height/mini_height);

		document.formulaire.width.value = Math.round(mini_width);
		document.formulaire.height.value = Math.round(mini_height);	
	}




		function voir1(img){
			Fc=window.open("","Fc","resizable=1");
			Fc.document.write('<html><body><center>');
			nav=navigator.appName.substring(0,3);
			if((nav=="Net")||(nav=="Moz"))
				Fc.document.write('<img name="apercu" src="file:///'+ img.value +'">') ;
			else
				Fc.document.write('<img name="apercu" src="'+img.value+'">') ;
			Fc.document.write('<br/><input type="button" value="Fermer" onClick="parent.close()"><b>Nom et chemin de l\'image<br>'+img.value+'</b></td></tr></table></center></body></html>');
			Fc.document.close();
		}




	/************************ 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 submit_form(valeur, confirmation){
		if (confirmation == '1'){
			if(confirm('Etes vous sûr de vouloir supprimer définitivement ces photos ?')){
				document.form.action.value = valeur;
				document.form.submit();
			}
		}
		else {
			document.form.action.value = valeur;
			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;
	}

	




	/******************** TRANSFERT.PHP **************************/

	function preview(img){
		if(img.value != '' && navigator.appName != "Netscape")
			document.img_preview.src = "file://" + img.value;
	}

	function voir(img){
		Fc = window.open("","Fc","resizable=1");
		nav = navigator.appName.substring(0,3);
		if((nav=="Net")||(nav=="Moz"))
			Fc.document.write('<img name="apercu" src="file:///z:/album/pics/zoom.png">');
		else
			Fc.document.write('<img name="apercu" src="'+img.value+'" />');
		Fc.document.close();
	}




	/************************** DIAPORAMA.PHP ************************/
	var current = 0;
	
	// forward one image
	function next(){ 
		if (document.diaporama.slide[current+1]){
			document.images.show.src = document.diaporama.slide[current+1].value;
			document.diaporama.slide.selectedIndex = ++current;
		}
		else
			first();
	}
	
	// back on image
	function previous(){ 
		if ((current-1) >= 0){
			document.images.show.src = document.diaporama.slide[current-1].value;
			document.diaporama.slide.selectedIndex= --current;
		}
		else
			last();
	}
	
	// jump to first image
	function first(){ 
		current=0;
		document.images.show.src = document.diaporama.slide[0].value;
		document.diaporama.slide.selectedIndex=0;
	}
	
	// this is jump to last image
	function last(){
		current=(document.diaporama.slide.length-1);
		document.images.show.src = document.diaporama.slide[current].value;
		document.diaporama.slide.selectedIndex=current;
	}
	
	// this controls the auto-play and/or auto-stop
	function ap(text){
		document.diaporama.slidebutton.value=(text == "Stop") ? "Start" : "Stop";
		rotate();
	}
	
	// this is for the pulldown menu
	function change(){ 
		current=document.diaporama.slide.selectedIndex;
		document.images.show.src = document.diaporama.slide[current].value;
	}
	
	function rotate(){
		if (document.diaporama.slidebutton.value == "Stop") {
			current = (current == document.diaporama.slide.length-1) ? 0 : current+1;
			document.images.show.src = document.diaporama.slide[current].value;
			document.diaporama.slide.selectedIndex = current;
			window.setTimeout("rotate()", 5000);
		}
	}
	

	/************************ Java des fonctions message Ajouter et modifier *************************/
	
	function actions(text) {
						text = ' ' + text + '';
						if (document.post.message.createTextRange && document.post.message.caretPos) {
										var caretPos = document.post.message.caretPos;
										caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + '' : text;
										document.post.message.focus();
						} else {
						document.post.message.value  += text;
						document.post.message.focus();
						}
		}
/*		function url(text) {
		var autre = prompt("Inserez un lien Internet (URL).","http://");
						text = ' ' + text  + autre + '[/url]';
						if (document.post.message.createTextRange && document.post.message.caretPos) {
										var caretPos = document.post.message.caretPos;
										caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + '' : text;
										document.post.message.focus();
						} else {
						document.post.message.value  += text;
						document.post.message.focus();
						}
		}
*/		function url(text) {
		var autre = prompt("Inserez un lien Internet (URL).","http://");
						text = ' ' + text  + autre + ']>>Lien[/url]';
						if (document.post.message.createTextRange && document.post.message.caretPos) {
										var caretPos = document.post.message.caretPos;
										caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + '' : text;
										document.post.message.focus();
						} else {
						document.post.message.value  += text;
						document.post.message.focus();
						}
		}
		function img(text) {
		var autre = prompt("Inserez un lien Internet vers une image (URL).","http://");
						text = ' ' + text  + autre + '[/img]';
						if (document.post.message.createTextRange && document.post.message.caretPos) {
										var caretPos = document.post.message.caretPos;
										caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + '' : text;
										document.post.message.focus();
						} else {
						document.post.message.value  += text;
						document.post.message.focus();
						}
		}
		function email(text) {
		var autre = prompt("Inserez une adresse Email.","");
						text = ' ' + text  + autre + '[/email]';
						if (document.post.message.createTextRange && document.post.message.caretPos) {
										var caretPos = document.post.message.caretPos;
										caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + '' : text;
										document.post.message.focus();
						} else {
						document.post.message.value  += text;
						document.post.message.focus();
						}
		}
		function gras(text) {
		var autre = prompt("Inserez le texte a mettre en gras:","");
						text = ' ' + text  + autre + '[/b]';
						if (document.post.message.createTextRange && document.post.message.caretPos) {
										var caretPos = document.post.message.caretPos;
										caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + '' : text;
										document.post.message.focus();
						} else {
						document.post.message.value  += text;
						document.post.message.focus();
						}
		}
		function souligne(text) {
		var autre = prompt("Inserez le texte a souligner:","");
						text = ' ' + text  + autre + '[/u]';
						if (document.post.message.createTextRange && document.post.message.caretPos) {
										var caretPos = document.post.message.caretPos;
										caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + '' : text;
										document.post.message.focus();
						} else {
						document.post.message.value  += text;
						document.post.message.focus();
						}
		}
		function italique(text) {
		var autre = prompt("Inserez le texte a mettre en italique:","");
						text = ' ' + text  + autre + '[/i]';
						if (document.post.message.createTextRange && document.post.message.caretPos) {
										var caretPos = document.post.message.caretPos;
										caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + '' : text;
										document.post.message.focus();
						} else {
						document.post.message.value  += text;
						document.post.message.focus();
						}
		}
		
		