/*
 * DAIICHI PLAZA
 *
 * CopyRight (C) DAIICHI PLAZA. All rights reserved.
 *
 */

/*--------------------------------------------------------
ready
--------------------------------------------------------*/

$(function(){

	// 別ウィンドウ設定
	$(".Blank").click(function() { window.open(this.href, "_blank"); return false;});
	// 戻る
	$(".BtnHistoryBack").click(function() { window.history.back(); return false;});

	// easing
	jQuery.easing.easeOutCubic = function (x, t, b, c, d) {
 		return c*((t=t/d-1)*t*t + 1) + b;
	};

	// PAGE TOP
	$(".ReturnTop").click(function() {
		var highlight = false;
		var target = (! this.hash || this.hash == "#") ? $("body") : $(this.hash);
		var top = (target.attr("tagName") == "BODY") ? 0 : target.offset().top-20;
		var winHeight = $(window).height();
		var cntHeight = $(document).height();
		if (cntHeight - top < winHeight) top = cntHeight - winHeight;
		$('html,body').animate({scrollTop: top}, 1000, 'easeOutCubic', function(){
		});
		return false;
	});


	// ロールオーバー設定
	$("ul#GlobalShopList img.RollOver").mousedown(function() { $(this).attr("src", ($(this).attr("src")).replace("_on.", "_act.")); });
	$("img.RollOver").mouseover(function() { $(this).attr("src", ($(this).attr("src")).replace("_off.", "_on.")); });
	$("img.RollOver").mouseout(function() { $(this).attr("src", ($(this).attr("src")).replace("_on.", "_off.")); $(this).attr("src", ($(this).attr("src")).replace("_act.", "_off.")); });
	$("ul#GlobalShopList a").focus(function(){this.blur()});
	$(".iepngfix").pngfix();

	// ホーム
	if($("body#Home").size() > 0) {
		$('div#Footer').css("height", $(document).height()-$('div#Wrapper').height()-40);
	}

	// 2階層目
	if($("body.Second").size() > 0) {
		$("div#PageTitle").pngfix();
	}
	
	// サービスポリシー
	if($("body#Service").size() > 0) {
		$("p#Policy img, div.Photo, div.SecondColumn p img").pngfix();
	}

	// ニュースリリース
	if($("body#News").size() > 0) {
		$("ol li").pngfix();
		$(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'light_square'});
	}

	// お問い合わせ
	if($("body#Contact").size() > 0) {
		$("a#btnReset").click(function(){
			$("form#InputForm")[0].reset();
			return false;
		});
		$("a#btnSubmit").click(function(){
			$("form#InputForm")[0].submit();
			return false;
		});
	}

	// お問い合わせ（確認）
	if($("body#ContactConfirm").size() > 0) {
		$("a#btnBack").click(function(){
			$("form#ConfirmForm").attr("action", "./");
			$("form#ConfirmForm")[0].submit();
			return false;
		});
		$("a#btnSubmit").click(function(){
			$("form#ConfirmForm")[0].submit();
			return false;
		});
	}

	// 店舗一覧
	if($("body#ShopList").size() > 0) {
		var arrTooltipWidth = new Array(49, 49, 55, 49, 63, 73, 41, 81, 85, 55, 55, 91, 73, 69, 91);
		var arrTooltipImg = new Object();
   		for (var i = 1; i < 16; i++) {
			arrTooltipImg["description_"+i] = new Image();
			arrTooltipImg["description_"+i].src = "img/ico_feature_description_"+i+".gif";
			arrTooltipImg["description_"+i].width = arrTooltipWidth[i-1];
		}

		$('ul.FeatureIcon li').mouseover(function(e){
			tooltip = $("div#Tooltip");
			className = $(this).attr('class');
			if (className == '') return;
			$("div#Tooltip img").attr("src", arrTooltipImg[className].src);
			tooltip.css("left",($(this).position().left - ((arrTooltipImg[className].width-30)/2))).css("top",($(this).position().top -22));
 			tooltip.show();
			}).mouseout(function()  {
   				tooltip.hide();
		});

		$("div#Content dl dd, div#Content dl dt, div.Item, div#Content ul.FeatureIcon li img").pngfix();
		$('div#Content dl dt, div#Content dl dd').flatHeights();  
	}

	// 店舗詳細
	if($("body#Shop").size() > 0) {
		var arrTooltipWidth = new Array(49, 49, 49, 55, 63, 73, 41, 81, 85, 55, 55, 91, 73, 69, 91);
		var arrTooltipImg = new Object();
   		for (var i = 1; i < 16; i++) {
			arrTooltipImg["description_"+i] = new Image();
			arrTooltipImg["description_"+i].src = "../img/ico_feature_description_"+i+".gif";
			arrTooltipImg["description_"+i].width = arrTooltipWidth[i-1];
		}

		$('.Tooltip').mouseover(function(e){
			tooltip = $("div#Tooltip");
			$("div#Tooltip img").attr("src", arrTooltipImg[this.id].src);
			tooltip.css("left",($(this).position().left - ((arrTooltipImg[this.id].width-36)/2))).css("top",($(this).position().top -22));
 			tooltip.show();
			}).mouseout(function()  {
   				tooltip.hide();
   		});

		//詳細テーブル(項目ごとに高さを統一)
		var arrFlatHeights = new Array(
			'div#Content dl dt.address, div#Content dl dd.address',
			'div#Content dl dt.access, div#Content dl dd.access',
			'div#Content dl dt.tel, div#Content dl dd.tel',
			'div#Content dl dt.open, div#Content dl dd.open',
			'div#Content dl dt.holiday, div#Content dl dd.holiday',
			'div#Content dl dt.kashidama, div#Content dl dd.kashidama',
			'div#Content dl dt.daisu, div#Content dl dd.daisu',
			'div#Content dl dt.parking, div#Content dl dd.parking',
			'div#Content dl dt.mobile, div#Content dl dd.mobile',
			'div#Content dl dt.blogURL, div#Content dl dd.blogURL'
		);
		for (var i = 0; i < arrFlatHeights.length; i++) {
			$(arrFlatHeights[i]).flatHeights();
		}

		$(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'light_square'});
		$("div#Content dl dd, div#Content dl dt, ul.FeatureIcon img, ul.gallery li").pngfix();
	}

});

