// JavaScript Document

function pulisciBox() {
	if (document.forms[0].query.value == "parole da cercare") {
		document.forms[0].query.value = "";
	}
}

function altroSito(url, target, features) {
    var theWindow = window.open(url, '_blank2');
	window.blur();
	window.focus();
    theWindow.focus();
    return theWindow;
}

function scorriDoc(direzione) {
   if (direzione == "avanti") {
      document.forms[1].pagina.value++;
   }
   else {
      document.forms[1].pagina.value--;
   }
   document.forms[1].submit();
}


function dataOggi() {

   function dammiAnnoGiusto(d) {
      if (d < 1000) d += 1900;
      return d;
   }

        giorni = new Array ("Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato");
	mesi = new Array ("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");
	oggi = new Date;

        document.write(giorni[oggi.getDay()] + ", " + oggi.getDate() + " " + mesi[(oggi.getMonth())] + " " + dammiAnnoGiusto(oggi.getYear()) + " - " + oggi.getHours() + ":");
        minuti = oggi.getMinutes();
        if (minuti < 10 )
           minuti = "0" + minuti;
        document.write(minuti);
}

function intestazione () {
        data = new Date;
        Ora = data.getHours();
        if ((Ora > 8) && (Ora <= 12)) {
           document.write("<div id=\"intestazione3\">"); 
        }
        if ((Ora > 12) && (Ora <= 17)) {
           document.write("<div id=\"intestazione1\">"); 
        }
        if ((Ora > 17)) {
           document.write("<div id=\"intestazione2\">"); 
        }
        if ((Ora <= 8)) {
           document.write("<div id=\"intestazione2\">"); 
        }
}

function chiudiIntestazione () {
	document.write("</div>")
}


function azzeraRicerca() {
   document.forms[1].pagina.value = 1;
   document.forms[1].submit();
}

var _POPUP_FEATURES = "location='0, statusbar=0, menubar=0, scrollbars=0, resizable=0, width=700, height=400";

function raw_popup(url, target, features) {
    var theWindow = window.open(url, '_blank', _POPUP_FEATURES);
	window.blur();
	window.focus();
    theWindow.focus();
    return theWindow;
}

function externalLinks() { 
	if (!document.getElementsByTagName) return;
	   var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { 
	   var anchor = anchors[i]; 
	   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank"; 
	} 
}

function disattivaModulo() {
        for (i=3; i<document.forms[2].length;i++) {
           document.forms[2].elements[i].disabled = "disabled";
        }
}

function attivaModulo() {
        for (i=0; i<document.forms[2].length;i++) {
           document.forms[2].elements[i].disabled = null;
        }

}
