

var ns6=false;
var ns4 =false;
var ie =false;
var ie4 =false;
var ie5=false;
var ie55=false;
var isMac=false;
var isWin=false;

//**************************
function initialiser_plateforme()
{
ns6=false;
ns4 =false;
ie4 =false;
ie5=false;
ie55=false;

isMac =(navigator.appVersion.indexOf("Mac")!=-1);
isWin = (navigator.appVersion.indexOf("Win") != -1);

//alert(isMac + " " + isWin);
 
if ( navigator.appName == 'Microsoft Internet Explorer')
	{
	ie=true;
	ie4 = (document.all)? true:false;
	if (navigator.userAgent.indexOf('MSIE 5')>0)
		ie5 = true;
	if (navigator.userAgent.indexOf('MSIE 5.5')>0)
		ie55 = true;
	}
if ( navigator.appName == 'Netscape')
	{
	ns6=(document.getElementById)? true:false;
	ns4 = (document.layers)? true:false;
	}
	
/*if (ns6)
	alert("ns6");
if (ns4)
	alert("ns4");
if (ie4)
	alert("ie4");*/
	
	
}


//***************************
function ancre_index(id_ancre) 
{
var i;

for (i=0; i<document.anchors.length; i++) 
	{
	if (document.anchors[i].name==id_ancre) 
		return(i);
	}
return(-1);
}	

//***************************
function ancre_adresse(id_ancre) 
{
var i;
var ancre=null;

for (i=0; i<document.anchors.length; i++) 
	{
	ancre=document.anchors[i];
	if (ancre.name==id_ancre) 
		return(ancre);
	}
return(null);
}	

//***************************
function ancre_position(id_ancre, index_ancre) 
{
var ancre;
var coords = {x: -1, y: -1 };

if (index_ancre ==null || index_ancre>0)
	ancre=ancre_adresse(id_ancre);	
else
	ancre=document.anchors[index_ancre];

if (ancre == null) 
	{
	alert(id_ancre + " : ancre non trouvée");
	return coords
	}

if (ns4) 
    { 
	coords.x=ancre.x;
	coords.y=ancre.y; 
	}

if(ie4 || ns6) 
	coords=objet_position(ancre);
return coords
}

//***************************
function ancre_position_dans_fenetre(id_ancre) 
{
var coords = {x: -1, y: -1 };
var x=0;
var y=0;

var coords=ancre_position(id_ancre);

if (document.getElementById) 
	{
	if (isNaN(window.screenX)) 
		{
		coords.x+=window.screenLeft-document.body.scrollLeft;
		coords.y+=window.screenTop-document.body.scrollTop;
		}
	else 
		{
		coords.x+=window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		coords.y+=window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	return coords;
	}
	
if (ie4) 
	{
	coords.x+=window.screenLeft-document.body.scrollLeft;
	coords.y+=window.screenTop-document.body.scrollTop;
	return coords;
	}
if (ns4) 
	{
	coords.x+=window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
	coords.y+=window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
	return coords;
	}
return coords;
}


//***************************
function objet_adresse(id_objet) 
{
if (document.getElementById) 
	return(document.getElementById(id_objet));
if(document.all) 
	return(document.all(id_objet));

return null;
}	

//***************************
function objet_position (objet) 
{
var obj;
var coords = {x: -1, y: -1};

obj=objet;

if (obj == null) 
	return coords

if (obj.offsetLeft!=undefined) 
	return({x: parseInt(obj.offsetLeft), y:parseInt(obj.offsetTop)});	

if (obj.style) 
	return({x: parseInt(obj.style.pixelLeft), y:parseInt(obj.style.pixelTop)});

if (obj.left!=undefined)
	return ({x: obj.left, y:obj.top});
	
return coords;	

/*
if (ns4) 
    return { x: obj.x, y: obj.y };
if (ns6) 
     {
      coords.x = obj.offsetLeft;
      coords.y = obj.offsetTop;
      obj = obj.offsetParent;
	  return coords;
	 }
if(ie4) 
	{
    while (obj)
     {
      coords.x += obj.offsetLeft;
      coords.y += obj.offsetTop;
      obj = obj.offsetParent;
	 }
    return coords;
  }
*/
  
}


//***************************
function fenetre_position(fenetre)
{
var coords = {x: -1, y: -1, l:-1, h:-1};

if (!fenetre)
 fenetre=window
 
if (ns4 || ns6)
	{ 
	coords.x = fenetre.pageXOffset;
	coords.y = fenetre.pageYOffset;
	coords.l = fenetre.innerWidth; 	
	coords.h = fenetre.innerHeight;
	}	
else	
	{
	coords.x = fenetre.document.body.scrollLeft;
	coords.y = fenetre.document.body.scrollTop;
	coords.l = fenetre.document.body.clientWidth;	
	coords.h = fenetre.document.body.clientHeight;	
	}
return coords;
}


//***************************
function fenetre_positionner(x, y)
{

/*
if (ns4 || ns6)
	{
	if (x>0) window.pageXOffset=x;
	if (y>0) window.pageYOffset=y;
	}
else
	{
	if (x>0) document.body.scrollLeft=x;
	if (y>0) document.body.scrollTop=y;
	}
*/


if (ns4 || ns6)
	{
	if (x<0) x=window.pageXOffset;
	if (y<0) y=window.pageYOffset;
	}
else
	{
	if (x<0) x=document.body.scrollLeft;
	if (y<0) y=document.body.scrollTop;
	}

window.scrollTo(x, y);
}


//***************************
function document_hauteur() 
{
 if (ie4) 
     return document.body.scrollHeight;
if (ns4 || ns6)
       return document.height;
if (ns6)
       return innerHeight;
return 0;
}


//***************************
function fenetre_positionner_selon_ancre(nom_ancre, y_decal) 
{
var y_ancre, y_fen;

y_ancre=ancre_position(nom_ancre).y;

//alert(y_ancre);	
if (ns4 || ns6)
	{ 
	y_decal+=20;
	location.href='#R' + id_rubrique;
	y_fen=fenetre_position().y;

//	alert (y_fen +"-"+y_ancre+"=" +(y_fen-y_ancre) +"<"+y_decal);
	if(Math.abs(y_fen-y_ancre)<y_decal)
		window.scrollBy(0, -y_decal);
	}
else
	{	
//	alert ("y_ancre:"+y_ancre+" hdoc:" +document_hauteur()+ " y_decal=" + y_decal);
	if (document_hauteur()-y_ancre>y_decal)
			y_ancre-=y_decal;
	fenetre_positionner(-1, y_ancre);
	}
}	


//***************************
function fenetre_centrer(fenetre)
{
var coor, x, y, l, h, l_dispo, h_dispo;

coor = fenetre_position(fenetre)

l=coor.l;
h=coor.h;
l_dispo=screen.availWidth;
h_dispo=screen.availHeight;
x= (l_dispo-l)/2;
y= (h_dispo-h)/2;
fenetre.moveTo(x,y)
}


//***************************
// diminue la taille de l'image si celle si dépasse
function image_diminuer(image, l, h)
{
var dl=1, dh=1, il, ih, new_l, new_h;

if (!image)
	return;
il=image.width;
ih=image.height;

//alert( il + ", " + ih + "->" + l + ", " +h);
if (il<= l && ih<=h) return;

if (l>0)
	dl=l-il;
if (h>0)
	dh=h-ih;
	
if (dl<0 || dh<0)
	{
	if (l*ih > h*il)
		{
		new_l= il*h/ih;
		new_h= h;
		}
	else
		{
		new_l= l;
		new_h= ih*l/il;
		}
	image.width=new_l;	
	image.height=new_h
	}

}

//***********************
// positionne un layer par rapport à un objet
// x_l, y_l : decalage en x,y par rapport à l'ancre
function repositionner_layer(nom_layer, x_l, y_l, nom_objet)
{
var	x_ancre=0, y_ancre=0 , objet;

if (nom_objet)
	{
	objet = eval(nom_objet);
	x_ancre=objet_position(objet).x;
	y_ancre=objet_position(objet).y;
	}
//if (nom_objet == "ancre_haut") 
	//{alert(nom_layer + " " + nom_objet + " " + x_ancre + " " + y_ancre);}

if (x_ancre<0) x_ancre=0;
if (y_ancre<0) y_ancre=0;

//pour netscape
if (ns4)
	{
	x_ancre += 2  ;
	y_ancre += 2 ;
	}
		
/*pour netscape
if (ns6 || ns7)
	{
	x_ancre += 2  ;
	y_ancre -= 28 ;
	}	
*/

//alert(x_ancre + " " + y_ancre)
//alert(x_l + " " + y_l)

layer_positionner(nom_layer, x_ancre + x_l, y_ancre + y_l) ;		

return  ;
}