﻿/*
 Btn Class v1.1
 update 2007.12.10
 create K.Kubonaka 
*/

function Btn(elm) {
	var me = this;
	this.elm = elm;
	this.over = function() { me.changeImage(true); };
	this.out = function() {	me.changeImage(false); };
	this.init();
}

var _Btn = Btn.prototype;

_Btn.init = function() {
	var me = this;
	var img_on = new Image();
	var img_str = this.elm.getAttribute("src");
	img_on.src = img_str.replace("_off", "_on");
	this.setEvent();
};


_Btn.doSelect = function() {
	this.deleteEvent();
	this.changeImage(true);
};


_Btn.setEvent = function() {
	try {
		this.elm.addEventListener("mouseover", this.over, false);
		this.elm.addEventListener("mouseout", this.out, false);
	} catch(e) {
		this.elm.attachEvent("onmouseover", this.over);
		this.elm.attachEvent("onmouseout", this.out);
	}
};


_Btn.deleteEvent = function() {
	try {
		this.elm.removeEventListener("mouseover", this.over, false);
		this.elm.removeEventListener("mouseout", this.out, false);
	} catch(e) {
		this.elm.detachEvent("onmouseover", this.over);
		this.elm.detachEvent("onmouseout", this.out);
	}
};


_Btn.changeImage = function(flag) {
	var img = this.elm.getAttribute("src");
	this.elm.setAttribute("src", (flag) ? img.replace("_off", "_on") : img.replace("_on", "_off"));
};


/*
 roSetter v1.1
 update 2007.12.10
 create K.Kubonaka 
*/

(function(func) {
	try {
		window.addEventListener("load", func, false);
	} catch(e) {
		window.attachEvent("onload", func);
	}
})(function() {
	var btnArray01 = document.getElementsByTagName("img");
	var btnArray02 = document.getElementsByTagName("input");
	for (var i = 0, ln = btnArray01.length; i < ln; i++) {
		if (btnArray01[i].getAttribute("src").indexOf("_off.") >= 0) new Btn(btnArray01[i]);
	}
	for (var i = 0, ln = btnArray02.length; i < ln; i++) {
		try{
			if(btnArray02[i].getAttribute("src") != null)
			{
				if (btnArray02[i].getAttribute("src").indexOf("_off.") >= 0) new Btn(btnArray02[i]);
			}			
		} catch(e){
		}
	}

	changeFont();
	switchEvent();
	
});

function setoverbtn()
{
	var btnArray01 = document.getElementsByTagName("img");
	var btnArray02 = document.getElementsByTagName("input");
	for (var i = 0, ln = btnArray01.length; i < ln; i++) {
		if (btnArray01[i].getAttribute("src").indexOf("_off.") >= 0) new Btn(btnArray01[i]);
	}
	for (var i = 0, ln = btnArray02.length; i < ln; i++) {
		try{
			if (btnArray02[i].getAttribute("src").indexOf("_off.") >= 0) new Btn(btnArray02[i]);
		} catch(e){
		}
	}
}

function OpenWindowComp(html,name,width,height) {
	WindowComp=window.open(html,name,"width="+width+",height="+height+",toolbar=1,location=1,status=1,menubar=1,scrollbars=1,resizable=1");
	WindowComp.focus();
}

if (navigator.appVersion.indexOf("Mac") !=-1){  
 document.write('<link href="/common/css/mac.css" type="text/css" rel="stylesheet">');  
}
var os, ua = navigator.userAgent;
if (ua.match(/Win(dows )?NT 6\.0/)) {
	document.write('<link href="/common/css/vista.css" type="text/css" rel="stylesheet">');  
}





//start if jQuery
if(typeof jQuery != "undefined"){ //jQueryの読み込み確認



/*-------------------------------------
 favicon.icoの読み込み
-------------------------------------*/
//window.document.onload=faviconAdd();

(function(jQuery) {
	faviconAdd();
	
	function faviconAdd() {
		document.write("<link rel='shortcut icon' href='/favicon.ico' type='image/vnd.microsoft.icon' />");
		document.write("<link rel='icon' href='/favicon.ico' type='image/vnd.microsoft.icon' />");
	}

})(jQuery);




/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};




/* Jquery Flat Heights
==========================================
Version: 2007-08-01

Copyright (c) 2007, KITAMURA Akatsuki

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
====================================================================== */
/*
	jQuery.changeLetterSize.addHandler(func)
	文字の大きさが変化した時に実行する処理を追加
*/

jQuery.changeLetterSize = {
	handlers : [],
	interval : 500,//定期処理を行う時間間隔。一応0.5秒で設定して有ります。1秒 = 1000
	currentSize: 0
};

(function(jQuery) {

	var self = jQuery.changeLetterSize;

	/* 文字の大きさを確認するためのins要素 */
	var ins = jQuery('<ins>M</ins>').css({
		display: 'block',
		visibility: 'hidden',
		position: 'absolute',
		padding: '0',
		top: '0'
	});

	/* 文字の大きさが変わったか */
	var isChanged = function() {
		
		ins.appendTo('body');
		var size = ins[0].offsetHeight;
		ins.remove();
		
		if (self.currentSize == size) return false;
		self.currentSize = size;
		
		return true;
	};

	/* 文書を読み込んだ時点で
	   文字の大きさを確認しておく */
	jQuery(isChanged);

	/* 文字の大きさが変わっていたら、
	   handlers中の関数を順に実行 */
	var observer = function() {
		if (!isChanged()) return;
		
		jQuery.each(self.handlers, function(i, handler) {
			handler();
		});
	};

	/* ハンドラを登録し、
	   最初の登録であれば、定期処理を開始 */
	self.addHandler = function(func) {
		self.handlers.push(func);
		if (self.handlers.length == 1) {
			setInterval(observer, self.interval);
		}
	};

})(jQuery);

/*
	jQuery(expr).flatHeights()
	jQuery(expr)で選択した複数の要素について、それぞれ高さを
	一番高いものに揃える
*/

(function(jQuery) {

	/* 対象となる要素群の集合 */
	var sets = [];

	/* 高さ揃えの処理本体 */
	var flatHeights = function(set) {
		var maxHeight = 0;
		set.each(function(){
			var height = this.offsetHeight;
			if (height > maxHeight) maxHeight = height;
		});
		set.css('height', maxHeight + 'px');
	};

	/* 要素群の高さを揃え、setsに追加 */
	jQuery.fn.flatHeights = function() {
		if (this.length > 1) {
			flatHeights(this);
			sets.push(this);
		}
		return this;
	};

	/* 文字の大きさが変わった時に、
	   setsに含まれる各要素群に対して高さ揃えを実行 */
	jQuery.changeLetterSize.addHandler(function() {
		jQuery.each(sets, function() {
			this.height('auto');
			flatHeights(this);
		});
	});

})(jQuery);

	/* 2-1.Setting
	---------------------------------------- */
	jQuery(function(){
		jQuery('.specialHigh').flatHeights();
		jQuery('.recommendHigh').flatHeights();
		jQuery('.memberHigh').flatHeights();
	});



/* アンカー処理 */

var speed = 10;
var remain;
var endY;

function Scroll(id){
	
	var d = document.getElementById(id);
	var windowHeight = document.body.offsetHeight;
	var innerHeight = get_browser_height();

	if(navigator.userAgent.indexOf("Safari") != -1){ 
		startY = document.body.scrollTop;
	}else{
		startY = document.documentElement.scrollTop;
	}
		
	endY = d.offsetTop;	
	if (d.offsetParent) while (d = d.offsetParent) endY += d.offsetTop;
	windowY = windowHeight - endY ;
	
	if(windowY > innerHeight){
		setIn = setInterval("ScrollCnt()",10);
	} else{
		endY = windowHeight - innerHeight;
		setIn = setInterval("ScrollCnt()",10);
	}
}

function get_browser_height() {
	if ( window.innerHeight ) { return window.innerHeight; }  
	else if ( document.documentElement && document.documentElement.clientHeight != 0 ) { return document.documentElement.clientHeight; }  
	else if ( document.body ) { return document.body.clientHeight; }
	return 0;
}

function ScrollCnt(){
	startY += ((endY-startY)/speed)+5;
	scrollTo(0,startY);
	
	if(startY > endY){
		clearInterval(setIn);
	}
}



// Easingの追加
jQuery.easing.quart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

/*-------------------------------------
 ページ読み込み中
-------------------------------------*/
jQuery(document).ready(function(){

	//
	// <a href="#***">の場合、スクロール処理を追加
	//
	jQuery('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var jQuerytarget = jQuery(this.hash);
			jQuerytarget = jQuerytarget.length && jQuerytarget || jQuery('[name=' + this.hash.slice(1) +']');
			if (jQuerytarget.length) {
				var targetOffset = jQuerytarget.offset().top;
				jQuery('html,body').animate({ scrollTop: targetOffset }, 600, 'quart');
				return false;
			}
		}
	});

});




/*-------------------------------------
 IE SELECT WIDTH
-------------------------------------*/

$(function ()
{
    // Set the width via the plugin.
    $('select.fixed-select-no-css').ieSelectWidth
    ({
        width : 200,
        containerClassName : 'select-container',
        overlayClassName : 'select-overlay'
    });
    
    // Set the width via CSS.
    $('select.fixed-select-css').ieSelectWidth
    ({
        width : 200,
        containerClassName : 'select-container',
        overlayClassName : 'select-overlay'
    });
    
    // Borders and padding etc for Internet Explorer 6/7.
    $('select.select-styleable').ieSelectWidth
    ({
        width : 200,
        containerClassName : 'select-container',
        overlayClassName : 'select-overlay'
    });
});



/*-------------------------------------
 開閉処理
-------------------------------------*/

function switchEvent()
{
	var flag = true;
	var click = true;
	var height = $("#tabBodyHotel").height()
		
	$(".switchEvent").click(function()
	{
		if(!click) return false;
		click = false;
		
		if(flag)
		{
			$(this).children("img").attr("src",$(this).children("img").attr("src").replace("Opne","Close"));
		}
		else
		{
			$(this).children("img").attr("src",$(this).children("img").attr("src").replace("Close","Opne"));
		}
		
		
		if (flag)
		{
			// 閉じる処理
			$("#tabBodyHotel").height(height);
			$("#switchSearch").hide();
			
			$("#tabBodyHotel").animate({height:"0px"},500,function()
			{
				click = true;
			});
		}
		else
		{
			// 開く処理
			$("#tabBodyHotel").animate({height:height},500,function()
			{
				click = true;
				$("#switchSearch").show();
			});				
		}
		
		flag = !flag;
	});
}

/*-------------------------------------
 開閉処理
-------------------------------------*/
var toggleFlag = true;

$(document).ready(function(){
	//ターゲット要素(.tglTarget)を隠す
	$(".tglTarget").hide();
	
	//トリガー要素(.tglTrigger)をクリックしたら、ターゲット（.tglTarget）を隠す
	$(".tglTrigger").each(function(){
		$(this).click(function(){
			$(this).siblings(".tglTarget").slideToggle("fast"); //同階層にあるターゲットをトグル
			if(toggleFlag == false){
				toggleFlag = true;
				$(this).removeClass("ancOpen");
			}	else {
				toggleFlag = false;
				$(this).addClass("ancOpen");
			};
		});
	});
});





/*-------------------------------------
 文字サイズ変更用トグル
-------------------------------------*/

function changeFont(){

	//文字サイズ変更ボタンの有無確認
	if($("#sizeL").length && $("#sizeM").length && $("#sizeS").length){
	
		var size = ($.cookie('className') == null)? "changeFontSizeM" : $.cookie('className'); 
		$("body").addClass(size);
		
		switch(size)
		{
			case "changeFontSizeL":
				$("#sizeL").children().attr("src",	$("#sizeL").children().attr("src").replace("_off","_act"));
				break;
				
			case "changeFontSizeM":
				$("#sizeM").children().attr("src",$("#sizeM").children().attr("src").replace("_off","_act"));
				break;
				
			case "changeFontSizeS":
				$("#sizeS").children().attr("src",$("#sizeS").children().attr("src").replace("_off","_act"));
				break;
			
			default:
				break;
		}
		
	
		$("#sizeL").click(function(){
			size = "changeFontSizeL";
			
			$("#sizeL").children().attr("src",	$("#sizeL").children().attr("src").replace("_on","_act"));
			$("#sizeM").children().attr("src",$("#sizeM").children().attr("src").replace("_act","_off"));
			$("#sizeS").children().attr("src",$("#sizeS").children().attr("src").replace("_act","_off"));
					
			$("body").removeClass("changeFontSizeS");
			$("body").removeClass("changeFontSizeM");
			$("body").addClass(size);
			$.cookie("className",size,{expires:365,path:'/'});
			//alert($(this).children().attr("src"));
			return false;
		});
	
		$("#sizeM").click(function(){
			size = "changeFontSizeM";		
			
			$("#sizeL").children().attr("src",	$("#sizeL").children().attr("src").replace("_act","_off"));
			$("#sizeM").children().attr("src",$("#sizeM").children().attr("src").replace("_on","_act"));
			$("#sizeS").children().attr("src",$("#sizeS").children().attr("src").replace("_act","_off"));
		
			$("body").removeClass("changeFontSizeS");
			$("body").removeClass("changeFontSizeL");
			$("body").addClass(size);
			$.cookie("className",size,{expires:365,path:'/'});
			//alert($(this).children().attr("src"));
			return false;
		});
	
		$("#sizeS").click(function(){
			size = "changeFontSizeS";	
			
			$("#sizeL").children().attr("src",	$("#sizeL").children().attr("src").replace("_act","_off"));
			$("#sizeM").children().attr("src",$("#sizeM").children().attr("src").replace("_act","_off"));
			$("#sizeS").children().attr("src",$("#sizeS").children().attr("src").replace("_on","_act"));
	
			//var src = $(this).children();
			//src.attr("src",	src.attr("src").replace("_on","_act"));
			
			$("body").removeClass("changeFontSizeL");
			$("body").removeClass("changeFontSizeM");
			$("body").addClass(size);
			$.cookie("className",size,{expires:365,path:'/'});
			//alert($(this).children().attr("src"));
			return false;
		});	

	}
}


/*-------------------------------------
 内容切替用 開閉処理(IBE関連)
-------------------------------------*/

var toggleFlagSwitch = true;

$(document).ready(function(){
	//切替用要素を隠す
	$(".viewMain").hide();
	
	//トリガー要素(.tggRSV)をクリックしたら、デフォルト要素(.viewDefo)を隠し、切替用要素(.viewMain)を表示
	$(".tggRSV").each(function(){
		$(this).click(function(){
			//同階層にあるターゲットをトグル
			$(this).siblings(".viewDefo").toggle(); 
			$(this).siblings(".viewMain").toggle();
			if(toggleFlagSwitch == false){
				toggleFlagSwitch = true;
				$(this).removeClass("tggRSVActive");
			}	else {
				toggleFlagSwitch = false;
				$(this).addClass("tggRSVActive");
			};
		});
	});
});




}//end if jQuery


