$(document).ready(function() {
  $('ul.secteur_liste').hide();
  var adresseUrl = window.location.search;
  var secteur_id =  adresseUrl.substring(13,14);
  var tab_secteur = eval(secteur_id-1);
  
  $('ul.secteur_liste:eq('+tab_secteur+')').show(); //Faire passer la variable pour montrer le bon bloc
  $('img.btn_secteur').click(function() { 
	$(this).next('ul').slideToggle('800')
	.siblings('ul:visible').slideUp('800');
});
/* MOTEUR DE RECHERCHE FR */
  $('#moteur_recherche').hide();
  $('.btn_moteur').click(function() { 
    $('#moteur_recherche').slideToggle('800');
  });
  	$('.btn_moteur').toggle(
    function () {
      $(this).attr("src", "templates/defaut/images/btn_close_moteur.jpg");
      },
      function () {
     $(this).attr("src", "templates/defaut/images/btn_open_moteur.jpg");
      }
    );
/* MOTEUR DE RECHERCHE EN */
  $('#moteur_recherche').hide();
  $('.btn_moteur_en').click(function() { 
    $('#moteur_recherche').slideToggle('800');
  });
  	$('.btn_moteur_en').toggle(
    function () {
      $(this).attr("src", "templates/defaut/images/btn_close_moteur_en.jpg");
      },
      function () {
     $(this).attr("src", "templates/defaut/images/btn_open_moteur_en.jpg");
      }
    );
    
/* MOTEUR DE RECHERCHE ES */
  $('#moteur_recherche').hide();
  $('.btn_moteur_es').click(function() { 
    $('#moteur_recherche').slideToggle('800');
  });
  	$('.btn_moteur_es').toggle(
    function () {
      $(this).attr("src", "templates/defaut/images/btn_close_moteur_es.jpg");
      },
      function () {
     $(this).attr("src", "templates/defaut/images/btn_open_moteur_es.jpg");
      }
    );
/**** PAGE DOCUMENTATION *****/
/* MOTEUR DE RECHERCHE FR OPEN */
  $('.btn_moteur_doc_open').click(function() { 
    $('#moteur_recherche_open').slideToggle('800');
  });
  	$('.btn_moteur_doc_open').toggle(
    function () {
      $(this).attr("src", "templates/defaut/images/btn_open_moteur.jpg");
      },
      function () {
     $(this).attr("src", "templates/defaut/images/btn_close_moteur.jpg");
      }
    );
/* MOTEUR DE RECHERCHE EN OPEN */
  $('.btn_moteur_doc_open_en').click(function() { 
    $('#moteur_recherche_open').slideToggle('800');
  });
  	$('.btn_moteur_doc_open_en').toggle(
    function () {
      $(this).attr("src", "templates/defaut/images/btn_open_moteur_en.jpg");
      },
      function () {
     $(this).attr("src", "templates/defaut/images/btn_close_moteur_en.jpg");
      }
    );
    
/* MOTEUR DE RECHERCHE ES OPEN */
  $('.btn_moteur_doc_open_es').click(function() { 
    $('#moteur_recherche_open').slideToggle('800');
  });
  	$('.btn_moteur_doc_open_es').toggle(
    function () {
      $(this).attr("src", "templates/defaut/images/btn_open_moteur_es.jpg");
      },
      function () {
     $(this).attr("src", "templates/defaut/images/btn_close_moteur_es.jpg");
      }
    ); 
    
/* MOTEUR DE RECHERCHE FR CLOSE */
  $('#moteur_recherche_close').hide();
  $('.btn_moteur_doc_close').click(function() { 
    $('#moteur_recherche_close').slideToggle('800');
  });
  	$('.btn_moteur_doc_close').toggle(
    function () {
      $(this).attr("src", "templates/defaut/images/btn_close_moteur.jpg");
      },
      function () {
     $(this).attr("src", "templates/defaut/images/btn_open_moteur.jpg");
      }
    );
/* MOTEUR DE RECHERCHE EN CLOSE */
  $('.btn_moteur_doc_close_en').click(function() { 
    $('#moteur_recherche_close').slideToggle('800');
  });
  	$('.btn_moteur_doc_close_en').toggle(
    function () {
      $(this).attr("src", "templates/defaut/images/btn_close_moteur_en.jpg");
      },
      function () {
     $(this).attr("src", "templates/defaut/images/btn_open_moteur_en.jpg");
      }
    );
    
/* MOTEUR DE RECHERCHE  ES CLOSE */
  $('.btn_moteur_doc_close_es').click(function() { 
    $('#moteur_recherche_close').slideToggle('800');
  });
  	$('.btn_moteur_doc_close_es').toggle(
    function () {
      $(this).attr("src", "templates/defaut/images/btn_close_moteur_es.jpg");
      },
      function () {
     $(this).attr("src", "templates/defaut/images/btn_open_moteur_es.jpg");
      }
    ); 
  /* INPUT RECHERCHE FREETEXT */
  $('.freetext').click(function() { 
     $(this).attr("value","");  
  }); 
  /* MENU DEROULANT */
  var menuOn = $('li.menuon');
  var sousmenuOn = $('li.menuon> ul.sousmenu');

  $('ul.sousmenu').hide();
  $('li.menuon> ul.sousmenu').show();
  $('ul#menu> li').hover(
  function() {
  menuOn.attr('class','');
  sousmenuOn.hide();
  $(this).children('ul').show();
  },
  function() {
   $('ul.sousmenu').hide();
   menuOn.attr('class','menuon');
   sousmenuOn.show();
  });

});
