if (/MSIE (5\.5|6)/.test(navigator.userAgent)) {
	document.write("<scri"+"pt src='/visionary/js/iepngfix_tilebg.js'></scr"+"ipt>");
}


$(function(){
	$("#header li img").scgrph_swapper();
	$("#m-h #top-nav li img").scgrph_swapper();
	$("#pager li img:not(.no-over)").scgrph_swapper();
	$("#m-h-nav img").scgrph_swapper();
	$("#m-h-d-nav a img").scgrph_swapper();


	var lw = 0;
	$("#pager li").each(function(){
		if($(this).find("img.no-over").length==0)
		lw+=$(this).width();
	});
	lw = Math.floor(($("#left").width()-lw)/2);

	if($("#pager li:eq(0) img").attr("class")=="no-over"){
		lw-=76;
		if($("#pager li:eq(1) img").attr("class")=="no-over"){
			lw-=76;
		}
	}

	$("#pager").css("margin-left",lw+"px");

	if($(".moment-story").length>0){
		/*the moment右アーカイブ読み込み*/
		$(".moment-story #right #archives").load("_toc.html",function(){
			$("ul#archives li a").each(function(){
				if($.scgrph_absolute_path(this.href).match(location.pathname.split(".html").join("").split("_")[0])){
					$(this).parent().addClass("cur");
				}
			});
		});
		/*the moment下バックナンバー読み込み*/
		$(".moment-story #updated ul").load("../_backnumber.html",function(){
		});
	}
	
	$("body#m-h-d #right").after('<div id="r-b" class="m-h-tile" />');
	$("#r-b").hide();
	
	var close = function(obj){
		$(obj).attr({title:"開く"}).next().hide().end().
		filter(".noc").attr("title","このカテゴリはありません");
		$("#r-b").hide();
	};
	var open = function(obj){
		$("#r-b").hide();//height("auto");
		
		$("#m-h-d-n>li:not(.h)>img").each(function(){close(this);});$(obj).attr({title:"閉じる"}).next().show();
		if($("#left").height() > $("#right").height()){
			$("#r-b").height($("#left").height()-$("#right").height()).show();
		}
	}
	var open_close = function(obj){
		if($(obj).next().css("display")=="none") open(obj);
		else close(obj);
		
		
	}
	
	/*展示品ガイド*/
	$("#m-h-d-n li a img").scgrph_swapper({force:"inactive"});
	$("#m-h-d #details li a").each(function(){
		if($.scgrph_absolute_path(this.href)==$.scgrph_absolute_path(location.pathname)){
			$(this).css("font-weight","bold");
		}
	});
	
	/*090210バックアップ
	$("#m-h-d-n>li:not(.h)>img").css("cursor","pointer").
	filter(function(){return $(this).next().children().length==0}).css("cursor","default").addClass("noc").end().
	/*toggle(function(){open_close(this);},function(){open_close(this);})* /
	filter(":not(.noc)").click(function(){open_close(this);}).trigger("click").end().
	next().find("a[href=#]").addClass("nol").click(function(){return false;}).end().
	find("a:not([href=#])").each(function(){
		if($.scgrph_absolute_path(this.href)==$.scgrph_absolute_path(location.pathname)){
			if($(this).addClass("cur").parent().parent().parent().find("img:first").trigger("click").length==0){
				$(this).addClass("cur").parent().parent().parent().parent().parent().find("img:first").trigger("click");
			}
			return false;
		}
	});
	*/
	/*090210暫定使用-----* /
	$("#m-h-d-n>li:not(.h)>img").//css("cursor","pointer").
	filter(function(){return $(this).next().children().length==0}).css("cursor","default").addClass("noc").end().
	//filter(":not(.noc)").click(function(){open_close(this);}).trigger("click").end().
	next().find("a[href=#]").parent().hide().end().end().//.addClass("nol").click(function(){return false;}).end().
	find("a:not([href=#])").each(function(){
		if($.scgrph_absolute_path(this.href)==$.scgrph_absolute_path(location.pathname)){
			if($(this).addClass("cur").parent().parent().parent().find("img:first").trigger("click").length==0){
				$(this).addClass("cur").parent().parent().parent().parent().parent().find("img:first").trigger("click");
			}
			return false;
		}
	});
	if($("#left").height() > $("#right").height()){
		$("#r-b").height($("#left").height()-$("#right").height()).show();
	}
	/ *----090210暫定使用*/

	
	
	$(window).load(function(){
		$(".item-photo img").each(function(){$(this).css("margin-top",parseInt(($(this).parent().height()-$(this).height())/2)+"px").css("margin-bottom",0)});
	});
	

	$(window).resize(function(){
		if($(window).width()%2!=0) $("body").css("margin-left","-1px");
		else $("body").css("margin-left","0");

		var dh = $(window).height() - $("body").height();
		if(dh>0){
			$("#footer").height(dh+110);
		}


	}).trigger("resize");
});
