
var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isDyn = (isDOM || isIE4 || isNS4);


function getRef(id)
{
 if (isDOM) return document.getElementById(id);
 if (isIE4) return document.all[id];
 if (isNS4) return document.layers[id];
}

function getSty(id)
{
 return (isNS4 ? getRef(id) : getRef(id).style);
} 


var popTimer = 0;

var litNow = new Array();

function popOver(menuNum, itemNum)
{
 clearTimeout(popTimer);


 hideAllBut(menuNum);


 litNow = getTree(menuNum, itemNum);
 changeCol(true);


 targetNum = menu[menuNum][itemNum].target;
 if (targetNum > 0)
 {

  thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);
  thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);


  with (menu[targetNum][0].ref)
  {
   left = thisX + menu[targetNum][0].x;
   top = thisY + menu[targetNum][0].y;
   visibility = 'visible';
  }
 }
}

function popOut(menuNum, itemNum)
{

 if ((menuNum == 0) && !menu[menuNum][itemNum].target) hideAllBut(0);
 else popTimer = setTimeout('hideAllBut(0)', 500);
}

function popClick(menuNum, itemNum)
{
 with (menu[menuNum][itemNum])
 {
  switch (type)
  {

   case 'js:': { eval(href); break }

   case '': type = 'window';
   default: eval(type + '.location.href = "' + href + '"');
  }
 }

 // Whatever happens, hide the menus when clicked.
 hideAllBut(0);
 return false;
}


function getTree(menuNum, itemNum)
{

 itemArray = new Array(menu.length);

 while(1)
 {
  itemArray[menuNum] = itemNum;

  if (menuNum == 0) return itemArray;
  itemNum = menu[menuNum][0].parentItem;
  menuNum = menu[menuNum][0].parentMenu;
 }
}


function changeCol(isOver)
{

 for (count = 0; count < litNow.length; count++)
 {

  if (litNow[count])
  {

   with (menu[count][0]) with (menu[count][litNow[count]])
   {
    newCol = isOver ? overCol : backCol;


    if (isNS4) ref.bgColor = newCol;
    else ref.backgroundColor = newCol;
   }
  }
 }
}

function hideAllBut(menuNum)
{

 var keepMenus = getTree(menuNum, 1);

 for (count = 0; count < menu.length; count++)
  if (!keepMenus[count]) menu[count][0].ref.visibility = 'hidden';


 changeCol(false);
}



function Menu(isVert, popInd, x, y, width, pad, overCol, backCol, borderClass, textClass)
{

 this.isVert = isVert;

 this.popInd = popInd
 this.x = x;
 this.y = y;
 this.width = width;
 this.pad = pad;
 this.overCol = overCol;
 this.backCol = backCol;
 this.borderClass = borderClass;
 this.textClass = textClass;
 this.parentMenu = null;
 this.parentItem = null;
 this.ref = null;
}

function Item(text, href, type, length, spacing, target)
{
 this.text = text;
 this.href = href;
 this.type = type;
 this.length = length;
 this.spacing = spacing;
 this.target = target;
 // Reference to the object's style properties (set later).
 this.ref = null;
}

function createMenus()
{
 if (!isDyn) return;

 for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0])
 {

  var str = '', itemX = 0, itemY = 0;

  if (isNS4) pad++;

  for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem])
  {
   var itemID = 'menu' + currMenu + 'item' + currItem;
   var w = (isVert ? width : length);
   var h = (isVert ? length : width);

   if (isDOM || isIE4)
   {
    str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX +
     '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; ';
    if (backCol) str += 'background: ' + backCol;
    str += '" ';
   }
   if (isNS4)
   {
    str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' + 
     w + '" height="' + h + '" visibility="inherit" ';
    if (backCol) str += 'bgcolor="' + backCol + '" ';
   }
   if (borderClass) str += 'class="' + borderClass + '" ';
   
    str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' +
     currMenu + ',' + currItem + ')" onClick="popClick(' + currMenu + ',' + currItem + ')">';


   if (target > 0)
   {
    menu[target][0].parentMenu = currMenu;
    menu[target][0].parentItem = currItem;

    if (popInd)
    {
     if (isNS4) str += '<layer class="' + textClass + '" left="'+ (w - 15) + '" top="' +
      pad + '">' + popInd + '</layer>';
     else str += '<div class="' + textClass + '" style="position: absolute; left: ' + (w - 15) +
      '; top: ' + pad + '">' + popInd + '</div>';
    }
   }

  
   if (isNS4) str += (borderClass ? '<table width="' + (w - 8) + '" border="0" cellpadding="0" ' +
    'cellspacing="0"><tr><td height="' + (h - 8) + '"></td></tr></table>' : '') + 
    '<layer left="' + pad + '" top="' + pad + '" width="' + (w - pad) + '" height="' +
     (h - pad) + '"><a class="' + textClass + '" href="javascript:void(0)">' + text + '</a></layer>';

   else str += '<div class="' + textClass + '" style="position: absolute; left: ' + pad +
    '; top: ' + pad + '">' + text + '</div>';

  
   str += (isNS4 ? '</layer>' : '</div>');

   
   var shrink = (isDOM && !document.all ? -1 : 1)
   if (isVert) itemY += length + spacing - shrink;
   else itemX += length + spacing - shrink;

  }


  if (document.all)
  {
  
   document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' +
    'style="position: absolute; width: 3; height: 3; visibility: hidden">' + str + '</div>');
   ref = getSty('menu' + currMenu + 'div');
  }
  
  else if (isDOM)
  {
   var newDiv = document.createElement('div');
   document.body.appendChild(newDiv);
   newDiv.innerHTML = str;
   ref = newDiv.style;
    
   ref.position = 'absolute';
   ref.visibility = 'hidden';
  }

  else if (isNS4)
  {
   ref = new Layer(0);
   ref.document.write(str);
   ref.document.close();
  }


  ref.left = x;
  ref.top = y;
  
  if (!isNS4) ref.cursor = (document.all ? 'hand' : 'pointer');


  for (currItem = 1; currItem < menu[currMenu].length; currItem++)
  {
   itemName = 'menu' + currMenu + 'item' + currItem;
   if (isDOM || isIE4) menu[currMenu][currItem].ref = getSty(itemName);
   if (isNS4)
   {
    menu[currMenu][currItem].ref = ref.document[itemName];
    with (ref.document[itemName])
    {
     document.captureEvents(Event.CLICK);
     document.onclick = new Function('popClick(' + currMenu + ', ' + currItem + ')');
    }
   }
  }

 }

 menu[0][0].ref.visibility = 'visible';
}



var menu = new Array();

var defOver = '#ccffcc', defBack = '#ffcc66';

var defLen = 22;

menu[0] = new Array();
menu[0][0] = new Menu(false, '', 15, 2, 18, 0, '#ffcc66', '#ffa07a', '', 'itemText');

menu[0][1] = new Item('&nbsp;Homepage&nbsp;', '../../default2.htm', '', 70, 10, 1);
menu[0][2] = new Item('&nbsp;Sfoglia Finanza&amp;Fisco', '../../sfoglia.htm', '', 140, 5, 2);
menu[0][3] = new Item('&nbsp;Contenuti', '../../cont.htm', '', 65, 5, 3);
menu[0][4] = new Item('&nbsp;Prodotti collegati', '../../prodo.htm', '', 110, 5, 4);
menu[0][5] = new Item('&nbsp;Servizi collegati', '../../quesiti.htm', '', 105, 5, 5);
menu[0][6] = new Item('&nbsp;Link utili', '../../link.htm', '', 60, 5, 6);
menu[0][7] = new Item('&nbsp;Abbonamenti&nbsp;', '../../abbonati.htm', '', 85, 1, 7);

// File menu.
menu[1] = new Array();

menu[1][0] = new Menu(true, '&gt;', 0, 22, 80, 3, defOver, defBack, 'itemBorder', 'itemText');
menu[1][1] = new Item('Torna alla Homepage', '../../default2.htm', '', 40, 0, 0);

// Edit menu.
menu[2] = new Array();
menu[2][0] = new Menu(true, '&gt;', 0, 22, 190, 3, defOver, defBack, 'itemBorder', 'itemText');
menu[2][1] = new Item('Ultimo numero on line', '../../sommario.htm', '', defLen, 0, 0);
menu[2][2] = new Item('Archivio della rivista on line', '../../archivio.htm', '', defLen, 0, 0);
menu[2][3] = new Item('Registrazione anteprima on line', '../../Anteprimaonline.htm', '', defLen, 0, 0);
menu[2][4] = new Item('Indici della rivista', '../../indici_carta.htm', '', defLen, 0, 0);

// Help menu
menu[3] = new Array();
menu[3][0] = new Menu(true, '&lt;', 0, 22, 100, 3, defOver, defBack, 'itemBorder', 'itemText');
menu[3][1] = new Item('Commenti', '../../comment.htm', '', defLen, 0, 0);
menu[3][2] = new Item('Legislazione', '../../legislazione.htm', '', defLen, 0, 0);
menu[3][3] = new Item('Prassi', '../../prassi.htm', '', defLen, 0, 0);
menu[3][4] = new Item('Giurisprudenza', '../../giurispr.htm', '', defLen, 0, 0);

// prodotti menu
menu[4] = new Array();
menu[4][0] = new Menu(true, '', 0, 22, 150, 2, defOver, defBack, 'itemBorder', 'itemText');
menu[4][1] = new Item('Dossier e raccoglitori', '../../dosserac.htm', '', defLen, 0, 0);
menu[4][2] = new Item('Indici in CD-Rom', '../../cdrom1.htm', '', defLen, 0, 0);
menu[4][3] = new Item('La rivista in CD-Rom', '../../cdrom2.htm', '', defLen, 0, 8);

// prodotti menu
menu[5] = new Array();
menu[5][0] = new Menu(true, '&gt;', 0, 22, 110, 2, defOver, defBack, 'itemBorder', 'itemText');
menu[5][1] = new Item('Numero verde', '../../quesiti.htm', '', defLen, 0, 0);


// prodotti menu
menu[6] = new Array();
menu[6][0] = new Menu(true, '&gt;', 0, 22, 80, 2, defOver, defBack, 'itemBorder', 'itemText');
menu[6][1] = new Item('Link utili', '../../link.htm', '', defLen, 0, 0);


// prodotti menu
menu[7] = new Array();
menu[7][0] = new Menu(true, '&gt;', 0, 22, 120, 2, defOver, defBack, 'itemBorder', 'itemText');
menu[7][1] = new Item('Sei possibilità diverse per personalizzare il tuo abbonamento', '../../abbonati.htm', '', 70, 0, 0);


// prodotti menu
menu[8] = new Array();
menu[8][0] = new Menu(true, '&gt;', 100, 22, 210, 2, defOver, defBack, 'itemBorder', 'itemText');
menu[8][1] = new Item('5 anni di rivista in un solo CD-Rom', '../../cdrom2.htm', '', defLen, 0, 0);



window.onload = createMenus;
window.onresize = resizeHandler;



var popOldWidth = window.innerWidth;
function resizeHandler()
{
 if (isNS4 && popOldWidth != window.innerWidth) location.reload()

}



function colItem(text, href, type, length, spacing, overCol, backCol, target)
{
 this.text = text;
 this.href = href;
 this.type = type;
 this.length = length;
 this.spacing = spacing;
 this.overCol = overCol;
 this.backCol = backCol;
 this.target = target;
 this.ref = null;
}


