function AutoSuggestDropDown(INPUT,CHOICEBOX,CHOICES)
{
	this.input = document.getElementById(INPUT);
	this.choiceBox = document.getElementById(CHOICEBOX);
	this.choices = CHOICES;
	this.PositionChoices();
	var dd = this;
	this.curChoice=-1;
	this.input.onblur = function()
	{
		if (dd.curChoice >= 0) dd.input.value = dd.choiceBox.childNodes[dd.curChoice].innerHTML;
		dd.CleanUp();	
	}
	this.input.onkeyup = function(e)
	{
		if (!e) e = window.event;
		var keyCode = e.keyCode;
		if (dd.input.value.length > 0 && (keyCode==8 || keyCode == 32 || (keyCode >= 47 && keyCode <=111) || keyCode > 123))
		{
			dd.RemoveAllChoices();
			dd.Populate();
		}
		else if (keyCode == 40 && dd.curChoice < dd.choiceBox.childNodes.length-1)
		{
			dd.curChoice++;
			dd.UnHighlightAll();
			dd.choiceBox.childNodes[dd.curChoice].className="CurrentChoice";
		}
		else if (keyCode == 38 && dd.curChoice >= 0)
		{
			dd.curChoice--;
			dd.UnHighlightAll();
			dd.choiceBox.childNodes[dd.curChoice].className="CurrentChoice";
		}
		else if ((keyCode == 13) && dd.curChoice >= 0)
		{
			dd.input.value = dd.choiceBox.childNodes[dd.curChoice].innerHTML;
			dd.CleanUp();
		}
	}
}

AutoSuggestDropDown.prototype.CleanUp = function()
{
	this.choiceBox.style.visibility = "hidden";
	this.curChoice=-1;
}

AutoSuggestDropDown.prototype.UnHighlightAll = function()
{
	for (var i=0; i < this.choiceBox.childNodes.length; i++)
	{
		this.choiceBox.childNodes[i].className="Choice";
	}
}

AutoSuggestDropDown.prototype.PositionChoices = function()
{
	var left = Position.cumulativeOffset(this.input)[0];
	var top = Position.cumulativeOffset(this.input)[1];
	var height = Element.getHeight(this.input);
	this.choiceBox.style.left = left + "px";
	this.choiceBox.style.top = height + top + "px";
}

AutoSuggestDropDown.prototype.RemoveAllChoices = function()
{
	while(this.choiceBox.hasChildNodes())
	{
		this.choiceBox.removeChild(this.choiceBox.firstChild);
	}
}

AutoSuggestDropDown.prototype.Populate = function()
{
	this.curChoice = -1;
	this.choices.sort();
	var userEntry = this.input.value.toLowerCase();
	var dd=this;
	var c=0;
	for (var i=0; i<this.choices.length; i++)
	{
		var choice = this.choices[i];
		if (choice.toLowerCase().substring(0,userEntry.length) == userEntry)
		{
			new Insertion.Bottom(this.choiceBox,"<div class='Choice' id='" + c + "Choice'>" + this.choices[i] + "</div>");
			var newDiv = this.choiceBox.lastChild;
			newDiv.onmouseover = function(e)
			{
				if (!e) e = window.event;
				var target = e.target || e.srcElement;
				dd.curChoice = parseInt(target.id);
				dd.UnHighlightAll();
				target.className = "CurrentChoice";
			}
			newDiv.onmouseout = function(e)
			{
				if (!e) e = window.event;
				var target = e.target || e.srcElement;
				target.className = "Choice";
			}
			c++;
		}
	}
	if (this.choiceBox.hasChildNodes())
	{	
		this.choiceBox.style.visibility = "visible";
	}
	else
	{
		this.choiceBox.style.visibility = "hidden";
	}
}