//<![CDATA[

function MM_openBrWindow(theURL,winName,features) { //v2.0
  var w = window.open(theURL,winName,features);
  w.focus();
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(objId,targ,restore){ //v9.0
  var selObj = null;  with (document) { 
  if (getElementById) selObj = getElementById(objId);
  if (selObj) eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0; }
}


function returnToTop() {
  var x1 = x2 = x3 = 0;
  var y1 = y2 = y3 = 0;
  if (document.documentElement) {
      x1 = document.documentElement.scrollLeft || 0;
      y1 = document.documentElement.scrollTop || 0;
  }
  if (document.body) {
      x2 = document.body.scrollLeft || 0;
      y2 = document.body.scrollTop || 0;
  }
  x3 = window.scrollX || 0;
  y3 = window.scrollY || 0;
  var x = Math.max(x1, Math.max(x2, x3));
  var y = Math.max(y1, Math.max(y2, y3));
  window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
  if (x > 0 || y > 0) {
      window.setTimeout("returnToTop()", 25);
  }
}

function addEvent (elm, listener, func) {
	try {
		elm.addEventListener(listener, func, false);
	}
	catch(e) {
		elm.attachEvent("on" + listener, func);
	}
}

function SlideMenu() {
	this.initalize.apply(this, arguments);
}

SlideMenu.prototype = {
	_target: 'cage',
	_elm: '',
	_visibleY: 0,
	_hiddenY: -350,
	_startY: 0,
	_goalY: 0,
	_speed: 5,
	initalize: function()
	{
		this._elm = document.getElementById(this._target);
		this._startY = parseInt(this._elm.style.marginTop.replace('px', ''));
		this._goalY = (this._startY == this._visibleY) ? this._hiddenY : this._visibleY;
	},
	up: function()
	{
		
	},
	down: function()
	{
		this.slide();
	},
	slide: function()
	{
		
		var goalY = Math.abs(this._goalY);
		var newY = this._startY;
		var i = 0;
		var tmpY = 0;
		var plus = (this._goalY < 0) ? -1 : 1;
		
		
		while(true) {
			//alert(newY);
			
			
			if (newY == this._goalY) {
				break;
			}
			
			
			tmpY = parseInt((this._goalY - newY) / this._speed);
			if (tmpY == 0) {
				tmpY = plus;
			}

			newY += tmpY;

			window.setTimeout("document.getElementById('" + this._target + "').style.marginTop = '"
			 + newY + "px';", 10 * ++i);
			
		}

	}
}

// 
// Show reserve&members menu in header area 
function showMenu() {
    document.getElementById('rsvMenuList').style.display = 'block';
  }
function hideMenu() {
    document.getElementById('rsvMenuList').style.display = 'none';
  }


// 
// Amenity tab show / hide 
// bpref = tab body prefix, hpref = tab header prefix
function seltab(bpref, hpref, id_max, selected) {
  if (! document.getElementById) return;
  for (i = 0; i <= id_max; i++) {
    if (! document.getElementById(bpref + i)) continue;
    if (i == selected) {
      document.getElementById(bpref + i).style.display = "block";
      document.getElementById(hpref + i).className = "open";
    } else {
      document.getElementById(bpref + i).style.display = "none";
      document.getElementById(hpref + i).className = "close";
    }
  }
}


// link to Toph
function link2Toph(ctgNo) {
	ctgNo = parseInt(ctgNo);
	
	if (ctgNo > 0) {
		var tophUrl = 'https://secure.toph.jp/rsv/prog/plan_list.php?hotel=kitakobushi&ctg=' + ctgNo;
		
		var urchinTag = new Array(
			'',
			'',
			'/urchinTracker/toph/category/rooms/openAir',
			'/urchinTracker/toph/category/rooms/central',
			'/urchinTracker/toph/category/rooms/highGrade',
			'/urchinTracker/toph/category/rooms/central/modern',
			'/urchinTracker/toph/category/rooms/annex',
			'/urchinTracker/toph/category/rooms/western',
			'/urchinTracker/toph/category/dishes/index',
			'/urchinTracker/toph/category/dishes/yomoNoUmi',
			'/urchinTracker/toph/category/dishes/dniningHallHokkai',
			'/urchinTracker/toph/category/dishes/heya',
			'/urchinTracker/toph/category/etc/longStay',
			'/urchinTracker/toph/category/etc/manyPeople',
			'/urchinTracker/toph/category/etc/anniversary',
			'',
			'/urchinTracker/toph/category/etc/natureGuide'
		);
		
		pageTracker._trackPageview(urchinTag[ctgNo]);
		
		var win = window.open(tophUrl);
		win.focus();
	}
}


//]]>
