﻿// JavaScript Document

function externalLinks()
{

	if (!document.getElementsByTagName)
		return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank";
			if (!anchor.className)
			    anchor.className = "external";
			anchor.innerHTML += "<span class=\"external\"> (Ce lien va ouvrir dans une nouvelle page)</span>";
		}
	}
}

function aOver(a)
{
	a.getElementsByTagName("img")[0].src = a.getElementsByTagName("img")[0].src.replace(/-a.gif/, "-a-on.gif");
}

function aOff(a)
{
	if (a.className != "selected")
		a.getElementsByTagName("img")[0].src = a.getElementsByTagName("img")[0].src.replace(/-a-on.gif/, "-a.gif");
}



function loadCSS(css_path)
{

	if(document.createStyleSheet) {
		document.createStyleSheet(css_path);
	} else {
		var newCSS=document.createElement('link');
		newCSS.rel ='stylesheet';
		newCSS.type ='text/css';
		newCSS.href = css_path;
		document.getElementsByTagName("head")[0].appendChild(newCSS);
	}
}

function initTailleCourante()
{
	tailleCourante = document.getElementById('small-a');
}

function changeGrosseurText(caller, combien)
{
	if (tailleCourante){
		document.body.style.fontSize = (combien/16) + "em";
		tailleCourante.getElementsByTagName("img")[0].src = tailleCourante.getElementsByTagName("img")[0].src.replace(/-a-on.gif/, "-a.gif");
		tailleCourante.className = "";
		tailleCourante = caller;
		tailleCourante.className = "selected";
		tailleCourante.getElementsByTagName("img")[0].src = tailleCourante.getElementsByTagName("img")[0].src.replace(/-a.gif/, "-a-on.gif");
	}
}

window.addEvent = function(e, fn){
	if(e.substr(0,2) == 'on') e = e.substr(2);
	if(window.addEventListener){
		window.addEventListener(e, fn, false);
	} else if(window.attachEvent){
		window.attachEvent('on'+e, function(){
			return fn.call(window, event);
		});
	}
}

window.addEvent("load", function(e){
    //externalLinks();
    initTailleCourante();
});