var vis = new Array();

function replace(text, by, string) {
    var i = string.indexOf(text);
    var newstr = '';
    if ((!i) || (i == -1)) return string;
    newstr += string.substring(0,i) + by;

    if (i+text.length < string.length)
        newstr += replace(text, by, string.substring(i+text.length,string.length));
    
    return newstr;
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function swap_couche(couche) {
	triangle = MM_findObj('deroule' + couche);
	if (!(layer = MM_findObj('Layer' + couche))) return;
	if (vis[couche] == 'hide'){
		//if (deroule) deroule.src = '../image/down' +  '.gif';
		layer.style.display = 'block';
		vis[couche] = 'show';
	} else {
		//if (deroule) deroule.src = '../image/up' + '.gif';
		layer.style.display = 'none';
		vis[couche] = 'hide';
	}
}

function swap_action(couche) {
	url=document.forms[0].action;
	index=url.indexOf(couche+'=', 0);

	if(index<0) {
		document.forms[0].action=document.forms[0].action+'&'+couche+'=show';
		vis[couche] = 'hide';
		swap_couche(couche);
	}
	else {
		indexbis=url.indexOf(couche+'=show', 0);
		if(indexbis<0) {
			document.forms[0].action=replace(couche+'=hide', couche+'=show', document.forms[0].action);
			vis[couche] = 'hide';
			swap_couche(couche);
		}
		else {
			document.forms[0].action=replace(couche+'=show', couche+'=hide', document.forms[0].action);
			vis[couche] = 'show';
			swap_couche(couche);
		}
	}

	//alert(document.forms[0].action);
}
