/* inputValue : function 
	Permet de mettre le texte par defaut d'un champ de type texte.
*/ 
function inputValue(elm, state) {
	elm.oldValue=elm.value;
	elm.onfocus=function() {
		if (!this.isChecking && this.value==this.oldValue) this.value='';			
	}
	elm.onblur=function() {
		if(this.value=='') this.value=this.oldValue;
	}
	if (!elm.isChecking) elm.onfocus();
}

function forceCheck(elm, linkedInput) {
	linkedInput = typeof linkedInput=="string" ? document.getElementById(linkedInput) : linkedInput;
	linkedInput.checked = elm.checked;
}


/**********
* Navigation
**********/
var navigation = {
	init : function() {
		var nav = document.getElementById("menu");
		if (!nav) return;
		var ul = getNode(nav, {nodeName:"ul"});
		var lis = getChildNodes(ul, {nodeName:"li"});
		lis.each(function(li) {
			var a = getNode(li, {nodeName:"a"});
			a.lis = lis;
			a.onclick = function() {
				navigation.changeTab(this);
				return false;
			}
		});
	},
	changeTab : function(elm) {
		var lis = elm.lis;
		var current = getParent(elm, {nodeName:"li"});
		lis.each(function(li) {
			removeClass(li, "current");
			if (li==current) 
				addClass(li, "current");
		});
	}
}
/* generates corners and others elements if needed */
function generateElements(parent) {
	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("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));
	};
	
	function addFirst(x, c) {
		var i=0; if (!x) return; 
		x.insertBefore(c.cloneNode(true),x.firstChild);
	};
	
	//-- creation des elements qui seronts clones --
	var corners = [nc("tl"), nc("tr"), nc("bl"), 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
	var topCorners = nc("top"); add(topCorners, nc("topIsd"));
	var bottomCorners = nc("bottom"); add(bottomCorners, nc("bottomIsd"));
	
	// -- 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(/\bblock\b/)) //block par defaut
				add(getIsd(x), corners);
			if(x.className.match(/\bblockOutsideCorners\b/)){
				addFirst(x,topCorners);
				add(x,bottomCorners);
			}
			x.alreadyProcessed = true;	
			initOtherBlocks(x); // fonction d'initialisation d'autres blocks
		}
	}
	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 (x.className.match(/\bblockTabs(Sub)?\b/)) //block d'onglets en general (gere tous types d'onglets).
		tabs.init(x);
	if (x.className.indexOf("blockToggle")!=-1) //block ouvert/ferme
		toggleBlock.init(x);
	if (x.className.indexOf("scrollH")!=-1)  //block de scroll horizontal
		scroll.init(x);
	if (x.className.match(/\bline\b/)) //si ligne de block, on la stocke dans un tableau
		linesOfBlocks.push(x);
}




 /******* 
* Tabs
 *******/
var tabs = {
	init : function(elm) {
		var ul = getNode(elm, {nodeName:"ul"});
		if (!ul) return;
		var a = ul.getElementsByTagName("a");
		for (var i=0; i<a.length; i++) {
			if (!hasAttributes(a[i], {className:"nochange"}))  {
				a[i].onclick = function() {
					tabs.change(this);
					return false;
				}
			}
			tabs.size(a[i], ul);
		}
	},
	size : function(a, ul) {
		var newSize =  a.offsetHeight + (ul.offsetHeight-a.offsetHeight) - getVStyles(a);
		a.style[heightPropertyToUse] = (newSize<0) ? 0 : newSize + "px"; //IE doesn't compute size under 0
	},
	change : function(elm) {
		var i, n, tabs, ul, li, body, tabCtns, current=0, block;
		ul = getParent(elm, {nodeName:"ul", className:"tabs(Big|Sub)?"});
		li = getParent(elm, {nodeName:"li"});
		tabs = ul.getElementsByTagName("li");
		block = getParent(ul, {nodeName:"div", className:"blockTabs(Sub)?"});
		// get What is the index of the new Tab and remove otherClass "current"
		for (i=0; i<tabs.length; i++) {
			if (tabs[i]==li) {
				current = i;
				addClass(li, "current");
			} else 
				removeClass(tabs[i], "current");
		}
		//get the tabCtn blocks, and show the contentTab that is match with clicked tab
		body = getNode(block, {nodeName:"div", className:"body"});
		tabCtns = getChildNodes(body, {nodeName:"div", className:"tabCtn"});
		for (i=0; i<tabs.length; i++) {
			n = tabCtns[i];
			removeClass(n, "tabCurrent");
			if (i==current) {
				addClass(n ,"tabCurrent");
			}
		}
		fixHeights(block); fixCorners(); fixColumns();
	}
}

/*********
* ToggleBlock :  block qui s'ouvre et qui se ferme
**********/
var toggleBlock = {
	init : function(elm) {
		var head = getNode(elm, {className:"head"});
		if (head) 
			var a = getNode(head, {nodeName:"a"});
			if (a)
				if (!a.className.match(/\bnochange\b/)) {
					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"});
		window[(hasAttributes(block, {className:"toggleClosed"}) ? "remove" : "add")+"Class"](block, "toggleClosed"); //addClass or RemoveClass
		fixHeights(block); fixCorners(); fixColumns();
		document.body.scrollTop = scrollTop;
	}
};


/******** 
* Scroll
**********/
var scroll = {
	time : 20,
	increment : 4,
	// initialise les blocks de scrolling en rajoutant les fonctions sur les boutons, ainsi qu'en alignant ce qui doit etre aligne
	init : function(elm) {
		var left, right, scrollIsd, scrollCtn, totalWidth = 0;
		left = getNode(elm, {className:"scrollLeft"});
		right = getNode(elm, {className:"scrollRight"});
		elm.scrollIsd = getNode(elm, {className:"scrollIsd"});
		function initButton(btn, sens) {
			btn.onmouseover = function() { scroll.scrollH(this, sens); };
			btn.onmouseout = function() { scroll.stop(this); };
		};
		initButton(left, -1);
		initButton(right, 1);
		function init() {scroll.initButtonsPosition(elm,[left,right]);};
		init();
		addOnLoadFunc(function() {
			init();
			scroll.sizeHContent(elm);
		})
	},
	// centre verticalement les boutons de scrolling
	initButtonsPosition : function(elm, arrElms) {
		removeClass(document.documentElement, 'hasJS');
		arrElms.each(function(btn) {
			if (btn) {
				btn.style.marginTop = (elm.offsetHeight-btn.offsetHeight)/2+"px";
				if (elm.scrollIsd.scrollWidth>elm.scrollIsd.offsetWidth) 
					btn.style.visibility = "visible";
			}
		});
		addClass(document.documentElement, 'hasJS');
		
	},
	//resize les contenus horizontaux, cela permet d'afficher les produits correctement sans qu'aucun ne soit coupe à l'affichage.
	sizeHContent : function(elm) {
		scroll.getScrollElm(elm, "scrollH");
		if (!elm.scrollElm) return;
		var prods = getNode(elm, {nodeName:"table", className:"prods"}); //on recupere le tableau de produits
		if (!prods || elm.scrollElm.scrollWidth<=elm.scrollElm.offsetWidth) return;
		
		if (prods.rows[0]) {
			var tds = prods.rows[0].cells;
		}
		var width=0, paddings=0, td, sumWidth=0;
		//on recupere le nombre maximum de produits qu'on peut afficher, on recupere aussi les paddings sur les TD 
		//et on joue avec les paddings pour reduire ou augmenter la largeur entre les produits
		for (var i=0; i<tds.length; i++) { 
			td = tds[i]	
			width+=td.offsetWidth;
			paddings += intStyle(td, "padding-left")+intStyle(td, "padding-right");
			if (width>elm.scrollElm.offsetWidth) break;
		}
		var lastProd = td;
		if (width-elm.scrollElm.offsetWidth>=lastProd.offsetWidth) return;
		var paddingsMin = 5*2*(i+1); //on calcule les paddings minimum qu'on peut accepter pour reduire les paddings afin d'afficher le dernier element qui est coupe
		var numberOfProductsToShow = (paddingsMin>=width-elm.scrollElm.offsetWidth) ? i+1 : i;
		for (var i=0; i<numberOfProductsToShow; i++) { 
			var td = tds[i];
			sumWidth += td.offsetWidth-intStyle(td, "padding-left")-intStyle(td, "padding-right");
		}
		var newPaddings = parseInt(((elm.scrollElm.offsetWidth-sumWidth)/numberOfProductsToShow)/2);
		var moduloPaddings = (elm.scrollElm.offsetWidth-sumWidth)%numberOfProductsToShow;
		for (var i=0; i<tds.length; i++) {
			var td=tds[i];
			td.style.paddingLeft = newPaddings + "px";
			td.style.paddingRight = newPaddings + (i<moduloPaddings ? 1 : 0) + "px";
		}
	},
	//scrollH() : fonction de scrolling (elle se rappelle elle meme, elle est initiee sur l'evenement onmouseover d'un bouton
	scrollH : function(elm, sens) {
		scroll.getScrollElm(elm, "scrollH");
		elm.scrollElm.scrollLeft += scroll.increment * sens;
		elm.scrollElm.scrollTimer = setTimeout(function() {scroll.scrollH(elm, sens)}, scroll.time);
	},
	getScrollElm : function(elm, className) {
		if (!elm.scrollElm) {
			var par = getParent(elm, {nodeName:"div", className:className});
			elm.scrollElm = getNode(par, {className:"scrollIsd"});
		}
	},
	//scrollStop() : stop le scrolling en se basant sur le timer accroche au block qui scrolle.
	stop : function(elm) {
		if (elm.scrollElm) 
			clearTimeout(elm.scrollElm.scrollTimer);
	}
};

/**************
* sizeBlocks : alignement des blocks en hauteurs
**************/
var linesOfBlocks=[];
function sizeBlocks(parentBlock) {
	function size(block, size){
		if (block){
			var body = block.className.match(/\bblock\b/) ? getNode(block, {nodeName:"div", className:"body"}) : block; //si on a une line ou bien un block
			if (body) body.style[heightPropertyToUse] = body.offsetHeight + size - getVStyles(body) + "px";
		}
	};
	linesOfBlocks.eachInv(function (line) { //les lignes fournies sont
		var units = getChildNodes(line, {className:"unit"});
		units.each(function(unit) {
			var blocks = getChildNodes(unit, {className:"(block|line)"}, {className:"(noresize|blockTabs)"});
			var sizeToApply = line.offsetHeight-unit.offsetHeight;
			var sizePerBlock = parseInt(sizeToApply/blocks.length);
			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.offsetHeight-unit.offsetHeight);
		});
	});
}

/**************
* sizeContent : alignement 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 - getVStyles(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();
		});
	});
}

/************
* listMenu
*************/
var listMenu = {
	currentMenu : null,
	currentLink : null,
	init : function() {
		var ul = getNodes(document, {nodeName:"ul", className:"listMenu"});
		ul.eachInv(listMenu.transform);
	},
	transform : function(menu) {
		var ul = getNodes(menu, "ul");
		ul.each(function(ul) {ul.className="";});
		var className = menu.className;
		menu.className = "";
		var a = getNode(menu, "a");
		if (menu.getAttribute("title")) {
			var str = menu.getAttribute("title");
		} else {
			var str = a ? a.innerHTML : "";
		}
		menu.title="";
		/* creation bouton */
		var btn = document.createElement("a");
		btn.innerHTML = "<strong><span><span>"+str+"</span></span></strong>";
		btn.href="javascript:;";
		addClass(btn, "listMenuLink");
		btn = menu.parentNode.insertBefore(btn, menu);
		addEvent(btn, "click", cancelBubble);
		btn.onclick = listMenu.open;
		//creation du menu
		btn.menu = document.createElement("div");
		btn.menu.className = "listMenu";
		btn.menu.appendChild(menu);
		//on place le bouton dans un ul pour lui donner le style qu'il doit avoir par defaut.
		var ul = document.createElement("ul");
		ul.className = className;
		toggleClass(ul, "listMenu", "listMenuCtn");
		btn.parentNode.insertBefore(ul, btn);
		var li = ul.appendChild(document.createElement("li"));
		li.appendChild(btn);
	},
	open : function() {
		if (listMenu.currentMenu && this==listMenu.currentLink) {
			listMenu.close();
		} else {
			listMenu.currentLink = this;
			setTimeout(function() {addEvent(document, "click", listMenu.close)}, 20);
			listMenu.close();
			var container = document.getElementById("page") || document.getElementById("pageBol");
			var menu = container.appendChild(this.menu.cloneNode(true));
			listMenu.resize(menu, this, container);
			listMenu.position(menu, this, container);
			listMenu.currentMenu = menu;
			var a = getNode(menu, "a");
			if (a) a.focus(); //put the focus on the first link cause accessibility
			ifrlayer.make(menu);
		}
		return false;
	},
	close : function() {
		if (listMenu.currentMenu) {
			listMenu.currentMenu.parentNode.removeChild(listMenu.currentMenu);
			ifrlayer.kill(listMenu.currentMenu);
			delete listMenu.currentMenu;
		}
		removeEvent(document, "click", listMenu.close);
	},
	resize : function(menu, button) {
		var HStyles = getHStyles(menu);
		menu.style.width = button.offsetWidth-HStyles+"px";
		if (menu.scrollWidth>menu.offsetWidth) 
			menu.style.width = menu.scrollWidth-HStyles+"px";
	},
	position : function(menu, button, container) {
		var pos = findPos(button);
		var posPage = findPos(container);
		var newLeft = pos[0]-posPage[0];
		menu.style.left = (newLeft+menu.offsetWidth < container.offsetWidth ? newLeft : newLeft-(menu.offsetWidth-button.offsetWidth-2))+"px"; //i don't know why i must add -2
		menu.style.top = pos[1]-posPage[1]+button.offsetHeight+"px"; 
	}
}

/***************
* fixColumns()
****************/
function fixColumns() {
	function fix() {
		var colonnes = ['main','rightColumn'],
			colonnesInside = ["", ""];
		var hMax=0, i, b, minMax=0, sum=0; hToU = heightPropertyToUse;
		
		function each(f) { //fonction d'iteration
			for (i=0; i<colonnes.length; i++){
				b = $(colonnes[i]);
				f();
			}
		}
		
		each(function() {
			sum=0;
			if (b) {
				getChildNodes(b, {}).each(function() { sum+=this.offsetHeight });
				if (sum>minMax) minMax=sum;
			}
		});
		// on remet la hauteur par defaut a toutes les colonnes (hauteur minimum)
		each(function() {
			var bToSize = $(colonnesInside[i]) || b;
			if (bToSize) bToSize.style[hToU] = minMax + "px";
		});
		// on recupere la hauteur la plus grande
		each(function() {
			if (b){
				if (b.offsetHeight + intStyle(b, "margin-top") >= hMax) {
					hMax = b.offsetHeight - intStyle(b, "margin-top");
				}
			}
		});
		// on applique la nouvelle hauteur sur les colonnes
		each(function() {
			var bIsd = $(colonnesInside[i]);
			if (b && bIsd) {
				var diff = (hMax - b.offsetHeight) + bIsd.clientHeight - getVStyles(bIsd);
				bIsd.style[hToU] = diff + 'px';
			} else if (b) {
				getVStyles(b);
				b.style[hToU] = hMax  - getVStyles(b) - intStyle(b, "margin-top") + 'px';
			}
			
		});
	};
	setTimeout(fix,1);
}

/*************
* 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"></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 = getNode(pop,  {nodeName:"div", className:"popContent"});
			pop.style.marginLeft = -pop.offsetWidth/2+"px"
			var close = getNode(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 = getNode(popLayer.popContent, {nodeName:"iframe"});
				popLayer.iframe = ifr;
				ifr.src = content;
				popLayer.timeout = setTimeout(popLayer.loaded,3000);
				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) {
					addEvent(pWin, "load", function() {
						popLayer.setPosition(elm);
					})
				}
			}
		}, 10);
		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();
			from.popLayer.pop.style.visibility = "hidden";
			from.popLayer.pop.style.display = "none";
			ifrlayer.hide(from.popLayer.pop);
		};
		if (window.parent) close(window.parent);
		ifrlayer.hide(popLayer.pop);
		try {close(window);}
		catch(e){ifrlayer.hide(popLayer.pop);};
		
	},
	resize: function(width, height) {
		var doc;
		var 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();
					}();
				}
				popLayer.resize(obj.document.documentElement.scrollWidth+10, obj.document.documentElement || obj.document.body);
			} 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);
		}
		popLayer.mask.style.height = document.documentElement.scrollHeight +'px';
		popLayer.mask.style.width = document.documentElement.scrollWidth +'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";
	});
	fixHeights(field);
}

/**********
* filtrage
**********/
function filterSelect(sel, filteredSelect, elementToHideAll) {
	var val = sel.value;
	filteredSelect = document.getElementById(filteredSelect);
	filerHide(elementToHideAll);
	var options = filteredSelect.options;
	if (!filteredSelect.filteringOptions) {
		filteredSelect.filteringOptions = [];
		for (var i=0; i<options.length; i++) {
			var opt = options[i];
			if (opt.getAttribute("filter")) {
				filteredSelect.filteringOptions.push(filteredSelect.removeChild(opt));
				i--;
			}
		}
	}
	while(filteredSelect.options.length>1){
		filteredSelect.removeChild(filteredSelect.options[1]);
	}
	filteredSelect.filteringOptions.each(function(sel) {
		if (sel.getAttribute("filter")==val) {
			filteredSelect.appendChild(sel.cloneNode(true));
		}
	});
}

function filerHide(elementToHideAll) {
	if (!elementToHideAll) return;
	var elementToHideAll = typeof elementToHideAll == "string" ? document.getElementById(elementToHideAll) : elementToHideAll;
	var childs = getChildNodes(elementToHideAll);
	childs.each(function(child) {child.style.display='none'});
}

function filterHTML(sel, elementId, tagName) {
	var val = sel.value;
	if (sel.value==-1) return;
	var element = document.getElementById(elementId);
	var childs = getChildNodes(element, {nodeName:(tagName || 'div')});
	filerHide(element);
	childs.each(function(child){
		if (child.className == sel.options[sel.selectedIndex].getAttribute("filter")+ "_" + val) child.style.display="block";
	});
}


/**********
* clickable lines
*********rieGei8I*/
var clickableLine = {
	init : function() {
		var trs = document.getElementsByTagName("tr");
		for (var i=0; i<trs.length; i++) {
			var tr = trs[i];
			if (tr.className.match(/clickable/)) {
				tr.onclick = clickableLine.click;
				var a = tr.getElementsByTagName("a");
				for (var j=0; j<a.length; j++) {
					addEvent(a[j], 'click', cancelClick);
				}
				
			}
		}
	},
	click : function() {
		if (this.getAttribute("link")) {
			document.location.href = this.getAttribute("link");
		}
	}
}


var allSpecialBackgrounds = [];
function pngTrans(elm) {
	if (document.all && window.print && !window.opera && /MSIE 6/.test(navigator.userAgent)) {
		var imgurl = elm.currentStyle.backgroundImage.match(/url\([\"\'](.*)[\"\']\)/);
		
		if (imgurl) {
		
			elm.style.backgroundImage = 'none';
			var newChild = elm.appendChild(document.createElement('span'));
			newChild.className = 'bkgIESpecial';
			elm.style.position = 'relative';
			newChild.style.backgroundImage="none";
			newChild.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src='"+imgurl[1]+"')";
			newChild.style.height = elm.offsetHeight+'px';
			allSpecialBackgrounds.push(newChild);
		} else {
			elm.style.filter=" ";
		}
	} else {
		elm.style.filter=" ";
	}
}

window.addEvent('load', function() {
	allSpecialBackgrounds.each(function(elm) {
		elm.style.height = elm.parentNode.offsetHeight+'px';
	})
});

/***********
* Init
************/
//initialisation de certains elements (contenus à aligner);
contentAdd({nodeName:"ul", className:"list3cols"}, {nodeName:"div", className:"listCtn"}, 3);
contentAdd({nodeName:"ul", className:"list2cols"}, {nodeName:"div", className:"listCtn"}, 2);

//fonction lancee pendant le chargement de la page
//function domLoadFunctions() {
	//navigation.init();
	//listMenu.init();
	//maxLengthOntextarea();
	//clickableLine.init();
//}
window.addEvent('domready', function(){
	generateElements('all');
});
//fonction lancee une fois toute la page chargee
//function onLoadFunctions() {
	
	//contentSize();
	//sizeBlocks();
	//fixCorners();
	//fixHeights();
	//fixColumns();
	//oblige pour laisser au navigateur le temps de se rafraichir
//}
//window.addEvent('load',function(){

//});
