
/*  ===============================================================
    FONCTION OUVERTURE POPUP
    ===============================================================
forme du lien :
<A HREF="../test_ouvre2.htm" 
   TARGET="newin" 
   onClick="ouvre(nom_fenetre,attributs,win_width,win_height,win_x,win_y,doc_url);">TEXTE DU LIEN</a>

1- le HREF porte l'url du document à atteindre

2- le TARGET porte le nom de la fenêtre cible (nom_fenetre)

3- le onClick peut passer les argument suivants :
		>> nom de la fenêtre - "newin" par défaut - variable nom_fenetre
		>> attributs de fenêtre - variable attributs :	
				menubar =	  1 barre de menu
				toolbar =	  2 barre de navigation
				location =	  4 barre d'adresse
				directories = 8 barre des favoris
				status =	 16 barre de statut (bas de fenêtre)
				resizable =  32 redimensionnement de la fenetre
				scrollbars = 64 barres de defilement
			l'addition des attributs souhaités doit être passées à la fonction.
			exemples :	pour une fenêtre avec menubar, location et scrollbar 
						--> 1 + 4 + 64 = 69 valeur à passer à la fonction.
			Si rien n'est passé, tout les attributs sont présents.
		>> largeur de la fenetre - variable win_width
		>> hauteur de la fenetre - variable win_height
		>> position horizontale coin haut gauche de la fenetre - variable win_x
		>> position verticale coin haut gauche de la fenetre - variable win_y
		>> adresse du document cible - variable doc_url
NB : aucune URL n'est passée à la fonction, c'est le HREF qui se charge d'envoyer le document dans la bonne fenêtre
	 en cas de problème, vérifier la concordance entre le nom de la fenêtre ouverte par le onClick et le nom du TARGET
	 !!!!! l'URL (doc_url) n'est passée que par d'autres scripts.
*/
var win = "";
function ouvre(nom_fenetre,attributs,win_width,win_height,win_x,win_y,doc_url) {
	var att="",i=0,r;
	var att_options = new Array('menubar','toolbar','location','directories','status','resizable','scrollbars');
	nom_fenetre=(nom_fenetre==undefined||nom_fenetre=='')?"newin":nom_fenetre;
	attributs=(attributs==undefined)?127:attributs;// tous les attributs par defaut
	win_width=(win_width==undefined||win_width=='')?760:win_width; // 760 de large par defaut
	win_height=(win_height==undefined||win_height=='')?540:win_height; // 540 de haut par defaut
	win_x=(win_x==undefined||win_x=='')?10:win_x; // position x par defaut 10
	win_y=(win_y==undefined||win_y=='')?10:win_y; // position y par defaut 10
	doc_url=(doc_url==undefined||doc_url=='')?'':doc_url; // url
	while (attributs >= 1){
		r = attributs % 2;
		attributs = Math.floor(attributs / 2);
		s=(att=="")?"":",";
		att=((r==1)&&(att_options[i]!=undefined))?att+s+att_options[i]:att;
		i+=1;
	}
	win = window.open(doc_url,nom_fenetre,'width='+win_width+',height='+win_height+','+att);
	win.moveTo(win_x,win_y);
	win.focus();
}

/*  ==================================================================
    Affiche l'heure en temps réel dans la barre d'état
    ==================================================================*/

function AfficheHeure() {
	var dt=new Date();
	var m=new Array(13);
	m[1]="Janvier"; m[2]="Février";	m[3]="Mars"; m[4]="Avril"; m[5]="Mai"; m[6]="Juin";
 	m[7]="Juillet";	m[8]="Août"; m[9]="Septembre"; m[10]="Octobre";	m[11]="Novembre"; m[12]="Décembre";
	var d=new Array(8);
	d[1]="dimanche"; d[2]="lundi"; d[3]="mardi"; d[4]="mercredi"; d[5]="jeudi"; d[6]="vendredi"; d[7]="samedi";
	var mois=m[dt.getMonth()+1];
	var jour=d[dt.getDay()+1];
	var date=dt.getDate();
	var an=dt.getYear();
	if (an<200) an=1900+an;
	date=jour+" "+date+" "+mois+" "+an;
	var heure=dt.getHours();
	var min=dt.getMinutes(); if (min<10) {min="0"+min;}
	var sec=dt.getSeconds(); if (sec<10) {sec="0"+sec;}
	window.status="Nous sommes le "+date+", il est "+heure+" h "+min+" min "+sec+" s"
	setTimeout("AfficheHeure()",1000);
}


/*  ==================================================================
    Gère l'affichage d'un post it de petite taille
    ==================================================================*/
  
function postit(xo,yo,img,texte){
 if (navigator.appName=="Netscape"){
  if (xo==-1){xo=(window.innerWidth/2)-120;}
  if (yo==-1){yo=(window.innerHeight/2)-120;}
  document.layers['postit'].left=xo;document.layers['postit'].top=yo;
  document.layers['postit'].document.write("<table border=0 cellpading=0 width=240 height=240 background='images/postit.gif'><tr><td align=center valign=middle><B>"+texte+"</B></TD></TR></TABLE><layer name=close top=10 left=110 width=21 height=21><img src='images/punaise.gif' border=0></layer><BR>");
  document.layers['postit'].document.close();
  document.layers['postit'].visibility="show";
 }
 else{
  if (xo==-1){xo=(document.body.clientWidth/2)-120;}
  if (yo==-1){yo=(document.body.clientHeight/2)-120;}
  document.all.postit.style.left=xo;document.all.postit.style.top=yo;
  document.all.postit.innerHTML='<table border=0 cellpading=0 width=240 height=240 background="images/postit.gif"><tr><td align=center valign=middle><B>'+texte+'</B></TD></TR></TABLE><DIV id="close" style="position:absolute;top:10px;left:110px;width:16px;height:16px;"><img src="images/punaise.gif" border=0></DIV><BR><DIV align=center id="photo" style="top:200px"><img src='+img+' border=0></DIV><BR>';
  document.all.postit.style.visibility="visible";
 }
}

function fermeIt(){
 if (navigator.appName=="Netscape"){
  document.layers['postit'].document.write("");
  document.layers['postit'].document.close();
  document.layers['postit'].visibility="hide";
 }
 else{
  postit.innerHTML="";
  document.all.postit.style.visibility="hidden";
 }
}

/*  ==================================================================
    Gère l'affichage d'un post it de grande taille
    ==================================================================*/
  
function postit2(xo,yo,titre,texte){
 if (navigator.appName=="Netscape"){
  if (xo==-1){xo=(window.innerWidth/2)-120;}
  if (yo==-1){yo=(window.innerHeight/2)-120;}
  document.layers['postit'].left=xo;document.layers['postit'].top=yo;
  document.layers['postit'].document.write("<table border=0 cellpading=0 width=400 height=400 background='images/postit2.gif'><tr><td align=center valign=middle><B>"+texte+"</B></TD></TR></TABLE><layer name=close top=10 left=110 width=21 height=21><img src='images/punaise.gif' border=0></layer><BR>");
  document.layers['postit'].document.close();
  document.layers['postit'].visibility="show";
 }
 else{
  if (xo==-1){xo=(document.body.clientWidth/2)-120;}
  if (yo==-1){yo=(document.body.clientHeight/2)-120;}
  document.all.postit.style.left=xo;document.all.postit.style.top=yo;
  document.all.postit.innerHTML='<table border=0 cellpading=0 width=400 height=400 background="images/postit2.gif"><tr><td align=center valign=top><br><br><B><h3><font color="#FF6666">'+titre+'</font></h3><br><br><font color="#3366FF">'+texte+'</font></B></TD></TR></TABLE><DIV id="close" style="position:absolute;top:10px;left:15px;width:16px;height:16px;"><img src="images/punaise.gif" border=0></DIV><DIV id="close" style="position:absolute;top:355px;left:365px;width:16px;height:16px;"><img src="images/punaise.gif" border=0></DIV><DIV id="close" style="position:absolute;top:355px;left:15px;width:16px;height:16px;"><img src="images/punaise.gif" border=0></DIV>';
  document.all.postit.style.visibility="visible";
 }
}

function fermeIt2(){
 if (navigator.appName=="Netscape"){
  document.layers['postit'].document.write("");
  document.layers['postit'].document.close();
  document.layers['postit'].visibility="hide";
 }
 else{
  postit.innerHTML="";
  document.all.postit.style.visibility="hidden";
 }
}