$(document).ready(function() {
	
	var position_element = 0;
	
    //donne une taille à chaque blocmenu pour bug ie7
    var tailleDivGamme1 = $("li.gamme1 div.boxGamme").innerHeight();
    var tailleDivGamme2 = $("li.gamme2 div.boxGamme").innerHeight();
    var tailleDivGamme3 = $("li.gamme3 div.boxGamme").innerHeight();
    var tailleDivGamme4 = $("li.gamme4 div.boxGamme").innerHeight();
    var tailleDivGamme5 = $("li.gamme5 div.boxGamme").innerHeight();
    $("li.gamme1 div.boxGamme").height(tailleDivGamme1);
    $("li.gamme1 div.boxGamme ul.categorie").height(tailleDivGamme1);
    $("li.gamme2 div.boxGamme").height(tailleDivGamme2);
    $("li.gamme3 div.boxGamme").height(tailleDivGamme3);
    $("li.gamme4 div.boxGamme").height(tailleDivGamme4);
    $("li.gamme5 div.boxGamme").height(tailleDivGamme5);
    //cache le menu des motos
    $("div.boxGamme").css("display", "none");
    // $("div.motoImage").css("display", "none");
    $("div.motoBas").css("display", "none");
    $("ul li.categorie").css("display", "none");
    $("ul li.mod1").find("div.motoImage").css("display", "block");

    //animation pour le menu des motos
    $("div#GammeMotos ul li.gamme").hover(

	function() {
	    // empeche la repetition d'animations
	    if ($(this).children("div.boxGamme").is(':animated')) {
		
	    } else {
			position_element = $(this).index("li.gamme");
			position_element++;
			$("li.gamme"+position_element).find("ul li.categorie").eq(0).show();
			$("div.motoImage").hide();
			$("ul li.mod1").find("div.motoImage").show();
	        $(this).children("div.boxGamme").slideDown('slow',function(){
			
				// $("li.gamme"+position_element).find("ul li.categorie").eq(0).fadeIn('fast',function(){
					$("li.gamme"+position_element).find("ul li.categorie").eq(1).fadeIn('fast',function(){
						$("li.gamme"+position_element).find("ul li.categorie").eq(2).fadeIn('fast',function(){
							$("li.gamme"+position_element).find("ul li.categorie").eq(3).fadeIn('fast',function(){
								$("li.gamme"+position_element).find("ul li.categorie").eq(4).fadeIn('fast');
							});
						});
					});
				// });
			
			});
	    }
	},

	function() {
		$("div.boxGamme").stop(true,true);
	    $(this).children("div.boxGamme").slideUp(function(){
		
			$(this).find("div.motoImage").css("display", "none");
			$(this).find("ul li.categorie").hide();
		
		});
	    
	}

	);

    //animation pour les modele des motos
    $("li.cat1 ul li.modele a").hover(

	function() {
	    //empeche la repetition d'animations
	    if ($(this).is(':animated')) {

	    } else {
	        $(this).animate({ "padding-right": "10px" }, "fast");
	        // $("div.imgOpen1").fadeOut("fast");
	        $("div.imgOpen1").hide();
	        $("div.imgOpen1").removeClass("imgOpen1");
	        $(this).next().addClass("imgOpen1");
	        // $(this).next().fadeIn("slow");
	        $(this).next().show();
	    }
	},

	function() {
	    $(this).animate({ "padding-right": "0" }, "fast");
	    /*$(this).next().fadeOut("fast");*/
	}

	);

    //animation pour les modele des motos
    $("li.cat2 ul li.modele a").hover(

	function() {
	    //empeche la repetition d'animations
	    if ($(this).is(':animated')) {

	    } else {
	        $(this).animate({ "padding-right": "10px" }, "fast");
	        // $("div.imgOpen2").fadeOut("fast");
	        $("div.imgOpen2").hide();
	        $("div.imgOpen2").removeClass("imgOpen2");
	        $(this).next().addClass("imgOpen2");
	        // $(this).next().fadeIn("slow");
	        $(this).next().show();
	    }
	},

	function() {
	    $(this).animate({ "padding-right": "0" }, "fast");
	    /*$(this).next().fadeOut("fast");*/
	}

	);

    //animation pour les modele des motos
    $("li.cat3 ul li.modele a").hover(

	function() {
	    //empeche la repetition d'animations
	    if ($(this).is(':animated')) {

	    } else {
	        $(this).animate({ "padding-right": "10px" }, "fast");
	        // $("div.imgOpen3").fadeOut("fast");
	        $("div.imgOpen3").hide();
	        $("div.imgOpen3").removeClass("imgOpen3");
	        $(this).next().addClass("imgOpen3");
	        // $(this).next().fadeIn("slow");
	        $(this).next().show();
	    }
	},

	function() {
	    $(this).animate({ "padding-right": "0" }, "fast");
	    /*$(this).next().fadeOut("fast");*/
	}

	);

    //animation pour les modele des motos
    $("li.cat4 ul li.modele a").hover(

	function() {
	    //empeche la repetition d'animations
	    if ($(this).is(':animated')) {

	    } else {
	        $(this).animate({ "padding-right": "10px" }, "fast");
	        // $("div.imgOpen4").fadeOut("fast");
	        $("div.imgOpen4").hide();
	        $("div.imgOpen4").removeClass("imgOpen4");
	        $(this).next().addClass("imgOpen4");
	        // $(this).next().fadeIn("slow");
	        $(this).next().show();
	    }
	},

	function() {
	    $(this).animate({ "padding-right": "0" }, "fast");
	    /*$(this).next().fadeOut("fast");*/
	}

	);

    //animation pour les modele des motos
    $("li.cat5 ul li.modele a").hover(

	function() {
	    //empeche la repetition d'animations
	    if ($(this).is(':animated')) {

	    } else {
	        $(this).animate({ "padding-right": "10px" }, "fast");
	        // $("div.imgOpen5").fadeOut("fast");
	        $("div.imgOpen5").hide();
	        $("div.imgOpen5").removeClass("imgOpen5");
	        $(this).next().addClass("imgOpen5");
	        // $(this).next().fadeIn("slow");
	        $(this).next().show();
	    }
	},

	function() {
	    $(this).animate({ "padding-right": "0" }, "fast");
	    /*$(this).next().fadeOut("fast");*/
	}

	);

    //animation pour les modele des motos
    $("li.cat6 ul li.modele a").hover(

	function() {
	    //empeche la repetition d'animations
	    if ($(this).is(':animated')) {

	    } else {
	        $(this).animate({ "padding-right": "10px" }, "fast");
	        // $("div.imgOpen6").fadeOut("fast");
	        $("div.imgOpen6").hide();
	        $("div.imgOpen6").removeClass("imgOpen6");
	        $(this).next().addClass("imgOpen6");
	        // $(this).next().fadeIn("slow");
	        $(this).next().show();
	    }
	},

	function() {
	    $(this).animate({ "padding-right": "0" }, "fast");
	    /*$(this).next().fadeOut("fast");*/
	}

	);

    //animation pour les modele des motos
    $("li.cat7 ul li.modele a").hover(

	function() {
	    //empeche la repetition d'animations
	    if ($(this).is(':animated')) {

	    } else {
	        $(this).animate({ "padding-right": "10px" }, "fast");
	        // $("div.imgOpen7").fadeOut("fast");
	        $("div.imgOpen7").hide();
	        $("div.imgOpen7").removeClass("imgOpen7");
	        $(this).next().addClass("imgOpen7");
	        // $(this).next().fadeIn("slow");
	        $(this).next().show();
	    }
	},

	function() {
	    $(this).animate({ "padding-right": "0" }, "fast");
	    /*$(this).next().fadeOut("fast");*/
	}

	);

    //animation pour les modele des motos
    $("li.cat8 ul li.modele a").hover(

	function() {
	    //empeche la repetition d'animations
	    if ($(this).is(':animated')) {

	    } else {
	        $(this).animate({ "padding-right": "10px" }, "fast");
	        // $("div.imgOpen8").fadeOut("fast");
	        $("div.imgOpen8").hide();
	        $("div.imgOpen8").removeClass("imgOpen8");
	        $(this).next().addClass("imgOpen8");
	        // $(this).next().fadeIn("slow");
	        $(this).next().show();
	    }
	},

	function() {
	    $(this).animate({ "padding-right": "0" }, "fast");
	    /*$(this).next().fadeOut("fast");*/
	}

	);

    function ajoutClassOpen() {

        $("li.cat1 ul li.mod1").find("div.motoImage").addClass("imgOpen1");
        $("li.cat2 ul li.mod1").find("div.motoImage").addClass("imgOpen2");
        $("li.cat3 ul li.mod1").find("div.motoImage").addClass("imgOpen3");
        $("li.cat4 ul li.mod1").find("div.motoImage").addClass("imgOpen4");
        $("li.cat5 ul li.mod1").find("div.motoImage").addClass("imgOpen5");
        $("li.cat6 ul li.mod1").find("div.motoImage").addClass("imgOpen6");
        $("li.cat7 ul li.mod1").find("div.motoImage").addClass("imgOpen7");
        $("li.cat8 ul li.mod1").find("div.motoImage").addClass("imgOpen8");

    }	

		//animation pour les categories des motos
		$("ul li.categorie").hover(

		function() {
		
			if($.browser.msie && $.browser.version<="8.0") {
		
			} else{
		
				$(this).find("div.motoImage").css({"opacity":"1"});
				$(this).find("span.categorie").css({"opacity":"1"});
			
			}
			
			//empeche la repetition d'animations
			if ($(this).is(':animated')) {

			} else {
				$(this).animate({ "padding-top": "110px" }, "fast");
				$(this).find("div.motoImage").animate({ "top": "-10px" }, "fast");
			}
		},

		function() {
		
			if($.browser.msie && $.browser.version<="8.0") {
		
			} else{
			
				$(this).find("div.motoImage").css({"opacity":"0.5"});
				$(this).find("span.categorie").css({"opacity":"0.5"});
			
			}
			
			ajoutClassOpen();
			$(this).animate({ "padding-top": "120px" }, "fast");
			$(this).find("div.motoImage").animate({ "top": "0" }, "fast");
		}

		);

});
