var flag = true;

var msg =  "Attenzione: Non inserendo nessun criterio, la ricerca potrebbe essere molto lunga.\n\n";

    msg += 'Per interrompere la ricerca premere il pulsante "OK"\n';
    msg += 'Per proseguire ugualmente premere il pulsante "Annulla"';



function selezionaBiblioteche()
{
    // ***********************************************************************
    // *** Alla selezione del gruppo, preseleziono le Biblioteche relative ***
    // ***********************************************************************

    objBiblioteche = document.ESIMPLEX.CODICE_BIBLIOj.options;
    objGruppi = document.Gruppi.CODICE_BIBLIO_GRUPPI.options;

    var arrBiblioteche;
    var temp, strSelezione = "";

    // *** Processo tutti gli elementi dei Gruppi ***
    for (var c=0; c<objGruppi.length; c++) {
    
        if ( objGruppi[c].selected == true ) {
            strSelezione += objGruppi[c].value + ",";
        }
    }//end_for
    
    // Suddivido in array ogni valore della selezione
    arrBiblioteche = strSelezione.split(",");

    // Per ogni codice Biblioteca assegnato al gruppo
    for(var i = 0; i < arrBiblioteche.length; i++) {
        // Seleziono ogni biblioteca avente il codice attuale
        temp = arrBiblioteche[i];

        // Ciclo su tutte le biblioteche e seleziono se codice gruppo uguale
        for(var a = 0; a < objBiblioteche.length; a++) {
            if (temp == objBiblioteche[a].value) {
                objBiblioteche[a].selected = true;
            }
        }
    }
 
}

function pulisci() {
    document.forms["ESIMPLEX"].reset();
    document.forms["Gruppi"].reset();
    writetoLyr('areabib', 'Tutte le Biblioteche');
}


// IDT scrittura in layers
function writetoLyr(name, message) {

if ( message != "") {
    if (document.layers) {
        document.layers[name].document.close();
        document.layers[name].document.write(message);
        document.layers[name].document.close();
    } else {
        if (document.all) {
            var tmp = escape(message);
            var objJayer = eval("document.all." + name);
            objJayer.innerHTML = unescape(tmp);
        } else {
            document.getElementById(name).innerHTML = message;
        }
    }
}

}

function statoCheckboxLibrerie ( blnCondizione ) {
//    document.Gruppi.checkAllLib.checked = blnCondizione;
    writetoLyr('areabib', "")
}

function checkAllLibrerie () {
//    if ( document.Gruppi.checkAllLib.checked ) {
//    {
        // Pulisco altre selezioni Attive
        document.ESIMPLEX.CODICE_BIBLIOj.selectedIndex = -1;
        document.Gruppi.CODICE_BIBLIO_GRUPPI.selectedIndex = -1;
        writetoLyr('areabib', "Tutte le Biblioteche")
//    }
}

//Gestione dei cookies
function FixCookieDate (date) {

  var base = new Date(0);

  var skew = base.getTime();

  if (skew > 0)

    date.setTime (date.getTime() - skew);

}



function getCookieVal (offset) {

  var endstr = document.cookie.indexOf (";", offset);

  if (endstr == -1)

    endstr = document.cookie.length;

  return unescape(document.cookie.substring(offset, endstr));

}





function GetCookie (name) {

  var arg = name + "=";

  var alen = arg.length;

  var clen = document.cookie.length;

  var i = 0;

  while (i < clen) {

    var j = i + alen;

    if (document.cookie.substring(i, j) == arg)

      return getCookieVal (j);

    i = document.cookie.indexOf(" ", i) + 1;

    if (i == 0) break; 

  }

  return null;

}




function SetCookieNew (name, value, valueGruppo) {

  var argv = SetCookieNew.arguments;

  var argc = SetCookieNew.arguments.length;

  var expires = (argc > 3) ? argv[3] : null;

  var path = (argc > 4) ? argv[4] : null;

  var domain = (argc > 5) ? argv[5] : null;

  var secure = (argc > 6) ? argv[6] : false;

if (expires!=null) FixCookieDate(expires); 

   var strContent = name + "=" + escape (value) +
  
    "; gruppi=" + escape(valueGruppo) +
    
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +

    ((path == null) ? "" : ("; path=" + path)) +

    ((domain == null) ? "" : ("; domain=" + domain)) +

    ((secure == true) ? "; secure" : "");

document.cookie = strContent;
}


function SetCookie (name, value) {

  var argv = SetCookie.arguments;

  var argc = SetCookie.arguments.length;

  var expires = (argc > 2) ? argv[2] : null;

  var path = (argc > 3) ? argv[3] : null;

  var domain = (argc > 4) ? argv[4] : null;

  var secure = (argc > 5) ? argv[5] : false;

if (expires!=null) FixCookieDate(expires); 

  document.cookie = name + "=" + escape (value) +
  

    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +

    ((path == null) ? "" : ("; path=" + path)) +

    ((domain == null) ? "" : ("; domain=" + domain)) +

    ((secure == true) ? "; secure" : "");

}





function DeleteCookie (name) {

  var exp = new Date();

  FixCookieDate (exp);

  exp.setTime (exp.getTime() - 1);  

  var cval = GetCookie (name);

  if (cval != null)

    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();

}



function ripristina()

{

    // Lettura dei codici delle Biblioteche dal Cookie; per ogni
    // codice viene verificato che nella maschera di selezione venga preselezionato.

    var strCodiciBiblioGookie = GetCookie("biblio");
    var strCodiciGruppiGookie = GetCookie("gruppi");
    
    strBiblioteche = "document.ESIMPLEX.CODICE_BIBLIOj.options";
    strGruppi = "document.Gruppi.CODICE_BIBLIO_GRUPPI.options";

    if ((strCodiciBiblioGookie == "") || (strCodiciBiblioGookie == null)) {
        document.ESIMPLEX.CODICE_BIBLIOj.selectedIndex = -1;
    }

    if ((strCodiciBiblioGookie != "") && (strCodiciBiblioGookie != null)) {

        var arrBiblioteche = strCodiciBiblioGookie.split(",");

        // *** Verifico se Preselezionare le Biblioteche ***
        for(var i = 0; i < arrBiblioteche.length; i++) {
            // Seleziono ogni biblioteca avente il codice attuale
            temp = arrBiblioteche[i];

            // Ciclo su tutte le biblioteche e seleziono se codice gruppo uguale
//            if (arrBiblioteche.length <= 20) {
                for(var a = 0; a < eval(strBiblioteche + ".length") ; a++) {
                    strBiblioteca = eval("document.ESIMPLEX.CODICE_BIBLIOj.options[" + a + "].value")

                    if (temp == strBiblioteca) {
                        eval("document.ESIMPLEX.CODICE_BIBLIOj.options[" + a + "].selected = true")
                    }
                }
//            }
        }

        // *** Verifico se Preselezionare i Gruppi ***
        document.Gruppi.CODICE_BIBLIO_GRUPPI.selectedIndex = -1
        
        for (c=0; c < eval(strGruppi + ".length"); c++) {
            // Se Gruppo memorizzato in Cookie, lo seleziono
            if (strCodiciBiblioGookie == eval(strGruppi + "[" + c + "].value")) {
                eval(strGruppi + "[" + c + "].selected = true");
                writetoLyr('areabib', document.Gruppi.CODICE_BIBLIO_GRUPPI.options[document.Gruppi.CODICE_BIBLIO_GRUPPI.selectedIndex].text);
            }
        }
    }//end_if

    document.ESIMPLEX.AUTOREj.focus();
}

function ripristina2(strCodiciBiblioGookie)

{

//    var strCodiciBiblioGookie = GetCookie("biblio");
//    var strCodiciGruppiGookie = GetCookie("gruppi");
    
    strBiblioteche = "document.ESIMPLEX.CODICE_BIBLIOj.options";
    strGruppi = "document.Gruppi.CODICE_BIBLIO_GRUPPI.options";

    if ((strCodiciBiblioGookie == "") || (strCodiciBiblioGookie == null)) {
        document.ESIMPLEX.CODICE_BIBLIOj.selectedIndex = -1;
    }

    if ((strCodiciBiblioGookie != "") && (strCodiciBiblioGookie != null)) {

        var arrBiblioteche = strCodiciBiblioGookie.split(",");

        // *** Verifico se Preselezionare le Biblioteche ***
        for(var i = 0; i < arrBiblioteche.length; i++) {
            // Seleziono ogni biblioteca avente il codice attuale
            temp = arrBiblioteche[i];

            // Ciclo su tutte le biblioteche e seleziono se codice gruppo uguale
            for(var a = 0; a < eval(strBiblioteche + ".length") ; a++) {
                strBiblioteca = eval("document.ESIMPLEX.CODICE_BIBLIOj.options[" + a + "].value")

                if (temp == strBiblioteca) {
                    eval("document.ESIMPLEX.CODICE_BIBLIOj.options[" + a + "].selected = true")
                }
            }
        }

        // *** Verifico se Preselezionare i Gruppi ***
        document.Gruppi.CODICE_BIBLIO_GRUPPI.selectedIndex = -1
        
        arrBiblioteches = arrBiblioteche.sort();
        for (c=0; c < eval(strGruppi + ".length"); c++) {
            // Se Gruppo memorizzato in Cookie, lo seleziono
//            if (strCodiciBiblioGookie == eval(strGruppi + "[" + c + "].value")) {
              var gruppit = eval(strGruppi + "[" + c + "].value");
              var arrGruppi = gruppit.split(",");
              arrGruppis = arrGruppi.sort();
              if (arrGruppis.toString() == arrBiblioteches.toString())
              {
                eval(strGruppi + "[" + c + "].selected = true");
                writetoLyr('areabib', document.Gruppi.CODICE_BIBLIO_GRUPPI.options[document.Gruppi.CODICE_BIBLIO_GRUPPI.selectedIndex].text);
                break;
              }
        }
    }//end_if

    document.ESIMPLEX.AUTOREj.focus();
}

// Funzioni per il corretto utilizzo degli operatori logici 
// tra i termini in un canale
function replaceString(txtstr,op_2)

{

     op_3 = "+";

     if (op_2 == "ADJ") op_3 = "+";

     if (op_2 == "stringa") op_3 = "+";

     if (op_2 == "AND") op_3 = "+";

     if (op_2 == "OR") op_3 = ",";

     contablk=0

     seconda=""

     prima=""

     if (txtstr.length == 0)

     {

       seconda=""

     }

     else

     {

       for (var k=0; k<txtstr.length; k++)

       {

          if (txtstr.charAt(k) == " ")

          {

             if (contablk == 0)

             {

                 contablk = contablk + 1

                 prima = prima + "+"

             }

             else

                 contablk = contablk + 1

          }

          else

          {

             contablk = 0

             prima = prima + txtstr.charAt(k)

          }

       }



       if (prima.charAt(prima.length-2) == "+")

           prima=prima.substring(0,prima.length-2)

       if (prima.charAt(prima.length-1) == "+")

           prima=prima.substring(0,prima.length-1)

       if (prima.charAt(0) == "+")

           prima=prima.substring(1,prima.length)



       contablk=0

       for (var j=0; j<prima.length; j++)

       {

          if (prima.charAt(j) == "+")

          {

             if (contablk == 0)

             {

                 contablk = contablk + 1

                 seconda = seconda + op_3

             }

             else

                 contablk = contablk + 1

          }

          else

          {

             contablk = 0

             seconda = seconda + prima.charAt(j)

          }

       }

     }

     return seconda

}





function replaceStringau(txtstr,op_2)

{

     op_3 = "+";

     if (op_2 == "ADJ") op_3 = "+";

     if (op_2 == "stringa") op_3 = "+";

     if (op_2 == "AND") op_3 = "&";

     if (op_2 == "OR") op_3 = ",";

     contablk=0

     seconda=""

     prima=""

     if (txtstr.length == 0)

     {

       seconda=""

     }

     else

     {

       for (var k=0; k<txtstr.length; k++)

       {

          if (txtstr.charAt(k) == " ")

          {

             if (contablk == 0)

             {

                 contablk = contablk + 1

                 prima = prima + "+"

             }

             else

                 contablk = contablk + 1

          }

          else

          {

             contablk = 0

             prima = prima + txtstr.charAt(k)

          }

       }



       if (prima.charAt(prima.length-2) == "+")

           prima=prima.substring(0,prima.length-2)

       if (prima.charAt(prima.length-1) == "+")

           prima=prima.substring(0,prima.length-1)

       if (prima.charAt(0) == "+")

           prima=prima.substring(1,prima.length)



       contablk=0

       for (var j=0; j<prima.length; j++)

       {

          if (prima.charAt(j) == "+")

          {

             if (contablk == 0)

             {

                 contablk = contablk + 1

                 seconda = seconda + op_3

             }

             else

                 contablk = contablk + 1

          }

          else

          {

             contablk = 0

             seconda = seconda + prima.charAt(j)

          }

       }

     }

     return seconda

}



function salva() {

    // Salvo le biblioteche/Gruppi selezionati nel Cookie

    var objBiblioteche = document.ESIMPLEX.CODICE_BIBLIOj;
    var objGruppiBiblioteche = document.Gruppi.CODICE_BIBLIO_GRUPPI;
  
    var strCodiciBiblioGookie = "";
    var strCodiciGruppiGookie = "";

    // *** Processo i Gruppi, se un gruppo e' selezionato NON considero le singole Biblioteche ***
    if ( document.Gruppi.CODICE_BIBLIO_GRUPPI.selectedIndex != -1 ) {

        for ( i=0; i<objGruppiBiblioteche.length ; i++) {
            if (objGruppiBiblioteche.options[i].selected == true ) {

                if (strCodiciGruppiGookie != "") {
                    strCodiciGruppiGookie += "," + escape(objGruppiBiblioteche.options[i].text);
                    strCodiciBiblioGookie += "," + objGruppiBiblioteche.options[i].value;
                } else {
                    strCodiciGruppiGookie = escape(objGruppiBiblioteche.options[i].text);
                    strCodiciBiblioGookie = objGruppiBiblioteche.options[i].value;
                }
            }
        }

    } else {

        // *** Memorizzo codici selezionati per le singole Biblioteche ***
        for ( i=0; i<objBiblioteche.length ; i++) {

            if (objBiblioteche.options[i].selected == true ) {

                if (strCodiciBiblioGookie != "") {
                    strCodiciBiblioGookie += "," + objBiblioteche.options[i].value;
                } else {
                    strCodiciBiblioGookie = objBiblioteche.options[i].value;
                }
            }

        }
    }
  
    var expdate = new Date ();
    expdate.setTime (expdate.getTime() + (365*24 * 60 * 60 * 1000));
    //SetCookie("strCodiciBiblioGookie", strCodiciBiblioGookie, expdate);
    SetCookieNew("biblio", strCodiciBiblioGookie, strCodiciGruppiGookie, expdate);

    chiudiMenu('sel');
    chiudiMenu('sel1');
    if (nome_file_css!='/basisicons/css/solotesto' && nome_file_css!='/basisicons/css/access')
    {
      makeUnbold(1);
      makeUnbold(2);
    }
}



function Cerca()
{

  flag = true;

  myvar=document.ESIMPLEX

  BD1=replaceString(myvar.BASE_DATIj.options[myvar.BASE_DATIj.selectedIndex].value,'uguale')

  var objBiblioteche=document.ESIMPLEX.CODICE_BIBLIOj;

  var CB1="";

  m1len = objBiblioteche.length ;

  for ( i=0; i<m1len ; i++)

  {

    if (objBiblioteche.options[i].selected == true )

    {

    if (CB1 != "")

    CB1=CB1 + "," + objBiblioteche.options[i].value;

    if (CB1 == "")

    CB1=objBiblioteche.options[i].value;

    }

  }

  CB1=replaceString(CB1,'uguale')

  COLLANA1=replaceString(myvar.COLLANAj.value,myvar.COLLANA_Oj.options[myvar.COLLANA_Oj.selectedIndex].value)

  AUTORE1=replaceStringau(myvar.AUTOREj.value,myvar.AUTORE_Oj.options[myvar.AUTORE_Oj.selectedIndex].value)

  TITOLO1=replaceString(myvar.TITOLOj.value,myvar.TITOLO_Oj.options[myvar.TITOLO_Oj.selectedIndex].value)

  SOGGETTO1=replaceString(myvar.SOGGETTOj.value,myvar.SOGGETTO_Oj.options[myvar.SOGGETTO_Oj.selectedIndex].value)

  ABSTRACT21=replaceString(myvar.ABSTRACT2j.value,myvar.ABSTRACT2_Oj.options[myvar.ABSTRACT2_Oj.selectedIndex].value)

  DESCRIZIONE_CLASSIFICAZIONE1=replaceString(myvar.DESCRIZIONE_CLASSIFICAZIONEj.value,myvar.DESCRIZIONE_CLASSIFICAZIONE_Oj.options[myvar.DESCRIZIONE_CLASSIFICAZIONE_Oj.selectedIndex].value)

  TIPO_DOCUMENTO1=replaceString(myvar.TIPO_DOCUMENTOj.options[myvar.TIPO_DOCUMENTOj.selectedIndex].value)

  LUOGO_EDIZIONE1=replaceString(myvar.LUOGO_EDIZIONEj.value,myvar.LUOGO_EDIZIONE_Oj.options[myvar.LUOGO_EDIZIONE_Oj.selectedIndex].value)

  EDITORE1=replaceString(myvar.EDITOREj.value,myvar.EDITORE_Oj.options[myvar.EDITORE_Oj.selectedIndex].value)

//  LINGUA1=replaceString(myvar.LINGUAj.value,myvar.LINGUA_Oj.options[myvar.LINGUA_Oj.selectedIndex].value)

  LINGUA1=myvar.LINGUAj.value

  LINGUAU=LINGUA1.toUpperCase();

  if ((LINGUAU == "ITALIANO") || (LINGUAU == "ITALIANA"))

{

  LINGUA1 = "italian*";

}

//  PAESE1=replaceString(myvar.PAESEj.value,myvar.PAESE_Oj.options[myvar.PAESE_Oj.selectedIndex].value)

  PAESE1=myvar.PAESEj.value

  NOTE_ISBD1=replaceString(myvar.NOTE_ISBDj.value,myvar.NOTE_ISBD_Oj.options[myvar.NOTE_ISBD_Oj.selectedIndex].value)

  IMPRONTA1=replaceString(myvar.IMPRONTAj.value,myvar.IMPRONTA_Oj.options[myvar.IMPRONTA_Oj.selectedIndex].value)

  POSSESSORE1=replaceString(myvar.POSSESSOREj.value,myvar.POSSESSORE_Oj.options[myvar.POSSESSORE_Oj.selectedIndex].value)

  MARCHE1=replaceString(myvar.MARCHEj.value,myvar.MARCHE_Oj.options[myvar.MARCHE_Oj.selectedIndex].value)

  NOTE_ESEMP1=replaceString(myvar.NOTE_ESEMPj.value,myvar.NOTE_ESEMP_Oj.options[myvar.NOTE_ESEMP_Oj.selectedIndex].value)



  FORMFL_OB1=replaceString(myvar.FORMFL_OBj.options[myvar.FORMFL_OBj.selectedIndex].value,'uguale')





  if (((CB1 == "") || (CB1 == " ")) && (myvar.AUTOREj.value.length == 0) && (myvar.TITOLOj.value.length == 0) && (myvar.SOGGETTOj.value.length == 0) && (myvar.ABSTRACT2j.value.length == 0) && (myvar.COLLANAj.value.length == 0) && (myvar.DESCRIZIONE_CLASSIFICAZIONEj.value.length == 0) && (myvar.DATA_PUBBLICAZIONEj.value.length == 0) && (myvar.LUOGO_EDIZIONEj.value.length == 0) && (myvar.EDITOREj.value.length == 0) && (myvar.LINGUAj.value.length == 0) && (myvar.PAESEj.value.length == 0) && (myvar.NOTE_ISBDj.value.length == 0) && (myvar.BIDj.value.length == 0) && (myvar.VIDj.value.length == 0) && (myvar.DATA_INSERIMENTOj.value.length == 0) && (myvar.IMPRONTAj.value.length == 0) && (myvar.POSSESSOREj.value.length == 0) && (myvar.MARCHEj.value.length == 0) && (myvar.NOTE_ESEMPj.value.length == 0))

  {
    alert ("Inserire almeno un canale di ricerca");
//    flag=confirm(msg);
    flag = false;

  }

  if (flag)

  {

    sommacb = "CODICE_BIBLIO_O=uguale&CODICE_BIBLIO=" + CB1

    sommabd = "&BASE_DATI_O=uguale&BASE_DATI=" + BD1

//    sommabd = "&BASE_DATI_O=" + myvar.BASE_DATI_Oj.options[myvar.BASE_DATI_Oj.selectedIndex].value + "&BASE_DATI=" + myvar.BASE_DATIj.options[myvar.BASE_DATIj.selectedIndex].value

    sommaco = "&COLLANA_O=" + myvar.COLLANA_Oj.options[myvar.COLLANA_Oj.selectedIndex].value + "&COLLANA=" + COLLANA1

    sommaau = "&AUTORE_O=" + myvar.AUTORE_Oj.options[myvar.AUTORE_Oj.selectedIndex].value + "&AUTORE=" + AUTORE1.replace(/,/g," ")

    sommati = "&TITOLO_O=" + myvar.TITOLO_Oj.options[myvar.TITOLO_Oj.selectedIndex].value + "&TITOLO=" + TITOLO1

    sommaso = "&SOGGETTO_O=" + myvar.SOGGETTO_Oj.options[myvar.SOGGETTO_Oj.selectedIndex].value + "&SOGGETTO=" + SOGGETTO1.replace(/'/g,"+")

    sommaab = "&ABSTRACT2_O=" + myvar.ABSTRACT2_Oj.options[myvar.ABSTRACT2_Oj.selectedIndex].value + "&ABSTRACT2=" + ABSTRACT21

    sommadc = "&DESCRIZIONE_CLASSIFICAZIONE_O=" + myvar.DESCRIZIONE_CLASSIFICAZIONE_Oj.options[myvar.DESCRIZIONE_CLASSIFICAZIONE_Oj.selectedIndex].value + "&DESCRIZIONE_CLASSIFICAZIONE=" + DESCRIZIONE_CLASSIFICAZIONE1

    sommatd = "&TIPO_DOCUMENTO_O=uguale&TIPO_DOCUMENTO=" + TIPO_DOCUMENTO1

    sommama = "&MATERIALE_O=uguale&MATERIALE=" + myvar.MATERIALEj.options[myvar.MATERIALEj.selectedIndex].value

    sommage = "&GENERE_O=uguale&GENERE=" + myvar.GENEREj.options[myvar.GENEREj.selectedIndex].value

    sommadp = "&DATA_PUBBLICAZIONE_O=" + myvar.DATA_PUBBLICAZIONE_Oj.options[myvar.DATA_PUBBLICAZIONE_Oj.selectedIndex].value + "&DATA_PUBBLICAZIONE=" + myvar.DATA_PUBBLICAZIONEj.value

    sommale = "&LUOGO_EDIZIONE_O=" + myvar.LUOGO_EDIZIONE_Oj.options[myvar.LUOGO_EDIZIONE_Oj.selectedIndex].value + "&LUOGO_EDIZIONE=" + LUOGO_EDIZIONE1

    sommaed = "&EDITORE_O=" + myvar.EDITORE_Oj.options[myvar.EDITORE_Oj.selectedIndex].value + "&EDITORE=" + EDITORE1

//    sommali = "&LINGUA_O=" + myvar.LINGUA_Oj.options[myvar.LINGUA_Oj.selectedIndex].value + "&LINGUA=" + LINGUA1

    sommali = "&LINGUA_O=" + "AND" + "&LINGUA=" + LINGUA1

//    sommapa = "&PAESE_O=" + myvar.PAESE_Oj.options[myvar.PAESE_Oj.selectedIndex].value + "&PAESE=" + PAESE1

    sommapa = "&PAESE_O=" + "AND" + "&PAESE=" + PAESE1

    sommani = "&NOTE_ISBD_O=" + myvar.NOTE_ISBD_Oj.options[myvar.NOTE_ISBD_Oj.selectedIndex].value + "&NOTE_ISBD=" + NOTE_ISBD1

    sommabv = "&BID_O=uguale&BID=" + myvar.BIDj.value + "&VID_O=uguale&VID=" + myvar.VIDj.value

    sommaim = "&IMPRONTA_O=" + myvar.IMPRONTA_Oj.options[myvar.IMPRONTA_Oj.selectedIndex].value + "&IMPRONTA=" + IMPRONTA1

    sommapo = "&POSSESSORE_O=" + myvar.POSSESSORE_Oj.options[myvar.POSSESSORE_Oj.selectedIndex].value + "&POSSESSORE=" + POSSESSORE1

    sommamh = "&MARCHE_O=" + myvar.MARCHE_Oj.options[myvar.MARCHE_Oj.selectedIndex].value + "&MARCHE=" + MARCHE1

    sommane = "&NOTE_ESEMP_O=" + myvar.NOTE_ESEMP_Oj.options[myvar.NOTE_ESEMP_Oj.selectedIndex].value + "&NOTE_ESEMP=" + NOTE_ESEMP1

    formfi1 = "&FORM_C=" + myvar.FORM_Cj.options[myvar.FORM_Cj.selectedIndex].value + "&FORMFL_OB=" + FORMFL_OB1

    formfi2 = "&FORM_SO=" + myvar.FORM_SOj.options[myvar.FORM_SOj.selectedIndex].value

    sommains = "&DATA_INSERIMENTO_O=" + myvar.DATA_INSERIMENTO_Oj.options[myvar.DATA_INSERIMENTO_Oj.selectedIndex].value + "&DATA_INSERIMENTO=" + myvar.DATA_INSERIMENTOj.value

  

    sommaca1 = sommacb + sommabd  + sommaau + sommati + sommaso + sommaab + sommaco + sommadc + sommatd + sommama + sommage + sommadp

    sommaca2 = sommale + sommaed + sommali + sommapa + sommani + sommabv + sommaim + sommapo + sommamh + sommane + sommains

  

    somma="http://sbnweb.csi.it:8092/BASIS/OPACX/UDMOPAC/esimplex/SDF?" + sommaca1 + sommaca2 + formfi1 + formfi2

  

    window.open(somma,'_self','menubar=yes,toolbar=yes,scrollbars=yes,location=yes,resizable=yes,status=yes,directories=yes');

  }

}











function Select_All(){

  for (i=0; i < document.FORM_SUM.length; i++){

    document.FORM_SUM.elements[i].checked = document.FORM_SUM.ALL_CHECK.checked;

  }

}



function Elababstr(campoin)

{

  var k = 0

  var NewString2 = campoin;

  var NewString3 = ""

  for (k = 0; k < NewString2.length; k++)

  {

    if (NewString2.charAt(k) == "+")

      {

                   NewString3 = NewString3 + " ";

      }

      else

      {

                   NewString3 = NewString3 + NewString2.charAt(k);

      }

  }

  var Newstring4 = (unescape(NewString3));

  var i = 0;

  var Stringa = Newstring4.replace(/ XBRX /g,"<BR>");

  var NewStringa = "";

  for (i = 0; i < Stringa.length; i++)

  {

    if (Stringa.charAt(i) == ' ')

    {

      NewStringa = NewStringa + '&nbsp;';

    }

    else

    {

      NewStringa = NewStringa + Stringa.charAt(i);

    }

  }

  return NewStringa;

}



function Cercasempl()

{

  flag = true;

  myvar=document.ESIMPLEX

  var objBiblioteche=document.ESIMPLEX.CODICE_BIBLIOj;

  var CB1="";

  m1len = objBiblioteche.length ;

  for ( i=0; i<m1len ; i++)

  {

    if (objBiblioteche.options[i].selected == true )

    {

    if (CB1 != "")

    CB1=CB1 + "," + objBiblioteche.options[i].value;

    if (CB1 == "")

    CB1=objBiblioteche.options[i].value;

    }

  }

  CB1=replaceString(CB1,'uguale')

  AUTORE1=replaceStringau(myvar.AUTOREj.value,myvar.AUTORE_Oj.value)

  TITOLO1=replaceString(myvar.TITOLOj.value,myvar.TITOLO_Oj.value)

  SOGGETTO1=replaceString(myvar.SOGGETTOj.value,myvar.SOGGETTO_Oj.value)

  EDITORE1=replaceString(myvar.EDITOREj.value,myvar.EDITORE_Oj.value)

  MACROCANALE1=replaceString(myvar.MACROCANALEj.value,myvar.MACROCANALE_Oj.value)



  FORMFL_OB1=replaceString(myvar.FORMFL_OBj.value,'uguale')





  if (((CB1 == "") || (CB1 == " ")) && (myvar.AUTOREj.value.length == 0) && (myvar.TITOLOj.value.length == 0) && (myvar.SOGGETTOj.value.length == 0) && (myvar.EDITOREj.value.length == 0) && (myvar.MACROCANALEj.value.length == 0))

  {

    alert ("Inserire almeno un canale di ricerca");
//    flag=confirm(msg);
    flag=false;

  }

  if (flag)

  {

    sommacb = "CODICE_BIBLIO_O=uguale&CODICE_BIBLIO=" + CB1

    sommaau = "&AUTORE_O=" + myvar.AUTORE_Oj.value + "&AUTORE=" + AUTORE1.replace(/,/g," ")

    sommati = "&TITOLO_O=" + myvar.TITOLO_Oj.value + "&TITOLO=" + TITOLO1

    sommaso = "&SOGGETTO_O=" + myvar.SOGGETTO_Oj.value + "&SOGGETTO=" + SOGGETTO1.replace(/'/g,"+")

    sommaed = "&EDITORE_O=" + myvar.EDITORE_Oj.value + "&EDITORE=" + EDITORE1

    sommamc = "&MACROCANALE_O=" + myvar.MACROCANALE_Oj.value + "&MACROCANALE=" + MACROCANALE1

    formfi1 = "&FORM_C=" + "AND" + "&FORMFL_OB=" + FORMFL_OB1

    formfi2 = "&FORM_SO=" + myvar.FORM_SOj.value



    sommaca1 = sommacb + sommaau + sommati + sommaso + sommaed + sommamc
 

    somma="http://sbnweb.csi.it:8092/BASIS/OPACX/UDMOPAC/esimplex/SDF?" + sommaca1 + formfi1 + formfi2

 

    window.open(somma,'_self','menubar=yes,toolbar=yes,scrollbars=yes,location=yes,resizable=yes,status=yes,directories=yes');

  }

}
