<!--------------------prototype window-------------------->

// ウィンドウをスムーズスクロールさせるためのクラス。
function FloatingScrollWindow(id, windowOptions) {
	this.winPosTop = windowOptions['top'];
	windowOptions['top'] += document.documentElement.scrollTop || document.body.scrollTop;
	this.winHeight = windowOptions['height'];
	this.scrollTimerId = null;
	this.scrollInterval = 250;
	this.moveEffect = null;
	
	this.prototypeWindow = new Window(id, windowOptions);
	this.element = document.getElementById(id);
}

FloatingScrollWindow.prototype.show = function() {
	this.prototypeWindow.show();
	var moveByTop = this.winHeight + this.winPosTop;
	new Effect.Move(this.element, {x : 0, y : moveByTop, from : -1, to : 0});
}

FloatingScrollWindow.prototype.beginScroll = function() {
	if (this.scrollTimerId != null) {
		clearTimeout(this.scrollTimerId);
	}
	this.scrollTimerId = setTimeout("onEndScroll()", this.scrollInterval);
}

FloatingScrollWindow.prototype.onEndScroll = function() {
	var curScrollPosY = document.documentElement.scrollTop || document.body.scrollTop;
	var newWinPosY = curScrollPosY + this.winPosTop;
	if (this.moveEffect != null) this.moveEffect.cancel();
	this.moveEffect = new Effect.Move(this.element, {x : this.element.offsetLeft, y : newWinPosY, mode: 'absolute'});
	this.scrollTimerId = null;
}

var floatingWin;

/* フローティングウィンドウを出現させる */
function loadFloatingWindow() {
	var winWidth = 160;		// ウィンドウの幅
	var winHeight = 240;		// ウィンドウの高さ
	var winPosTop = 50;
	var winPosLeft = getBodySize()[0] / 2 + 400;
	if (winPosLeft < 780) { winPosLeft = 780; }
	var winViewUrl = 'menu_window.html';
	
	floatingWin = new FloatingScrollWindow("win1", { className : "alphacube", url : winViewUrl, closable : true, //showEffect : Element.show, 
		minimizable : false, maximizable : false, width : winWidth, height : winHeight, 
		top : winPosTop, left : winPosLeft});
	floatingWin.show();
}

/*window.onscroll = function() {
	if (floatingWin != undefined) floatingWin.beginScroll();
}

function onEndScroll() {
	floatingWin.onEndScroll();
}*/

//ウインドウサイズ取得 From http://www.sasaraan.net/program/js/jswndstate.html
function getBodySize() 
{
     var ua = navigator.userAgent;       // ユーザーエージェント
     var nWidth, nHeight;                   // サイズ
     var nHit = ua.indexOf("MSIE");     // 合致した部分の先頭文字の添え字
     var bIE = (nHit >=  0);                 // IE かどうか
     var bVer6 = (bIE && ua.substr(nHit+5, 1) == "6");  // バージョンが 6 かどうか
     var bStd = (document.compatMode && document.compatMode=="CSS1Compat");
                                                                           // 標準モードかどうか
     if (bIE) {
          if (bVer6 && bStd) {
               nWidth = document.documentElement.clientWidth;
               nHeight = document.documentElement.clientHeight;
          } else {
               nWidth = document.body.clientWidth;
               nHeight = document.body.clientHeight;
          }
     } else {
          nWidth = window.innerWidth;
          nHeight = window.innerHeight;
     }

     return new Array(nWidth, nHeight);
}


