var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers && window.innerWidth ? true : false);

function getElement(id) {
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function ChangeFamille() {
	f = document.listefamille;
	famille = f.choixfamille.options[f.choixfamille.selectedIndex].value;
	window.location = "affiche_item.php?famille=" + famille + "&item=0";
}


function pageInit() {
	try {
		var menu = getElement('menu').childNodes;
		for (var i = 0; i < menu.length; i++) {
			try {
				if (menu[i].id != null) {
					var m;
					if (m = menu[i].id.match(/^menu(\d+)$/)) {
						var m2 = document.location.href.match(/^([^?]+)/);
						if (menu[i].firstChild.href == m2[1] ||
							(menu[i].firstChild.href.match(/familles_items\.php/) && document.location.href.match(/affiche_item\.php/)) ||
							(m[1] == '1' && document.location.href.match(/ignifugation-liste-produits\.htm/))) {
							if (m[1].length < 2) {
								m[1] = '0'+m[1];
							}
							menu[i].style.backgroundImage = 'url(/commun/menu/menu_'+m[1]+'_o.gif)';
							if (m[1] == '02') {
								menu[i].firstChild.style.color = 'rgb(170,0,0)';
							}
						} else {
							menu[i].onclick = menuClick;
							menu[i].onmouseover = swapMenuOn;
							menu[i].onmouseout = swapMenuOff;
						}
					}
				}
			} catch (e) {
				//alert(e.message);
			}
		}
		var m;
		if (m = document.location.href.match(/^(.+)(en|fr)(\/.+)$/)) {
			if (m[2] == 'en') {
				getElement('language').href = m[1]+'fr'+m[3];
			} else {
				getElement('language').href = m[1]+'en'+m[3];
			}
		}
	} catch (e) {
		//alert(e.message);
	}
}


function swapMenuOn() {
	var m = this.id.match(/^menu(\d+)$/);
	if (m) {
		if (m[1].length < 2) {
			m[1] = '0'+m[1];
		}
		this.style.backgroundImage = 'url(/commun/menu/menu_'+m[1]+'_o.gif)';
		if (m[1] == '02') {
			this.firstChild.style.color = 'rgb(170,0,0)';
		}
	}
}
function swapMenuOff() {
	var m = this.id.match(/^menu(\d+)$/);
	if (m) {
		if (m[1].length < 2) {
			m[1] = '0'+m[1];
		}
		this.style.backgroundImage = 'url(/commun/menu/menu_'+m[1]+'.gif)';
		if (m[1] == '02') {
			this.firstChild.style.color = 'rgb(255,255,255)';
		}
	}
}
function menuClick() {
	document.location.href = this.firstChild.href;
}


window.onload = pageInit;