function bgchg(a,b){//change le bg des menus déroulants
	//bg1 et bg2 sont définis dans les variables de configuration dans la page principale
	if(b)
		a.style.background = bg1;
	else
		a.style.background = bg2;
}
function build_catch_note(a){
	src_num='1';
	c_=document.getElementById('build_note_temp');
	b = a.parentNode.parentNode.childNodes;
	for(i=0;i<b.length;i++)
	{
		b[i].firstChild.src='..'+uri_images+'/build_point_'+src_num+'.bmp';
		//alert(b[i].src)
		b[i].firstChild.alt="#";
		if(b[i]==a.parentNode)
		{
			c_.innerHTML=(i);
			src_num='2';
		}
	}
}
function build_ico(a,b){
	temp = a.src.split('/');
	temp = temp[temp.length-1].split('.');
	for(c='',ico=0;ico<temp[0].length-1;ico++)
	{
		c+=temp[0].charAt(ico);
	}
	a.src = a.src.replace(temp[0],c+b)
}
function build_ico_(a){
	var temp = a.parentNode.parentNode.getElementsByTagName('img');
	for(var i=0;i<temp.length;i++)
	{
		if(temp[i].previousSibling.checked)
			build_ico(temp[i],3);
		else
			build_ico(temp[i],1);
	}
}
function dom_button(a){
	if(a==undefined)
	{
		dom = document.getElementsByTagName('*');
		for(var dom_i=0;dom_i<dom.length;dom_i++)
		{
			if(dom[dom_i].tagName.toLowerCase()=='img')
			{
				//hack pour ie plantant sous IE -_-
				//rendre_transparent(dom[dom_i]);
			}
			try{
				if(dom[dom_i].className=="bouton_sup")
				{
					DT.getParentNodeByTagName(dom[dom_i],'table').parentNode.replaceChild(dom[dom_i].getElementsByTagName('input')[0],DT.getParentNodeByTagName(dom[dom_i],'table'))
				}
			}catch(e){
				dom[dom_i].parentNode.removeChild(dom[dom_i])
			}
		}
		if(document.getElementById('buildotheque'))
			dom = document.getElementById('buildotheque').getElementsByTagName('input');
		else
			dom = document.getElementsByTagName('input');
			//alert(document.getElementsByTagName('div')[document.getElementsByTagName('div').length-1].getElementsByTagName('input').length)
		}
	else
	{
		try{
			if(a.parentNode.parentNode.className=='bouton_sup')
			{
				var b = DT.getParentNodeByTagName(a,'table');
				b.parentNode.replaceChild(a,b);
			}
		}catch(e){}
		dom = Array(a);
	}
	//u = document.getElementById('buildotheque').getElementsByTagName('button');
	//for(dom_i=0;dom_i<u.length;dom_i++){dom.push(u[dom_i]);}
	for(var dom_i=0;dom_i<dom.length;dom_i++)
	{
		switch(dom[dom_i].getAttribute('type_bouton'))
		{
			case 'bouton':
			bouton_uri = 'bouton_simple0';
			break;
			case 'menu':
			bouton_uri = 'bouton_menu_dessous';
			break;
			default:
			//alert(dom[dom_i].type+' '+dom[dom_i].value)
			if(dom[dom_i].type=='button')
				bouton_uri = 'bouton_simple0';
			else
				bouton_uri = '';
			break;
		}
		if(bouton_uri!='')
		{
			try{
				//alert(dom[dom_i].value)
				if(page.toLowerCase()==dom[dom_i].value.toLowerCase()&&appartab(menus_principaux,dom[dom_i].value)){
					bouton_uri = 'bouton_menu_dessus';
				}
			}catch(e){}
			dom[dom_i].style.background='url(..'+uri_images+'/'+bouton_uri+'_m.png) center repeat-x';
			if(dom[dom_i].style.display!='none'&&(dom[dom_i].type=='button'||dom[dom_i].tagName=='BUTTON'))
			{
				t_table = cr('table');
				t_tbody = cr('tbody');
				t_tr = cr('tr');
				t_tr.className="bouton_sup";
				setEvent(t_tr,'onmouseover',"maj_bg_boutons(this,true)");
				setEvent(t_tr,'onmouseout',"maj_bg_boutons(this,false)");
				t_0 = cr('td');
				t_0.className="build_av_bouton";
				t_0.innerHTML='&nbsp;&nbsp;&nbsp;'
				t_0.style.background='url(..'+uri_images+'/'+bouton_uri+'_g.png) center right no-repeat';
				t_tr.appendChild(t_0);
				t_0 = cr('td');
				t_0.style.height='31px';
				t_tr.appendChild(t_0);
				t_0 = cr('td');
				t_0.className="build_ap_bouton";
				t_0.innerHTML='&nbsp;&nbsp;&nbsp;'
				t_0.style.background='url(..'+uri_images+'/'+bouton_uri+'_d.png) center left no-repeat';
				t_tr.appendChild(t_0)
				t_tr.style.height='31px'
				t_tbody.appendChild(t_tr)
				t_table.appendChild(t_tbody);
				t_table.style.display='inline';
				//insère l'objet avant le bouton
				dom[dom_i].parentNode.insertBefore(t_table,dom[dom_i]);
				dom[dom_i].style.height='31px';
				//insère le bouton au centre de l'objet
				dom[dom_i].previousSibling.firstChild.firstChild.childNodes[1].appendChild(dom[dom_i]);
				//alert(dom[dom_i].parentNode.parentNode.parentNode.innerHTML)
			}
		}
		if(dom[dom_i].getAttribute('type_bouton')=='menu'&&DT.getParentNodeByTagName(dom[dom_i],'table').parentNode.id!='build_header2')
		{
			document.getElementById('build_header2').appendChild(DT.getParentNodeByTagName(dom[dom_i],'table'));
		}
		
	}
}	

function maj_bg_boutons(a,b){
	if(b)
		c=1;
	else
		c=0;
	//mettre à jour le bg
	if(a.getElementsByTagName('td'))
	{
		d = a.getElementsByTagName('td')
		remplace_bg(d)
	}
	if(a.getElementsByTagName('input'))
	{
		d = a.getElementsByTagName('input')
		remplace_bg(d)
	}
	function remplace_bg(d){
		//récupérer les uris de chaque et mettre à jour
		for(var mbi=0;mbi<d.length;mbi++)
		{
			temp = d[mbi].style.background;
			if(temp.match('simple')!=null)
			{
				temp = temp.replace(/.*url\("?(.*\.png)"?\).*/,'$1')
				temp = temp.replace(/.*\/([_a-zA-Z0-9]+\.png)/,'$1')
				temp = temp.replace(/\d/,'¨')
				temp = temp.replace(/"/,'')
				temp = temp.split('¨');
				//alert(temp)
				temp[1] = temp[1].split('.')[0];
				if(temp[1].match('d')!=null)
				{
					e = 'left';
					f = 'no-repeat';
				}
				else if(temp[1].match('g')!=null)
				{
					e = 'right';
					f = 'no-repeat';
				}

				else
				{
					e = '';
					f = 'repeat-x';
				}
				//alert('url('+temp[0]+c+temp[1]+'.png) center '+e+' '+f)
				d[mbi].style.background='url(..'+uri_images+'/'+temp[0]+c+temp[1]+'.png) center '+e+' '+f;
			}
		}
	}
}
function dom_cadre(){
	if(!document.getElementById('cadre_buildotheque'))
	{
		w = cr_cadre_cache2();
		w.id='cadre_buildotheque';
		//document.getElementById('buildotheque').appendChild(w)
		w.firstChild.childNodes[0].childNodes[1].innerHTML='&nbsp;';//barre de titre
		w.firstChild.childNodes[0].childNodes[1].setAttribute('style','font-weight:bold;text-align:left;padding-top:4px;');
		u = w.firstChild.childNodes[2].childNodes[1]//première ligne juste sous le titre
		v=cr('div')//bloc juste avant le cadre, dans la partie centrale du cadre
		v.innerHTML = '&nbsp;';
		v.style.marginTop='-50px';
		v.style.marginBottom = '10px';
		v.style.width = '800px';
		u.appendChild(v);
		//w.setAttribute('style','border:0;border-collapse:collapse;margin:0;');
		document.getElementById('buildotheque').parentNode.insertBefore(w,document.getElementById('buildotheque'));
		document.getElementById('buildotheque').previousSibling.firstChild.childNodes[2].childNodes[1].appendChild(document.getElementById('buildotheque'))
	}
	if(!document.getElementById('cadre_build_header2'))
	{
		w = cr_cadre_cache3(0);
		w.id='cadre_build_header2';
		//document.getElementById('buildotheque').appendChild(w)
		w.firstChild.childNodes[0].childNodes[1].setAttribute('style','font-weight:bold;text-align:left;padding-top:4px;');
		u = w.firstChild.childNodes[1].childNodes[1]//première ligne juste sous le titre
		w.style.marginTop = '-1px';
		//w.setAttribute('style','border:0;border-collapse:collapse;margin:0;');
		document.getElementById('build_header2').parentNode.insertBefore(w,document.getElementById('build_header2').nextSibling);
		document.getElementById('cadre_build_header2').firstChild.childNodes[1].childNodes[1].appendChild(document.getElementById('build_content'));
		document.getElementById('cadre_build_header2').firstChild.childNodes[1].childNodes[1].appendChild(document.getElementById('build_content_groupe'));
		document.getElementById('cadre_build_header2').firstChild.childNodes[1].childNodes[1].appendChild(document.getElementById('build_footer'));
	}
	if(!document.getElementById('cadre_build_content'))
	{
		w = cr_cadre_cache3(1);
		w.id='cadre_build_content';
		//w.style.background='red';
		if(document.getElementById('build_tab_principal'))
		{
			if(page=='Presentation')w.style.width='80%';
			document.getElementById('build_tab_principal').parentNode.insertBefore(w,document.getElementById('build_tab_principal'));
			w.firstChild.childNodes[1].childNodes[1].appendChild(document.getElementById('build_tab_principal'))
		}
		/*else if(document.getElementById('build_edition'))
		{
			document.getElementById('build_edition').parentNode.insertBefore(w,document.getElementById('build_edition'));
			w.firstChild.childNodes[1].childNodes[1].appendChild(document.getElementById('build_edition'));
		}*/
	}
}
