// JavaScript Document

function pulisciBox(lg) {
     if (lg == 'IT') {
	if (document.forms[0].query.value == "parole da cercare") {
		document.forms[0].query.value = "";
	}
     }
     if (lg == 'EN') {
	if (document.forms[0].query.value == "words to search") {
		document.forms[0].query.value = "";
	}
     }
     if (lg == 'DE') {
	if (document.forms[0].query.value == "Wörter suchen") {
		document.forms[0].query.value = "";
	}
     }
     if (lg == 'FR') {
	if (document.forms[0].query.value == "mots à chercher") {
		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() { 
	stripe('zebra');
	stripe('zebra1');

	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[1].length;i++) {
           document.forms[1].elements[i].disabled = "disabled";
        }
}

function attivaModulo() {
        for (i=0; i<document.forms[1].length;i++) {
           document.forms[1].elements[i].disabled = null;
        }

}


function css() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
        if (b == "ie ie7"){
           document.write("<link rel=\"stylesheet\" href=\"/costaserena/opencms/risorse/stili/schermo_ie7.css\" />");
        }
	else {
           document.write("<link rel=\"stylesheet\" href=\"/costaserena/opencms/risorse/stili/schermo.css\" />");
        }

	h.className += h.className?' '+c:c;
}











  // this function is needed to work around 
  // a bug in IE related to element attributes
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe(id) {

    // the flag we'll use to keep track of 
    // whether the current row is odd or even
    var even = false;
  
    // if arguments are provided to specify the colours
    // of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#F9F9FB";
  
    // obtain a reference to the desired table
    // if no such table exists, abort
    var table = document.getElementById(id);

    if (! table) { return; }
   
    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // &lt;tbody&gt;s 

    var tbodies = table.getElementsByTagName("tbody");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {
   
     // find all the &lt;tr&gt; elements... 
      var trs = tbodies[h].getElementsByTagName("tr");
      
      // ... and iterate through them
      for (var i = 0; i < trs.length; i++) {

        // avoid rows that have a class attribute
        // or backgroundColor style
        if (! hasClass(trs[i]) &&
            ! trs[i].style.backgroundColor) {
 		  
          // get all the cells in this row...
          var tds = trs[i].getElementsByTagName("td");
        
          // and iterate through them...
          for (var j = 0; j < tds.length; j++) {
        
            var mytd = tds[j];

            // avoid cells that have a class attribute
            // or backgroundColor style
            if (! hasClass(mytd) &&
                ! mytd.style.backgroundColor) {
        
              mytd.style.backgroundColor =
                even ? evenColor : oddColor;
            
            }
          }
        }
        // flip from odd to even, or vice-versa
        even =  ! even;
      }
    }
  }