MJL.event.add(window, "load", function() {
    // MJL に関係するコードはこの中に記述
    MJL.enable.flash("flash");
    MJL.enable.window("window");
    MJL.enable.tab("tabs");
    MJL.enable.styleSwitcher("styleSwitcher");
    MJL.enable.heightEqualizer("equalize");
    MJL.enable.heightEqualizer("list-col3",{groupBy : 3});
    MJL.enable.rollover("roll", { disable : "unroll" });
});

// MJL と無関係なコードはこの先に記述

$(document).ready(function(){
						   
	//Toggle Box
	$(".box-toggle .section-inner").hide(); 
	$(".box-toggle h2").click(function(){
		$(this).toggleClass("active").next().slideToggle("fast");
		return false;
	});

	//Smooth Scroll
	$('#nav-pagetop a').click(function() {
      var speed = 400;// ミリ秒
      var href= $(this).attr("href");
      var target = $(href == "#" || href == "" ? 'html' : href);
      var position = target.offset().top;
      $($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'swing');
      return false;
   });
	
	// カテゴリナビ
	$("#nav-global > .category > li:not(.unroll)").each(function(i, e)
	{
		var $e = $(e);
		var $label = $(".label img:first", e);
		var closedWidth = $label.width();
		var openedWidth = $e.parent().width();
		
		$e.width(closedWidth);
		
		$e.mouseenter(function(event)
		{
			$e.removeClass("close").stop().clearQueue("fx").animate({ width : openedWidth });
		});
		
		$e.focus(function(event)
		{
			$e.removeClass("close").stop().clearQueue("fx").animate({ width : openedWidth });
		});
		
		$label.mouseleave(function(event)
		{
			if ($e.is(":not(.close)"))
			{
				window.setTimeout(function()
				{
					with ($label.get(0))
						{ src = src.replace(/(\.\w+$)/, "_o$1") }
				}, 0);
			}
		});
		
		$e.mouseleave(function(event)
		{
			if ($e.is(":not(.close)"))
			{
				$e.stop().clearQueue("fx").animate(
					{ width : closedWidth },
					{ complete : function(){ $e.addClass("close") } }
				);
				
				window.setTimeout(function()
				{
					with ($label.get(0))
						{ src = src.replace(/_o(\.\w+$)/, "$1") }
				}, 0);
			}
		});
	});
	
	// グローバルネットワーク地図
	$("#map_world area").each(function(i, e)
	{
		$("*[href~=\"" + e.href.replace(/\/$/, "") + "\"]")
		.mouseenter(function(event)
		{
			with ($("*[usemap=\"#" + e.parentNode.name + "\"]").get(0))
				{ src = src.replace(/(\.\w+$)/, "_" + e.id + "$1") }
		})
		.mouseleave(function(event)
		{
			with ($("*[usemap=\"#" + e.parentNode.name + "\"]").get(0))
				{ src = src.replace(/_[a-z]{2}(\.\w+$)/, "$1") }
		});
	});
	
});
