
/* ADD CSS */

document.open();
document.writeln('<style type="text/css"><!--');
document.writeln('#introCts,#aboutCts,#springsCts,#cuisineCts,#otherCts,#spaCts,#kaisekiCts,#infoCts{ display:none; }');
document.writeln('#rightContent{overflow:hidden;}');
if(window.opera || (window.navigator.userAgent.indexOf("Firefox/2",0) != -1)){
document.writeln('body{padding-left:0px !important;}');
}
document.writeln('h2{display:none;} #homeCts h2{ display:block; }');
document.writeln('#pageNavi{ display:block; }');
document.writeln('--></style>');
document.close();





/* WINDOW ON LOAD */

pageNavi = [];

window.onload = function(){
	LoadObj();
}





/* CONSTRUCTOR */

var LoadObj = function(){
	var insWrap = new Effect();
	var aTag = document.getElementById("navigation").getElementsByTagName("a");
	var liTag = document.getElementById("navigation").getElementsByTagName("li");
	var btn = document.getElementById("btnReservation");
	SwapBackground(liTag,btn);
	//
	//
	pageNavi["back"] = [];	
	pageNavi["next"] = [];
	//
	//
	for(var i=0; i<aTag.length; i++){
		var ins = new insWrap.animation(i);
		aTag[i].onclick = ins.run;
		aTag[i].onfocus = function(){
			this.blur();
		};
		//
		//
		var bi = (i - 1).toString();
		var ni = (i + 1).toString();
		pageNavi["back"][bi] = document.createElement("a");
		pageNavi["next"][ni] = document.createElement("a");
		pageNavi["back"][bi].href = "#";
		pageNavi["next"][ni].href = "#";
		//
		//
		var backImgSrc = "img/pagenavi_back_on.gif";
		var nextImgSrc = "img/pagenavi_next_on.gif";
		if(i==0){
			backImgSrc = backImgSrc.replace("_on","_of");
			var insNext = new insWrap.animation(i+1);
			pageNavi["back"][bi].style.cursor = "default";
			pageNavi["back"][bi].onclick = function(){ return false; };
			pageNavi["next"][ni].onclick = insNext.run;
			pageNavi["back"][bi].className = "hoverFalse";
			pageNavi["next"][ni].className = "";
		}else if(i==aTag.length-1){
			nextImgSrc = nextImgSrc.replace("_on","_of");
			var insBack = new insWrap.animation(i-1);
			pageNavi["next"][ni].style.cursor = "default";
			pageNavi["back"][bi].onclick = insBack.run;
			pageNavi["next"][ni].onclick = function(){ return false; };
			pageNavi["back"][bi].className = "";
			pageNavi["next"][ni].className = "hoverFalse";
		}else{
			var insBack = new insWrap.animation(i-1);
			var insNext = new insWrap.animation(i+1);
			pageNavi["back"][bi].onclick = insBack.run;
			pageNavi["next"][ni].onclick = insNext.run;	
			pageNavi["back"][bi].className = "";
			pageNavi["next"][ni].className = "";			
		}
		pageNavi["back"][bi].onfocus = function(){ this.blur(); };
		pageNavi["next"][ni].onfocus = function(){ this.blur(); };
		pageNavi["back"][bi].innerHTML = '<img src="' + backImgSrc + '" width="57" height="21" />';
		pageNavi["next"][ni].innerHTML = '<img src="' + nextImgSrc + '" width="57" height="21" />';
	}
	document.getElementById("pageNaviBack").replaceChild(pageNavi["back"]["-1"],document.getElementById("pageNaviBack").firstChild);
	document.getElementById("pageNaviNext").replaceChild(pageNavi["next"]["1"],document.getElementById("pageNaviNext").firstChild);
}

var Preload = function(){
	var n = document.getElementById("navigation").getElementsByTagName("a");
	var a = []; var r = [];
	for(var i=0; i<n.length; i++){
		a[i] = document.createElement("div");
		a[i].style.background = "url(img/"+ i +".jpg) 50% 50% no-repeat";
		r[i] = "url(img/"+ i +".jpg) 50% 50% no-repeat"; // safari2ではa[i].style.backgroundをそのまま新規オブジェクトに代入しても効かない為テキストノードで。
		document.getElementsByTagName("body")[0].appendChild(a[i]);
	}
	return r;
}


var Effect = function(){
	var wrap        = document.getElementById("wrap");
	var container   = document.getElementById("container");
	var box         = document.getElementById("box");
	var h1          = document.getElementsByTagName("h1")[0];
	var pageNaviBack= document.getElementById("pageNaviBack");
	var pageNaviNext= document.getElementById("pageNaviNext");
	var contentBox  = (function(){
								var a = []; var d = box.getElementsByTagName("div"); var n=0;
								for(var i=0; i<d.length; i++){
									if(d[i].className.indexOf("contentBox") != -1){
										a[n] = d[i]; n++;
									}
								}	return a; a=null; n=null;
								})();
	var contentNum  = 0;
	var num         = 0;
	var anum        = 100;
	var limit       = 186;
	var containerTop= limit*-1;
	var boxTop      = 0;
	var boxHeight   = 0;
	var boxFps      = 10;
	var boxFpsRatio = 8;
	var bgFps       = 1;
	if(window.navigator.userAgent.indexOf("Firefox/3",0) != -1){
		var bgFpsRatio  = 1;
	}else if(window.navigator.userAgent.indexOf("Firefox/2",0) != -1){
		var bgFpsRatio  = 4;	
	}else{
		var bgFpsRatio  = 3;
	}
	var wrapBgSrc = Preload();
	//
	//
	var runControl = false;
	//
	//
	this.pageNavi = null;
	//
	//
	this.animation = function(objnum){
		//
		//
		this.run = function(){
		//
		//
		if(runControl){ return false; }
		runControl = true;
		//
		//
		boxHide();
		//
		//
		function boxHide(){
		this.num = num;
		this.motion = setInterval(function(){
			if(this.num >= limit){
			clearInterval(this.motion);
			this.motion = null;
			this.num=num;
			bgHide();
			}else{
			this.num += Math.floor((limit-this.num)/boxFpsRatio);
			this.num++;
			boxTop = 0 - this.num;
			boxHeight = (limit - this.num)*2;
			container.style.top = (containerTop + this.num) + "px";
			container.style.height = boxHeight + "px"
			box.style.top = boxTop + "px";
			}
		},boxFps);
		}
		//
		//
		function bgHide(){
		this.anum = anum;
		this.motion = setInterval(function(){
			if(this.anum < 0){
			clearInterval(this.motion);
			this.motion = null;
			this.anum = anum;
			wrap.style.background = wrapBgSrc[objnum];
			adjustInterval();
			}else{
			this.anum -= bgFpsRatio;
			alpha(wrap,this.anum);
			}			
		},1);
		}
		//
		//
		function adjustInterval(){
		//
		//
		var bi = (objnum - 1).toString();
		var ni = (objnum + 1).toString();
		pageNaviBack.replaceChild(pageNavi["back"][bi],pageNaviBack.firstChild);
		pageNaviNext.replaceChild(pageNavi["next"][ni],pageNaviNext.firstChild);
		//
		//
		var h1Class = contentBox[objnum].getAttribute("id");
		h1Class = h1Class.replace("Cts","Title");
		h1.className = h1Class;
		if(objnum == 0){
			box.className = "homeBox";
		}else if(objnum == 2 || objnum == 3 || objnum == 7){
			box.className = "darkBox";
		}else{
			box.className = "normalBox";
		}
		//
		//
		contentBox[contentNum].style.display = "none";
		contentBox[objnum].style.display = "block";
		//
		//
		this.num = 0;
		this.motion = setInterval(function(){
			if(this.num > 10){
			clearInterval(this.motion);
			this.motion = null;
			this.num = 0;
			bgShow();
			}else{ this.num++; };
		},50);
		}
			//
		//
		function bgShow(){
		this.anum = 0;
		this.motion = setInterval(function(){
			if(this.anum > anum){
			clearInterval(this.motion);
			this.motion = null;
			this.anum = 0;
			boxShow();
			}else{
			this.anum += bgFpsRatio;
			alpha(wrap,this.anum);
			}
		},bgFps);
		}
		//
		//
		function boxShow(){
		this.num = 0;
		this.motion = setInterval(function(){
			if(this.num >= limit){
			clearInterval(this.motion);
			this.motion = null;
			this.num=0;
			//
			//
			contentNum = objnum;
			runControl = false;
			//
			//
			}else{
			this.num += Math.floor((limit-this.num)/boxFpsRatio);
			this.num++;
			boxTop = (limit*-1) + this.num;
			boxHeight = this.num*2;
			container.style.top = (limit - this.num + containerTop) + "px";
			container.style.height = boxHeight + "px";
			box.style.top = boxTop + "px";
			}
		},boxFps);
		}
		//
		//
		function alpha(elem,anum){
			if(document.all && !window.opera){
			elem.style.zoom = 1;
			elem.style.filter = "alpha(opacity="+anum+")";
			}else{
			elem.style.MozOpacity = anum/100;
			elem.style.opacity = anum/100;
			}
		}
		//
		//
		return false;
		//
		//
		}//run
	}//animation
}//endClass



var SwapBackground = function(/* ... */){
	var s,S,ies,ieS;
	var IE6 = window.navigator.userAgent.indexOf("MSIE 6.0") != -1;
	for(var i=0; i<arguments.length; i++){
		if(arguments[i].length){
			for(var j=0; j<arguments[i].length; j++){
				replaceSrc(arguments[i][j]);
			}
		}else{
			replaceSrc(arguments[i]);
		}
	};
	function replaceSrc(o){
		s = o.getAttribute("id");
		s = s.toLowerCase();
		ies = "img/" + s + "_of.png";
		ieS = ies.replace("_of","_on");
		s = "url(img/" + s + "_of.png) left top no-repeat";
		S = s.replace("_of","_on");
		if(IE6){
			o.swapAfterBgUrl = ieS;
			o.swapBeforeBgUrl = ies;
		}else{
			o.swapAfterBgUrl = S;
			o.swapBeforeBgUrl = s;
		}
		o.onmouseover = function(){
			if(IE6){
				this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.swapAfterBgUrl + "', sizingMethod=image)";
			}else{
				this.style.background = this.swapAfterBgUrl;
			}
		}
		o.onmouseout  = function(){
			if(IE6){
				this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.swapBeforeBgUrl + "', sizingMethod=image)";
			}else{
					this.style.background = this.swapBeforeBgUrl;
			}
		}
	}
}