/******************************************************************************
* 14-09-2005 MP: treeMenuCode.js                                              *
*                                                                             *
* Copyright 1999 by Mike Hall.                                                *
* Web address: http://members.aol.com/MHall75819                              *
* Email: MHall75819@aol.com                                                   *
* Last update: July 23, 1999.                                                 *
*                                                                             *
* This file defines the objects and functions needed to create a tree menu    *
* and display it in a child frame. Documentation can be found at:             *
*                                                                             *
*   http://members.aol.com/MHall75819/JavaScript/tree.html                    *
*                                                                             *
* Use is permitted provided this notice remains intact.                       *
******************************************************************************/
//
// Replaces oldS with newS in the string fullS  
function replaceString(oldS,newS,fullS) {
	for (var i=0; i<fullS.length; i++) {      
		if (fullS.substring(i,i+oldS.length) == oldS) {         
			fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length);
		}
	}
	return fullS;
}


// Redazione WEB Santi Apostoli
// Personalizzazione di Marco P. 23/08/2002


//----------------------------------------------------------------------------
// Define the TreeMenuItem object.
//----------------------------------------------------------------------------

// Global index variable.

var treeMenuIndex = 0;

// Constructor.

function TreeMenuItem(text, url, target, icon) {

  this.text = text;

  if (url)
    this.url = url;
  else
    this.url = "";
  if (target)
    this.target = target;
  else
    this.target = "";
  if (icon)
    this.icon = icon;
  else
    this.icon = "";

  this.submenu = null;
  this.index = treeMenuIndex++;
  this.makeSubmenu = TreeMenuMakeSubmenu;
}

// Methods.

function TreeMenuMakeSubmenu(menu) {

  this.submenu = menu;
}

//----------------------------------------------------------------------------
// Define the TreeMenu object.
//----------------------------------------------------------------------------

// Constructor.

function TreeMenu() {

  this.items = new Array();
  this.addItem = treeMenuAddItem;
}

// Methods.

function treeMenuAddItem(item) {

  this.items[this.items.length] = item;
}

//----------------------------------------------------------------------------
// Global variables used in drawing the menu.
//----------------------------------------------------------------------------

var treeMenuDocument;       // Handle to the menu frame document.
var treeMenuWidth;          // Menu width in pixels.
var treeMenuExpand;         // Array created from first cookie.
var treeMenuSelected;       // Index of selected menu item from other cookie.
var treeMenuSelectedFound;  // Indicates if we've displayed the selected item.
var treeMenuScrollX;        // Amount to scroll the window right, if needed.
var treeMenuScrollY;        // Amount to scroll the window down, if needed.
var treeMenuLastItem;       // Flag indicating if we are on a menu's last item.
var treeMenuDepth;          // Keeps track the current menu level.
var treeMenuBars;           // Keeps track of image placement from row to row.

//----------------------------------------------------------------------------
// This function rewrites the menu document to display the menu.
//----------------------------------------------------------------------------

function treeMenuDisplay(doc) {

  var i, cookie;

  // Check for cookies with the menu state data. If not found, or if the menu
  // state has not been set, initialize it.

  cookie = getCookie(treeMenuName);
  if (!cookie) {
    if (!treeMenuExpand) {
      treeMenuExpand = new Array();
      for (i = 0; i < treeMenuIndex; i++)
        treeMenuExpand[i] = 0;
      treeMenuSelected = -1;
    }
  }
  else {
    treeMenuExpand = cookie.split(",");
    cookie = getCookie(treeMenuName + "-selected");
    if (!cookie)
      treeMenuSelected = -1;
    else
      treeMenuSelected = cookie;
  }

  // Set up reference to the menu document.

  treeMenuDocument = doc;

  // Set global variables used to draw the menu.

  treeMenuDepth = 0;
  treeMenuBars = new Array();

  // Intialize scrolling data.

  treeMenuSelectedFound = false;
  treeMenuScrollX = 36;
  treeMenuScrollY = 18;

  // Draw the menu.

  if (document.images)
    treeMenuDocument.open("text/html", "replace");
  else
    treeMenuDocument.open("text/html");

//  treeMenuDocument.writeln('<head>');
//  treeMenuDocument.writeln('<title>' + treeMenuRoot + '</title>');

//  treeMenuDocument.writeln('<link href="/scripts/treeMenuCode.css" rel="stylesheet">');
//  treeMenuDocument.writeln('</head>');
//  treeMenuDocument.writeln('<body onLoad="parent.treeMenuScroll(this);">');
//  treeMenuDocument.write('<div class="ollo"><div class="tit">');
//  treeMenuDocument.write('<h1><a class="sezione" href="#" onClick="top.alto.richiamaHome();return parent.treeMenuClickRoot();">');
//  treeMenuDocument.write(' <img border="0" src="/img/home.gif" align="left"> ' + treeMenuRoot + '&nbsp;');
//  treeMenuDocument.writeln('</a>');
//  treeMenuListItems(treeMenu);
//  treeMenuDocument.writeln('</div></div></div></div>');
//  treeMenuDocument.writeln('</body></html>');


    treeMenuDocument.writeln('<html><head>');
    treeMenuDocument.writeln('<title>' + treeMenuRoot + '</title>');
    treeMenuDocument.writeln('<link href="script/mymenu.css" rel="stylesheet">');
    treeMenuDocument.writeln('</head>');
    treeMenuDocument.writeln('<body onLoad="parent.treeMenuScroll(this);">');
    treeMenuDocument.writeln('<div class="miomenu">');
    treeMenuDocument.writeln('<table class="sielta" bordercolor=white border=0 cellpadding=2 cellspacing=0" width=95%>');
    treeMenuDocument.write('<tr valign=top><td>');
    treeMenuDocument.write('<img src="' + treeMenuImgDir + 'menu_root.gif" border=0 vspace=0 hspace=0>');
    treeMenuDocument.write('<img src="' + treeMenuImgDir + 'close.gif" align=left border=0 vspace=0 hspace=0>');
    treeMenuDocument.write('<a class="null" href="home_page.htm" onClick="return parent.treeMenuClickRoot();">');	
    treeMenuDocument.write('&nbsp;' + treeMenuRoot);
    treeMenuDocument.writeln('</td></tr>');
    treeMenuListItems(treeMenu);
	
// quello che segue è la parte bassa del frame del menù

    treeMenuDocument.write('</table>');
    treeMenuDocument.write('<br />');
    treeMenuDocument.write('<!--WEBBOT bot="HTMLMarkup" startspan ALT="Site Meter" -->');
    treeMenuDocument.write('<a href="http://s11.sitemeter.com/stats.asp?site=s11miraf" target="_top">');
    treeMenuDocument.write('<img src="http://s11.sitemeter.com/meter.asp?site=s11miraf" alt="Site Meter" border=0></a>');
    treeMenuDocument.write('<!--WEBBOT bot="HTMLMarkup" endspan -->');
    treeMenuDocument.writeln('</div>');
    treeMenuDocument.write('</body></html>');

  
    treeMenuDocument.close();



  // Prova
  //treeMenuShowAllItems(treeMenu);

}

//----------------------------------------------------------------------------
// This function rewrites the MAP document to display the menu.
//----------------------------------------------------------------------------

function treeMapDisplay(doc) {

  var i, cookie;
  var s;
  var a;
  var l;
  var pagina = "";
  var n_articoli = 0;

  var MOYArray = new Array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");
  var LastModDate = new Date();
		// Problemi con Mozilla
	if (LastModDate.getYear() < 1900) {
       var Anno = LastModDate.getYear() + 1900;
	} else {
		   var Anno = LastModDate.getYear();
	}
  var Data = LastModDate.getDate() + " " + MOYArray[LastModDate.getMonth()] + " " + Anno;

	
  // Draw the MAP.

  if (document.images)
    doc.open("text/html", "replace");
  else
    doc.open("text/html");

  doc.writeln('<html><head>');
  doc.writeln('<title>Mappa del sito</title>');
  doc.writeln('<link href="../../scripts/sap.css" rel="stylesheet">');
  doc.writeln('<base target="_parent">');
  doc.writeln('</head>');
  doc.writeln('<body>');
  doc.writeln('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1 width=100%>');
  doc.writeln('<tr><td colspan=2 class="tit">Mappa del sito</td></tr>');
  doc.writeln('</table>');

  // Attenzione al "tappo" al fondo del menu
  for (i = 0; i < (treeMenu.items.length - treeMenuTappo); i++) {

	// Sezione
  	pagina += "<h1>&nbsp;&nbsp;&nbsp;&nbsp;" + treeMenu.items[i].text + "</h1>\n";

	for (a = 0; a < treeMenu.items[i].submenu.items.length; a++) {

		// Argomento
  		pagina += "<h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + treeMenu.items[i].submenu.items[a].text + "</h2>\n";
  		pagina += "<ul>\n";

		for (l = 0; l < treeMenu.items[i].submenu.items[a].submenu.items.length; l++) {

			// Articolo
			var url = "javascript:top.alto.aggiornaNavigazione" + treeMenu.items[i].submenu.items[a].submenu.items[l].url;
  			pagina += "<li><a href=\"" + url + "\">" + treeMenu.items[i].submenu.items[a].submenu.items[l].text + "</a></li>\n";
			n_articoli++;
		}
  		pagina += "</ul>\n";
	}
  }

//alert(pagina);
n_articoli += 2;

  doc.writeln('<p>Al ' +  Data + ' il sito si compone di ' + n_articoli + ' articoli</p>');

  doc.writeln('<h1>Pagina Iniziale</h1>');

  doc.writeln(pagina);
				doc.writeln("<div class=\"right1\">");
        doc.writeln("<a style=\"padding-left: 1.5em;\" href=\"javascript:window.print();\">Stampa</a>");
        doc.writeln("<a style=\"padding-left: 1.5em;\" href=\"javascript:top.alto.spedisci();\">Spedisci ad un amico</a>");
        doc.writeln("<a style=\"padding-left: 1.5em; padding-right: 1.5em;\" href=\"http://www.santiapostoli.org\" target=\"_top\">Vai al sito</a>");
  doc.writeln('</div></body></html>');
  doc.close();

}


//----------------------------------------------------------------------------
// Questa funzione cerca la sezione dato un determinato articolo.
//----------------------------------------------------------------------------

function treeMenuFindSection(sezione, argomento, articolo) {

  var i;
  var s;
  var a;
  var l;


  //
  // Tutti i possibili casi (1, 1, 1) (1,1,1) (1, 1,1) (1,1, 1)
  //
  var searchValue1 = "(" + sezione + ", " + argomento + ", " + articolo + ")";
  var searchValue2 = "(" + sezione + "," + argomento + "," + articolo + ")";
  var searchValue3 = "(" + sezione + ", " + argomento + "," + articolo + ")";
  var searchValue4 = "(" + sezione + "," + argomento + ", " + articolo + ")";

  // Attenzione al "tappo" al fondo del menu
  for (i = 0; i < (treeMenu.items.length - treeMenuTappo); i++) {
	for (a = 0; a < treeMenu.items[i].submenu.items.length; a++) {
		for (l = 0; l < treeMenu.items[i].submenu.items[a].submenu.items.length; l++) {
			stringName = treeMenu.items[i].submenu.items[a].submenu.items[l].url;

			if ((stringName == searchValue1) || (stringName == searchValue2) || (stringName == searchValue3) || (stringName == searchValue4)) {

				// Set up redraw the menu frame.
				parent.treeMenuClick(treeMenu.items[i].index, false, true);
			}
		}
	}
  }

}

//----------------------------------------------------------------------------
// Questa funzione cerca l'argomento dato un determinato articolo.
//----------------------------------------------------------------------------

function treeMenuFindArgument(sezione, argomento, articolo) {

  var i;
  var s;
  var a;
  var l;
  //var searchValue = "(2, 1, 1)";

  //
  // Tutti i possibili casi (1, 1, 1) (1,1,1) (1, 1,1) (1,1, 1)
  //
  var searchValue1 = "(" + sezione + ", " + argomento + ", " + articolo + ")";
  var searchValue2 = "(" + sezione + "," + argomento + "," + articolo + ")";
  var searchValue3 = "(" + sezione + ", " + argomento + "," + articolo + ")";
  var searchValue4 = "(" + sezione + "," + argomento + ", " + articolo + ")";

  // Attenzione al "tappo" al fondo del menu
  for (i = 0; i < (treeMenu.items.length - treeMenuTappo); i++) {
	for (a = 0; a < treeMenu.items[i].submenu.items.length; a++) {
		for (l = 0; l < treeMenu.items[i].submenu.items[a].submenu.items.length; l++) {
			stringName = treeMenu.items[i].submenu.items[a].submenu.items[l].url;

			if ((stringName == searchValue1) || (stringName == searchValue2) || (stringName == searchValue3) || (stringName == searchValue4)) {

				// Set up redraw the menu frame.
				parent.treeMenuClick(treeMenu.items[i].submenu.items[a].index, false, true);
			}
		}
	}
  }

}


//----------------------------------------------------------------------------
// This function shows each item in the given menu or submenu.
//----------------------------------------------------------------------------

function treeMenuShowAllItems(menu) {

  var i;
  var s;
  var a;
  var l;

  // Attenzione al "tappo" al fondo del menu
  for (i = 0; i < (menu.items.length - treeMenuTappo); i++) {
	alert("sezione: " + menu.items[i].text + "\n  n. argomenti: " + menu.items[i].submenu.items.length);
	for (a = 0; a < menu.items[i].submenu.items.length; a++) {
		alert("argomento: " + menu.items[i].submenu.items[a].text + "\n  n. articoli: " + menu.items[i].submenu.items[a].submenu.items.length);
		for (l = 0; l < menu.items[i].submenu.items[a].submenu.items.length; l++) {
			alert("articolo: " + menu.items[i].submenu.items[a].submenu.items[l].url);
		}
	}
  }

}

//----------------------------------------------------------------------------
// This function displays each item in the given menu or submenu.
//----------------------------------------------------------------------------

function treeMenuListItems(menu) {

  var i;

  for (i = 0; i < menu.items.length; i++) {
    if (i == menu.items.length - 1)
      treeMenuLastItem = true;
    else
      treeMenuLastItem = false;
    treeMenuDisplayItem(menu.items[i]);
  }

}

//----------------------------------------------------------------------------
// This displays a single menu or submenu item.
//----------------------------------------------------------------------------

function treeMenuDisplayItem(item) {

  var bars, cmd, expanded, i, img, alt, link, more, submenu;

  // Update vertical scrolling amount until we find the selected item.

  if (item.index == treeMenuSelected)
    treeMenuSelectedFound = true;
  if (!treeMenuSelectedFound)
    treeMenuScrollY += 18;

  // If this item is a submenu, determine if should be expanded. For older
  // browsers, always expand.

  if (treeMenuExpand[item.index] == 1)
    expanded = true;
  else
    expanded = false;

  // Define the command used when an item is clicked. For older browsers, just
  // return true or false so links will be followed.

  if (item.submenu)
    submenu = true;
  else
    submenu = false;
  if (item.url != "")
    link = true;
  else
    link = false;
  cmd = "return parent.treeMenuClick(" + item.index + ", " + link + ", " + submenu + ");";

  // Start the table row.

  treeMenuDocument.write('<tr valign=top><td>');

  // Draw descending bars from upper levels, also set horizontal scrolling
  // amount if this is the selected item.

  bars = new Array();
  for (i = 0; i < treeMenuDepth; i++) {
    if (treeMenuBars[i]) {
      treeMenuDocument.write('<img src="' + treeMenuImgDir + 'menu_bar.gif" align=left border=0 vspace=0 hspace=0>');
      bars[i] = true;
    }
    else {
      treeMenuDocument.write('<img src="' + treeMenuImgDir + 'menu_spacer.gif" align=left border=0 vspace=0 hspace=0>');
      bars[i] = false;
    }
    if (item.index == treeMenuSelected)
      treeMenuScrollX += 18;
  }

  // Determine if this is a submenu item that contains other submenus.

  more = false;
  if (item.submenu && treeMenuFolders >= 0)
    for (i = 0; i < item.submenu.items.length; i++)
      if (item.submenu.items[i].submenu != null || treeMenuFolders == 1)
        more = true;

  // Draw tee bar or corner if this item is not a submenu or if it is a
  // submenu but doesn't contain other submenus.

  if (!more) {
    if (treeMenuLastItem) {
      img = "menu_corner.gif";
      bars[bars.length] = false;
    }
    else {
      img = "menu_tee.gif";
      bars[bars.length] = true;
    }
    treeMenuDocument.write('<img src="' + treeMenuImgDir + img + '" align=left border=0 vspace=0 hspace=0>');
  }

  // Write the start of the link tag so all of the following images and text
  // will be clickable.

  if (item.url != "")
//    treeMenuDocument.write('<div class="linc"><a href="' + item.url + '" target="' + item.target + '" onClick="' + cmd + '">');
      treeMenuDocument.write('<div class="linc"><a href="' + item.url + '" target="' + item.target + '">');
  else
    treeMenuDocument.write('<a href="#" onClick="' + cmd + '">');

  // For a submenu item that contains other submenus, draw a tee bar or corner
  // with a plus or minus sign.

  if (more) {
    if (expanded) {
      if (treeMenuLastItem) {
        img = "menu_corner_minus.gif";
        bars[bars.length] = false;
      }
      else {
        img = "menu_tee_minus.gif";
        bars[bars.length] = true;
      }
    }
    else {
      if (treeMenuLastItem) {
        img = "menu_corner_plus.gif";
        bars[bars.length] = false;
      }
      else {
        img = "menu_tee_plus.gif";
        bars[bars.length] = true;
      }
    }
    treeMenuDocument.write('<img src="' + treeMenuImgDir + img + '" align=left border=0 vspace=0 hspace=0>');
  }

  // If the item is a submenu, draw an open or closed folder icon. Otherwise
  // draw a link icon.

  if (item.submenu) {
    if (expanded)
      img = "menu_folder_open.gif";
    else
      img = "menu_folder_closed.gif";
  }
  else {
    if (item.icon != "")
      img = item.icon;
    else if (item.url.indexOf("http://") == 0)
      img = "menu_link_external.gif";
    else
      img = "menu_link_local.gif";
  }
  if (treeMenuAltText)
    alt = ' alt="' + item.text + '"';
  else
    alt = '';
  treeMenuDocument.write('<img src="' + treeMenuImgDir + img + '"' + alt + ' align=left border=0 vspace=0 hspace=0>');

  // Write the link text and finish the link and table row.

  if (item.index == treeMenuSelected)
    treeMenuDocument.write(item.text);
//		    treeMenuDocument.write('<span class="selected">&nbsp;' + item.text + '&nbsp;</span>');
  else
    treeMenuDocument.write(item.text);
  treeMenuDocument.write('</a>');
  treeMenuDocument.writeln('</td></tr>');

  // Set the placement of vertical bars needed for the next row.

  treeMenuBars = bars;

  // If the item is a submenu and it is expanded, make a recursive call to
  // draw its item list.

  if (item.submenu && expanded) {
    treeMenuDepth++;
    treeMenuListItems(item.submenu);
    treeMenuDepth--;
  }
}


//----------------------------------------------------------------------------
// This function handles a click on a menu item.
//----------------------------------------------------------------------------

function treeMenuClick(n, link, submenu) {

  var date, cookie;

  // Fix bug that occurs when the top-level page is reloaded.

  if (!treeMenuExpand)
    treeMenuDisplay(treeMenuDocument);

  // If this is a submenu, toggle the expansion flag.

  if (submenu)
    treeMenuExpand[n] = 1 - treeMenuExpand[n];

  // Save the selected item index and update the cookies.

  treeMenuSelected = n;
  var date = new Date ();
  date.setTime (date.getTime() + (86400 * 1000 * treeMenuDays));
  cookie = treeMenuExpand.toString();
  setCookie(treeMenuName, cookie, date)
  setCookie(treeMenuName + "-selected", treeMenuSelected, date)

  // Set up redraw the menu frame.
  treeMenuDisplay(treeMenuDocument);

  // Return the link flag.

  return link;
}

//----------------------------------------------------------------------------
// This function handles a click on the menu root.
//----------------------------------------------------------------------------

function treeMenuClickRoot() {

  // Clear the menu state.

  treeMenuExpand = null;
  treeMenuSelected = null;

  // Delete cookies.

  deleteCookie(treeMenuName);
  deleteCookie(treeMenuName + "-selected");

  // Set up redraw the menu frame.
  treeMenuDisplay(treeMenuDocument);

  return false;
}

//----------------------------------------------------------------------------
// This function scrolls the window to ensure the selected item is in view.
// It should only be called after the page has loaded.
//
// Note: This code is browser-dependent. Scrolling may be ignored for older
// browsers.
//----------------------------------------------------------------------------

function treeMenuScroll(mappa) {

  var win, height, width;

  // Get a handle to the menu frame.

  win = mappa;
  treeMenuDocument = mappa.document;

  // Find the dimensions of the frame.

  if (document.layers) {
    height = win.innerHeight;
    width = win.innerWidth;
  }
  else if (document.all) {
    height = win.document.body.clientHeight;
    width = win.document.body.clientWidth;
  }
  else if (document.images) {
    win.scroll(0, treeMenuScrollY);
    return;
  }
  else
    return;

  // Scroll the frame if necessary.

  if (treeMenuScrollY > height)
    win.scrollBy(0, treeMenuScrollY);
  if (treeMenuScrollX > width)
    win.scrollBy(treeMenuScrollX, 0);
}

//----------------------------------------------------------------------------
// Set a cookie given a name, value and expiration date.
//----------------------------------------------------------------------------


function setCookie (name, value, expires) {
}

//----------------------------------------------------------------------------
// Returns the value of the named cookie.
//----------------------------------------------------------------------------

function getCookie(name) {
   return "";
}

//----------------------------------------------------------------------------
// Delete the named cookie.
//----------------------------------------------------------------------------

function deleteCookie(name) {
}


//----------------------------------------------------------------------------
// Crea la pagina degli articoli arretrati.
//----------------------------------------------------------------------------

function treeArretratiDisplay(doc, sezione, argomento) {

  var i, cookie;
  var s;
  var a;
  var l;
  var pagina = "";
  var arg_titolo = "";

  var MOYArray = new Array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");
  var LastModDate = new Date();
  var Data = LastModDate.getDate() + " " + MOYArray[(LastModDate.getMonth()+1)] + " " + LastModDate.getYear();

  // Draw the MAP.

  if (document.images)
    doc.open("text/html", "replace");
  else
    doc.open("text/html");

  doc.writeln('<html><head>');
  doc.writeln('<title></title>');
  doc.writeln('<link rel="stylesheet" href="../../scripts/sap.css" type="text/css">');
  doc.writeln('</head>');
  doc.writeln('<body>');
  doc.writeln('<TABLE width="100%">');
  doc.writeln('<tr><td class="tit">Articoli arretrati</td></tr>');
  doc.writeln('</table>');

  //
  // Tutti i possibili casi: "(1, 1," oppure "(1,1,"
  //
  var searchValue1 = "(" + sezione + ", " + argomento + ",";
  var searchValue2 = "(" + sezione + ","  + argomento + ",";

  pagina = "<ul>\n";

  // Attenzione al "tappo" al fondo del menu
  for (i = 0; i < (treeMenu.items.length - treeMenuTappo); i++) {
	for (a = 0; a < treeMenu.items[i].submenu.items.length; a++) {
		for (l = 0; l < treeMenu.items[i].submenu.items[a].submenu.items.length; l++) {

			var stringName = treeMenu.items[i].submenu.items[a].submenu.items[l].url;

			// E' un articolo dell'Argomento corrente

			if ((stringName.indexOf(searchValue1) >= 0) || (stringName.indexOf(searchValue2) >= 0)) {

				arg_titolo = treeMenu.items[i].submenu.items[a].text;

				//alert(stringName.indexOf(searchValue1));
				//alert(stringName.indexOf(searchValue2));

				// Articolo arretrato
				if (treeMenu.items[i].submenu.items[a].submenu.items[l].target == "") {
					var url = "javascript:top.alto.aggiornaNavigazione" + treeMenu.items[i].submenu.items[a].submenu.items[l].url;
  					pagina += "<li><a href=\"" + url + "\">" + treeMenu.items[i].submenu.items[a].submenu.items[l].text + "</a></li>\n";
				}
			}

		}
	}
  }

  pagina += "</ul>\n";

//alert(pagina);

  doc.writeln('<P class="centrale">In questa pagina sono elencati tutti gli arretrati del "' + arg_titolo + '"</P>');
  doc.writeln(pagina);

  doc.writeln('<hr>');
  doc.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  doc.write("<a href=\"javascript:window.print();\">Stampa</a>");
  doc.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  doc.write("<a href=\"javascript:top.alto.spedisci();\">Spedisci ad un amico</a>");
  doc.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  doc.write("<a href=\"http://www.santiapostoli.it\" target=\"_top\">Vai al sito</a>");
  doc.write("<br><br>");


  doc.writeln('</body></html>');
  doc.close();

}
