$(function(){
// begin //

// よくあるお問い合わせ
$("#qa dl dt.linkbar").each(function(){
	$(this).mouseover(function(){
		$("span",this).removeClass("def").addClass("over");
		$(this).removeClass("def").addClass("over");
	}).mouseout(function(){
		$("span",this).removeClass("over").addClass("def");
		$(this).removeClass("over").addClass("def");
	}).click(function(){
	if($("+dd.textbox",this).css("display")=="block"){
		$("span",this).removeClass("on").addClass("def");
		// $(this).removeClass("on").addClass("def");
		$("+dd.textbox:not(:animated)",this).slideUp("slow",function(){
			$("#qa dl dt.linkbar").removeClass("on").addClass("def");
		});
	}else{
		$("span",this).removeClass("over").addClass("on");
		$(this).removeClass("over").addClass("on");
		$("+dd.textbox",this).slideDown("slow");
	}
	});
});




// みんなのクチコミタヒチ情報
$("#recommend div.thumbnaillist").each(function(){
	$("div",this).hover(function(){
		$("span.photo",this).removeClass("bgw").addClass("bgg");
	},
	function(){
		$("span.photo",this).removeClass("bgg").addClass("bgw");
	}).css({
	height: $(this).height()+"px"
	});
});


// タブパネル
$("div.panel:not("+$("ul.tab li.selected a").attr("href")+")").css("display","none");
$("ul.tab li").click(function(){
	$("ul.tab li").removeClass("selected");
	$(this).addClass("selected");
	$("div.panel:not(:animated)").fadeOut("slow");
	$($("a",this).attr("href")).fadeIn("slow");
	return false;
});


var panel1 = $("#panel1").height();
var panel2 = $("#panel2").height();
var panel3 = $("#panel3").height();
var panel4 = $("#panel4").height();
var panel5 = $("#panel5").height();
var panelwrapper_height = Math.max.apply( null, [panel1,panel2,panel3,panel4,panel5]);
$("#panelwrapper").css("height",panelwrapper_height+12+"px");


$("#class #panel").each(function(){
	var panelheight = $(".image",this).height();
	$(this).css("height",panelheight)
});


// モーダルウィンドウ
$("span.close").css("cursor","pointer").hover(function(){
	$(this).addClass("orange");
},
function(){
	$(this).removeClass("orange");
}).click(function(){
	parent.$("#bluelayer,#overlayer").hide();
});


if($.browser.msie && $.browser.version<7){
	$("body:has(a.modalwin)").append("<div id='bluelayer'>&nbsp;</div><iframe id='overlayer' frameborder='0' scrolling='yes'></iframe>");
}else{
	$("body:has(a.modalwin)").append("<div id='bluelayer'>&nbsp;</div><iframe id='overlayer' frameborder='0' scrolling='auto'></iframe>");
}

$("#bluelayer").click(function(){
	$(this).hide();
	$("#overlayer").hide();
});

$("body#recommend a.modalwin").click(function(){
	$("#bluelayer:not(:animated)").fadeIn("slow");
	$("#overlayer:not(:animated)").fadeIn("slow").attr("src",$(this).attr("href"));
	$('html,body').animate({ scrollTop: $("#pagetop").offset().top},'fast');
	return false;
});

$("body[id!='recommend'] a.modalwin").click(function(){
var url = $(this).attr("href");
var link = url.substr(0, url.indexOf('?'));
var modalwinsize = url.slice(url.indexOf('?'));
str = modalwinsize;
arr = str.split("&");
var first = arr[0];
var second = arr[1];
var firstvalue = first.slice(7);
var secondvalue = second.slice(7);
modalwinwidth = firstvalue+"px";
modalwinheight = secondvalue+"px";
modalwinml = "-"+firstvalue/2+"px";
modalwinmt = "-"+secondvalue/2+"px";
	$("#overlayer").css({
		width: modalwinwidth,
		height: modalwinheight,
		marginTop: modalwinmt,
		marginLeft: modalwinml
	});
	$("body").css({
		minWidth: modalwinwidth,
		minHeight: modalwinheight
	});
	$("#bluelayer:not(:animated)").fadeIn("slow");
	$("#overlayer:not(:animated)").fadeIn("slow").attr("src",link);
	$('html,body').animate({ scrollTop: $("#pagetop").offset().top},'fast');
	return false;
});

var h = Math.max.apply( null, [document.body.clientHeight , document.body.scrollHeight, document.documentElement.scrollHeight, document.documentElement.clientHeight] );
$("#bluelayer").css("height",h);

if($.browser.msie && $.browser.version<7){
var winheight = $(window).height()/2;
var overlayerh = $("#overlayer").height()/2;
	if(winheight-overlayerh > 0){
		$("#overlayer").css("top",winheight);
	}
	if(winheight-overlayerh <= 0){
		$("#overlayer").css({
		top: "0px",
		marginTop: "0px"
		});
	}
}




// プルダウン
$("#gnavi dl").each(function(){
	$("dd",this).hover(function(){
		$("div:not(:animated)",this).slideDown("slow");
	},
	function(){
		$("div",this).slideUp("slow");
	});
});

$("#hotels ul#tab").each(function(){
	$("li.others",this).hover(function(){
		$("dl:not(:animated)",this).slideDown("slow");
	},
	function(){
		$("dl",this).slideUp("slow");
	});
});

// プルダウン汎用
$(".pulldownmenu").each(function(){
	$(this).hover(function(){
		$(".pulldown:not(:animated)",this).slideDown("slow");
	},
	function(){
		$(".pulldown",this).slideUp("slow");
	});
});


// headdingほかレイアウト関連
$("h3:has(span),h4.bar").append("<div class='mask'></div>");
$("#mainvisual+h3").css("margin-top","40px");
$("h3+ul.list,h3+ul.listkome,h3+dl,h4+ul.list,h4+ul.listkome").css("margin-top","15px");
$("p+ol.list,p+ul.list,p+ul.listkome").css("margin-top","15px");
$("#mainvisual+p,#mainvisual+.copy,#mainvisual+div,#mainvisual+ul").css("margin-top","40px");
$(".copy+p,div.imagebox+p").css("margin-top","30px");

$("h3:not(has(span))").each(function(){
	$(this).css("width",$("img",this).width())
});


var basesrc = $("html script[src*='common']").attr("src");　// 101207修正
var path = basesrc.substr(0, basesrc.lastIndexOf('common'));
var spacegif = path+"common/img/space.gif";
var maskpng = path+"common/img/ttl_mask.png";

if($.browser.msie && $.browser.version<7){
	$("h3 .mask,h4.bar .mask").css({
	width: "712px",
	height:" 4px",
	background: "none",
	filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+maskpng+"',sizingMethod='image')",
	position: "absolute",
	left: "0",
	overflow: "hidden"
	});
}


if($.browser.msie && $.browser.version<7){
$("h3").each(function(){
	var h = $(this).height();
	if(h % 2 == 0){
		$("h3 .mask").css("bottom","0");
		$("h3 span").css("margin","0px 10px");
	}else{
		$("h3 .mask").css("bottom","-1px");
		$("h3 span").css("margin","0px 10px");
	}
});
$("h4.bar").each(function(){
	var h = $(this).height();
	if(h % 2 == 0){
		$("h4.bar .mask").css("bottom","0");
		$("h4.bar span").css("margin","0px 10px");
	}else{
		$("h4.bar .mask").css("bottom","-1px");
		$("h4.bar span").css("margin","0px 10px");
	}
});
}


// tableレイアウト
$(".tablewrapper").each(function(){
var divwidth = $("table",this).width();　// 101207修正
	$(this).css("width",divwidth);
});

// 101207追加ここから
$("table.oline").each(function(){
	$("tr:last td,tr:last th",this).css("background-image","none");
}).before("<div class='tableolinetop'></div>").after("<div class='tableolinebtm'></div>");
// 101207追加ここまで

$("table.bline").each(function(){
	$("tr:last td,tr:last th",this).css("background-image","none");
}).before("<div class='tablelinetop'></div>").after("<div class='tablelinebtm'></div>");

$("p+table.noline").css("margin-top","15px");


// $(".imagebox").each(function(){
// 	$(this).css({
// 	width: $("img",this).width()+"px"
// 	});
// });

// photoboxのwidth取得
$(".photobox").each(function(){
	$("span,ul",this).css({
	width: $("img",this).width()+"px"
	});
});

$(".photoboxset").each(function(){
var leftwidth= $(this).parent("div").width()-$(".photobox.right",this).width()-15+"px";
var rightwidth= $(this).parent("div").width()-$(".photobox.left",this).width()-15+"px";
	$("p.photobox.left,ul.photobox.left",this).css("width",leftwidth);
	$("div.photobox.left p",this).css("width",leftwidth);
	$("div.photobox.left h4.waves",this).css("width",leftwidth);
	$("p.photobox.right,ul.photobox.right",this).css("width",rightwidth);
	$("div.photobox.right p,div.photobox.right ul",this).css("width",rightwidth);
	$("div.photobox.right h4.waves",this).css("width",rightwidth);
});

$("#resorts .photoboxset").each(function(){
var resortsleftwidth= $(this).parent("div").width()-$(".photobox.right",this).width()-25+"px";
var resortsrightwidth= $(this).parent("div").width()-$(".photobox.left",this).width()-25+"px";
	$("div.photobox.right p",this).css("width",resortsrightwidth);
	$("div.photobox.left p",this).css("width",resortsleftwidth);
});

$("#resorts .contentsboxn .photoboxset").each(function(){
var resortsleftwidthn= $(this).parent("div").width()-$(".photobox.right",this).width()-40;
var resortsrightwidthn= $(this).parent("div").width()-$(".photobox.left",this).width()-40;
	$("div.photobox.right p,div.photobox.right div.topline,div.photobox.right div.btmline",this).css("width",resortsrightwidthn+"px");
	$("div.photobox.left p",this).css("width",resortsleftwidthn+"px");
var rdboxleftwidth= $(this).parent("div").width()-$(".photobox.right",this).width()-66;
var rdboxrightwidth= $(this).parent("div").width()-$(".photobox.left",this).width()-66;
	$("div.photobox.right div.textbox",this).css("width",rdboxrightwidth+"px");
	$("div.photobox.left div.textbox",this).css("width",rdboxleftwidth+"px");

if($.browser.msie && $.browser.version<7){
var buttonlyellow = $("a.txtlink",this).width()+10;
	if(rdboxleftwidth < buttonlyellow){
		$("div.photobox.left .buttonlyellow",this).css({
		width: rdboxleftwidth+"px"
		});
	}if(rdboxleftwidth >= buttonlyellow){
		$("div.photobox.left .buttonlyellow",this).css({
		width: buttonlyellow+"px"
		});
	}
	if(rdboxrightwidth < buttonlyellow){
		$("div.photobox.right .buttonlyellow",this).css({
		width: rdboxrightwidth+"px"
		});
	}if(rdboxrightwidth >= buttonlyellow){
		$("div.photobox.right .buttonlyellow",this).css({
		width: buttonlyellow+"px"
		});
	}
}else{
	$("div.photobox.left .buttonlyellow",this).css({
	maxWidth: rdboxleftwidth+"px",
	width: "auto !important",
	width: $("a.txtlink",this).width()+10+"px"
	});
	$("div.photobox.right .buttonlyellow",this).css({
	maxWidth: rdboxrightwidth+"px",
	width: "auto !important",
	width: $("a.txtlink",this).width()+10+"px"
	});
}
});

$(".photobox").each(function(){
	$("span,ul",this).css({
	width: $("img",this).width()+"px"
	});
});

$(".tableboxset").each(function(){
var tablewidth= $(this).parent("div").width()-$("table",this).width()-25+"px";
	$("div.tabletxtbox",this).css("width",tablewidth);
});



// contentsboxのheight取得
$("#hotels .contentsbox,.contentsbox:has(.textbox)").each(function(){
	$(this).css("height",$(".textbox",this).height()+"px");
});


// リンクの点線を消す
$("a").focus(function(){
	this.blur();
});


// ロールオーバー　オーバー時の画像名に_ovを付ける
$("img.rollover").mouseover(function(){
	$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2"));
}).mouseout(function(){
	$(this).attr("src",$(this).attr("src").replace(/^(.+)_ov(\.[a-z]+)$/, "$1$2"));
}).mousedown(function(){
	$(this).attr("src",$(this).attr("src").replace(/^(.+)_ov(\.[a-z]+)$/, "$1$2"));
}).each(function(){
	$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2"));
});


// pngロールオーバー　オーバー時の画像名に_ovを付ける
$("img.pngrollover,#gnavi .pulldown img").each(function(){
	$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2"));
});

if($.browser.msie && $.browser.version<7){
	$("img.pngrollover,#gnavi .pulldown img").each(function(){
		$(this)
			.data("src",$(this).attr("src"))
			.attr("src",spacegif)
			.css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')");
	}).mouseover(function(){
		$(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src").replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2")+"',sizingMethod='scale')");
	}).mouseout(function(){
		$(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')");
	});
	
}else{
	$("img.pngrollover,#gnavi .pulldown img").mouseover(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2"));
	}).mouseout(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)_ov(\.[a-z]+)$/, "$1$2"));
	}).mousedown(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)_ov(\.[a-z]+)$/, "$1$2"));
	});
}


// pngロールオーバーなし　imgクラス名png
if($.browser.msie && $.browser.version<7){
	$(".png").each(function(){
		$(this)
			.data("src",$(this).attr("src"))
			.attr("src",spacegif)
			.css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')");
	});
}


// ページトップへほかアンカーリンクスクロール
$("a[href^='#'],area[href^='#']").click(function(){
if($.browser.msie && $.browser.version<7){
	$('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top-15},"slow","swing");
	return false;
}else{
	$('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top},"slow","swing");
	return false;
}
});

// end //
});




