/* ****************************************************************** 

	@This javascript Information{
		JS File Name:common.js

		Setting of:General pages
			1:xxx setting
			2:imgover setting
			3:
			4:
			5:
	}

****************************************************************** */



/*===================================================================

	1:xxx setting

===================================================================*/





/*===================================================================

	2:imgover setting

===================================================================*/
if(typeof jQuery != "undefined"){ //jQueryの読み込み確認

	/* img */
	$(function(){
		$('img.imgover').each(function(){
			var imgOut  = new Image();
			imgOut.src  = $(this).attr('src');
			var imgOver = new Image();
			if(imgOut.src.match(/.gif$/)){
			    imgOver.src = $(this).attr('src').replace('.gif','_o.gif');
			}else if(imgOut.src.match(/.jpg$/)){
			    imgOver.src = $(this).attr('src').replace('.jpg','_o.jpg');
			}else if(imgOut.src.match(/.png$/)){
			    imgOver.src = $(this).attr('src').replace('.png','_o.png');
			}
			
			$(this)
				.mouseover(function(){$(this).attr('src',imgOver.src);})
				.mouseout( function(){$(this).attr('src',imgOut.src);});
		});
	});

	/* input */
	$(function(){
		$('input[type=image].imgover').each(function(){
			var imgOut  = new Image();
			imgOut.src  = $(this).attr('src');
			var imgOver = new Image();
			if(imgOut.src.match(/.gif$/)){
			    imgOver.src = $(this).attr('src').replace('.gif','_o.gif');
			}else if(imgOut.src.match(/.jpg$/)){
			    imgOver.src = $(this).attr('src').replace('.jpg','_o.jpg');
			}else if(imgOut.src.match(/.png$/)){
			    imgOver.src = $(this).attr('src').replace('.png','_o.png');
			}
			
			$(this)
				.mouseover(function(){$(this).attr('src',imgOver.src);})
				.mouseout( function(){$(this).attr('src',imgOut.src);});
		});
	});
}



/* fade */
if(typeof jQuery != "undefined"){ //jQueryの読み込み確認
$(function(){
	$('a img.imgfade').hover(
		function(){
			$(this).fadeTo(100,0.8);
		},
		function(){
			$(this).fadeTo(100,1.0);
		}
	);
	});
}





/*===================================================================

	3: setting

===================================================================*/
$(function(){
	$(".tabarea #tab_menu li").click(function(){
		var tab = $(this).attr("id"); //クリックされたタブのidを取得
		var num = tab.split("_"); //セパレータで分割
		var con = "#content_" + num[1]; //表示させるコンテンツのid名を生成
		$(this).addClass("selected"); //クリックされたタブのclassにselectedを割り当て
		$(".tabarea li:not(#"+tab+")").removeClass("selected"); //その他のタブのclassにあるselectedを削除
		$(".tabarea div[id^=content]").hide(); //コンテンツをすべて非表示に
		$(".tabarea " + con).addClass("showText").fadeIn("slow").slideDown("slow"); //クリックされたタブ対応のコンテンツのみ表示
	});
});


jQuery(document).ready(function($) {
	$('.tabarea #tab_menu li a').focus(function(){this.blur();});
});








/*===================================================================

	4:anchorlink setting(scroll)

===================================================================*/

/*--------------------------------------------------------------------------*
 *  
 *  SmoothScroll JavaScript Library V2
 *  
 *  MIT-style license. 
 *  
 *  2007-2011 Kazuma Nishihata 
 *  http://www.to-r.net
 *  
 *--------------------------------------------------------------------------*/
 
new function(){

//	var attr ="data-tor-smoothScroll";
//  for html5 , if you can't use html5 , this value change "class"

	var attr ="class";
	var attrPatt = /no-smooth/;
	var d = document;//document short cut
	
	/*
	 *add Event
	  -------------------------------------------------*/
	function addEvent(elm,listener,fn){
		try{ // IE
			elm.addEventListener(listener,fn,false);
		}catch(e){
			elm.attachEvent(
				"on"+listener
				,function(){
					fn.apply(elm,arguments)
				}
			);
		}
	}

	/*
	 *Start SmoothScroll
	  -------------------------------------------------*/
	function SmoothScroll(a){
		if(d.getElementById(a.rel.replace(/.*\#/,""))){
			var e = d.getElementById(a.rel.replace(/.*\#/,""));
		}else{
			return;
		}
		
		//Move point
		var end=e.offsetTop
		var docHeight = d.documentElement.scrollHeight;
		var winHeight = window.innerHeight || d.documentElement.clientHeight
		if(docHeight-winHeight<end){
			var end = docHeight-winHeight;
		}
		
		//Current Point
		var start=window.pageYOffset || d.documentElement.scrollTop || d.body.scrollTop || 0;
		
		
		var flag=(end<start)?"up":"down";

		function scrollMe(start,end,flag) {
			setTimeout(
				function(){
					if(flag=="up" && start >= end){
						start=start-(start-end)/5-1;
						window.scrollTo(0,start)
						scrollMe(start,end,flag);
					}else if(flag=="down" && start <= end){
						start=start+(end-start)/15+1;
						window.scrollTo(0,start)
						scrollMe(start,end,flag);
					}else{
						scrollTo(0,end);
					}
					return ;
				}
				,1
			);
			
		}

		scrollMe(start,end,flag);
		
	}

	/*
	 *Add SmoothScroll
	  -------------------------------------------------*/
	addEvent(window,"load",function(){
		var anchors = d.getElementsByTagName("a");
		for(var i = 0 ,len=anchors.length; i<len ; i++){
			if(!attrPatt.test(anchors[i].getAttribute(attr)) && 
				anchors[i].href.replace(/\#[a-zA-Z0-9_\\-]+/,"") == location.href.replace(/\#[a-zA-Z0-9_\\-]+/,"")){
				anchors[i].rel = anchors[i].href;
				anchors[i].href = "javascript:void(0)";
				anchors[i].onclick=function(){SmoothScroll(this)}
			}
		}
	});

}





/*===================================================================

	5: setting

===================================================================*/
$( function() {
    $( '#down_menu_1' ) . click( function() {
        $( "#down_menu_1_sub" ) . slideToggle( 'slow' );
    } );
	$( '#down_menu_2' ) . click( function() {
        $( "#down_menu_2_sub" ) . slideToggle( 'slow' );
    } );
	$( '#down_menu_3' ) . click( function() {
        $( "#down_menu_3_sub" ) . slideToggle( 'slow' );
    } );
	$( '#down_menu_4' ) . click( function() {
        $( "#down_menu_4_sub" ) . slideToggle( 'slow' );
    } );
	$( '#down_menu_5' ) . click( function() {
        $( "#down_menu_5_sub" ) . slideToggle( 'slow' );
    } );
	$( '#down_menu_6' ) . click( function() {
        $( "#down_menu_6_sub" ) . slideToggle( 'slow' );
    } );
} );





/*===================================================================

	6:xxxxx setting

===================================================================*/
$(document).ready(function() {
	$('div#gnavi ul li#btn_info a')
		.css( {backgroundPosition: "0px 0px"} ) //デフォルト時、背景画像を縦0pxに指定。
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px -100px)"}, {duration:500})
			//マウスオーバー時に縦位置100pxに0.5秒かけて移動
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:200, complete:function(){
			//マウスアウト時に縦位置0pxに2秒かけて移動
				$(this).css({backgroundPosition: "0px 0px"})
				//移動完了後、元の位置に戻す
			}})
	})
});

$(document).ready(function() {
	$('body#stayguide div#gnavi ul li#btn_info a')
		.css( {backgroundPosition: "0px -100px"} ) //デフォルト時、背景画像を縦0pxに指定。
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px -100px)"}, {duration:500})
			//マウスオーバー時に縦位置100pxに0.5秒かけて移動
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0px -100px)"}, {duration:200, complete:function(){
			//マウスアウト時に縦位置0pxに2秒かけて移動
				$(this).css({backgroundPosition: "0px -100px"})
				//移動完了後、元の位置に戻す
			}})
	})
});


$(document).ready(function() {
	$('div#gnavi ul li#btn_booking a')
		.css( {backgroundPosition: "-107px 0px"} ) 
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-107px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-107px 0px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-107px 0px"})
			}})
	})
});

$(document).ready(function() {
	$('body#booking div#gnavi ul li#btn_booking a')
		.css( {backgroundPosition: "-107px -100px"} ) 
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-107px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-107px -100px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-107px -100px"})
			}})
	})
});


$(document).ready(function() {
	$('div#gnavi ul li#btn_plan a')
		.css( {backgroundPosition: "-213px 0px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-213px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-213px 0px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-213px 0px"})
			}})
	})
});

$(document).ready(function() {
	$('body#plan div#gnavi ul li#btn_plan a')
		.css( {backgroundPosition: "-213px -100px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-213px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-213px -100px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-213px -100px"})
			}})
	})
});


$(document).ready(function() {
	$('div#gnavi ul li#btn_access a')
		.css( {backgroundPosition: "-321px 0px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-321px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-321px 0px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-321px 0px"})
			}})
	})
});

$(document).ready(function() {
	$('body#access div#gnavi ul li#btn_access a')
		.css( {backgroundPosition: "-321px -100px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-321px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-321px -100px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-321px -100px"})
			}})
	})
});


$(document).ready(function() {
	$('div#gnavi ul li#btn_guide a')
		.css( {backgroundPosition: "-428px 0px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-428px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-428px 0px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-428px 0px"})
			}})
	})
});

$(document).ready(function() {
	$('body#townguide div#gnavi ul li#btn_guide a')
		.css( {backgroundPosition: "-428px -100px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-428px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-428px -100px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-428px -100px"})
			}})
	})
});


$(document).ready(function() {
	$('div#gnavi ul li#btn_boardwalk a')
		.css( {backgroundPosition: "-535px 0px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-535px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-535px 0px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-535px 0px"})
			}})
	})
});

$(document).ready(function() {
	$('body#boardwalk div#gnavi ul li#btn_boardwalk a')
		.css( {backgroundPosition: "-535px -100px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-535px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-535px -100px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-535px -100px"})
			}})
	})
});


$(document).ready(function() {
	$('div#gnavi ul li#btn_inq a')
		.css( {backgroundPosition: "-642px 0px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-642px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-642px 0px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-642px 0px"})
			}})
	})
});

$(document).ready(function() {
	$('body#inq div#gnavi ul li#btn_inq a')
		.css( {backgroundPosition: "-642px -100px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-642px -100px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-642px -100px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-642px -100px"})
			}})
	})
});

