function inputRaz(mytype, lang, mode)
{
  var type_id = ($(mytype).attr('id'));
  var num = type_id.substr(4); // type
  var myinput = $("#motscles"+num);
  var myinputHidden = $("#hiddenmotscles"+num);
  var myinputDestArbo = $("#dest_arbo");
  var pos, posleft, postop;
  
  myinput.val('');  
  myinputHidden.val('');
  
  if ( acResultsDiv != null )
    clearAutoComplete();
  
  if ($(mytype).val() == "I_APH1")
  {
    $("#arbo2").remove();
    $("#man").remove();
    $("#mus").remove();
    $("#pays").remove();
    myinput.attr('readonly','readonly');
    $.getJSON('get_arbre.php?id=arbo1&lang='+lang+'&mode='+mode, {},
      function(json) {
        $("body").append(json['div']);
        $("#matieres1").Treeview({ animated: "fast", collapsed: true });
      	pos = myinput.offset();
	      posleft = pos.left - 5;
	      postop = pos.top +  myinput.height() + 10;
	      $("#arbo1").css('left',posleft);
	      $("#arbo1").css('top',postop);
      }
    );
	  myinputDestArbo.val('motscles'+num);
	  $(mytype).children("option[value='I_MAN']").addClass("none");
	  $(mytype).children("option[value='I_MUS']").addClass("none");
	  $(mytype).children("option[value='I_PAYS']").addClass("none");
	  $(mytype).children("option[value='I_MEL']").addClass("none");
	  $(mytype).children("option[value='I_PER']").addClass("none");
  }
  else if ($(mytype).val() == "I_APH2")
  {
    $("#arbo1").remove();
    $("#man").remove();
    $("#mus").remove();
    $("#pays").remove();
    myinput.attr('readonly','readonly');
    $.getJSON('get_arbre.php?id=arbo2&lang='+lang+'&mode='+mode, {},
      function(json) {
        $("body").append(json['div']);
        $("#matieres2").Treeview({ animated: "fast", collapsed: true });
      	pos = myinput.offset();
	      posleft = pos.left - 5;
	      postop = pos.top +  myinput.height() + 10;
	      $("#arbo2").css('left',posleft);
	      $("#arbo2").css('top',postop);
      }
    );
	  myinputDestArbo.val('motscles'+num);
	  $(mytype).children("option[value='I_MAN']").addClass("none");
	  $(mytype).children("option[value='I_MUS']").addClass("none");
	  $(mytype).children("option[value='I_PAYS']").addClass("none");
	  $(mytype).children("option[value='I_MEL']").addClass("none");
	  $(mytype).children("option[value='I_PER']").addClass("none");
  }
  else if ($(mytype).val() == "I_MAN")
  {
    $("#arbo1").remove();
    $("#arbo2").remove();
    $("#mus").remove();
    $("#pays").remove();
    myinput.attr('readonly','readonly');
    $.getJSON('get_arbre.php?id=man&lang='+lang+'&mode='+mode, {},
      function(json) {
        $("body").append(json['div']);
		    $("#manuscrits1").Treeview({ animated: "fast", collapsed: true });
		    $("#manuscrits2").Treeview({ animated: "fast", collapsed: true });
		    $("#manuscrits3").Treeview({ animated: "fast", collapsed: true });
      	pos = myinput.offset();
	      posleft = pos.left - 5;
	      postop = pos.top +  myinput.height() + 10;
	      $("#man").css('left',posleft);
	      $("#man").css('top',postop);
      }
    );
	  myinputDestArbo.val('motscles'+num);
	  $(mytype).children("option[value='I_MAN']").removeClass("none");
	  $(mytype).children("option[value='I_MUS']").addClass("none");
	  $(mytype).children("option[value='I_PAYS']").addClass("none");
	  $(mytype).children("option[value='I_MEL']").addClass("none");
	  $(mytype).children("option[value='I_PER']").addClass("none");
  }
  else if ($(mytype).val() == "I_MUS")
  {
    $("#arbo1").remove();
    $("#arbo2").remove();
    $("#man").remove();
    $("#pays").remove();
    myinput.attr('readonly','readonly');
    $.getJSON('get_arbre.php?id=mus&lang='+lang+'&mode='+mode, {},
      function(json) {
        $("body").append(json['div']);
		    $("#musees1").Treeview({ animated: "fast", collapsed: true });
		    $("#musees2").Treeview({ animated: "fast", collapsed: true });
		    $("#musees3").Treeview({ animated: "fast", collapsed: true });
      	pos = myinput.offset();
	      posleft = pos.left - 5;
	      postop = pos.top +  myinput.height() + 10;
	      $("#mus").css('left',posleft);
	      $("#mus").css('top',postop);
      }
    );
	  myinputDestArbo.val('motscles'+num);
	  $(mytype).children("option[value='I_MAN']").addClass("none");
	  $(mytype).children("option[value='I_MUS']").removeClass("none");
	  $(mytype).children("option[value='I_PAYS']").addClass("none");
	  $(mytype).children("option[value='I_MEL']").addClass("none");
	  $(mytype).children("option[value='I_PER']").addClass("none");
  }
  else if ($(mytype).val() == "I_PAYS")
  {
    $("#arbo1").remove();
    $("#arbo2").remove();
    $("#man").remove();
    $("#mus").remove();
    myinput.attr('readonly','readonly');
    $.getJSON('get_arbre.php?id=pays&lang='+lang+'&mode='+mode, {},
      function(json) {
        $("body").append(json['div']);
		    $("#pays1").Treeview({ animated: "fast", collapsed: true });
		    $("#pays2").Treeview({ animated: "fast", collapsed: true });
		    $("#pays3").Treeview({ animated: "fast", collapsed: true });
      	pos = myinput.offset();
	      posleft = pos.left - 5;
	      postop = pos.top +  myinput.height() + 10;
	      $("#pays").css('left',posleft);
	      $("#pays").css('top',postop);
      }
    );
	  myinputDestArbo.val('motscles'+num);
	  $(mytype).children("option[value='I_MAN']").addClass("none");
	  $(mytype).children("option[value='I_MUS']").addClass("none");
	  $(mytype).children("option[value='I_PAYS']").removeClass("none");
	  $(mytype).children("option[value='I_MEL']").addClass("none");
	  $(mytype).children("option[value='I_PER']").addClass("none");
  }
  else if ($(mytype).val() == "I_MEL")
  {
    $("#arbo1").remove();
    $("#arbo2").remove();
    $("#man").remove();
    $("#mus").remove();
    $("#pays").remove();
    myinput.removeAttr('readonly');
	  $(mytype).children("option[value='I_MAN']").addClass("none");
	  $(mytype).children("option[value='I_MUS']").addClass("none");
	  $(mytype).children("option[value='I_PAYS']").addClass("none");
	  $(mytype).children("option[value='I_MEL']").removeClass("none");
	  $(mytype).children("option[value='I_PER']").addClass("none");
  }
  else if ($(mytype).val() == "I_PER")
  {
    $("#arbo1").remove();
    $("#arbo2").remove();
    $("#man").remove();
    $("#mus").remove();
    $("#pays").remove();
    myinput.removeAttr('readonly');
	  $(mytype).children("option[value='I_MAN']").addClass("none");
	  $(mytype).children("option[value='I_MUS']").addClass("none");
	  $(mytype).children("option[value='I_PAYS']").addClass("none");
	  $(mytype).children("option[value='I_MEL']").addClass("none");
	  $(mytype).children("option[value='I_PER']").removeClass("none");
  }
  else
  {
    $("#arbo1").remove();
    $("#arbo2").remove();
    $("#man").remove();
    $("#mus").remove();
    $("#pays").remove();
    myinput.removeAttr('readonly');
	  $(mytype).children("option[value='I_MAN']").addClass("none");
	  $(mytype).children("option[value='I_MUS']").addClass("none");
	  $(mytype).children("option[value='I_PAYS']").addClass("none");
	  $(mytype).children("option[value='I_MEL']").addClass("none");
	  $(mytype).children("option[value='I_PER']").addClass("none");
	}
}

function inputInit(myinput, lang, mode)
{
  var input_id = ($(myinput).attr('id'));
  var num = input_id.substr(8); // motscles
  var mytype = $("#type"+num);
  var myinputHidden = $("#hiddenmotscles"+num);
  var myinputDestArbo = $("#dest_arbo");
  var pos, posleft, postop;

  myinputHidden.val('');
  
  if ( acResultsDiv != null )
    clearAutoComplete();

  $("#arbo1").remove();
  $("#arbo2").remove();
  $("#man").remove();
  $("#mus").remove();
  $("#pays").remove();

  if (mytype.val() == "I_APH1")
  {
    $(myinput).attr('readonly','readonly');
    $.getJSON('get_arbre.php?id=arbo1&lang='+lang+'&mode='+mode, {},
      function(json) {
        $("body").append(json['div']);
        $("#matieres1").Treeview({ animated: "fast", collapsed: true });
      	pos = $(myinput).offset();
	      posleft = pos.left - 5;
	      postop = pos.top +  $(myinput).height() + 10;
	      $("#arbo1").css('left',posleft);
	      $("#arbo1").css('top',postop);
      }
    );
	  myinputDestArbo.val('motscles'+num);
  }
  else if (mytype.val() == "I_APH2")
  {
    $(myinput).attr('readonly','readonly');
    $.getJSON('get_arbre.php?id=arbo2&lang='+lang+'&mode='+mode, {},
      function(json) {
        $("body").append(json['div']);
        $("#matieres2").Treeview({ animated: "fast", collapsed: true });
      	pos = $(myinput).offset();
	      posleft = pos.left - 5;
	      postop = pos.top +  $(myinput).height() + 10;
	      $("#arbo2").css('left',posleft);
	      $("#arbo2").css('top',postop);
      }
    );
	  myinputDestArbo.val('motscles'+num);
  }
  else if (mytype.val() == "I_MAN")
  {
    $(myinput).attr('readonly','readonly');
    $.getJSON('get_arbre.php?id=man&lang='+lang+'&mode='+mode, {},
      function(json) {
        $("body").append(json['div']);
        $("#manuscrits1").Treeview({ animated: "fast", collapsed: true });
        $("#manuscrits2").Treeview({ animated: "fast", collapsed: true });
        $("#manuscrits3").Treeview({ animated: "fast", collapsed: true });
      	pos = $(myinput).offset();
	      posleft = pos.left - 5;
	      postop = pos.top +  $(myinput).height() + 10;
	      $("#man").css('left',posleft);
	      $("#man").css('top',postop);
      }
    );
	  myinputDestArbo.val('motscles'+num);
  }
  else if (mytype.val() == "I_MUS")
  {
    $(myinput).attr('readonly','readonly');
    $.getJSON('get_arbre.php?id=mus&lang='+lang+'&mode='+mode, {},
      function(json) {
        $("body").append(json['div']);
        $("#musees1").Treeview({ animated: "fast", collapsed: true });
        $("#musees2").Treeview({ animated: "fast", collapsed: true });
        $("#musees3").Treeview({ animated: "fast", collapsed: true });
      	pos = $(myinput).offset();
	      posleft = pos.left - 5;
	      postop = pos.top +  $(myinput).height() + 10;
	      $("#mus").css('left',posleft);
	      $("#mus").css('top',postop);
      }
    );
	  myinputDestArbo.val('motscles'+num);
  }
  else if (mytype.val() == "I_PAYS")
  {
    $(myinput).attr('readonly','readonly');
    $.getJSON('get_arbre.php?id=pays&lang='+lang+'&mode='+mode, {},
      function(json) {
        $("body").append(json['div']);
        $("#pays1").Treeview({ animated: "fast", collapsed: true });
        $("#pays2").Treeview({ animated: "fast", collapsed: true });
        $("#pays3").Treeview({ animated: "fast", collapsed: true });
      	pos = $(myinput).offset();
	      posleft = pos.left - 5;
	      postop = pos.top +  $(myinput).height() + 10;
	      $("#pays").css('left',posleft);
	      $("#pays").css('top',postop);
      }
    );
	  myinputDestArbo.val('motscles'+num);
  }
  else
  {
    $(myinput).removeAttr('readonly');
	}

  setAutoComplete(input_id, "results", "autocomplete.php?type="+mytype.val()+"&start=","type_rech");
}

function setCritere(critere, lang, mode)
{
  var num = $("#dest_arbo").val().substr(8); // motscles

  switch(critere)
  {
    case 'C_MANUSCRIT' :
      $("#type"+num).val("I_MAN");
      break;
    case 'C_MUSEE' :
      $("#type"+num).val("I_MUS");
      break;
    case 'C_PAYS' :
      $("#type"+num).val("I_PAYS");
      break;
    case 'C_MELANGE' :
      $("#type"+num).val("I_MEL");
      break;
    case 'C_PERSONALIA' :
      $("#type"+num).val("I_PER");
      break;
  }
  inputRaz($("#type"+num), lang, mode);
}

function prepareSelection()
{
  if (($("#type_0").val()=="I_AUT")||($("#type_0").val()=="I_TXT")||($("#type_0").val()=="I_MEL")||($("#type_0").val()=="I_PER"))
  {
    copyValues();
  }
  if ($("#type_0").val()=="I_APH1")
  {
    copyTrees('arbo1');
  }
  if ($("#type_0").val()=="I_APH2")
  {
    copyTrees('arbo2');
  }
  if ($("#type_0").val()=="I_MAN")
  {
    copyTrees('man');
  }
  if ($("#type_0").val()=="I_MUS")
  {
    copyTrees('mus');
  }
  if ($("#type_0").val()=="I_PAYS")
  {
    copyTrees('pays');
  }
}

function plus(obj)
{
  var original = $(obj).parent();
  var original_id = original.attr('id');
  var original_num = original_id.substr(4);

  var duplicate = original.clone();
  var duplicate_num = parseInt(original_num)+1;
  
  if ($(original).attr('class')=='ra_first') // c'est le premier
  {
    $(duplicate).attr('class','ra_sup ra_last');
    $(duplicate).children("#divop").attr('style','visibility: visible;');
    $(duplicate).children("#moins").attr('style','display: block;');
  }
  else
  {
    $(original).attr('class','ra_sup');
  }
  $(obj).remove();

  $(duplicate).attr('id','div_'+duplicate_num);
  $(duplicate).children("#divop").children("#op_"+original_num).attr('name','op_'+duplicate_num);
  $(duplicate).children("#divop").children("#op_"+original_num).val('AND');
  $(duplicate).children("#divop").children("#op_"+original_num).attr('id','op_'+duplicate_num);
  $(duplicate).children("#type_"+original_num).attr('name','type_'+duplicate_num);  
  $(duplicate).children("#type_"+original_num).val('I_AUT');  
  $(duplicate).children("#type_"+original_num).attr('id','type_'+duplicate_num);  
  $(duplicate).children("#motscles_"+original_num).attr('name','motscles_'+duplicate_num);  
  $(duplicate).children("#motscles_"+original_num).val('');  
  $(duplicate).children("#motscles_"+original_num).attr('id','motscles_'+duplicate_num);  
  $(duplicate).children("#hiddenmotscles_"+original_num).attr('name','hiddenmotscles_'+duplicate_num);  
  $(duplicate).children("#hiddenmotscles_"+original_num).val('');  
  $(duplicate).children("#hiddenmotscles_"+original_num).attr('id','hiddenmotscles_'+duplicate_num);  
  $(duplicate).insertAfter($("#"+original_id));
  
  return false;
}

function moins(obj)
{
  var original = $(obj).parent();

  if ($(original).attr('class')=='ra_sup ra_last') // c'est le dernier
  {
    var precedent = $(original).prev();

    if ($(precedent).attr('class')!='ra_first')
    {
      $(precedent).attr('class','ra_sup ra_last');
    }
    var plus = $(obj).next();

    var lastdiv = $(precedent).children('div:last');
    $(plus).insertBefore($(lastdiv));
  }

  $(original).remove();
  
  return false;
}

function wrapFilter(obj)
{
  var filtre = $(obj).parent().parent();
  
  if ($(filtre).attr('class')=='ra_filter_closed')
  {
    $(filtre).attr('class','ra_filter_open');
  }
  else
  {
    $(filtre).attr('class','ra_filter_closed');
  }
}

function setChecks(type)
{
  var nbselect = parseInt($("#nbselect").text());
  var nbnotselect = parseInt($("#nbnotselect").text());
  var nball = parseInt($("#nball").text());
  var nbrep = parseInt($("#nbrep").text());
  var maxnot = parseInt($("#maxnot").text());
  var nbpage = parseInt($("#selectnbnotpage1").val());
  var nbliste = parseInt($("#inputnbliste").val());
  if (type=="all")
  {
    $("#resetcheck").attr("value", 1);
    $("#checkall").attr("value", 1);
    $(":checkbox.num").attr("checked", 1);
    nbselect = nbliste;
    nbnotselect = 0;
  }
  if (type=="page")
  {
    $("#checkall").attr("value", 0);
    $(":checkbox.num").attr("checked", 1);
    nbselect = Math.min(nbpage, nbrep);
    nbnotselect = Math.min(nbrep - nbselect, nbliste);
  }
  if (type=="none")
  {
    $("#resetcheck").attr("value", 1);
    $("#checkall").attr("value", 0);
    $(":checkbox.num").attr("checked", 0);
    nbselect = 0;
    nbnotselect = nbliste;
  }
  $("#inputnbselect").attr("value",nbselect);
  $("#inputnbnotselect").attr("value",nbnotselect);
}

function countChecks(obj)
{
  var nbselect = parseInt($("#inputnbselect").val());
  var nbnotselect = parseInt($("#inputnbnotselect").val());
  if ($(obj).is(":checked"))
  {
    nbselect++;
    nbnotselect--;
  }
  else
  {
    nbselect--;
    nbnotselect++;
  }
  $("#inputnbselect").attr("value",nbselect);
  $("#inputnbnotselect").attr("value",nbnotselect);
}

function showPopup(type,maxnot)
{

  var nbselect = parseInt($("#inputnbselect").val());
  var nbnotselect = parseInt($("#inputnbnotselect").val());
  var nbliste = parseInt($("#inputnbliste").val());

  if (nbselect <= maxnot)
  {
    $("#nbselect").text(nbselect);
  }
  else
  {
    $("#nbselect").text("les "+maxnot+" premières");
  }
  if (nbnotselect <= maxnot)
  {
    $("#nbnotselect").text(nbnotselect);
  }
  else
  {
    $("#nbnotselect").text("les "+maxnot+" premières");
  }
  if ( nbliste <= maxnot )
  {
    $("#nball").text(maxnot);
  }
  else
  {
    $("#nball").text("les "+maxnot+" premières");
  }

  $("#popup").attr('style','visibility: visible;');
  $(":radio").attr("checked", 0);
  if (nbselect)
  {
    $("#noticestype1").attr("checked", 1);
  }
  else
  {
    $("#noticestype3").attr("checked", 1);
  }
  
  if (type=="print")
  {
    $("#titprint").attr('style','display: block;');
    $("#titsend").attr('style','display: none;');
    $("#titexport").attr('style','display: none;');
    $("#titsave").attr('style','display: none;');
    $("#titsave_alert").attr('style','display: none;');
    $("#titadd").attr('style','display: none;');
    $("#titremove").attr('style','display: none;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: none;');
    $("#labelalert").attr('style','visibility: hidden;');
    $("#alert").attr('style','visibility: hidden;');
    $("#parna").attr('style','display: none;');
    $("#parsavefull").attr('style','display: none;');
    $("#paraddfull").attr('style','display: none;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: block;');
    $("#choicesend").attr('style','display: none;');
    $("#choiceexport").attr('style','display: none;');
    $("#choiceadd").attr('style','display: none;');
    $("#choiceremove").attr('style','display: none;');
    $("#select").attr('style','display: block;');
    $("#format").attr('style','display: none;');
    $("#noticesformat4").attr('style','visibility: hidden;');
    $("#labelnoticesformat4").attr('style','visibility: hidden;');
    $("#email").attr('style','display: none;');
    $("#btnprint").attr('style','display: block; float: right;');
    $("#btnsend").attr('style','display: none; float: right;');
    $("#btnexport").attr('style','display: none; float: right;');
    $("#btnsaveRechAlert").attr('style','display: none; float: right;');
    $("#btnsaveRech").attr('style','display: none; float: right;');
    $("#btnsaveAlert").attr('style','display: none; float: right;');
    $("#btnadd").attr('style','display: none; float: right;');
    $("#btnremove").attr('style','display: none; float: right;');
    $("#btncancel").attr('style','display: block;');
    $("#btnclose").attr('style','display: none;');
    $("#formliste").removeAttr('onsubmit');
  }
  if (type=="send")
  {
    $("#titprint").attr('style','display: none;');
    $("#titsend").attr('style','display: block;');
    $("#titexport").attr('style','display: none;');
    $("#titsave").attr('style','display: none;');
    $("#titsave_alert").attr('style','display: none;');
    $("#titadd").attr('style','display: none;');
    $("#titremove").attr('style','display: none;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: none;');
    $("#labelalert").attr('style','visibility: hidden;');
    $("#alert").attr('style','visibility: hidden;');
    $("#paraddfull").attr('style','display: none;');
    $("#parna").attr('style','display: none;');
    $("#parsavefull").attr('style','display: none;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: none;');
    $("#choicesend").attr('style','display: block;');
    $("#choiceexport").attr('style','display: none;');
    $("#choiceadd").attr('style','display: none;');
    $("#choiceremove").attr('style','display: none;');
    $("#select").attr('style','display: block;');
    $("#format").attr('style','display: block;');
    $("#formatsend").attr('style','display: block;');
    $("#formatexport").attr('style','display: none;');
    $("#noticesformat4").attr('style','visibility: hidden;');
    $("#labelnoticesformat4").attr('style','visibility: hidden;');
    $("#email").attr('style','display: block;');
    $("#btnprint").attr('style','display: none; float: right;');
    $("#btnsend").attr('style','display: block; float: right;');
    $("#btnexport").attr('style','display: none; float: right;');
    $("#btnsaveRechAlert").attr('style','display: none; float: right;');
    $("#btnsaveRech").attr('style','display: none; float: right;');
    $("#btnsaveAlert").attr('style','display: none; float: right;');
    $("#btnadd").attr('style','display: none; float: right;');
    $("#btnremove").attr('style','display: none; float: right;');
    $("#btncancel").attr('style','display: block;');
    $("#btnclose").attr('style','display: none;');
    $("#formliste").removeAttr('onsubmit');
  }
  if (type=="export")
  {
    $("#titprint").attr('style','display: none;');
    $("#titsend").attr('style','display: none;');
    $("#titexport").attr('style','display: block;');
    $("#titsave").attr('style','display: none;');
    $("#titsave_alert").attr('style','display: none;');
    $("#titadd").attr('style','display: none;');
    $("#titremove").attr('style','display: none;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: none;');
    $("#labelalert").attr('style','visibility: hidden;');
    $("#alert").attr('style','visibility: hidden;');
    $("#parna").attr('style','display: none;');
    $("#parsavefull").attr('style','display: none;');
    $("#paraddfull").attr('style','display: none;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: none;');
    $("#choicesend").attr('style','display: none;');
    $("#choiceexport").attr('style','display: block;');
    $("#choiceadd").attr('style','display: none;');
    $("#choiceremove").attr('style','display: none;');
    $("#select").attr('style','display: block;');
    $("#format").attr('style','display: block;');
    $("#formatsend").attr('style','display: none;');
    $("#formatexport").attr('style','display: block;');
    $("#noticesformat4").attr('style','visibility: visible;');
    $("#labelnoticesformat4").attr('style','visibility: visible;');
    $("#email").attr('style','display: none;');
    $("#btnprint").attr('style','display: none; float: right;');
    $("#btnsend").attr('style','display: none; float: right;');
    $("#btnexport").attr('style','display: block; float: right;');
    $("#btnsaveRechAlert").attr('style','display: none; float: right;');
    $("#btnsaveRech").attr('style','display: none; float: right;');
    $("#btnsaveAlert").attr('style','display: none; float: right;');
    $("#btnadd").attr('style','display: none; float: right;');
    $("#btnremove").attr('style','display: none; float: right;');
    $("#btncancel").attr('style','display: block;');
    $("#btnclose").attr('style','display: none;');
    $("#formliste").removeAttr('onsubmit');
  }
  if (type=="saveRechAlert")
  {
    $("#titprint").attr('style','display: none;');
    $("#titsend").attr('style','display: none;');
    $("#titexport").attr('style','display: none;');
    $("#titsave").attr('style','display: block;');
    $("#titsave_alert").attr('style','display: none;');
    $("#titadd").attr('style','display: none;');
    $("#titremove").attr('style','display: none;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: block;');
    $("#labelalert").attr('style','visibility: visible;');
    $("#alert").attr('style','visibility: visible;');
    $("#parna").attr('style','display: none;');
    $("#parsavefull").attr('style','display: none;');
    $("#paraddfull").attr('style','display: none;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: none;');
    $("#choicesend").attr('style','display: none;');
    $("#choiceexport").attr('style','display: none;');
    $("#choiceadd").attr('style','display: none;');
    $("#choiceremove").attr('style','display: none;');
    $("#select").attr('style','display: none;');
    $("#format").attr('style','display: none;');
    $("#formatsend").attr('style','display: none;');
    $("#formatexport").attr('style','display: none;');
    $("#noticesformat4").attr('style','visibility: hidden;');
    $("#labelnoticesformat4").attr('style','visibility: hidden;');
    $("#email").attr('style','display: none;');
    $("#btnprint").attr('style','display: none; float: right;');
    $("#btnsend").attr('style','display: none; float: right;');
    $("#btnexport").attr('style','display: none; float: right;');
    $("#btnsaveRechAlert").attr('style','display: block; float: right;');
    $("#btnsaveRech").attr('style','display: none; float: right;');
    $("#btnsaveAlert").attr('style','display: none; float: right;');
    $("#btnadd").attr('style','display: none; float: right;');
    $("#btnremove").attr('style','display: none; float: right;');
    $("#btncancel").attr('style','display: block;');
    $("#btnclose").attr('style','display: none;');
    $("#formliste").removeAttr('onsubmit');
  }
  if (type=="saveRech")
  {
    $("#titprint").attr('style','display: none;');
    $("#titsend").attr('style','display: none;');
    $("#titexport").attr('style','display: none;');
    $("#titsave").attr('style','display: block;');
    $("#titsave_alert").attr('style','display: none;');
    $("#titadd").attr('style','display: none;');
    $("#titremove").attr('style','display: none;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: block;');
    $("#labelalert").attr('style','visibility: hidden;');
    $("#alert").attr('style','visibility: hidden;');
    $("#parna").attr('style','display: none;');
    $("#parsavefull").attr('style','display: none;');
    $("#paraddfull").attr('style','display: none;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: none;');
    $("#choicesend").attr('style','display: none;');
    $("#choiceexport").attr('style','display: none;');
    $("#choiceadd").attr('style','display: none;');
    $("#choiceremove").attr('style','display: none;');
    $("#select").attr('style','display: none;');
    $("#format").attr('style','display: none;');
    $("#formatsend").attr('style','display: none;');
    $("#formatexport").attr('style','display: none;');
    $("#noticesformat4").attr('style','visibility: hidden;');
    $("#labelnoticesformat4").attr('style','visibility: hidden;');
    $("#email").attr('style','display: none;');
    $("#btnprint").attr('style','display: none; float: right;');
    $("#btnsend").attr('style','display: none; float: right;');
    $("#btnexport").attr('style','display: none; float: right;');
    $("#btnsaveRechAlert").attr('style','display: none; float: right;');
    $("#btnsaveRech").attr('style','display: block; float: right;');
    $("#btnsaveAlert").attr('style','display: none; float: right;');
    $("#btnadd").attr('style','display: none; float: right;');
    $("#btnremove").attr('style','display: none; float: right;');
    $("#btncancel").attr('style','display: block;');
    $("#btnclose").attr('style','display: none;');
    $("#formliste").removeAttr('onsubmit');
  }
  if (type=="saveAlert")
  {
    $("#titprint").attr('style','display: none;');
    $("#titsend").attr('style','display: none;');
    $("#titexport").attr('style','display: none;');
    $("#titsave").attr('style','display: none;');
    $("#titsave_alert").attr('style','display: block;');
    $("#titadd").attr('style','display: none;');
    $("#titremove").attr('style','display: none;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: block;');
    $("#labelalert").attr('style','visibility: hidden;');
    $("#alert").attr('style','visibility: hidden;');
    $("#parna").attr('style','display: none;');
    $("#parsavefull").attr('style','display: none;');
    $("#paraddfull").attr('style','display: none;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: none;');
    $("#choicesend").attr('style','display: none;');
    $("#choiceexport").attr('style','display: none;');
    $("#choiceadd").attr('style','display: none;');
    $("#choiceremove").attr('style','display: none;');
    $("#select").attr('style','display: none;');
    $("#format").attr('style','display: none;');
    $("#formatsend").attr('style','display: none;');
    $("#formatexport").attr('style','display: none;');
    $("#noticesformat4").attr('style','visibility: hidden;');
    $("#labelnoticesformat4").attr('style','visibility: hidden;');
    $("#email").attr('style','display: none;');
    $("#btnprint").attr('style','display: none; float: right;');
    $("#btnsend").attr('style','display: none; float: right;');
    $("#btnexport").attr('style','display: none; float: right;');
    $("#btnsaveRechAlert").attr('style','display: none; float: right;');
    $("#btnsaveRech").attr('style','display: none; float: right;');
    $("#btnsaveAlert").attr('style','display: block; float: right;');
    $("#btnadd").attr('style','display: none; float: right;');
    $("#btnremove").attr('style','display: none; float: right;');
    $("#btncancel").attr('style','display: block;');
    $("#btnclose").attr('style','display: none;');
    $("#formliste").removeAttr('onsubmit');
  }
  if (type=="savena")
  {
    $("#titprint").attr('style','display: none;');
    $("#titsend").attr('style','display: none;');
    $("#titexport").attr('style','display: none;');
    $("#titsave").attr('style','display: block;');
    $("#titsave_alert").attr('style','display: none;');
    $("#titadd").attr('style','display: none;');
    $("#titremove").attr('style','display: none;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: none;');
    $("#labelalert").attr('style','visibility: hidden;');
    $("#alert").attr('style','visibility: hidden;');
    $("#parna").attr('style','display: block;');
    $("#parsavefull").attr('style','display: none;');
    $("#paraddfull").attr('style','display: none;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: none;');
    $("#choicesend").attr('style','display: none;');
    $("#choiceexport").attr('style','display: none;');
    $("#choiceadd").attr('style','display: none;');
    $("#choiceremove").attr('style','display: none;');
    $("#select").attr('style','display: none;');
    $("#format").attr('style','display: none;');
    $("#formatsend").attr('style','display: none;');
    $("#formatexport").attr('style','display: none;');
    $("#noticesformat4").attr('style','visibility: hidden;');
    $("#labelnoticesformat4").attr('style','visibility: hidden;');
    $("#email").attr('style','display: none;');
    $("#btnprint").attr('style','display: none; float: right;');
    $("#btnsend").attr('style','display: none; float: right;');
    $("#btnsaveRechAlert").attr('style','display: none; float: right;');
    $("#btnsaveRech").attr('style','display: none; float: right;');
    $("#btnsaveAlert").attr('style','display: none; float: right;');
    $("#btnexport").attr('style','display: none; float: right;');
    $("#btnadd").attr('style','display: none; float: right;');
    $("#btnremove").attr('style','display: none; float: right;');
    $("#btncancel").attr('style','display: none;');
    $("#btnclose").attr('style','display: block;');
    $("#formliste").removeAttr('onsubmit');
  }
  if (type=="savefull")
  {
    $("#titprint").attr('style','display: none;');
    $("#titsend").attr('style','display: none;');
    $("#titexport").attr('style','display: none;');
    $("#titsave").attr('style','display: block;');
    $("#titsave_alert").attr('style','display: none;');
    $("#titadd").attr('style','display: none;');
    $("#titremove").attr('style','display: none;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: none;');
    $("#labelalert").attr('style','visibility: hidden;');
    $("#alert").attr('style','visibility: hidden;');
    $("#parna").attr('style','display: none;');
    $("#parsavefull").attr('style','display: block;');
    $("#paraddfull").attr('style','display: none;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: none;');
    $("#choicesend").attr('style','display: none;');
    $("#choiceexport").attr('style','display: none;');
    $("#choiceadd").attr('style','display: none;');
    $("#choiceremove").attr('style','display: none;');
    $("#select").attr('style','display: none;');
    $("#format").attr('style','display: none;');
    $("#formatsend").attr('style','display: none;');
    $("#formatexport").attr('style','display: none;');
    $("#noticesformat4").attr('style','visibility: hidden;');
    $("#labelnoticesformat4").attr('style','visibility: hidden;');
    $("#email").attr('style','display: none;');
    $("#btnprint").attr('style','display: none; float: right;');
    $("#btnsend").attr('style','display: none; float: right;');
    $("#btnexport").attr('style','display: none; float: right;');
    $("#btnsaveRechAlert").attr('style','display: none; float: right;');
    $("#btnsaveRech").attr('style','display: none; float: right;');
    $("#btnsaveAlert").attr('style','display: none; float: right;');
    $("#btnadd").attr('style','display: none; float: right;');
    $("#btnremove").attr('style','display: none; float: right;');
    $("#btncancel").attr('style','display: none;');
    $("#btnclose").attr('style','display: block;');
    $("#formliste").removeAttr('onsubmit');
  }
  if (type=="add")
  {
    $("#titprint").attr('style','display: none;');
    $("#titsend").attr('style','display: none;');
    $("#titexport").attr('style','display: none;');
    $("#titsave").attr('style','display: none;');
    $("#titsave_alert").attr('style','display: none;');
    $("#titadd").attr('style','display: block;');
    $("#titremove").attr('style','display: none;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: none;');
    $("#labelalert").attr('style','visibility: hidden;');
    $("#alert").attr('style','visibility: hidden;');
    $("#parna").attr('style','display: none;');
    $("#parsavefull").attr('style','display: none;');
    $("#paraddfull").attr('style','display: none;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: none;');
    $("#choicesend").attr('style','display: none;');
    $("#choiceexport").attr('style','display: none;');
    $("#choiceremove").attr('style','display: none;');
    $("#choiceadd").attr('style','display: block;');
    $("#select").attr('style','display: block;');
    $("#format").attr('style','display: none;');
    $("#formatsend").attr('style','display: none;');
    $("#formatexport").attr('style','display: none;');
    $("#noticesformat4").attr('style','visibility: hidden;');
    $("#labelnoticesformat4").attr('style','visibility: hidden;');
    $("#email").attr('style','display: none;');
    $("#btnprint").attr('style','display: none; float: right;');
    $("#btnsend").attr('style','display: none; float: right;');
    $("#btnexport").attr('style','display: none; float: right;');
    $("#btnsaveRechAlert").attr('style','display: none; float: right;');
    $("#btnsaveRech").attr('style','display: none; float: right;');
    $("#btnsaveAlert").attr('style','display: none; float: right;');
    $("#btnadd").attr('style','display: block; float: right;');
    $("#btnremove").attr('style','display: none; float: right;');
    $("#btncancel").attr('style','display: block;');
    $("#btnclose").attr('style','display: none;');
    $("#formliste").removeAttr('onsubmit');
  }
  if (type=="addna")
  {
    $("#titprint").attr('style','display: none;');
    $("#titsend").attr('style','display: none;');
    $("#titexport").attr('style','display: none;');
    $("#titsave").attr('style','display: none;');
    $("#titsave_alert").attr('style','display: none;');
    $("#titadd").attr('style','display: block;');
    $("#titremove").attr('style','display: none;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: none;');
    $("#labelalert").attr('style','visibility: hidden;');
    $("#alert").attr('style','visibility: hidden;');
    $("#parna").attr('style','display: block;');
    $("#parsavefull").attr('style','display: none;');
    $("#paraddfull").attr('style','display: none;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: none;');
    $("#choicesend").attr('style','display: none;');
    $("#choiceexport").attr('style','display: none;');
    $("#choiceadd").attr('style','display: none;');
    $("#choiceremove").attr('style','display: none;');
    $("#select").attr('style','display: none;');
    $("#format").attr('style','display: none;');
    $("#formatsend").attr('style','display: none;');
    $("#formatexport").attr('style','display: none;');
    $("#noticesformat4").attr('style','visibility: hidden;');
    $("#labelnoticesformat4").attr('style','visibility: hidden;');
    $("#email").attr('style','display: none;');
    $("#btnprint").attr('style','display: none; float: right;');
    $("#btnsend").attr('style','display: none; float: right;');
    $("#btnsaveRechAlert").attr('style','display: none; float: right;');
    $("#btnsaveRech").attr('style','display: none; float: right;');
    $("#btnsaveAlert").attr('style','display: none; float: right;');
    $("#btnexport").attr('style','display: none; float: right;');
    $("#btnadd").attr('style','display: none; float: right;');
    $("#btnremove").attr('style','display: none; float: right;');
    $("#btncancel").attr('style','display: none;');
    $("#btnclose").attr('style','display: block;');
    $("#formliste").removeAttr('onsubmit');
  }
  if (type=="addfull")
  {
    $("#titprint").attr('style','display: none;');
    $("#titsend").attr('style','display: none;');
    $("#titexport").attr('style','display: none;');
    $("#titsave").attr('style','display: none;');
    $("#titsave_alert").attr('style','display: none;');
    $("#titadd").attr('style','display: block;');
    $("#titremove").attr('style','display: none;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: none;');
    $("#labelalert").attr('style','visibility: hidden;');
    $("#alert").attr('style','visibility: hidden;');
    $("#parna").attr('style','display: none;');
    $("#parsavefull").attr('style','display: none;');
    $("#paraddfull").attr('style','display: block;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: none;');
    $("#choicesend").attr('style','display: none;');
    $("#choiceexport").attr('style','display: none;');
    $("#choiceadd").attr('style','display: none;');
    $("#choiceremove").attr('style','display: none;');
    $("#select").attr('style','display: none;');
    $("#format").attr('style','display: none;');
    $("#formatsend").attr('style','display: none;');
    $("#formatexport").attr('style','display: none;');
    $("#noticesformat4").attr('style','visibility: hidden;');
    $("#labelnoticesformat4").attr('style','visibility: hidden;');
    $("#email").attr('style','display: none;');
    $("#btnprint").attr('style','display: none; float: right;');
    $("#btnsend").attr('style','display: none; float: right;');
    $("#btnexport").attr('style','display: none; float: right;');
    $("#btnsaveRechAlert").attr('style','display: none; float: right;');
    $("#btnsaveRech").attr('style','display: none; float: right;');
    $("#btnsaveAlert").attr('style','display: none; float: right;');
    $("#btnadd").attr('style','display: none; float: right;');
    $("#btnremove").attr('style','display: none; float: right;');
    $("#btncancel").attr('style','display: none;');
    $("#btnclose").attr('style','display: block;');
    $("#formliste").removeAttr('onsubmit');
  }
  if (type=="remove")
  {
    $("#titprint").attr('style','display: none;');
    $("#titsend").attr('style','display: none;');
    $("#titexport").attr('style','display: none;');
    $("#titsave").attr('style','display: none;');
    $("#titsave_alert").attr('style','display: none;');
    $("#titadd").attr('style','display: none;');
    $("#titremove").attr('style','display: block;');
    $("#titconfirm").attr('style','display: none;');
    $("#parerreur").attr('style','display: none;');
    $("#parsave").attr('style','display: none;');
    $("#labelalert").attr('style','visibility: hidden;');
    $("#alert").attr('style','visibility: hidden;');
    $("#parna").attr('style','display: none;');
    $("#parsavefull").attr('style','display: none;');
    $("#paraddfull").attr('style','display: none;');
    $("#parconfirm").attr('style','display: none;');
    $("#parconfirmSRA").attr('style','display: none;');
    $("#parconfirmSR").attr('style','display: none;');
    $("#parconfirmSA").attr('style','display: none;');
    $("#parconfirmA").attr('style','display: none;');
    $("#parconfirmR").attr('style','display: none;');
    $("#choiceprint").attr('style','display: none;');
    $("#choicesend").attr('style','display: none;');
    $("#choiceexport").attr('style','display: none;');
    $("#choiceadd").attr('style','display: none;');
    $("#choiceremove").attr('style','display: block;');
    $("#select").attr('style','display: block;');
    $("#format").attr('style','display: none;');
    $("#formatsend").attr('style','display: none;');
    $("#formatexport").attr('style','display: none;');
    $("#noticesformat4").attr('style','visibility: hidden;');
    $("#labelnoticesformat4").attr('style','visibility: hidden;');
    $("#email").attr('style','display: none;');
    $("#btnprint").attr('style','display: none; float: right;');
    $("#btnsend").attr('style','display: none; float: right;');
    $("#btnexport").attr('style','display: none; float: right;');
    $("#btnsaveRechAlert").attr('style','display: none; float: right;');
    $("#btnsaveRech").attr('style','display: none; float: right;');
    $("#btnsaveAlert").attr('style','display: none; float: right;');
    $("#btnadd").attr('style','display: none; float: right;');
    $("#btnremove").attr('style','display: block; float: right;');
    $("#btncancel").attr('style','display: block;');
    $("#btnclose").attr('style','display: none;');
    $("#formliste").attr('onsubmit',"return confirm('Êtes-vous sûr ?');");
  }

  return false;
}

function hidePopup(type)
{
  $("#popup").attr('style','visibility: hidden;');
  $("#noticesformat4").attr('style','visibility: hidden;');
  $("#labelnoticesformat4").attr('style','visibility: hidden;');
  $("#labelalert").attr('style','visibility: hidden;');
  $("#alert").attr('style','visibility: hidden;');
  if ( type == 'confirmationR' )
    window.location = "index.php?do=mesNotices";

  return false;
}

function hideErrorNav()
{
  $("#errornav").attr('style','visibility: hidden;');
}

function hideErrorSearch()
{
  $("#errorsearch").attr('style','visibility: hidden;');
}

function formRaz()
{
  var divArboAph1 = document.getElementById("arbo1");
  var divArboAph2 = document.getElementById("arbo2");

  $(":hidden.motscles").attr('value','');
  $(":text.motscles").attr('value','');
  $(":text.rech").attr('value','');
  $("option.rech").attr('selected',0);
  $(":checkbox").attr('checked',0);
  $(":radio").attr('checked',0);

  if ( acResultsDiv != null )
    clearAutoComplete();
  
  divArboAph1.style.visibility="hidden";
  divArboAph2.style.visibility="hidden";
  
  return false;
}

function setTarget(form, type)
{
  if (type=="export")
  {
    $(form).attr('target','_blank');
  }
  else
  {
    $(form).attr('target','_self');
  }
}

function setChecksSearchs(type)
{
  if (type=="all")
  {
    $(":checkbox.mrech").attr("checked", 1);
  }
  if (type=="none")
  {
    $(":checkbox.mrech").attr("checked", 0);
  }
}

function setChecksAlerts(type)
{
  if (type=="all")
  {
    $(":checkbox.malert").attr("checked", 1);
  }
  if (type=="none")
  {
    $(":checkbox.malert").attr("checked", 0);
  }
}

function setChecksNotices(type)
{
  if (type=="all")
  {
    $(":checkbox.mnot").attr("checked", 1);
    $("#checkallnot").attr("value", 1);
  }
  if (type=="none")
  {
    $(":checkbox.mnot").attr("checked", 0);
    $("#checkallnot").attr("value", 0);
  }
}

function setSelect(num,value)
{
  $("#selectnbnotpage"+num).attr("value", value);
  $("#inputpage1").attr("value", "1");
  $("#inputpage2").attr("value", "1");
  $("#formliste").submit();
}

function setInput(num,value)
{
  $("#inputpage"+num).attr("value", value);
}

function addOperand(obj)
{
  $("#motsclesHisto").val($("#motsclesHisto").val()+" "+$(obj).text()+" ");
  $("#motsclesHisto").focus();
}

function saveChecks()
{
  $("#formliste").submit();
  var date = new Date();
  var curDate = null;

  do { curDate = new Date(); } 
  while(curDate-date < 200);
}


