var currentPage = location.pathname;

$(function(){

	/* ==
	
	　ローカルナビゲーション（.lnav）
	
	============================================================================================== */
	//URLが/できられてる場合の処理
	var fileName = new RegExp(".html", "i");
	if(!currentPage.match(fileName)){ currentPage = currentPage + "index.html"; }

	//財務ハイライト
	var highlight2 = new RegExp("/company/highlight/index2.html", "i");
	if(currentPage.match(highlight2)){ currentPage = "/company/highlight/index.html"; }
	var highlight3 = new RegExp("/company/highlight/index3.html", "i");
	if(currentPage.match(highlight3)){ currentPage = "/company/highlight/index.html"; }


	//決算説明会
	var fannounce = new RegExp("/company/financhialannouncement/", "i");
	if(currentPage.match(fannounce)){ currentPage = "/company/financhialannouncement/index.html"; }


	//月次受注状況
	var juchu = new RegExp("/company/juchu/", "i");
	if(currentPage.match(juchu)){ currentPage = "/company/juchu/index.html"; }

	//カレント処理
	var currentLnav = $("div.lnav").attr("id");
	
	//中ページのリンクは一旦全部隠す
	$("div.lnav > div li").find("ul").hide();

	var currentFlg = false;
	$("div.lnav > div > ul > li").children("a").each(function(){
		if(currentFlg == false){
			var thisUrl = $(this).attr("href");
			if(currentPage.indexOf(thisUrl) != -1){
				
				if(currentPage.match(fannounce)){ //「決算発表会資料」がアクティブにならないよう回避
					if($(this).parent().parent().parent().attr("class") != "lnav05"){ return true; }
				}
				
				$(this).parent().addClass("current");
				currentFlg = true;
			}
		}
	});
	
	if(currentFlg != true){
		$("div.lnav > div > ul > li > ul > li").children("a").each(function(){
			var thisUrl = $(this).attr("href");
			if(currentPage.indexOf(thisUrl) != -1){
				$(this).parent().parent().parent("li").addClass("current");
				currentFlg = true;
			}	
		});
	}
	
	if(currentFlg != true){
		$("div.lnav > div > ul > li > ul > li > ul > li").children("a").each(function(){
			var thisUrl = $(this).attr("href");
			if(currentPage.indexOf(thisUrl) != -1){
				$(this).parent().parent().parent().parent().parent("li").addClass("current");
				currentFlg = true;
			}	
		});
	}




	//カレントの子ども<ul>を表示させる。
	if(currentLnav != ""){ $("li.current").find("ul").show(); }
	
	//展開された子どものカレントが一番目だった時の処理
	//$("div.lnav > div > ul").children("li:first").css("marginTop", "1px");
	$("div.lnav > div").each(function(){
		$(this).children("ul").children("li").eq(0).css("marginTop", "1px");
	});

	//リスト一番下の背景処理
	$("div.lnav > div").children("ul").find("li:last").addClass("lastChild");
	

	/* ==
	
	　各ページ処理
	
	============================================================================================== */
	/* 月次受注状況
	---------------------------------------------------------------------------------------------- */
	$(".ir div.juchu").each(function(){ $(this).children("dl:even").addClass("even"); });
	$(".ir div.documents").each(function(){ $(this).find("li:even").addClass("even"); });
	$(".ir div.ir_news").each(function(){ $(this).find("dl:even").addClass("even"); });


	/* ニュースリリース
	---------------------------------------------------------------------------------------------- */
	$(".container div.news div > dl").hover(function(){
		$(this).css("backgroundColor", "transparent");
	},function(){
		$(this).css("backgroundColor", "#f4f4f4");
	});
	$(".container div.news div").each(function(){ $(this).children("dl:last").children("dd").css("backgroundImage", "none"); });
	
	/*
	//通常
	$(".container .info > div").hover(function(){
		$(this).css("backgroundColor", "transparent");
	},function(){
		$(this).css("backgroundColor", "#f4f4f4");
	});
	$(".container .info > div:last-child dd").css("background", "none");

	//項目別
	$(".container .infoItem > div").hover(function(){
		$(this).css("backgroundColor", "transparent");
	},function(){
		$(this).css("backgroundColor", "#f4f4f4");
	});
	$(".container .infoItem > div:last-child dd").css("background", "none");
	*/




});


