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); 

document.documentElement.className+=" hasJS";
document.documentElement.className+= IS_IE ? " IS_IE" : "";

/*désactivation du click droit et du menu contextuel*/
// bloque le menu contextuel
//document.oncontextmenu = function() {return false};
/** *********************************************************************************************************
Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤ HELPERS FUNCTIONS Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤Ä¤ 
*********************************************************************************************************  */


if(!window.$) {
	window.$ = function(id) {
		return typeof id=='string' ? document.getElementById(id) : id;
	}
}
/** *********************************************************************************************************

     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
*/
if (!window.$extend) {
	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], a[2]):
				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, fn):
				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.fromElement;
			case 'mouseout': // Retourne l'element survole suivant l'element source de l'evenement
				return e.relatedTarget || 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, strCssRule) {
		var strValue = "";
		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");
	}
};

//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;
		if (check(a)) return true;
		return false;
	},
	/* 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") a = {nodeName:a}; //si une chaine de caracteres passee en parametre, cela signifie qu'on ne veut que recuperer des tags
		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");
	}
}

function MM_jumpMenu(targ,selObj,restore){
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}	

function addHover(elm, params) {
	params = params || [];
	var className = params[0];
	var iframeTag = params[1];
	var forceIE = params[2];
	elm.style.behavior = " "; //reecriture du style behavior
	if (IS_IE || forceIE) {
		className = className || "hover";
		elm.hoverClassName = className;
		if (iframeTag) {
			elm.iframeElm = $n.node(elm, iframeTag);
		}
		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);
		}
	}
}

var ifrlayer = {
	ie: document.all && window.print && !window.opera && document.getElementById,
	$: function(obj) { 
		if (!obj) return null;
		return (typeof(obj)=="string") ? document.getElementById(obj) : obj; 
	},
	make: function(obj) {
		return;
		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 + "px";
				}
			}
		}
	}
};


/********************
* Extensions d'objets 
 ********************/
var extend = function (object, extender) {
	var props = extender || {}; // fail-safe
	for (var property in props)
		if (!object.prototype[property])	object.prototype[property] = props[property];
	return object;
};

Array.Utils = {
	each: function(f) {
		var len = this.length;
		for (var i = 0; i < len; i++) {
			  if (i in this)
				f.call(this, this[i], i, this);
			}
		return this;
	},
	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 $n.node(node, {className: (className || "blockInside")})};
	
	// fonction de creation d'un coin (b avec className) 
	function nc(clN) {var b = document.createElement("b");b.className=clN;return b;};
	
	//ajoute un element ou une liste d'elements (c) sur l'element x
	function add(x, c) {
		var i=0; if (!x) return; 
		if (c.length) for (i=0; i<c.length; i++) x.appendChild(c[i].cloneNode(true));
		else x.appendChild(c.cloneNode(true));
	};
	
	/* corners top left, top right, bottom left, bottom right for a block */
	var topCorners = nc('topCorners');
	topCorners.innerHTML = '<b class="tl"></b><b class="tr"></b>';
	var bottomCorners = nc('bottomCorners');
	bottomCorners.innerHTML = '<b class="bl"></b><b class="br"></b>';
	
	
	function addBlockCorners(x, top, bottom, className) {
		var inside = getIsd(x, className);
		if (!inside) return;
		var parent = inside.parentNode;
		// top corners 
		parent.insertBefore(top.cloneNode(true), inside);
		// bottom Corners : insertAfter emulation :D
		var bottomCorners = parent.insertBefore(bottom.cloneNode(true), inside);
		parent.insertBefore(inside, bottomCorners);
	};
	
	/* sides  top, bottom, left and right for a block (type toggle or shadow block */
	var sideT = nc('sideT'); var sideB = nc('sideB');
	var sideL = nc('sideL'); var sideR = nc('sideR');
	sideT.innerHTML = sideB.innerHTML = '<b class="cornerRight"></b>';

	
	function addBlockSides(x, top, bottom, left, right) {
		var inside = getIsd(x); if (!inside) return;
		var parent = inside.parentNode;
		if (left) parent.insertBefore(left.cloneNode(true), inside);
		if (right)  parent.insertBefore(right.cloneNode(true), inside);
		parent.insertBefore(top.cloneNode(true), inside);
		// bottom Corners : insertAfter emulation :D
		var bottomCorners = parent.insertBefore(bottom.cloneNode(true), inside);
		parent.insertBefore(inside, bottomCorners);
	};
	
	//-- creation des elements qui seronts clones --
	var topCornersMaster = nc('topCorners');
	topCornersMaster.innerHTML = '<b class="tl blockMastertl"></b><b class="tr blockMastertr"></b>';
	var bottomCornersMaster = nc('bottomCorners');
	bottomCornersMaster.innerHTML = '<b class="bl blockMasterbl"></b><b class="br blockMasterbr"></b>';
	
	
	// -- 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(/\bblockTemoignage\b/)) { //blocks avec coins absolus sur tous les cotes.
				addBlockSides(x, sideT, sideB, sideL, sideR);
			}else if (x.className.match(/\bblockMaster\b/)) {
				addBlockCorners(x, topCornersMaster, bottomCornersMaster, 'blockMasterInside');
			} else if(x.className.match(/(blocBandBlue|blocNouveaute)/)) {
				addBlockSides(x, sideT, sideB);
			}	else if (x.className.match(/\bblock\b/)) //block par defaut
				addBlockCorners(x, topCorners, bottomCorners);
			
			if (x.className.indexOf("blockToggle")!=-1)
				toggleBlock.init(x);
			x.alreadyProcessed = true;	
			initOtherBlocks(x); // fonction d'initialisation d'autres blocks
		}
	}
	
}

/* 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|blockTabsVille/)) //block d'onglets en general (gere tous types d'onglets).
		tabs.init(x);
	if (x.className.match(/blockToggle|insideToggle/)) //block d'onglets en general (gere tous types d'onglets).
		toggle.init(x);
	if (x.className.match(/\blistHome\b/)) 
		homeToggle.init(x);
	if (x.className.match(/\barrayGenCode\b/)) 
		genCodeSelect.init(x);
	if ($c.has(x, 'line')) //si ligne de block, on la stocke dans un tableau
		linesOfBlocks.push(x);
}

var toggle = {
	init : function(block) {
		var link = $n.node(block, {nodeName:'a'});
		if (!link) return;
		link.onclick = function() {
			toggle.toggle(this);
			return false;
		}
	},
	toggle : function(link) {
		var block = $n.parent(link, {className:/(block|inside)Toggle/i});
		if ($c.has(block, 'blockToggle'))
			$c.has(block, 'toggleClosed') ? $c.remove(block, 'toggleClosed') : $c.add(block, 'toggleClosed');
		if ($c.has(block, 'insideToggle'))
			$c.has(block, 'insideToggleClosed') ? $c.remove(block, 'insideToggleClosed') : $c.add(block, 'insideToggleClosed');
		toggle.inGroup(block);

	},
	/* gere un toggle quand il est dans un groupe de toggles */
	inGroup : function(block) {
		var toggleState = $c.has(block,'toggleClosed');
		var group = $n.parent(block, {className:"(toggleGroup|toggleGroupHome)"});
		if (!group) return false;
		$n.childs(group, {className:"(blockToggle|blockToggleHome)"}).each(function(block) {
			$c.add(block, 'toggleClosed');
		});
		toggleState ? $c.add(block, 'toggleClosed') : $c.remove(block, 'toggleClosed');
	}

}
/** *********************************************************************************************************

*/

var afterLoad = {
	functions : [],
	add : function(f) {
		this.functions.push(f);
	},
	start : function() {
		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.sizeTab(a[i], ul);
		}
		afterLoad.add(function() {tabs.sizeContents(elm)});
	},
	sizeTab : function(a, ul) {
		if ($c.has(ul, 'noresize')) return;
		var newSize =  a.offsetHeight + (ul.offsetHeight-a.offsetHeight) - $s.getV(a);
		a.style[heightPropertyToUse] = (newSize<0) ? 0 : newSize + "px"; //IE doesn't compute size under 0
	},
	sizeContents : function(block) {
		if (block.className.match(/\b(noresize|blockTabs|blockTabsVertical|blockTabsVille)\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|blockTabsVille/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|blockTabsVille/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);
			}
		}
		
		if (document.all && window.print) {
			$n.nodes(block, {nodeName:'span', className:'(tr|bl)'}).each(function(corner,i) {
				setTimeout(function() {
					corner.style.height = '';
				},2*i);
			});
		}
	}
}

/**************
* 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"});
		arrayLines = arrayLines.concat($n.nodes(parentBlock, {nodeName: 'div', className: "line"}));
	}
	arrayLines.eachInv(function (line) { 
		var units = $n.childs(line, {className: "unit"});
		units.each(function(unit) {
			var blocks = $n.childs(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);
		});
	});
}

/*************
* PopLayer
**************/
var popLayer = {
	template : '<b class="popt"><b></b></b><div class="popInside"><b class="popl"></b><b class="popr"></b><div class="popBody"><div class="popHead"><b class="close">Fermer</b></div><div class="popContent">Content Here</div></div></div><b class="popb"><b></b></b>',
	pop : null,
	currentPosition:null,
	popContent : null,
	timeout : null,
	elmSource : null,
	eventsArray : ["click", "mouseover", "mouseout", "mousemove", "mouseup", "mousedown", "keyup", "keydown", "keypress", "abort", "blur", "change", "dblclick", "error", "load", "reset", "resize", "select", "submit"],
	init : function(parent) {
		if (!popLayer.pop) {
			parent = (typeof parent =="string") ? document.getElementById(parent) : parent;
			parent = parent || document.body;
			var pop = document.getElementById("popLayer");
			if (!pop) {
				pop = parent.appendChild(document.createElement("div"));
				pop.id = "popLayer";
				pop.innerHTML = popLayer.template;
			}
			popLayer.pop = pop;
			popLayer.popContent = $n.node(pop,  {nodeName:"div", className:"popContent"});
			pop.style.marginLeft = -pop.offsetWidth/2+"px"
			var close = $n.node(pop, {className:"close"});
			close.onclick = function() { popLayer.close(); };
		}
		//popLayer.close();
		popLayer.pop.style.width = "";
		popLayer.pop.className = "";
		popLayer.pop.style.display = "block";
		popLayer.popContent.innerHTML = "";
		popLayer.popContent.style.height = "";
	},
	openHtml : function(elm, content, width, height, mask) { popLayer.open(elm, 'html', content, width, height, mask); },
	openTag : function(elm, content, width, height, mask) { popLayer.open(elm, 'tag', content, width, height, mask); },
	openUrl : function(elm, content, width, height, mask) { popLayer.open(elm, 'url', content, width, height, mask); },
	open : function(elm, type, content, width, height, mask) {
		popLayer.elmSource = elm;
		popLayer.init();
		popLayer.setPosition(elm);
		switch(type) {
			case 'html' : 
				popLayer.popContent.innerHTML = content;
				break;
			case 'tag' : 
				content = typeof(content)=="string" ? document.getElementById(content) : content;
				popLayer.copyNodes(content, popLayer.popContent);
				break;
			case 'url' : 
				popLayer.pop.className = "iframe loading";
				popLayer.popContent.innerHTML = '<iframe class="popIframe" onload="popLayer.loaded()" frameborder="0"></iframe>'; //cause IE, we must use innerHTML instead of DOM functions
				var loader = popLayer.popContent.appendChild(document.createElement("b"));
				loader.className="loader";
				var ifr = $n.node(popLayer.popContent, {nodeName:"iframe"});
				popLayer.iframe = ifr;
				ifr.src = content;
				popLayer.timeout = setTimeout(popLayer.loaded,1000);
				break;
			default :
				alert("Vous n'avez pas specifie le bon type de contenu");
				return;
		}
		if (mask) {
			popLayer.showMask();
		}
		setTimeout(function() {
			if (popLayer.iframe) {
				var pWin = popLayer.iframe.contentWindow || popLayer.iframe.window;
				if (pWin && elm) {
					pWin.onload = function() {
						popLayer.setPosition(elm);
						popLayer.showMask();
					};
				}
			}
		}, 2);
		popLayer.resize(width, height);
		popLayer.setPosition(elm);
		popLayer.pop.style.visibility = "visible";
		ifrlayer.make(popLayer.pop);
	},
	close : function(url) {
		popLayer.hideMask();
		if (url) {
			if (window.parent) {
				window.parent.location.href=url;
			}
		}
		function close(from) {
			from.popLayer.hideMask();
			ifrlayer.kill(from.popLayer.pop);
			from.popLayer.pop.parentNode.removeChild(from.popLayer.pop);
			popLayer.pop  = null;
			popLayer.iframe = null;
			popLayer.popContent = null;
		};
		ifrlayer.kill(popLayer.pop);
		if (window.parent) close(window.parent);
		try {close(window);}
		catch(e){
			ifrlayer.kill(popLayer.pop);
			popLayer.pop=null
		};
	},
	resize: function(width, height) {
		var doc, objectSized;
		if (width) {
			var pWin = popLayer.iframe && (popLayer.iframe.contentWindow || popLayer.iframe.window);
			if (pWin) {
				popLayer.pop.style.width = width + (popLayer.pop.offsetWidth-popLayer.popContent.offsetWidth) + "px";
			}
			else
				popLayer.pop.style.width = width + ((width+"").match(/%/) ? "%" : "px");
		}
		if (height) { 
			if (popLayer.iframe) {
				if (isNaN(height)) {
					objectSized = height;
					height = objectSized.offsetHeight;
				}
				popLayer.iframe.style.height="10px";
				if (objectSized && objectSized.scrollHeight>=popLayer.iframe.offsetHeight) {
					popLayer.iframe.style.height = objectSized.scrollHeight + 1 + "px"; //on met la taille pour supprimer le scroller
					popLayer.iframe.style.height = "10px"; //on remet la taille ï¿½ 10 pour avoir le bon scrollHeight
					popLayer.iframe.style.height = objectSized.scrollHeight + 1 + "px"; //on resize definitifement via le bon scrollHeight
				} else {
					popLayer.iframe.style.height = height+"px";
				}
			}
			else
				popLayer.popContent.style.height = height+"px";
		}
		
		var sides = getNodes(popLayer.pop, {nodeName:"b", className:"pop(r|l)"});
		sides.each(function(side) { side.style.height = side.parentNode.offsetHeight + "px"; });
		ifrlayer.make(popLayer.pop);
	},
	setPosition : function(elm, top, left) {
		popLayer.pop.style.marginLeft = -popLayer.pop.offsetWidth/2+"px";
		if (elm && typeof elm!="string") 
			popLayer.pop.style.top = findPos(elm)[1] + 10 + "px";
		else 
			popLayer.pop.style.top = document.documentElement.clientHeight>popLayer.pop.offsetHeight ? parseInt((document.documentElement.clientHeight-popLayer.pop.offsetHeight)/2) + document.documentElement.scrollTop + "px" :  document.documentElement.scrollTop + 10 + "px";
		ifrlayer.move(popLayer.pop);	
	},
	fixSize : function(elmSrc) {
		if (window.parent && window.parent.popLayer && window.parent.popLayer.iframe) {
			window.parent.popLayer.iframe.style.height="10px";
			window.parent.popLayer.resize(null, document.documentElement.scrollHeight+1);
			window.parent.popLayer.setPosition(elmSrc);
		}
	},
	loaded : function(elm) {
		clearTimeout(popLayer.timeout);
		var from = window.parent || window;
		if (from) {
			from.popLayer.pop.className = from.popLayer.pop.className.replace(/loading/g, "");
			var obj = from.popLayer.iframe.contentWindow || from.popLayer.iframe.window;
			try {
				obj.close =  function() {
					return function() {
						popLayer.close();
					}();
				}
				if (document.all && window.print && !window.opera) {
					var objToSend = obj.document.body || obj.document.documentElement;
				} else {
					var objToSend = (obj.document.body && obj.document.documentElement && obj.document.body.scrollHeight>obj.document.documentElement.offsetHeight) ? obj.document.body : obj.document.documentElement;
				}
				popLayer.resize(obj.document.documentElement.scrollWidth+10, objToSend);
			} catch(e) {}
		}
		popLayer.setPosition(popLayer.elmSource);
		popLayer.elmSource = null;
	},
	copyNodes : function(sourceElm, destElm) {
		for (var i=0; i<sourceElm.childNodes.length; i++) {
			destElm.appendChild(sourceElm.childNodes[i].cloneNode(true));
		}
		var allSourceNodes = $n.getByTagName(sourceElm, "*");
		var allDestNodes = $n.getByTagName(destElm, "*");
		for (var i=0; i<allSourceNodes.length; i++) {
			popLayer.copyEvents(allSourceNodes[i], allDestNodes[i]);
		}
	},
	copyEvents : function(sourceElm, destElm) {
		for (var i=0; i<popLayer.eventsArray.length; i++) {
			var evt = "on"+popLayer.eventsArray[i];
			destElm[evt] = sourceElm[evt];
		}
	},
	
	showMask : function() {
		if (!popLayer.mask) {
			var div = document.createElement('div');
			div.id = 'popLayerMask';
			popLayer.mask = document.body.appendChild(div);
		}
		var height = document.documentElement.scrollHeight>document.documentElement.clientHeight ? document.documentElement.scrollHeight : document.documentElement.clientHeight;
		var width  = document.documentElement.scrollWidth>document.documentElement.clientWidth ? document.documentElement.scrollWidth : document.documentElement.clientWidth;
		popLayer.mask.style.height = height +'px';
		popLayer.mask.style.width = width +'px';
		popLayer.mask.style.display = 'block';
		ifrlayer.make(popLayer.mask);
	},
	
	hideMask : function() {
		if (popLayer.mask) {
			popLayer.mask.style.display = 'none';
			ifrlayer.kill(popLayer.mask);
		}
	}
}

function showAndHide(field) {
	var allFields = getNodes(field.form, {name:field.name}, null, false, field.form.elements);
	allFields.each(function(field) {
		var elm = document.getElementById(field.value);
		elm.style.display = field.checked ? "block" : "none";
	});
}



/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;



/*	fixPng :
	@function 	: 	fixe les images de fond png 24 bits sous IE6 (pour la transparent alpha) ainsi que les tags <img>
*/
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'ê­©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 ê­©ment qui avait une image de fond
				if (elm.nodeName=='IMG') {
					if (!elm.src.match(/.*\.png$/)) return;
					var imgContainer = document.createElement('i');
					with(imgContainer.style) {
						display = 'inline-block';
					}
					elm.parentNode.insertBefore(imgContainer, elm)
					var styles = ['position', 'width', 'height', 'left', 'top', 'right', 'bottom', 'display'];
					for (var i=0; i<styles.length; i++) {
						imgContainer.style[styles[i]] = elm.currentStyle[styles[i]];
					}
					
					imgContainer.className = elm.className;
					elm.className = '';
					
					with (elm.style) {
						position = 'static';
					}
					imgContainer.appendChild(elm);
					imgContainer.style.backgroundImage = 'url('+elm.src+')';
					imgContainer.style.backgroundRepeat = 'no-repeat';
					elm.style.filter = 'alpha(opacity=0)';
					elm = imgContainer;
				}
				
				
				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 (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 (pngLayerN.offsetWidth>elmN.offsetWidth && elm.currentStyle.backgroundPositionX.match(/^(right|100%)$/) || elm.currentStyle.backgroundPositionY.match(/^(bottom|100%)$/)){
								pngLayerN.filters['DXImageTransform.Microsoft.AlphaImageLoader'].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)
								
							pngLayerN.sizingMethod = 	pngLayerN.filters['DXImageTransform.Microsoft.AlphaImageLoader'].sizingMethod;
						}
					}(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ê¤¡lé¡³ur 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é¡°endant 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ê¥¬ 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) {
			window.attachEvent('onload', function() {
				pngFixLoader.launch();
			});
		}
	}
}
pngFixLoader.init();

var navLeft = {
	navElement : null,
	init : function(navId){
		var nav = $(navId);
		if (!nav) return;
		this.navElement = nav;
		var lis = nav.getElementsByTagName('li');
		for (var i=0; i<lis.length; i++) {
			var li = lis[i];
			var a = $n.node(li, {nodeName:'a'});
			if (a.href.match(/\#$/)) {
				var ul = $n.after(a, {nodeName:'ul'});
				if (ul) {
					a.onclick = navLeft.toggleNav
				}	
			}
		}
		this.currentLi = this.findCurrentLiFirstTime(nav);
	},
	
	toggleNav : function() {
		var clickedLi = this.parentNode;
		/* add by chaman*/
		var uls = clickedLi.getElementsByTagName('ul');
		var ul = uls[0];
		/**/
		// si la nav est deja ouverte on la referme et  ainsi que tous ses noeuds enfants
		if (clickedLi.className.match(/\bcurrent\b/)) {
			clickedLi.className = clickedLi.className.replace(/\bcurrent\b/g,'')
			var lis = clickedLi.getElementsByTagName('li');
			for (var i=0; i<lis.length; i++)
				lis[i].className = lis[i].className.replace(/\bcurrent\b/g,'');
			/*on refreme tous les ul by chaman*/
			uls = navLeft.currentLi.getElementsByTagName('ul');
			if(uls){
				for (var i=0; i<uls.length; i++)
					uls[i].style.display = 'none';
			}
			var links = navLeft.currentLi.getElementsByTagName('a');
			if(links){
				for (var i=0; i<links.length; i++)
					links[i].className += ' noBg';
			}
			navLeft.currentLi = null;
			ul.style.display = 'none';
			this.className += ' noBg';
			/**/
			
		} else {
			// si un bout de la nav est déja ouvert on va le refermer
			if (navLeft.currentLi) {
				/* delete by chaman
				//on check d'abord si le noeud actuellement ouvert n'est pas un noeud parent du noeud qu'on veut ouvrir (cela evitera les surprises);
				var liParent = clickedLi.parentNode.parentNode;
				if (liParent != navLeft.currentLi) {
					var li = navLeft.currentLi;
					while(navLeft.navElement!=li && liParent!=li) {
						if (li.nodeName=='LI') li.className = li.className.replace(/\bcurrent\b/g,'');
						li = li.parentNode;
					}
				}
				*/

			}
			// maintenant que la nav est refermee on peut ouvrir celle qu'on vient de cliquer
			clickedLi.className+=' current';
			/* add by chaman*/
			this.className = this.className.replace(/\bnoBg\b/g,'');
			ul.style.display = 'block';
			/**/
		}
		navLeft.currentLi = clickedLi;
		return false;
	},
	// cette fonction est trï¿½s utile au premier chargement de la page quand nevLeft.currentLi == null.
	findCurrentLiFirstTime : function(ul, li) {
		if (!ul) return li;
		var lisChilds = $n.childs(ul, {nodeName:'li'});
		for (var i=0; i<lisChilds.length; i++) {
			var li = lisChilds[i];
			if (li.className.match(/\bcurrent\b/)) {
				var nextLi = navLeft.findCurrentLiFirstTime($n.node(li, {nodeName:'ul'}), li);
				return nextLi || li;
			}
		}
	}

}

function resetInput(input) {
	input.theDefaultValue = input.getAttribute('value');
	input.onfocus = function() {
		if (this.value==this.theDefaultValue) {
			this.value='';
		}
		this.className+= " focusField";
	};
	input.onblur = function() {
		if (this.value=='') {
			this.value=this.theDefaultValue;
			this.className = this.className.replace(/\bfocusField\b/g,'');
		}
	}
	input.onfocus();
}
var inputIncrement = {
	delayIncr : 150,
	max : 99999,
	min : 1,
	init : function(parent) {
		var inputs = ($(parent) || document).getElementsByTagName('input');
		for(var i=inputs.length-1; i>=0; i--) {
			var inp = inputs[i];
			if (inp.className.match(/\btypeIncrement\b/) && !inp.incrementSetted && inp.offsetHeight>0) {
				var span = document.createElement('span');
				span.className = inp.className;
				inp.parentNode.insertBefore(span, inp);
				span = span.appendChild(document.createElement('span'));
				span.appendChild(inp);
				var plus = document.createElement('input');
				with(plus) {
					type = "button";
					className = 'plus';
					plus.value = '+';
				}
				span.appendChild(plus);
				var moins = plus.cloneNode(moins);
				with(moins) {
					className = 'moins';
					value = '-';
				}
				span.appendChild(moins);
				
				inputIncrement.addInputEvents(inp, plus, moins);
				
				inp.incrementSetted = true;
			}
			
		}
	},
	
	increment:function(input, incr) {
		var val = parseInt(input.value)-parseInt(input.value)%Math.abs(incr);
		if (isNaN(val)) val = 1;
		input.value = val + incr;
		var min = !input.getAttribute('min') ? inputIncrement.min : parseInt(input.getAttribute('min'));
		input.value = input.value<min ? min : (input.value>inputIncrement.max ? inputIncrement.max : input.value);
		if (input.onkeyup) input.onkeyup();
	},
	
	addInputEvents : function(input, plus, moins) {
		plus.incrementInput = input;
		moins.incrementInput= input;
		plus.onfocus = moins.onfocus = plus.onmouseover = moins.onmouseover = input.onmouseover = function() {
			if (input.getAttribute('incrementStep')) {
				input.step = parseInt(this.getAttribute('incrementStep'));
			} else {
				var td = $n.parent(input,{nodeName:'td', className:'increment'});
				if (td) {
					td = $n.before(td,{className:'conditionnement'});
					//input.step = parseInt(td.innerText || td.textContent);
					//dans tous cas de conditionnement rencontrés la  propriété step de l'object input devra etre = 1 
					input.step = parseInt(td.innerText || td.textContent) ? parseInt(td.innerText || td.textContent) : 1;
				}
				
				if (isNaN(input.step)) input.step = 1;
			}
		
		}
		
		plus.onclick = function() {
			inputIncrement.increment(this.incrementInput, input.step);
		}
		plus.onmousedown = function() {
			var ___this = this;
			this.inputIncrementInterval = setInterval(function() {
				inputIncrement.increment(___this.incrementInput, input.step);
			}, inputIncrement.delayIncr);
		};
		moins.onclick = function() {
			inputIncrement.increment(this.incrementInput, -input.step);
		}
		moins.onmousedown = function() {
			var ___this = this;
			this.inputIncrementInterval = setInterval(function() {
				inputIncrement.increment(___this.incrementInput, -input.step);
			},inputIncrement.delayIncr);
		};
		plus.onmouseup = plus.onmouseout = inputIncrement.clear;
		moins.onmouseup = moins.onmouseout = inputIncrement.clear;
	},

	clear : function() {
		clearInterval(this.inputIncrementInterval);
	}
}


var formval={
	defaultErrorMessage:"Ce champ est erron\u00E9",
	defaultPosition:"beforefield",
	globalErrorMsg : "",
	callbackfunctions : function() {
	},
	lineInput : {nodeName:"(div|p|li|dd|td)"},
	validationFunc:{
		requiredgroup:function(field) {
			var self = this;
			var returnMessage=true;
			var allFields = field.getAttribute('requiredgroupothers').split(',');
			allFields.push(field);
			allFields.each(function(field) {
				field = $(field);
				if (self.required(field)!=true) returnMessage = false;
			});
			return returnMessage;
		},
		required:function(field) {
			var returnMessage=true;
			switch(field.type) {
				case "text":
				case "file":
				case "password":
				case "textarea":
					if (field.value=="") returnMessage="text";
					break;
				case "checkbox":
				case "radio":
					var sameElt = formval.getSameElements(field);
					var onecheck=false;
					for (var i=0; i<sameElt.length; i++) {
						if (sameElt[i].checked)
							onecheck=true;
					}
					if (!onecheck) returnMessage=field.type;
					break;
				case "select-one":
				case "select-multiple":
					if(field.selectedIndex==0)
						returnMessage="select";
					break;
			}
			return returnMessage;
		},
		lengthis1:function(field) {return field.value.length != 1;},
		email:function(field) {return (field.value=="" || !!field.value.match(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,6}$/i));},
		name:function(field) {return (field.value=="" || !!field.value.match(/^[a-zA-Z]([a-zA-Z]|\s|\'|\.|\-)+$/));},
		pseudo:function(field) {return !!field.value.match(/^[a-zA-Z0-9_\-]{3,20}$/);},
		image:function(field) {return (field.value=="" || !!field.value.match(/^.+\.(gif|jpe?g|png)$/));},
		date:function(field) {
			if (field.value=='') return;
			var dateSplit = field.value.split('/');
			var date = new Date(dateSplit[2], dateSplit[1]-1, dateSplit[0]);
			if (date.getDate()!=dateSplit[0] || date.getMonth()!=dateSplit[1]-1 || date.getFullYear()!=dateSplit[2]) {
				return false;
			}
			return true;
		},
		dateMax:function(field) {
			if (field.value=='') return;
			var dateSplit = field.value.split('/');
			var date = new Date(dateSplit[2], dateSplit[1]-1, dateSplit[0]);
			return !(date.getTime()>new Date().getTime())
		},
		dateMin:function(field) {
			if (field.value=='') return;
			var dateSplit = field.value.split('/');
			var date = new Date(dateSplit[2], dateSplit[1]-1, dateSplit[0]);
			var currentDate = new Date();
			if (date.getMonth()==currentDate.getMonth() && date.getDate()==currentDate.getDate())
				return true;
			return (date.getTime()>new Date().getTime())
		},
		codepostal:function(field){return !!field.value.match(/\d[ab0-9]\d{3}/);},
		cpordep:function(field){if (field.value=="") return true; return !!field.value.match(/\d[ab0-9](\d{3})?/i);},
		phonenumber:function(field){
			var val = field.value;
			if (val=="") return true;
			val.replace(/[.\-\s]/g,'');
			return !!val.match(/^\d{10}$/);
		},
		rio:function(field) { if (field.value=="") return true; return (!!field.value.replace(/\W|_/gi, "").match(/^[\dA-Za-z]{12}$/));},
		phonenumber2:function(field){
			var val = field.value;
			if (val=="") return true;
			var cleanNum = val.match(/(\+)?\d+/g)
			if (!cleanNum) return false;
			cleanNum = cleanNum.join(""); //on recupere le numero de telephone en version nettoyee.
			if (!cleanNum.match(/^\+?(33|033|0033)?0?[1-9]\d{8}$/)) return false; //on checke reelement le numero de telephone
			return !!val.match(/^(\d|\s|-|\.|\\|\/|_|\+)+$/); //on check si des caract&egrave;res autres que chiffes,-,+,.,_,/,\  sont pr&eacute;sents
		},
		numbers:function(field){if (field.value=="") return true; return !!field.value.match(/^\d+$/);},
		numcommande:function(field){if (field.value=="") return true; return !!field.value.match(/\d{10}/);},
		alphanum:function(field){if (field.value=="") return true; return !!field.value.match(/^[\dA-Za-z\s]+$/);},
		heure:function(field){if (field.value=="") return true; return !!field.value.match(/^[\dA-Za-z\s\:]+$/);},
		decimal:function(field){if (field.value=="") return true; return !!field.value.match(/^\d+([.,]\d+)?$/);},
		gencode:function(field) {
			var ok = true;
			var val = field.value;
			if (!val.match(/^312729\d{7}$/)) return false;
			//verification de la cle de controle 
			var gencode = val.substr(0,12).split('');
			var sums = 0;
			var poids = 1;
			gencode.each(function(num) {
				sums += num*poids;
				poids = 4-poids; //inversion du 1 en 3 et inversement
			});
			return val.substr(12,1) == 10-(sums%10 == 0 ? 10 : sums%10); //on compare le resultat avec la cle de controle
		},
		equalsto:function(field) {
			var equalsFieldId = field.getAttribute("equalsto");
			var equalsField = document.getElementById(equalsFieldId);
			return (field.value==equalsField.value);
		},
		minimum:function(field) {
			var minNum = field.getAttribute("minimum_num") || 1;
			var properties = field.getAttribute("minimum_field") || "text";
			var properties = properties.split(/,/g);
			var inputs = field.getElementsByTagName("input");
			var counter = 0;
			for (var i=0; i<inputs.length; i++) {
				var x=inputs[i];
				if (x.type==properties[0] && (properties[1] ? new RegExp(properties[1]).test(x.name) && x.offsetHeight>0 : true)) {
					if (formval.validationFunc["required"](x)===true) {
						counter++;
					}
				}
			}
			return counter<minNum ? ([false,minNum]) : true;
		},
		minimumLetter:function(field){
			if (field.value=="") return true;
			var minLength = field.getAttribute("minlength")
			return  (field.value.length>=minLength) ? true : [false,minLength];
		},
		maximumLetter:function(field){
			if (field.value=="") return true;
			var maxLength = field.getAttribute("maxlength")
			return  (field.value.length<=maxLength) ? true : [false,maxLength];
		},
		requiredexclusif:function(field) {
			var reqExclusifField = document.getElementById(field.getAttribute("reqexclusiffield"));
			if (!reqExclusifField) { return false; }
			
			if(field.nodeName=="SELECT") {
				if (field.selectedIndex == 0 && reqExclusifField.value != "")
					return false;
			} else {
				if(field.value == 0 && reqExclusifField.value != "") 
					return false;
			}
			return true;
		}
	},
	errorMessages:{
		required:{
			checkbox:"Cette case doit \u00EAtre coch\u00E9e",
			radio:"Vous devez s\u00E9lectionner une de ces options",
			text:"Attention, ce champ est obligatoire",
			select:"Vous devez s\u00E9lectionner une de ces options"
		},
		requiredoptional:this.required,
		email:"Cette adresse e-mail est erron\u00E9e",
		name:"Ce champ ne doit comporter que des lettres, et les caract&egrave;res suivants : '-",
		numbers:"Ce champ ne doit comporter que des chiffres",
		numcommande:"Le num&eacute;ro de commande doit comporter 10 chiffres",
		alphanum:"Ce champ ne doit comporter que des chiffres et/ou des lettres",
		heure:"Ce champ ne doit comporter que des chiffres et/ou des lettres ou le caract&egrave;re :",
		decimal:"Ce champ ne doit comporter que des chiffres",
		phonenumber:"Ce champ ne doit comporter que des chiffres",
		phonenumber2:"Veuillez v\u00E9rifier votre num\u00E9ro de t\u00E9l\u00E9phone",
		equalsto:"Ce champ doit &ecirc;tre identique au pr&eacute;c&eacute;dent",
		codepostal:"Ce code postal est erron\u00E9",
		cpordep:"Vous ne pouvez mettre qu'un num\u00E9ro de d\u00E9partement ou un code postal",
		pseudo:'Attention, votre pseudo doit contenir uniquement 20 caract&egrave;res, des lettres et des num\u00E9ros et les signes "_" et "-"',
		image:"Votre fichier n'est pas au bon format",
		minimum:"Vous devez remplir au moins ## champ",
		minimumLetter:"Vous devez remplir au moins ## caract&egrave;res",
		maximumLetter:"Vous devez remplir moins de ## caract&egrave;res",
		requiredexclusif:"Vous devez remplir au moins un des champs",
		siret:"Le num\u00E9ro siret n'est pas valide",
		rio:"Le code rio n\u0027est pas valide (12 caract&egrave;res)",
		date:"La date est erron\u00E9e ou n'est pas au format JJ/MM/AAAA",
		dateMin:"La date doit &ecirc;tre sup&eacute;rieure &agrave; la date en cours",
		dateMax:"La date doit &ecirc;tre inf&eacute;rieure &agrave; la date en cours",
		dateFerie:"Le jour ne doit pas &ecirc;tre un jour f&eacute;ri&eacute;"
	},
	getMessagePosition:function(field){
		var element=field;
		var position="";
		if (field.getAttribute("position")) {
			var position = field.getAttribute("position");
			if (!position.match(/^(before|after)(label|parentnode|field)$/)) {
				position = formval.defaultPosition;
			}
			var arrPos = position.match(/^(before|after)(label|parentnode|field)$/);
			switch(arrPos[2]) {
				case "label" :
					var node = field;
					while(node.nodeName!="LABEL") {
						node=node.previousSibling;
					}
					if (node.nodeName=="LABEL") element=node;
					break;
				case "parentnode" :
					var parentPos = field.getAttribute("parentnode_pos") ? parseInt(field.getAttribute("parentnode_pos")) : 1;
					var element=field;
					for (var i=0; i<parentPos; i++) {
						element=element.parentNode;
					}
					break;
			}
			return [arrPos[1],element];
		} else {
			return [formval.defaultPosition.match(/(before|after)(label|parentnode|field)/)[1],element]
		}
	},
	getSameElements:function(field) { //return an array of elements in form who have same nodeName, name and type
		var aReturnElements=[];
		var elt=field.form.elements;
		for (var i=0; i<elt.length; i++) {
			if (elt[i].nodeName==field.nodeName && elt[i].name==field.name && elt[i].type==field.type) {
				aReturnElements.push(elt[i]);
			}
		}
		return aReturnElements;
	},
	getElements : function(form) {
		var elements = [];
		var tags = 'input,select,textarea,a,div,button,dd'.split(',');
		tags.each(function(tag) {
			var allElms = form.getElementsByTagName(tag);
			for (var i=0; i<allElms.length; i++) {
				elements.push(allElms[i]);
			}
		})
		return elements;
	},
	check:function(theForm, showOnlyOneMessage, otherReturnValues) {
		formval.globalErrorMsg = "";
		var scrollTop = document.body.scrollTop;
		var finalErrorMessage="";
		var hasError=false;
		var elm = formval.getElements(theForm);
		for (var i=0; i<elm.length; i++) {
			var x=elm[i];
			if (x.getAttribute("validation") && x.offsetHeight && x.offsetHeight>0 && !x.disabled) {
				var validOptions = x.getAttribute("validation").split(/\s+/g);
				finalErrorMessage="";
				for (var j=validOptions.length-1; j>=0; j--) {
					if (typeof(formval.validationFunc[validOptions[j]])=="function") {
						var returnMessage = formval.validationFunc[validOptions[j]](x);
						var quantity = typeof(returnMessage)=="object" && returnMessage.length ? returnMessage[1] : 0;
						returnMessage = typeof(returnMessage)=="object" && returnMessage.length ? returnMessage[0] : returnMessage;
						if (returnMessage==false || typeof(returnMessage)=="string") { //si message erreur ou index de tableau associatif
							hasError=true;
							if (x.getAttribute(validOptions[j]+"_em")!=null) { //si le champ possede un message personnalis&eacute; pour l'erreur alors on affihce
								finalErrorMessage=x.getAttribute(validOptions[j]+"_em");
							} else { //sinon
								if (typeof(returnMessage)=="string") { //si le message d'erreur est un index de tableau associatif
									finalErrorMessage=formval.errorMessages[validOptions[j]][returnMessage]; //on va chercher le message associ&eacute; &agrave; cet index
								} else {
									if (formval.errorMessages[validOptions[j]] && typeof(formval.errorMessages[validOptions[j]])=="string") { //si le message d'error est false
										finalErrorMessage=formval.errorMessages[validOptions[j]]; //alors on retourne le message d'erreur associ&eacute;
										if (quantity>0) finalErrorMessage=finalErrorMessage.replace(/\#\#/g,quantity);
									}
									else finalErrorMessage=formval.defaultErrorMessage; //sinon on affiche le message d'erreur par d&eacute;faut pour tout champ
								}
							}
						} else {
							formval.clearMessage(x);
						}
					}
				}
				if (finalErrorMessage!="") formval.showMessage(x, finalErrorMessage);
			}
		}
		document.body.scrollTop=scrollTop;
		var secondErrorValue=false;
		if (otherReturnValues!=null) {
			if(typeof(otherReturnValues)=="boolean") {
				secondErrorValue=!otherReturnValues;
			} else {
				for (var i=0; i<otherReturnValues.length; i++) {
					if (!otherReturnValues[i]) secondErrorValue = true;
				}
			}
		}

		hasError = hasError || secondErrorValue;
		if (showOnlyOneMessage) {
			if (showOnlyOneMessage==true) {
				elm = null;
			} else {
				var elm = document.getElementById(showOnlyOneMessage);
			}
			if (hasError) {
				//elm.className+=" errorAlertShow";
				alert(formval.globalErrorMsg);
			} else {
				if (elm) elm.className=elm.className.replace(/\berrorAlertShow\b/g,"");
			}
		}
		formval.callbackfunctions();
		return (!hasError); //return true si aucune erreur sinon false;
	},
	checkIfErrorMessageBefore:function(field) {
		var node = field;
		var i=0;
		while(node.previousSibling && i<=2) {
			if (node.nodeType==1 && node.className.match(/\berrormsg\b/))
				return node;
			node=node.previousSibling;
			i++;
		}
		return null;
	},
	clearMessage:function(field) {
		if (field.getAttribute("typemessage") && field.getAttribute("typemessage")=="aspect") {
			if (field.getAttribute("rel") && field.getAttribute("rel")!="") {
				var elm = document.getElementById(field.getAttribute("rel"));
				elm.className = elm.className.replace(/\berror\b/g,"");
			}
		} else {
			if (field.associatedErrorMessage) {
				field.associatedErrorMessage.style.display="none";
			}
		}
	},
	insertAfter:function(parent, nodeToInsert, nodeInDom) {
		var node = parent.insertBefore(nodeToInsert, nodeInDom);
		parent.insertBefore(nodeInDom, nodeToInsert);
		return nodeToInsert;
	},
	showMessage:function(field, msg) {
		formval.globalErrorMsg += "- " + msg + "\n";
		if (field.getAttribute("typemessage") && field.getAttribute("typemessage")=="aspect") {
			if (field.getAttribute("rel") && field.getAttribute("rel")!="") {
				var elm = document.getElementById(field.getAttribute("rel"));
				elm.className+=" error";
			}
		} else {
			if (!field.associatedErrorMessage) {
				if (!formval.checkIfErrorMessageBefore(field)) {
					var pos = formval.getMessagePosition(field);
					var parentField = $n.parent(field, formval.lineInput);
					if (parentField.nodeName == "TD") {
						var msgField = parentField.appendChild(document.createElement("span"));
					} else {
						var msgField = formval.insertAfter(parentField.parentNode, document.createElement("span"), parentField);
					}
					msgField.className="errormsg";
					field.associatedErrorMessage=msgField;
				} else {
					field.associatedErrorMessage = formval.checkIfErrorMessageBefore(field);
				}
			}
			field.associatedErrorMessage.innerHTML=msg;
			field.associatedErrorMessage.style.display="";
			//<span class="errormsg">Attention, ce champ est obligatoire</span>
		}
	}
}
//function addValid() {
/*
	addValid("champemail", { validation : "required email", email_em : "Cette email n'est pas bon", type_message : aspect};
	addValid("champ", { validation : "required"};
*/
function addValid(inputId, validationAttr, attributes) {
	attributes.validation = validationAttr;
	var inp = document.getElementById(inputId);
	if (!inp) return;
	for (var i in attributes) {
		inp.setAttribute(i,attributes[i]);
	}
}


function enableDisableInput(selectCaller, selectDestId) {
	var selectDest = document.getElementById(selectDestId);
	if (!selectDest.filterInitialized) {
		selectDest.savedOptions = [];
		while(selectDest.options.length>2)
			selectDest.savedOptions.push(selectDest.removeChild(selectDest.options[1]));
		selectDest.filterInitialized = true;
	}
	while(selectDest.options.length>2)
			selectDest.removeChild(selectDest.options[1]);
	
	if (selectCaller.value.match(/^(42|34|64)$/)) {
		selectDest.disabled = '';
		selectDest.savedOptions.each(function(option) {
			if (
				(selectCaller.value=='42' && option.className=="stateCAN") ||
				(selectCaller.value=='34' && option.className=="stateBRA") ||
				(selectCaller.value=='64' && option.className=="stateUSA") 
			) {
				selectDest.appendChild(option);
			}
		});
		
	} else {
		selectDest.disabled = 'disabled';
	}
}


function filterAdresseMag(sel) {
	var bigBlock = $('theBigBlock');
	bigBlock.style.display = sel.selectedIndex==0 ?  'none' : '';
	for (var i=0; i<sel.options.length; i++) {
		var opt = sel.options[i];
		if (opt.className) {
			var div = $(opt.className);
			div.style.display = opt.selected ? '' : 'none';
		}
	}
}


/* gencode functions */
function openGenCodeWindow(link, gencodeInputId) {
	window.open(link, 'gencodepopup', 'width=600, height=500, scrollbars=yes, menubars=no');
	window.gencodeInput = $(gencodeInputId);
}
var genCodeSelect = {
	init : function(array) {
		var table = array.nodeName=='TABLE' ? array : array.getElementsByTagName('table')[0];
		for (var i=0; i<table.tBodies[0].rows.length; i++) {
			var r = table.tBodies[0].rows[i];
			r.onclick = genCodeSelect.getGenCode;
		}
	},
	
	getGenCode :  function() {
		var genCode = $n.node(this, {nodeName:'td', className:'genCode'});
		window.opener.gencodeInput.value = genCode.textContent || genCode.innerText;
		window.close();
	}
}


function popup(page, args) {
	window.open(page, "popup", args);
}


/* Calendar : classe calendrier
	@fonctionnement : 
		Cette classe ne fait qu'initialiser un objet calendrier
			var calendar = new Calendar(options); //option est une hashmap d'options
		Si on souhaite l'afficher par rapport à¡µn element
			calendar.show(elm); //element
	
		//on peut cumuler la creation du calendrier et son affichage
		new Calendar().show('truc');
	
	@TODO : 
		- gerer l'ê­©ment parent du calendrier (#page par exemple ou document.body par defaut)
		- lors du show, il faut gerer si aucun element est passé¡¥n parametre, si le cas se produit, il faudrait gerer un affichage par coordonnees
		- si gestion modules, il faudra : 
			- gerer l'ajout d'event, 
			- la fonction initDate pour gerer d'autres cas
			- modifier generate pour qu'il execute des fonctions sur la string html (pas urgent)
		- URGENT : gerer le sourceField, (utiliser le destField quand pas de sourceField en se basant sur le masque surtout) le champ depuis lequel on recupere la date pour initialiser le calendrier
*/
var Calendar = function(daysNames, monthsNames, fermer) {
	this.options = {
		defaultClassName : 'calendar',
		daysNames : daysNames,
		monthsNames : monthsNames,
		dateMask : 'DD/MM/YYYY',
		templateCal : [
			'<div class="closeBtnContainer"><a href="#" class="closeBtn">'+fermer+'</a></div>',
			'__HEADER__',
			'<div class="calendarTable">',
				'<table>',
					'<thead>',
						'<tr>',
							'__DAYSNAME__',  // <th>MON</th> //entete des jours
						'</tr>',
					'</thead>',
					'<tbody>',
						'__DAYS__', //generation des jours du calendrier ici
					'</tbody>',
				'</table>',
			'</div>',
			'<div class="calendar_footer"></div>'
			].join('\n'),
		templateDay : [
			'<td class="day __CLASSNAME__" date="__NUM__,__MONTH__,__YEAR__">',
				'<a href="#">__NUM__</a>',
			'</td>'
			].join('\n'),
		templateDayName : '<th>__FIRSTLETTER__</th>',  // __DAY__
		templateHeader : [
			'<div class="calendarHeader">',
				'<a href="" class="previousBtn">&lt;&lt;</a>',
				'<a href="" class="nextBtn">&gt;&gt;</a>',
				'<div class="dayTitle">',
					'__MONTH__ __YEAR__', //__DAYNAME__ __DATE__ 
				'</div>',
			'</div>'
		].join('\n'),
		firstWeekDay : 1 //premier jour de la semaine : dim=0, lun=1, mar=2....sam=6
	};
	this.dom = {}; //objet contenant les references aux elements du dom
	this.days = {}, //objet contenant des informations sur les jours (important pour la generation du calendrier)
	this.initialize.apply(this, arguments);
};
Calendar.prototype = {
	initialize : function(options) {
		this.setOptions(options);
		if (!this.options.firstWeekDay) this.options.firstWeekDay = 0;
		// pas besoin de faire quelque chose en plus ici
	},
	
	/* show : affiche le calendrier et le genere s'il n'a jamais ete genere
			@params :
				- elm : element par rapport auquel le calendrier va s'affichier
	*/
	show : function(element, options) {
		var _self = this;
		
		this.setOptions(options);
		
		if (this.options.destField) 
			this.options.destField = this.z.$(this.options.destField);
		
		this.dom.element = this.z.$(element);
		if (this.dom.element.calendarIsOpen) 
			return;
		this.dom.element.calendarIsOpen = true;
		
		//creation div conteneur
		var d = document.createElement('div');
		d.style.visibility = 'hidden';
		d.className = this.options.defaultClassName + ' ' + (this.options.className || '');
		document.body.appendChild(d);
		this.z.addEvent(d, 'click', function(e) {
			_self.z.stopEvent(e);
			_self.eventsManager(e);
		}, true);
		this.z.each(['mouseover', 'mouseout','focus', 'blur'], function(evt) {
			_self.z.addEvent(d, evt, function(e) {
				_self.eventsManager(e);
			});
		})
		this.dom.calendar = d;
		
		
		/* event sur document */
		setTimeout(function() { 
			if (!document.CalendarClickCloseEvents) {
				document.CalendarClickCloseEvents = [];
				_self.z.addEvent(document, 'click', function(e) {
					_self.documentClick(e);
				});
			}
			document.CalendarClickCloseEvents.push(function() { _self.close(); })
		},500);
		
		
		
		var date = this.options.destField ? this.getDateFromStr(this.options.destField.value) : null;
		
		// generer le calendrier
		this.generate(date);
		//afficher
		this.dom.calendar.style.visibility = 'visible';
		this.setPosition();
	},
	
	close : function(fromDocument) {
		if (!fromDocument) this.documentClick();
		if (this.dom.calendar) {
			this.z.remove(this.dom.calendar);
			this.dom.calendar = null;
		}
		this.dom.element.calendarIsOpen = null;
		if (this.iframe) {
			this.iframe.parentNode.removeChild(this.iframe);
			this.iframe = null;
		}
	},
	
	documentClick : function() {
		while(document.CalendarClickCloseEvents.length>0) {
			document.CalendarClickCloseEvents.pop()(true);
		}
	},
	
	/* generate : genere le calendrier 
			generer les tableau et le header du tableau
	*/
	generate : function(date) {
		date = date || new Date();
		
		var str = this.options.templateCal;
		this.initDates(date);
			
		
		/* entete du calendrier */
		str = str.replace(/__HEADER__/,
			this.options.templateHeader.replace(/__DAYNAME__/, this.options.daysNames[this.getWeekDayIndex(date.getDay())])
			.replace(/__DATE__/,date.getDate())
			.replace(/__MONTH__/, this.options.monthsNames[date.getMonth()])
			.replace(/__YEAR__/, date.getFullYear())
		);
		
		/* entete des jours */
		str = str.replace(/__DAYSNAME__/, this.getDaysName());
		
		var d = new Date(this.days.firstMonthDate);
		d.setDate(d.getDate()-this.getWeekDayIndex(d));
		
		var lines = [];
		for (var i=1; i<=6; i++) { //lignes (6 lignes max par mois)
			var days = [];
			for (var j=1; j<=7; j++) { //colonnes
				var num = d.getDate();
				var month = d.getMonth();
				var year = d.getYear();
				var className = '';
				// gestion des classes du jour
				if(month<date.getMonth()) // mois precedent
					className += ' previousMonth';
				if(month>date.getMonth())  //mois suivant
					className += ' nextMonth';
				else {  //mois precedent
					if(num==date.getDate() && month==date.getMonth())  
						className += ' currentDay';
					if(num==this.days.today.getDate() && month==this.days.today.getMonth() && year==this.days.today.getYear()) {
						className += ' today';
					}
				}
				days.push(this.options.templateDay.replace(/__CLASSNAME__/g,className)
										.replace(/__NUM__/g,num)
										.replace(/__MONTH__/g,month)
										.replace(/__YEAR__/g,d.getFullYear()));
				d.setDate(d.getDate()+1);
			}
			lines.push(days.join('\n'));
		//	if(d.getMonth()>date.getMonth()) break;
		}
		str =  str.replace(/__DAYS__/,'<tr>'+lines.join('</tr>\n<tr>')+'</tr>');;

		/* cleanage du template */
		str = str.replace(/href=\"#?\"/g, 'href="javascript:;"'); //remplacement des href="#" ou href="" par un href qui ne mene nullepart afin de ne pas avoir de surprise lors du clic
	
		this.dom.calendar.innerHTML = str;
	
	},
	
	eventsManager : function(e) {
		var _self = this;
		var event = e || window.event;
		var target = event.target || event.srcElement;
		var eventType = event.type;
		function doActions(target) {
			_self.z.each(target.className.split(/\s+/), function(clN) {
				if (_self.eventsClass[eventType] && _self.eventsClass[eventType][clN]) {
					_self.eventsClass[eventType][clN].call(_self, target, event);
					actionsDones++;
				}
			})
		}
	
		// premier on attaque la target
		var actionsDones = 0;
		doActions(target);
		
		// si aucune action n'a ete effectue, on va chercher le parent avec un className sur lequel l'action aurait du etre faite (cas d'un element span dans le TD par exemple)
		if (actionsDones==0 &&  target!=this.dom.calendar) {
			do { 
				target = target.parentNode;
			} while(target.className.match(/^\s*$/) && target!=this.dom.calendar)
			if (target!=this.dom.calendar) {
				doActions(target);
			}
		}
		
	},
	
	
	/* eventsClass : 
			objet contenant tous les evenement appliques sur le calendrier selon le type
			une action est associe a une classe
			Il ne peut pas y avoir 2 classes du meme nom sur 2 objets qui ont un comportement different
			ex : 
				pour <td class="day">, j'ai l'index 'day' associe dans l'objet eventsClass.click et eventsClass.mouseover
				
			chaque fonction accepte comme parametre : 
				elm : element sur lequel se passe l'event
				event : evenement 
			
			le this correspond au calendrier
	*/
	
	eventsClass : {
		click : {
			'day' : function(elm) {
				var date = elm.getAttribute('date').split(',');
				if (this.options.destField) {
					this.options.destField.value = this.getFormatedDate(date[0],parseInt(date[1])+1,date[2]);
				}
				this.close();
			},
			'previousBtn' : function(elm) {
				this.goMonth(-1);
			},
			'nextBtn' : function(elm) {
				this.goMonth(1);
			},
			'closeBtn' : function(elm) {
				this.close();
			}
		},
		mouseover : {
			'day' : function(elm) {
				elm.className += ' dayHover';
			}
		},
		mouseout : {
			'day' : function(elm) {
				elm.className = elm.className.replace(/dayHover/g, '')
			}
		}
	},
	
	goMonth : function(sens) {
		var d = new Date(this.days.currentDate);
		d.setMonth(d.getMonth()+sens);
		this.generate(d);
	},
	
	/* getDaysName : 
		retourne une lise des noms des jours 
	*/
	getDaysName : function() {
		var _self = this;
		var days = []; 
		
		this.z.each(this.options.daysNames, function(name, index) {
			index = _self.getWeekDayIndex(index);
			days[index] = _self.options.templateDayName.replace(/__DAY__/g, name)
									.replace(/__FIRSTLETTER__/, name.substr(0,1).toUpperCase());
		});
		return days.join('');
	},
	
	/* initDates : intialise les jours
			Permet de recuperer certains jours importants (jours interdits (si modules), premier jour du mois....)
	*/
	initDates : function(date) {
		var td = this.days;
		td.currentDate = date;
		td.today = new Date();
		td.firstMonthDate = new Date(date);
		td.firstMonthDate.setDate(1);
	},

	/* getWeekDayIndex :
			Retourne l'index du jour en fonction du jour de debut de semaine qui a ete defini dans les options
	 */
	getWeekDayIndex : function(date) {
		var num = (date.constructor==Date ? date.getDay()  : date) - this.options.firstWeekDay;
		return num>=0 ? num : 7+num;
	},
	
	
	/* getFormatedDate :
			Retourne une date formatee (string) selon le template en lui passant une date ou les 3 valeurs de la date en parametre
	 */
	getFormatedDate : function(/*date or day, month, year */) {
		var args = arguments;
		if (args.length==3)
			var date = new Date(parseInt(args[2],10), parseInt(args[1],10)-1, parseInt(args[0]));
		else 
			var date = args[0];
			
		return this.options.dateMask.replace(/YYYY/g, date.getFullYear())
							.replace(/MM/g, this.getZero(date.getMonth()+1))
							.replace(/DD/g, this.getZero(date.getDate()))
							.replace(/ww/gi, this.options.daysNames[date.getDay()]);
	},
	
	/* getDateFromStr :
			Retourne une date depuis une chaine de caractere en fonction du mask de date
	 */
	getDateFromStr : function(str) {
		var mask = '^(' + this.options.dateMask.replace(/\W+/g, ').*(').replace(/[A-Z]/g,'\\d') + ')$';
		var maskStr = this.options.dateMask.replace(/\W+/g,'');
		var d = str.match(new RegExp(mask));
		
		if (!d) return null;
		
		var dayPos = maskStr.indexOf('DD');
		var monthPos = maskStr.indexOf('MM');
		var yearPos = maskStr.indexOf('YY');

		var day = dayPos<monthPos ? (dayPos<yearPos ? d[1] : d[2]) : (dayPos<yearPos ? d[2] : d[3]);
		var month = monthPos<yearPos ? (monthPos<dayPos ? d[1] : d[2]) : (monthPos<dayPos ? d[2] : d[3]);
		var year = yearPos<monthPos ? (yearPos<dayPos ? d[1] : d[2]) : (monthPos<dayPos ? d[2] : d[3]);
		if (day>31|| month>12) return null;
		else return new Date(year, month-1, day);
	},
	
	/* setPosition : 
		positionne le calendrier en fonction des parametres passes, par defaut il se positionne par rapport a l'element qui aura ete clique
	*/
	setPosition : function() {
		if (this.dom.element) {
			var pos = this.z.getPosition(this.dom.element, true);
			with(this.dom.calendar.style) {
				left = document.documentElement.scrollLeft + pos.x + 'px';
				top = document.documentElement.scrollTop + (pos.y + this.dom.element.offsetHeight) + 2 +  'px';
			}
		}
		if (document.all && !this.iframe) {
			this.iframe = document.createElement('<iframe src="about:blank;" style="position:absolute;filter:alpha(opacity=0); top:0;"></iframe>');
			document.body.appendChild(this.iframe);
			var cs = this.dom.calendar.style;
			with(this.iframe.style) {
				left = cs.left;
				top = cs.top;
				width = this.dom.calendar.offsetWidth + 'px';
				height = this.dom.calendar.offsetHeight + 'px';
				zIndex = this.dom.calendar.currentStyle.zIndex-1;
			}
		}
	},
	
	/* setOptions : initialize les options de l'objet en fonction des options passees en parametres */
	setOptions : function(options) {
		if (!this.options) this.options = {};
		if (options==null) return;
		for (var i in options) this.options[i] = options[i];
		return this;
	},
	
	getZero  : function(num) {
		return num<10 ? '0'+num : num;
	},
	
	
	/* Dom and current library functions
			Si vous voulez reduire la taille du calendrier, il faut modifier les fonctions ici, ce sont des fonctions generiques qu'on retrouve dans la plupart des libraries (mootools, prototype)
	*/
	z : {
		$ : function(id) {
			return typeof(id)=='string' ? document.getElementById(id) : id;
		},
		//simule le each/forEach sur array
		each : function(array, fun) {
			var len = array.length;
			for (var i = 0; i < len; i++) {
				  if (i in array)
					fun.call(array, array[i], i, array);
				}
			return array;
		},
		
		addEvent : function(obj, type, fn, useCapture) {
			if (obj.addEventListener)
				obj.addEventListener( type, fn, useCapture || false);
			else if (obj.attachEvent)
			{
				obj["e"+type+fn] = fn;
				obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
				obj.attachEvent( "on"+type, obj[type+fn] );
			}
		},
		
		stopEvent : 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
		},
		
		getPosition : function(obj, overflown) {
			var curleft = 0,
				 curtop = 0;
			if (obj.offsetParent) {
				do {
					curleft += obj.offsetLeft + (overflown ? -obj.scrollLeft : 0) ;
					curtop += obj.offsetTop + (overflown ? -obj.scrollTop : 0) ;
				} while (obj = obj.offsetParent);
				return {x:curleft,y:curtop};
			}
		},
		
		remove : function(elm) {
			return elm.parentNode.removeChild(elm);
		}
	}
}

function showHide(blockId) {
	var block = document.getElementById(blockId);
	block.style.display = block.offsetHeight>0 ? 'none' : '';
}

function setProductPosition(){
	var aParent = $('scroll').getElements('div.posRelative');
	if (aParent.length==0) return;
	var oDiv = new Element('div',{'class':'productName',styles:{'display':'none'}});
	$(document.body).adopt(oDiv);
	aParent.each(function(oElem,i){
		var aProducts = oElem.getElements('a.produits');
		var oParentPos = oElem.getCoordinates();
		aProducts.each(function(oProd,j){
			var oSpan;
			var oImg = oProd.getElement('img');
			oImg.addEvent('mouseenter',(function(oImg){
				return function(e){
					e = new Event(e); e.stop();
					var oPos = oImg.getCoordinates();
					//oDiv.set({html:oSpan.get('html')});
					oSpan = oProd.getElement('span').clone();
					oDiv.adopt(oSpan);
					oDiv.setStyles({
						'top':oPos.top-oElem.getStyle('margin-top').toInt(),
						'left':oPos.left
					});
					oDiv.setStyle('display','');
				}
			})(oImg));
			
			oImg.addEvent('mouseleave',(function(oImg){
				return function(e){
					e = new Event(e); e.stop();
					oSpan.destroy();
					div.setStyle('display','none');
				}
			})(oImg));
		});
	});
}

function linkLayerHome(){
	var aNode = $$('#zoneFlash .layerHome a')[0];
	if (!aNode) return;
	var i=0;
	var links = $$('#zoneFlash .imagelien a');
	setInterval(function(){
		aNode.href = links[i].href;
		aNode.set('title',links[i].get('title'));
		aNode.set('target',links[i].get('target'));
		if (i == 2){
			i=0;
		}else{
			i++;
		}
	}, 5000)
}

$e.add('domready', function() {
	generateElements();
});
$e.add(window, 'load', function() {
	inputIncrement.init();
	navLeft.init('navG');
	sizeBlocks();
	linkLayerHome();
	if($('scroll'))	setProductPosition();
}); 

/* others pages functions */
function checkDiagForm(theForm, nbrQ, msgErr){
	var nbrChecked = 0;
	for(cpt=0;cpt<nbrQ;cpt++){
		if(!theForm.choice[cpt].checked)
			nbrChecked++;
	}
	if(nbrChecked != nbrQ)
		return true;
	else{
		document.getElementById('msgErr').innerHTML = '<span style="color:#FF0000; margin-left:60px;">'+msgErr+'</span>';
		return false;
	}
}


/*Initialiser l'event listener blurOnFocus sur Chaque input de type increments au chargement du dom*/
window.addEvent('domready', blurOnFocus);



/* Blur Certains Champs Input  class="typeIncrements" apres l'evenement OnFocus*/
function blurOnFocus(){

	if($$('input.typeIncrement')){
		var blurInputs = $$('input.typeIncrement');

		for (i=0; i<blurInputs.length; i++){
			blurInputs[i].addEvent('focus', function(){
			
				blur();
			});
		}
	}
}


