function esplodicond() {
  var el = document.getElementById('idcondivisione');
  if (el) {
    if (el.style.display == '') {
      el.style.display = 'none';
    }
    else {
      el.style.display = '';
    }
  }
}

function PopupCentrataA(posizione,notizia,w,h) {
  window.open("http://www.sardegnaambiente.it/index.php?xsl=656&s=18&v=9&c=4545&notizia="+notizia+"&pic="+posizione,"","width="+w+",height="+h+",top=60,left=60,status=no,menubar=no,toolbar=no,scrollbar=no");
return false;
}

function PopupCentrataNgA(posizione,notizia,w,h,ng) {
  window.open("http://www.sardegnaambiente.it/index.php?xsl=656&s=18&v=9&c=4545&notizia="+notizia+"&pic="+posizione+"&ng="+ng,"","width="+w+",height="+h+",top=60,left=60,status=no,menubar=no,toolbar=no,scrollbar=no");
return false;
}


function temporizzaA(immagine,news,ng){
  window.location.href = "http://www.sardegnaambiente.it/index.php?xsl=656&s=18&v=9&c=4545&slide=1&notizia="+news+"&pic="+immagine+"&ng="+ng;
}



function PopupCentrata(posizione,notizia,w,h) {
  window.open("http://www.regione.sardegna.it/index.php?xsl=434&s=1&v=9&c=25&notizia="+notizia+"&pic="+posizione,"","width="+w+",height="+h+",top=60,left=60,status=no,menubar=no,toolbar=no,scrollbar=no");
return false;
}

function PopupCentrataNg(posizione,notizia,w,h,ng) {
  window.open("http://www.regione.sardegna.it/index.php?xsl=434&s=1&v=9&c=25&notizia="+notizia+"&pic="+posizione+"&ng="+ng,"","width="+w+",height="+h+",top=60,left=60,status=no,menubar=no,toolbar=no,scrollbar=no");
return false;
}


function temporizza(immagine,news,ng){
  window.location.href = "http://www.regione.sardegna.it/index.php?xsl=434&s=1&v=9&c=25&slide=1&notizia="+news+"&pic="+immagine+"&ng="+ng;
}

function PopupCentrataCultura2(posizione,id1,id2,w,h) {
  window.open(
    "http://www.sardegnacultura.it/j/v/285?s=7&v=9&c=2476&id1="+id1+"&id2="+id2+"&pic="+posizione,
    "",
    "width=" + w + ",height=" + h + ",top=60 , left=60, status=no, menubar=no, toolbar=no scrollbar=no");
}

function PopupCentrataCultura(posizione,notizia,w,h) {
  window.open(
    "http://www.sardegnacultura.it/j/v/277?s=7&v=9&c=2476&notizia="+notizia+"&pic="+posizione,
    "",
    "width=" + w + ",height=" + h + ",top=60 , left=60, status=no, menubar=no, toolbar=no scrollbar=no");
}
function PopupCentrataTurismo(posizione,notizia,w,h) {
  window.open(
    "http://www.sardegnaturismo.it/index.php?xsl=30&s=1&v=9&c=25&notizia="+notizia+"&pic="+posizione,
    "",
    "width="+w+",height="+h+",top=60,left=60,status=no,menubar=no,toolbar=no,scrollbar=no");
}

function sendmail2(subject,linkhref){
  window.location.href = "mailto:?subject="+escape(subject)+"&body="+escape(linkhref);
  return false;
}
function sendmail(subject){
  window.location.href = "mailto:?subject="+escape(subject)+"&body="+escape(window.location);
  return false;
}
function intercetta() {
    for (var i=0; i<document.links.length; i++) {
        if (document.links[i].rel=="blank") {
            document.links[i].target="_blank";
      document.links[i].title = document.links[i].title+" (apertura in nuova finestra)";
        }
        else if (document.links[i].rel=="blankcc") {
            document.links[i].target="_blank";
      document.links[i].rel="license";
      document.links[i].title = document.links[i].title+" (apertura in nuova finestra)";
        }
  }
}
/*addEvent(window,'load',intercetta);*/
window.onload = intercetta;
function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}
/**
 * Determine whether a node's text content is entirely whitespace.
 *
 * @param nod  A node implementing the |CharacterData| interface (i.e.,
 *             a |Text|, |Comment|, or |CDATASection| node
 * @return     True if all of the text content of |nod| is whitespace,
 *             otherwise false.
 */
function is_all_ws( nod )
{
  // Use ECMA-262 Edition 3 String and RegExp features
  return !(/[^\t\n\r ]/.test(nod.data));
}


/**
 * Determine if a node should be ignored by the iterator functions.
 *
 * @param nod  An object implementing the DOM1 |Node| interface.
 * @return     true if the node is:
 *                1) A |Text| node that is all whitespace
 *                2) A |Comment| node
 *             and otherwise false.
 */

function is_ignorable( nod )
{
  return ( nod.nodeType == 8) || // A comment node
         ( (nod.nodeType == 3) && is_all_ws(nod) ); // a text node, all ws
}

/**
 * Version of |previousSibling| that skips nodes that are entirely
 * whitespace or comments.  (Normally |previousSibling| is a property
 * of all DOM nodes that gives the sibling node, the node that is
 * a child of the same parent, that occurs immediately before the
 * reference node.)
 *
 * @param sib  The reference node.
 * @return     Either:
 *               1) The closest previous sibling to |sib| that is not
 *                  ignorable according to |is_ignorable|, or
 *               2) null if no such node exists.
 */
function node_before( sib )
{
  while ((sib = sib.previousSibling)) {
    if (!is_ignorable(sib))
      return sib;
  }
  return null;
}

/**
 * Version of |nextSibling| that skips nodes that are entirely
 * whitespace or comments.
 *
 * @param sib  The reference node.
 * @return     Either:
 *               1) The closest next sibling to |sib| that is not
 *                  ignorable according to |is_ignorable|, or
 *               2) null if no such node exists.
 */
function node_after( sib )
{
  while ((sib = sib.nextSibling)) {
    if (!is_ignorable(sib))
      return sib;
  }
  return null;
}

function closeAll(){
  var hurray=document.getElementsByTagName('ul');
  if (hurray) {
    for (i=0;i<hurray.length;i++){
      if(hurray[i].className=='tab-open2'){
        hurray[i].style.display='none';
      }
    }
  }
  hurray=document.getElementsByTagName('div');
  if (hurray) {
    for (i=0;i<hurray.length;i++){
      if(hurray[i].className=='tab-open2'){
        hurray[i].style.display='none';
      }
    }
  }
}

function showSublinks(me,cat)
{
  if(me.src){
    if(me.src.substring(me.src.lastIndexOf('/')+1)=="minus.gif"){
      me.src="/img/plus.gif";
      me.alt="Espandi categoria "+cat;
      me.title="Espandi categoria "+cat;
      node_after(me.parentNode).style.display='none';
    }
    else{
      closeAll();
      me.src="/img/minus.gif";
      me.alt="Comprimi categoria "+cat;
      me.title="Comprimi categoria "+cat;
      node_after(me.parentNode).style.display='inline';
    }
  }
  else{
    closeAll();
    if(node_after(me.parentNode).style.display == 'inline'){
      node_after(me.parentNode).style.display='none';
    }
    else{
      node_after(me.parentNode).style.display='inline';
    }
  }
}

function openPopUp(url, larghezza, altezza){
  var location=url;
  if (location!=''){
    var DispWin;
    DispWin=window.open(location, '','toolbar=no, "NewWin", status=yes,resizable=yes,,scrollbars=yes, width='+larghezza+', height='+altezza+',  top=1, left=1');
    DispWin.focus();
  }
  return false;
}

function stoperror(){return true;}

window.onerror=stoperror
  
function validate_RecomendForm() {  
  var validity = true;
  if (!check_empty(document.inviaLink.senderName.value)) {
    validity = false;
    alert('Campo NOME MITTENTE obbligatorio!');
    document.inviaLink.senderName.focus();
  }   
  if (!check_email(document.inviaLink.senderEmail)) {
    if (validity == true)
      document.inviaLink.senderEmail.focus();
    validity = false;
  } 
  if (!check_email(document.inviaLink.receiverEmail)) {
    if (validity == true)
      document.inviaLink.receiverEmail.focus();
    validity = false;
  }
  return validity;
}

function check_empty(text) {
  return (text.length > 0); 
}

function check_email(address)
{
  var status = false;
  if (address.value.length > 0) {
    var regEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
    status = regEmail.test(address.value);
    if (status == false) {
      alert('Il campo \"Email\" non e\' valido');
    }
  }
  else
    alert('Campo \"Email\" obbligatorio!'); 
  return status;
}

function aprippinvio(url) {
  var location=url;
  if (location!=''){
    var DispWin;
    DispWin=window.open(location, '','toolbar=no, "NewWin", status=yes,resizable=no,,scrollbars=no, width=560px, height=600px,  top=1, left=1');
    DispWin.focus();
  }
  return false;
}

function CambiaStato(posizione) {
        var el = document.getElementById('divn_'+posizione);
  var el2 = document.getElementById('divs_'+posizione);
  el.style.display = 'none';
  el2.style.display = '';

        for (i=1; i<=10; i++) {
              if (posizione != i) {
                var ela = document.getElementById('divn_'+i);
                var ela2 = document.getElementById('divs_'+i);
                if (ela) {
                ela.style.display = '';
                }
                if (ela2) {
                ela2.style.display = 'none';
                }
              }
            }

  return true;
}

function galleriaimg(idc,c1,n,pagina,nn,w,h) {
  window.open("http://www.sardegnadigitallibrary.it/index.php?xsl=625&slide=1&s=17&v=9&c="+idc+"&c1="+c1+"&pagina="+pagina+"&nn="+nn+"&n="+n,"","width="+w+",height="+h+",top=60,left=60,status=no,menubar=no,toolbar=no,scrollbar=no");
  return false;
}

function Check_s3d(url,idcat) {
  s3d_openPopUp("http://www.sardegna3d.it/xml/check_s3d.php?idcat="+idcat+"&url="+escape(url),530,100);
  return false;
}