/* Overture d'un sous-menu */
function openSub(num)
{		
  var menu;
  var sub;
  
  if (!document.getElementById('menu_' + num))
  {
    menu = document.all['menu_' + num];
    sub = document.all['sub_' + num];
  }
	else
  {
    menu = document.getElementById('menu_' + num);
    sub = document.getElementById('sub_' + num);
  }
	if (menu.className.match(/menu_item/g) && menu.className.match(/container/g) && !menu.className.match(/open/g))
	{
	  menu.className = "menu_item container open";
		sub.style.display = "";
	}
	else
	{
	  menu.className = "menu_item container";
		sub.style.display = "none";
	}
}

/* Ajout d'une fonction à onload */
function addLoadEvent(func)
{
   var oldonload = window.onload;
   if (typeof window.onload != "function")
   {
      window.onload = func;
   } 
   else 
   {
      window.onload = function() 
      {
         if (oldonload) 
         {
            oldonload();
         }
         func();
      };
   }
}

/* Ajout d'une fonction à onresize */
function addResizeEvent(func)
{
   var oldonresize = window.onresize;
   if (typeof window.onresize != "function")
   {
      window.onresize = func;
   } 
   else 
   {
      window.onresize = function() 
      {
         if (oldonresize) 
         {
            oldonresize();
         }
         func();
      };
   }
}

/* Affiche un layer translucide qui bloque la page*/
page_lock_show = false;
addResizeEvent(page_lock_resize);

function page_lock_resize()
{
  if (page_lock_show)
  {
    page_lock(true);
  }
}

function page_lock(show)
{
  var lock_layer;
  if (!document.getElementById('lock_layer'))
  {
    lock_layer = document.all['lock_layer'];
  }
	else
  {
    lock_layer = document.getElementById('lock_layer');
  }
  
  if (show)
  {
    var layer_height;
    var layer_width;
    
    if( document.body.clientHeight > document.documentElement.clientHeight)
    {
      layer_height = document.body.clientHeight;
    }
    else
    {
      layer_height = document.documentElement.clientHeight;
    }
    
    if( document.body.clientWidth > document.documentElement.clientWidth)
    {
      layer_width = document.body.clientWidth;
    }
    else
    {
      layer_width = document.documentElement.clientWidth;
    }
  
  
    lock_layer.style.display = "block";
    lock_layer.style.height = layer_height + "px";
    lock_layer.style.width = layer_width + "px";
  }  
  else
  {
    lock_layer.style.display = "none";
  }
}

function print_page()
{
  window.print();
}
