/**Fonction s'executant au chargement du document**/
$(document).ready(function(){
  
  $("img").fullsize({shadow: true, iconOffset: 2, extraTrigger: ".myClass", forceTitleBar: true,parentSteps: 2});
  $(".agrandir").fullsize({shadow: true, iconOffset: 0, extraTrigger: ".myClass", forceTitleBar: false,parentSteps: 2});
  $("#recherche-suggestions").hide();
  
  //Gestion du champ recherche
  $("#recherche-input").focus(function(){
    $(this).attr('value','');
  });
  $("#recherche-input").blur(function(){
    if($(this).attr('value')=='') $(this).attr('value','Recherche...');
    $("#recherche-suggestions").hide('normal');
  });   
  
  function clignotement(id,frequence,interval){
    
    option = {};
    
    function pulsate(){
      $("#promo").effect("pulsate",option,frequence,function callback(){});
    }
    
    pulsate();
    
    setInterval(pulsate,interval);
     
  }
  
  clignotement('promo',800,10000);
  $(".onglet_cat").hide();
  
  $("#produits").click(function() {
    $("#produits").hide("drop");
    setTimeout(function() {$(".onglet_cat").show()},400);
  });
  
  $(".actualite").hide();
  $(".actualite").dialog({
    autoOpen: true,
    show: 'slide',
    title: "Actualit&eacute;s :",
    zIndex: 2
  });
  
  //Fonction de recherche
  $("#recherche-input").keyup(function(){
    $.ajax({
      type: "GET",
      url: "includes/scripts/recherche.php",
      data: "recherche="+$("#recherche-input").val(),
      success: function(html){
        $("#recherche-suggestions").show();
        $("#recherche-suggestions").html(html);
        $("span.suggestion").click(function(){
          $("#recherche-input").val($(this).text());
          $("form#recherche-form").submit();
        });
      }
    });
  })

});

function open_info_produits(page,nom,width,height){
  
  var w = window.open(page,nom,"menubar=no, status=no, scrollbars=yes, menubar=no, resizable=no, width="+width+", height="+height);
  w.document.close();
  w.focus();

}