/*
* LoginComponent
* Require:
*  jquery.js
*
**************************************/

var moveBox = {};

/* Setting
**************************************/
moveBox.componentID = "subArea02";
moveBox.objectPadding = 0;
moveBox.duration = 450;

/* Init
**************************************/
moveBox.id = "#" + moveBox.componentID;
moveBox.positionY = 0;
moveBox.footerOffset = 810;

moveBox.move = function() {
	this.beforePositionY = this.positionY;
	this.positionY = $.browser.msie ? document.documentElement.scrollTop : window.pageYOffset;
	var objPosition;
//	if (this.beforePositionY + this.objectPadding > this.objectY && this.positionY + this.objectHeight + this.objectPadding < this.pageHeight){
		if (this.positionY < this.headerHeight){
			objPosition = 0;
		} else if(this.pageHeight - this.footerOffset - this.headerHeight < this.positionY - this.headerHeight) {
			objPosition = this.pageHeight - this.footerOffset - this.headerHeight;
		} else {
			objPosition = this.positionY - this.headerHeight;
		}
		var parameter = {
			top: objPosition
		};
		$(this.id).dequeue().animate(parameter, this.duration, "swing");
//	}
}

$(document).ready(function(){
	moveBox.clientHeight = $.browser.msie ? document.documentElement.clientHeight : window.innerHeight; 
	moveBox.pageHeight = document.body.offsetHeight;
	moveBox.objectHeight = document.getElementById(moveBox.componentID).clientHeight;
	moveBox.objectY = document.getElementById(moveBox.componentID).offsetTop;
	moveBox.headerHeight = document.getElementById("contentBlock").offsetTop;
	$(window).scroll(function(){
		moveBox.move();
	});
});
