//=================================================
//==  script by Stefano Roncari - www.syntax.it  ==
//=================================================

ns4 = (document.layers) ? true:false
ie = (document.all) ? true:false
op5 = (navigator.userAgent.indexOf('Opera') != -1) ? true:false
ns6 = (document.getElementById) ? true:false

function centerDivs()
{
   if (ns4){
      //alert('Ns4!');
      up = document.layers.divUpControl;
      down = document.layers.divDownControl;
      container = document.layers.divContainer;
      menu = document.layers.menuHomeDiv;
      menu.top = 72; // Ns4 posiziona il layer sbagliato in altezza;
      centerPage = window.innerWidth/2 - 10;
   }
   else if (op5){
      //alert('Op5!');
      up = document.all.divUpControl.style;
      down = document.all.divDownControl.style;
      container = document.all.divContainer.style;
      menu = document.all.menuHomeDiv.style;
      menu.top = 66; // Opera posiziona il layer sbagliato in altezza;
      centerPage = (window.innerWidth/2);
   }
   else if (ie){
      //alert('IE');
      up = document.all.divUpControl.style;
      down = document.all.divDownControl.style;
      container = document.all.divContainer.style;
      menu = document.all.menuHomeDiv.style;
      centerPage = document.body.clientWidth/2;  // normalmente si usa document.body.scrollWidth, ma dà problemi con IE 4.01
   }
   else if (ns6){
      //alert('Ns6!');
      up = document.getElementById('divUpControl').style;
      down = document.getElementById('divDownControl').style;
      container = document.getElementById('divContainer').style;
      menu = document.getElementById('menuHomeDiv').style;
      centerPage = 335; 
      //Ns6 rileva il centro della pagina in modo diverso a seconda che le scrollbars siano visibili o invisibili, sicché in ns6 si allinea il sito a sinistra.
   }


   if (centerPage <= 335){
      up.left = 641;
      down.left = 641;
      container.left = 452;
      menu.left = 511;
   }

   else
   { 
      up.left = centerPage + 306;
      down.left = centerPage + 306;
      container.left = centerPage + 117;
      menu.left = centerPage + 176;
   }
   
   up.visibility = 'visible';
   down.visibility = 'visible';
   container.visibility = 'visible';
   menu.visibility = 'visible';
}