﻿// Fichier JScript
// Menu Dynamique pour Oxatis
// Version 1.3 
// Copyright AG System 2008
var ccollect=new Array();if (document.getElementById){document.write('<style type="text/css">')document.write('.switchcontent{display:none;}')document.write('</style>')}function openlink( target)
 {
  var texte= escape(window.location);
  var test = escape(target);
 if ( texte.indexOf(test) == -1 ) window.location = target; 
 } function getElementbyClass(classname){var inc=0var alltags=document.all ? document.all : document.getElementsByTagName("*")for (i=0; i<alltags.length; i++){if (alltags[i].className==classname)ccollect[inc++]=alltags[i]}}function contractcontent(omit){var inc=0while (ccollect[inc]){if (ccollect[inc].id!=omit)ccollect[inc].style.display="none"inc++}}// if sub menu already open leave it openfunction expandcontent(cid){if (document.getElementById(cid).style.display=="block") return;if (typeof ccollect!="undefined"){    if (collapseprevious=="yes")        contractcontent(cid)    document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"    }}function getMenubyUrl(MENU,PARAM){var nomenu=-1;
var searchUrl = window.location.toString();
 for (i=0;i<MENU.length;i++)
 {
   header = MENU[i][0].toString().split(",");
   if ( header[2] != "" )
   {
      if ( searchUrl.indexOf(header[2]) != -1 || searchUrl.indexOf(header[2].toLowerCase()) != -1) {
      // Url found and something to expand
       if  (MENU[i].length > 1 ) return PARAM['id']+i.toString();
       else return nomenu;
      }
   }
   // Any items ??
   if (MENU[i].length > 1 )  {
    // Look in submenu items
      for (j=1;j<MENU[i].length;j++){
        content = MENU[i][j].toString().split(",");
       // Is there a link
       if ( content[2] !=""){
           if ( searchUrl.indexOf(content[2]) != -1 || searchUrl.indexOf(header[2].toLowerCase()) != -1 )
             return PARAM['id']+i.toString(); 
         }
      }
    }
  }  return nomenu;}function do_onload(MENU,PARAM){var inMenu = getMenubyUrl(MENU,PARAM);    if (inMenu != -1 )   expandcontent(inMenu);}

 function  setColors(objet, couleur, fond)
 {
 objet.style.color= couleur;
 objet.style.background= fond;
 }
 
 
 function createMenu(MENU,PARAM)
{
// Write Top DIV
   var texte ="<div style=\"left:"+ PARAM['posxbar'];
   texte+= "; top:" + PARAM['posybar']; 
   texte+= "; width:" + PARAM['widthbar'];
   texte+= "; padding:" +PARAM['paddingbar'];
   texte+= "; color:" +PARAM['menufontcolor'];
   texte+= "; font-size:" +PARAM['menufontsize'];
   texte+= "; font-family:" +PARAM['menufont'];
   texte+= "; font-weight:" +PARAM['menufontweight'];
   texte+= "; position: relative; text-align:"+PARAM['menutextalign']+";\">";
   document.write(texte);
// Write TOP MENU
for (i=0;i<MENU.length;i++)
 {
   header = MENU[i][0].toString().split(",");
   texte = " <div ";
   // Any items ??
   if (MENU[i].length > 1 )
   {
   texte+= "onclick=\" ";
   }
   if ( header[2] != "" )
   {
        if (MENU[i].length > 1 )
       {
       texte+= "openlink('"+header[2]+"');";
       }
       else
       {
       texte+= "onclick=\" contractcontent('omitnothing'); openlink('"+header[2]+"');";
       }
   }
   texte+= "\" style=\"";
   texte+= " height:"+PARAM['menuimageheight'];
   texte+= "; line-height:"+PARAM['menuimageheight'];
   texte+= "; margin:"+ PARAM['menumargin'];
   texte+= "; background-color:"+PARAM['menubgcolor'];
   texte+= "; cursor: pointer\">";
   if ( header[1] != "" )
   {
  texte+= "<img alt=\""+header[0]+"\" src=\""+imagesfolder+header[1]+"\" style=\"float: none; clear:both;\" /><br/>";
   }
   texte+= header[0] + "</div>";
   document.write(texte);
   // Any items ??
   if (MENU[i].length > 1 ) 
   {
       texte = "<div id=\""+ PARAM['id'] +i.toString()+"\" class=\"switchcontent\" style=\"width:"+PARAM['menuwidth']+"\" >";
     document.write(texte);
    // Write Menu items
        for (j=1;j<MENU[i].length;j++)
          {
           texte= "<div "; 
           content = MENU[i][j].toString().split(",");
           // Is there a link
           if ( content[2] !="")
             {
             texte+= " onmouseout=\"setColors(this,'"+PARAM['itemfontcolor']+"','"+PARAM['itembgcolor']+"')\"";
             texte+= " onmouseover=\"setColors(this,'"+PARAM['itemfontcolorover']+"','"+PARAM['itembgcolorover']+"')\"";
             texte+= " onclick=\"openlink('"+content[2]+"')\" ";
             texte+= " style=\"cursor: pointer;";
             }
             else  {  texte+= " style=\"";}
           texte+= " text-align:"+PARAM['itemtextalign']+"; text-decoration:none; color: "+PARAM['itemfontcolor']+"; background-color:"+PARAM['itembgcolor'];
           texte+= ";  font-weight:" +PARAM['itemfontweight']+"; font-size:" +PARAM['itemfontsize']+ "\" >" ;
           // Is there an image
           if ( content[1] !="")
             {
             texte+= "<img alt=\""+content[0]+"\" src=\""+imagesfolder+content[1]+"\" style=\"float: none; clear:both;\" /><br/>";
             }
             texte+= content[0] + "</div>";
             document.write(texte);
            
          }
       document.write("</div>");
   }
  }
document.write("</div>");
do_onload(MENU,PARAM);
} 
