/******************************************************************************************
* sg_bandeau.js                                                                           * 
*                                                                                         *
* Version 1.2                                                                             *
*                                                                                         *
* Copyright 2001 par SMX  (Sébastien MOULIGNEAUX - Société SERLOG)                        *
* Derniere MAJ : 05 Novembre 2001.                                                        *
*                                                                                         *
* Permet d'ajouter un menu dynamique horizontal en haut de page                           * 
* Fonctionne sous Internet Explorer 4 (et superieur) ainsi que Netscape                   *
* Navigator 4 (et superieur).                                                             *
*                                                                                         *
* Lignes a inserer entre <HEAD> </HEAD> dans la page :                                    *
*   <link rel="stylesheet" href="css/global.css" type="text/css">                         *
*   <SCRIPT src="js/dhtmllib.js"></SCRIPT>                                                *
*   <SCRIPT SRC="js/sg_bandeau.js"></SCRIPT>                                              *
*   <SCRIPT SRC="js/sg_definition_bandeau.js"></SCRIPT>                                   *
*                                                                                         *
* Lignes a ajouter juste apres le TAG <BODY> :                                            *
*   <script> SG_bandeau_draw() </script>                                                  *
*                                                                                         *
*******************************************************************************************/


// Definition des variables

var SG_mouseX,SG_mouseY;
var SG_timerID = null;
var SG_timerRunning = false;
var SG_objectMenu;

SG_bandeau_libelle = new Array();
SG_bandeau_url = new Array();
SG_menu_libelle = new Array();
SG_menu_url = new Array();


//Recuperateur des coordonnees de la souris


function SG_get_mouse(e)
{
SG_mouseX = (isMinNS4) ? e.pageX : event.x+document.body.scrollLeft;
SG_mouseY = (isMinNS4) ? e.pageY : event.y+document.body.scrollTop;
}

//Evite le BUG de Netscape lors du redimenssionnement de fenetre

function SG_reloadPage(init) {  
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=SG_reloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}


// Generateur automatique du bandeau

function SG_bandeau_draw() {

if (isMinIE4) document.write("<DIV ID=\"SGtelecommande\" style=\"position:absolute; left: 0px; top: 80px; z-index:100; visibility:visible\"></DIV>");
if (isMinNS4) document.write("<layer id=\"SGtelecommande\"  left=\"0\" top=\"80\" z-index=\"100\" visibility=\"show\" width=\"0\" height=\"0\"></layer>");


if (isMinIE4) 
	{
	document.write("<DIV ID=\"SGMenu\" style=\"position:absolute; z-index:10000; visibility: hidden\"></DIV>");
	document.write("<DIV ID=\"LienLogo\" style=\"position:absolute; width:150px; height:50px; left: 0; top: 0\"><a href=\""+SG_logo_url+"\"><img src=\""+SG_path_images_bandeau+"blank.gif\" border=\"0\" width=150 height=50></a></DIV>");
	}
if (isMinNS4) 
	{
	document.write("<layer id=\"SGMenu\"  z-index=\"10000\" visibility=\"hide\"></layer>");
	document.write("<layer id=\"LienLogo\" left=\"0\" top=\"0\" width=\"150\" height=\"50\"><a href=\""+SG_logo_url+"\"><img src=\""+SG_path_images_bandeau+"blank.gif\" border=\"0\" width=150 height=50></a></layer>");
	}
	




if (isMinIE4) SG_objectMenu=SGMenu;
if (isMinNS4) SG_objectMenu=document.SGMenu;

var SG_bandeau_aff = "<table width=\"100%\" border=0 cellspacing=0 cellpadding=0 height=50>\n";
SG_bandeau_aff    += "<tr>\n";
SG_bandeau_aff    += "<td valign=middle align=right class=SGBandeauFond><span class=SGTitre1>"+SG_titre1+"</span>&nbsp;&nbsp;<br><span class=SGTitre2>"+SG_titre2+"</span>&nbsp;&nbsp;</td>\n";
SG_bandeau_aff    += "</tr>\n";
SG_bandeau_aff    += "</table>\n";

SG_bandeau_aff    += "<table width=\"100%\" border=0 cellpadding=1 cellspacing=0><tr><td class=SGBarreBordure><table width=\"100%\" height=18 border=0 cellspacing=0 cellpadding=0 class=SGBarreFond>\n";
SG_bandeau_aff    += "<tr align=center>\n";

for(var a=0;a<SG_bandeau_libelle.length;a++)
		{
			SG_bandeau_aff    += "<td class=SGBarreFond><a href=";
			
			if (SG_bandeau_url[a]==null) 	SG_bandeau_aff    += "\"javascript://\"";
									else 	SG_bandeau_aff    += "\""+SG_bandeau_url[a]+"\"";
			
			SG_bandeau_aff    += " onMouseOver='SG_affiche("+eval(a+1)+")' onMouseOut='SG_efface()' class=SGBarreLibelle>";
			SG_bandeau_aff    += SG_bandeau_libelle[a];
			SG_bandeau_aff    += "</a></td>\n";
			if (a!=SG_bandeau_libelle.length-1)  SG_bandeau_aff += "    <td class=SGBarreFond><span class=SGBarreLibelle>|</span></td>\n";
		}

SG_bandeau_aff    += "    </tr>\n";
SG_bandeau_aff    += "</table></td></tr></table>\n";

document.writeln(SG_bandeau_aff);
}

// Generateur de menu deroulant

function SG_menu_draw(n_menu)
{

	var menu_aff = "<table border=0 cellspacing=0 cellpadding=0>\n<tr><td class=SGMenuBorder>\n<table border=0 cellspacing=1 cellpadding=1>\n";

    for(var a=0;a<SG_menu_libelle[n_menu].length;a++)
		{
	    menu_aff += "<tr height=10><td onMouseOver=\"SG_efface();this.id='SGMenuFondHover'\" onMouseout=\"this.id='SGMenuFond'\" class=SGMenuFond";
		menu_aff += ">\n";
		if (SG_menu_url[n_menu][a]!=null) menu_aff += "<a class=SGMenuLibelle href=\""+SG_menu_url[n_menu][a]+"\" onMouseOver=\"SG_efface()\">";
		menu_aff += "&nbsp;"+SG_menu_libelle[n_menu][a];
		if (SG_menu_url[n_menu][a]!=null) menu_aff += "</a>\n";
		menu_aff += "&nbsp;";
		menu_aff += "\n</td></tr>\n";
  	    }

	menu_aff += "</table>\n</td></tr>\n</table>";

    if (isMinIE4) SG_objectMenu.innerHTML = menu_aff;
   	if (isMinNS4)
     { 
   	 SG_objectMenu.document.open();
     SG_objectMenu.document.write(menu_aff);
   	 SG_objectMenu.document.close();
     }		
}		

	
// SG_afficheur de menu apres generation par la fonction SG_menu_draw()

function SG_affiche(n_menu)
{
n_menu--;
hideLayer(SG_objectMenu);

if (SG_bandeau_url[n_menu]==null)
	{
	SG_menu_draw(n_menu);
	moveLayerTo(SG_objectMenu,SG_mouseX-50,69);
	showLayer(SG_objectMenu);
	}
}

// SG_efface le menu

function SG_efface() {


if(SG_timerRunning) clearTimeout(SG_timerID);
SG_timerRunning = false; 

SG_timerID=setTimeout('hideLayer(SG_objectMenu)',2000);
SG_timerRunning = true; 
}	


//------------------------------------------------------------------------------


if (isMinNS4) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = SG_get_mouse;

SG_reloadPage(true);


