function rollOver(){
	var postfix = '_o';
	$('img.o').not('[src*="'+postfix+'."]').each(
		function(){
			var src_org = jQuery(this).attr('src');
			var src_ovr = src_org.substr(0,src_org.lastIndexOf('.')) + postfix + src_org.substr(src_org.lastIndexOf('.'));
			jQuery('<img>').attr('src', src_ovr);
			jQuery(this).hover(
				function(){
					jQuery(this).attr('src',src_ovr);
				},
				function(){
					jQuery(this).attr('src',src_org);
				}
			);
		}
	);
}


function reserveCalender(){
	var calenderSrc;
	var ifrm = $('body.reserve #CONTENTS div.index iframe');
	
	if(ifrm.length>0){
		ifrm = ifrm[0];
		calenderSrc = ifrm.src;
		ifrm.src = null;
//		ifrm.style.display = 'none';


		$.ajax({
			url: calenderSrc,
			cache: false,
			success: function(html){
				$("body.reserve #CONTENTS div.index iframe").append(html);
			}
		});



	}
}


// Easingの追加
jQuery.easing.quart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};



/* Event onLoad */
jQuery(document).ready(function(){
	// 
	rollOver();
	
	// スクロール処理を追加
	$('a[href*=#],area[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = jQuery(this.hash);
			$target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				jQuery('html,body').animate({ scrollTop: targetOffset }, 500, 'quart');
				return false;
			}
		}
	});
	
	// 透過PNG対応
	$('img[@src$=png], .iepngfix').pngfix();
	
	//
	$('.room #CONTENTS table tr td.photo a, a.lightbox').lightBox( {imageLoading: '/common/img/lightbox-ico-loading.gif'} );
	
	// ポップアップウィンドウ
	if(typeof jQuery.fn.popupwindow=='function'){
		var popwinProfile = {
			ashiMap:{
				width:790,
				height:750,
				createnew:0
			}
		};
		$(".popupwindow").popupwindow(popwinProfile);
		
	}
	
	// ポップアップウィンドウから親ウィンドウのURLを変更
	$('.popupopner').click(function() {
		if(window.opener && !window.opener.closed){
			window.opener.location.href=this.href;
			window.opener.focus();
			return false;
		}
	});
	
	
	// 印刷ボタン
	$('#PRINTBUTTON img').click(function() {
		window.print();
	});
	$('#PRINTBUTTON img').css('cursor','pointer');
	
	// 閉じるボタン
	$('#CLOSE img').click(function() {
		window.close();
	});
	$('#CLOSE img').css('cursor','pointer');
	
	// 予約用カレンダー
	reserveCalender();
});

