function LoginBlockOpener
	(LoginBlockId, LoginBlockInnerId, LoginTitleId, LoginTitleOpenId, LoginBlockMoreId,
	UsernameEditId,	InitialHeight, HeightLimit, InnerHeightDifference, Step,
	OpenCloseRate, AutoCloseTimeout)
{
	this.InitialHeight = InitialHeight;
	this.HeightLimit = HeightLimit;
	this.InnerHeightDifference = InnerHeightDifference;
	this.Step = Step;
	this.OpenCloseRate = OpenCloseRate;
	this.AutoCloseTimeout = AutoCloseTimeout;

	this.login_block		= document.getElementById(LoginBlockId);
	this.login_block_inner	= document.getElementById(LoginBlockInnerId);
	this.login_title		= document.getElementById(LoginTitleId);
	this.login_title_open	= document.getElementById(LoginTitleOpenId);
	this.login_block_more	= document.getElementById(LoginBlockMoreId);
	this.username_edit		= document.getElementById(UsernameEditId);
}

LoginBlockOpener.prototype.OpenLoginBlock = function ()
{
	if (this.login_block == null || this.login_block_inner == null ||
		this.login_title == null || this.login_title_open == null ||
		this.login_block_more == null)
		return;

	this.originalOnClickEvent = this.login_title.onclick;
	this.login_title.onclick = "";
	var thisObj = this;
	this.IntervalID = setInterval
		(function() { thisObj.DoOpenLoginBlock(); }, this.OpenCloseRate);
}

LoginBlockOpener.prototype.DoOpenLoginBlock = function ()
{
	var loginBlockHeight = parseInt(this.login_block.style.height);
	loginBlockHeight += this.Step;
	if (loginBlockHeight > this.HeightLimit)
		loginBlockHeight = this.HeightLimit;
	var loginBlockInnerHeight = loginBlockHeight - this.InnerHeightDifference;
	this.login_block_inner.style.height = loginBlockInnerHeight.toString() + "px";
	this.login_block.style.height = loginBlockHeight.toString() + "px";
		
	if (loginBlockHeight == this.HeightLimit)
	{
		clearInterval (this.IntervalID);
		this.login_title.style.display = "none";
		this.login_title_open.style.display = "";
		this.login_block_more.style.display = "";
		if (this.username_edit != null)
			this.username_edit.focus();
		this.ClosingBlock = false;
		var thisObj = this;
		this.TimeoutID = setTimeout
			(function() { thisObj.CloseLoginBlock(); }, this.AutoCloseTimeout);
		this.SetupResetTimeoutHandlers();
	}
}

LoginBlockOpener.prototype.CloseLoginBlock = function ()
{
	this.RemoveResetTimeoutHandlers();
	this.login_block_more.style.display = "none";

	var thisObj = this;
	this.IntervalID = setInterval
		(function() { thisObj.DoCloseLoginBlock(); }, this.OpenCloseRate);
}

LoginBlockOpener.prototype.DoCloseLoginBlock = function ()
{
	loginBlockHeight = parseInt(this.login_block.style.height);
	loginBlockHeight -= this.Step;
	if (loginBlockHeight < this.InitialHeight)
		loginBlockHeight = this.InitialHeight;
	var loginBlockInnerHeight = loginBlockHeight - this.InnerHeightDifference;
	this.login_block_inner.style.height = loginBlockInnerHeight.toString() + "px";
	this.login_block.style.height = loginBlockHeight.toString() + "px";

	if (loginBlockHeight == this.InitialHeight)
	{
		clearInterval (this.IntervalID);
		this.login_title_open.style.display = "none";
		this.login_title.onclick = this.originalOnClickEvent;
		this.login_title.style.display = "";
	}
}

LoginBlockOpener.prototype.SetupResetTimeoutHandlers = function ()
{
	var thisObj = this;
	var resetFunc = function ()
		{
			thisObj.ResetCloseTimeout();
		};
	var inputs = document.getElementsByTagName("input");
	for (var i = 0; i < inputs.length; i++)
	{
		inputs[i].onblur = inputs[i].onmousemove = inputs[i].onkeypress = inputs[i].onfocus = resetFunc;
	}
	this.login_block.onmousemove = resetFunc;
}

LoginBlockOpener.prototype.RemoveResetTimeoutHandlers = function ()
{
	var thisObj = this;
	var inputs = document.getElementsByTagName("input");
	for (var i = 0; i < inputs.length; i++)
	{
		inputs[i].onblur = inputs[i].onmousemove = inputs[i].onkeypress = inputs[i].onfocus = "";
	}
	this.login_block.onmousemove = "";
}

LoginBlockOpener.prototype.ResetCloseTimeout = function ()
{
	clearTimeout(this.TimeoutID);
	var thisObj = this;
	this.TimeoutID = setTimeout
		(function() { thisObj.CloseLoginBlock(); }, this.AutoCloseTimeout);
}
