function addLoadEvent(func) {
	/*if (document.addEventListener) {
		document.addEventListener("DOMContentLoaded", func, false);
	}*/
	if (window.addEventListener) {
		window.addEventListener("load", func, false);
	}
	else if (document.addEventListener) {
		document.addEventListener("load", func, false);
	}
	else if (window.attachEvent) {
		window.attachEvent("onload", func);
	}
	else if (typeof window.onload != "function") {
		window.onload = func;
	}
	else {
		var oldonload = window.onload;
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
		func();
		};
	}
}

function ouvrir(page,fenetre,largeur,hauteur,options)
{
var top=(screen.height-hauteur)/2;
var left=(screen.width-largeur)/2;
ff=window.open(page,fenetre,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
ff.focus();
fenetre.title='nawak';
}

function open_ext_link() {
	if (document.getElementById && document.createTextNode) {
		var liens = document.getElementsByTagName('a');
		// On récupère tous les liens (<a>) du document dans une variable (un array), ici liens.
		// Une boucle qui parcourt le tableau (array) liens du début à la fin.
		for (var i = 0 ; i < liens.length ; ++i)  {
			// Si les liens ont un nom de class égal à lien_ext, alors on agit.
			if ( ((liens[i].className == 'lien_ext') || (liens[i].className == 'lien_ext_img')) || (liens[i].className == 'lien_ext_img_de') )  {
				liens[i].title = liens[i].title + ' (Nouvelle fenêtre)';
				if (liens[i].target == '_blank') {
					// Au clic de la souris.
					// inutile de prévoir un onkeypress voir : http://www.accessiweb.org/fr/uwem/notes.html#note_36
					liens[i].onclick = function() {
						window.open(this.href,this.target) //,"top=0,left=0,width="+screen.availWidth+",height="+screen.availHeight+",menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=no,directories=no,location=no");
						return false; // On ouvre une nouvelle page ayant pour URL le href du lien cliqué et on inhibe le lien réel.
					};
				}
				else {
					liens[i].h = 600;
					liens[i].l = 800;
					liens[i].top = Math.round((screen.availHeight-liens[i].h)/2);
					liens[i].left = Math.round((screen.availWidth-liens[i].l)/2);
					liens[i].onclick = function()  {
					window.open(this.href,this.target,"top="+this.top+",left="+this.left+",width="+this.l+",height="+this.h+",menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=no,directories=no,location=no");
					return false; // On ouvre une nouvelle page ayant pour URL le href du lien cliqué et on inhibe le lien réel.
					};
				}
			}
		}
	}
}

// Au chargement de la page, on appelle la fonction.
addLoadEvent(open_ext_link); 

//script de mise à jour email... (s'éxécute automatiquement
if (document.getElementById && document.createTextNode && {}.hasOwnProperty) {
(function(cns) {
	function init() {
		if (document.body && !init.done) {
			init.done = true;
			initSpans(getElsCN(cns.email, "span"));
		}
	}

	function initSpans(spans) {
		for (var i = 0, s; (s = spans[ i]); ++i) {
			initSpan(s);
		}
	}

	function initSpan(span) {
		var u, h, d, spans = span.getElementsByTagName("span"), str;
		for (var i = 0, s; (s = spans[ i]); ++i) {
			str = s.firstChild && s.firstChild.nodeValue;
			if (hasClass(s, cns.user)) {
				u = str;
			} else if (hasClass(s, cns.host)) {
				h = str;
			} else if (hasClass(s, cns.domain)) {
				d = str;
			}
		}
		if (u && h && d) {
			chgSpan(span, u, h, d);
		}
	}

	function chgSpan(span, u, h, d) {
		var email = u + "@" + h + "." + d;
		span.parentNode.replaceChild(createEl("a", {href: "mailto:" + email, className: cns.email}, email), span);
	}

	// DOM
	function createEl(n) {
		var a, i = 0, e = document.createElementNS ? document.createElementNS("http://www.w3.org/1999/xhtml", n) : document.createElement(n);
		while ((a = arguments[++i])) {
			if (typeof a === "string") {
				e.appendChild(document.createTextNode(a));
			} else {
				for (var p in a) {
					if (a.hasOwnProperty(p)) {
						e[p] = a[p];
					}
				}
			}
		}
		return e;
	}

	function hasClass(e, c) {
		return new RegExp("(^| )" + c + "( |$)").test(e.className);
	}

	function getElsCN(c, t) {
		var els = document.getElementsByTagName(t), res = [], re = new RegExp("(^| )" + c + "( |$)");
		for (var i = 0, e; (e = els[ i]); ++i) {
			if (re.test(e.className)) {
				res[res.length] = e;
			}
		}
		return res;
	}

addLoadEvent(init);
})({
	email: "email", user: "u", host: "h", domain: "d"
});
}
