/* Load classes */
function DocumentsEventsDispatcher() {
	this.documentMouseDown = new Array();
	this.documentMouseMove = new Array();
	this.documentMouseUp = new Array();
	
	this.addDocumentMouseDownHandler = function(handler)
	{
		this.documentMouseDown.push(handler);
	}
	
	this.fireMouseDownEvent = function()
	{ 
		for(var i=0; i < this.documentMouseDown.length; i++) {
			this.documentMouseDown[i].onMouseDown();
		}
	}
	
	this.addDocumentMouseMoveHandler = function(handler)
	{
		this.documentMouseMove.push(handler);
	}
	
	this.fireMouseMoveEvent = function(evt)
	{
	    result = true;
	    //hideMenu(evt);
		for(var i=0; i < this.documentMouseMove.length; i++) {
			result = result && this.documentMouseMove[i].onMouseMove(evt);
		}
		return result;
	}
	
	this.addDocumentMouseUpHandler = function(handler)
	{
		this.documentMouseUp.push(handler);
	}
	
	this.fireMouseUpEvent = function()
	{
		for(var i=0; i < this.documentMouseUp.length; i++) {
			this.documentMouseUp[i].onMouseUp();
		}
	}
}
var ex;
var ey;
var debugInfo = false;
var w3c=(document.getElementById)? true: false;
var ie5=(w3c && document.all)? true : false;
var ns6=(w3c && (navigator.appName=="Netscape"))? true: false;
var OP = ((ind1 = navigator.userAgent.indexOf("Opera")) > -1) ? 1 : 0; 
var IE = ((ind2 = navigator.appVersion.indexOf("MSIE")) > -1 && !OP) ? 1 : 0;
var IE6 = (IE && parseInt(navigator.appVersion.substr(ind2 + 5)) == 6) ? 1 : 0;
var IPAD = ((ind3 = navigator.userAgent.indexOf("iPad")) > -1) || ((ind3 = navigator.userAgent.indexOf("iPhone")) > -1) ? 1 : 0;
var documentiCaricati=0;
var documentiDaCaricare=0;
var dimensioneCarattere = 100;
var documentEventsDispacher = new DocumentsEventsDispatcher();
var lastMouseMoveEvent;
var dateFieldIni = '';
var dateFieldFin = '';
var toExecuteOnLoad = '';
document.onmousedown = function fireDown() { documentEventsDispacher.fireMouseDownEvent(); }
document.onmousemove = function fireMove(evt) { 
    lastMouseMoveEvent = evt; 
    try {
    ex=(ie5)?event.clientX+document.body.scrollLeft:lastMouseMoveEvent.pageX;
    ey=(ie5)?event.clientY+document.body.scrollTop:lastMouseMoveEvent.pageY;
    }catch(e){}
    return documentEventsDispacher.fireMouseMoveEvent(evt); } 
document.onmouseup = function fireUp() { documentEventsDispacher.fireMouseUpEvent(); } 
/* Inits Method */
function include_dom(script_filename) {
    var html_doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    js.setAttribute('language', 'javascript');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', script_filename);
    html_doc.appendChild(js);
}
/* **********************************************************************************************
   ******************* MENU' a comparsa - inizio
   ********************************************************************************************** */
var currentMenu = '';
//var ImgRestore = true;
function swapImage(id) {
    pathAttuale = document.getElementById('tab'+id).src;
    if (pathAttuale.indexOf("over.gif")<1)
	    document.getElementById('tab'+id).src= pathAttuale.replace(".gif","over.gif");
	
}
function swapImgRestore(id) {
    //if (ImgRestore)
	    document.getElementById('tab'+id).src= document.getElementById('tab'+id).src.replace("over.gif",".gif");
	//else
	//    ImgRestore = true;
}
function changeAreaRicercaQ(myself,id) {
    document.getElementById('ar1').className = 'linkAreaRicercaFasciaQ';
    document.getElementById('ar2').className = 'linkAreaRicercaFasciaQ';
    //document.getElementById('ar3').className = 'linkAreaRicercaFascia';
    document.getElementById('ar4').className = 'linkAreaRicercaFasciaQ';
    document.getElementById(myself).className = 'linkAreaRicercaFasciaSelQ';
    document.getElementById('doveRicercare').value = id;
}
function changeAreaRicerca(myself,id) {
    document.getElementById('ar1').className = 'linkAreaRicercaFascia';
    document.getElementById('ar2').className = 'linkAreaRicercaFascia';
    //document.getElementById('ar3').className = 'linkAreaRicercaFascia';
    document.getElementById('ar4').className = 'linkAreaRicercaFascia';
    document.getElementById(myself).className = 'linkAreaRicercaFasciaSel';
    document.getElementById('doveRicercare').value = id;
}
function switchOptions(visibile, nascosta) {
    document.getElementById(visibile + 'L').className = 'TabLeftMenuAcceso';
    document.getElementById(nascosta + 'L').className = 'TabLeftMenu';
    document.getElementById(visibile).style.display = 'block';
    document.getElementById(nascosta).style.display = 'none';
}
function switchOptions2(visibile, nascosta, nascosta2, sett, url) {
    document.getElementById(visibile + 'L').className = 'TabLeftMenuAcceso80';
    document.getElementById(nascosta + 'L').className = 'TabLeftMenu80';
//    document.getElementById(nascosta2 + 'L').className = 'TabLeftMenu80';
//    document.getElementById(visibile).style.display = 'block';
//    document.getElementById(nascosta).style.display = 'none';
//    document.getElementById(nascosta2).style.display = 'none';
    document.getElementById('ix_tipoVisualizza').value = sett;
    loadIndiceFiltrato(url);
}
function showMenu(idMenu,idimm)
{
    //ImgRestore = false; //swapImgRestore(idimm); 
    menu=document.getElementById(idMenu);
    div=document.getElementById('b'+idimm);
    if (currentMenu != '') 
    {   
        if (document.getElementById(currentMenu).className != 'sottomenuVis')
        {
            document.getElementById(currentMenu).style.display='none';
            document.getElementById('b'+currentMenu).className= 'Nf';
        }
    }
    if (currentSelected!='')
    {
            document.getElementById(currentSelected).style.display='none';
            document.getElementById('b'+currentSelected).className= 'Nf';
    }
    if (menu)
    {
	    currentMenu = idMenu
        document.getElementById('b'+idMenu).className= 'NfSel';
        menu.style.display='block';
    }
    
    
}
/* **********************************************************************************************
   ******************* MENU' a comparsa - fine
   ********************************************************************************************** */
/* **********************************************************************************************
   ******************* AJAX FUNCTIONS - inizio
   ********************************************************************************************** */
/////////////////////////////////////////
//Variabili generiche
var http = getHTTPObject(); 
var httpAusilio = getHTTPObject(); 
var httpWorking;
var targetDiv = "";
var targetFunction = "";
var historyFlag;
var historyPageLoaded = false;
var emb;
var httpCallbackFunction = "";
var contenutoSommarioAperto='';
/////////////////////////////////////////
//Funzioni pubbliche
var checkWorking = true;
function loadPage(url, divID, uniqueCall, history, historyData, checkWorking, _httpCallbackFunction, postData)
{
	//checkWorking = checkWorking ? checkWorking : false;
	if (debugInfo) document.getElementById('debugHttpRunning').value="true";
	httpCallbackFunction = _httpCallbackFunction ? _httpCallbackFunction : "callBackDefault";
    httpCallbackFunction = httpCallbackFunction != "" ? httpCallbackFunction : "callBackDefault";
    //if (httpWorking && checkWorking) 
    //{
    //    if (!confirm('E\' in corso un\' altra operazione di caricamento. Si desidera proseguire ugualmente con il link richiesto?.'))
    //    return;
    //}
    targetDiv = divID;
    
    if (uniqueCall)
    {
        if (url.indexOf('?')>0) url += '&randomID=' + Math.random()*10000;
        else url += '?randomID=' + Math.random()*10000;
    }
   
    if (http) {
    httpWorking = true;
    if (history)
    {
        addHistoryData(historyData);
    }
    if (postData && postData != "")
    {
    	http.open('POST', url, true);
        http.onreadystatechange = handleHttpResponse;
        http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http.setRequestHeader("Content-length", postData.length);
        if (!IE6) http.setRequestHeader("Connection", "close");
        http.send(postData);
    }
    else
    {
	    http.open("GET", url, true);
	    http.onreadystatechange = handleHttpResponse;
	    http.send(null);
    }
   
    }
    else
    {
        alert('Impossibile effettuare l\'operazione richiesta');
    }
    
    if (debugInfo) document.location='#'+ Math.random()*10000;
}
function loadPageNoControllo(url, divID, uniqueCall, history, historyData)
{
	loadPage(url, divID, uniqueCall, history, historyData, false, "callBackDefault");
}
function loadDoc(url, uniqueCall, history, historyData)
{
	loadPage(url, divID, uniqueCall, history, historyData, true, "callBackDoc");
}
function loadDocQuesito(url, uniqueCall, history, historyData)
{
	loadPage(url, divID, uniqueCall, history, historyData, true, "callBackDocQuesiti");
}
function loadPageRisRicerca(url, data)
{
	loadPage(url, '', false, false, '', true, "callBackRic", data);
}
function loadDocPost(url, uniqueCall, history, historyData, postData)
{
	loadPage(url, '', uniqueCall, history, historyData, true, "callBackDoc", postData);
}
function loadPagePost(url, divID, uniqueCall, postData)
{
	loadPage(url, divID, uniqueCall, false, '', true, "callBackDefault", postData);
}
function updatePage(url, data, endFunction)
{
	loadPage(url, '', true, false, '', true, endFunction, data);
}
function addHistoryData(historyData)
{
    historyPageLoaded = true;
    historyFlag = true;
    frm = document.getElementById('historyFrame');
    frm.src = 'history.aspx?data=' + historyData;
}
function inizializzahistory()
{
    historyFlag = true;
}
function Backhistory(data)
{
    if(!historyPageLoaded && data!='parent.location.reload()') 
    {
        historyPageLoaded = true;
        historyFlag = false;
        httpWorking = false;
    }
    if (historyFlag)
    {
        historyFlag = false;
    }
    else
    {
        funzione = data.replace(/&amp;/g,'&');
        funzione = funzione.replace(/%20/g, ' ');
        funzione = funzione.replace(/%25/g, '#');
        try {
        eval(funzione);
    } catch (e) {if (funzione == 'parent.location.reload()') window.location.reload(); }
    }
}
//////////////////
//Funzioni usate dalle altre precedenti
function handleHttpResponse() {
  if (http.readyState == 4) {
    if (debugInfo) document.getElementById('debugHttpRunning').value="false";
  	eval(httpCallbackFunction +'()'); //\''+http.responseText+'\'
  }
}
function callBackDefault()
{
	document.getElementById(targetDiv).innerHTML=http.responseText;
    httpWorking = false;
    if (targetDiv == 'framebasso')
        resizeWin();
    if (idParteSommarioDaCaricareAFineLoadTreeSommario != "") {
        showDocDaTreeSommario(idParteSommarioDaCaricareAFineLoadTreeSommario,divIDSommarioDaCaricareAFineLoadTreeSommario);
        idParteSommarioDaCaricareAFineLoadTreeSommario = "";
        divIDSommarioDaCaricareAFineLoadTreeSommario = "";
    }
}
function callBackLow() {
   httpWorking = false;
    var mydoc = http.responseText;
    pos1 = mydoc.indexOf('@@@@--div--@@@@');
    testo1 = mydoc.substring(pos1+15);
    toolbar1 = mydoc.substring(0,pos1);

    
    content_parte = document.getElementById('contenutoLow'); 
    content_parte.innerHTML=testo1;
    content_parte.scrollTop = 0;
    
    document.getElementById('toolbarLow').innerHTML=toolbar1;
    pos3 = toolbar1.indexOf('<!--toolbarheight=');
    if (pos3>0)
    {
        pos4 = toolbar1.indexOf('-->',pos3);
        funzione = toolbar1.substring(pos3+18,pos4);
        if (panel1Low) { panel1Low.defaultHeight = funzione; bodyP.resize() }
    }
}
function callBackDoc() {
   
    var mydoc = http.responseText;
    pos1 = mydoc.indexOf('@@@@--div--@@@@');
    pos2 = mydoc.indexOf('@@@@--div--@@@@',pos1+1);
    testo1 = mydoc.substring(pos2+15);
    toolbar1 = mydoc.substring(pos1+15,pos2);
    titolo1 = mydoc.substring(0,pos1);
    testo1 = checkEmb(testo1);
    content_parte = document.getElementById("contenuto");
    content_parte.innerHTML=testo1;
    content_parte.scrollTop = 0;
    
    document.getElementById("toolbar").innerHTML=toolbar1;
    document.getElementById("fascetta").innerHTML=titolo1;
    navigaAncora(testo1,false);
    
    httpWorking = false;
    documentiCaricati++;

    // Gestione chiamata a funzioni javascript 
    pos3 = testo1.indexOf('<!--@@@[EVAL]@@@');
    if (pos3>0)
    {
        pos4 = testo1.indexOf('-->',pos3);
        funzione = testo1.substring(pos3+16,pos4);
        eval(funzione);
    }
    
    pos3 = toolbar1.indexOf('<!--toolbarheight=');
    if (pos3>0)
    {
        pos4 = toolbar1.indexOf('-->',pos3);
        funzione = toolbar1.substring(pos3 + 18, pos4);
        if (IPAD) {
            if (panel1Doc) document.getElementById("toolbar").style.height = funzione;
            else toExecuteOnLoad += 'document.getElementById("toolbar").style.height = "' + funzione + '";';
        } else {
            if (panel1Doc) panel1Doc.defaultHeight = funzione;
            else toExecuteOnLoad += 'panel1Doc.defaultHeight = "' + funzione + '";';
        }
    }
   ripristinaSommario();
    if (panel1Doc && toolbar1!= '') panel1Doc.show();
    else toExecuteOnLoad += 'panel1Doc.show();';
    if (panel2Doc) panel2Doc.show();
}
function callBackDocQuesiti() {
   
    var mydoc = http.responseText;
    pos1 = mydoc.indexOf('@@@@--div--@@@@');
    pos2 = mydoc.indexOf('@@@@--div--@@@@',pos1+1);
    testo1 = mydoc.substring(pos2+15);
    toolbar1 = mydoc.substring(pos1+15,pos2);
    titolo1 = mydoc.substring(0,pos1);
    testo1 = checkEmb(testo1);
    
    content_parte = document.getElementById("contenuto");
    content_parte.innerHTML=testo1;
    content_parte.scrollTop = 0;
    
    document.getElementById("toolbar").innerHTML=toolbar1;
    document.getElementById("fascetta").innerHTML=titolo1;
    navigaAncora(testo1,false);
    
    httpWorking = false;
    documentiCaricati++;
    
    // Gestione chiamata a funzioni javascript
    pos3 = testo1.indexOf('<!--@@@[EVAL]@@@');
    if (pos3>0)
    {
        pos4 = testo1.indexOf('-->',pos3);
        funzione = testo1.substring(pos3+16,pos4);
        eval(funzione);
   }
}
function navigaDoc()
{
    testo1 = document.getElementById("contenuto").innerHTML;
    testo1 = checkEmb(testo1);
    navigaAncora(testo1, true);
    
}
function navigaAncora(testo1, delay)
{
    // Gestione ancore (per esempio a un comma)
    pos3 = testo1.indexOf('<!--navigaAncora:');
    if (pos3>0)
    {
        document.getElementById("contenuto").scrollTop = 0;
        pos4 = testo1.indexOf('-->',pos3);
        ancora = testo1.substring(pos3+17,pos4);
        comma = document.getElementById(ancora);
        if (comma){ if (delay) setTimeout("window.location.href='#"+ancora+"'", 500); 
                    else window.location.href='#'+ancora; 
        }
    }
}
function checkEmb(testo1) {
    var re = new RegExp(/<(iframe|embed|IFRAME|EMBED).*?src="([^"]*)".*?(iframe|embed|IFRAME|EMBED)>/g);
    var m = testo1.match(re);
    if (m) {
        if (!checkPdfPlugin()) {
            for (i = 0; i < m.length; i++) {
                filename = m[i].replace(/.*?src="/, '');
                filename = filename.replace(/".*/, '');
                filename = '<div style="border: solid 1px maroon; padding: 5px;"><strong>Documento pdf N. ' + i + '</strong> <br />Il browser non supporta la visualizzazione dei file pdf in una pagina web. Aggiornare la propria versione di Acrobat Reader e/o verificare le impostazioni di sicurezza del proprio computer.<br/>L\'allegato &egrave; tuttavia scaricabile <a class="link" href="' + filename + '">cliccando qui</a></div>'
                testo1 = testo1.replace(m[i], filename);
            }
        }
    }
    posemb = testo1.indexOf('<EMBED');
    if (posemb>0)
    {
        emb = true;
    }
    else
    {
        emb=false;
    }
    return testo1;
}
function callBackRic() {
	document.getElementById('framebasso').innerHTML=http.responseText;
    httpWorking = false;
}
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
	  xmlhttp.overrideMimeType("text/xml"); 
	  //xmlhttp.overrideMimeType("text/html"); 
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
/* **********************************************************************************************
   ******************* AJAX CLASSES - fine
   ********************************************************************************************** */
function showDocDaTree(url,divid)
{
    showDoc(url);
    if (debugInfo) document.location='#3'+divID;
}
function ShowDocTuirSchema(url)
{
    showDoc(url);
}
function ShowDocTuir(url)
{
    showDoc(url);
}
function showdoc(url)
{
    showDoc(url);
}
function ShowDoc(url)
{
    showDoc(url);
}
function showDocVigenza(url,data)
{
    showDoc(url+'&vigenza='+data);
}
function ShowDocIntero(url) {
    showDoc(url + '&tipo=intero');
}
// Carica un documento nella finestra principale
function showDoc(url)
{
    if (httpWorking && checkWorking) 
    {
        //alert('E\' in corso un\' altra operazione. Attendere.');
        if (!confirm('E\' in corso un\' altra operazione di caricamento. Si desidera proseguire ugualmente con il link richiesto?.'))
        return;
    }
    hideEpigrafe('');
    if (url.indexOf('ocumento.aspx?')<=0)
    {
        //Gesione vecchi link del tipo showDoc('l0002007121200001'); senza percorso esteso
        url = basePathUrl + url;
    }
    divID='contenuto';
        httpWorkingDoc = new Date();
        documentiDaCaricare++;
        setTimeout('showWaitMessage()', 4000); 
    url = url.replace('#','%23');
    historyData = 'showDocNoHistory(\''+ url + '\')';
    loadDoc(url.replace('&amp;','&'), false, true, escape(encodeURI(historyData)));
    
    if (debugInfo) document.location='#'+ Math.random()*10000;
}
var contentpartehtml = '';
function showRicLowForm(url) {
    contentpartehtml = document.getElementById('contenuto').innerHTML;
    url = AgoBackUrlManage(url);
    showDocInBasso(url, getFormValues('formRicerca'));
}

function ripristinaMascheraRicerca()
{
    if (contentpartehtml != "")
    { 
    
    panel1Doc.hide();
    panel1Doc.element.innerHTML = '';
    panel2Doc.hide();
    panel2Doc.element.innerHTML = '';
    document.getElementById('contenuto').innerHTML = contentpartehtml; 
    
    }
}
function AgoBackUrlManage(url) { 
    if (document.getElementById("HiddenAgoUrl")) {
        url = url + "&agoReturn=" + escape(document.getElementById("HiddenAgoUrl").innerHTML);
    }
    return url;
}
function showDocLowForm(url) {
    url = AgoBackUrlManage(url);
    showDocInBasso(url, getFormValues('formRisultati'));
    if (debugInfo) document.location='#'+ Math.random()*10000;
}
function showDocLow(url)
{
    showDocInBasso(url, '');
    if (debugInfo) document.location='#'+ Math.random()*10000;
}
function showDocInBasso(url, formData)
{
    //if (httpWorking) 
    //{
    //    alert('E\' in corso un\' altra operazione. Attendere.');
    //    return;
    //}
    if (httpWorking && checkWorking) 
    {
        if (!confirm('E\' in corso un\' altra operazione di caricamento. Si desidera proseguire ugualmente con il link richiesto?.'))
        return;
    }
if (splitterhr) {
    if (splitterhr.lowPanelCollapsed){
    splitterhr.highPanelHeight = bodyP.getFloatHeight()/2;
    splitterhr.openLow();
    }
    panelhrDivider.show();
    panel1Low.defaultHeight = "19px";
    panel1Low.element.innerHTML='<table style="background-color: #4F8FBB; height:19px;" align="center" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td class="titolotree" style="background-color: #4F8FBB; color: white;">Risultati</td><td align="right"><a href="javascript:splitterhr.collapseLow()"><img src="img/bnt_chiudi.gif" alt="Chiudi" /></a></td></tr></table>';
    panel1Low.show();
    panel3Low.element.innerHTML= '<div align="center" style="text-align:center"><br><br><br><br><img src="img/loading.gif" />Ricerca in corso...<br><br></div>';
    panel3Low.show();
    
    hideEpigrafe('');
  }
    divID='contenutoLow';
    url = url.replace('#','%23');
    historyData = 'showDocLowNoHistory(\''+ url + '\')';
    loadPage(url.replace('&amp;','&'), divID, true, false, '', true, 'callBackLow', formData);
}
// Carica un documento nella finestra principale (senza memorizzazione history)
function showDocNoHistory(url)
{
    if (httpWorking && checkWorking) 
    {
        if (!confirm('E\' in corso un\' altra operazione di caricamento. Si desidera proseguire ugualmente con il link richiesto?.'))
        return;
    }
    hideEpigrafe('');
    divID='contenuto';
        ////httpWorkingDoc = new Date();
        ////documentiDaCaricare++;
        ////setTimeout('showWaitMessage()', 4000); 
    url = url.replace('#','%23');
    loadDoc(url.replace('&amp;','&'), false, false, '');
}
function showWaitMessage()
{
    if (httpWorking) 
    {
        dataora = new Date();
        if((dataora.getTime()-httpWorkingDoc.getTime())>=4000 && (documentiDaCaricare - documentiCaricati)==1)
        {
        divContenuto = document.getElementById('contenuto');
        loadMsg ='<div align="center" style="text-align:center"><br><br><br><br><img src="img/loading.gif" /> Caricamento...<br><br>';
        loadMsg +='Il tempo di caricamento di un documento dipende da molti fattori<br> come le condizioni di traffico della rete internet o la dimensione del documento stesso. <br>';
        loadMsg +='<br>Tra qualche istante il documento richiesto sar&agrave; visualizzato. </div>';
        divContenuto.innerHTML= loadMsg;
        }
    }
}
function showEpigrafe(idepi)
{
    clientXX = bodyP.getFloatWidth();
    clientYY = bodyP.getFloatHeight();
    var ex=(ie5)?event.clientX+document.body.scrollLeft:lastMouseMoveEvent.pageX;
    var ey=(ie5)?event.clientY+document.body.scrollTop:lastMouseMoveEvent.pageY;
    
    if (clientYY < ey+100) ey = ey - 100;
    
    if (ex==null || ey==null) return;
    divE = document.getElementById('popupepigrafe');
    divE.innerHTML= '<img src="img/loading.gif" /> Caricamento epigrafe...';
    divE.style.display='block';
    divE.style.top = (ey+10) +'px';
    if (clientXX < ex+250) ex = ex - 280; //Riga di comando per posizionare a sinistra le note a ridosso del margine destro della pagina
    divE.style.left = ex +'px';
    
    loadPageNoControllo('showEpigrafe.aspx?ids='+idepi, 'popupepigrafe', false, false, '');
}
//Nasconti l'epigrafe del link quando lasci il link col mouse
function hideEpigrafe(idepi)
{
    divE = document.getElementById('popupepigrafe');
    divE.style.display='none';
}
//Funzione per caricare griglia documenti aggiornati (versione senza memorizzazione nella history del browser)
function loadContentNoHistory(url)
{
    divID='contenuto';
     divContenuto = document.getElementById(divID);
    divContenuto.innerHTML= '<div style="text-align:center"><br><br><br><br><img src="img/loading.gif" /> Caricamento...</div>';
    loadPage(url.replace('&amp;','&'), divID, true, false, '', "callBackDefault");
}
//Funzione per caricare griglia documenti aggiornati 
function loadContent(url)
{
    divID='contenuto';
    divContenuto = document.getElementById(divID);
    divContenuto.innerHTML= '<div style="text-align:center"><br><br><br><br><img src="img/loading.gif" /> Caricamento...</div>';
    historyData = 'loadContentNoHistory(\''+ url + '\')';
    loadPage(url.replace('&amp;','&'), divID, true, true, escape(encodeURI(historyData)), "callBackDefault");
}
function loadIndiceFiltrato(url)
{
    da = document.getElementById('ix_dataIni');
    a = document.getElementById('ix_dataFin');
    argomentoCodice = "";
    _argomentoPresente = false;
    _argomento = document.getElementById('ix_argomentosub3');
    if (_argomento)
    {
        argomentoCodice = _argomento.options[_argomento.selectedIndex].value;
        _argomentoPresente = true;
    }
    _argomento = document.getElementById('ix_argomentosub');
    if (_argomento)
    {
        if (argomentoCodice=="") argomentoCodice = _argomento.options[_argomento.selectedIndex].value;
        else
        {
            partiliv = argomentoCodice.split(".");
            partiAttuali = _argomento.options[_argomento.selectedIndex].value.split(".");
            if (partiliv[0] != partiAttuali[0] || partiliv[1] != partiAttuali[1])
                argomentoCodice = _argomento.options[_argomento.selectedIndex].value;
        }
        _argomentoPresente = true;
    }
    _argomento = document.getElementById('ix_argomento');
    if (_argomento)
    {
        if (argomentoCodice=="") argomentoCodice = _argomento.options[_argomento.selectedIndex].value;
        else
        {
            partiliv = argomentoCodice.split(".");
            partiAttuali = _argomento.options[_argomento.selectedIndex].value.split(".");
            if (partiliv[0] != partiAttuali[0])
                argomentoCodice = _argomento.options[_argomento.selectedIndex].value;
        }
        _argomentoPresente = true;
    }
    while (argomentoCodice.substring(argomentoCodice.length-1, argomentoCodice.length) == '.')
    {
        argomentoCodice = argomentoCodice.substring(0,argomentoCodice.length-1);
    }
    _argomentoext = document.getElementById('ix_argomentoext');
    _autore = document.getElementById('ix_autore');
    _visualizza = document.getElementById('ix_visualizza');
    currDate = document.getElementById('ix_checkDate');
    _ordinamento = document.getElementById('ordinamentoRassegne');
    
    
    if (url.indexOf('&fa=Cs') > 1) {
        //Argomento rassegna giuris. indice crono per sent
        _argomento = document.getElementById('is_argomento');
        if (_argomento) {
            argomentoCodice = _argomento.options[_argomento.selectedIndex].value;
            _argomentoPresente = false;
            _argomentoext = null;
            url = url + '&ag=' + argomentoCodice;
        }
    }
    
    if (da) url = url + '&di=' + da.value;
    if (a) url = url + '&df=' + a.value;
    if (_argomentoPresente && url.indexOf('&fa=o')<1) url = url + '&ag=' + escape(encodeURI(argomentoCodice));
    if (_argomentoext && (!_argomentoPresente || url.indexOf('&fa=o') > 1)) url = url + '&ag=' + _argomentoext.value;
    if (_autore) url = url + '&at=' + _autore.options[_autore.selectedIndex].value;
    if (_ordinamento) url = url + '&ord=' + _ordinamento.options[_ordinamento.selectedIndex].value;
    if (_visualizza) url = url + '&vi=' + _visualizza.options[_visualizza.selectedIndex].value;
    else url + '&vi=0';
    

    if (document.getElementById('per_1'))
    {
        //controllo che la voce selezionata sia quella giusta
        if (document.getElementById('per_1').className=='linkprodottocentroevidenziato')
        {
            document.getElementById('per_1').className='leftLink';
            document.getElementById('per_5').className='linkprodottocentroevidenziato';
        }
    }
    if (document.getElementById('per_2'))
    {
        //controllo che la voce selezionata sia quella giusta
        if (document.getElementById('per_2').className=='linkprodottocentroevidenziato')
        {
            document.getElementById('per_2').className='leftLink';
            document.getElementById('per_5').className='linkprodottocentroevidenziato';
        }
    }
  
    loadIndice(url);
    
    if (_argomentoPresente)
    {
        //devo caricare le sub aree dell'argomento
        httpAusilio.open("GET", "caricaSubArgomento.aspx?idpadre="+escape(encodeURI(argomentoCodice))+"&url="+escape(encodeURI(url))+ "?randomID=" + Math.random()*10000, true);
	    httpAusilio.onreadystatechange = callBackArgo;
	    httpAusilio.send(null);
    }
}



function callBackArgo() {
    if (httpAusilio.readyState == 4) {
	document.getElementById('subArgomentoArea').innerHTML=httpAusilio.responseText;
	}
}
         
function loadIxPeriodo(url,_da,_a)
{
    da = document.getElementById('ix_dataIni');
    a = document.getElementById('ix_dataFin');
    da.value = _da; a.value = _a;
    loadIndiceFiltrato(url);
}

function loadIndice(url)
{
    panel1Doc.hide();
    panel2Doc.hide();

    _tipoVisualizza = document.getElementById('ix_tipoVisualizza');
    if (_tipoVisualizza) url = url + '&fa=' + _tipoVisualizza.value;
    
    divID='contenuto';
    divContenuto = document.getElementById(divID);
    divContenuto.innerHTML= '<div style="text-align:center"><br><br><br><br><img src="img/loading.gif" /> Caricamento...</div>';
    historyData = 'loadIndiceNoHistory(\''+ url + '\')';
    loadPage(url.replace('&amp;','&'), divID, true, true, escape(encodeURI(historyData)), true, "callBackDoc"); //callBackDefault
}
function loadIndiceNoHistory(url)
{
    panel1Doc.hide();
    panel2Doc.hide();
    
    divID='contenuto';
    divContenuto = document.getElementById(divID);
    divContenuto.innerHTML= '<div style="text-align:center"><br><br><br><br><img src="img/loading.gif" /> Caricamento...</div>';
    historyData = 'loadIndiceNoHistory(\''+ url + '\')';
    loadPage(url.replace('&amp;','&'), divID, true, false, '', true, "callBackDoc");
}
function checkChange(aggiunta, idDiv)
{
    da = document.getElementById('ix_dataIni');
    a = document.getElementById('ix_dataFin');
    da.value = dateFieldIni; 
    a.value = dateFieldFin;
    selVoce(idDiv);
    document.getElementById(idDiv).innerHTML = 'Dal ' + dateFieldIni.substring(6, 8) + '/' + dateFieldIni.substring(4, 6) + '/' + dateFieldIni.substring(0, 4) + '<br /> al ' + dateFieldFin.substring(6, 8) + '/' + dateFieldFin.substring(4, 6) + '/' + dateFieldFin.substring(0, 4);
    
    loadIndiceFiltrato(document.getElementById('ix_url').value+aggiunta);
}
function attivaDisattivaSommario(url)
     {
         somm=document.getElementById('sommario');
         sommCont=document.getElementById('sommariocontent');
         
         if (somm.style.display=='none' || somm.style.display==''){
            somm.style.display='block';
            somm.style.width='200px';
            document.getElementById('contenuto').scrollTop=0;
            if ((sommCont.innerHTML!='' || sommCont.innerHTML!='<img src="img/loading.gif" /> Caricamento sommario...') && url!='')
            {
                sommCont.innerHTML='<img src="img/loading.gif" /> Caricamento sommario...';
                //Carica via Ajax il sommario
                loadPage(url, 'sommariocontent', false, false,'');
            }
         }
         else
         {
            somm.style.display='none';
         }
         
         if (debugInfo) document.location='#'+ Math.random()*10000;
     }
     function espandiRiduciSommario()
     {
         somm=document.getElementById('sommario');
         somm_img = document.getElementById('espandisommario');
         if (somm.style.width=='400px'){
            somm.style.width='200px';
            somm_img.src = 'img/bnt_espandi.gif';
         }
         else
         {
            somm.style.width='400px';
            somm_img.src = 'img/bnt_riduci.gif';
         }
     }
     
     function ripristinaSommario()
     {
        if (contenutoSommarioAperto!='')
        {
             somm=document.getElementById('sommario');
             sommCont=document.getElementById('sommariocontent');
                somm.style.display='block';
                somm.style.width='200px';
                sommCont.innerHTML=contenutoSommarioAperto;
         }
         contenutoSommarioAperto = '';
     }
function showDocDaTreeSommario(url,divid)
{
    //contenutoSommarioAperto
    sommCont = document.getElementById('sommariocontent');
    if (sommCont)
        if ((sommCont.innerHTML != '' && sommCont.innerHTML != 'Caricamento' && sommCont.innerHTML != '<img src="img/loading.gif" /> Caricamento sommario...') && url != '')
        {
            contenutoSommarioAperto = sommCont.innerHTML;
        }
         
    showDoc(url);
}
//apre un ramo del tree tramite una chiamata ajax
// url è l'indirizzo della pagina asp che genera l'html del ramo
// divID è l'id del div che dovrà contenere il nuovo ramo
var idParteSommarioDaCaricareAFineLoadTreeSommario = "";
var divIDSommarioDaCaricareAFineLoadTreeSommario = "";
function apriRamoTreeSommario(url, divID, idp) {
    idParteSommarioDaCaricareAFineLoadTreeSommario = idp;
    divIDSommarioDaCaricareAFineLoadTreeSommario = divID;
    apriRamoTree(url, divID);
}
function apriRamoTree(url, divID)
{
    divramo = document.getElementById(divID);
    lnkramo = document.getElementById('lnk_'+divID);
    if (divramo == null) return;
    // Se il livello non esiste già chiedi tramite ajax il contenuto del ramo
    if (divramo.innerHTML=='Caricamento...' || divramo.innerHTML=='')
    {
        //Mostra l'icona della cartella aperta e cambia il link
        htmlLink = lnkramo.innerHTML;
        htmlLink =  htmlLink.replace(':apriRamoTree',':chiudiRamoTree');
        htmlLink =  htmlLink.replace('Cart_chiusa.gif','Cart_aperta.gif');
        htmlLink =  htmlLink.replace(/\n/g,'');
        // mostra la scritta caricamento
        lnkramo.innerHTML= htmlLink;
        divramo.style.display='block';
        divramo.innerHTML='Caricamento...';
        //Richiedi il caricamento del ramo (il replace serve perchè aspx codifica le & dell'indirizzo in entity
        //Funzioni per gestire l'history del tree (non funziona a dovere)
        loadPage(url.replace('&amp;','&'), divID, true, false, '');
    }
    else
    {
        //C'è già stato il caricamento del ramo
        htmlLink = lnkramo.innerHTML;
        htmlLink =  htmlLink.replace(':apriRamoTree',':chiudiRamoTree');
        htmlLink =  htmlLink.replace('Cart_chiusa.gif','Cart_aperta.gif');
        lnkramo.innerHTML=htmlLink;
        divramo.style.display = 'block';
        if (idParteSommarioDaCaricareAFineLoadTreeSommario != "") {
            showDocDaTreeSommario(idParteSommarioDaCaricareAFineLoadTreeSommario, divIDSommarioDaCaricareAFineLoadTreeSommario);
            idParteSommarioDaCaricareAFineLoadTreeSommario = "";
            divIDSommarioDaCaricareAFineLoadTreeSommario = "";
        }
    }
    if (debugInfo) document.location='#4'+divID;
}
function chiudiRamoTreeSommario(url, divID, idp) {
    idParteSommarioDaCaricareAFineLoadTreeSommario = idp;
    divIDSommarioDaCaricareAFineLoadTreeSommario = divID;
    chiudiRamoTree(url, divID);
}
function chiudiRamoTree(url, divID)
{
    divramo = document.getElementById(divID);
    lnkramo = document.getElementById('lnk_'+divID);
    
    if (divramo == null) return;
    htmlLink = lnkramo.innerHTML;
    htmlLink =  htmlLink.replace(':chiudiRamoTree',':apriRamoTree');
    htmlLink =  htmlLink.replace('Cart_aperta.gif','Cart_chiusa.gif');
    htmlLink =  htmlLink.replace(/\n/g,'');
    lnkramo.innerHTML=htmlLink;
    divramo.style.display='none';
      
      if (debugInfo) document.location='#'+ Math.random()*10000;  
}
//Funzione di apertura ramo usata nell'history back basata su iframe
function apriRamoTreeEx(url, divID)
{
    divramo = document.getElementById(divID);
    lnkramo = document.getElementById('lnk_'+divID);
    if (divramo == null) return;
    if (divramo.innerHTML=='Caricamento...' || divramo.innerHTML=='')
    {
        //Mostra l'icona della cartella aperta e cambia il link
        htmlLink = lnkramo.innerHTML;
        htmlLink =  htmlLink.replace(':apriRamoTree',':chiudiRamoTree');
        htmlLink =  htmlLink.replace('Cart_chiusa.gif','Cart_aperta.gif');
        htmlLink =  htmlLink.replace(/\n/g,'');
    
        // mostra la scritta caricamento
        lnkramo.innerHTML= htmlLink;
        divramo.style.display='block';
        divramo.innerHTML='Caricamento...';
        loadPage(url.replace('&amp;','&'), divID, true, false,'');
    }
    else
    {
        chiudiRamoTreeEx(url, divID)
    }
}
//Funzione di chiusura ramo usata nell'history back basata su iframe
function chiudiRamoTreeEx(url, divID)
{
    divramo = document.getElementById(divID);
    lnkramo = document.getElementById('lnk_'+divID);
    
    if (divramo == null) return;
    htmlLink = lnkramo.innerHTML;
    htmlLink =  htmlLink.replace(':chiudiRamoTree',':apriRamoTree');
    htmlLink =  htmlLink.replace('Cart_aperta.gif','Cart_chiusa.gif');
    htmlLink =  htmlLink.replace(/\n/g,'');
    lnkramo.innerHTML=htmlLink;
    divramo.style.display='none';
       
}
function openPopup(theURL,winName,features) { 
  window.open(theURL,winName,features);
  
  if (debugInfo) document.location='#'+ Math.random()*10000;
}
function aumentaCarattere()
{
    dimensioneCarattere +=10;
    if (dimensioneCarattere >170) dimensioneCarattere = 175;
    cookieManager = new CookiesManager();
    cookieManager.createCookie("dimChar",dimensioneCarattere + '',0);
    document.getElementsByTagName("html")[0].style.fontSize = dimensioneCarattere + '%';
}
function diminuisciCarattere()
{
    dimensioneCarattere -=10;
    if (dimensioneCarattere < 50) dimensioneCarattere = 55;
    cookieManager = new CookiesManager();
    cookieManager.createCookie("dimChar",dimensioneCarattere + '',0);
    document.getElementsByTagName("html")[0].style.fontSize = dimensioneCarattere + '%';
}
function reloadSettings()
{
    cookieManager = new CookiesManager();
    if (cookieManager.hasCookie("dimChar"))
    {   
        dimensioneCarattere =  parseInt(cookieManager.readCookie("dimChar"));
        document.getElementsByTagName("html")[0].style.fontSize = dimensioneCarattere + '%';
    }
    if (toExecuteOnLoad != '') 
    {
        eval(toExecuteOnLoad);
        toExecuteOnLoad = '';
    }
}
function mostraNascondiDivHome(idHome)
{
    div_obj=document.getElementById(idHome);
     if (div_obj.style.display == 'none'){
        div_obj.style.display='block';
     }
     else
     {
        div_obj.style.display='none';
     }
}
        
/////////////////////////////////////////////////////////////////
//Funzione per aprire box note
function ApriChiudiNote(divid)
{
    divNote = document.getElementById(divid);
    divContenitoreNote = document.getElementById(divid+'P');
    if ( divContenitoreNote.style.display=='none' || divContenitoreNote.style.display=='')
    {
        divContenitoreNote.style.display='block';
    }
    else
    {
        divContenitoreNote.style.display='none';
    }
    if (debugInfo) document.location='#'+ Math.random()*10000;
}
//Mostra nota nel popup div
function showNota(divid)
{
    //  Prepara il testo della nota 
    testoNota = document.getElementById(divid).innerHTML;
    posiz = testoNota.indexOf('<STRONG>');
    posiz1 = testoNota.indexOf('</STRONG>');
    if (posiz1>0)
        testoNota = testoNota.substring(0,posiz) + testoNota.substring(posiz1+9);
    
    if (emb)
    {
        // Se ci sono file embed devo usare i vecchi popup
        finestra= window.open('v.htm','nome', 'width=300, height=250');
        finestra.document.write('<html><title>Nota</title><body>' + testoNota +' </body></html>');
        finestra.document.close();
    }
    else
    {
        clientXX = bodyP.getFloatWidth();
        clientYY = bodyP.getFloatHeight();
           
        divContenitoreNote = document.getElementById(divid+'DIV');
        if ( divContenitoreNote.style.display=='none' || divContenitoreNote.style.display=='')
        {
            divContenitoreNote.style.display='block';
            if (clientYY < ey+260) ey = ey - 270;
            divContenitoreNote.style.top = (ey+10) +'px';
            if (clientXX < ex+310) ex = ex - 310; //Riga di comando per posizionare a sinistra le note a ridosso del margine destro della pagina
            divContenitoreNote.style.left = ex +'px';
            if (testoNota!='') document.getElementById(divid+'DIVint').innerHTML= testoNota;
        }
        else
        {
            divContenitoreNote.style.display='none';
        }
    }
    if (debugInfo) document.location='#'+ Math.random()*10000;
}
 function stampaDoc(url)
 {
    window.open(url,'Stampa','top=50,left=50,width=520,height=320,status=no,resizable=yes,scrollbars=yes');
    if (debugInfo) document.location='#'+ Math.random()*10000;
 }
 function confrontaTesti(url, vigenzaA, vigenzaB)
{
    selectA=document.getElementById('vigenzaA');
    selectB=document.getElementById('vigenzaB');
    selectAValue = selectA.options[selectA.selectedIndex].value; 
    selectBValue = selectB.options[selectB.selectedIndex].value;
    if ( selectAValue == selectBValue)
    {
        alert('Attenzione: selezionare due versioni diverse per affettuare il confronto');
        return;
    }
                
    showDoc(url + '&vigenzaA=' + selectAValue + '&vigenzaB=' + selectBValue );
}
function showCorrelazioniSplit(url)
{
    splitterhr.highPanelHeight = bodyP.getFloatHeight()/2;
    splitterhr.openLow();
    
    panelhrDivider.show();
    panel1Low.defaultHeight = "19px";
    panel1Low.element.innerHTML='<table style="background-color: #4F8FBB; height:19px;" align="center" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td class="titolotree" style="background-color: #4F8FBB; color: white;">Correlazioni</td><td align="right"><a href="javascript:splitterhr.collapseLow()"><img src="img/bnt_chiudi.gif" alt="Chiudi" /></a></td></tr></table>';
    panel1Low.show();
    
    panel3Low.element.innerHTML= 'Caricamento dati in corso...';
    panel3Low.show();
    loadPage(url.replace('&amp;','&'), 'contenutoLow', true, false,'');
}
function apriTab(id)
{
	rs = document.getElementById('rassegnaStampa');
	rl = document.getElementById('rassegnaLegislazione');
	rp = document.getElementById('rassegnaPrassi');
	rg = document.getElementById('rassegnaGiurisprudenza');
	if (rs) rs.style.display= 'none';
	if (rl) rl.style.display= 'none';
	if (rp) rp.style.display= 'none';
	if (rg) rg.style.display= 'none';
	document.getElementById(id).style.display= 'block';
}
function selVoce(id)
{
    for(i = 1; i< 8; i++)
    {
        idOra = 'per_' + i;
        if (!document.getElementById(idOra)) continue;
        if (idOra == id) document.getElementById(idOra).className='linkprodottocentroevidenziato';
        else  document.getElementById(idOra).className='leftLink';
    }
    if (document.getElementById('per_dalal'))
    {
        if (id == 'per_dalal') document.getElementById('per_dalal').className='linkprodottocentroevidenziato';
        else {
            document.getElementById('per_dalal').className='leftLink';
            document.getElementById('per_dalal').innerHTML = 'Dal ... al ...' ;
        }
    }
    if (document.getElementById('per_dala2')) {
        if (id == 'per_dala2') document.getElementById('per_dala2').className = 'linkprodottocentroevidenziato';
        else {
            document.getElementById('per_dala2').className = 'leftLink';
            document.getElementById('per_dala2').innerHTML = 'Dal ... al ...';
        }
    }
}
function selVoceEstesa(id,val)
{
    if (document.getElementById('ix_argomentoext')) document.getElementById('ix_argomentoext').value = val;
    for(i = 1; i< 200; i++)
    {
        idOra = 'per_1' + i;
        if (!document.getElementById(idOra)) break;
        if (idOra == id) document.getElementById(idOra).className='linkprodottocentroevidenziato';
        else  document.getElementById(idOra).className='leftLink';
    }
}
function selVoceEstesaDoppia(id, val) {
    selVoceEstesa(id, val);
    selVoce(id);
}




function getFormValues(fname) 
{ 
   fobj = document.forms[fname];
   var str = ""; 
   var valueArr = null; 
   var val = ""; 
   var cmd = ""; 
   for(var i = 0;i < fobj.elements.length;i++) 
   { 
       switch(fobj.elements[i].type) 
       { 
           case "radio":
                if(fobj.elements[i].checked) 
                {
                    str += fobj.elements[i].name;
                    str += "=" + encodeURI(fobj.elements[i].value) + "&"; 
                }
                break; 
           case "checkbox": 
                if(fobj.elements[i].checked) 
                {
                    str += fobj.elements[i].name;
                    str += "=" + encodeURI(fobj.elements[i].value) + "&"; 
                }
                //else  str += "=-1&"; 
                break; 
           case "hidden":
           case "textarea":
           case "text": 
                str += fobj.elements[i].name + 
                 "=" + encodeURI(fobj.elements[i].value).replace('&','%26') + "&"; 
                 break; 
           case "select-one": 
                str += fobj.elements[i].name + 
                "=" + fobj.elements[i].options[fobj.elements[i].selectedIndex].value + "&"; 
                break; 
       } 
   } 
   str = str.substr(0,(str.length - 1)); //Togli & finale
   return str; 
}
function FormValue(_id) {
    this.name = _id.substring(0,_id.indexOf('='));
    this.value = _id.substring(_id.indexOf('=')+1);    
}
function setFormValues(fname, serializedValues) 
{ 
   fobj = document.forms[fname];
   valori = serializedValues.split('|');
   valoriDaSettare = new Array();
   for (var i=0; i<valori.length; i++) 
   {
        val = new FormValue(valori[i]);
        valoriDaSettare.push(val);
   }
   for(var i = 0;i < fobj.elements.length;i++) 
   { 
        campoTrovato = null;
        valoreDaAssociare = null;
        for (var j=0; j<valoriDaSettare.length; j++) 
        {
            if (fobj.elements[i].name == valoriDaSettare[j].name){
                campoTrovato = fobj.elements[i];
                valoreDaAssociare = valoriDaSettare[j];
                break;
            }
        }
        if (campoTrovato == null) continue;
       switch(campoTrovato.type) 
       { 
           case "checkbox": 
                campoTrovato.checked = true;
                valutaOnclickCheck(campoTrovato,false);
                break; 
           case "radio": 
                if (campoTrovato.value == valoreDaAssociare.value)
                {
                    campoTrovato.checked = true;
                    if(campoTrovato.value.indexOf('(')>0) eval(campoTrovato.value);
                }
                break;
           case "hidden":
           case "textarea":
           case "text": 
                 campoTrovato.value = valoreDaAssociare.value; 
                 break; 
           case "select-one": 
                for (var j=0; j<campoTrovato.options.length; j++) 
                {
                    if (campoTrovato.options[j].value == valoreDaAssociare.value)
                        campoTrovato.selectedIndex = j;
                }
                break; 
       } 
   } 
}
function resetFormValues(fname) 
{ 
   fobj = document.forms[fname];
   trovatoCheck = true;
   for(var i = 0;i < fobj.elements.length;i++) 
   { 
        campoTrovato = fobj.elements[i];
       switch(campoTrovato.type) 
       { 
           case "checkbox": 
                if (campoTrovato.name != 'ambCheckAll')
                {
                    campoTrovato.checked = trovatoCheck;
                    trovatoCheck = trovatoCheck && false;
                    valutaOnclickCheck(campoTrovato,true);
                }
                break; 
           case "text": 
                 campoTrovato.value = ''; 
                 break; 
           case "select-one": 
                 campoTrovato.selectedIndex = 0;
                break; 
       } 
   } 
}
var maxParoleEvidenziate=0;
var parolaEvidenziata;
function inizializzaParole(tothits)
{
    maxParoleEvidenziate = tothits-5;
    parolaEvidenziata = 0;
}
function ricercaParolaPrecedente()
{
    if (maxParoleEvidenziate)
    {
        if (parolaEvidenziata == 0)
        {
            parolaEvidenziata = maxParoleEvidenziate;
            window.location.href='#hit'+maxParoleEvidenziate;
        }
        else 
        {
            parolaEvidenziata--;
            window.location.href='#hit'+parolaEvidenziata;
        }
    }
}
function ricercaParolaSuccessiva()
{
    if (maxParoleEvidenziate)
    {
        if (parolaEvidenziata > maxParoleEvidenziate)
        {
            parolaEvidenziata = 1;
            window.location.href='#hit'+parolaEvidenziata;
        }
        else 
        {
            parolaEvidenziata++;
            window.location.href='#hit'+parolaEvidenziata;
        }
    }
}
function selezionaTutti()
{
    tutti = document.getElementById("ambCheckAll").value == "Seleziona tutti";
    
    nAmbiti = document.getElementById("nas").value;
    numeroTrue = 0;
    for (q=0; q< nAmbiti; q++)
    {
        check = document.getElementById('as_'+q);
        if(check) numeroTrue++;
    }
    if (numeroTrue==1 && !tutti) return; 
    for (q=0; q< nAmbiti; q++)
    {
        check = document.getElementById('as_'+q);
        check.checked = tutti;
        document.getElementById("ambCheckAll").value = tutti ? "Deseleziona tutti" : "Seleziona tutti";
        valutaOnclickCheck(check,true);  
    }
    almenoUnAmbito();
}
function almenoUnAmbito()
{
    nAmbiti = document.getElementById("nas").value;
    tuttiFalse = true;
    for (q=0; q< nAmbiti; q++)
    {
        check = document.getElementById('as_'+q);
        tuttiFalse = tuttiFalse && !check.checked;
    }
    if (tuttiFalse)
    {
        alert('Almeno un ambito di ricerca deve essere selezionato');
        check = document.getElementById('as_0');
        check.checked = true;
        valutaOnclickCheck(check,true);        
    }
}
function valutaOnclickCheck(check, settaSubElementi)
{
    if((new String(check.onclick)).indexOf('apriChiudiProdotto')>0)
    {
        str =  new String(check.onclick);
        ini = str.indexOf('apriChiudiProdotto');
        fin = str.indexOf(')',ini)+1;
        str = str.substring(ini, fin);
        if (!settaSubElementi) str = "ex"+str;
        eval(str);
    }
}
function compareData(id)
{
	 dataA=document.getElementById(id);
     dataA.style.visibility = 'visible';
     dataA.style.display='inline';
}
function scompareData(id, formSuff)
{
	 dataA=document.getElementById(id);
     dataA.style.visibility = 'hidden';
     dataA.style.display='none';
     document.getElementById(formSuff+'Giorno').value='';
     document.getElementById(formSuff+'Mese').selectedIndex = 0;
     document.getElementById(formSuff+'Anno').selectedIndex = 0;
}
function leggiComuni(legge)
{
    setFormValues('formRicerca', legge);
    scompareData('DataA','a');
}
function showCronologia()
{
    document.getElementById('cronologia').style.display= 'block';
    document.getElementById('cronoContent').innerHTML = 'Caricamento in corso...';
    loadPage('caricaCronologia.aspx', 'cronoContent', true, false,'');
}
function chiudiCronologia()
{
    document.getElementById('cronologia').style.display= 'none';
}
function iconize()
{
     somm_img = document.getElementById('iconRedux');

     if (somm_img.alt=='Riduci'){
        splitterhr.iconizeLow();
        somm_img.src = 'img/bnt_deiconize.gif';
        somm_img.alt='Ripristina';
     }
     else
     {
        splitterhr.deiconizeLow();
        somm_img.src = 'img/bnt_iconize.gif';
        somm_img.alt='Riduci';
     }
 }
 function compilaModulo(url) {
     window.open(url, 'Cm', 'top=10,left=10,width=1000,height=700,status=no,resizable=yes,scrollbars=yes');
 }

 function apriIFrame(file, divid) {
     divEl = document.getElementById(divid);
     if (divEl) {
         var ffTest = /MSIE[\/\s](\d+\.\d+)/;
         if (ffTest.test(navigator.userAgent)) {
             divEl.innerHTML = '<iframe align="center" src="' + file + '" width="95%" height="500px"></iframe>';
             return;
         }
         
     }
     divEl.innerHTML = '';
 }
 function checkPdfPlugin() {
     presenza = false;
     var axObj = null;
     try{
     if (window.ActiveXObject) {
         axObj = new ActiveXObject("AcroPDF.PDF");
         if (!axObj) {
             axObj = new ActiveXObject("PDF.PdfCtrl");
         }
         if (axObj !== null) {
             presenza = true;
         }
     }
     if (!presenza) {
         for (var i = 0; i < navigator.plugins.length; i++) {
             name = navigator.plugins[i].name;
             if (name.indexOf('Adobe Reader') > -1 || name.indexOf('Adobe PDF') > -1 || name.indexOf('Acrobat') > -1)
                 presenza = true;
         } 
     }
     if (!presenza) {
         plugin = navigator.mimeTypes["application/pdf"];
         presenza = (plugin && plugin.enabledPlugin);
     }
     }catch(e){presenza = false;}
     return presenza;
 }



 function showPopupLibro(idepi) {
     clientXX = bodyP.getFloatWidth();
     clientYY = bodyP.getFloatHeight();
     var ex = (ie5) ? event.clientX + document.body.scrollLeft : lastMouseMoveEvent.pageX;
     var ey = (ie5) ? event.clientY + document.body.scrollTop : lastMouseMoveEvent.pageY;

     if (clientYY < ey + 370) ey = ey - 370;

     if (ex == null || ey == null) return;
     divE = document.getElementById('popupSchedaLibro');
     divE.innerHTML = '<img src="img/loading.gif" /> Caricamento...';
     divE.style.display = 'block';
     divE.style.top = (ey + 10) + 'px';
     if (clientXX < ex + 600) ex = ex - 620; //Riga di comando per posizionare a sinistra le note a ridosso del margine destro della pagina
     divE.style.left = ex + 'px';

     loadPageNoControllo('caricaSchedaLB.aspx?'+idepi, 'popupSchedaLibro', false, false, '');
 }
 function hidePopupLibro() {
     divE = document.getElementById('popupSchedaLibro');
     divE.style.display = 'none';
 }
 function compilaFormula(formula) {
     document.location = 'scaricaRtf.aspx?file=' + formula+'.rtf';
 }



 function trackVideo() {
     if (idlogvideo > 0 && document.getElementById('videoPresente')) {
         $.get("trackTimeOnPage.aspx?idlog=" + idlogvideo);
         clearTimeout(timeoutAttuale);
         timeoutAttuale = setInterval("trackVideo()", 10000);
     }
 }
 function avviaTrackTempo(idlog) {
     idlogvideo = idlog;
     if (idlogvideo > 0) {
         clearTimeout(timeoutAttuale);
         timeoutAttuale = setInterval("trackVideo()", 10000);
     }
 }
 function viewVideo(_idlog, _file, _image, _width, _height) {
     avviaTrackTempo(_idlog);
     jwplayer("videoPlayerCont").setup({
               //autostart: false,
               controlbar: "bottom",
               image: _image,
               file: _file,
               flashplayer: "player.swf",
                   height: _height,
                   width: _width
               });
           }


function openReader(_url) {
   window.open(_url, "reader", "top=0,left=0,width=" + screen.width*0.97 + ",height=" + screen.height*0.9 + ",status=no,resizable=yes,scrollbars=yes");
}


 
