// script preparato da sergio.vaccaro@istat.it - sergio.vaccaro@iol.it

// preload delle icone per la stampa e per la lente d'ingrandimento
//stampazzurro = new Image;
//stampazzurro.src="/images/stampa_azzurro.gif";
//ingrandisciazzurro = new Image;
//ingrandisciazzurro.src="/images/ingrandisci_azzurro.gif";

// funzione per il ridimensionamento del font del titolo, a seconda della lunghezza
function change_size() {
		 var min_size = 18;
         var max_size = 25;
         var elem_titolone = document.getElementById("titolone");
         var elem_descrizione = document.getElementById("descrizione");
		 var myHead = elem_titolone.innerHTML;
		 var targetSize = myHead.length;
		 var mySize = (elem_descrizione.offsetWidth/targetSize)*1.54;
		 if (mySize < min_size) {
		 	mySize = min_size;
			} else if (mySize > max_size) {
			mySize = max_size;
			}
		 elem_titolone.style.fontSize = mySize+'px';
		 }

// funzione per l'ingrandimento del testo della pagina
function ingrandisci(titolo,titolotesto,testo) {
		 with (document) {
		 	  var elem_descrizione = getElementById("descrizione");
			  var descrizione_html = elem_descrizione.innerHTML;
			  var elem_titolone = getElementById("titolone");
			  var titolone_html = elem_titolone.innerHTML;
			  var elem_testo = getElementById("testo");
			  var testo_html = elem_testo.innerHTML;
			  }
		 testogrande = window.open("","TestoGrande","directories=no,height=400,location=no,menubar=yes,screenX=10,screenY=10,scrollbars,status=no,titlebar=no,toolbar=yes,width=600");
		 with (testogrande.document) {
		 	  open();
			  writeln("<html>");
			  writeln("<head>");
			  writeln("<title>Istat - "+titolone_html+"</title>");
			  writeln("<meta http-equiv=\"Content-Style-Type\" content=\"text/css\">");
			  writeln("<style>");
			  writeln("body {margin: 24px;}");
			  writeln("h1 {font-size: 16px; margin-top: 0px; padding-top: 0px; padding-bottom: 16px;}");
			  writeln("h5 {font-size: 100%; font-weight: bold; margin: 0; padding: 0 0 2px 0; border-bottom: 1px solid #ccc;}");
			  writeln("body, td, p {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;}");
			  writeln("p {text-indent: 0px; text-align: justify;}");
			  writeln("ul {text-align: justify;}");
			  writeln("a {text-decoration: none; color: #9c1e3d;}");
			  writeln("a:hover {text-decoration: underline;}");
			  writeln("</style>");
			  writeln("<base target=\"www_principale\">");
			  writeln("</head>");
			  writeln("<body>");
			  writeln("<img src=\"/images/istat.gif\" width=\"150\" height=\"36\" alt=\"Istat\"><br><br>\n");
			  writeln(descrizione_html);
			  writeln(testo_html);
			  writeln("<br>");
			  writeln("<hr width=\"100%\" size=\"1\" noshade>");
			  writeln("<p span style=\"font-size: 10px;\">Questa pagina ha il solo scopo di fornire leggibilità e chiarezza al testo. Il suo contenuto è da intendersi esclusivamente come il testo estratto da una pagina più ampia e dettagliata. Ogni utilizzo delle informazioni qui contenute dovrà essere inteso pertanto come corredato delle note e dei collegamenti presenti sulla pagina di partenza.</p>");
			  writeln("</body>");
			  writeln("</html>");
			  close();
			  }
		 }

// funzioni per la selezione o deselezione completa dei box a selezione multipla
function seleziona(form,box) {
		 for (k=0; k<document.forms[form].elements[box].options.length; k++) {
		 	 document.forms[form].elements[box].options[k].selected=true;
			 }
		 }
function deseleziona(form,box) {
		 for (k=0; k<document.forms[form].elements[box].options.length; k++) {
		 	 document.forms[form].elements[box].options[k].selected=false;
			 }
		 }

// funzione per la stampa del testo della pagine, menu esclusi
function stampa(titolo_prn,titolotesto_prn,testo_prn) {
		 ingrandisci(titolo_prn,titolotesto_prn,testo_prn);
		 testogrande.print();
		 testogrande.close();
		 }

// funzione per i moduli
function apri_modulo(url) {
         modulo=window.open(url,'modulo',"height=480,screenX=10,screenY=10,width=740,scrollbars");
         }

function htsubmit() {
         if (document.htsearch.words.value.length>0) {
            document.htsearch.action="http://cerca-www.istat.it/cgi-bin/htsearch";
            } else {
            document.htsearch.action="http://www.istat.it/cerca/";
            }
         document.htsearch.submit();
         }

