/**********************************************************************************
   NOM      : fddscrpt.js
   DATE     :
   AUTEUR   :

   MODULE   :

   OBJET    :

   NOTE     :

   HISTOIRE :

   Date       | Aut.| Objet
  ============+=====+===============================================================
   06.09.2001 | HEY | Création de la fonction
  ------------+-----+---------------------------------------------------------------
   08.10.2001 | MIK | Modification de la fonction AutresCibles().
  ------------+-----+---------------------------------------------------------------
   23.07.2002 | LUD | Gestion tableaux dynamiques
  ------------+-----+---------------------------------------------------------------
   09.08.2002 | LUD | Gestion scroll sur un champ
  ------------+-----+---------------------------------------------------------------
   10.10.02   | LUD | Gestion scroll sur un champ
  ------------+-----+---------------------------------------------------------------
   16.10.02   | LUD | fonction lanceGloss
  ------------+-----+---------------------------------------------------------------
   08.11.02   | LUD | menudynamique
  ------------+-----+---------------------------------------------------------------
   06.12.02   | LUD | utilisation de principal pour que l'ouverture d'une page html avec la fonction principal dans une page secondaire, utilise la principale deja présente
              |     | pas d'appel a la fonction posit dans fonction second et popup car erreur quand on ouvre une secondaire et qu'elle existe deja
  ------------+-----+---------------------------------------------------------------
   07.01.03   | LUD | ajout de la fonction ScrollChpCorpsCorps pour scoller dans la frame Corps_Corps
  ------------+-----+---------------------------------------------------------------
   08.01.03   | LUD | menu dynamique, onclick
  ------------+-----+---------------------------------------------------------------
   24.03.03   | LUD | integration sommaire xml
  ------------+-----+---------------------------------------------------------------
   14.05.03   | LUD | gestion des tailles par defaut
************************************************************************************/

//LUD 14.05.03 gestion des tailles par defaut
sec_x_default=0;
sec_y_default=0;
sec_dx_default=600;
sec_dy_default=400;

pop_x_default=0;
pop_y_default=0;
pop_dx_default=600;
pop_dy_default=400;
//LUD fin

noSecond=0;
var sec,sec0,sec1=null;
browserIe = (navigator.appName == "Microsoft Internet Explorer")
positFen=1
if(browserIe)
{
  var ua = window.navigator.userAgent
  var msie = ua.indexOf ( "MSIE " )
  var version = 0
  if ( msie > 0 )
        version =parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
  if(version>=5)
	positFen=1
  else
	positFen=0
}

//**********************   Gestion tableaux dynamiques *************************//
//initialisation pour tableau dynamique
if (navigator.appName == "Netscape")
	{
	layerRef="document.layers";
	styleSwitch="";
	ns=1;
	}
	else
	{
	layerRef="document.all";
	styleSwitch=".style";
	ns=0
	}

layerVisible=null;
layerVisibleM2=null;


//LUD 06.11.02 pour netscape 4 corrige le pb de reaffichage des div quand on resize la fenetre
if(ns)
{
  widthCheck = window.innerWidth
  heightCheck = window.innerHeight
  window.onResize = resizeFix
}

function resizeFix() {
  if (widthCheck != window.innerWidth ||heightCheck != window.innerHeight)
    document.location.href = document.location.href
}



function hide(layer)
{
	var y = new getObj(layer);
	y.style.visibility = 'hidden';
}

function show(layer)
{
	
	if(layerVisible!=null && layerVisible!=layer)
	{
		//if(ns)//LUD 09.01.03
		//{
			if(layer.substring(0,1)=="m")
			{	
				var z= new getObj(layerVisible);
				z.style.visibility = 'hidden';
				if(layerVisibleM2!=null && layerVisibleM2!=layer)
				{
					var z= new getObj(layerVisibleM2);
					z.style.visibility = 'hidden';
				}		
			}
		//}
	}
	var y = new getObj(layer);
	y.style.visibility = 'visible';
	layerVisible=layer;
}

function showM2(layer)
{
	if(layerVisibleM2!=null && layerVisibleM2!=layer)
	{
		var z= new getObj(layerVisibleM2);
		z.style.visibility = 'hidden';
	}
	var y = new getObj(layer);
	y.style.visibility = 'visible';
	layerVisibleM2=layer;

}


function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
	this.obj = getObjNN4(document,name);
	this.style = this.obj;
  }
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var thereturn;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	thereturn = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) thereturn = tmp;
	}
	return thereturn;
}




//**********************   Fin Gestion tableaux dynamiques *************************//



self.focus();

if(name=="")
{
//LUD 06.12.02 on utilise principal
//name="_top"
name="principal"
}


function Posit(fen,x,y,dx,dy)
{
if(positFen==1)
{
if(fen!=null || fen!="")
{
	fen.moveTo(x,y)
	fen.resizeTo(dx, dy)
	fen.focus()
}
}
}


function principal(file)
{
	//princ=open(file,"_top")
	princ=open(file,"principal")//LUD 06.12.02 on utilise principal
}



//******************************
// HEY 19.02.2033 - création
//******************************
function GetMyName()
{var url,cible;
 
  url = new String(window.location.href);  
  cible = url.substr(url.lastIndexOf("/")+1,url.length);
  return cible  
}
/*
function principal(file)
{
       //alert("file="+file+" name ="+name)
       //HEY 06.02.03 if (name=="second")//partie spécifique a centre loire
       //HEY 19.02.03 if ((name=="second")|| ( (name=="Entete") && (file!="../home.htm"))) //partie spécifique a centre loire
       
       if ((file!="../home.htm") && (GetMyName()!="home_c.htm")) //partie spécifique a centre loire
	{
		//alert('tutu')
		var pos
		var fileEntete
		var fileCorpsCorps
	
		pos=0	
		pos=file.indexOf(".htm",0)
		
		fileEntete=file.substring(0,pos)+"_e.htm"
		fileCorpsCorps=file.substring(0,pos)+"_c.htm"
		
		if(pos!=-1)
		{
			open(fileEntete,'Entete')
			open(fileCorpsCorps,'Corps_Corps')
		}
	
	}
	else //fin
		princ=open(file,"principal")
		
	
	close()
	
}*/

















function frm(file,nameFrm)
{
frm=open(file,nameFrm)
}
function second(fichier,x,y,dx,dy)
{
//LUD 14.05.03 valeur par défaut	
if(x==-1 && y==-1 && dx==-1 && dy==-1)
{
x=sec_x_default;
y=sec_y_default;
dx=sec_dx_default;
dy=sec_dy_default;
}	
if(browserIe)
{
	if(positFen==0)
	{
		if(noSecond==0)
		{
		if(sec1!=null)
		sec1.close();
		noSecond=1;
		sec0=open(fichier,"second"+noSecond,"left="+x+",top="+y+",width="+dx+",height="+dy+",menubar=no,toolbar=no,resizable=yes,scrollbars=yes")
		}
		else
		{
		if(sec0!=null)
		sec0.close();
		noSecond=0;
		sec1=open(fichier,"second"+noSecond,"left="+x+",top="+y+",width="+dx+",height="+dy+",menubar=no,toolbar=no,resizable=yes,scrollbars=yes")
		}
	}
	else
	sec=open(fichier,"second","left="+x+",top="+y+",width="+dx+",height="+dy+",menubar=no,toolbar=no,resizable=yes,scrollbars=yes")

	Posit(sec,x,y,dx,dy);//LUD 06.12.02
}
else
{
if(sec!=null && sec.document!=null)
sec.close()
sec=open(fichier,"second","left="+x+",top="+y+",width="+dx+",height="+dy+",menubar=no,toolbar=no,resizable=yes,scrollbars=yes")
}
}
function popup(fichier,x,y,dx,dy)
{
//LUD 14.05.03 valeur par défaut
if(x==-1 && y==-1 && dx==-1 && dy==-1)
{
x=pop_x_default;
y=pop_y_default;
dx=pop_dx_default;
dy=pop_dy_default;
}		
	
if(browserIe)
{
if(positFen==0)
{
if(noSecond==0)
{
if(sec1!=null)
sec1.close();
noSecond=1;
sec0=open(fichier,"second"+noSecond,"left="+x+",top="+y+",width="+dx+",height="+dy+",menubar=no,toolbar=no,status=no,resizable=no,scrollbars=yes")
}
else
{
if(sec0!=null)
sec0.close();
noSecond=0;
sec1=open(fichier,"second"+noSecond,"left="+x+",top="+y+",width="+dx+",height="+dy+",menubar=no,toolbar=no,status=no,resizable=no,scrollbars=yes")
}
}
else
sec=open(fichier,"second","left="+x+",top="+y+",width="+dx+",height="+dy+",menubar=no,toolbar=no,status=no,resizable=no,scrollbars=yes")
Posit(sec,x,y,dx,dy); //LUD 06.12.02
}
else
{
if(sec!=null && sec.document!=null)
sec.close()
sec=open(fichier,"second","left="+x+",top="+y+",width="+dx+",height="+dy+",menubar=no,toolbar=no,status=no,resizable=no,scrollbars=yes")
}
}
function toggleDisplay(mainID)
{
if (document.all("T_" + mainID).style.display=='none')
{
document.all("T_" + mainID).style.display='block';
document.all("H_" + mainID).className='FDDselectedClass';
}
else
{
document.all("T_" + mainID).style.display='none';
document.all("H_" + mainID).className='FDDLinkClass';
}
}

function Context(CtxSom)
{
parent.Corps_Som.document.fddsom.AjouteContext(CtxSom)
}
function ContextPlus(CtxSom,pagedest)
{
parent.Corps_Som.document.fddsom.AjouteContext(CtxSom)
parent.Corps_Corps.location.href=pagedest
}
function ContextUrl(CtxSom,StrUrl)
{
parent.Corps_Som.document.fddsom.AjouteContextUrl(CtxSom,StrUrl)
}
function ContextUrlPlus(CtxSom,StrUrl,pagedest)
{
top.Corps.Corps_Som.document.fddsom.AjouteContextUrl(CtxSom,StrUrl)
top.Corps.Corps_Corps.location.href=pagedest
}
function ContextLabel(CtxSom,StrLabel)
{
parent.Corps_Som.document.fddsom.AjouteContextLabel(CtxSom,StrLabel)
}
function ContextLabelPlus(CtxSom,StrLabel,pagedest)
{
parent.Corps_Som.document.fddsom.AjouteContextLabel(CtxSom,StrLabel)
parent.Corps_Corps.location.href=pagedest
}

 /*-------------------------------------------------------------------------
   Auteur : HEY
   Date   : 06.09.2001
   nom    : AutresCibles

   Objet  : permet de selectionner une cible différente de
   		principale, secondaire, popup

  ------------+-----+------------------------------------------------------
   Date       | Aut.| Objet
  ============+=====+======================================================
   06.09.2001 | HEY | Création
  ------------+-----+------------------------------------------------------
   08.10.2001 | MIK | Modification des cas 5,6 et 7.
  ------------+-----+------------------------------------------------------
  -------------------------------------------------------------------------*/
function AutresCibles(cible,mavar)
{
   if    (cible == 4) // Entete
         window.top.Entete.location.href=mavar;
   else
      if (cible == 5) // corps
         window.top.Corps.location.href=mavar;			// MIK 08.10.2001
   else
      if (cible == 6) // sommaire
         window.top.Corps.Corps_Som.location.href=mavar;	// MIK 08.10.2001
   else
      if (cible == 7) // corps_corps
         window.top.Corps.Corps_Corps.location.href=mavar;	// MIK 08.10.2001
}


 /*-------------------------------------------------------------------------
   Auteur : LUD
   Date   : 09.08.2002
   nom    : ScrollChp

   Objet  : permet de scroller sur une ancre qui a été posée dans la frame Corps_Corps

  ------------+-----+------------------------------------------------------
   Date       | Aut.| Objet
  ============+=====+======================================================
  ------------+-----+------------------------------------------------------
  04.09.02    | LUD | correction bug
  -------------------------------------------------------------------------*/
function ScrollChpCorpsCorps(x)
{
	pos=window.top.Corps.Corps_Corps.location.href.indexOf("#",0)

	if(pos!=-1)
		window.top.Corps.Corps_Corps.location.href=window.parent.top.Corps.Corps_Corps.location.href.substring(0,pos)+"#"+x
	else
		window.top.Corps.Corps_Corps.location.href=window.parent.top.Corps.Corps_Corps.location.href+"#"+x
}


 /*-------------------------------------------------------------------------
   Auteur : LUD
   Date   : 10.10.2002
   nom    : ScrollChpSelf

   Objet  : permet de scroller sur une ancre qui a été posée dans la meme frame que le composant qui appel cette fonction

  ------------+-----+------------------------------------------------------
   Date       | Aut.| Objet
  ============+=====+======================================================
  ------------+-----+------------------------------------------------------
  -------------------------------------------------------------------------*/
function ScrollChpSelf(x)
{
	pos=window.self.location.href.indexOf("#",0)

	if(pos!=-1)
		window.self.location.href=window.self.location.href.substring(0,pos)+"#"+x
	else
		window.self.location.href=window.self.location.href+"#"+x
}

 /*-------------------------------------------------------------------------
   Auteur : LUD
   Date   : 16.10.2002
   nom    : lanceGloss

   Objet  : fonction appeler a partir d'un alphabet présent dans l'entete d'une fiche
   	    cette fonction est nécessaire

  ------------+-----+------------------------------------------------------
   Date       | Aut.| Objet
  ============+=====+======================================================
  ------------+-----+------------------------------------------------------
  -------------------------------------------------------------------------*/
function lanceGlossEntete(page)
{
window.top.Entete.location.href='../gloss_e.htm'
window.top.Corps.Corps_Som.location.href='../gloss_sc.htm'
window.top.Corps.Corps_Corps.location.href=page
}


 /*-------------------------------------------------------------------------
   Auteur : LUD
   Date   : 16.10.2002
   nom    : lanceGlossEntete

   Objet  : fonction appeler a partir d'un alphabet présent dans l'entete d'une fiche
   	    cette fonction est nécessaire

  ------------+-----+------------------------------------------------------
   Date       | Aut.| Objet
  ============+=====+======================================================
  ------------+-----+------------------------------------------------------
  -------------------------------------------------------------------------*/
function lanceGloss(page)
{
if(window.top.Corps.Corps_Corps==null)
	window.top.Corps.location.href=page
else
	window.top.Corps.Corps_Corps.location.href=page
}



/****************************************************/
 /*-------------------------------------------------------------------------
   Auteur : LUD
   Date   : 24.03.2003
   nom    : dem

   Objet  : lance le positionnement dans le sommaire xml

  ------------+-----+------------------------------------------------------
   Date       | Aut.| Objet
  ============+=====+======================================================
  ------------+-----+------------------------------------------------------
  -------------------------------------------------------------------------*/
var niveau //la chaine de niveau 

function dem(chaine){
 
 try{//LUD gestion erreur
	 fenetreSom=findFrame("Corps_Som")
	 
	 if(fenetreSom!=null)
	 {
		 niveau = fenetreSom.getPos(chaine);
		 
		 if(chaine!=fenetreSom.brancheSelect)//si la branche sélectionné dans l'arbre est différente de la fiche courante
		 {
			 fenetreSom.location=fenetreSom.location; 
			 fenetreSom.Pos(niveau);
		 }
	
	 }
     }
 catch(e){}

 	
}


 /*-------------------------------------------------------------------------
   Auteur : LUD
   Date   : 25.03.2003
   nom    : findFrame

   Objet  : determine si la frame existe

  ------------+-----+------------------------------------------------------
   Date       | Aut.| Objet
  ============+=====+======================================================
  ------------+-----+------------------------------------------------------
  -------------------------------------------------------------------------*/
function findFrame(Frame) {
    for (var i=0;i<parent.frames.length;i++) {
         if (parent.frames[i].name == Frame)
                 return parent.frames[i];
    }
    return null;
}


function lD()
{
	document.write('<TR><TD WIDTH=100% nowrap style="margin:0;padding:0"><DIV STYLE="position:relative">')
}


//v1:texte
//v2:left
//v3:top
//v4:width
//v5:height
//v6:font-size
//v7:color
//v8:face
//v9:align
//v10:valign
function l(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11)
{
	//Default
	if(v7=="")
		v7="000000"	
	if(v8=="")
		v8="Arial"
	if(v9=="")
		v9="CENTER"		
	
	document.write('<DIV STYLE="position:absolute;">');

	if (!NS)
	{
		document.write('<DIV STYLE="position:relative; left:'+v2+'px; top:'+v3+'px; width:'+v4+'px; height:'+v5+'px;')
		
		if(v11!='')
			document.write('cursor:hand;" onclick="'+v11+'">')
		else
		 	document.write('">')
	}
	else
		document.write('<LAYER LEFT='+v2+' TOP='+v3+' WIDTH='+v4+' HEIGHT='+v5+'>')

	document.write('<TABLE border=0 cellpadding=0 cellspacing=0><TR><TD width='+v4+' height='+v5+' align='+v9+' valign=top>');
	
	document.write('<p style="margin:0px;margin-top:2px"><FONT style="font-size:'+v6+'px" COLOR='+v7+' FACE="'+v8+'">');

	if(v10!='')
		document.write('<'+v10+'>');
	
	document.write(v1);
	
	if(v10!='')
		document.write('</'+v10+'>');	
	
	document.write('</FONT></p>');
	
	
	document.write('</TD></TR></TABLE>');

	if (!NS) document.write('</DIV>')
	else document.write('</LAYER>')
	
		
	document.write('</DIV>');
	
}

function lF(v1,v2)
{
	
	document.write('</MAP><p class="logiImage"><img src="'+v1+'" USEMAP="#'+v2+'" border=0 margintop=0 marginbottom=0></p>');	
	document.write('</TD></TR></DIV>')
	
}	

function lA(v1,v2,v3,v4,v5,v6)
{
	document.write('<AREA SHAPE=RECT COORDS="'+v1+','+v2+','+v3+','+v4+'" ALT="'+v5+'"');
	if(v6!="")
		document.write(' HREF="javascript:'+v6+'"');
	document.write('>')
}


