// TOP DIRECTORY PATH SEARCH
if(document.domain.indexOf("risonare") > 0 ){
	if(location.href.indexOf("risonare.com/release2/") > 0 ){
		var docRootlng = location.href.split("risonare.com/release2/en/")[1].split("/");
	}else{
		var docRootlng = location.href.split("risonare.com/en/")[1].split("/");
	}
}else{
	var docRootlng = location.href.split("risonare/en/")[1].split("/");
}
var docRoot = "";
	for(var i=0;i<(docRootlng.length)-1;i++){
		docRoot += "../";
	}

//=============================================
// SmartRollOver()
//=============================================
function initRollovers() {
	if (!document.getElementById) return

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {	
		if (aImages[i].className == 'ov') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}


//=============================================
// BlWin2()
//=============================================
function BLinks() {
	if (!document.getElementsByTagName) return;

	var anchors = document.getElementsByTagName("a");

	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "bl")
		anchor.target = "_blank";
	}
}






//=============================================
// init()
//=============================================

function init() {
	curCheck();
	BLinks();
	initRollovers();
}


window.onload=init;


//=============================================
// FC追加スクリプト
//=============================================

//=============================================
// ブロック要素の高さを揃える
//=============================================

/*--------------------------------------------------------------------------*
 *  
 *  heightLine JavaScript Library beta4
 *  
 *  MIT-style license. 
 *  
 *  2007 Kazuma Nishihata 
 *  http://www.webcreativepark.net
 *  
 *--------------------------------------------------------------------------*/
new function(){
	
	function heightLine(){
	
		this.className="heightLine";
		this.parentClassName="heightLineParent"
		reg = new RegExp(this.className+"-([a-zA-Z0-9-_]+)", "i");
		objCN =new Array();
		var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
		for(var i = 0; i < objAll.length; i++) {
			var eltClass = objAll[i].className.split(/¥s+/);
			for(var j = 0; j < eltClass.length; j++) {
				if(eltClass[j] == this.className) {
					if(!objCN["main CN"]) objCN["main CN"] = new Array();
					objCN["main CN"].push(objAll[i]);
					break;
				}else if(eltClass[j] == this.parentClassName){
					if(!objCN["parent CN"]) objCN["parent CN"] = new Array();
					objCN["parent CN"].push(objAll[i]);
					break;
				}else if(eltClass[j].match(reg)){
					var OCN = eltClass[j].match(reg)
					if(!objCN[OCN]) objCN[OCN]=new Array();
					objCN[OCN].push(objAll[i]);
					break;
				}
			}
		}
		
		//check font size
		var e = document.createElement("div");
		var s = document.createTextNode("S");
		e.appendChild(s);
		e.style.visibility="hidden"
		e.style.position="absolute"
		e.style.top="0"
		document.body.appendChild(e);
		var defHeight = e.offsetHeight;
		
		changeBoxSize = function(){
			for(var key in objCN){
				if (objCN.hasOwnProperty(key)) {
					//parent type
					if(key == "parent CN"){
						for(var i=0 ; i<objCN[key].length ; i++){
							var max_height=0;
							var CCN = objCN[key][i].childNodes;
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j] && CCN[j].nodeType == 1){
									CCN[j].style.height="auto";
									max_height = max_height>CCN[j].offsetHeight?max_height:CCN[j].offsetHeight;
								}
							}
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j].style){
									var stylea = CCN[j].currentStyle || document.defaultView.getComputedStyle(CCN[j], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight -= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight -= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","");
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									CCN[j].style.height =newheight+"px";
								}
							}
						}
					}else{
						var max_height=0;
						for(var i=0 ; i<objCN[key].length ; i++){
							objCN[key][i].style.height="auto";
							max_height = max_height>objCN[key][i].offsetHeight?max_height:objCN[key][i].offsetHeight;
						}
						for(var i=0 ; i<objCN[key].length ; i++){
							if(objCN[key][i].style){
								var stylea = objCN[key][i].currentStyle || document.defaultView.getComputedStyle(objCN[key][i], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight-= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight-= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","")
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									objCN[key][i].style.height =newheight+"px";
							}
						}
					}
				}
			}
		}
		
		checkBoxSize = function(){
			if(defHeight != e.offsetHeight){
				changeBoxSize();
				defHeight= e.offsetHeight;
			}
		}
		changeBoxSize();
		setInterval(checkBoxSize,1000)
		window.onresize=changeBoxSize;
	}
	
	function addEvent(elm,listener,fn){
		try{
			elm.addEventListener(listener,fn,false);
		}catch(e){
			elm.attachEvent("on"+listener,fn);
		}
	}
	addEvent(window,"load",heightLine);
}

//=============================================
// ウィンドウポップアップ
//=============================================


function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


//=============================================
// 印刷ボタン
//=============================================

function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();
	}
}



//=============================================
// カレントメニューチェック
//=============================================
function curCheck(){	
	var myurl = location.href;
	var val =  myurl.split("/");
		val.pop();
		val = val.join("/");

	if(document.getElementById("gNavi")){var myobjg= document.getElementById("gNavi").getElementsByTagName("ul")[0].getElementsByTagName("a");}
	// GLOBAL MENU の。
	if(myobjg){
		for( var i = 0; i < myobjg.length; i ++ ){
			if( (myobjg[i].href.split("index.html")[0].indexOf(val) >= 0) && ((myurl.indexOf("en/index") == -1) && (myurl.split("en")[1]).length > 1) ){
				// ロルオバ。
				myobjg[i].getElementsByTagName("img")[0].src = myobjg[i].getElementsByTagName("img")[0].src.split(".gif").join("_c.gif");
			}else if(myobjg[i].href.indexOf("en/index") >= 0){
			}else{
				myobjg[i].getElementsByTagName("img")[0].setAttribute("class","ov");
			}
		}
	}
	if(document.getElementById("header")){var myobjs= document.getElementById("header").getElementsByTagName("a");}
	// SUB MENU の。
	if(myobjs){
		for( var i = 0; i < myobjs.length; i ++ ){
			if( (myobjs[i].href.split("index.html")[0].indexOf(val) >= 0) && ((myurl.indexOf("en/index") == -1) && (myurl.split("en")[1]).length > 1) ){
				// ロルオバ。
				myobjs[i].getElementsByTagName("img")[0].src = myobjs[i].getElementsByTagName("img")[0].src.split(".gif").join("_c.gif");
			}else{
				if(myobjs[i].getElementsByTagName("img")[0]){
					myobjs[i].getElementsByTagName("img")[0].setAttribute("class","ov");
				}
			}
		}
	}
}

//=============================================
// ウィンドウポップアップ(楽しみ方検索用)
//=============================================
function pop2ASearch(p){
	var path = (p) ? p : docRoot + "activity/search.html" ;
	var PopWidth  = ",width=" + 950;
	var PopHeight = ",height=" + 680;
	var PopWinName= "pop";
	var PopDetail = "scrollbars=1,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0" + PopWidth + PopHeight;
	PopWin = window.open(path,PopWinName,PopDetail);
	PopWin.focus();
}


//=============================================
// 共通HEADER書き出し
//=============================================
function setHeader(){
	// HEADER
	var _str = ""
		_str += '<div id="header">';
		_str += '<div class="inner">';
		_str += '<ul>';
		_str += '<li class="hmenu01"><a href="'+docRoot+'access/index.html"><img alt="ACCESS" src="'+docRoot+'common/images/hmenu01.gif" width="46"height="12" /></a></li>';
		_str += '<li class="hmenu02"><a href="'+docRoot+'faq/index.html"><img alt="FAQ" src="'+docRoot+'common/images/hmenu02.gif" width="25" height="12" /></a></li>';
		_str += '<li class="hmenu03"><a href="'+docRoot+'contact/index.html"><img alt="CONTACT" src="'+docRoot+'common/images/hmenu03.gif" width="62"height="12" /></a></li>';
		_str += '<li class="hmenu04"><a href="https://room-yoyaku.jp/risonare_e/search/search_period_top.asp"><img alt="CHARGES/ROOM AVAILABILITY" src="'+docRoot+'common/images/hmenu04.gif" width="195" height="12" /></a></li>';
		_str += '<li class="hmenu05"><a href="https://room-yoyaku.jp/risonare_e/login.asp"><img alt="RECONFIRM" src="'+docRoot+'common/images/hmenu05.gif" width="100" height="21" /></a></li>';
		_str += '</ul>';
		_str += '</div>';
		_str += '</div>';
	document.write(_str);

}
//=============================================
// 共通GlOBALNAVI書き出し
//=============================================
function setGnavi(){
	var myurl = location.href;
	var logoimg = ( myurl.indexOf("en/index") == -1 && (myurl.split("en")[1]).length > 1 )?'<img alt="RISONARE" src="'+docRoot+'common/images/gmenu00.gif" width="170" height="61" />':'<img alt="RISONARE" src="'+docRoot+'images/gmenu00.gif" width="170" height="108" />';
	
	// GLOBALNAVI
	var _str = ""
		_str += '<div id="gNavi">';
		_str += '<div class="bg"><img alt="RISONARE" src="'+docRoot+'common/images/bg_menushadow.png" width="190" height="327" class="alphafilter" /></div>';
		_str += '<div class="inner">';
		_str += '<ul>';
		_str += '<li class="np"><a href="'+docRoot+'index.html">'+logoimg+'</a></li>';
		_str += '<li><a href="'+docRoot+'about/index.html"><img alt="ABOUT RISONARE" src="'+docRoot+'common/images/gmenu01.gif" width="170" height="38" /></a></li>';
		_str += '<li><a href="'+docRoot+'guestroom/index.html"><img alt="GUESTROOMS" src="'+docRoot+'common/images/gmenu02.gif" width="170" /></a></li>';
		_str += '<li><a href="'+docRoot+'cuisine/index.html"><img alt="RESTAURANTS &amp; CAFE" src="'+docRoot+'common/images/gmenu03.gif" width="170" height="38" /></a></li>';
		_str += '<li><a href="'+docRoot+'poolspa/index.html"><img alt="SPA &amp; RELAXATION" src="'+docRoot+'common/images/gmenu04.gif" width="170" height="38" /></a></li>';
		_str += '<li><a href="'+docRoot+'shop/index.html"><img alt="SHOPS" src="'+docRoot+'common/images/gmenu05.gif" width="170" height="38" /></a></li>';
		_str += '<li><a href="'+docRoot+'stayplan/index.html"><img alt="STAY PLAN" src="'+docRoot+'common/images/gmenu06.gif" width="170" height="38" /></a></li>';
		_str += '<li><a href="'+docRoot+'seasonal/index.html"><img alt="SEASONAL INFO" src="'+docRoot+'common/images/gmenu07.gif" width="170" height="38" /></a></li>';
		_str += '</ul>';
		_str += '</div>';
		_str += '<p class="btn01"><a href="'+docRoot+'../index.html"><img alt="JAPANESE" src="'+docRoot+'common/images/btn_japanese.gif" width="98" height="21" /></a></p>';
		_str += '</div>';
	document.write(_str);

}
//=============================================
// 共通RESERVATION書き出し
//=============================================
function setReservation(){
	// RESERVATION
	var _str = ""
		_str += '<div id="reservationArea">';
		_str += '<dl>';
		_str += '<dt><a href="https://room-yoyaku.jp/risonare_e/search/search_stay_top.asp"><img alt="Reservation" src="'+docRoot+'common/images/btn_bottom_reserve01.gif" width="190" height="57" /></a></dt>';
		_str += '<dd class="txt"><img alt="Reservation over the telephone +81-551-36-5111" src="'+docRoot+'common/images/btn_bottom_reserve02.gif" width="357" height="20" /></dd>';
		_str += '</dl>';
		_str += '</div>';
		_str += '<div class="space0px"></div>';
	document.write(_str);

}
//=============================================
// 共通FOOTER書き出し
//=============================================
function setFooter(){
	// FOOTER
	var _str = ""
		_str += '<div id="footer">';
		_str += '<ul>';
		_str += '<li class="np"><a href="'+docRoot+'about/index.html">ABOUT RISONARE</a></li>';
		_str += '<li><a href="'+docRoot+'guestroom/index.html">GUESTROOMS</a></li>';
		_str += '<li><a href="'+docRoot+'cuisine/index.html">RESTAURANTS &amp; CAFE</a></li>';
		_str += '<li><a href="'+docRoot+'poolspa/index.html">SPA &amp; RELAXATION</a></li>';
		_str += '<li><a href="'+docRoot+'shop/index.html">SHOPS</a></li>';
		_str += '<li><a href="'+docRoot+'stayplan/index.html">STAY PLAN</a></li>';
		_str += '<li><a href="'+docRoot+'seasonal/index.html">SEASONAL INFO</a></li>';
		_str += '</ul>';
		_str += '<ul>';
		_str += '<li class="np"><a href="'+docRoot+'access/index.html">ACCESS</a></li>';
		_str += '<li><a href="'+docRoot+'faq/index.html">FAQ</a></li>';
		_str += '<li><a href="'+docRoot+'contact/index.html">CONTACT</a></li>';
		_str += '<li><a href="https://room-yoyaku.jp/risonare_e/search/search_period_top.asp">CHARGES/ROOM AVAILABILITY</a></li>';
		_str += '<li><a href="https://room-yoyaku.jp/risonare_e/login.asp">RECONFIRM</a></li>';
		_str += '<li><a href="'+docRoot+'../index.html">JAPANESE</a></li>';
		_str += '</ul>';
		_str += '<p><img alt="Copyright(C)2008 risonare All Right Reserved." src="'+docRoot+'common/images/copyrights.gif" width="234" height="10" /></p>';
		_str += '</div>';
	document.write(_str);

	// GA WRITE
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
	
	// 
	document.write(unescape("%3Cscript src='" + docRoot + "common/js/ga_1.js' type='text/javascript'%3E%3C/script%3E"));

}