var IS_IE = document.all && window.print && !window.opera && ( !document.compatMode || /MSIE [56]/.test(navigator.userAgent) || (document.compatMode && document.compatMode=="BackCompat"));
var IE_NG = document.all && window.print && !window.opera && /MSIE [7-9]/.test(navigator.userAgent) && document.compatMode && document.compatMode!="BackCompat"; //variable pour IE7 et + si besoin.
var IS_quirks = IS_IE && document.compatMode && document.compatMode=="BackCompat"; // variable qui declare le quirksmode seulement utile pour IE
var heightPropertyToUse = IS_IE ? "height" : "minHeight"; //variable utilisee pour l'alignement en hauteur des elements.

var IS_Webkit = /Konqueror|Safari|KHTML/.test(navigator.userAgent);
var IS_MS = /MSIE /.test(navigator.userAgent);
document.documentElement.className =" hasJS" ;
document.documentElement.className+= IS_IE ? " IS_IE" : "";

/** *********************************************************************************************************
¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ HELPERS FUNCTIONS ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
*********************************************************************************************************  */

/** *********************************************************************************************************
	 REMPLACEMENT DES METHODES getElementById ET getElementsByTagName
	 EXEMPLES :
	var oEl = $('test');              // retourne l'objet ayant l'id 'test'
	var oEl2 = $(oEl);               // retourne oEl
	var aEls = $(oEl, 'a');         // retourne tous les liens de oEl
	var aEls2 = $('test', 'a');    // retourne tous les liens du conteneur ayant pour id 'test'
	var oEl3 = $(oEl, 'a')[0];    // retourne le premier lien de oEl
*/

// alert('debug');


var $ = {
	select: function() {
		var aArgs = arguments;
		if(aArgs.length > 1 && typeof aArgs[1] == 'string') {
			return typeof aArgs[0] == 'string' ?
				document.getElementById(aArgs[0]).getElementsByTagName(aArgs[1]):
				aArgs[0].getElementsByTagName(aArgs[1]);
		} else {
            switch (typeof aArgs[0]) {
                case 'string':
                    return document.getElementById(aArgs[0]);
                case 'object':
                    return aArgs[0];
            }
        }
		return false;
	}
};
$ = $.select;

/** *********************************************************************************************************
	 FONCTION D'EXTENTION DE PROPRIETES D'UN OBJET - Extrait de Mootools
	 EXEMPLES :
	$extend(myObj, {alerte: function(sMsg) { alert(sMsg); });      //  Ajout de la methode alerte a l'objet myObj
	$extend(myObj, anotherObj);                                             //  Ajout des methodes de l'objet anotherObj a l'objet myObj
*/

var $extend = {
	extend: function(){
		var args = arguments;
		if (!args[1]) {
            args = [this, args[0]];
        }
		for (var property in args[1]) {
            args[0][property] = args[1][property];
        }
		return args[0];
	}
};
$extend = $extend.extend;

/** *********************************************************************************************************
	OBJET DE GESTION DE CLASSE - INSPIRE DE http://www.onlinetools.org/articles/unobtrusivejavascript/cssjsseparation.html
	EXEMPLES :
	$c.add(oEl, 'test');                    //  Ajout d'une classe a l'element oEl
	$c.has(oEl, 'test');                    //  Verification de l'existence de la classe 'test' sur l'element oEl via une chaine texte
	$c.has(oEl, /\btest\b/);             //  Verification de l'existence de la classe 'test' sur l'element oEl via une expression reguliere
	$c.swap(oEl, 'test', 'test2');      //  Modification de la classe 'test' de l'element oEl en classe 'test2' (ou inversement)
	$c.remove(oEl, 'test2');            //  Suppression de la classe 'test2' de l'element oEl
 */

var $c = {
	remove: function(oEl, sClass) {
		var rep = oEl.className.match(' ' + sClass) ? ' ' + sClass : sClass;
		oEl.className = oEl.className.replace(rep, '');
	},
	add: function(oEl, sClass) {
		if(!$c.has(oEl, sClass)) {
			oEl.className += oEl.className ? ' ' + sClass : sClass;
        }
    },
	swap: function(oEl, sClass1, sClass2) {
		oEl.className = !$c.has(oEl, sClass1) ?
			oEl.className.replace(sClass2, sClass1):
			oEl.className.replace(sClass1, sClass2);
	},
	has: function() {
		return typeof arguments[1] == 'string' ?
			new RegExp('\\b' + arguments[1] + '\\b').test(arguments[0].className):
			arguments[1].test(arguments[0].className);
	}
};

/** *********************************************************************************************************
	GESTIONNAIRE D'EVENEMENT
	EXEMPLES :
	$e.add('domready', alerte);                                                    // Lance le gestionnaire alerte au chargement de la page
	$e.add(oEl, 'click', alerte);                                                     // Ajoute le gestionnaire alerte au clic sur oEl en mode 'effervescence'
	$e.add(oEl, 'click', alerte, true);                                             // Ajoute le gestionnaire alerte au clic sur oEl en mode 'capture' (IE ne sait pas faire)
	$e.remove(oEl, 'click', alerte);                                               // Supprime le gestionnaire alerte au clic sur oEl
	$e.add(oEl, 'click', function(e) { $e.stop(e); });                        // Si oEl est un lien, $e.stop(e); stoppe la transmission de l'evenement et annule l'action normale du lien
	$e.add(oEl, 'click', function(e) { alert($e.getSrc(e)); });            // Retourne la source de l'evenement
	$e.add(oEl, 'mouseover', function(e) { alert($e.relSrc(e)); });    // Retourne l'element survole precedent le mouseover
	$e.add(oEl, 'mouseout', function(e) { alert($e.relSrc(e)); });     // Retourne l'element survole suivant le mouseout
*/

var $e = {
	// Ajout d'un gestionnaire d'evenement sur un element lors d'un evenement donne
	add: function() {
		var a = arguments;
		if(a[0] == 'domready') {
			return $e.domready(a[1]);
		}
		return document.addEventListener ?
			a[0].addEventListener(a[1], a[2], a[3] || false):
			a[0].attachEvent ?
				a[0].attachEvent('on' + a[1], function(e) { a[2].apply(a[0], arguments); }):
				false;
	},
	// Suppression d'un gestionnaire d'evenement sur un element pour un evenement donne
	remove: function(oElem, sEvType, fn, bCapture) {
		return document.addEventListener ?
			oElem.removeEventListener(sEvType, fn, bCapture || false):
			oElem.detachEvent ?
				oElem.detachEvent('on' + sEvType, function(e) { fn.apply(oElem, arguments); }):
				false;
	},
	// Annulation de la propagation d'un evenement et de l'action par defaut d'un element
	stop: function(e) {
		if(e && e.stopPropagation && e.preventDefault) {
			e.stopPropagation();
			e.preventDefault();
		}
		else if(e && window.event) {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		return false; // Indispensable pour Safari
	},
	// Retourne la source de l'evenement
	getSrc: function(e) {
		return e.target || e.srcElement;
	},
	relSrc: function(e) {
		switch(e.type) {
			case 'mouseover': // Retourne l'element survole precedent l'element source de l'evenement
				return e.relatedTarget(e) || e.fromElement;
			case 'mouseout': // Retourne l'element survole suivant l'element source de l'evenement
				return e.relatedTarget(e) || e.toElement;
		}
	},
	// Detecte le chargement du DOM - http://dean.edwards.name/weblog/2006/06/again/#comment5338
	domready: function(fn) {
		// Internet Explorer
		if(window.attachEvent) {
			document.write('<script id="ieScriptLoad" defer src="//:"><\/script>');
			document.getElementById('ieScriptLoad').onreadystatechange = function() {
				if(this.readyState == 'complete'){
					$e.init(fn);
                }
            };
		}
		// Mozilla/Opera 9
		if(document.addEventListener) {
			document.addEventListener('DOMContentLoaded', function() { $e.init(fn); }, false);
        }
        // Safari
		if(navigator.userAgent.search(/WebKit/i) != -1){
			$e.loadTimer = setInterval(function (){
				if(document.readyState.search(/loaded|complete/i) != -1) {
					$e.init(fn);
                }
            }, 10);
		}
		// Other web browsers
		if($e) {
			$e.add(window, 'load', function() { $e.init(fn); });
        }
    },
	// Initialise le script
	init: function(fn) {
		if (arguments.callee.done) {return;}
		arguments.callee.done = true;
		if ($e.loadTimer) {clearInterval($e.loadTimer);}
			fn();
	}
};

/** *********************************************************************************************************
	GESTIONNAIRE DE STYLES
*/

var $s = {
	// Retourne la valeur d'une propriete CSS appliquee a un element
	get: function(oElm, rule) {
		var strValue = "";
        var strCssRule = rule;
        if(document.defaultView && document.defaultView.getComputedStyle) {
			try{
				strValue = document.defaultView.getComputedStyle(oElm, null).getPropertyValue(strCssRule);
			}
			catch(e) { strValue = ""; }
		}
		else if(oElm.currentStyle) {
			try{
				strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
					return p1.toUpperCase();
				});
				strValue = oElm.currentStyle[strCssRule];
			} catch(e) {
				strValue = "";
			}
		}
		return strValue;
	},
	// Retourne la valeur entiere d'un style
	integer: function(oElm, strCSSRule) {
		var val = parseInt($s.get(oElm, strCSSRule));
		if (isNaN(val)) {
            val = 0;
        }
		return val;
	},
	// Retourne la somme de tous les styles verticaux appliques (border-width+padding)
	getV: function(elm) {
		return IS_quirks ?
			0 :
			$s.integer(elm, "padding-top") +
			$s.integer(elm, "padding-bottom") +
			$s.integer(elm, "border-top-width") +
			$s.integer(elm, "border-bottom-width");
	},
	// Retourne la somme de tous les styles horizontaux appliques (border-width+padding)
	getH: function(elm) {
		return IS_quirks ?
			0 :
			$s.integer(elm, "padding-left") +
			$s.integer(elm, "padding-right");
	}
};

/*
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

// openclose
function swapContent(elm) {
	var par = getParent(elm, {className:/\bcontent(show|hide)/i});
	par.className.match(/contenthide/i) ? toggleClass(par, "contentHide", "contentShow") : toggleClass(par, "contentShow", "contentHide");
	fixColumns();
}
*/

//Toggle In Nav
function overLinkToggling(bloc){
	var toOpen = bloc.getElementsByTagName('div')[0];
	if (toOpen.className.match(/\bopened\b/)){
		toOpen.className = toOpen.className.replace(/\bopened\b/, '');
	}
	else {
		toOpen.className+=' opened';
	}
	bloc.blur();
}

/*******************************************************************************************************************************/
/** FIN DES MODIFS *********************************************************************************************************/
/*******************************************************************************************************************************/

/**********
* $n : objet de parcours du DOM, facile. Les fonctions ne font que les nodes HTML
***********/
var $n = {
	/* 	hasAttributes : retourne true si l'element passe en parametre correspond a tous les attributs passes, on peut aussi donner des attributs que l'on ne veut pas, afin de filtrer tous les elements
		ex : if (hasAttributes(div, {nodeName:"div", className:"foobar"), {className:"idontwant"} ) doStuff();
		ici on recherche tous les DIV qui on la classe "foobar", mais on ne prend pas ceux qui ont la classe "idontwant" ex : <div class="foobar idontwant"> ne sera pas recupere.
	*/
	hasAttr : function(n, a, not) {
		var re, at;
		if (n.nodeType!=1) {
            return false;
        }
		function check(attr) {
			for (var i in attr) {
				at = (typeof n[i]) !="undefined" ? n[i] : n.getAttribute(i);
				re = attr[i] instanceof RegExp ? attr[i] : new RegExp("\\b" + attr[i] + "\\b","i");
				if (!at || !re.test(at)) {
					return false;
                }
            }
			return true;
		}
		if (not && check(not))	{
            return false;
        }
		return check(a);
    },
	/* getByTagName : equivalent a element.getElementsByTagName, mais compatible avec IE5 et IE5.5 pour l'histoire du "*" */
	getByTagName : function(n, tag) {
		return  (tag=="*") ? (n.all ? n.all : n.getElementsByTagName("*")) : n.getElementsByTagName(tag);
	},
	/* fonction qui retourne le premier element correspondant aux attributs donnes */
	node : function(n, a, not) {
		return $n.nodes(n, a, not, true);
	},
	/* fonction qui retourne tous les elements correspondant selon "a" */
	nodes : function(n, a, not, oneNode, arrElms) {
		var aRetElms=[];
		if (!a) {
            a = {};
        }
		if (typeof a == "string") {//si une chaine de caracteres passee en parametre, cela signifie qu'on ne veut que recuperer des tags
        a = {nodeName:a};
        }
        if (a.nodeName && a.nodeName=="*") {
            delete a.nodeName;
        }
		var elms = arrElms || $n.getByTagName(n, (a.nodeName || "*"));
		for (var i=0; i<elms.length; i++) {
			var x = elms[i];
			if ($n.hasAttr(x, a, not)) {
				if (oneNode) {
                    return x;
                } else {
                    aRetElms.push(x);
                }
			}
		}
		if (oneNode) {
            return null;
        }
		return aRetElms;
	},
	/* childs : retourne tous les noeuds enfants de l'element  */
	childs : function(n, a, not) {
		return $n.nodes(n, a, not, false, n.childNodes);
	},
	firstChild : function(n, a, not) {
		return $n.nodes(n, a, not, true, n.childNodes);
	},
	lastChild : function(n, a, not) {
		var node = $n.nodes(n, a, not, false, n.childNodes);
		return node[node.length-1];
	},
	move : function(n, a, not, action) {
		while (n) {
			if ($n.hasAttr(n, a, not)) {
                return n;
            }
			n = n[action];
		}
		return null;
	},
	after : function(n, a, not) {
		return $n.move(n, a, not, "nextSibling");
	},
	before : function(n, a, not) {
		return $n.move(n, a, not, "previousSibling");
	},
	parent : function(n, a, not) {
		return $n.move(n, a, not, "parentNode");
	}
};
/* fonctions raccourcis */
var getNode = $n.node,
	getNodes = $n.nodes,
	getChildNodes = $n.childs,
	getNextSibling = $n.after,
	getPreviousSibling = $n.before,
	getParent = $n.parent,
	hasAttributes = $n.hasAttr,
	getElementsByTagName = $n.getByTagName;




/******
*  IE fixes
******/
var CSSBottomCorners = [], currentBlockToFixCorners, CSSHeightCorners = [];
function cssRight(elm) {
	if (elm.currentStyle.right != "auto") {
		elm.style.right = (parseInt(elm.currentStyle.right)-(elm.parentNode.offsetWidth % 2)) + "px";
	} else {
		elm.style.right = "auto";
	}
}
function cssBottom(elm, pushElement) {
	if (pushElement && !elm.CSSBottomAlreadyCSS) {
		CSSBottomCorners.push(elm);
		elm.CSSBottomAlreadyCSS = true;
	}
	if (elm.currentStyle.bottom != "auto") {
		elm.style.bottom = (parseInt(elm.currentStyle.bottom)-(elm.parentNode.offsetHeight % 2)) + "px";
	} else {
		elm.style.bottom = "auto";
	}
}
function fixCorners(block) {
	if (IS_IE) {
		if (block) {
			var corners = $n.nodes(block, {nodeName:'span', className:'(bl|br|tr)'});
			for (var i = CSSBottomCorners.length - 1; i > -1; --i) {
				CSSBottomCorners[i].style.bottom = "";
				CSSBottomCorners[i].style.right = "";
			}
		} else {
			for (var j = CSSBottomCorners.length - 1; j > -1; --j) {
				CSSBottomCorners[j].style.bottom = "";
			}
		}
	} else {
		if (IS_Webkit || /Gecko\/200[56]|Opera 8.5/i.test(navigator.userAgent) || IE_NG || IS_MS) {
			fixCornersOnBlocks(block);
		}
	}
}
function fixCornersOnBlocks(block) {
	var blockToFix = block || document.body;
	blockToFix.className += " hideCorners";
	setTimeout(function() {
		if (blockToFix) {
			blockToFix.className = blockToFix.className.replace(/\bhidecorners\b/gi, "");
        }
    }, 2);
}
function cssHeight(elm, pushElement) {
	if (pushElement && !elm.CSSHeightAlreadyCSS) {
		CSSHeightCorners.push(elm);
		elm.CSSHeightAlreadyCSS = true;
	}
	elm.style.height = elm.parentNode.offsetHeight + "px";
}

function fixHeights(block) {
	if (IS_IE) {
		var array = block ? $n.nodes(block, {nodeName:"span", className:"tr|bl"}) : CSSHeightCorners;
		array.eachInv(function(x) {
			x.style.height = "";
		});
	}
}
function fixAll(actions, element) {
	actions = actions ? actions.toLowerCase().split('') : ['c','h','p'];
	actions.each(function(action) {
		switch(action) {
			case 'c' : fixCorners(element); break;
			case 'h' : fixHeights(element); break;
			case 'p' : fixColumns(element); break;
		}
	});
}

function addHover(elm, iframeTag) {
	elm.style.behavior = " "; //reecriture du style behavior
	elm.hoverClassName = "hover";
	if (iframeTag) {
		elm.iframeElm = getNode(elm, iframeTag);
		alert(elm.iframeElm)
	}
	elm.onmouseenter = function() {
	   this.className+= ' ' + this.hoverClassName;
	   if (this.iframeElm) {
           ifrlayer.make(this.iframeElm);
       }
	};
	elm.onmouseleave = function() {
	   this.className = this.className.replace(new RegExp("\\b" + this.hoverClassName + "\\b", "g"), "");
	   if (this.iframeElm) {
           ifrlayer.hide(this.iframeElm);
       }
	};
}



function navAddHover(elm) {
	elm.style.behavior = " ";
	var ul = elm.getElementsByTagName("ul");
	if (ul.length > 0) {
		elm.theUl = ul[0];
		ifrlayer.make(elm.theUl);

		elm.onmouseenter = function() {
			this.className += ' hover';
			ifrlayer.make(elm.theUl);
		};

		elm.onmouseleave = function() {
			this.className = this.className.replace(/\bhover\b/, "");
			ifrlayer.hide(this.theUl);
		};
	}
}

var ifrlayer = {
	ie: IS_IE,
	$: function(obj) {
		if (!obj) {
            return null;
        }
		return (typeof(obj)=="string") ? document.getElementById(obj) : obj;
	},
	make: function(obj) {
		obj = this.$(obj);
		if(!obj) {
            return;
        }
		if(this.ie) {
			if (!obj.iframelayer) {
				var ifr = document.createElement('iframe');
				ifr.src = "javascript:false";
				obj.parentNode.insertBefore(ifr, obj);
				obj.iframelayer = ifr;
			}
			var ifr = obj.iframelayer;
			if(obj.currentStyle.zIndex != "" && parseInt(obj.currentStyle.zIndex) > 1) {
				ifr.style.zIndex = parseInt(obj.currentStyle.zIndex)-1;
			}
			with(ifr.style) {
				filter = "mask()";
				position = "absolute";
			}
			obj.iframelayer.style.visibility = "visible";
			ifrlayer.move(obj,true);
		}
	},
	hide: function(obj) {
		obj = this.$(obj);
		if(!obj) {
            return;
        }
		if(obj.iframelayer) {
			obj.iframelayer.style.visibility = "hidden";
		}
	},
	kill: function(obj) {
		obj = this.$(obj);
		if(!obj) {
            return;
        }
		if(obj.iframelayer) {
			obj.iframelayer.parentNode.removeChild(obj.iframelayer);
			obj.iframelayer = null;
		}
	},
	move: function(obj, size) {
		obj = this.$(obj);
		if(obj && obj.iframelayer) {
			with(obj.iframelayer.style) {
				top = obj.offsetTop + "px";
				left = obj.offsetLeft + "px";
				if(size) {
					width = obj.offsetWidth + "px";
					height = obj.offsetHeight +18+"px";
				}
			}
		}
	}
};


/********************
* Extensions d'objets
 ********************/
var extend = function (object, extender) {
	var props = extender || {}; // fail-safe
	for (var property in props) {
		object.prototype[property] = props[property];
    }
    return object;
};

Array.Utils = {
	each: function(f) {
		var i;
		for(i=0;i<this.length;i++) {
			f(this[i]);
		}
	},
	eachInv: function(f) {
		for(var i=this.length-1;i>=0;i--) {
			f(this[i]);
		}
	},
	last: function() {
		return this.length>0 ? this[this.length-1] : null;
	}
};
extend(Array, Array.Utils);

/******
* resizing d'objets
*******/
/* generates corners and others elements if needed */
function generateElements(parent, stringClasses) {
	var i, x;
	parent = (typeof parent == "string") ? document.getElementById(parent) : parent;
	var content = parent || document.body;
	var div = content.getElementsByTagName("div");

	//recupere un node avec la class blockInsideParDefaut
	function getIsd(node, className) {
	    return getNode(node, {className: (className || "blockInside")});
	}

	// fonction de creation d'un coin (b avec className)
	function nc(clN) {
		var b = document.createElement("span");
		b.className = clN;
		return b;
	}

	//ajoute un element ou une liste d'elements (c) sur l'element x
	function add(x, c) {
		if (!x) {
            return;
        }
		if(c.length) {
			for (var i = 0; i < c.length; i++) {
                x.appendChild(c[i].cloneNode(true));
            }
        } else {
			x.appendChild(c.cloneNode(true));
        }
    }

	//-- creation des elements qui seronts clones --
	var corners = [nc("tl"), nc("tr"), nc("bl"), nc("br")]; //corners
	var cornersTop = [nc("colTl"), nc("colTr")]; //corners
	var cornersBottom = [nc("colBl"), nc("colBr")]; //corners
	var bottomLeft = nc("bl"); //corners
	var bottomRight = nc("br"); //corners
	var shadow = nc("specialShadow"); add(shadow, [nc("lt"), nc("rt"), nc("trame")]); // specialShadow
	var overtl = nc("overtl"); // overtl : coin arrodis supplementaire pour les blocks avec des bordures speciales

	// -- creation des coins ou autres elements --
	// parcours des divs pour leur rajouter les corners
	// – creation des coins ou autres elements –
// parcours des divs pour leur rajouter les corners
	for (i = div.length - 1; i >= 0; i--) {
		x = div[i];
		if (!x.alreadyProcessed) {
			if (x.className.match(/blockSmallCorners/)){
				add(getIsd(x), cornersBottom);
			}
			else if (x.className.match(/\bblockBigCorners\b/)){
				//block par defaut
				add(getIsd(x), cornersBottom);
			}
			else if (x.className.match(/\bblock\b/)){
				//block par defaut
				add(getIsd(x), bottomLeft);
			}
			if (x.className.match(/blockInfo/)) {
				add(getIsd(x), bottomRight);
            }
            if (x.className.match(/blockSmallCorners/)){
				add(getIsd(x), bottomLeft);
            }
            if (x.className.match(/blockTransverse/)){
				add(getIsd(x), bottomRight);
            }
            if (x.id == 'leftCol' || x.id == 'rightCol' || x.id == 'mainInside'){
				add(x, cornersTop);
            }
            x.alreadyProcessed = true;
			initOtherBlocks(x); // fonction d'initialisation d'autres blocks
			if (x.className.indexOf("blockToggle")!=-1){
				toggleBlock.init(x);
            }
        }
	}
	var uls = document.getElementsByTagName('ul');
	for (i = uls.length-1; i >= 0; i--){
		initOtherBlocks(uls[i]);
    }
    fixColumns();
}

/* initOtherBlocks() : fonction rajoute d'autres fonctionnalites sur differents blocks  (toggle, onglets),
   Cette fonction est forcement lancee depuis generateElements, et cela evite de faire une deuxieme passe sur les divs de la page
 */
function initOtherBlocks(x) {
	// block a onglets
	if ($c.has(x, /\bblockTabs/)) { //block d'onglets en general (gere tous types d'onglets).
		tabs.init(x);
    }
    if ($c.has(x, 'line')) {//si ligne de block, on la stocke dans un tableau
		linesOfBlocks.push(x);
    }
}


function fixColumns() {
	function fix() {
		var colonnes = ['mainInside'];
		var colonnesInside = ['', ''];
		var hMax = minMax = sum = 0, i, b; hToU = heightPropertyToUse;

		function each(f) { //fonction d'iteration
			for (i = 0; i < colonnes.length; i++){
				b = $(colonnes[i]);
				f();
			}
		}

		// on remet la hauteur par defaut a toutes les colonnes (hauteur minimum)

		each(function() {
			var bToSize = $(colonnesInside[i]) || b;
			if (bToSize) {
                bToSize.style[hToU] = "5px";
            }
		});
		// on recupere la hauteur la plus grande
		/* hMax = $('body').offsetHeight; */

		// on applique la nouvelle hauteur sur les colonnes
		each(function() {
			var bIsd = $(colonnesInside[i]);
			if (b && b.scrollHeight>0) {
				if (bIsd) {
					var diff = (hMax - b.offsetHeight) + bIsd.clientHeight - $s.getV(bIsd);
					bIsd.style[hToU] = diff + 'px';
				} else {
					b.style[hToU] = hMax  - $s.getV(b) + 'px';
                }
            }
		});
	}
	//setTimeout(fix,1);
	fix();
}

/* ToggleBlock :  block qui s'ouvre et qui se ferme */
var toggleBlock = {
	init : function(elm) {
	    var head = getNode(elm, {className:"head"});
	    if(head.offsetHeight > 26) {
            head.className += " twoLines";
        }
	    if (head) {
            var a = getNode(head, {nodeName:"a"});
            if (a) {
                a.onclick = function() {
                    toggleBlock.toggle(this);
                    return false;
                };
            }
        }
	},
	// ajout les fonctionnalites du open/close (toggle);
	toggle : function(elm) {
		elm.blur();
		var scrollTop = document.body.scrollTop;
		var block = getParent(elm, {nodeName:"div", className:"blockToggle"});
	        toggleClass(block, 'toggleClosed');
		//fixColumns();
		document.body.scrollTop = scrollTop;
		document.body.style.zoom = 1;
	        setTimeout(function() {document.body.style.zoom=0;}, 1);
		setTimeout(fixCorners,2);
	}
};
//removeClass
function removeClass(element, className) {
	element.className = element.className.replace(new RegExp("\\b"+className+"\\b","g"),"");
}

//addClass
function addClass(element, className) {
	element.className += " " + className;
};

//toggleClass
function toggleClass(element, className) {
	if (element.className.match(className)) {
	    removeClass(element, className);
	} else {
	    addClass(element, className);
	}
}
/** *********************************************************************************************************

*/

var afterLoad = {
	functions : [],
	add : function(f) {
		this.functions.push(f);
	},
	start : function() {
		//console.log(this);
		this.functions.each(function(f) {
			f();
		});
	}
};

/*******
* Tabs
 *******/
var tabs = {
	init : function(elm) {
		var ul = $n.node(elm, {nodeName:"ul"});
		if (!ul) {
            return;
        }
		var a = ul.getElementsByTagName("a");
		for (var i=0; i<a.length; i++) {
			if (!$n.hasAttr(a[i], {className:"nochange"}))  {
				a[i].parentNode.onclick = function() {
					tabs.change(this);
					return false;
				};
				a[i].onclick = a[i].parentNode.onclick;
				$e.add(a[i], 'click', $e.stop);
			}
			//tabs.centerAlign(a[i], ul);
			tabs.sizeTab(a[i], ul);
		}
	        afterLoad.add(function() {tabs.sizeContents(elm);});
	        afterLoad.add(function() {fixCorners(elm);});
	},
	sizeTab : function(a, ul) {
		if ($c.has(ul, 'noresize')) {
            return;
        }
		if(a.offsetHeight > 40) a.parentNode.className += " twoLines";
		// var newSize =  a.offsetHeight + (ul.offsetHeight-a.offsetHeight) - $s.getV(a);
		// console.log(a, a.offsetHeight);
		// console.log(ul, ul.offsetHeight);
		// console.log(newSize);
		// console.log("-------------");
		
		//a.style[heightPropertyToUse] = (newSize<0) ? 0 : newSize + "px"; //IE doesn't compute size under 0
		//
	},
	sizeContents : function(block) {
		//console.info(block.className);
		if (block.className.match(/\b(noresize|blockTabs|blockTabsVertical)\b/)) {
            return;
        }
		var body = $n.node(block, {nodeName:"div", className:"body"});
		var tabsCtn = $n.childs(body, {nodeName:"div", className:"tabCtn"});
		var maxHeight = body.offsetHeight;
		tabsCtn.each(function(x) {
			x.style.display = 'block';
			if (x.offsetHeight > maxHeight) {
                maxHeight = x.offsetHeight;
            }
		});
		tabsCtn.each(function(x) {
			var tabBody = $n.node(x, {className:'tabBody'});
			tabBody.style[heightPropertyToUse] = tabBody.offsetHeight + (maxHeight - x.offsetHeight) - $s.getV(tabBody) + "px";
			x.style.display = '';
		});
	},
	change : function(elm) {
		var i, n, current=0,
		ul = $n.parent(elm, {nodeName:"ul", className:"tabs(Big|Sub)?"}),
		li = elm.nodeName.toLowerCase()=='LI' ? elm : $n.parent(elm, {nodeName:"li"}),
		tabs = ul.getElementsByTagName("li"),
		block = $n.parent(ul, {nodeName:"div", className:/\bblockTabs/i});

		for (i=0; i<tabs.length; i++) { // get the index of the new Tab and remove otherClass "current"
			if (tabs[i]==li) {
				current = i;
				$c.add(li, "current");
			} else {
                $c.remove(tabs[i], "current");
            }
		}
		//get the tabCtn blocks, and show the contentTab that is match with clicked tab
		var body = $n.node(block, {nodeName:"div", className:"body"});
		var tabCtns = $n.childs(body, {nodeName:"div", className:"tabCtn"});
		for (i=0; i<tabs.length; i++) {
			n = tabCtns[i];
			$c.remove(n, "tabCurrent");
			if (i==current) {
				if (block.className.match(/\bblockTabs/i) && !n.allImagesTransformed) {
					n.allImagesTransformed = true;
					//image replacement, this is good, if you don't want images are loaded on start of the page, the images are replaced by <span class="img" title="http://www.myimage.com/image.gif">alt content text here</span>
					var spans = $n.nodes(tabCtns[i], {nodeName:'span', className:'img'});
					spans.each(function(span) {
						if (span.getAttribute('title')) {
							var img = document.createElement('img');
							img.src = span.getAttribute('title');
							img.setAttribute('alt', span.innerHTML);
							img.className = span.className.replace(/(^|\s)img(?:\s|$)\b/,'$1');
							span.parentNode.replaceChild(img, span);
						}
					});
				}
				$c.add(n ,"tabCurrent");
				sizeBlocks(n);
				fixHeights(n);
			}
		}
		 fixCorners();
		 fixCorners(block);
		 fixColumns();
	},

	centerAlign: function (elm, ul){
		elm.style.paddingTop = (ul.offsetHeight-elm.offsetHeight)/2+"px";
	}
};


/**************
* sizeBlocks : alignement des blocks en hauteurs
**************/
var linesOfBlocks = [];
function sizeBlocks(parentBlock, smoothResize) { //smoothResize is a boolean for only resizing blocks that are alone in a unit beceause while loading if resize is made on a lot of blocks it's not good
	function size(block, size){
		if (size<=0) {
            return;
        }
		if (block){
			var body = block.className.match(/\bblock\b/) ? $n.node(block, {nodeName: "div", className: "body"}) : block; //si on a une line ou bien un block
			if (body) {
                body.style[heightPropertyToUse] = body.offsetHeight + size - $s.getV(body) + "px";
            }
		}
	}
	var arrayLines = linesOfBlocks;
	if (parentBlock) {
		arrayLines = $n.nodes(parentBlock, {nodeName: 'ul', className: "line"}, {nodeName: 'ul', className: "noresize"});
		arrayLines = arrayLines.concat($n.nodes(parentBlock, {nodeName: 'div', className: "line"}, {nodeName: 'div', className: "noresize"}));
	}
	arrayLines.eachInv(function (line) {
		var units = getChildNodes(line, {className: "unit"});
		units.each(function(unit) {
			//if(/dashed/.test(unit.className)) fixDashed(unit);
			var blocks = getChildNodes(unit, {className: "(block|line)"}, {className: "noresize"});
			unit.blocks = blocks;
			var sizeToApply = line.clientHeight-unit.clientHeight;
			var sizePerBlock = parseInt(sizeToApply/blocks.length);
			if (blocks.length > 1 &&  smoothResize) {
                return;
            }
			blocks.each(function(block) {
				size(block, sizePerBlock);
			});
			//sur une division on tombe parfois sur un calcul pas precis, on resize le dernier element d'un unit, afin que le calcul soit correct
			if (blocks.length > 1) {
                size(blocks.last(), line.clientHeight - unit.clientHeight);
            }
		});
	});
}
/******
* resize des contenus
******/
var contentsArray = [];
function contentAdd(ContainerAttr, childNodeAttr, numberPerLines) {
	contentsArray.push({container: ContainerAttr, child: childNodeAttr, number: numberPerLines});
}
function contentSize() {
	contentsArray.each(function(attr) {
		var containers = getNodes(document, attr.container);
		containers.each(function(container) {
			var childs = getNodes(container, attr.child);
			var lineBreak = attr.number;
			var maxH = 0, count = 1, lineArray = [];
			function sizeElements() {
				lineArray.each(function(line) {
					line.style[heightPropertyToUse] = maxH - $s.getV(line) + "px";
				});
				lineArray = [];
				count=0;
				maxH=0;
			}
			childs.each(function(child) {
				if (count==1){
					child.parentNode.style.clear="left";
				}
				if (child.offsetHeight>maxH) {
					maxH = child.offsetHeight;
				 }
				lineArray.push(child);
				if (count >= lineBreak) {
					sizeElements();
				}
				count++;
			});
			sizeElements();
		});
	});
}
contentAdd({nodeName: 'ul', className: 'list2cols '}, {nodeName: 'li', className: 'item'}, 2);
contentAdd({nodeName: 'ul', className: 'list3cols '}, {nodeName: 'li', className: 'item'}, 3);
/**
/
/ modif
/
**/
/**
/ renvoie le left et le top d'un elm
**/
function getLeft(MyObject){
	if (MyObject.offsetParent) {
        return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
    } else {
        return (MyObject.offsetLeft);
    }
	}
function getTop(MyObject){
	if (MyObject.offsetParent) {
	    return (MyObject.offsetTop + getTop(MyObject.offsetParent));
    } else {
	    return (MyObject.offsetTop);
    }
}

/**
/ array index of
**/
if (!Array.prototype.indexOf){
    Array.prototype.indexOf = function(elt /*, from*/) {
        var len = this.length;

        var from = Number(arguments[1]) || 0;
        from = (from < 0) ? Math.ceil(from): Math.floor(from);
        if (from < 0) {
            from += len;
        }
        for (; from < len; from++) {
            if (from in this && this[from] === elt) {
                return from;
            }
        }
        return -1;
    };
}
/**
/ accordion
**/
var clicker;
var myAccordion = {
	/*********************************************************
	*********** close : remove current
	*********** open : add current
	**********************************************************/

	init : function (id){
		if(!$('nav')) {return;}
		myAccordion.target = document.getElementById(id);
		myAccordion.uls = myAccordion.target.getElementsByTagName('ul');
		for(var i=myAccordion.uls.length-1;i>=0;i--){
			myAccordion.uls[i].style.display = "block";
			myAccordion.uls[i].style.overflow = "hidden";
		    myAccordion.uls[i].setAttribute("naturalHeight", myAccordion.uls[i].offsetHeight);
			myAccordion.uls[i].style.height = "0";
		}
		if (myAccordion.target.nodeName.toLowerCase() != "ul") {
            return;
        }
		myAccordion.btns = myAccordion.target.getElementsByTagName('a');
		myAccordion.btns2 = myAccordion.target.getElementsByTagName('span');
		myAccordion.width = myAccordion.target.offsetWidth;
		myAccordion.clicker;
		for(i=0;i<myAccordion.btns2.length;i++){
			myAccordion.btns2[i].onclick = function (){
				myAccordion.clicker = this;
				myAccordion.dispatch(this.nextSibling.nextSibling);

			};
		}
		this.fixIE();
	        setTimeout(function(){myAccordion.openCurrent();},5);
		//document.getElementById("leftCol").style.visibility = "visible";
		setTimeout(
			function (){
				document.getElementById("leftCol").style.visibility = "visible";
			},
			500
		);
	},

	dispatch : function (elm){
		var ul = elm.parentNode.getElementsByTagName('ul')[0];
		myAccordion.parent = getPN(ul, myAccordion.target);
		myAccordion.deployHeight = 0;
		if(elm.parentNode.className.match(/open/) && ul.offsetHeight != 0) {
			myAccordion.hideOne(ul);
			return;
		}
		myAccordion.hide();
		myAccordion.show(ul);
	},

	show : function (elm, elmOri){
		//elm.style.visibility = "visible";
		elm.open = true;
		var h = parseInt(elm.getAttribute('naturalHeight'));
		var hh = h + parseInt(myAccordion.deployHeight);
	        if(IS_MS) {
                myAccordion.makeTransitions(elm, {height:{start:elm.offsetHeight,end:hh,steps:3}}, true);
            } else {
                myAccordion.makeTransitions(elm, {height:{start:elm.offsetHeight,end:hh,steps:5}}, true);
            }
		myAccordion.deployHeight += h;
		$c.add(elm.parentNode, "open");
	        if(elm.parentNode && elm.parentNode.parentNode && elm.parentNode.parentNode != myAccordion.target) {myAccordion.show(elm.parentNode.parentNode);}
		//if (myAccordion.clicker.parentNode) {myAccordion.clicker.parentNode.style.height = getCSSRule(myAccordion.clicker.parentNode, 'height')-32+"px";}
	},


	hide : function (elm){ // ferme tous les ul
		for(var i=0;i<myAccordion.uls.length;i++){
			if(myAccordion.parent.indexOf(myAccordion.uls[i])==-1) {
		            myAccordion.makeTransitions(myAccordion.uls[i],{height:{start:myAccordion.uls[i].offsetHeight,end:0,steps:5}}, true);
			    $c.remove(myAccordion.uls[i].parentNode, "open");
			    myAccordion.uls[i].open = false;


			}
		}
	},

	hideOne : function(ul){
            log('hideOne');
	    myAccordion.makeTransitions(ul,{height:{start:ul.offsetHeight,end:0,steps:5}}, true);
		$c.remove(ul.parentNode, "open");
	    log(ul.parentNode.parentNode);
		if(ul.parentNode.parentNode) {
            ul.parentNode.parentNode.style.height = "auto";
        }
		if(ul.parentNode.parentNode.parentNode.parentNode) {
            ul.parentNode.parentNode.parentNode.parentNode.style.height = "auto";
        }
	},

	reinitNaturalHeight: function (){
		return;
		for(var i=myAccordion.uls.length-1;i>=0;i--){
			myAccordion.uls[i].style.overflow = "";
			myAccordion.uls[i].style.height = "auto";
		        myAccordion.uls[i].setAttribute("naturalHeight", myAccordion.uls[i].offsetHeight);
			myAccordion.uls[i].style.overflow = "hidden";
			myAccordion.uls[i].style.height = "0";
		}
	},

	fixIE : function (){
		if(!IS_MS) {
            return;
        }
		//alert('fixIE')
		var lis = myAccordion.target.getElementsByTagName("li");
		for(var i = 0; i<lis.length; i++){
			if(lis[i].getElementsByTagName('ul').length > 0 /*&& */){
				if(lis[i].parentNode != myAccordion.target) {
                    lis[i].style.marginBottom = -(lis[i].getElementsByTagName('ul').length * 3) + "px";
                } else {
                    if (lis[i].className.match(/open/)) {
                        lis[i].style.marginBottom = -(lis[i].getElementsByTagName('ul').length * 2.5) + "px";
                    } else {
                        lis[i].style.marginBottom = "-3px";
                    }
                }
			}
		}
	},

	makeTransitions : function (elm, transitions, callBack) {
		//console.log(elm);
		var height = transitions.height;
        var ferme = false;
        if (height.end ==  0) {
            ferme = true;
        }
		height.step = Math.ceil((height.end - height.start)/height.steps);
		elm.style.zoom = "1";
		function makeAction(transition, func) {
			if (transition && !transition.isFinished) {
				transition.current = transition.current==null ? transition.start : transition.current ;
				if (transition.step>0) {
                    transition.current = transition.current > transition.end ? transition.end : transition.current;
                } else {
                    transition.current = transition.current < transition.end ? transition.end : transition.current;
                }

				transition.isFinished = transition.current==transition.end;
				func(elm, transition.current);
				 //pour le saut suivant on incremente
				transition.current += transition.step;
			}
		}

		makeAction(height, function(element, value) {
			element.style.height = value + "px";
			});
		if (height.isFinished) {
			if (callBack) {
				// elm.style.padding  = "0";
				elm.style.zoom = "0";
				// elm.style.overflow = "hidden";
				// elm.style.height = height.end+"px";
				//fixIE();
			}
		} else {
			setTimeout(function() {
				myAccordion.makeTransitions(elm, transitions, callBack);
			},10);
		}
	},

	openCurrent: function (){
		var a = getNodes(myAccordion.target, {className:"current", nodeName:"a"});
		if(!a[0]) {
            return;
        }
		var span = (a[0].previousSibling && a[0].previousSibling.nodeType == 3) ? a[0].previousSibling.previousSibling : a[0].previousSibling ;
		if(span){
			span.className += " blackArrow";
		}
		var ul = a[0].parentNode.getElementsByTagName('ul')[0];
		myAccordion.deployHeight = 0;
		var u = ul || a[a.length-1].parentNode.parentNode;
		if (u && u != myAccordion.target) {
            myAccordion.show(u);
        }
	}
};

/***********************************************************************************************************
**************************************************************************************
***************************** myAnim  animate($('id'))
************************************************************************************/
var myAnim = {
	animate: function (elm, css, endValue, time, unit){
		// setting
		if(typeof(elm) == "string") {
            this.target = document.getElementById(elm);
        } else {
            if (typeof(elm) == "object") {
                this.target = elm;
            }
        }
		//
        if (!unit) {
            unit = "px";
        }
		if(css == 'opacity'){
		    this.fade(elm, endValue, time, unit);
		}

		var beginTime = new Date().getTime();

		var beginVal = getCSSRule(this.target, css);

		var debatment = endValue-beginVal;

		var step = debatment/(time*1000);

		// engine
		var TO = setInterval(function(){
			var currentTime = new Date().getTime();
			if(currentTime>=(beginTime+(time*1000))) {
				clearInterval(TO);
				setTimeout(function(){
					myAnim.target.style[css] = endValue+unit;
				}, 1);
				//console.log(getCSSRule(myAnim.target, css));
			}
			myAnim.target.style[css] = beginVal + ((currentTime-beginTime)*step)+unit;
		}, 1);
	},

	fadeIn : function (elm, css, endValue, time){
		// setting
		if(typeof(elm) == "string") {
            this.target = document.getElementById(elm);
        } else {
            if (typeof(elm) == "object") this.target = elm;
        }

		var beginTime = new Date().getTime();
		var beginVal = "0";
		var debatment = "1";
		var step = debatment/(time*1000);
		//console.log(step);
		var TO = setInterval(function(){
			var currentTime = new Date().getTime();
			if(currentTime>=(beginTime+(time*1000))) {
				clearInterval(TO);
				setTimeout(function(){
					if(!IS_MS) {
                        myAnim.target.style.opacity = "1";
                    } else {
                        myAnim.target.style.filter = "alpha(opacity=100)";
                    }
				}, 1);
			}
			if(!IS_MS) {
                myAnim.target.style.opacity = beginVal + ((currentTime - beginTime) * step);
            } else {
                myAnim.target.style.filter = "alpha(opacity=" + beginVal + ((currentTime - beginTime) * step) * 100 + ")";
            }
		}, 1);
	},

	fadeOut : function(elm, time){
		this.target = $(elm);
		var beginTime = new Date().getTime();
		var beginVal = "1";
		var debatment = "0";
		var step = debatment/(time*1000);
		//console.log(step);
		var TO = setInterval(function(){
			var currentTime = new Date().getTime();
			if(currentTime>=(beginTime+(time*1000))) {
				clearInterval(TO);
				setTimeout(function(){
					if(!IS_MS) {
                        myAnim.target.style.opacity = "0";
                    } else {
                        myAnim.target.style.filter = "alpha(opacity=0)";
                    }
				}, 1);
			}
			if(!IS_MS) {
                myAnim.target.style.opacity = beginVal + ((currentTime - beginTime) * step);
            } else {
                myAnim.target.style.filter = "alpha(opacity=" + beginVal + ((currentTime - beginTime) * step) * 100 + ")";
            }
		}, 1);
	}
};

/**
/ racocurci console.log
**/

function fixIE(){
	var a = $('nav').getElementsByTagName('ul');
	for(var i=0; i<a.length;i++){
		if(a[i].style.height == '0px') {
            a[i].style.display = "none";
        }
		else {
            a[i].style.zoom = "1";
        }

		//alert(a[i])
	}

}

function log(txt) {return;
	if(window.console && ! IS_MS && ! IS_IE) {
        return console.log(txt);
    }
}

function getCSSRule (cible, rule){
	// camelCase by Mootools
	if (rule.indexOf("-") != -1){
		var a = rule.split('-');
		rule = a[0]+ a[1].charAt(0).toUpperCase() +a[1].substr(1).toLowerCase();
	}
	//
	var CSSrule, cr;
	if(cible.currentStyle){
		cr = cible.currentStyle;
		return parseFloat(cr[rule]);
	}
	else {
		cr = window.getComputedStyle(cible, null);
		return parseFloat(cr[rule]);
	}
	if(rule.indexOf('color') != -1) {
		return RGB2Hexa(CSSrule);
	}

}

/**
/  transforme rgb(0,0,0) en #000000
**/
function RGB2Hexa(rgb){
// samori powered
	if(rgb.indexOf('rgb') != -1){
		rgb = rgb.substring(4);
		rgb = rgb.substring(0, rgb.length-1);
		var s = [];
		rgb = rgb.split(',');
		for (var x in rgb){
			if(parseInt(x)+1*2){ // si numeric
				var ind = parseInt(rgb[x]).toString(16);
			        if(ind<10){ind = "0"+ind;}
				s.push(ind);
			}
		}
		rgb = s.join("");
		rgb = "#"+rgb;

	}
	return rgb;
}
/**
/ renvoie true si NodeToTest est enfant de common
**/


function isChildrenOf (nodeToTest, common){
	while(nodeToTest) {
		if (nodeToTest==common){
			return true;}
		else {
			nodeToTest=nodeToTest.parentNode;}
	}
	return false;
}
//
function isBrother (tab1, tab2){
	var bool = false;
	toto:
	for(var i=0;i<tab1.length;i++){
		for(var j=0;j<tab2.length;j++){
			if(tab1[i]==tab2[j]){
				bool = true;
				break toto;
			}
		}
	}
	return bool;

}
// retourne un tableau de tous les parentNodes de elm enfant de limit
function getPN (elm, limit){
	var tab = [];
	while (elm && elm != limit){
		tab.push(elm);
		elm = elm.parentNode.parentNode;
	}
	return tab;
}
/*
* COOKIE by QUIRKSMODE
*/
function createCookie(name,value,days) {
    var expires;
    if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	} else { expires = ""; }
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') {
            c = c.substring(1, c.length);
        }
		if (c.indexOf(nameEQ) == 0) {
            return c.substring(nameEQ.length, c.length);
        }
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
/**/


function changeFontSize(k){
    //if($('espaceClient')) return;
	
	$(document.body).className = $(document.body).className.replace(/big|small|normal/, "");	
    if (k==null || k == "") {
        k = "small";
    }
	$(document.body).className += " "+k;
	createCookie('fontSize', k, 0);
	if($('nav')) {
        myAccordion.reinitNaturalHeight();
    }
	if($('backfond') && k=="small") {
        $('backfond').style.height = '193px';
    }
	if($('backfond') && k=="normal") {
        $('backfond').style.height = '226px';
    }
	if($('backfond') && k=="big") {
        $('backfond').style.height = '285px';
    }
	
	if($('rightCol')) {
		$('rightCol').style.height = "auto";
	}
	fixCorners();
	recalculatedColsHeight();
	fixRightColOnly()
}
/**
/ tooltip :
**/

var tooltip = {
	init: function (){
		tooltip.nodes = getNodes(document.body, {nodeName:"span", className:'tips'});
		if(!tooltip.nodes) {
            return;
        }
		// creation du tooltip
		var div = document.createElement('div');
		div.id = "tooltip";
		div.style.display = "block";
		div.style.opacity = "0";
		div.style.filter = "alpha(opacity=0)";
		var div2 = document.createElement('div');
		div2.id = "tooltipInner";
		var p = document.createElement('p');
		p.innerHTML = "<strong>Le crédit d’impôt</strong> est une dette que le Trésor a envers vous. Son avantage : si votre impôt est négatif, le Trésor vous rembourse la différence";
		var span = document.createElement('span');
		span.id = "tooltip-fleche";
		div2.appendChild(p);
		div.appendChild(div2);
		div.appendChild(span);
		document.body.appendChild(div);
		//
		tooltip.target = div;
		tooltip.btns = [];
		//
		for(var i=0;i<tooltip.nodes.length;i++){
		    $e.add(tooltip.nodes[i], 'mouseover', function(e){$e.stop(e);tooltip.initialize(e, $e.getSrc(e));});
		    $e.add(tooltip.nodes[i], 'mousemove', function(e){$e.stop(e);tooltip.animate(e, $e.getSrc(e));});
		    $e.add(tooltip.nodes[i], 'mouseout', function(e){$e.stop(e);tooltip.unanimate();});
		}


	},

	initialize : function (e, elm){
		document.getElementById("tooltipInner").innerHTML = "<p>"+getNode(elm, {nodeName:"span", className:"tooltipHide"}).innerHTML+"</p>";
		myAnim.fadeIn("tooltip", 0.5);
		//bytefx.fade(tooltip.target, 0, 100, 10);
		tooltip.target.style.left = e.clientX-69+"px";
		tooltip.target.style.top = getTop(elm)-tooltip.target.offsetHeight+"px";
	},

	animate : function (e, elm){
		tooltip.target.style.left = e.clientX-69+"px";
	},

	unanimate: function (){
		myAnim.fadeOut("tooltip", 0.5);
		//bytefx.fade(tooltip.target, 100, 0, 10);
	}
};
/**
/ fontLauncher : remplace le innerHTML de l'elm par un swf
**/

/**
objet permettant de remanier le DOM avant d'executer l'objet Font sur chaque elm de la cible
**/
var fontLauncher = {
	initialize: function (cible, marginTop){
		this.cible = cible;
		this.marginTop = marginTop;
		if(cible.getChildren().length == 0 ){
			new Font(cible, this.marginTop);
		}
		else {
			this.noMoreTextNode(cible);
		}
	},
	noMoreTextNode: function (cible){
		cible.tab = [];
		cible.childs = [];
		cible.nodes = cible.childNodes;
		var nodes = cible.nodes;
		//cible.initStyle = cible.getStyles('font-size','color', 'text-indent', 'font-weight', 'text-align', 'letter-spacing');
		for(var i=0;i<nodes.length;i++){
			//log(nodes[i].nodeName+" ==> "+nodes[i].nodeType+" ====> "+nodes[i].parentNode.id)
			if(nodes[i].length == 0 || nodes[i].nodeName == 'IMG' || nodes[i].nodeName == 'TABLE' || nodes[i].nodeName == 'SELECT' || nodes[i].nodeName == 'INPUT' || nodes[i].nodeName == 'EMBED' || nodes[i].nodeName == 'OBJECT'){
				//log("*********************************************************");
				//log(nodes[i].nodeName);
				//log("*********************************************************");
				return;
			}
			else if(nodes[i].nodeType == '3'){
				var spans = document.createElement("span");
				spans.innerHTML = nodes[i].nodeValue;
				//spans.setStyles(cible.initStyle);
				nodes[i].parentNode.replaceChild(spans, nodes[i]);
				new Font(nodes[i]);
			}
			else if (nodes[i].childNodes.length == 1 && nodes[i].childNodes[0].nodeType == '3' ){
					new Font(nodes[i]);
			}
			else if (!nodes[i].done && nodes[i].childNodes.length != 0){
				nodes[i].done = true;
				//this.noMoreTextNode(nodes[i]);
				cible.tab.push(nodes[i]);
			}
		}
		for(i=0;i<cible.tab.length;i++){
			this.noMoreTextNode(cible.tab[i]);
		}
	}
};
/**
classe du font
**/


var Font = {
	initialize: function (cible, marginTop){
		this.cible = cible;
	        if(!marginTop){this.marginTop = 0;}else{this.marginTop = marginTop;}
		this.fontIt();

	},
	fontIt: function(){
		var cible = this.cible;
	    if(!cible.id){cible.id = "elm_"+Math.round(Math.random()*100000);} //id obligatoire
		var fSize = cible.getStyle('fontSize');
		fSize = parseInt(fSize);
		var fColor = cible.getStyle('color');
		var fLetterSpace = cible.getStyle('letter-spacing');
		if(fLetterSpace == "normal"){fLetterSpace=0;}
		fLetterSpace = parseInt(fLetterSpace);
		var fAlign = cible.getStyle('textAlign');
		//
		var so = new SWFObject("myFont.swf", cible.id+"_", cible.offsetWidth, cible.offsetHeight, "7", "#000000");
		so.addParam("wmode", "transparent");
		so.addParam("AllowScriptAccess", "always");
		/** FlashVars **/
		// recuperation des valeurs CSS du champ de texte
		so.addVariable("FontSize", fSize);
		so.addVariable("FontColor", fColor);
		so.addVariable("elmHeight", parseInt(cible.offsetHeight));
		so.addVariable("elmWidth", parseInt(cible.offsetWidth));
		so.addVariable("letterSpace", fLetterSpace);
		so.addVariable("alignment", fAlign);
		// nb de px de margin du textfield correspond à un margin-top sur le textField
		so.addVariable("marginTop", this.marginTop);
		// recuperation du texte
		so.addVariable("Text", cible.innerHTML);
		// ecriture
		so.write(cible.id);
		//document[cible.id+"_"].style.display = 'block';
		}
	};




/**********
* Popup
**********/

function PopupCentrer(url, name, largeur, hauteur, options) {
	var top =(screen.height-hauteur)/2;
	var left =(screen.width-largeur)/2;

	window.open(url, name, "top=" + top + ", left=" + left + ", width=" + largeur + ", height=" + hauteur + ", " + options);
}


function openLink(mySelect){

	if(mySelect.selectedIndex == 0) {
		return;
	}
	var link = mySelect.value;
	if(link.match(/javascript/)){
		var link_splitted = link.split(',');
		var link_url = link_splitted[4].substring(1, link_splitted[4].indexOf(')') - 1);
		var link_no_url =  link.substring(link.indexOf('xt_med'), link.lastIndexOf(',')) + ')'
		var link_without_params = link.substring(link.indexOf('xt_med'));
		var popup_parameters = link.substring(11, link.indexOf('xt_med') - 1).split('#');
		if (popup_parameters[0] == '1'){
			if (popup_parameters[1] != '0' && popup_parameters[2] != '0'){
				eval(link_no_url);
				window.open(link_url, '', 'directories=no,menubar=no,status=no,location=no,scrollbars=no,resizable=no,height=' + popup_parameters[1] + ',width=' + popup_parameters[2] +',fullscreen=no');
			}else{
				var link_without_params_blank = link.substring(link.indexOf('xt_med'), link.lastIndexOf(')')) + ',\'1\')';
				eval(link_without_params_blank);
			}
		} else {
			eval(link_without_params);
		}
	}else if (link.match(/http/)){
		window.open(link);
	}
	else {
		document.location = link;
	}
}


/*
* Fonction de toggle sur la home html
*/

var homeActu = {
    init: function () {
        this.ul = document.getElementById("actuHome");
        this.as = this.ul.getElementsByTagName('a');
        this.ps = this.ul.getElementsByTagName('p');
        var _self = this;
        this.cur = this.as[0];
        function click(index) {
            return function() {
                homeActu.toggle(index);
            };
        }
        for (var i = 0; i < this.as.length; i++) {
            $e.add(this.as[i], "click", click(i));
        }
    },

    toggle: function (index) {
        var elm = this.as[index];
        var p = this.ps[index];
        this.cur.parentNode.className = "";
        elm.parentNode.className = "current";
        this.cur = elm;
    }
};


function fixRightCol (){
	if($('main') && $('nav') && $('main').offsetHeight < $('nav').offsetHeight){
		$('main').style.height = $('nav').offsetHeight + "px";
	}
	fixRightColOnly();
}

function fixRightColOnly() {
	// A little fix to ensure that the right col is still in the correct size after all the previous applied modifications
	if($('rightCol')) {
        $('rightCol').style.height = $('main').offsetHeight + 'px';
    }
}
/**
**
**/
/*	fixPng :
	@function 	: 	fixe les images de fond png 24 bits sous IE6 (pour la transparent alpha) ainsi que les tags <img>
    @desc 			: 	cette fonction est appelée par la CSS pour un élément qui a un PNG24Bits en background,
							Un élément (<i> dans notre cas) est généré et mis en position:absolute avec z-index:-1 et des largeur/hauteur de 32000px, celui-ci contiendra l'image en PNG.afin de gérer les élément extensible.
							Cette méthode a été utilisée afin de ne page avoir le bug ou certains contenus se retrouve désactivé (liens) lorsqu'on utilise le filter sur un élément.
							L'élément conteneur se verra appliqué un position:relative (si position de base est 'static') et un overflow:hidden afin de bien cacher le le dépassement de l'éménet qui contient l'image.
							Si on ne veut pas utiliser l'overflow:hidden ou on veut utiliser la methode 'crop' il est possible de passer des parametres à la fonction (cf @params)
							Fonctionne aussi avec les tag <img> on le nécessaire est faire pour remplacer l'image, sans la désactiver (cf @additional)
	@use				:   A utiliser dans la CSS, ex :
							.myclass{
								background:url('skin/nav/backgroundnav.png) no-repeat left top;
								filter:expression(pngFix(this));
							}
	@params		:	pngFix(element:HTMLElement, noOverflow:boolean, scale:boolean);
							- element : element HTML : passer  this dans la CSS.
							- noOverflow (true) :	par defaut on utilise un overflow:hidden, sur le parent conteneur, si cela, gêne,
																il suffit de passer la valeur true pour ce parametre, et automatiquement on utilisera un overflow:visible;
							- scale (true): 	par défaut la methode du filter est 'crop', ce qui est le comportement normal d'une image de background.
													Mais pour certaines raisons l'image a besoin de prendre tout le block , ex: une image de 1px répétée.
													Donc pour cela, la seule manière est d'utiliser la méthode 'scale' du imageAlphaLoader.
	@additional	: Gère aussi les tag <img> qui seront automatiquement transformés en image avec transparence PNG.
							En utilisant la méthode de base  (appel au filter), l'image est automatiquement gérée.
							Mais si on veut faire du cas par cas, il suffit de créer une classe CSS appelée pngFix, qui sera ensuite posée sur les tags <img>
								img.pngFix {filter:expression(pngFix(this));}
								<img src="img/myImage.png" class="pngFix" />
	@exemples	:
						- filter:expression(pngFix(this))  //==> mode normal, un layer contenant le png dans le fond, est mis sur l'élément avec comme avantage
																				de pouvoir utiliser une image très grande, et automatiquement,
																				le bloc peut etre extensible en largeur + hauteur.
						- filter:expression(pngFix(this, null, true))  //==> l'image prend toute la taille du bloc, ce qui est utile par exemple pour simuler un png répété sous les autres navigateurs
						- filter:expression(pngFix(this, true))  //==> on ne change que l'overflow par visible, ce qui du coup ne permet plus d'avoir un bloc extensible à 100% en largeur

	@TODO		:
						- Gérer les overflow:auto déclarés par défaut, et  caller automatiquement le layer indiquer cela dans une doc, qu'il faut obligatoirement un élément conteneur.
						- gérer les options en les mettant obligatoirement entre guillement, comme ça on pourra traiter facilement un dictionnaire de parametres type JSON.
						- gérer les background-position en utilisant le sizingMethod 'image '

*/function pngFix(elm, noOverflow) {
	elm.style.filter = ' ';
	if (!(document.all && window.print && /MSIE [56]/.test(navigator.userAgent))) return;
	var exec = (function(elm, noOverflow, scale) {
		return function() {
			
		
			var options = { noOverflow:noOverflow};
			var repeat = elm.currentStyle.backgroundRepeat.toLowerCase()=='repeat';
			elm.style.filter = ' ';
				// si l'élément est un tag img, on va en faire creer une balise qui encadrera cette image et ensuite traiter la balise comme si c'etait un élément qui avait une image de fond
				if (elm.nodeName.match(/^(IMG|INPUT)$/)) {
					if (!elm.src.match(/.*\.png$/)) return;
					
					elm.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod='image', src='"+ elm.src + "')";
					
					elm.width = elm.offsetWidth;
					elm.height = elm.offsetHeight;
					
					/* recuperation de l'url du pixel transparent */
					var url = elm.currentStyle.backgroundImage.match(/^url\(["'](.*\.gif)["']\)$/); //seulement les .png
					elm.src = url[1];
					elm.className = elm.className.replace(/pngFix/g,'');
					
				}
				else {
					if (elm.currentStyle.backgroundImage == "" || elm.currentStyle.backgroundImage == "url()") return;
					var url = elm.currentStyle.backgroundImage.match(/^url\(["'](.*\.png)["']\)$/); //seulement les .png
					if (!url || url.length<2) return;
					var pngLayer = document.createElement('i'); // on genere un <i> en position:absolute (layer), qui viendra se placer sous le contenu du div  qui avait besoin du style.
					with(pngLayer.style) {	
						if (options.noOverflow) {
							width = elm.offsetWidth + 'px';
							height = elm.offsetHeight + 'px';
						} else {
						 	width = '32000px';
							height = '32000px'; 
						}
						position = 'absolute';
						zIndex = -1;
						fontSize = '1%';
						filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod='" + (options.noOverflow ? 'crop' : 'image') + "', src='"+url[1]+"')";
						background = 'none'; //forcing car parfois il peut arriver qu'on ai une CSS qui vienne rajouter des images / couleurs de fond
						/* positionnement de l'image en fonction du background-position sur l'element */
						if (!repeat) {
							switch((elm.currentStyle.backgroundPositionX+'').toLowerCase()) {
								case 'left' : left=0; break; 
								case 'right' : right = 0; break;
								case 'center' : 
									left='50%'; 
									setTimeout(function(pngLayer) {
										return function() {
											pngLayer.style.marginLeft = -(pngLayer.offsetWidth/2)+'px'; 
										}
									}(pngLayer), 50);
									break;
								default : 
									left = elm.currentStyle.backgroundPositionX; 
							}

							switch((elm.currentStyle.backgroundPositionY+'').toLowerCase()) {
								case 'top' : top = 0; break;
								case 'bottom' : bottom = 0; break;
								case 'center' : 
									top='50%'; 
									setTimeout(function(pngLayer) {
										return function() {
											pngLayer.style.marginTop=-(pngLayer.offsetHeight/2)+'px'; 
										}
									}(pngLayer), 100);
									break;
								default : 
									top = elm.currentStyle.backgroundPositionY || 0; 
							}
						} else {
							left = 0; //elm.currentStyle.backgroundPositionX +'';
							top = 0; //elm.currentStyle.backgroundPositionY +'';
						}
					} 
					
						/* gestion automatique du sizingMethod='scale' ou sizingMethod='image', ne pouvant pas tester le backgroundRepeat correctement, on passe par une methode un peu plus tricky */
						setTimeout(function(elmN, pngLayerN, repeatN) {
							return function() {
								if (!elmN || elmN.parentNode || !pngLayerN || !pngLayerN.parentNode) return;
								if (pngLayerN.filters['DXImageTransform.Microsoft.AlphaImageLoader'].sizingMethod=='image') {
									if (pngLayerN.offsetWidth<elmN.offsetWidth && repeatN) {
										pngLayerN.filters['DXImageTransform.Microsoft.AlphaImageLoader'].sizingMethod='scale';
									} else if (pngLayerN.offsetWidth>elmN.offsetWidth && elm.currentStyle.backgroundPositionX.match(/^(left|0%|0px|0)$/) || elm.currentStyle.backgroundPositionY.match(/^(top|0%|0px|0)$/)){
										pngLayerN.filters['DXImageTransform.Microsoft.AlphaImageLoader'].sizingMethod='crop';
									}
								} else {
									pngLayerN.sizingMethod = 'image';
								}
								if (elm.currentStyle.width.match(/^(0|[12](%|px)?)$/)) {
									pngLayerN.filters['DXImageTransform.Microsoft.AlphaImageLoader'].sizingMethod='image';
								}
								if (pngLayerN.style.right != 'auto' && pngLayerN.style.right !='')
									setTimeout(function() {
										pngLayerN.style.right = parseInt(pngLayerN.style.right) - (elm.offsetWidth%2 ? 1 : 0) + 'px';
									}, 50)
							}
						}(elm, pngLayer, repeat), 200);
					
					with (elm.style) {
						position = elm.currentStyle.position=="static" || elm.currentStyle.position=="" ? 'relative' : position;
						if (elm.currentStyle.overflow!='auto' && elm.currentStyle.overflow!='hidden') overflow = options.noOverflow ? 'visible' : (elm.currentStyle.width.match(/^(0|[12](%|px)?)$/) ? 'visible' : 'hidden');
						backgroundImage = 'none';
					}
					elm.appendChild(pngLayer);
			
			}
		}
	})(elm, noOverflow);
	try{
		pngFixLoader.useOnload ? pngFixLoader.addFunc(exec) : exec();
	} catch(e) {};
}



/* pngFixLoader 
	@unction 		:	objet pour permet le lancement des modifications des png via pngFix en décalé sur le onload de la page.
							cela permet de contourner un bug d'internet explorer qui affiche un message d'erreur si le DOM est modifié pendant le chargement de la page.
*/
var pngFixLoader = {
	useOnload : true, // true : active l'execution du fixPng sur le load, et false, execute le fixPng dès qu'il est appelé par la CSS
	functions : [], // toutes les fonctions à éxécuter sur le onload de la page
	addFunc : function(func) {
		pngFixLoader.functions.push(func);
	},
	launch : function() {
			pngFixLoader.useOnload = false; //une fois la page chargée, il faut laisser s'executer automatiquement la fonction pour d'autres actions (ex : ouverture layer)
			var counter = 1;
			while(pngFixLoader.functions.length>0) {
				//setTimeout(pngFixLoader.functions.pop(), 20*counter);
				pngFixLoader.functions.pop()();
				counter++;
			}
	},
	init : function() {
		if (pngFixLoader.useOnload && window.attachEvent && document.all) {
			window.attachEvent('onload', function() {
				setTimeout(pngFixLoader.launch, 100);
			});
		}
	}
}
pngFixLoader.init();

function fixLayout(){
	if(!IS_IE) return;
	var ctn = document.getElementById('content');
	if(ctn && ctn.offsetHeight < 500) ctn.style.height = "500px";
	var imgs = document.getElementsByTagName('img');
	//return;
	for(var i=0;i<imgs.length;i++){
		if(imgs[i].src.match(/\.png/)) {
		imgs[i].style.backgroundImage = "url(/css/skin/px.gif)";
		pngFix(imgs[i]);
		}
	}
}

function capabilities(){
	   var img = new Image();
	   img.onload = function (oThis){
			return function (){
				oThis.gotIMG = true;
				document.documentElement.className += " hasIMG";
	   }}(this);
	   img.onerror = function (oThis){
			return function (){
				oThis.gotIMG = false;
				document.documentElement.className += " noIMG";
			}
	   }(this);
	   img.src = "/css/skin/px.gif?"+new Date().getTime();
		// SWF
		var gotSWF = false;
		if(navigator.mimeTypes.length > 0 ){
			gotSWF = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin != null;
		}
		else if( window.ActiveXObject ){
	       try {
	          new ActiveXObject( "ShockwaveFlash.ShockwaveFlash" );
	          gotSWF = true;
	       }
	       catch(oError){
	          gotSWF = false;
	       }
		}
	   else{
	       gotSWF = false;
	   }
	   if(gotSWF) document.documentElement.className += " hasSWF";
	   else document.documentElement.className += " noSWF";
	  
	   // CSS
		var div = document.createElement("div");
		div.style.width = "1000px";
		document.documentElement.appendChild(div);
		this.gotCSS = div.offsetWidth == 1000 ? true : false;
		div.parentNode.removeChild(div);
		if(this.gotCSS) document.documentElement.className += " hasCSS";
		else document.documentElement.className += " noCSS";
}



/** GESTION DE NAV VERTICALE **/

	var verticalNavigation = {
		init : function (id){
			//
			// todo id=elm
			this.NAV = document.getElementById(id);
			if(!this.NAV) return;
			this.NAV.style.visibility = "hidden";
			// 
			if(!this.NAV || this.NAV.nodeName != "UL") return;
			// 
			this.ULS = this.NAV.getElementsByTagName('ul');
			this.LIS = this.NAV.getElementsByTagName('li');
			//
			this.objs = [];
			this.branches = [];
			this.currentObj = false;
			//
			for(var i=this.ULS.length-1,j=0;i>=0;i--,j++){
				var obj = new verticalNavigationItem({elm:this.ULS[i], index:j});
				if(!this.currentObj && obj.checkCurrent()) this.currentObj=obj;
				this.objs.push(obj);			
			}
			for(var i=0;i<this.LIS.length;i++){
				this.LIS[i].style.zoom = "1";
			}
			
			this.buildParent();
			this.currentOpener(this.currentObj);
			this.NAV.style.visibility = "visible";
		},
		
		hideAll : function (obj){
			for(var i=0;i<this.objs.length;i++){
				if(this.objs[i].elm == obj.elm) continue;
				this.objs[i].toggle(false);
			}
		},
		
		currentOpener : function (obj){
			if(!obj) return;
			obj.quickOpen();
			var index = obj.elm.parentNode.parentNode.getAttribute('index');
			if(obj.elm.parentNode.parentNode != this.NAV) this.currentOpener(this.objs[index]);
			else return;
		},
		
		buildParent: function (){
			for(var i=0;i<this.objs.length;i++){
				this.objs[i].getParent(this.objs[i]);
				this.objs[i].parentObj.pop();
			}
		}
	};


	var verticalNavigationItem = function() { 
		this.initialize.apply(this, arguments);
	};
	verticalNavigationItem.prototype = {
		options : {},
		
		constructor : verticalNavigationItem,
		
		initialize : function(options) {
			if(!options.elm) return;
			//
			this.index = options.index;
			this.elm = options.elm;
			this.elm.setAttribute('index', this.index);
			//
			this.open = false;
			this.branch = this.options.branch;
			this.initHeight = this.elm.offsetHeight;
			//
			this.elm.style.height = "0px";
			this.elm.style.display = "none";
			this.elm.style.zoom = "1";
			this.elm.style.overflow = "hidden";
			this.elm.style.position = "relative";
			//
			this.elm.parentNode.style.position = "relative";
			this.elm.parentNode.style.zoom = "1";
			this.elm.parentNode.style.overflow = "hidden";
			//
			this.uls = this.elm.getElementsByTagName('ul');
			this.level = this.uls.length;
			//
			this.as = this.elm.parentNode.getElementsByTagName('a');
			this.a = this.as[0];
			this.a.style.zoom = "1";
			//
			this.quirksMode = /MSIE /.test(navigator.userAgent) && document.compatMode && document.compatMode=="BackCompat";
			//
			this.btns = this.elm.parentNode.getElementsByTagName('span');
			this.span = this.btns[0];
			if(this.span) {
				this.span.style.cursor = "pointer";
				this.span.onclick = function (obj){
					return function (){
						if(obj.elm.style.height == "0px") obj.open = false;
						obj.toggle(!obj.open)
					}
				}(this)
			}
			//
			this.a.onfocus = function (obj){
				return function (){
					obj.toggle(true)
				}
			}(this)
			//
			this.parentObj = [];
		},
		
		toggle: function (open){
			switch(open){
				case true:
					verticalNavigation.hideAll(this);
					this.unlockParent();
					this.animate(true, 0.3);
					break;
				case false:
					this.animate(false, 0.3);
					break;
			}
		},
		
		hideChild: function (){
			for(var i=0;i<this.uls.length;i++){
				this.uls[i].style.height = "0px";
				this.uls[i].style.display = "none";
			}
		},
		
		quickOpen: function (){
			if(this.TO) clearInterval(this.TO);
			this.elm.style.height = "auto";
			this.elm.style.display = "";
			this.open = true;
		},
		
		checkCurrent : function (){
			if(this.a.className.match(/current/))  return true;
			for(var i=0;i<this.as.length;i++){
				if(this.as[i].className.match(/current/)) return true;
			}
			return false;
		},
		
		/** time: parametre en seconde, duree de l'animation **/
		animate: function (open, time){
			var endValue = open == true ? this.initHeight : 0;
			if(open == this.open) return;
			//
			if(this.TO) clearInterval(this.TO);
			var beginTime = new Date().getTime();
			if(this.elm.style.display == "none") this.elm.style.height = "4px";
			var beginVal = this.elm.offsetHeight;
			var debatment = (endValue-beginVal);
			var step = debatment/(time*1000);
			var _self = this;
			this.elm.style.display = "block";
			// engine
			/**BUGWARE : commenter si besoin est**/
			setTimeout(function(){_self.elm.parentNode.style.marginBottom = '';}, 100)
			this.elm.parentNode.style.marginBottom = '-3px';
			this.elm.style.position = 'relative';
			//
			this.TO = setInterval(function(){
				var currentTime = new Date().getTime();
				var a = beginVal + ((currentTime-beginTime)*step) > 0 ? beginVal + ((currentTime-beginTime)*step) : 0;
				_self.elm.parentNode.style.zoom = "0";
				_self.elm.style.zoom = "1";
				_self.elm.style.height = a +"px";
				_self.elm.style.zoom = "0";
				_self.elm.parentNode.style.zoom = "1";
				if(currentTime>=(beginTime+(time*1000))) {
					_self.elm.style.height = endValue+"px";
					_self.hideChild();
					if(open) _self.elm.style.height = "auto";
					else _self.elm.style.display = "none";
					_self.elm.style.marginBottom = "";
					_self.elm.style.zoom = "1";
					
					_self.open = open;
					clearInterval(_self.TO);
				}
			}, 25);
			this.elm.style.display = "";
		},
		
		getParent : function (obj){
			if(!obj) return;
			var parUL = obj.elm.parentNode.parentNode;
			var index = parseInt(parUL.getAttribute('index'));
			this.parentObj.push(verticalNavigation.objs[index]);
			this.getParent(verticalNavigation.objs[index]);
		},
		
		unlockParent : function(){
			for(var i=0;i<this.parentObj.length;i++){
				this.parentObj[i].quickOpen();
			}
		},
		
		setOptions : function(options) {
			if (!options){return;}
			var savedOpt = this.options;
			this.options = {};
			for (var i in savedOpt) this.options[i] = savedOpt[i];
			for (var i in options) this.options[i] = options[i];
		}
		
	}


function imgPngTrans(a){
	return true;
}

// module div.dashedDiv resize hauteur

function fixDashed (unit){
	var cn = unit.parentNode.childNodes;
	var ln = 0;
	for(var i=0,l=cn.length;i<l;i++){
		var node = cn[i];
		if(node.nodeType != 3) ln++;
	}
	
	alert(ln);
	
	var line = unit.parentNode;
	line.className = line.className.replace(/Bspace/, "")
	
	for(var i = 0; i < ln-1; i++){
		var div = document.createElement('div');
		line.style.position = "relative";
		line.appendChild(div);
		div.className = "dashedDiv";
		div.style.height = line.offsetHeight + "px";
		
		switch(ln){
			case 1:
				div.style.height = 0;
				break;
			case 2:
				div.style.left = "49.5%";
				break;
			case 3:
				div.style.left = 30.5 * (i+1) + "%";
				break;
		}
	}
}






/**
  * SLIDERS MANAGEMENT - k64
  */


// Define Namespace

var F6 = window.F6 || {};


// Extend Array prototype with the filter method

if(typeof Array.prototype.filter === 'undefined') {

	Array.prototype.filter = function(fnBoolean) {
	
		var _aFiltered = [];
		for(var _iKey = 0, _iCount = this.length; _iKey < _iCount; _iKey++) {
			if(fnBoolean(this[_iKey], _iKey, this)) {
				_aFiltered.push(this[_iKey]);
			}
		}
		return _aFiltered;
	
	};

}


// Extend Array prototype with the forEach method

if(typeof Array.prototype.forEach === 'undefined') {

	Array.prototype.forEach = function(fn) {

		if(typeof fn !== "function") {
			throw new Error();
		}
		for(var _iKey = 0, _iCount = this.length; _iKey < _iCount; _iKey++) {
			typeof arguments[1] === 'object' ?
				fn.apply(arguments[1], [this[_iKey], _iKey, this]):
				fn(this[_iKey], _iKey, this);
		}
		return true;

	};

}


// Convert an object to table

F6.toArray = function() {

	if(!arguments[0].length) {
		return;
	}
	var _aArray = [];
	for(var _iItem = 0, _iCount = arguments[0].length; _iItem < _iCount; _iItem++) {
		_aArray[_iItem] = arguments[0][_iItem];
	}
	return _aArray;

};


// Constructor

F6.Sliders = function() {

	this.initialize.apply(this, arguments);

};


// Prototype

F6.Sliders.prototype = (function() {
	
	// Initialize a Slider block

	var _initSlider = function(oBlockSlider) {
		
		_setProperties(oBlockSlider);
		_initList(oBlockSlider);
		_addMethods(oBlockSlider);
		_addBehaviour(oBlockSlider);

	};
	
	
	// Define Slider block properties
	
	var _setProperties = function(oBlockSlider) {
	
		// console.log(oBlockSlider);
		oBlockSlider.previous = F6.toArray(oBlockSlider.getElementsByTagName('a')).filter(
			function(oNode) {

				return /\bprevious\b/.test(oNode.parentNode.className);

			}
		)[0];
		oBlockSlider.previous.blockSlider = oBlockSlider;
		oBlockSlider.slider = F6.toArray(oBlockSlider.getElementsByTagName('div')).filter(
			function(oNode) {

				return /\bslider\b/.test(oNode.className);

			}
		)[0];
		oBlockSlider.list = oBlockSlider.getElementsByTagName('ul')[0];
		oBlockSlider.items = F6.toArray(oBlockSlider.getElementsByTagName('li'));
		oBlockSlider.next = F6.toArray(oBlockSlider.getElementsByTagName('a')).filter(
			function(oNode) {

				return /\bnext\b/.test(oNode.parentNode.className);

			}
		)[0];
		oBlockSlider.next.blockSlider = oBlockSlider;
	
	};
	
	
	// Initialize Slider list parameters
	
	var _initList = function(oBlockSlider) {
	
		oBlockSlider.list.style.width = 0;
		var _iWidthList = 0;
		oBlockSlider.slider.style.display = 'block';
		oBlockSlider.slider.style.width = oBlockSlider.slider.parentNode.scrollWidth - oBlockSlider.previous.scrollWidth - oBlockSlider.next.scrollWidth + 'px';
		var _iWidthSlider = oBlockSlider.slider.scrollWidth;
		oBlockSlider.display = 0;
		var _iWidthDisplay = 0;
		var _iMarginItem = 0;
		oBlockSlider.step = 0;
		oBlockSlider.items.forEach(
			function(oItem, iItem) {
			
				if(oBlockSlider.step === 0) {
					oBlockSlider.step = oItem.scrollWidth;
				}
				_iWidthList += oItem.scrollWidth;
				if(_iWidthList > _iWidthSlider) {
					if(oBlockSlider.display === 0) {
						oBlockSlider.display = iItem;
					}
				}
				else {
					_iWidthDisplay = _iWidthList;
				}
			
			}
		);
		if(oBlockSlider.display === 0) {
			oBlockSlider.next.style.visibility = 'hidden';
		}
		else {
			_iMarginItem = Math.round((_iWidthSlider - _iWidthDisplay) * 100 / oBlockSlider.display) / 100;
		}
		oBlockSlider.step += _iMarginItem;
		if(_iMarginItem != 0) {
			oBlockSlider.list.style.width = _iWidthList + _iMarginItem * oBlockSlider.items.length + 'px';
		}
		else {
			oBlockSlider.list.style.width = 'auto';
		}
		oBlockSlider.list.style.marginLeft = 0 + 'px';
		oBlockSlider.previous.style.visibility = 'hidden';
		oBlockSlider.previous.style.marginRight = _iMarginItem / 2 + (typeof XMLHttpRequest === 'undefined' ? -3 : 0) + 'px';
		oBlockSlider.slider.style.width = parseInt(oBlockSlider.slider.style.width) - (window.attachEvent ? _iMarginItem : _iMarginItem / 2)  + 'px';
		if(window.attachEvent) {
			oBlockSlider.next.style.position = 'relative';
			oBlockSlider.next.style.left = _iMarginItem / 2 + (typeof XMLHttpRequest === 'undefined' ? -3 : 0) + 'px';
		}
		if(_iMarginItem != 0) {
			oBlockSlider.items.forEach(
				function(oItem) {
				
					oItem.style.marginRight = _iMarginItem + 'px';
				
				}
			);
		}
	
	};
	
	
	// Add navigation methods
	
	var _addMethods = function(oBlockSlider) {
		
		oBlockSlider.clic = 0;
		oBlockSlider.goToPreviousQueue = 0;
		oBlockSlider.goToNextQueue = 0;
		
		
		// Go to the previous item
		
		oBlockSlider.goToPrevious = function() {
			
			if(!oBlockSlider.run) {
				oBlockSlider.run = true;
				oBlockSlider.clic--;
				var _iStart = new Date().getTime();
				var _iStop = _iStart + 750;
				var _iStopPos = parseFloat(oBlockSlider.list.style.marginLeft) + oBlockSlider.step;
				if(_iStopPos >= 0) {
					oBlockSlider.previous.style.visibility = 'hidden';
					oBlockSlider.goToPreviousQueue = 0;
				}
				if(_iStopPos >= -(oBlockSlider.list.scrollWidth - oBlockSlider.display * oBlockSlider.step)) {
					oBlockSlider.next.style.visibility = 'visible';
				}
				var _interval = setInterval(
					function() {
				
						var _iCurrent = new Date().getTime();
						var _iCurrentPos = parseFloat(oBlockSlider.list.style.marginLeft);
						if(_iCurrent >= _iStop) {
							if(oBlockSlider.clic === 0) {
								oBlockSlider.list.style.marginLeft = 0 + 'px';
							}
							clearInterval(_interval);
							oBlockSlider.run = false;
							if(oBlockSlider.goToPreviousQueue > 0) {
								oBlockSlider.goToPreviousQueue--;
								oBlockSlider.goToPrevious();
							}
							return;
						}
						var _iPos = _iCurrentPos + (oBlockSlider.step * (_iCurrent - _iStart) / 750);
						oBlockSlider.list.style.marginLeft = (_iPos >= _iStopPos ? _iStopPos : _iPos) + 'px';
				
					},
					1
				);
			}
			else {
				oBlockSlider.goToPreviousQueue++;
			}
			
		};
		
		
		// Go to the next item
		
		oBlockSlider.goToNext = function() {
			
			if(!oBlockSlider.run) {
				oBlockSlider.run = true;
				oBlockSlider.clic++;
				var _iStart = new Date().getTime();
				var _iStop = _iStart + 750;
				var _iStopPos = parseFloat(oBlockSlider.list.style.marginLeft) - oBlockSlider.step;
				if(_iStopPos <= 0) {
					oBlockSlider.previous.style.visibility = 'visible';
				}
				if(oBlockSlider.clic === oBlockSlider.items.length - oBlockSlider.display) {
					oBlockSlider.next.style.visibility = 'hidden';
					oBlockSlider.goToNextQueue = 0;
				}
				var _interval = setInterval(
					function() {
				
						var _iCurrent = new Date().getTime();
						var _iCurrentPos = parseInt(oBlockSlider.list.style.marginLeft);
						if(_iCurrent >= _iStop) {
							clearInterval(_interval);
							oBlockSlider.run = false;
							if(oBlockSlider.goToNextQueue > 0) {
								oBlockSlider.goToNextQueue--;
								oBlockSlider.goToNext();
							}
							return;
						}
						var _iPos = _iCurrentPos - (oBlockSlider.step * (_iCurrent - _iStart) / 750);
						oBlockSlider.list.style.marginLeft = (_iPos <= _iStopPos ? _iStopPos : _iPos) + 'px';
				
					},
					1
				);
			}
			else {
				oBlockSlider.goToNextQueue++;
			}
			
		};
	
	};
	
	// Add Events handlers
	
	var _addBehaviour = function(oBlockSlider) {
	
		$e.add(oBlockSlider.previous, 'click', _clickGoToPrevious);
		$e.add(oBlockSlider.next, 'click', _clickGoToNext);
	
	};
	
	
	// Previous button management
	
	var _clickGoToPrevious = function(e) {
	
		$e.stop(e);
		this.blockSlider.goToPrevious();
	
	};
	
	
	// Next button management
	
	var _clickGoToNext = function(e) {
	
		$e.stop(e);
		this.blockSlider.goToNext();
	
	};
	

	// Public methods
	
	return {
	
		// Initialize Slider blocks
		
		initialize: function(oOptions) {

			F6.toArray(document.getElementsByTagName('div')).filter(
				function(oNode) {

					return /\bblockSlider\b/.test(oNode.className);

				}
			).forEach(_initSlider, this);

		}
	
	};

})();

function fixMea (){
	var divs = document.getElementsByTagName("div");
	var lines = [];
	for(var i=0, l=divs.length;i<l;i++){
		if(divs[i].className.match(/line/)){
			lines.push(divs[i]);
		}
	}
	
	for(var i=0, l=lines.length;i<l;i++){
		var subDiv = lines[i].getElementsByTagName('div');
		var $arr = [];
		for(var j=0, k=subDiv.length; j<k;j++){
			if(subDiv[j].className.match(/blockresize/)){
				$arr.push(subDiv[j]);
			}
		}
		doFixMea($arr);
	}
	
}

function doFixMea (arr){
	var maxHeight = 0;
	for(var i=0;i<arr.length;i++){
		if(maxHeight < arr[i].offsetHeight) maxHeight = arr[i].offsetHeight;
	}
	
	for(var i=0;i<arr.length;i++){
		if(arr[i].offsetHeight < maxHeight){
			var delta = maxHeight - arr[i].offsetHeight;
			var body = arr[i].firstChild.nodeType == 3 ? arr[i].firstChild.nextSibling : arr[i].firstChild;
			body.style.height = body.offsetHeight + delta + "px";
		}
	}
}

/**
*  Calculate height to cols display
*/
function initColsHeight() {
	var IE7 = (navigator.appVersion.indexOf("MSIE 7.")==-1) ? false : true;
	
	// We get all the lines of the page
	var lines = $n.nodes($(document.body), {nodeName:'div', className:'line'}, {nodeName:'div', className:'noresize'});
	
	// for each line, we search node containing columns (unit)
	for(var i = 0; i < lines.length; i++) {
		// Getting the offset height  of the main div (contaning all the cols)
		var lineHeight = lines[i].offsetHeight;
		var cols = $n.childs(lines[i], {nodeName:'div', className:'unit'});
		
		// If the line contains more than one column
		if(cols.length > 1) {
			// For each of them, we search all columns requiring footer alignement
			for(var j = 0; j < cols.length; j++) {			
				// Getting all the cols requiring footer alignement
				var alignedCols = $n.nodes(cols[j], {nodeName:'div', className:'alignFooters'});			
				
				// For each column requiring footer alignement, we search for the footer
				// and if it exists, we resize the body so that the body + the footer fill the line
				// height
				for(var k = 0; k < alignedCols.length; k++) {
					var divBody = $n.nodes(alignedCols[k], {nodeName:'div', className:'body'});	
					var divFooter = $n.nodes(alignedCols[k], {nodeName:'div', className:'foot'});	
					if(divFooter && divFooter[0]) {
						divBody[0].style.height = (lineHeight-divFooter[0].offsetHeight) + "px";
					}
				}
				
				// Blocks with borders
				var blocks = $n.childs(cols[j], {nodeName:'div', className:'block'});
				
				for(var k = 0; k < blocks.length; k++) {
					blocks[k].style.height = lines[i].offsetHeight + "px";

					if(IE7) {
						blocks[k].className += " blockIE7";
					}
					
					var blocksInsides = $n.childs(blocks[k], {nodeName:'div', className:'blockInside'});
					
					for(var l = 0; l < blocksInsides.length; l++) {
						var h2s = $n.childs(blocks[k], {className:'head'});
						var tabs = $n.childs(blocks[k], {className:'tabs'});
						var heightToRemove = 0;

						// For tabbed blocks
						if(tabs && tabs.length > 0) {
							heightToRemove += tabs[0].offsetHeight;
						}					

						// For titled blocks
						if(h2s && h2s.length > 0) {
							heightToRemove += h2s[0].offsetHeight;
						}
						
						blocksInsides[l].style.height = (lines[i].offsetHeight - heightToRemove - 2)+ "px";
					}
				}
				
				// Blocks without border				
				var blocks = $n.childs(cols[j], {nodeName:'div', className:'blockSansBorder'});
				
				for(var k = 0; k < blocks.length; k++) {
					blocks[k].style.height = lines[i].offsetHeight + "px";
					
					if(IE7) {
						blocks[k].className += " blockIE7";
					}
					
					var blocksInsides = $n.childs(blocks[k], {nodeName:'div', className:'blockInsidenoBrd'});
					
					for(var l = 0; l < blocksInsides.length; l++) {
						var h2s = $n.childs(blocks[k], {className:'head'});
						var tabs = $n.childs(blocks[k], {className:'tabs'});
						var heightToRemove = 0;
						
						// For tabbed blocks
						if(tabs && tabs.length > 0) {
							heightToRemove += tabs[0].offsetHeight;
						}					
						
						// For titled blocks
						if(h2s && h2s.length > 0) {
							heightToRemove += h2s[0].offsetHeight;
						}
						
						blocksInsides[l].style.height = (lines[i].offsetHeight - heightToRemove - 2)+ "px";
					}
				}
				
				// We resize the unit div to fill the line height to be sure that it 
				// displays all the content
				cols[j].style.height = lines[i].offsetHeight + "px";
			}
		}
	}
}

/**
*  Calculate height to cols display
*/
function recalculatedColsHeight() {
	// We get all the lines of the page
	var lines = $n.nodes($(document.body), {nodeName:'div', className:'line'});
	
	// for each line, we search node containing columns (unit)
	for(var i = 0; i < lines.length; i++) {
		// Getting the offset height  of the main div (contaning all the cols)
		var lineHeight = lines[i].offsetHeight;
		var cols = $n.childs(lines[i], {nodeName:'div', className:'unit'});
		
		// If the line contains more than one column
		if(cols.length > 1) {
			// For each of them, we search all columns requiring footer alignement
			for(var j = 0; j < cols.length; j++) {
				// We resize the unit div to fill the line height to be sure that it 
				// displays all the content
				//cols[j].style.height = lineHeight + "px";
				cols[j].style.height = "auto";
			}
		}
	}
	
	initColsHeight();
}


function navResize(){
	var nav = $('navigation');
	var subNav = $n.nodes(nav, {nodeName:'div', className:'unit'});
	for(var i=0,l=subNav.length;i<l;i++){
		var line = subNav[i].parentNode;
		subNav[i].style[heightPropertyToUse] = line.offsetHeight + "px";
	}
	var lis = $n.nodes(nav, {nodeName:'li'});
	for(var i=0,l=lis.length;i<l;i++){
		lis[i].onmouseover = function (){
			this.className += " hover";
		}
		lis[i].onmouseout = function (){
			this.className = this.className.replace(/hover/g, "");
		}
	}
	
}


/************
* 3.2.1 GO !
************/

$e.add('domready', function() {
	//verticalNavigation.init("nav");
	myAccordion.init("nav");
});
$e.add(window, 'load', function() {
	generateElements();
	if($('actuHome')) {
		homeActu.init();
	}
	var coo = readCookie("fontSize");
	changeFontSize(coo);
	contentSize();
	tooltip.init();
	afterLoad.start();
	//sizeBlocks();
	fixColumns();
	fixRightCol();
	//fixPNG();
	fixCorners();
	fixLayout();
	//new myAnim()
	capabilities();
	fixMea();
	var x = new F6.Sliders;


	initColsHeight();
	
	// A little fix to ensure that the right col is still in the correct size after all the previous applied modifications
	fixRightColOnly();
	navResize();
});
