// マウスポインタがある時の背景画像の点滅を回避
// (IE 5.0,IE 5.2,IE 5.5,IE 6.0, hover,background)
try {
document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


//
//スムーズアンカーリンク
//
//させない場合はクラスにnoscrollを記述
$(function(){
    $('a[href*=#], area[href*=#]').not('a.noscroll[href*=#], area.noscroll[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 500);
                return false;
            }
        }
    });
});


//---------------------------------------------------------------------

//
//別窓表示
//
//aタグにclass="blank"
$(function(){
  $('a.blank').click(function(){
    window.open(this.href);
    return false;
  })
});


//---------------------------------------------------------------------

//
//画像ロールオーバー
//
//class="rollover"で設定
//拡張子に_onと_crがついている場合はロールオーバーしない
$(function(){
	var postfix = '_on';//マウスオーバー
	var currentfix = '_cr';//現在位置
	$('.rollover a img,  a.rollover img, img.rollover, input.rollover, #globalNav a img').not('[src*="'+ postfix +'."], [src*="'+ currentfix +'."]').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);
			}
		);
	});
});



//---------------------------------------------------------------------

//
//現在位置表示
//
//class="active"でがついている要素の配下のimgのソースに_onを追加
$.event.add(window, "load", function() {
	$('.active img').each(function() {
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	}).mouseout(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
	});
});


//---------------------------------------------------------------------

//
//first-child、last-childを有効にする
//
//class="fl-check"
$(function() {
		$( '.fl-check :first-child' ).addClass( 'firstChild' );
		$( '.fl-check :last-child' ).addClass( 'lastChild' );
});


//---------------------------------------------------------------------

//
//stripe
//
//class="stripe"を指定した<tr>と<li>
//偶数、奇数でそれぞれeven,oddのクラスが追加される
$(function(){
	$(".stripe tr:nth-child(even) , .stripe li:nth-child(even)").addClass("even");
	$(".stripe tr:nth-child(odd) , .stripe li:nth-child(odd)").addClass("odd");
});



//---------------------------------------------------------------------

//
//ナビゲーション
//
$.event.add(window, "load", function() {
	$('.recommendation .nav01 img').each(function() {
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	}).mouseout(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
	});
	$('.stay .nav02 img').each(function() {
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	}).mouseout(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
	});
	$('.restaurant .nav03 img').each(function() {
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	}).mouseout(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
	});
	$('.wedding .nav04 img').each(function() {
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	}).mouseout(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
	});
	$('.banquet .nav05 img').each(function() {
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	}).mouseout(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
	});
	$('.facilities .nav06 img').each(function() {
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	}).mouseout(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
	});
});



//---------------------------------------------------------------------
//
//Tab
//
$(document).ready(function(){
	$('.tabs .tabContents').hide();
	$('.tabs .tabContents-first').show();
	$('.tabs .tab-select li:first-child').addClass('tab-active');
	
	$('.tabs .tab-select li a').click(function(){
		$('.tabs .tab-select li').removeClass('tab-active');
		$(this).parent().addClass('tab-active');
		var currentTab = $(this).attr('href');
		$('.tabs .tabContents').hide();
		$(currentTab).show();
		return false;
	});
});
