jQuery(document).ready
( function()
  { init_menu_deroulant();
    init_menu_social();
    init_menu_pages();
    init_metiers_menu();
    init_expertises();
  }
);

/* --------------------------------------------------------------------------------
 *                                                                        menus top
 */

function init_menu_deroulant()
{ jQuery("#menu_pages li.premier_niveau").hover
  ( function()
    { jQuery(this).find("ul").first().slideDown(200);
      jQuery(this).find("ul").first().css("zIndex", 200);
    },
    function()
    { jQuery(this).find("ul").first().fadeOut(100);
    }
  );
}

function init_menu_social()
{ jQuery("#menu_social ul  li a").hover
  ( function()
    { jQuery(this).find("img").first().attr("width", "28");
      jQuery(this).find("img").first().attr("height", "28");
      jQuery(this).find("img").first().css("margin", "8px 0 0 3px");
    },
    function()
    { jQuery(this).find("img").first().attr("width", "24");
      jQuery(this).find("img").first().attr("height", "24");
      jQuery(this).find("img").first().css("margin", "10px 0 0 5px");
    }
  );
}

function init_menu_pages()
{ jQuery(".sous_menu_plus").click
  ( function()
    { var display = jQuery(this).parent().find("ul").first().css("display");
      if(display == "block") jQuery(this).parent().find("ul").first().slideUp(200);
      else jQuery(this).parent().find("ul").first().slideDown(200);
   }
  );
  jQuery(".sous_menu_plus").hover
  ( function()
    { jQuery(this).find("img").first().attr("width", "14");
      jQuery(this).find("img").first().attr("height", "13");
	  jQuery(this).find("img").first().css("margin", "-1px 0 0 -1px");
    },
    function()
    { jQuery(this).find("img").first().attr("width", "12");
      jQuery(this).find("img").first().attr("height", "11");
	  jQuery(this).find("img").first().css("margin", "0 0 0 0");
   }
  );
}

/* --------------------------------------------------------------------------------
 *                                                                     menus metier
 */

var current_menu_metier = "";

function init_metiers_menu()
{ var anim_delai = 130;
  var z_index = 100;
  jQuery("#metiers ul li").each
  ( function()
    { z_index--;
	  jQuery(this).css("zIndex", z_index);
	}
  );
  jQuery("#metiers ul li.menu_picto a.menu_picto").hover
  ( function()
    { jQuery(this).find("img").first().animate({height: 168}, anim_delai, function() {});
      jQuery(this).animate({height: 168, paddingTop: 0}, anim_delai, function() { aff_bulle(this); });
    },
    function()
    { jQuery(this).find("img").first().animate({height: 126}, anim_delai, function() {});
      jQuery(this).animate({height: 126, paddingTop: 42}, anim_delai, function() { del_bulle(this); });
    }
  );
  jQuery("#metiers ul li a.menu_picto").click(function() { active_menu_metier(this, 400); });
  if(current_menu_metier.length > 0) active_menu_metier(current_menu_metier, 0);
}

function active_menu_metier(a, delai)
{ jQuery("#metiers ul li ul").slideUp(0);
  jQuery(a).parent().find("ul").first().slideDown(delai);
  jQuery("#metiers ul li a.menu_picto").css("opacity", "0.3");
  jQuery(a).css("opacity", "1");
}

function aff_bulle(a)
{ var bulle = "<span class=\"metier_bulle\"><strong>" + jQuery(a).find("img").first().attr("alt") + "</strong></span>";
  jQuery(a).parent().prepend(bulle);
}

function del_bulle(a)
{ jQuery(a).parent().find(".metier_bulle").remove();
}

/* --------------------------------------------------------------------------------
 *                                                                 menus expertises
 */

function init_expertises()
{ jQuery("#expertises ul li").hover
  ( function()
    { jQuery(this).find(".titre").first().css("font-size", "1.2em");
    },
    function()
    { jQuery(this).find(".titre").first().css("font-size", "1em");
    }
  );
}
