// Ouvrir une fenêtre pop-up
function openWin(str_url, str_name, str_options)
{
	focus();
	win = window.open(str_url, str_name, str_options);
	win.focus();
} // END FUNC

// Rediriger vers une autre page au bout de X secondes
function delayRedirect(str_url, int_seconds)
{
	window.setTimeout('location=("' + str_url + '");', int_seconds * 1000);
} // END FUNC

/* Afficher/masquer la couche DIV indiquée ou inverser l'état des couches (nommées <préfixe><numéro>)
*
* @param string str_layer : ID de la couche (pour "swap", préfixe des couches)
* @param string str_action : "show" (afficher), "hide" (masquer), "toggle" (alterner), "swap" (inverser l'état des couches)
* @param string str_options : pour "swap", numéro de la couche à afficher
*/
function showHideLayer(str_layer, str_action, str_options)
{
	if (str_action == 'swap') {
		var targetElement = document.getElementById(str_layer + str_options);
		if (targetElement.style.display == 'none') {
			i = 0;
			do {
				i++;
				var targetElement = document.getElementById(str_layer + i);
				if (targetElement == null) {
					// rien
				} else if (str_options == i) {
					targetElement.style.display = '';
				} else {
					targetElement.style.display = 'none';
				} // END IF
			} while (targetElement != null);
		} // END IF

	} else {
		var targetElement = document.getElementById(str_layer);
		if (targetElement.style.display == 'none' || str_action == 'show' || str_action == 'toggle') {
			targetElement.style.display = '';
		} else if (targetElement.style.display == '' || str_action == 'hide' || str_action == 'toggle') {
			targetElement.style.display = 'none';
		} // END IF
	} // END IF
} // END FUNC

// Générer un lien e-mail non exploitable par les extracteurs d'adresses
function noSpam(str_email, str_label, str_options)
{
	if (str_label == "") {
		str_label = str_email;
	} // END IF
	str_email = str_email.replace('NOSPAMAT', '@');
	str_label = str_label.replace('NOSPAMAT', '@');

	while (str_email.indexOf('NOSPAMDOT') > 0) {
		str_email = str_email.replace('NOSPAMDOT', '.');
	} // END WHILE
	while (str_label.indexOf('NOSPAMDOT') > 0) {
		str_label = str_label.replace('NOSPAMDOT', '.');
	} // END WHILE
	document.write('<a href="mailto:' + str_email + '" ' + str_options + '>' + str_label + '</a>');
} // END FUNC

// Ajouter l'URL indiquée dans les signets
function addBookmark(str_pageurl, str_pagename)
{
	if (confirm("Ajouter la page\n\"" + str_pagename + "\"\ndans vos Signets ou Favoris ?")) {
		message = "";

		// Konqueror (à tester en 1er car Konqueror répond aussi TRUE aux autres tests...)
		if (navigator.userAgent.indexOf('Konqueror') >= 0) {
			message = "<Ctrl + B>";
		// Internet Explorer 4+ et dérivés (Crazy Browser, Avent Browser, etc.)
		} else if (window.external) {
			window.external.AddFavorite(str_pageurl, str_pagename);
		// Internet Explorer Mac
		} else if (document.all && (navigator.userAgent.indexOf('Win') < 0)) {
			message = "<Pomme + D>";
		// Opera 6+
		} else if (window.opera && window.print) {
			message = "<Ctrl + T>";
		// Netscape 6+, Mozilla, FireFox et dérivés (K-Meleon, etc.)
		} else if (window.sidebar) {
			window.sidebar.addPanel(str_pagename, str_pageurl, "");
		// Netscape 4
		} else if (document.layers) {
			message = "<Ctrl + D>";
		// INCONNU
		} else {
			message = "Cette fonction n'est pas disponible pour votre navigateur.";
		} // END IF

		if (message.charAt(0) == "<") {
			alert("Appuyez sur les touches " + message + "\npour l'ajouter manuellement.");
		} else if (message != "") {
			alert(message);
		} // END IF
	} // END IF
} // END FUNC

// Fonctions Macromedia (roll-overs, gestion de couches, ...)
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
} // END FUNC

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
} // END FUNC

function MM_findObj(n, d) { //v4.01
	var p,i,x;
	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
} // END FUNC

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
} // END FUNC

function MM_showHideLayers() { //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3)
		if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
			if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v='hide')?'none':v; }
			obj.display=v; }
} // END FUNC

function MM_reloadPage(init) { //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
} // END FUNC
//MM_reloadPage(true);
