function DropDown(listElementID, movementRate, rate)
{
	this.List = document.getElementById(listElementID);
	this.MovementRate = movementRate;
	this.Rate = rate;
	this.SingleDropDown = false;
	this.LastRolledDown = null;
	
	var LastTitle;
	var Index = -1;
	
	for(var i = 0; i != this.List.childNodes.length; ++i)
	{
		var N = this.List.childNodes[i];
		
		if(N.nodeName.toUpperCase() == "DT")
		{
			var A = N.getElementsByTagName("a")[0];
			
			LastTitle = N;
			++Index;

			N.DropDownRolledUp = (arguments.length < 3 || arguments[3] != Index);
			A.onclick = this.CreateEventHandler("ItemClick", N);
			
			if(!N.DropDownRolledUp)
				this.LastRolledDown = N;
		}
		else if(N.nodeName.toUpperCase() == "DD")
		{
			LastTitle.DropDownContents = N;
			N.DropDownContentHeight = N.offsetHeight - 10;
			N.style.overflow = "hidden";
			
			if(arguments.length < 3 || arguments[3] != Index)
			{
				N.style.display = "none";
				N.style.height = "0";
			}
		}
	}
}

DropDown.prototype.CreateEventHandler = function(methodName, node)
{
	var Context = this;
	
	return function(e)
	{
		e = e || window.event;
		
		return Context[methodName](e, node);
	};
}

DropDown.prototype.CreateIntervalCallback = function(methodName, node)
{
	var Context = this;
	
	return function()
	{
		return Context[methodName](node);
	};
}

DropDown.prototype.ItemClick = function(e, node)
{
	var A = e.srcElement || e.target;
	
	if(node.DropDownRolledUp)
		this.BeginRollDown(A, node);
	else
		this.BeginRollUp(A, node);
}

DropDown.prototype.BeginRollUp = function(a, node)
{
	if(this.LastRolledDown == node)
		this.LastRolledDown = null;
	
	node.DropDownRolledUp = true;
	
	if(node.DropDownContents.Timer)
		clearInterval(node.DropDownContents.Timer);
	
	if(node.DropDownContents.style.height == "")
		node.DropDownContents.style.height = node.DropDownContents.DropDownContentHeight + "px";
	
	node.DropDownContents.Timer = setInterval(this.CreateIntervalCallback("ItemRollUp", node.DropDownContents), this.Rate);
	
	if(this.onItemSelected)
		this.onItemSelected(a.getAttribute("id"), false);
}

DropDown.prototype.BeginRollDown = function(a, node)
{
	if(this.SingleDropDown && this.LastRolledDown)
		this.BeginRollUp(node.getElementsByTagName("a")[0], this.LastRolledDown);

	this.LastRolledDown = node;

	node.DropDownRolledUp = false;
	
	if(node.DropDownContents.Timer)
		clearInterval(node.DropDownContents.Timer);
	
	node.DropDownContents.style.display = "block";
	
	if(node.DropDownContents.style.height == "")
		node.DropDownContents.style.height = "0";
	
	node.DropDownContents.Timer = setInterval(this.CreateIntervalCallback("ItemRollDown", node.DropDownContents), this.Rate);
	
	if(this.onItemSelected)
		this.onItemSelected(a.getAttribute("id"), true);
}

DropDown.prototype.ItemRollDown = function(node)
{
	var OldHeight = parseInt(node.style.height);
	
	if(isNaN(OldHeight))
		OldHeight = 0;
	
	var NewHeight = OldHeight + this.MovementRate;

	if(NewHeight >= node.DropDownContentHeight)
	{
		node.style.height = "";
		clearInterval(node.Timer);
	}
	else
		node.style.height = NewHeight + "px";
}

DropDown.prototype.ItemRollUp = function(node)
{
	var OldHeight = parseInt(node.style.height);
	
	if(isNaN(OldHeight))
		OldHeight = node.DropDownContentHeight;
	
	var NewHeight = OldHeight - this.MovementRate;

	if(NewHeight <= 0)
	{
		node.style.display = "none";
		node.style.height = "0";
		clearInterval(node.Timer);
	}
	else
		node.style.height = NewHeight + "px";
}