$(document).ready(function() {
	$("#menu li").hover(
  function () {
    $(this).find(".menu-list").show();
     $("#suggestion").hide();
    $("#top-search").css("z-index","-1");
  }, 
  function () {
    $(this).find(".menu-list").hide();
   $("#top-search").css("z-index","0");
  }
);
$(".modules").hover(
  function () {
   var position = $(this).offset();
 $(this).find(".explication").css("top",position.top-50);
  $(this).find(".explication").show();
  }, 
  function () {
   $(this).find(".explication").hide();
  }
);
$("#rform1").keyup(function() 
{   var search; 
    search = $("#rform1").val(); 
 
    if (search.length > 0) 
    { 
     $.ajax({
        type: "POST",
		url: "includes/suggestion.php",
		data: "search="+search,
        dataType: "text",
        beforeSend: function(){ },
        success: function(text){
		$("#suggestion").empty(); 
		 if (search.length > 0){
        $("#suggestion").html(text);
         $("#suggestion").fadeIn('50');
        }
	
		},
		error: function (XMLHttpRequest, textStatus, errorThrown) {
		 alert ('Erreur ' + textStatus + ' ' + errorThrown);
		}
    });
    } 
    else 
    { $("#suggestion").fadeOut('50');
    $("#suggestion").empty(); 
    } 
    $("#suggestion").mouseleave(function() {
    $("#suggestion").hide();
    });
     $("body").click(function() {
    $("#suggestion").hide();
    });
   
});

});
function suggest(a) {
location.href="index.php?mdl=search&testsearch="+a;
return false;
}
function go(){
if ($("#rform1").val()=="") return false;
}

