$(document).ready(function() {
var ean=$("#ean").val();
var id=$("#pid").val();

$(".similaire").show();
$(".similaire").click(function() 
{
	var pos=$(this).offset();
var pid=$(this).attr('id');

 $.ajax({
        type: "POST",
		url: "includes/ajaxproduct.php",
		data: "ean="+ean+"&id="+pid,
        dataType: "text",
         beforeSend: function(){
        $("#ajaxproduct").html("<img src='images/loading.gif'/>");
        $("#ajaxproduct").css('top',pos.top+25);
		 $("#ajaxproduct").css('left',pos.left-120);
         $("#ajaxproduct").show(); 
        
    },
         success: function(text){
         $("#ajaxproduct").html(text);
		
		 fermer();
        return false;  
     },
		error: function (XMLHttpRequest, textStatus, errorThrown) {
		  alert ('Erreur ' + textStatus + ' ' + errorThrown);
		}
    });
  return false;  
});
$("#grand_content").click(function() 
{
	 $("#ajaxproduct").hide();
});
 

	$("#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();
    });
   
});
$("img").lazyload({
             placeholder : "img/grey.gif",
             effect      : "fadeIn"
          });
});
function suggest(a) {
$("#rform1").val(a); 
return false;
}
function go(){
if ($("#rform1").val()=="") return false;
}
function fermer(){
$("#fermer").click(function(){
	 $("#ajaxproduct").hide();
	 return false;
	 
});
$("#tableajax tr").hover(
  function () {
$(this).addClass('active');
  }, 
  function () {
  $(this).removeClass('active');
  }
);
	}
	
	
	
