var currentPage = location.pathname;
var thisPage = location.href;


/* ==

　ナビゲーションロールオーバー処理　＋　プレミストクラブTOPメインビジュアル

============================================================================================== */
jQuery(function($) {
    var postfix = '_on';
	//サイドメニューrollover及び.mainカラム内a.roll（汎用）のrollover処理
    $('.sub ul.nav a img, a.roll img').not('[src*="'+ postfix +'."]').each(function() {
        var img = $(this);
        var src = img.attr('src');
        var src_on = src.substr(0, src.lastIndexOf('.'))
                   + postfix
                   + src.substring(src.lastIndexOf('.'));
        $('<img>').attr('src', src_on);
        img.hover(function() {
            img.attr('src', src_on);
        }, function() {
            img.attr('src', src);
        });
    });



	/* プレミストクラブTOP　メインビジュアル
	------------------------------------------------------------------------------------------ */
	$("#premistclubtop_h1").prepend("<p class=\"h1_img\"><img src=\"/mansion/premistclub/images/h1_img.jpg\" alt=\"\" /></p>");
	$("#premistclubtop_h1 > p.h1_img").fadeIn(1500, function(){ $("#premistclubtop_h1 > h1").css({ width:"0px" }).animate({ width:"750px" }, 1800); });
	



	/* ==
	
	　ローカルナビゲーション（.lnav）
	
	============================================================================================== */
	//URLが/できられてる場合の処理
	var fileName = new RegExp(".html", "i");
	if(!currentPage.match(fileName)){ currentPage = currentPage + "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){
				$(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").children("ul").find("li:last").addClass("lastChild");





});




/* ==

　ナビゲーション（エリア選択プルダウン）の処理

============================================================================================== */
if(window.$ == undefined){
} else {
$(function(){

	$(".nav").find("ul.nav01_area").hover(function(){
		$(this).show();
		$(this).css("display", "block");
	},function(){
		$(this).hide();
		$(this).css("display", "none");
	});
	
	$("div.nav > div > ul > li.nav01").children("a").hover(function(){
		$(".nav").find("ul.nav01_area").show();
	}, function(){
		$(".nav").find("ul.nav01_area").hide();
	});

});
}



/* ==

　ピックアップ物件の高さ調整　※※実行のコントロールは「/common/js/fontSize.js」に設定あり※※

============================================================================================== */
function setHeight(){
	
	//height調整
	var nameH = 0;
	$(".pickup").find("p.name").each(function(){
		$(this).css("height", "auto");
		var thisH = $(this).height();
		if(nameH < thisH){ nameH = thisH; }
	});
	$(".pickup").find("p.name").css({"height": nameH + "px", paddingBottom: "7px"});

	var trafficH = 0;
	$(".pickup").find("p.traffic").each(function(){
		$(this).css("height", "auto");
		var thisH = $(this).height();
		if(trafficH < thisH){ trafficH = thisH; }
	});
	$(".pickup").find("p.traffic").css({"height": trafficH + "px", paddingBottom: "7px"});

}

